* Resource: www.foshanshop.net in ejb3.pdf tutorial ....
1. EJB-Enterprise Java Bean. EJB is a Java-based component specification launched by Sun, one of the OMG members. The component is a reusable software component, and is headed by DCOM/COM, which is headed by Microsoft, from DDE, Ole
ActiveX provides the basis for component development,
2. Use JBoss (support for EJB. If Tomcat also supports EJB, You have to copy some jar packages to Tomcat.
/Shared/LIB) Environment jboss_home E:/jboss4 (JBoss installation directory) SRC class put under the "JBoss installation directory/Server/default/deploy/" directory, JBoss supports hot deployment ,*. jar will be discovered and deployed automatically. Copy my. War to the "JBoss installation directory/Server/default/deploy. Enter http: // localhost: 8080/My/index. jsp in the browser.
3. the deployment process in JBoss is very simple and straightforward. In every configuration, JBoss constantly scans
Special directory changes: [JBoss installation directory]/Server/config-name/deploy this directory is generally "deployment directory ". You can copy the following files to this directory: * any jar Library (the classes will be automatically added to the JBoss classpath) * EJB jar * war (webappliction arrchive) * ear (enterpriseapplication archive) * contains the XML file defined by jbossmbean * contains the decompressed content of ejbjar, war, or ear, and uses. jar ,. war or. end with ear
. To redeploy any of the above files (jar, war, ear, XML, etc.), use the new version to overwrite
Previous. JBoss detects changes based on the time when the files are compared, and then deploys new files. To redeploy a directory, update it
.
4. enterprisejavabean (EJB) defines three enterprise beans: Session Bean, Entity Bean, and messagedrivenbean ).
5. how to package enterprise applications? A complete enterprise application contains the EJB module and web module. When releasing an enterprise application, we need to compress it *. the ear file must be configured in the package. XML file, which is stored in the packaged META-INF directory. In application. in the XML file, you must specify the information of the EJB module and the web module, an application. xml configuration example: <application xmlns = "http://java.sun.com/xml/ns/j2ee" version = "1.4" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> <display-Name> ejb3sampleapplication </display-Name> <module> <web-Uri> Web. war </Web-Uri> <context-roo T> Web </context-root> </Web> </module> <EJB> ejb3.jar </EJB> </module> </Application> <web> specify the web module, <EJB> You can specify multiple EJB modules, including the web module and EJB module. Regardless of the packaging method you use, the directory structure of an enterprise application after packaging should be as follows: ear application root directory | -- ejb3.jar (your EJB module) | -- web. war (your web module) | -- META-INF | -- manifest. mf (this file is automatically generated by the tool if it is packaged using a tool) | -- application. XML
6.
Because the client needs to search for EJB through JNDI, What Is JNDI?
JNDI (thejavanaminganddirectoryinterface, Java Naming and Directory Interface) is a set
For Java applications
API. It provides developers with a universal and unified way to search for and access various naming and directory services.
With the interfaces provided by JNDI
Locate users, machines, networks, and object services by name.
Naming Service: Like DNS, most J2EE servers provide services through naming servers.
All contain naming servers.
Directory Service: A simplified RDBMS system that stores some simple information through the properties of the directory.
. The directory service is implemented through the Directory Server,
For example, Microsoft ActiveDirectory.
Benefits of JNDI:
(1) it contains a large number of naming and directory services. You can use the same API call to access any name or Directory Server.
Service.
(2) Multiple naming and directory services can be connected at the same time.
(3) Allow the name to be associated with a Java object or resource without having to know the physical ID of the object or resource
.
(4) use common interfaces to access different types of directory services
(5) enables developers to centrally use and implement a type of naming or directory service customer API
.
JNDI Programming process
Since JNDI is a set of interfaces, we only need to program according to interface specifications. Enter
For row resource access, we must set the initial
Context parameters are mainly used to set the class name (Java. Naming. Factory. Initial) and
URL for Naming Service
(Java. Naming. provider. URL ). Because there are many JNDI implementation products. So
The value of Java. Naming. Factory. Initial is provided by the JNDI server.
Java. Naming. provider. url values include the host address that provides the Naming Service and
The port number.
The following is the access to the JBoss Server
Propeties props = new properties ();
Props. setproperty
("Java. Naming. Factory. Initial", "org. jnp. Interfaces. namingcontextfactory ");
Props. setproperty ("Java. Naming. provider. url", "localhost: 1099 "):
Initialcontext-New initialcontext (props );
Helloworld = (helloworld) cxt. Lookup (helloworldbean/remote ");
The following is an example code used to access the weblogic10 Application Server:
Propeties props = new properties ();
Props. setproperty
("Java. Naming. Factory. Initial", "weblogic. JNDI. wlinitialcontextfactory ");
Props. setproperty ("Java. Naming. provider. url", "T3: // localhost: 7001 "):
Initialcontext-New initialcontext (props );
Helloworld = (helloworld) cxt. Lookup (helloworldbean/remote ");