use of com.sun.enterprise.security.EmbeddedSecurity in project Payara by payara.
the class EJBContainerProviderImpl method createContainer.
private Locations createContainer(Map<?, ?> properties, Locations l) throws EJBException {
synchronized (lock) {
// if (container == null || !container.isOpen()) {
try {
if (runtime != null) {
// dispose of the old one
runtime.shutdown();
}
BootstrapProperties bootstrapProperties = new BootstrapProperties();
// Propagate non EJB embeddable container properties into GlassFishProperties
Properties newProps = new Properties();
if (properties != null) {
copyUserProperties(properties, newProps);
}
// Disable weaving if it is not spesified
if (newProps.getProperty(WEAVING) == null) {
newProps.setProperty(WEAVING, "false");
}
GlassFishProperties glassFishProperties = new GlassFishProperties(newProps);
if (Boolean.getBoolean(KEEP_TEMPORARY_FILES)) {
// set autodelete to false.
glassFishProperties.setProperty("org.glassfish.embeddable.autoDelete", "false");
// make sure the domain.xml is written back.
glassFishProperties.setConfigFileReadOnly(false);
}
if (l.installed_root != null && l.instance_root != null) {
// Real install
_logger.info("[EJBContainerProviderImpl] Using installation location " + l.installed_root.getCanonicalPath());
bootstrapProperties.setInstallRoot(l.installed_root.getCanonicalPath());
}
if (l.instance_root != null && l.reuse_instance_location) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("[EJBContainerProviderImpl] Reusing instance location at: " + l.instance_root);
}
_logger.info("[EJBContainerProviderImpl] Using instance location: " + l.instance_root.getCanonicalPath());
glassFishProperties.setInstanceRoot(l.instance_root.getCanonicalPath());
} else if (l.domain_file != null) {
_logger.info("[EJBContainerProviderImpl] Using config file location: " + l.domain_file.toURI().toString());
glassFishProperties.setConfigFileURI(l.domain_file.toURI().toString());
}
addWebContainerIfRequested(properties, glassFishProperties);
runtime = GlassFishRuntime.bootstrap(bootstrapProperties);
_logger.info("[EJBContainerProviderImpl] Using runtime class: " + runtime.getClass());
GlassFish server = runtime.newGlassFish(glassFishProperties);
if (l.instance_root != null && !l.reuse_instance_location) {
// XXX Start the server to get the services
server.start();
EmbeddedSecurity es = server.getService(EmbeddedSecurity.class);
ServiceLocator habitat = server.getService(ServiceLocator.class);
server.stop();
// If we are running from an existing install, copy over security files to the temp instance
if (es != null) {
es.copyConfigFiles(habitat, l.instance_root, l.domain_file);
}
}
// server is started in EJBContainerImpl constructor
container = new EJBContainerImpl(server);
validateInstanceDirectory();
archiveFactory = server.getService(ArchiveFactory.class);
Sniffer sniffer = server.getService(Sniffer.class, "Ejb");
ejbAnnotations = sniffer.getAnnotationTypes();
} catch (Exception e) {
try {
if (container != null) {
container.stop();
}
} catch (Exception e0) {
_logger.log(Level.SEVERE, e0.getMessage(), e0);
}
container = null;
throw new EJBException(e);
}
// }
}
return l;
}
Aggregations