web server - Borland Technical Publications

web server - Borland Technical Publications web server - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
12.11.2014 Views

Getting information about an enterprise bean UserTransaction.rollback() to rollback and end the transaction). In between, the client does its queries and updates. This code sample shows the code that a client would implement to manage its own transactions. The parts that pertain specifically to client-managed transactions are highlighted in bold. ... import javax.naming.InitialContext; import javax.transaction.UserTransaction; ... public class clientTransaction { public static void main (String[] argv) { UserTransaction ut = null; InitialContext initContext = new InitialContext(); ... ut = (UserTransaction)initContext.lookup("java:comp/UserTransaction"); // start a transaction ut.begin(); // do some transaction work ... // commit or rollback the transaction ut.commit(); // or ut.rollback(); ... ] ] Getting information about an enterprise bean Information about an enterprise bean is referred to as metadata. A client can obtain metadata about a bean using the enterprise bean's home interface getMetaData() method. The getMetaData() method is most often used by development environments and tool builders that need to discover information about an enterprise bean, such as for linking together beans that have already been installed. Scripting clients might also want to obtain metadata on the bean. Once the client retrieves the home interface reference, it can call the getEJBMetaData() method on the home interface. Then, the client can call the EJBMetaData interface methods to extract such information as: ■ ■ ■ ■ ■ ■ The bean's EJBHome home interface, using EJBMetaData.getEJBHome(). The bean's home interface class object, including its interfaces, classes, fields, and methods, using EJBMetaData.getHomeInterfaceClass(). The bean's remote interface class object, including all class information, using EJBMetaData.getRemoteInterfaceClass(). The bean's primary key class object, using EJBMetaData.getPrimaryKeyClass(). Whether the bean is a session bean or an entity bean, using EJBMetaData.isSession(). The method returns true if this is a session bean. Whether a session bean is stateless or stateful, using EJBMetaData.isStatelessSession(). The method returns true if the session bean is stateless. Chapter 11: Writing enterprise bean clients 91

Support for JNDI Support for JNDI The EJB specification defines the JNDI API for locating home interfaces. JNDI is implemented on top of other services, including CORBA's Naming Service, LDAP/ X.500, flat files, and proprietary directory services. The diagram below illustrates the different implementation choices. Typically, the EJB server provider selects a particular implementation of JNDI. Figure 11.1 JNDI implementation EJB to CORBA mapping The technology implemented beneath JNDI is of no concern to the client. The client needs to use only the JNDI API. There are a number of aspects to the relationship between CORBA and Enterprise JavaBeans. Three important ones are the implementation of an EJB container/server with an ORB, the integration of legacy systems into an EJB middle tier, and the access of enterprise beans from non-Java components, specifically clients. The EJB specification is currently only concerned with the third aspect. CORBA is a very suitable and natural platform on which to implement an EJB infrastructure. CORBA addresses all of the concerns of the EJB specification with the CORBA Core specification or the CORBA Services: ■ ■ Support for distribution. CORBA Core and CORBA Naming Service Support for transactions. CORBA Object Transaction Service ■ Support for security. CORBA Security Specification, including IIOP-over-SSL Additionally, CORBA allows the integration of non-Java components into an application. These components can be legacy systems and applications, plus different kinds of clients. Back-end systems can be easily integrated using OTS and any programming language for which an IDL mapping exists. This requires an EJB container to provide OTS and IIOP APIs. The EJB specification is concerned with the accessibility of enterprise beans from non- Java clients and provides an EJB to CORBA mapping. The goals of the EJB/CORBA mapping are: ■ ■ ■ Supporting interoperability between clients written in any CORBA-supported programming language and enterprise beans running on a CORBA-based EJB server. Enabling client programs to mix and match calls to CORBA objects and enterprise beans within the same transaction. Supporting distributed transactions involving multiple enterprise beans running on CORBA-based EJB servers provided by different vendors. 92 BES Developer’s Guide

Support for JNDI<br />

Support for JNDI<br />

The EJB specification defines the JNDI API for locating home interfaces. JNDI is<br />

implemented on top of other services, including CORBA's Naming Service, LDAP/<br />

X.500, flat files, and proprietary directory services. The diagram below illustrates the<br />

different implementation choices. Typically, the EJB <strong>server</strong> provider selects a particular<br />

implementation of JNDI.<br />

Figure 11.1<br />

JNDI implementation<br />

EJB to CORBA mapping<br />

The technology implemented beneath JNDI is of no concern to the client. The client<br />

needs to use only the JNDI API.<br />

There are a number of aspects to the relationship between CORBA and Enterprise<br />

JavaBeans. Three important ones are the implementation of an EJB container/<strong>server</strong><br />

with an ORB, the integration of legacy systems into an EJB middle tier, and the access<br />

of enterprise beans from non-Java components, specifically clients. The EJB<br />

specification is currently only concerned with the third aspect.<br />

CORBA is a very suitable and natural platform on which to implement an EJB<br />

infrastructure. CORBA addresses all of the concerns of the EJB specification with the<br />

CORBA Core specification or the CORBA Services:<br />

■<br />

■<br />

Support for distribution. CORBA Core and CORBA Naming Service<br />

Support for transactions. CORBA Object Transaction Service<br />

■<br />

Support for security. CORBA Security Specification, including IIOP-over-SSL<br />

Additionally, CORBA allows the integration of non-Java components into an<br />

application. These components can be legacy systems and applications, plus different<br />

kinds of clients. Back-end systems can be easily integrated using OTS and any<br />

programming language for which an IDL mapping exists. This requires an EJB<br />

container to provide OTS and IIOP APIs.<br />

The EJB specification is concerned with the accessibility of enterprise beans from non-<br />

Java clients and provides an EJB to CORBA mapping. The goals of the EJB/CORBA<br />

mapping are:<br />

■<br />

■<br />

■<br />

Supporting interoperability between clients written in any CORBA-supported<br />

programming language and enterprise beans running on a CORBA-based EJB<br />

<strong>server</strong>.<br />

Enabling client programs to mix and match calls to CORBA objects and enterprise<br />

beans within the same transaction.<br />

Supporting distributed transactions involving multiple enterprise beans running on<br />

CORBA-based EJB <strong>server</strong>s provided by different vendors.<br />

92 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!