A ConfigAdapter instance for the Apache Yoko
CORBA support.
Method from org.apache.geronimo.yoko.ORBConfigAdapter Detail: |
public ORB createClientORB(CSSBean client) throws ConfigException {
return createORB(client.getURI(), client, translateToArgs(client), translateToProps(client));
}
Create an ORB for a CSSBean client context. |
public Object createNameService(String host,
int port) throws ConfigException {
try {
// create a name service using the supplied host and publish under the name "NameService"
TransientNameService service = new TransientNameService(host, port, "NameService") {
public void run() throws TransientServiceException {
// Create an ORB object
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBServerId", "1000000" ) ;
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
props.put("yoko.orb.oa.endpoint", "iiop --bind " + host + " --host " + host + " --port " + port );
createdOrb = ORB.init((String[])null, props) ;
// now initialize the service
initialize(createdOrb);
}
};
service.run();
log.debug("Creating ORB endpoint with host=" + host + ", port=" + port);
// the service instance is returned as an opaque object.
return service;
} catch (TransientServiceException e) {
throw new ConfigException("Error starting transient name service on port " + port, e);
}
}
Create a transient name service instance using the
specified host name and port. |
public ORB createNameServiceClientORB(CSSBean client) throws ConfigException {
return createORB(client.getURI(), client, translateToArgs(client), translateToNameServiceProps(client));
}
Create an ORB for a CSSBean name service client context. |
public ORB createServerORB(CORBABean server) throws ConfigException {
ORB orb = createORB(server.getURI(), server, translateToArgs(server), translateToProps(server));
// check the tss config for a transport mech definition. If we have one, then
// the port information will be passed in that config, and the port in the IIOP profile
// needs to be zero.
TSSConfig config = server.getTssConfig();
TSSTransportMechConfig transportMech = config.getTransport_mech();
if (transportMech != null) {
if (transportMech instanceof TSSSSLTransportConfig) {
Any any = orb.create_any();
any.insert_boolean(true);
try {
Policy portPolicy = orb.create_policy(ZERO_PORT_POLICY_ID.value, any);
Policy[] overrides = new Policy [] { portPolicy };
server.setPolicyOverrides(overrides);
} catch (org.omg.CORBA.PolicyError e) {
// shouldn't happen, but we'll let things continue with no policy set.
}
}
}
return orb;
}
Create an ORB for a CORBABean server context. |
public void destroyNameService(Object ns) {
// The name service instance handles its own shutdown.
((TransientNameService)ns).destroy();
}
Destroy a name service instance created by a
prior call to createNameService(). |
public void doFail() {
// nothing much to do.
log.warn("Failed Yoko ORBConfigAdapter");
}
|
public void doStart() throws Exception {
// define the default ORB for ORB.init();
System.setProperty("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
// redirect the RMI implementation to use the Yoko ORB.
System.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass", "org.apache.yoko.rmi.impl.PortableRemoteObjectImpl");
System.setProperty("javax.rmi.CORBA.StubClass", "org.apache.yoko.rmi.impl.StubImpl");
// this hooks the util class and allows us to override certain functions
System.setProperty("javax.rmi.CORBA.UtilClass", "org.apache.geronimo.corba.util.UtilDelegateImpl");
// this tells the openejb UtilDelegateImpl which implementation to delegate non-overridden
// operations to.
System.setProperty("org.apache.geronimo.corba.UtilDelegateClass", "org.apache.yoko.rmi.impl.UtilImpl");
// this allows us to hook RMI stub invocation/serialization events.
System.setProperty("org.apache.yoko.rmi.RMIStubInitializerClass", "org.apache.geronimo.yoko.RMIStubHandlerFactory");
// ok, now we have a potential classloading problem because of where our util delegates are located.
// by forcing these classes to load now using our class loader, we can ensure things are properly initialized
Class clazz = this.getClass().getClassLoader().loadClass("javax.rmi.PortableRemoteObject");
Method m = clazz.getMethod("narrow", Object.class, Class.class);
m.invoke(null, new Object(), Object.class);
log.debug("Started Yoko ORBConfigAdapter");
}
Start the config adapter GBean. This is basically
an opportunity to set any system properties
required to make the ORB hook ups. In particular,
this makes the ORB hookups for the RMI over IIOP
support. |
public void doStop() throws Exception {
// nothing really required here.
log.debug("Stopped Yoko ORBConfigAdapter");
}
|