/** * Get server installation root */ public String getInstallRoot() { return ctx.getInstallRoot().getPath(); }
private Object loadInstance(String className){ try{ // See IT 11674 for why CommonClassLoader must be used Class clazz = serverContext.getCommonClassLoader().loadClass(className); return clazz.newInstance(); } catch (Throwable ex){ _logger.log(Level.SEVERE,"webcontainer.unableToLoadExtension",ex); } return null; }
/** * Get the server instance name */ public String getInstanceName() { return ctx.getInstanceName(); }
File root = _serverContext.getInstallRoot(); File libRoot = new File(root, "lib"); File schemas = new File(libRoot, "schemas"); instanceName = _serverContext.getInstanceName(); engine.setParentClassLoader(EmbeddedWebContainer.class.getClassLoader()); _embedded.addEngine(engine); ((StandardEngine) engine).setDomain(_serverContext.getDefaultDomainName()); engine.setName(_serverContext.getDefaultDomainName());
ctx.setJvmRoute(engine.getJvmRoute()); String j2eeServer = _serverContext.getInstanceName(); String domain = _serverContext.getDefaultDomainName(); parentLoader = _serverContext.getSharedClassLoader();
private WebModule createAdHocWebModule( String id, VirtualServer vs, String ctxtRoot, String appName) { AdHocWebModule wm = new AdHocWebModule(); wm.setID(id); wm.setWebContainer(this); wm.restrictedSetPipeline(new WebPipeline(wm)); // The Parent ClassLoader of the AdhocWebModule was null // [System ClassLoader]. With the new hierarchy, the thread context // classloader needs to be set. //if (Boolean.getBoolean(com.sun.enterprise.server.PELaunch.USE_NEW_CLASSLOADER_PROPERTY)) { wm.setParentClassLoader( Thread.currentThread().getContextClassLoader()); //} wm.setContextRoot(ctxtRoot); wm.setJ2EEApplication(appName); wm.setName(ctxtRoot); wm.setDocBase(vs.getAppBase()); wm.setEngineName(vs.getParent().getName()); String domain = _serverContext.getDefaultDomainName(); wm.setDomain(domain); String j2eeServer = _serverContext.getInstanceName(); wm.setJ2EEServer(j2eeServer); wm.setCrossContext(true); //wm.setJavaVMs(J2EEModuleUtil.getjavaVMs()); vs.addChild(wm); return wm; }
/** * Creates the monitoring helper. */ public GrizzlyConfig(WebContainer webContainer, String domain, int port) { this.domain = domain; this.port = port; this.habitat = webContainer.getServerContext().getDefaultHabitat(); // get an instance of the MBeanServer ArrayList servers = MBeanServerFactory.findMBeanServer(null); if(!servers.isEmpty()) mBeanServer = (MBeanServer)servers.get(0); else mBeanServer = MBeanServerFactory.createMBeanServer(); grizzlyConfigList.add(this); }
/** * Virtual servers are maintained in the reference contained * in Server element. First, we need to find the server * and then get the virtual server from the correct reference * * @param appName Name of the app to get vs * * @return virtual servers as a string (separated by space or comma) */ private String getVirtualServers(String appName) { String ret = null; Server server = serverContext.getDefaultServices().getService(Server.class); for (ApplicationRef appRef : server.getApplicationRef()) { if (appRef.getRef().equals(appName)) { return appRef.getVirtualServers(); } } return ret; }
public ResourceInjectorImpl(WebModule webModule) { this.webModule = webModule; this.desc = webModule.getWebBundleDescriptor(); ServerContext serverContext = webModule.getServerContext(); if (serverContext == null) { throw new IllegalStateException( _rb.getString("resource.injector.noservercontext")); } this.injectionMgr = serverContext.getDefaultHabitat().getByContract( InjectionManager.class); }
public void loadAuditModules() { try { SecurityService securityBean = serverContext.getDefaultServices().getService(SecurityService.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
public void postConstruct() { File root = serverContext.getInstallRoot(); File libRoot = new File(root, "lib"); schemaDir = new File(libRoot, "schemas"); dtdDir = new File(libRoot, "dtds"); }
public Thread newThread(Runnable r) { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); t.setContextClassLoader(habitat.<ServerContext>getService(ServerContext.class).getCommonClassLoader()); return t; }
public void postConstruct() { instanceName = _serverContext.getInstanceName(); }
private synchronized void init(WebModule wm) { if (initialized) { return; } ServerContext serverContext = wm.getServerContext(); if (serverContext == null) { String msg = _rb.getString("webmodule.noservercontext"); msg = MessageFormat.format(msg, wm.getName()); throw new IllegalStateException(msg); } im = serverContext.getDefaultHabitat().getByContract( InvocationManager.class); tm = serverContext.getDefaultHabitat().getByContract( JavaEETransactionManager.class); injectionMgr = serverContext.getDefaultHabitat().getByContract( InjectionManager.class); initialized = true; securityContext = serverContext.getDefaultHabitat().getByContract(AppServSecurityContext.class); if (securityContext != null) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Obtained securityContext implementation class " + securityContext); } } else { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Failed to obtain securityContext implementation class "); } } }
private File defaultLocalNodeDirFile() { /* * The "nodes" directory we want to use is a child of * the install directory. * * The installDir field contains the installation directory which the * administrator specified, if s/he specified one, when the target node * was first created. It is null if the administrator did not specify * an installation directory for the node. In that case we should * use the DAS's install directory (because this method applies in the * local instance case). */ final File nodeParentDir = ( installDir == null ? serverContext.getInstallRoot() : new File(installDir, "glassfish")); return new File(nodeParentDir, "nodes"); }
private Class loadClass(String className) throws ClassNotFoundException { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { return Class.forName(className, true, tccl); } catch (ClassNotFoundException e) { // Not a significant error. Try with common class loader instead. _logger.logp(Level.FINE, "GlassFishNamingBuilder", "loadClass", "Failed to load {0} using thread context class loader {1}", new Object[]{className, tccl}); // Try using CommonClassLoader. ClassLoader ccl = sc.getCommonClassLoader(); if (tccl != ccl) { try { return Class.forName(className, true, ccl); } catch (ClassNotFoundException e2) { _logger.logp(Level.WARNING, "GlassFishNamingBuilder", "loadClass", "Failed to load {0} using CommonClassLoader", new Object[]{className}); throw e2; } } throw e; } }
public String getDataSourceLookupName() { String val = batchRuntimeConfiguration.getDataSourceLookupName(); if (val == null || val.trim().length() == 0) { val = serverContext.getInstanceName().equals("server") ? "jdbc/__TimerPool" : "jdbc/__default"; } return val; }
/** * Virtual servers are maintained in the reference contained * in Server element. First, we need to find the server * and then get the virtual server from the correct reference * * @param appName Name of the app to get vs * * @return virtual servers as a string (separated by space or comma) */ private String getVirtualServers(String appName) { String ret = null; Server server = serverContext.getDefaultHabitat().getComponent(Server.class); for (ApplicationRef appRef : server.getApplicationRef()) { if (appRef.getRef().equals(appName)) { return appRef.getVirtualServers(); } } return ret; }
public File getScriptPath() { File file = new File(env.getInstallRoot(), "config"); File parentDir = new File(file, "libvirt"); // needs to be changed. // we try to locate the right directory using this runtime operating system. // if not found, we user the generic linux scripts. File osDir = new File(parentDir, RuntimeContext.getEncodedOS()); if (!osDir.exists()) { osDir = new File(parentDir, "linux"); } return osDir; }
private Class loadClass(String className) throws ClassNotFoundException { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { return Class.forName(className, true, tccl); } catch (ClassNotFoundException e) { // Not a significant error. Try with common class loader instead. logger.logp(Level.FINE, "GlassFishNamingBuilder", "loadClass", "Failed to load {0} using thread context class loader {1}", new Object[]{className, tccl}); // Try using CommonClassLoader. ClassLoader ccl = sc.getCommonClassLoader(); if (tccl != ccl) { try { return Class.forName(className, true, ccl); } catch (ClassNotFoundException e2) { logger.logp(Level.WARNING, "GlassFishNamingBuilder", "loadClass", FAILED_TO_LOAD_CLASS, new Object[]{className}); throw e2; } } throw e; } }