use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class StaticGlassFishRuntimeBuilder method build.
public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException {
/* Step 1. Build the classloader. */
// The classloader should contain installRoot/modules/**/*.jar files.
String installRoot = getInstallRoot(bsProps);
if (installRoot != null) {
System.setProperty("org.glassfish.embeddable.installRoot", installRoot);
}
// Required to add moduleJarURLs to support 'java -jar modules/glassfish.jar case'
List<URL> moduleJarURLs = getModuleJarURLs(installRoot);
ClassLoader cl = getClass().getClassLoader();
if (!moduleJarURLs.isEmpty()) {
cl = new StaticClassLoader(getClass().getClassLoader(), moduleJarURLs);
}
// Step 2. Setup the module subsystem.
Main main = new EmbeddedMain(cl);
SingleHK2Factory.initialize(cl);
ModulesRegistry modulesRegistry = AbstractFactory.getInstance().createModulesRegistry();
modulesRegistry.setParentClassLoader(cl);
// Step 3. Create NonOSGIGlassFishRuntime
GlassFishRuntime glassFishRuntime = new StaticGlassFishRuntime(main);
logger.logp(Level.FINER, getClass().getName(), "build", "Created GlassFishRuntime {0} with InstallRoot {1}, Bootstrap Options {2}", new Object[] { glassFishRuntime, installRoot, bsProps });
return glassFishRuntime;
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class Utils method getNewHabitat.
public static ServiceLocator getNewHabitat(String root) {
Properties p = new Properties();
p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTALL_ROOT_PROP_NAME, root);
p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_PROP_NAME, root);
ModulesRegistry registry = new StaticModulesRegistry(Utils.class.getClassLoader(), new StartupContext(p));
ServiceLocator defaultSL = registry.createServiceLocator("default");
return defaultSL;
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class EmbeddedOSGiGlassFishRuntime method newGlassFish.
@Override
public synchronized GlassFish newGlassFish(GlassFishProperties gfProps) throws GlassFishException {
try {
// set env props before updating config, because configuration update may actually trigger
// some code to be executed which may be depending on the environment variable values.
setEnv(gfProps.getProperties());
final StartupContext startupContext = new StartupContext(gfProps.getProperties());
final ServiceTracker hk2Tracker = new ServiceTracker(getBundleContext(), Main.class.getName(), null);
hk2Tracker.open();
final Main main = (Main) hk2Tracker.waitForService(0);
hk2Tracker.close();
final ModulesRegistry mr = ModulesRegistry.class.cast(getBundleContext().getService(getBundleContext().getServiceReference(ModulesRegistry.class.getName())));
ServiceLocator serviceLocator = main.createServiceLocator(mr, startupContext, null, null);
final ModuleStartup gfKernel = main.findStartupService(mr, serviceLocator, null, startupContext);
GlassFish glassFish = createGlassFish(gfKernel, serviceLocator, gfProps.getProperties());
gfs.add(glassFish);
return glassFish;
} catch (BootException ex) {
throw new GlassFishException(ex);
} catch (InterruptedException ex) {
throw new GlassFishException(ex);
}
}
use of com.sun.enterprise.module.ModulesRegistry in project Payara by payara.
the class SunDeploymentManager method prepareHabitat.
private void prepareHabitat() {
ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader());
ServiceLocator serviceLocator = registry.createServiceLocator("default");
habitat = serviceLocator.getService(ServiceLocator.class);
StartupContext startupContext = new StartupContext();
ServiceLocatorUtilities.addOneConstant(habitat, startupContext);
ServiceLocatorUtilities.addOneConstant(habitat, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other));
}
use of com.sun.enterprise.module.ModulesRegistry 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<-: ");
}
}
}
Aggregations