azizkhani.net

I know that I know nothing

How does @RequestParam in Spring handle Optional?

clock December 31, 2014 20:04 by author Administrator
@RequestMapping("foo")
@ResponseBody
public String foo(@RequestParam(required =false) final Optional name){
return"name: "+(name ==null?"null": name.get());
}


Hibernate exception _$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy

clock December 23, 2014 22:18 by author Administrator

hibernate 4.3.7 using javasssist new version and oracle weblogic older than that version for solve this problem will add this configuration to weblogic.xml

<wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>javassist</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>



@Autowired and static method

clock December 23, 2014 16:09 by author Administrator

@Component
public class Boo {

    private static Foo foo;

    @Autowired
    public Boo(Foo foo) {
        Boo.foo = foo;
    }

    public static void randomMethod() {
         foo.doStuff();
    }
}


@Component
public class Boo {

    private static Foo foo;
    @Autowired
    private Foo tFoo;

    @PostConstruct
    public void init() {
        Boo.foo = tFoo;
    }

    public static void randomMethod() {
         foo.doStuff();
    }
}



To see the number of process for a user run this

clock November 25, 2014 21:46 by author Administrator

To see the number of process for a user run this (replacing [user] with the username):

 

ps -eLF -u[user] | wc -l


install maven in mac os

clock November 14, 2014 20:55 by author Administrator

brew install maven



YAML

clock November 14, 2014 20:26 by author Administrator

 

YAML is a superset of JSON, and as such is a very convenient format for specifying hierarchical configuration data

 

traditional





@Platform and @Qualifier

clock November 11, 2014 22:23 by author Administrator

@Autowired
private MarketPlace marketPlaces;


@Autowired
@Qualifier( "ios") // the use is unique to Spring. It's darned convenient, too!
 private MarketPlace marketPlaces;



and now jsr 330




package spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static spring.Spring.Platform;

@Configuration
@ComponentScan
public class Spring {

    public static void main(String[] args) {
        new AnnotationConfigApplicationContext(Spring.class);
    }

    @Autowired
 @Platform(Platform.OperatingSystems.ANDROID)
    private MarketPlace android;

    @Autowired
 @Platform(Platform.OperatingSystems.IOS)
    private MarketPlace ios;

    @PostConstruct
    public void qualifyTheTweets() {
        System.out.println("ios:" + this.ios);
        System.out.println("android:" + this.android);
    }

    // the type has to be public!
    @Target({ElementType.FIELD,
            ElementType.METHOD,
            ElementType.TYPE,
            ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @Qualifier
    public static @interface Platform {

        OperatingSystems value();

        public static enum OperatingSystems {
            IOS,
            ANDROID
        }
    }
}

interface MarketPlace {
}

@Component
@Platform(Platform.OperatingSystems.IOS)
class AppleMarketPlace implements MarketPlace {

    @Override
    public String toString() {
        return "apple";
    }
}

@Component
@Platform(Platform.OperatingSystems.ANDROID)
class GoogleMarketPlace implements MarketPlace {

    @Override
    public String toString() {
        return "android";
    }
}


Hibernate: Version-Based Optimistic Concurrency Control

clock November 11, 2014 22:17 by author Administrator

Optimistic locking discards all incoming changes that are relative to an older entity version. But everything has a cost and optimistic locking makes no difference.

The optimistic concurrency control mechanism takes an all-or-nothing approach even for non-overlapping changes. If two concurrent transactions are changing distinct entity property subsets then there’s no risk of losing updates.

Two concurrent updates, starting from the same entity version are always going to collide. It’s only the first update that’s going to succeed, the second one failing with an optimistic locking exception. This strict policy acts as if all changes are overlapping. For highly concurrent write scenarios, this single-version check strategy can lead to a large number of roll-backed updates.

optimisticlockingoneproductentityoneversion

 

http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/optimisticlockingonerootentityoneversion1.png



https problem (Error code: ssl_error_no_cypher_overlap) in firefox

clock November 11, 2014 20:19 by author Administrator

go to about:config

 

You can check the ssl and tls prefs on the about:config page.

 

 

 



Open multiple Eclipse workspaces on the Mac

clock November 9, 2014 21:29 by author Administrator

OS X Eclipse Launcher 2.0.0 plugin

http://marketplace.eclipse.org/content/osx-eclipse-launcher#.VF-r4S9ZLVR

 


About the author

 Welcome to this web site . This page has two purposes: Sharing information about my professional life such as articles, presentations, etc.
This website is also a place where I would like to share content I enjoy with the rest of the world. Feel free to take a look around, read my blog


Java,J2EE,Spring Framework,JQuery,

Hibernate,NoSql,Cloud,SOA,Rest WebService and Web Stack tech...

RecentPosts

Month List

Sign In