MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 755

Developing coldfusion mx applications
Table of Contents

Advertisement

Name of the EJB, as registered with the naming service
Install the EJB home and component interface compiled classes on your ColdFusion web server,
3
either as class files in the web_root/WEB-INF/classes directory or packaged in a JAR file the
web_root/WEB-INF/lib directory.
Note: To use an EJB served by a JRUN server, your ColdFusion installation and the JRun server that
hosts the EJB must have the same version of the jrun.jar file (located in cf_root\runtime\lib directory in
ColdFusion).
While the specific steps for using an EJB depend on the EJB server and on the EJB itself, they
generally correspond to the following order:
To use an EJB:
Use the
tag to create an object of the JNDI naming context class
1
cfobject
(javax.naming.Context). You will use fields from this class to define the information that you
use to locate the EJB. Because you only use fields, you do not initialize the object.
Use the
tag to create a java.util.Properties class object that will contain the context
2
cfobject
object properties.
Call the
method to initialize the Properties object.
3
init
Set the Properties object to contain the properties that are required to create an initial JNDI
4
naming context. These include the INITIAL_CONTEXT_FACTORY and
PROVIDER_URL properties. You might also need to provide SECURITY_PRINCIPAL and
SECURITY_CREDENTIALS values required for secure access to the naming context. For
more information on these properties, see the JNDI documentation.
Use the
tag to create the JNDI InitialContext (javax.naming. InitialContext) object.
5
cfobject
Call the
method for the InitialContext object with the Properties object values to initialize
6
init
the object.
Call the InitialContextext object's
7
the bean that you want. Specify the JNDI name of the bean as the
Call the
method of the bean's home object to create a new instance of the bean. If you
8
create
are using Entity beans, you typically use a finder method instead. A finder method locates one
or more existing entity beans.
Now you can use the bean's methods as required by your application.
9
When finished, call the context object's
10
The following code shows this process using a simple Java Entity bean on a JRun 4.0 server. It
calls the bean's
getMessage
<html>
<head>
<title>cfobject Test</title>
</head>
<body>
<H1>cfobject Test</H1>
<!--- Create the Context object to get at the static fields. --->
<CFOBJECT
action=create
name=ctx
type="JAVA"
class="javax.naming.Context">
method to get a reference to the home interface for
lookup
method to close the object.
close
method to obtain a message.
argument.
lookup
Using Java objects
755

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion mx

Table of Contents