Posts filed under 'Uncategorized'
Migrating from EJB 2.x to EJB 3
J2se 6 is full of annotations , which makes developer just to tag in their application.
Migration from ejb 2.x to 3 its not at all difficult task i belive, a simple annotaions makes your application more easy and look beautiful for a developer…..
Developing an application prior to ejb 3.0 was an nightmare…
- Creating Home Interface,
- Creating Remote Interface(Business Mehods)
- Creating Bean Class, or Session Bean..
- Twiking Deplyoment Discriptor
- JNDI LookUp
But you can find lots of changes in EJB 3.0 . the spec says
- There is no concept of remote and home interfaces, and only one interface is defined: the “business interface,” which is a POJI (Plain Old Java Interface). Whether this interface is local or remote can also be indicated by annotations.
- The client may get a reference using annotations and dependency injection.
- The business interfaces are annotated using
@Remoteand@Localannotations. - Deployment descriptors are optional
- JNDI lookups are no longer necessary
Implementing a Bean whether statefull or stateless can be done also using annotations.
no need of implementing sessionbean interface and writing vanilla life cycle methods , you need to implement just business Interface,
you can refer to Click here
Add comment February 5, 2007
Static factory methods vs Java collection API
Some of the features like searching, sorting, shuffling, immutability etc are achieved with java.util.Collections class and java.util.Arrays utility classes. The great majority of these implementations are provided via static factory methods in a single, non-instantiable (i.e. private constrctor) class. Speaking of static factory methods, they are an alternative to creating objects through constructors. Unlike constructors, static factory methods are not required to create a new object (i.e. a duplicate object) each time they are invoked (i.e. immutable instances can be cached) and also they have a more meaningful names.
For example to print an array, instead of looping through, you could write something like this.
String[] myArray = {“A”,”B”, “C”};
System.out.println(Arrays.asList(myArray));
What are some of the best practices relating to Java collection?
Use ArrayLists, HashMap etc as opposed to Vector, Hashtable etc, where possible to avoid any synchronization overhead. Even better is to use just arrays where possible. If multiple threads concurrently access a collection and at least one of the threads either adds or deletes an entry into the collection, then the collection must be externally synchronized
Program in terms of interface not implementation: For example you might decide a LinkedList is the best choice for some application, but then later decide ArrayList might be a better choice for performance reason.
Use:
List list = new ArrayList(100); // program in terms of interface & set the initial capacity.
Instead of:
ArrayList list = new ArrayList();
Add comment February 5, 2007
