Search in sources :

Example 1 with ORBSingleton

use of com.sun.corba.se.impl.orb.ORBSingleton in project wildfly by wildfly.

the class CorbaORBService method start.

@Override
public void start(StartContext context) throws StartException {
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    }
    try {
        // set the ORBClass and ORBSingleton class as system properties.
        properties.setProperty(Constants.ORB_CLASS, ORBImpl.class.getName());
        properties.setProperty(Constants.ORB_SINGLETON_CLASS, ORBSingleton.class.getName());
        WildFlySecurityManager.setPropertyPrivileged(Constants.ORB_CLASS, ORBImpl.class.getName());
        WildFlySecurityManager.setPropertyPrivileged(Constants.ORB_SINGLETON_CLASS, ORBSingleton.class.getName());
        properties.setProperty(ORBConstants.IOR_TO_SOCKET_INFO_CLASS_PROPERTY, CSIV2IORToSocketInfo.class.getName());
        // set the IIOP and IIOP/SSL ports from the respective socket bindings.
        if (this.iiopSocketBindingInjector.getValue() != null) {
            InetSocketAddress address = this.iiopSocketBindingInjector.getValue().getSocketAddress();
            properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress());
            properties.setProperty(ORBConstants.SERVER_PORT_PROPERTY, String.valueOf(address.getPort()));
            properties.setProperty(ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, String.valueOf(address.getPort()));
        }
        if (this.iiopSSLSocketBindingInjector.getOptionalValue() != null) {
            InetSocketAddress address = this.iiopSSLSocketBindingInjector.getValue().getSocketAddress();
            properties.setProperty(Constants.ORB_SSL_PORT, String.valueOf(address.getPort()));
            final String sslSocket = new StringBuilder().append(Constants.SSL_SOCKET_TYPE).append(':').append(String.valueOf(address.getPort())).toString();
            properties.setProperty(ORBConstants.LISTEN_SOCKET_PROPERTY, sslSocket);
            if (!properties.containsKey(Constants.ORB_ADDRESS)) {
                properties.setProperty(Constants.ORB_ADDRESS, address.getAddress().getHostAddress());
            }
        }
        // initialize the ORB - the thread context classloader needs to be adjusted as the ORB classes are loaded via reflection.
        ClassLoader loader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(WildFlySecurityManager.getClassLoaderPrivileged(this.getClass()));
            this.orb = ORB.init(new String[0], properties);
            // initialize the ORBSingleton.
            ORB.init();
        } finally {
            // restore the thread context classloader.
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(loader);
        }
        // start the ORB in a separate thread.
        Thread orbThread = SecurityActions.createThread(new ORBRunner(this.orb), "ORB Run Thread");
        orbThread.start();
        // bind the ORB to JNDI under java:/jboss/ORB.
        ServiceTarget target = context.getChildTarget();
        CorbaServiceUtil.bindObject(target, "ORB", this.orb);
    } catch (Exception e) {
        throw new StartException(e);
    }
    CorbaUtils.setOrbProperties(properties);
    IIOPLogger.ROOT_LOGGER.corbaORBServiceStarted();
}
Also used : ORBImpl(com.sun.corba.se.impl.orb.ORBImpl) InetSocketAddress(java.net.InetSocketAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) StartException(org.jboss.msc.service.StartException) CSIV2IORToSocketInfo(org.wildfly.iiop.openjdk.csiv2.CSIV2IORToSocketInfo) ORBSingleton(com.sun.corba.se.impl.orb.ORBSingleton) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) StartException(org.jboss.msc.service.StartException)

Aggregations

ORBImpl (com.sun.corba.se.impl.orb.ORBImpl)1 ORBSingleton (com.sun.corba.se.impl.orb.ORBSingleton)1 InetSocketAddress (java.net.InetSocketAddress)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 StartException (org.jboss.msc.service.StartException)1 CSIV2IORToSocketInfo (org.wildfly.iiop.openjdk.csiv2.CSIV2IORToSocketInfo)1