Search in sources :

Example 11 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class GlassFishTldProvider method postConstruct.

@Override
public void postConstruct() {
    URI[] uris = null;
    Module module = registry.find(Version.class);
    if (module != null) {
        uris = module.getModuleDefinition().getLocations();
    } else {
        ClassLoader classLoader = getClass().getClassLoader();
        if (classLoader instanceof URLClassLoader) {
            URL[] urls = ((URLClassLoader) classLoader).getURLs();
            if (urls != null && urls.length > 0) {
                uris = new URI[urls.length];
                for (int i = 0; i < urls.length; i++) {
                    try {
                        uris[i] = urls[i].toURI();
                    } catch (URISyntaxException e) {
                        logger.log(WARNING, format(resourceBundle.getString(TLD_PROVIDER_IGNORE_URL), urls[i]), e);
                    }
                }
            }
        } else {
            logger.log(WARNING, UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { "JSTL", classLoader, GlassFishTldProvider.class.getName() });
        }
    }
    if (uris != null && uris.length > 0) {
        Pattern pattern = compile("META-INF/.*\\.tld");
        for (URI uri : uris) {
            List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
            if (entries != null && entries.size() > 0) {
                tldMap.put(uri, entries);
            }
        }
    }
}
Also used : JarURIPattern(com.sun.enterprise.util.net.JarURIPattern) Pattern(java.util.regex.Pattern) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL) TLD_PROVIDER_IGNORE_URL(org.glassfish.web.loader.LogFacade.TLD_PROVIDER_IGNORE_URL) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Module(com.sun.enterprise.module.Module)

Example 12 with Module

use of com.sun.enterprise.module.Module 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)

Example 13 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class ASClassLoaderUtil method getModulesClasspath.

private static synchronized String getModulesClasspath(ServiceLocator habitat) {
    synchronized (ASClassLoaderUtil.class) {
        if (modulesClassPath == null) {
            final StringBuilder tmpString = new StringBuilder();
            ModulesRegistry mr = habitat.getService(ModulesRegistry.class);
            if (mr != null) {
                for (Module module : mr.getModules()) {
                    for (URI uri : module.getModuleDefinition().getLocations()) {
                        tmpString.append(uri.getPath());
                        tmpString.append(File.pathSeparator);
                    }
                }
            }
            // set shared classpath for module so that it doesn't need to be
            // recomputed for every other invocation
            modulesClassPath = tmpString.toString();
        }
    }
    return modulesClassPath;
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) Module(com.sun.enterprise.module.Module) URI(java.net.URI)

Example 14 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class RuntimeRootImpl method stopDomain.

public void stopDomain() {
    final ModulesRegistry registry = InjectedValues.getInstance().getModulesRegistry();
    final Collection<Module> modules = registry.getModules("com.sun.enterprise.osgi-adapter");
    if (modules.size() == 1) {
        final Module mgmtAgentModule = modules.iterator().next();
        mgmtAgentModule.stop();
    } else {
        AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.cantFindOSGIAdapter);
    }
    AMXLoggerInfo.getLogger().warning(AMXLoggerInfo.stoppingServerForcibly);
    System.exit(0);
}
Also used : ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) Module(com.sun.enterprise.module.Module)

Example 15 with Module

use of com.sun.enterprise.module.Module in project Payara by payara.

the class ListModulesCommand method execute.

public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    report.setActionDescription("List of modules");
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ActionReport.MessagePart top = report.getTopMessagePart();
    top.setMessage("List Of Modules");
    top.setChildrenType("Module");
    StringBuilder sb = new StringBuilder("Module Status Report Begins\n");
    for (Module m : registry.getModules()) {
        if (m.getState() == ModuleState.READY) {
            sb.append(m).append("\n");
        }
    }
    sb.append("\n");
    // then resolved
    for (Module m : registry.getModules()) {
        if (m.getState() == ModuleState.RESOLVED) {
            sb.append(m).append("\n");
        }
    }
    sb.append("\n");
    // finally installed
    for (Module m : registry.getModules()) {
        if (m.getState() != ModuleState.READY && m.getState() != ModuleState.RESOLVED) {
            sb.append(m).append("\n");
        }
    }
    sb.append("Module Status Report Ends");
    ActionReport.MessagePart childPart = top.addChild();
    childPart.setMessage(sb.toString());
}
Also used : ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.module.Module)

Aggregations

Module (com.sun.enterprise.module.Module)16 JarURIPattern (com.sun.enterprise.util.net.JarURIPattern)4 URI (java.net.URI)4 Pattern (java.util.regex.Pattern)4 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)2 ActionReport (org.glassfish.api.ActionReport)2 EngineInfo (org.glassfish.internal.data.EngineInfo)2 CacheTag (com.sun.appserv.web.taglibs.cache.CacheTag)1 InitialGroupInfoService (com.sun.corba.ee.impl.folb.InitialGroupInfoService)1 Application (com.sun.enterprise.config.serverbeans.Application)1 Config (com.sun.enterprise.config.serverbeans.Config)1 Engine (com.sun.enterprise.config.serverbeans.Engine)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1