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;
}
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() };
}
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;
}
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();
}
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);
}
}
Aggregations