Search in sources :

Example 1 with ServerEnvironmentImpl

use of org.glassfish.server.ServerEnvironmentImpl in project Payara by payara.

the class ActiveJmsResourceAdapter method getBrokerInstanceName.

public static String getBrokerInstanceName(JmsService js) {
    ServerEnvironmentImpl serverenv = Globals.get(ServerEnvironmentImpl.class);
    Domain domain = Globals.get(Domain.class);
    String asInstance = serverenv.getInstanceName();
    String domainName = null;
    if (isClustered()) {
        Server server = domain.getServerNamed(asInstance);
        domainName = server.getCluster().getName();
    /*ClusterHelper.getClusterForInstance(
                            ApplicationServer.getServerContext().getConfigContext(),
                            asInstance).getName();*/
    } else {
        // ServerManager.instance().getDomainName();
        domainName = serverenv.getDomainName();
    }
    String s = getBrokerInstanceName(domainName, asInstance, js);
    if (_logger.isLoggable(Level.FINE))
        logFine("Got broker Instancename as " + s);
    String converted = convertStringToValidMQIdentifier(s);
    if (_logger.isLoggable(Level.FINE))
        logFine("converted instance name " + converted);
    return converted;
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) Server(com.sun.enterprise.config.serverbeans.Server) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 2 with ServerEnvironmentImpl

use of org.glassfish.server.ServerEnvironmentImpl in project Payara by payara.

the class DomainRootImpl method getUptimeMillis.

public Object[] getUptimeMillis() {
    final ServerEnvironmentImpl env = InjectedValues.getInstance().getServerEnvironment();
    final long elapsed = System.currentTimeMillis() - env.getStartupContext().getCreationTime();
    final Duration duration = new Duration(elapsed);
    return new Object[] { elapsed, duration.toString() };
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) Duration(com.sun.enterprise.universal.Duration)

Example 3 with ServerEnvironmentImpl

use of org.glassfish.server.ServerEnvironmentImpl in project Payara by payara.

the class ConnectorMessageBeanClient method getActivationName.

/**
 * {@inheritDoc}
 * @Override
 */
public String getActivationName() {
    if (activationName == null) {
        String appName = descriptor_.getApplication().getName();
        String moduleID = descriptor_.getEjbBundleDescriptor().getModuleID();
        int pound = moduleID.indexOf("#");
        if (pound >= 0) {
            // the module ID is in the format: appName#ejbName.jar
            // remove the appName part since it is duplicated
            moduleID = moduleID.substring(pound + 1);
        }
        String mdbClassName = descriptor_.getEjbClassName();
        ServerEnvironmentImpl env = Globals.get(ServerEnvironmentImpl.class);
        String instanceName = env.getInstanceName();
        Domain domain = Globals.get(Domain.class);
        String domainName = domain.getName();
        Cluster cluster = domain.getServerNamed(instanceName).getCluster();
        String clusterName = null;
        if (cluster != null) {
            // this application is deployed in a cluster
            clusterName = cluster.getName();
        }
        if (clusterName != null) {
            // this application is deployed in a cluster
            activationName = combineString(domainName, clusterName, appName, moduleID, mdbClassName);
        } else {
            // this application is deployed in a stand-alone server instance.
            activationName = combineString(domainName, instanceName, appName, moduleID, mdbClassName);
        }
    }
    return activationName;
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) Cluster(com.sun.enterprise.config.serverbeans.Cluster) Domain(com.sun.enterprise.config.serverbeans.Domain) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Example 4 with ServerEnvironmentImpl

use of org.glassfish.server.ServerEnvironmentImpl in project Payara by payara.

the class AppServerStartupTest method initialize.

// ----- test initialization ---------------------------------------------
private void initialize(ServiceLocator testLocator) {
    DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
    DynamicConfiguration config = dcs.createDynamicConfiguration();
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new TestSystemTasks()));
    // These are services that would normally be started by hk2 core
    config.addActiveDescriptor(AppServerStartup.AppInstanceListener.class);
    AbstractActiveDescriptor<?> descriptor = BuilderHelper.createConstantDescriptor(new TestModulesRegistry());
    descriptor.addContractType(ModulesRegistry.class);
    config.addActiveDescriptor(descriptor);
    descriptor = BuilderHelper.createConstantDescriptor(new ExecutorServiceFactory().provide());
    descriptor.addContractType(ExecutorService.class);
    config.addActiveDescriptor(descriptor);
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new ServerEnvironmentImpl()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new EventsImpl()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new Version()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new StartupContext()));
    config.bind(BuilderHelper.link(RunLevelControllerImpl.class).to(RunLevelController.class).build());
    config.addUnbindFilter(BuilderHelper.createContractFilter(RunLevelContext.class.getName()));
    config.bind(BuilderHelper.link(RunLevelContext.class).to(Context.class).in(Singleton.class).build());
    config.addUnbindFilter(BuilderHelper.createContractFilter(AsyncRunLevelContext.class.getName()));
    config.bind(BuilderHelper.link(AsyncRunLevelContext.class).in(Singleton.class).build());
    config.bind(BuilderHelper.link(AppServerStartup.class).build());
    descriptor = BuilderHelper.createConstantDescriptor(testLocator);
    descriptor.addContractType(ServiceLocator.class);
    config.addActiveDescriptor(descriptor);
    bindService(config, TestInitRunLevelService.class);
    bindService(config, TestStartupService.class);
    bindService(config, TestStartupRunLevelService.class);
    bindService(config, TestPostStartupRunLevelService.class);
    bindService(config, CommonClassLoaderServiceImpl.class);
    bindService(config, APIClassLoaderServiceImpl.class);
    bindService(config, APIExporterImpl.class);
    config.commit();
}
Also used : RunLevelContext(org.glassfish.hk2.runlevel.RunLevelContext) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) AsyncRunLevelContext(org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext) Context(org.glassfish.hk2.api.Context) DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) DynamicConfiguration(org.glassfish.hk2.api.DynamicConfiguration) Version(com.sun.appserv.server.util.Version) AsyncRunLevelContext(org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext) RunLevelControllerImpl(org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl) EventsImpl(org.glassfish.kernel.event.EventsImpl)

Example 5 with ServerEnvironmentImpl

use of org.glassfish.server.ServerEnvironmentImpl in project Payara by payara.

the class EmbeddedSecurityUtil method copyConfigFiles.

public void copyConfigFiles(ServiceLocator habitat, File fromInstanceDir, File domainXml) {
    // For security reasons, permit only an embedded server instance to carry out the copy operations
    ServerEnvironment se = habitat.getService(ServerEnvironment.class);
    if (!isEmbedded(se)) {
        return;
    }
    if ((fromInstanceDir == null) || (domainXml == null)) {
        throw new IllegalArgumentException("Null inputs");
    }
    File toInstanceDir = habitat.<ServerEnvironmentImpl>getService(ServerEnvironmentImpl.class).getInstanceRoot();
    List<String> fileNames = new ArrayList<String>();
    try {
        // Add FileRealm keyfiles to the list
        fileNames.addAll(new EmbeddedSecurityUtil().new DomainXmlSecurityParser(domainXml).getAbsolutePathKeyFileNames(fromInstanceDir));
        // Add keystore and truststore files
        // For the embedded server case, will the system properties be set in case of multiple embedded instances?
        // Not sure - so obtain the other files from the usual locations instead of from the System properties
        String keyStoreFileName = fromInstanceDir + File.separator + "config" + File.separator + "keystore.jks";
        String trustStoreFileName = fromInstanceDir + File.separator + "config" + File.separator + "cacerts.jks";
        fileNames.add(keyStoreFileName);
        fileNames.add(trustStoreFileName);
        // Add login.conf and security policy
        String loginConf = fromInstanceDir + File.separator + "config" + File.separator + "login.conf";
        String secPolicy = fromInstanceDir + File.separator + "config" + File.separator + "server.policy";
        fileNames.add(loginConf);
        fileNames.add(secPolicy);
        File toConfigDir = new File(toInstanceDir, "config");
        if (!toConfigDir.exists()) {
            if (!toConfigDir.mkdir()) {
                throw new IOException();
            }
        }
        // Copy files into new directory
        for (String fileName : fileNames) {
            FileUtils.copyFile(new File(fileName), new File(toConfigDir, parseFileName(fileName)));
        }
    } catch (IOException e) {
        _logger.log(Level.WARNING, SecurityLoggerInfo.ioError, e);
    } catch (XMLStreamException e) {
        _logger.log(Level.WARNING, SecurityLoggerInfo.xmlStreamingError, e);
    }
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) XMLStreamException(javax.xml.stream.XMLStreamException) ServerEnvironment(org.glassfish.api.admin.ServerEnvironment) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Aggregations

ServerEnvironmentImpl (org.glassfish.server.ServerEnvironmentImpl)5 Domain (com.sun.enterprise.config.serverbeans.Domain)2 Version (com.sun.appserv.server.util.Version)1 Cluster (com.sun.enterprise.config.serverbeans.Cluster)1 Server (com.sun.enterprise.config.serverbeans.Server)1 StartupContext (com.sun.enterprise.module.bootstrap.StartupContext)1 Duration (com.sun.enterprise.universal.Duration)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ServerEnvironment (org.glassfish.api.admin.ServerEnvironment)1 Context (org.glassfish.hk2.api.Context)1 DynamicConfiguration (org.glassfish.hk2.api.DynamicConfiguration)1 DynamicConfigurationService (org.glassfish.hk2.api.DynamicConfigurationService)1 RunLevelContext (org.glassfish.hk2.runlevel.RunLevelContext)1 AsyncRunLevelContext (org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext)1 RunLevelControllerImpl (org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl)1 EventsImpl (org.glassfish.kernel.event.EventsImpl)1