Oracle8i CORBA Developer's Guide and Reference Release 3 (8.1.7) Part Number A83722-01 |
|
This example demonstrates how to use the TIE mechanism.
Overview ======== This is a CORBA TIE (delegation) implementation of the helloworld example. See the readme for that example for more information. It uses the _initializeAuroraObject() method to return a class delegate, rather than the object itself. Source files ============ hello.idl ------------ (See the helloworld example readme file.) Client.java ----------- (See the helloworld example readme file.) helloServer/HelloImpl.java -------------------------- Implements the IDL-specified Hello interface. The interface has one method, helloWorld(), that returns a String to the caller. Note that the class definition *implements* the IDL-generated HelloOperations interface, rather than extending _HelloImplBase, as in the helloworld example. The class also implements the Aurora ActivateableObject interface. ActivatableObject has only one method: _initializeAuroraObject(), which returns the class to be activated by the BOA. This class performs no database access. Client-side output ================== The client prints the returned String "Hello World!" and then exits immediately. Compiling and Running the Example ================================= UNIX ---- Enter the command 'make all' or simply 'make' in the shell to compile, load, and deploy the objects, and run the client program. Other targets are 'run' and 'clean'. Make sure that a shell environment variable ORACLE_HOME is set to point to the home location of the Oracle installation. This is operating system dependent, so see the Installation documentation that came with your system for the location. Also, review the README file for the Oracle database, and the README file for the CORBA/EJB server (the Oracle8i ORB), for additional up-to-date information. Windows NT ---------- On Windows NT, run the batch file makeit.bat from a DOS command prompt to compile, load, and deploy the objects. Run the batch file runit.bat to run the client program, and see the results. Make sure that the environment variables %ORACLE_HOME%, %CLASSPATH%, and %SERVICE% are set appropriately for the DOS command window. You can set these as either user or system environment variables from the Control Panel. Double click on System in the Control Panel then on the Environment tab to set these variables. Start a new DOS window after setting environment variable values. See the Installation documentation that came with your Oracle8i system for the values of these variables. Also, review the README file for the Oracle database, and the README file for the CORBA/EJB server (the Oracle8i ORB), for additional up-to-date information. You can also set an environment variable %JAVA_HOME% to point to the root of your Java JDK. For example, SET JAVA_HOME=C:\JDK1.1.6.
module hello { interface Hello { wstring helloWorld (); }; };
package helloServer; import hello.*; import oracle.aurora.AuroraServices.ActivatableObject; public class HelloImpl implements HelloOperations, ActivatableObject { public String helloWorld () { return "Hello World!"; } public org.omg.CORBA.Object _initializeAuroraObject () { return new _tie_Hello (this); } }
import hello.Hello; import oracle.aurora.jndi.sess_iiop.ServiceCtx; import javax.naming.Context; import javax.naming.InitialContext; import java.util.Hashtable; public class Client { public static void main (String[] args) throws Exception { if (args.length != 4) { System.out.println ("usage: Client serviceURL objectName user password"); System.exit (1); } String serviceURL = args [0]; String objectName = args [1]; String user = args [2]; String password = args [3]; Hashtable env = new Hashtable (); env.put (Context.URL_PKG_PREFIXES, "oracle.aurora.jndi"); env.put (Context.SECURITY_PRINCIPAL, user); env.put (Context.SECURITY_CREDENTIALS, password); env.put (Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN); Context ic = new InitialContext (env); Hello hello = (Hello)ic.lookup (serviceURL + objectName); System.out.println (hello.helloWorld ()); } }
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|