WebLogic Tuxedo Connector Programmer's Guide
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Note: You will need to perform some administration tasks to configure the WebLogic Tuxedo Connector for CORBA interoperability. For information on how to administer the WebLogic Tuxedo Connector for CORBA interoperability, see Administration of CORBA Applications.
For information on how to develop Tuxedo CORBA applications, see CORBA Programming.
The following sections provide information on how to modify your applications to use WebLogic Tuxedo Connector to support interoperability between WebLogic Server and Tuxedo CORBA objects:
Note: For more information on the WebLogic CORBA API implementation, see "Developing Clients for CORBA Objects".
The WebLogic Tuxedo Connector enables objects (such as EJBs or RMI objects) to invoke upon CORBA objects deployed in Tuxedo using the CORBA Java API (Outbound). This release of WebLogic Tuxedo Connector implements a new WTC ORB which uses WebLogic Server RMI-IIOP runtime and CORBA support. This enhancement provides the following features:
ORB orb = ORB.init(args, Prop);
To use CORBA Java API, you must use the WTC ORB. Use one of the following methods to obtain an ORB in your Bean:
Properties Prop;
Prop = new Properties();
Prop.put("org.omg.CORBA.ORBClass","weblogic.wtc.corba.ORB");
ORB orb = ORB.init(new String[0], Prop);
ORB orb = (ORB)(new InitialContext().lookup("java:comp/ORB"));
ORB orb = ORB.init();
You can use either of the following methods to reference objects deployed in Tuxedo:
Note: For more information on object references, see How to Use FederationURL Formats.
corbaloc:tgiop
or corbaname:tgiop
object reference. The following statements use the CosNaming service to get a reference to a Tuxedo CORBA Object:// Get the simple factory.
org.omg.CORBA.Object simple_fact_oref =
orb.string_to_object("corbaname:tgiop:simpapp#simple_factory");
simpapp
is the domain id of the Tuxedo domain specified in the Tuxedo UBB.simple_factory
is the name that the object reference was bound to in the Tuxedo CORBA CosNaming server.Note: For an example on how to develop client beans for outbound Tuxedo CORBA objects, see the SAMPLES_HOME\server\examples\src\examples\wtc\corba\simpappcns
package in your WebLogic Server examples distribution.
The following ToupperCorbaBean.java
code provides an example of how to call the WTC ORB and get an object reference using the COSNaming Service.
Listing 4-1 Example Service Application
.
.
.
public String Toupper(String toConvert)
throws RemoteException
{
log("toupper called, converting " + toConvert);
try {
// Initialize the ORB.
String args[] = null;
Properties Prop;
Prop = new Properties();
Prop.put("org.omg.CORBA.ORBClass",
"weblogic.wtc.corba.ORB");
ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB");
// Get the simple factory.
org.omg.CORBA.Object simple_fact_oref =
orb.string_to_object("corbaname:tgiop:simpapp#simple_factory");
//Narrow the simple factory.
SimpleFactory simple_factory_ref =
SimpleFactoryHelper.narrow(simple_fact_oref);
// Find the simple object.
Simple simple = simple_factory_ref.find_simple();
// Convert the string to upper case.
org.omg.CORBA.StringHolder buf =
new org.omg.CORBA.StringHolder(toConvert);
simple.to_upper(buf);
return buf.value;
}
catch (Exception e) {
throw new RemoteException("Can't call TUXEDO CORBA server: " +e);
}
}
.
.
.
Note: For more information on object references, see How to Use FederationURL Formats.
WebLogic Tuxedo Connector provides support for FactoryFinder objects using the find_one_factory_by_id method. This is accomplished by using a corbaloc:tgiop
or corbaname:tgiop
object reference. Use the following method to obtain the FactoryFinder object using the ORB:
// String to Object.
org.omg.CORBA.Object fact_finder_oref =
orb.string_to_object("corbaloc:tgiop:simpapp/FactoryFinder");
// Narrow the factory finder.
FactoryFinder fact_finder_ref =
FactoryFinderHelper.narrow(fact_finder_oref);
// Use the factory finder to find the simple factory.
org.omg.CORBA.Object simple_fact_oref =
fact_finder_ref.find_one_factory_by_id(SimpleFactoryHelper.id());
simpapp
is the domain id of the Tuxedo domain specified in the Tuxedo UBB.FactoryFinder
is the name that the object reference was bound to in the Tuxedo CORBA server.WLEC is deprecated in this release of WebLogic Server. WLEC uses should migrate their applications to WebLogic Tuxedo Connector. For more information, see WLEC to WebLogic Tuxedo Connector Migration Guide.
The following code provides an example of how to call the WTC ORB and get an object reference using FactoryFinder.
Listing 4-2 Example FactoryFinder Code
.
.
.
public ConverterResult convert (String changeCase, String mixed)
throws ProcessingErrorException
{
String result;
try {
// Initialize the ORB.
String args[] = null;
Properties Prop;
Prop = new Properties();
Prop.put("org.omg.CORBA.ORBClass","weblogic.wtc.corba.ORB");
ORB orb = (ORB)new InitialContext().lookup("java:comp/ORB");
org.omg.CORBA.Object fact_finder_oref =
orb.string_to_object("corbaloc:tgiop:simpapp/FactoryFinder");
// Narrow the factory finder.
FactoryFinder fact_finder_ref =
FactoryFinderHelper.narrow(fact_finder_oref);
// find_one_factory_by_id
org.omg.CORBA.Object simple_fact_oref =
fact_finder_ref.find_one_factory_by_id(FactoryFinderHelper.id());
// Narrow the simple factory.
SimpleFactory simple_factory_ref =
SimpleFactoryHelper.narrow(simple_fact_oref);
// Find the simple object.
Simple simple = simple_factory_ref.find_simple();
if (changeCase.equals("UPPER")) {
// Invoke the to_upper opeation on M3 Simple object
org.omg.CORBA.StringHolder buf =
new org.omg.CORBA.StringHolder(mixed);
simple.to_upper(buf);
result = buf.value;
}
else
{
result = simple.to_lower(mixed);
}
}
catch (org.omg.CORBA.SystemException e) {e.printStackTrace();
throw new ProcessingErrorException("Converter error: Corba system exception: " + e);
}
catch (Exception e) {
e.printStackTrace();
throw new ProcessingErrorException("Converter error: " + e);
}
return new ConverterResult(result);
}
.
.
.
Note: For more information on how to develop RMI/IIOP applications, see Programming WebLogic RMI.
RMI over IIOP (Internet Inter-ORB Protocol) extends RMI so that Java programs can interact with Common Object Request Broker Architecture (CORBA) clients and execute CORBA objects. The WebLogic Tuxedo Connector:
The following sections provide information on how to modify RMI/IIOP applications to use the WebLogic Tuxedo Connector to interoperate with Tuxedo CORBA applications:
A client must pass the correct name to which the WebLogic Server's name service has been bound to the COSNaming Service.
The following code provides an example for obtaining a naming context. "WLS" is the bind name specified in the cnsbind
command detailed in the Administration of CORBA Applications.
Listing 4-3 Example Code to Obtain a Naming Context
.
.
.
// obtain a naming context
TP::userlog("Narrowing to a naming context");
CosNaming::NamingContext_var context =
CosNaming::NamingContext::_narrow(o);
CosNaming::Name name;
name.length(1);name[0].id = CORBA::string_dup("WLS");
name[0].kind = CORBA::string_dup("");
.
.
.
An EJB must use a FederationURL to obtain the initial context used to access a remote Tuxedo CORBA object. Use the following sections to modify outbound RMI/IIOP applications to use the WebLogic Tuxedo Connector:
The following code provides an example of how to configure an ejb-jar.xml
file to pass a FederationURL format to the EJB at run-time.
Listing 4-4 Example ejb-jar.xml File Passing a FederationURL to an EJB
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<small-icon>images/green-cube.gif</small-icon>
<enterprise-beans>
<session>
<small-icon>images/orange-cube.gif</small-icon>
<ejb-name>IIOPStatelessSession</ejb-name>
<home>examples.iiop.ejb.stateless.TraderHome</home>
<remote>examples.iiop.ejb.stateless.Trader</remote>
<ejb-class>examples.iiop.ejb.stateless.TraderBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry>
<env-entry-name>foreignOrb</env-entry-name>
<env-entry-type>java.lang.String </env-entry-type>
<env-entry-value>corbaloc:tgiop:simpapp</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>WEBL</env-entry-name>
<env-entry-value>10.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>INTL</env-entry-name>
<env-entry-type>java.lang.Double </env-entry-type>
<env-entry-value>15.0</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>tradeLimit</env-entry-name>
<env-entry-type>java.lang.Integer </env-entry-type>
<env-entry-value>500</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>IIOPStatelessSession</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
To pass the FederationURL to the EJB at run-time, add an env-entry
for the EJB in the ejb-jar.xml
file for your application. You must assign the following env-entry
sub-elements:
The env-entry-name
element is used to specify the name of the variable used to pass the value in the env-entry-value
element to the EJB. The example code shown in Listing 4-4 specifies the env-entry-name
as foreignOrb
.
The env-entry-type
element is used to specify the data type (example String, Integer, Double) of the env-entry-value
element that is passed to the EJB. The example code shown in Listing 4-4 specifies that the foreignOrb
variable passes String
data to the EJB.
The env-entry-value
element is used to specify the data that is passed to the EJB. The example code shown in Listing 4-4 specifies that the foreignOrb
variable passes the following FederationURL format to the EJB:
corbaloc:tgiop:simpapp
Where simpapp
is the DOMAINID
of the Tuxedo remote service specified in the Tuxedo UBB.
This section provides information on how to use the FederationURL to obtain the InitialContext used to access a remote Tuxedo CORBA object.
The following code provides an example of how to use FederationURL to get an InitialContext.
Listing 4-5 Example TraderBean.java Code to get InitialContext
.
.
.
public void createRemote() throws CreateException {
log("createRemote() called");
try {
InitialContext ic = new InitialContext();
// Lookup a EJB-like CORBA server in a remote CORBA domain
Hashtable env = new Hashtable();
catch (NamingException ne) {
env.put(Context.PROVIDER_URL, (String)
ic.lookup("java:/comp/env/foreignOrb")
+ "/NameService");
InitialContext cos = new InitialContext(env);
TraderHome thome =
(TraderHome)PortableRemoteObject.narrow(
cos.lookup("TraderHome_iiop"),TraderHome.class);
remoteTrader = thome.create();
}
throw new CreateException("Failed to find value "+ne);
}
catch (RemoteException re) {
throw new CreateException("Error creating remote ejb "+re);
}
}
.
.
.
Use the following steps to use FederationURL to obtain an InitialContext for a remote Tuxedo CORBA object:
"ic.lookup("java:/comp/env/foreignOrb")
The example code shown in Listing 4-4 specifies that the foreignOrb
variable passes the following FederationURL format to the EJB:
This section provides information on the syntax for the following FederationURL formats:
CORBA URL
syntax is described in the CORBA specification. For more information, see the OMG Web Site at http://www.omg.org/.corbaloc:tgiop
form is specific to the BEA tgiop protocol.This section provides the syntax for corbaloc URL format:
<corbaloc> = "corbaloc:tgiop":[<version>] <domain>["/"<key_string>]
<version> = <major> "." <minor> "@" | empty_string
<domain> = TUXEDO CORBA domain name
<major> = number
<minor> = number
<key_string> = <string> | empty_string
This section provides examples on how to use corbaloc:tgiop
orb.string_to_object("corbaloc:tgiop:simpapp/NameService");
orb.string_to_object("corbaloc:tgiop:simpapp/FactoryFinder");
orb.string_to_object("corbaloc:tgiop:simpapp/InterfaceRepository");
orb.string_to_object("corbaloc:tgiop:simpapp/Tobj_SimpleEventsService");
orb.string_to_object("corbaloc:tgiop:simpapp/NotificationService");
orb.string_to_object("corbaloc:tgiop:1.1@simpapp/NotificationService);
You can also use the -ORBInitRef
option to orb.init
and resolve_initial_reference
.
Given the following -ORBInitRef
definitions:
-ORBInitRef FactoryFinder=corbaloc:tgiop:simp/FactoryFinder
-ORBInitRef InterfaceRepository=corbaloc:tgiop:simp/InterfaceRepository
-ORBInitRef Tobj_SimpleEventService=corbaloc:tgiop:simp/Tobj_SimpleEventsService
-ORBInitRef NotificationService=corbaloc:tgiop:simp/NotificationService
orb.resolve_initial_references("NameService");
orb.resolve_initial_references("FactoryFinder");
orb.resolve_initial_references("InterfaceRepository");
orb.resolve_initial_references("Tobj_SimpleEventService");
orb.resolve_initial_references("NotificationService");
You can use the -ORBDefaultInitRef
and resolve_initial_reference
.
Given the following -ORBDefaultInitRef
definition:
-ORBDefaultInitRef corbaloc:tgiop:simpapp
orb.resolve_initial_references("NameService");
You can also use the corbaname
format instead of the corbaloc
format.
Given the following -ORBInitRef
definition:
-ORBInitRef NameService=corbaloc:tgiop:simpapp/NameService
then:
orb.string_to_object("corbaname:rir:#simple_factory");
orb.string_to_object("corbaname:tgiop:simpapp#simple_factory");
orb.string_to_object("corbaname:tgiop:1.1@simpapp#simple_factory");
orb.string_to_object("corbaname:tgiop:simpapp#simple/simple_factory");
Note: For more information on managing transactions in Tuxedo CORBA applications, see Overview of Transactions in BEA Tuxedo CORBA Applications.
The WebLogic Tuxedo Connector uses the Java Transaction API (JTA) to manage transactions with Tuxedo Corba Applications. For more detailed information, see:
![]() ![]() |
![]() |
![]() |