Search in sources :

Example 1 with GlassFishORBLifeCycleListener

use of org.glassfish.enterprise.iiop.api.GlassFishORBLifeCycleListener in project Payara by payara.

the class GlassFishORBManager method initORB.

private void initORB(Properties props) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, ".initORB->: ");
        }
        setORBSystemProperties();
        Properties orbInitProperties = new Properties();
        orbInitProperties.putAll(props);
        orbInitProperties.put(ORBConstants.APPSERVER_MODE, "true");
        // The main configurator.
        orbInitProperties.put(ORBConstants.USER_CONFIGURATOR_PREFIX + PEORB_CONFIG_CLASS, "dummy");
        setFOLBProperties(orbInitProperties);
        // Standard OMG Properties.
        String orbDefaultServerId = DEFAULT_SERVER_ID;
        if (!processType.isServer()) {
            orbDefaultServerId = ACC_DEFAULT_SERVER_ID;
        }
        orbDefaultServerId = System.getProperty(USER_DEFINED_ORB_SERVER_ID_PROPERTY, orbDefaultServerId);
        orbInitProperties.put(ORBConstants.ORB_SERVER_ID_PROPERTY, orbDefaultServerId);
        orbInitProperties.put(OMG_ORB_CLASS_PROPERTY, ORB_CLASS);
        orbInitProperties.put(ORBConstants.PI_ORB_INITIALIZER_CLASS_PREFIX + GLASSFISH_INITIALIZER, "");
        orbInitProperties.put(ORBConstants.ALLOW_LOCAL_OPTIMIZATION, "true");
        orbInitProperties.put(ORBConstants.GET_SERVICE_CONTEXT_RETURNS_NULL, "true");
        orbInitProperties.put(ORBConstants.ORB_ID_PROPERTY, S1AS_ORB_ID);
        orbInitProperties.put(ORBConstants.SHOW_INFO_MESSAGES, "true");
        // Do this even if propertiesInitialized, since props may override
        // ORBInitialHost and port.
        String initialPort = checkORBInitialPort(orbInitProperties);
        String orbInitialHost = checkORBInitialHost(orbInitProperties);
        String[] orbInitRefArgs;
        if (System.getProperty(IIOP_ENDPOINTS_PROPERTY) != null && !System.getProperty(IIOP_ENDPOINTS_PROPERTY).isEmpty()) {
            orbInitRefArgs = getORBInitRef(System.getProperty(IIOP_ENDPOINTS_PROPERTY));
        } else {
            // Add -ORBInitRef for INS to work
            orbInitRefArgs = getORBInitRef(orbInitialHost, initialPort);
        }
        // can be used.  Actual lazy init setup takes place in PEORBConfigurator
        if (processType.isServer()) {
            validateIiopListeners();
            orbInitProperties.put(ORBConstants.NO_DEFAULT_ACCEPTORS, "true");
            // 14734893 - IIOP ports don't bind to the network address set for the cluster instance
            // GLASSFISH-17469   IIOP Listener Network Address Setting Ignored
            checkORBServerHost(orbInitProperties);
        }
        checkConnectionSettings(orbInitProperties);
        checkMessageFragmentSize(orbInitProperties);
        checkServerSSLOutboundSettings(orbInitProperties);
        checkForOrbPropertyValues(orbInitProperties);
        Collection<GlassFishORBLifeCycleListener> lcListeners = iiopUtils.getGlassFishORBLifeCycleListeners();
        List<String> argsList = new ArrayList<String>();
        argsList.addAll(Arrays.asList(orbInitRefArgs));
        for (GlassFishORBLifeCycleListener listener : lcListeners) {
            listener.initializeORBInitProperties(argsList, orbInitProperties);
        }
        String[] args = argsList.toArray(new String[argsList.size()]);
        if (processType.isServer()) {
            PEORBConfigurator.setThreadPoolManager();
        }
        // orb MUST be set before calling getFVDCodeBaseIOR, or we can
        // recurse back into initORB due to interceptors that run
        // when the TOA supporting the FVD is created!
        // DO NOT MODIFY initORB to return ORB!!!
        /**
         * we can't create object adapters inside the ORB init path,
         * or else we'll get this same problem in slightly different ways.
         * (address in use exception) Having an IORInterceptor
         * (TxSecIORInterceptor) get called during ORB init always
         * results in a nested ORB.init call because of the call to getORB
         * in the IORInterceptor.i
         */
        // TODO Right now we need to explicitly set useOSGI flag.  If it's set to
        // OSGI mode and we're not in OSGI mode, orb initialization fails.
        boolean useOSGI = false;
        ClassLoader prevCL = Utility.getClassLoader();
        try {
            Utility.setContextClassLoader(GlassFishORBManager.class.getClassLoader());
            if (processType.isServer()) {
                Module corbaOrbModule = null;
                // start glassfish-corba-orb bundle
                ModulesRegistry modulesRegistry = services.getService(ModulesRegistry.class);
                for (Module m : modulesRegistry.getModules()) {
                    if (m.getName().equals("glassfish-corba-orb")) {
                        corbaOrbModule = m;
                        break;
                    }
                }
                if (corbaOrbModule != null) {
                    useOSGI = true;
                    corbaOrbModule.start();
                }
            }
        } finally {
            Utility.setContextClassLoader(prevCL);
        }
        // Can't run with GlassFishORBManager.class.getClassLoader() as the context ClassLoader
        orb = ORBFactory.create();
        prevCL = Utility.getClassLoader();
        try {
            if (processType != processType.Other && !prevCL.getClass().getName().contains("OSGi")) {
                Utility.setContextClassLoader(prevCL.getParent());
            }
            ORBFactory.initialize(orb, args, orbInitProperties, useOSGI);
        } finally {
            Utility.setContextClassLoader(prevCL);
        }
        // needs to create listen ports.
        try {
            org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
        } catch (org.omg.CORBA.ORBPackage.InvalidName in) {
            logger.log(Level.SEVERE, "Problem resolving RootPOA ORB reference", in);
        }
        if (processType.isServer()) {
            // This MUST happen before new InitialGroupInfoService,
            // or the ServerGroupManager will get initialized before the
            // GIS is available.
            gmsClient.setORB(orb);
            // J2EEServer's persistent server port is same as ORBInitialPort.
            orbInitialPort = getORBInitialPort();
            for (GlassFishORBLifeCycleListener listener : lcListeners) {
                listener.orbCreated(orb);
            }
            // TODO: The following statement can be moved to
            // some GlassFishORBLifeCycleListeners
            rfm = (ReferenceFactoryManager) orb.resolve_initial_references(ORBConstants.REFERENCE_FACTORY_MANAGER);
            // ensure we don't inherit any Context Class Loaders when bootstrapping
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            new InitialGroupInfoService(orb);
            Thread.currentThread().setContextClassLoader(cl);
            iiopUtils.setORB(orb);
        }
        // SeeBeyond fix for 6325988: needs testing.
        // Still do not know why this might make any difference.
        // Invoke this for its side-effects: ignore returned IOR.
        orb.getFVDCodeBaseIOR();
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "UTIL6009:Unexpected Exception in createORB.", ex);
        throw new RuntimeException(ex);
    } finally {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, ".initORB<-: ");
        }
    }
}
Also used : GlassFishORBLifeCycleListener(org.glassfish.enterprise.iiop.api.GlassFishORBLifeCycleListener) ArrayList(java.util.ArrayList) Properties(java.util.Properties) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) InitialGroupInfoService(com.sun.corba.ee.impl.folb.InitialGroupInfoService) Module(com.sun.enterprise.module.Module)

Aggregations

InitialGroupInfoService (com.sun.corba.ee.impl.folb.InitialGroupInfoService)1 Module (com.sun.enterprise.module.Module)1 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 GlassFishORBLifeCycleListener (org.glassfish.enterprise.iiop.api.GlassFishORBLifeCycleListener)1