Simplified developers
If you use the existing version of EJB you will know how difficult it is to develop a simple EJB program such as HelloWorld. You need at least two interfaces, a bean class, and a deployment description file. Most developers want to know why I need all these. Ides (Development Environment Tools) Simply simplified developers' doing these ordinary work development cycles, but before the EJB is deployed, compiling classes and packaging deployments are still developing before you deployed to the selected container. Personnel work.
EJB3.0 attempts to simplify complexity from the following aspects:
· You don't have to define the interface and deployment description file, which can be generated by the container using Metadata Annotations.
· Use common Java classes as EJB classes and common EJB service interfaces.
Metadata Annotation
EJB3.0 is very relying on Metadata Annotations. Metadata Annotations has become a JSR 175 standard and will be part of J2SE 5.0. ANNOTATIONS is an object that is becoming an object, which is very similar to xDoclet. However, it is not necessary to pre-compile like XDoclet, and Annotations compiles when compiled by the Java compiler. (Depending on the start time of @Retrion). In the viewpoint of developers, Annotations is like a public and can be used as a class, domain, method, parameters, local variables, construction, enumeration, and packages. You can use ANNOTATIONS to generate code, automatically write document code, or provide special services such as enhancing business level security or special business logic during operation. J2EE1.5 (5.0) The goal is to simplify developers using Annotations so there is a set of Annotations templates. Annotations uses @ to mark as follows:
@Author ("Debu Panda")
@Bean
Public class mysessionBean
EJB3.0 In order to simplify the development therefore use Metadata Annotations to generate many people as interfaces, and use Annotations to replace deployment description files.
Use Pojos and Pojis
In specification conditions, JavaBeans and interfaces often relate to simple Java objects (Pojos) and simple Java interfaces (Pojis). These unnecessary people such as HOME interface have been removed.
Developers must implement an EJB interface (session bean, entity bean or message driver bean) in the Javax.ejb package, or select ANNOTATION in the implementation class of the bean. You can use a stateless, status, message driver, or entity to comment a bean class. For example, if you define a stateless EJB as a HelloWorld, you can define EJBs as follows:
@Remote
@StateLess Public Class HelloWorldbean {
Public String Sayhello (String S)
{System.out.println ("Hello:" s;}
}
EJB's interface does not have to realize EJBOBJECT and EJBLOCALOBJECT regardless of remote or local. You either serve the business interface for EJB and implement interfaces in the bean class, or you need to generate these interfaces when deploying. Although the interface of the session bean and the message-driven bean is required, the interface of the entity bean is optional. If you don't implement an interface for your session bean, it will automatically generate one for you. The generated interface is local or remote dependent on Annotations in the Bean class. If you take a closer look at the code paradigm above, @ transote is obviously used to generate a remote interface for your HelloWorld. If you need, you can generate remote and local interfaces in your EJB. In the example above, it is clear that developers do not have to do these ordinary work such as definition interfaces and rollback methods.
The name of the generated interface is derived from the name of the bean implementation class. The generated interface is very useful for developers. But I didn't see any of these IDEs such as Oracle's JDeveloper immediately implemented this generated interface function.
There is no clear demand for EJB when EJB lookups in the specification, and there is no identification of how we keep these EJBs need to call. Based on the following cases I will not recommend the generated interface:
· The name of the generated interface comes from the name of the bean
• If you don't want to expose some methods in EJB, you will expose all methods by default.
· You need to use the interface to call EJB on the client.
Remove the needs of the rollback method.
EJB2.1 and earlier versions require many ways to achieve some life cycles that you don't need for each EJB, such as EJBPassivate, EJBActivate, EjbLoad, EJBStore, and more. For example, there is no need for EJBPASSIVATE in the stateless session bean but you still have to implement it. The method of similar Java classes in EJB3.0 now achieves these life cycles are made into optional. These methods are called if you implement any rollup container in EJB.
The only exception is that the EJBRemove method for the business method of a state session bean when you can use Remove's Annotations is the status session bean. If you use this annotations it will remove the status session bean instance after completing the AnnotationS method (regardless of normal or abnormal) prompts. For example, you can specify the following way to remove a status session bean instance after the Checkout method is executed.
@Stateful public class cart {
...
...
@Remove public void checkout () {
...
}
}
Comparison of annotations and deployment descriptions
In the previous item, we will no longer need deployment description in EJB and by Annotations. The properties of each deployment will be selected for a default value, while the developers do not have to specify values for these attributes until they want to change the default values of these properties. These can also be used for the ANNOTATIONS used for the class of Beans itself. EJB3.0 Specifications For developers using bean type, interface type, resource reference, transaction attribute, security, etc. to define a set of Metadata Annotations. For example, if we can use the resource reference for a special EJB definition:
@Resource (name = "jdbc / oracleds", resourcetype = "javax.sql.datasource")
J2EE's providers such as Oracle, BEA, IBM will increase attribute Annotations In their specified deployment description, developers will be able to use these Annotations to avoid using deployment descriptions. This looks very attractive to developers, especially the XML description is a developer who already disgusted, and they have long hate and want to leave the old description of the old, but there are still some problems that make us officially use Annotations. Need to be cautious. It violates the goal of our light application, because if an EJB uses a provider specified deployment description, it must change multiple times when recompilating or packing EJB.
Deployment Description Provides a global view to the EJB template for assembly and deployment, you don't have to consider separate EJBs, and they are screwed together for each deployment requirement, and the description is invalid or not automatically generated before deployment. This is a terrible thing for deployers.
Deployment Description is used in the EJB template to define EJBs when you try to integrate one with another container is very useful. EJB3.0 specifications also advocate how to use overload ANNOTATIONS in the deployment description. However, there is no detail to overload annotations in the specification.
Undoubtedly getting rid of deployment, which will make new developers easier, but if it is improper use, this will also cause terrible issues.