|
CORBA UTILITY
______________________
|
BEA WebLogic Enterprise (Formarly BEA M3)
for C++
_________________________________________________________
|
BEA WebLogic Enterprise (Formarly BEA M3)
for Java
______________________________________________________
|
VISIBROKER (*)
for Java
________________________________________________
|
Sun's Java 2 Platform
CORBA Package
_________________________________________________________
|
Sun's Java 2 Platform
RMI
_________________________________________________________ |
| IDL Compiler |
idl [options] idl-filename [icf-filename]
where:
-
options may be -i, to generate implementation files and/or
-T to generate tie class templates for the interfaces in a WLE application.
-
idl-filename represents the name of your application's OMG
IDL file.
-
icf-filename is an optional parameter that represents the
name of your application's Implementation Configuration File (ICF file)
|
m3idltojava |
idl2java |
idltojava |
rmic |
| Admininistation and Other Utilities: |
-
buildobjserver: compiles and links Server applications.
buildobjserver [-o servername] [options] [-o servername] represents the
name of the server and [options] represent command line options.
-
buildobjclient: combines the client stubs for interfaces
that use static invocation and associated header files with M3 libraries
to form client executables.
-
genicf moduleName.idl : generates moduleName.icf
file used for???
-
tmloadcf: Creates the TUXCONFIG file, a binary file
for the WebLogic Enterprise Domain.
-
tmboot: Used to boot-up the Enterprise Domain
and/or part of the domain.
-
tmadmin: Used to administer the Enterprise Domain.
|
-
buildjavaserver : Creates a JAR file containing your
Java server class files; also creates a server descriptor file (SER).
-
buildXAJS: For applications that use an XA-compliant
resource manager, creates an XA-specific version of the Java Server.
-
For building java client applications, include m3envobj.jar
file in CLASSPATH. m3envobj.jar contains Java classes for M3
environmental objects.
-
tmloadcf: Creates the TUXCONFIG file, a binary
file for the WebLogic
-
Enterprise domain specifies the configuration of your server
application.
-
tmadmin: Used to administer the Enterprise Domain.
|
OSAgent: Smart Agent that perfoms the work of
registry.
vbj: Used to start up the servers and clints. |
javac: java compiler
tnameserv:starts the name server.
java : to start the java VM. |
rmic: rmi compiler
registry: Starts a registry server |
| Output from IDL Compiler |
-
Client stub file: application_c.cpp: Contains
generated code for sending a request.
-
Client stub header file: application_c.h: Contains
class definitions for each interface and type specified in the OMG
IDL file.
-
Skeleton file: application_s.cpp: Contains
skeletons for each interface specified in the OMG IDL file. The skeleton
maps client requests to the appropriate operation in the server application
during run time.
-
Skeleton header file: application_s.h:
Contains the skeleton class definitions.
-
Implementation file: application_i.cpp:
Contains signatures for the methods that implement the operations on the
interfaces specified in the OMG IDL file.
-
Implementation header file: application_i.h:
Contains the initial class definitions for each interface specified
in the OMG IDL file.
Further steps:
-
Edit your object implementation files, adding the business
logic to each object's methods.
-
Create the Server object, which is code that performs the
initialize and release functions for the server application.
-
Use the buildobjserver/ buildobjclent utilities to compile
the server / client aplications into executables. (See sample codes showing
the process flow of a server and client.)
|
-
Base interface class file: interface.java:
Contains an implementation of the interface, written in Java. You
need to copy this file to create a new file and add your business logic
to the new file. By convention name this file interfaceImpl.java, substituting
the actual name of the interface in the file name.
-
Client stub file: _interfaceStub.java:
Contains generated code for sending a request.
-
Server skeleton file: _interfaceImplBase.java:
Contains Java skeletons for each interface specified in the OMG IDL
file. The skeleton maps client requests to the appropriate operation
in the Java server application during run time.
-
Holder class file: interfaceHolder.java:
Contains the implementation of the Holder class. The Holder class provides
operations for out and inout arguments, which CORBA has, but which do not
map exactly to Java.
-
Helper class file: interfaceHelper.java:
Contains the implementation of the Helper class. The Helper class provides
auxiliary functionality, notably the narrow method.
Further steps:
-
Edit your object implementation files, adding the business
logic to each object's methods.
-
Create the Server object, which is code that performs the
initialize and release functions for the server application.
-
Use the javac compiler to compile all the *.java files into
Java bytecodes (*.class files).
|
-
Client stub file: interface.java:
-
Client implementation file: _InterfaceImplBase.java
-
Server skeleton file: _st_interface.java
-
Server implementation file: _interfaceImplBase.java
-
Helper classes: interfaceHelper.java: containing
utilities
-
Holder classes: interfaceHolder.java: Provids
a holder for passing parameters.
-
Tie Classes: _tie_interface.java: A
tie class is used to tie up an existing java class, with an interface that
is CORBA compliant.
|
-
_InterfaceNameImplBase.java : This abstract
class is the server skeleton, providing basic CORBA functionality for the
server. It implements the InterfaceName.java interface. The server class
InterfaceNameServant extends _InterfaceNameImplBase.
-
_InterfaceNameStub.java : This class is the client
stub, providing CORBA functionality for the client. It implements the InterfaceName.java
interface.
-
InerfaceName.java : This interface contains
the Java version of our IDL interface. It contains the single method doSomething().
The InterfaceName.java interface extends org.omg.CORBA.Object, providing
standard CORBA object functionality as well.
-
InterfaceNameHelper.java : This final class provides
auxiliary functionality, notably the narrow() method required to cast CORBA
object references to their proper types.
-
InterfaceNameHolder.java : This final class holds
a public instance member of type Hello. It provides operations for out
and inout arguments, which CORBA has but which do not map easily to Java's
semantics.
|
(TBD) |
| Application Server Startup Procedure |
-
Prepare ubbconfig file. The ubbfile of M3 has the same structure
that is used for Tuxedo UBBCONFIG File, without
services section and with interface section.
-
Compile UBBCONFIG File using tmloadcf
-
Start up all servers using tmboot
|
-
Create a text file called a Server Description File, which
is expressed in the XML language.
-
In your Server Description File, you assign the activation
and transaction policies for the interfaces implemented in your server
application. This XML file also contains a server declaration, which includes
the name of the Server object and the name of the server descriptor
file (SER). You can also identify the Java class files that comprise the
server application's Java Archive (JAR) file.
-
Compile the XML-based Server Description File with the buildjavaserver
command and generate the SER file and JAR file.
-
Deploy your Java server application.
|
-
Start Smart Agent using OSAgent
-
Start Server using vbj Server
-
Start Client using vbj Client
|
-
Start Name Server using : tnameserv -ORBInitialPort 8080
-
Start Server using : java someServer -ORBInitialPort 8080
-
Run Client application using : java aClient -ORBInitialPort
8080
|
(TBD) |
IDL File Contents
( Modules attributes and Interfaces) |
module ModuleName
{
attribute Long
aLong;
interface InterfaceName
{
float operationName();
};
};
Module is mapped to Namespace
Interface is mapped to class
Operation is mapped to member function |
module ModuleName
{
attribute Short nShort;
interface InterfaceName
{
float operationName();
};
};
Module is mapped to package
Interface is mapped to class
Operation is mapped to method of the class. |
module ModuleName
{
attribute Short nShort;
interface InterfaceName
{
float operationName();
};
};
Module is mapped to package
Interface is mapped to class
Operation is mapped to method of the class. |
module ModuleName
{
attribute Long aLong;
interface InterfaceName
{
string doSomething();
};
};
Module is mapped to package
Interface is mapped to class
Operation is mapped to method of the class. |
RMI is not CORBA Compliant, but has the similar
architecture that of Corba Product like registry and name service. Here
the communication is between java applications only.
|
| ORB Initialisation |
(TBD) |
orb = org.omg.CORBA.ORB.init(args, null) |
orb = org.omg.CORBA.ORB.init(args, null) |
orb = org.omg.CORBA.ORB.init(args, null) |
(TBD) |
| Locate Business Object Reference |
(TBD) |
manager = Bank.AccountManagerHelper.bind(orb,"BankManger") |
manager = Bank.AccountManagerHelper.bind(orb,"BankManger") |
(TBD) |
(TBD) |
| Class Hierarchy |
(TBD) |
(TBD) |
class org.omg.CORRBA.protable.Skeleton
(provided with VisiBroker)
abstract class Back._AccountManagerImplBase
(generated by idl2java)
interface bank.AccountManager
(generated by idl2java)
class AccountManagerImpl
(written by programmer and used by server) |
(TBD) |
(TBD) |
| Typical Structure of a Server Application |
Server has 3 major functions as follows:
CORBA::Boolean Server::initialize(int argc, char**
argv)
{
// Create and register factories
University::RegistrarFactory
s_v_fact_ref =
TP::create_object_reference(
University::_tc_RegistrarFactory->id(),
object_id,
CORBA::NVList::_nil()
);
TP::register_factory (CORBA::Object_ptr
factory_or,
const char* factory_id);
// OR ???
//TP::register_factory(s_v_fact_ref.in(),
//
University::_tc_RegistrarFactory->id());
// Allocate any machine resources
//Initialize global variables
needed by the server application
//Open databases used by server
application
//Open XA resource manager
}
Tobj_Servant Server::create_servant(const char*
interfaceName)
{
/// ????
if (!strcmp(intf_repos_id,
University::_tc_RegistrarFactory->id())) {
return new RegistrarFactory_i();
}
if (!strcmp(intf_repos_id,
University::_tc_Registrar->id())) {
return new Registrar_i();
}
if (!strcmp(intf_repos_id,
University::_tc_CourseSynopsisEnumerator->id())) {
return new CourseSynopsisEnumerator_i();
}
return 0; // unknown
interface
}
void Server::release()
{
// Perform any application-specific
cleanup task
// Unregister object factories
TP::unregister_factory (CORBA::Object_ptr
factory_or,
const char* factory_id)
// OR ???
//TP::unregister_factory(s_v_fact_ref.in(),
// UnivB::_tc_RegistrarFactory
-> id());
// Deallocating resources
// Close databases
// Close XA resource manager
} |
(TBD) |
// Server.java
public class Server {
public statc void main(String[] args)
{
// Initialize the ORB.
org.omg.CORBA.ORB
orb = org.omg.CORBA.ORB.init(args, null);
// Initialize
the Basic Object Adapter (BOA).
org.omg.CORBA.BOA
boa = orb.BOA.init();
// Create
the account manager object.
Bank.AccountManager
manager = new AccountManagerImpl("Dallas");
// Export
the newly created object.
boa.obj_is_ready(manager);
System.out.println(manager
+ " is ready!");
// Wait for
incoming requests
boa.impl_is_ready();
}
} |
// Server.java
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class Server {
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// create servant and register it with the ORB
HelloServant helloRef = new HelloServant();
orb.connect(helloRef);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Narrow the reference using the helper class
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// Bind the Object Reference in Naming
// Note: rebind() needs array of Namecomponents.
NameComponent nc = new NameComponent("Hello", "");
NameComponent path[] = {nc};
ncRef.rebind(path, helloRef);
// wait for invocations from clients
java.lang.Object sync = new java.lang.Object();
synchronized (sync) {
sync.wait();
}
} catch (Exception
e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
} |
(TBD |
| Implemeting Transaction Management???: |
1. Generate ICF File using:
genicf university.idl
This generates the file university.icf.
2. Edit the ICF file generated:
module POA_UniversityB
{
implementation
CourseSynopsisEnumerator_i
{
activation_policy ( method );
transaction_policy ( optional );
implements ( UniversityB::CourseSynopsisEnumerator );
};
};
3. You can limit the number of interfaces for which you
want skeleton and implementation files generated, you can remove from the
ICF file the implementation blocks that implement those interfaces.
4.Pass the ICF file to the IDL compiler to generate
the skeleton and implementation files that correspond to the specified
policies.
Step 5: Compile and link the server application. |
(TBD) |
(TBD) |
(TBD) |
(TBD |
| Typical Structure of a Client Application |
// Initialize the ORB
CORBA::ORB_var orb_ptr = CORBA::ORB_init(argc,
argv, ORBid);
// Create a Bootstrap object to establish
communication
// with the WLE domain (Note: List
of IIOP Listener/Handlers
// can also be specified in TOBJADDR
environmental variable)
Tobj_Bootstrap* bootstrap = new Tobj_Bootstrap(orb_ptr,
"//host:port");
//Get a FactoryFinder object,
use it to find a Moderator factory,
// and get a Moderator.
//Use the Bootstrap object to
find the FactoryFinder object
CORBA::Object_var
var_factory_finder_oref =
bootstrap-> resolve_initial_references
("FactoryFinder");
// Use the factory finder to get a
factory
var_factory_finder_oref = var_factory_finder_oref
.find_one_factory_by_id(ModuleName::_tc_InterfaceName::id);
//Narrow the FactoryFinder object
Tobj::FactoryFinder_var
var_factory_finder_ref =
Tobj :: FactoryFinder
:: _narrow ( var_factory_finder_oref.in());
//Use the FactoryFinder object
to find a factory for the Moderator
CORBA::Object_var
var_moderator_factory_oref =
var_factory_finder->find_one_factory_by_id("ModeratorFactory"
);
//Narrow the Moderator Factory
ChatRoom::ModeratorFactory_var
var_moderator_factory =
ChatRoom::ModeratorFactory::_narrow(var_moderator_factory_oref.in());
//Get a Moderator
//The chatroom name is passed
as a command line parameter
var_moderator_oref = var_moderator_factory->get_moderator
(var_chat_room_name.in() ); |
// Initialize the ORB
org.omg.CORBA::ORB orb = org.omg.CORBA.ORB.init(args,
props);
// Create a Bootstrap object to establish communication
// with the WLE domain
Tobj_Bootstrap bootstrap = new
Tobj_Bootstrap(orb_ptr, "//host:port");
//Resolve Factory Finder
org.omg.CORBA.Object off = bootstrap.resolve_initial_references("FactoryFinder");
// Use the factory finder to get a factory
org.omg.CORBA.Object of = FactoryFinder.
find_one_factory_by_id(ModuleName::_tc_InterfaceName::id);
//Narrow the object
ModuleName.InerfaceName iobj = ModuleName.InterfaceName.
narrow ( var_factory_finder_oref.in());
|
// Client.java
public class Client
{
public statc void main(String[] args)
{
// Initialize the ORB.
org.omg.CORBA.ORB
orb =
org.omg.CORBA.ORB.init(args, null);
// Locate
an account manager.
Bank.AccountManager
manager =
Bank.AccountManagerHelper.bind(orb, "Dallas");
// Export the
newly created object.
boa.obj_is_ready(manager);
System.out.println(manager
+ " is ready!");
// Wait for
incoming requests
boa.impl_is_ready();
}
} |
// HelloClient.java
import HelloApp.*;
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
public class HelloClient
{
public static void main(String args[])
{
try
{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get the naming context called "NameService"
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// Resolve the Object Reference
NameComponent nc = new NameComponent("Hello", "");
NameComponent path[] = {nc};
// Use resolve() to retrieve an object bound to a name in given
//context.
Hello helloRef = HelloHelper.narrow(ncRef.resolve(path));
// call the Hello server object and print results
String hello = helloRef.sayHello();
System.out.println(hello);
}
catch (Exception
e)
{
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
} |
(TBD |