public static void InitRuntime(ServletConfig config, object evidence) { ServletContext context = config.getServletContext(); if (context.getAttribute(J2EEConsts.APP_DOMAIN) != null) { return; } _facesContextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); //TODO: null-check for Weblogic, that tries to initialize Servlet before ContextListener //Javadoc says: Lifecycle instance is shared across multiple simultaneous requests, it must be implemented in a thread-safe manner. //So we can acquire it here once: LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); _lifecycle = lifecycleFactory.getLifecycle(context.getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR) ?? LifecycleFactory.DEFAULT_LIFECYCLE); _renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); AppDomain servletDomain = createServletDomain(config); [email protected](servletDomain); try { //GH Infromation Initizalization long currentTime = java.lang.System.currentTimeMillis(); servletDomain.SetData(".domainId", currentTime.ToString("x")); currentTime = ~currentTime; servletDomain.SetData(".appId", currentTime.ToString("x")); servletDomain.SetData(".appName", servletDomain.SetupInformation.ApplicationName); servletDomain.SetData(J2EEConsts.CLASS_LOADER, java.lang.Thread.currentThread().getContextClassLoader()); //servletDomain.SetData (J2EEConsts.CLASS_LOADER, vmw.common.TypeUtils.ToClass (evidence).getClassLoader ()); //servletDomain.SetData(J2EEConsts.SERVLET_CONFIG, config); servletDomain.SetData(J2EEConsts.RESOURCE_LOADER, new ServletResourceLoader(context)); lock (evidence) { if (context.getAttribute(J2EEConsts.APP_DOMAIN) == null) { context.setAttribute(J2EEConsts.APP_DOMAIN, servletDomain); } } //config.getServletContext ().setAttribute (J2EEConsts.CURRENT_SERVLET, this); } finally { [email protected](); [email protected](); } }
public override bool Execute() { ILog log = new MsBuildLogger(this.Log); IAssemblies assemblies = new Assemblies(); IFactoryFinder factoryFinder = new FactoryFinder(log); IConstructorCallFinder constructorCallFinder = new ConstructorCallFinder(log); IFactoryCallWeaver factoryCallWeaver = new FactoryCallWeaver(log); IFactoryMapSerializer factoryMapSerializer = new FactoryMapSerializer(); IObjectFactoriesProcessor processor = new ObjectFactoriesProcessor(log, assemblies, factoryFinder, constructorCallFinder, factoryCallWeaver, factoryMapSerializer); foreach (string path in this.Assemblies) { this.Log.LogMessage("Processing {0}", path); processor.ProcessAssembly(path); } return(true); }
public static void DestroyRuntime(ServletContext context, IJDBCDriverDeregisterer evidence) { AppDomain servletDomain = (AppDomain)context.getAttribute(J2EEConsts.APP_DOMAIN); if (servletDomain == null) { return; } try { [email protected](servletDomain); Debug.WriteLine("Destroy of GhHttpServlet"); HttpRuntime.Close(); [email protected](evidence); context.removeAttribute(J2EEConsts.APP_DOMAIN); try { FactoryFinder.releaseFactories(); } catch (FacesException) { } java.lang.ClassLoader appClassLoader = vmw.common.TypeUtils.ToClass(evidence).getClassLoader(); IJDBCDriverDeregisterer dereg = evidence; java.util.Enumeration en = java.sql.DriverManager.getDrivers(); while (en.hasMoreElements()) { Object o = en.nextElement(); if (vmw.common.TypeUtils.ToClass(o).getClassLoader() == appClassLoader) { dereg.DeregisterDriver((java.sql.Driver)o); } } java.lang.Thread.currentThread().setContextClassLoader(null); } catch (Exception e) { Debug.WriteLine(String.Format("ERROR in Servlet Destroy {0},{1}", e.GetType(), e.Message)); Debug.WriteLine(e.StackTrace); } finally { [email protected](); } }