12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Embedding VisiClient Container functionality into an existing application<br />

To run the J2EE client using the appclient:<br />

1 Set the PATH to appclient.exe and JDK.<br />

2 Edit the appclient.config to change JAVA_HOME, and lib PATH.<br />

3 Run the J2EE client from /client.<br />

Embedding VisiClient Container functionality into an existing<br />

application<br />

As an alternative to deploying and running a client application in the VisiClient<br />

container, it is possible to use a programmatic approach to embed the client container's<br />

functionality into an existing application. In this case, the client application can be<br />

started in a common Java fashion by running a class implementing the main() method.<br />

To embed the VisiClient container functionality into your application, you need to call<br />

the following method:<br />

public static void com.borland.appclient.Container.init<br />

(java.io.InputStream deploymentDescriptorSun,<br />

java.io.InputStream deploymentDescriptor<strong>Borland</strong>)<br />

throws IllegalArgumentException;<br />

This method will create and populate the “java:comp/env” naming context based on the<br />

information provided in the pair of Sun and <strong>Borland</strong> deployment descriptors. The<br />

deploymentDescriptorSun and deploymentDescriptor<strong>Borland</strong> parameters must represent<br />

text XML data corresponding to the deployment descriptors. An<br />

IllegalArgumntException exception is thrown if the data provided is not recognized as a<br />

valid deployment descriptor.<br />

Note<br />

Sample code<br />

This example shows usage of this method:<br />

public static void main (String[] args) {<br />

. . .<br />

// load deployment descriptor files<br />

java.io.FileInputStream ddSun = new<br />

java.io.FileInputStream("META-INF/application-client.xml");<br />

java.io.FileInputStream dd<strong>Borland</strong> = new<br />

java.io.FileInputStream("META-INF/application-client-borland.xml");<br />

// initialize client container<br />

com.borland.appclient.Container.init(ddSun, dd<strong>Borland</strong>);<br />

// lookup ejb in JNDI using an ejb-ref<br />

javax.naming.Context context = new javax.naming.InitialContext();<br />

Object ref = context.lookup ("java:comp/env/ejb/hello");<br />

. . .<br />

}<br />

Only application client descriptors can be loaded using this method. This means that all<br />

ejb-refs must be resolved or located by specifying the jndi-name in the <strong>Borland</strong><br />

descriptor. This cannot be done using the ejb-link in the Sun descriptor since using ejblink<br />

requires complete knowledge of the whole application including application and<br />

EJB JAR deployment descriptors.<br />

Chapter 12: The VisiClient Container 103

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

Saved successfully!

Ooh no, something went wrong!