/** * Return the ServletContext of our associated web application. */ public ServletContext getServletContext() { return (this.context.getServletContext()); }
/** * Return the ServletContext to which this session belongs. */ public ServletContext getServletContext() { if (manager == null) return (null); if (context == null) return (null); else return (context.getServletContext()); }
/** * Post a copy of our current list of welcome files as a servlet context * attribute, so that the default servlet can find them. */ private void postWelcomeFiles() { getServletContext().setAttribute("org.apache.catalina.WELCOME_FILES", welcomeFiles); }
private static boolean isIgnored(StandardContext standardContext) { // useful to disable web applications deployment // it can be placed in the context.xml file, server.xml, ... // see http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Context_Parameters if (standardContext.getServletContext().getAttribute(IGNORE_CONTEXT) != null) return true; if (standardContext.getServletContext().getInitParameter(IGNORE_CONTEXT) != null) return true; return false; }
private static boolean isIgnored(final StandardContext standardContext) { // useful to disable web applications deployment // it can be placed in the context.xml file, server.xml, ... // see http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Context_Parameters return standardContext.getServletContext().getAttribute(IGNORE_CONTEXT) != null || standardContext.getServletContext().getInitParameter(IGNORE_CONTEXT) != null || standardContext instanceof IgnoredStandardContext || isExcludedBySystemProperty(standardContext); }
/** * Create mandatory servlet context attributes. */ protected void postContextAttributes() { ServletContext context = getServletContext(); context.setAttribute(Globals.SERVLET_VERSION, version); context.setAttribute(Globals.RESOURCES_ATTR, getResources()); context.setAttribute(Globals.WELCOME_FILES_ATTR, welcomeFiles); // Jasper attributes context.setAttribute(Globals.JSP_PROPERTY_GROUPS, jspPropertyGroups); context.setAttribute(Globals.JSP_TAG_LIBRARIES, jspTagLibraries); // Instance manager (also used by Jasper) context.setAttribute(InstanceManager.class.getName(), instanceManager); }
/** * Create mandatory servlet context attributes. */ protected void postContextAttributes() { ServletContext context = getServletContext(); context.setAttribute(Globals.SERVLET_VERSION, version); context.setAttribute(Globals.RESOURCES_ATTR, getResources()); context.setAttribute(Globals.WELCOME_FILES_ATTR, welcomeFiles); // Jasper attributes context.setAttribute(Globals.JSP_PROPERTY_GROUPS, jspPropertyGroups); context.setAttribute(Globals.JSP_TAG_LIBRARIES, jspTagLibraries); // Instance manager (also used by Jasper) context.setAttribute(InstanceManager.class.getName(), instanceManager); }
/** * Stores the resources of this application as ServletContext * attributes. */ private void postResources() { getServletContext().setAttribute( Globals.RESOURCES_ATTR, getResources()); context.setAttributeReadOnly(Globals.RESOURCES_ATTR); getServletContext().setAttribute( Globals.ALTERNATE_RESOURCES_ATTR, getAlternateDocBases()); context.setAttributeReadOnly(Globals.ALTERNATE_RESOURCES_ATTR); }
private URL getWsdlUrl(ServiceReferenceInfo ref) { if (ref.wsdlFile == null) return null; URL wsdlUrl = null; try { wsdlUrl = new URL(ref.wsdlFile); } catch (MalformedURLException e) { } if (wsdlUrl == null) { wsdlUrl = standardContext.getLoader().getClassLoader().getResource(ref.wsdlFile); } if (wsdlUrl == null) { try { wsdlUrl = standardContext.getServletContext().getResource("/" + ref.wsdlFile); } catch (MalformedURLException e) { } } if (wsdlUrl == null ) { throw new IllegalArgumentException("WSDL file " + ref.wsdlFile + " for web service-ref " + ref.referenceName + " not found"); } return wsdlUrl; }
public void afterStop(StandardServer standardServer) { // clean ear based webapps after shutdown for (ContextInfo contextInfo : infos.values()) { if (contextInfo != null && contextInfo.deployer != null) { StandardContext standardContext = contextInfo.standardContext; HostConfig deployer = contextInfo.deployer; deployer.unmanageApp(standardContext.getPath()); String realPath = standardContext.getServletContext().getRealPath(""); if (realPath != null) { deleteDir(new File(realPath)); } } } }
/** * {@inheritDoc} */ @Override public void afterStop(StandardServer standardServer) { // clean ear based webapps after shutdown for (ContextInfo contextInfo : infos.values()) { if (contextInfo != null && contextInfo.deployer != null) { StandardContext standardContext = contextInfo.standardContext; HostConfig deployer = contextInfo.deployer; deployer.unmanageApp(standardContext.getPath()); String realPath = standardContext.getServletContext().getRealPath(""); if (realPath != null) { deleteDir(new File(realPath)); } } } }
/** * {@inheritDoc} */ @Override public void beforeStart(StandardContext standardContext) { ServletContext sc = standardContext.getServletContext(); if (sc != null && !SystemInstance.get().getOptions().get(OPENEJB_JSESSION_ID_SUPPORT, true)) { Set<SessionTrackingMode> defaultTrackingModes = sc.getEffectiveSessionTrackingModes(); if (defaultTrackingModes.contains(SessionTrackingMode.URL)) { Set<SessionTrackingMode> newModes = new HashSet<SessionTrackingMode>(); newModes.remove(SessionTrackingMode.URL); sc.setSessionTrackingModes(newModes); } } }
public void undeployWebApps(AppInfo appInfo) throws Exception { for (WebAppInfo webApp : appInfo.webApps) { ContextInfo contextInfo = getContextInfo(webApp); if (contextInfo != null && contextInfo.deployer != null) { StandardContext standardContext = contextInfo.standardContext; HostConfig deployer = contextInfo.deployer; deployer.unmanageApp(standardContext.getPath()); deleteDir(new File(standardContext.getServletContext().getRealPath(""))); removeContextInfo(standardContext); } } }
public void stop(StandardContext standardContext) { if (standardContext.getServletContext().getAttribute(IGNORE_CONTEXT) != null) return; ContextInfo contextInfo = getContextInfo(standardContext); if (contextInfo != null && contextInfo.appInfo != null && contextInfo.deployer == null) { try { assembler.destroyApplication(contextInfo.appInfo.jarPath); } catch (Exception e) { logger.error("Unable to stop web application " + standardContext.getPath() + ": Exception: " + e.getMessage(), e); } } removeContextInfo(standardContext); }
private void wrapInstanceManager(StandardContext context) { if (context.getInstanceManager() instanceof TomcatInstanceManager) { return; } InstanceManager processor = context.getInstanceManager(); InstanceManager custom = new TomcatInstanceManager(context.getLoader().getClassLoader(), processor); context.setInstanceManager(custom); context.getServletContext().setAttribute(InstanceManager.class.getName(), custom); }
/** * Creates an openejb {@link AppModule} instance * from given tomcat context. * * @param standardContext tomcat context instance * @return a openejb application module */ private AppModule loadApplication(final StandardContext standardContext) { final ServletContext servletContext = standardContext.getServletContext(); final TomcatDeploymentLoader tomcatDeploymentLoader = new TomcatDeploymentLoader(standardContext, getId(standardContext)); final AppModule appModule; try { appModule = tomcatDeploymentLoader.load(new File(servletContext.getRealPath(".")).getParentFile()); } catch (OpenEJBException e) { throw new TomEERuntimeException(e); } // create the web module loadWebModule(appModule, standardContext); return appModule; }
/** * {@inheritDoc} */ @Override public void undeployWebApps(AppInfo appInfo) throws Exception { for (WebAppInfo webApp : appInfo.webApps) { ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot); if (contextInfo != null && contextInfo.deployer != null) { StandardContext standardContext = contextInfo.standardContext; HostConfig deployer = contextInfo.deployer; if (deployer != null) { deployer.unmanageApp(standardContext.getPath()); } else if (contextInfo.host != null) { contextInfo.host.removeChild(standardContext); } deleteDir(new File(standardContext.getServletContext().getRealPath(""))); removeContextInfo(standardContext); } } }
private StandardContext createContext(String path, String docBase, ClassLoader classLoader, Map<String, List<Injector<?>>> injectors) { StandardContext context = new StandardContext(); context.setDocBase(docBase); context.setPath(path); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); context.setParentClassLoader(classLoader); Fabric3Loader loader = new Fabric3Loader(classLoader); context.setLoader(loader); // turn off unpacking so Tomcat does not copy the extracted WAR to the /webapps directory and autodeploy it on a subsequent boot context.setUnpackWAR(false); Fabric3AnnotationProcessor annotationProcessor = new Fabric3AnnotationProcessor(injectors); context.setAnnotationProcessor(annotationProcessor); context.getServletContext().setAttribute(AnnotationProcessor.class.getName(), annotationProcessor); return (context); }
@Override public void configureStart(StandardContext standardContext) { if (TomcatHelper.isTomcat7()) { TomcatHelper.configureJarScanner(standardContext); ContextTransaction contextTransaction = new ContextTransaction(); contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName()); standardContext.getNamingResources().setTransaction(contextTransaction); startInternal(standardContext); } // clear a bit log for default case addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext()); }
@Override public void configureStart(final LifecycleEvent event, final StandardContext standardContext) { final ContextTransaction contextTransaction = new ContextTransaction(); contextTransaction.setProperty(org.apache.naming.factory.Constants.FACTORY, UserTransactionFactory.class.getName()); standardContext.getNamingResources().setTransaction(contextTransaction); if (event != null) { // ensure NamingContext is available for eager usage (@Observes @Initialized(ApplicationScoped) for instance) standardContext.getNamingContextListener().lifecycleEvent(event); } TomcatHelper.configureJarScanner(standardContext); startInternal(standardContext); // clear a bit log for default case addMyFacesDefaultParameters(standardContext.getLoader().getClassLoader(), standardContext.getServletContext()); // breaks cdi standardContext.setTldValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.tld.validation", "false"))); // breaks jstl standardContext.setXmlValidation(Boolean.parseBoolean(SystemInstance.get().getProperty("tomee.xml.validation", "false"))); }