Package org.apache.catalina.core

Examples of org.apache.catalina.core.StandardContext$DummyAnnotationProcessor


        }
    }

    public void discardWorkDir(Context context) {
        if (context instanceof StandardContext) {
            StandardContext standardContext = (StandardContext) context;
            logger.info("Discarding " + standardContext.getWorkPath());
            Utils.delete(new File(standardContext.getWorkPath(), "org"));
        } else {
            logger.error("context " + context.getName() + " is not an instance of " + context.getClass().getName() + ", expected StandardContext");
        }
    }
View Full Code Here


        List<WARDeployable> wars = earDeployable.getWARDeployables();

        for (WARDeployable war : wars) {

            // Build a new context for this war file
            StandardContext standardContext = new StandardContext();

            // Build Object Name
            String objectName = buildObjectName(war);

            // Register Object MBean
            try {
                CommonsModelerHelper.registerModelerMBean(standardContext, objectName);
            } catch (CommonsModelerException e) {
                throw new DeployerException("Cannot register the object '" + standardContext + "' with the objectname '"
                        + objectName + "'.", e);
            }

            // set the context-root

            standardContext.setPath(war.getContextRoot());

            // Get the URL for this War
            URL warURL = null;
            try {
                warURL = war.getArchive().getURL();
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + war.getArchive() + "'.", e);
            }


            // Analyze the war archive
            IWarDeployableMetadata warDeployableMetadata = null;
            try {
                warDeployableMetadata = new WarDeployableMetadataFactory().createDeployableMetadata(war);
            } catch (DeployableMetadataException e) {
                logger.error("Unable to analyze the metadata of the war '" + warURL + "'.", e);
            }

            // Now, get the bindings for this web application
            ENCBindingHolder encBindingHolder = null;
            if (warDeployableMetadata != null) {
                try {
                    encBindingHolder = ENCBindingBuilder.analyze(warDeployableMetadata);
                } catch (ENCBindingException e) {
                    logger.error("Unable to analyze metadata of '" + warURL + "'", e);
                }
            }

            // File of this war
            File warFile = URLUtils.urlToFile(warURL);

            // docbase
            String docBase = warFile.getPath();

            // File and not a directory --> unpack it
            if (warFile.isFile()) {
                // Need to unpack the file
                File unpackDir = unpack(warFile, war, earURL);
                docBase = unpackDir.getPath();
            }

            // set the path to the war file (needs to be unpacked else it will
            // be unpacked by tomcat in the webapps folder and it will try to
            // deploy twice the webapp with wrong classloader)
            standardContext.setDocBase(docBase);

            // default XML files
            standardContext.setDefaultWebXml("conf/web.xml");
            standardContext.setDefaultContextXml("context.xml");


            File contextXmlFile = new File(docBase + File.separator + "META-INF" + File.separator + "context.xml");
            // META-INF/context.xml file support
            if (contextXmlFile.exists()) {
                standardContext.setConfigFile(contextXmlFile.getAbsolutePath());
            }

            // Set the parent class loader
            standardContext.setParentClassLoader(parentClassLoader);

            // Set the java delegation model
            standardContext.setDelegate(true);

            // Set our naming context listener
            EasyBeansNamingContextListener namingContextListener = new EasyBeansNamingContextListener();
            namingContextListener.setEncBindingHolder(encBindingHolder);
            namingContextListener.setInjectionHolder(ejbInjectionHolder);
            namingContextListener.setName(getNamingContextName(standardContext));
            standardContext.addLifecycleListener(namingContextListener);
            standardContext.setNamingContextListener(namingContextListener);

            // Start the context
            try {
                standardContext.start();
            } catch (LifecycleException e) {
                throw new DeployerException("Cannot start the context of the War '" + warURL + "'.", e);
            }

            // War has been deployed
View Full Code Here

        List<WARDeployable> wars = earDeployable.getWARDeployables();

        for (WARDeployable war : wars) {

            // Build a new context for this war file
            StandardContext standardContext = new StandardContext();

            // Build Object Name
            String objectName = buildObjectName(war);

            // Register Object MBean
            try {
                CommonsModelerHelper.registerModelerMBean(standardContext, objectName);
            } catch (CommonsModelerException e) {
                throw new DeployerException("Cannot register the object '" + standardContext + "' with the objectname '"
                        + objectName + "'.", e);
            }

            // set the context-root

            standardContext.setPath(war.getContextRoot());

            // Get the URL for this War
            URL warURL = null;
            try {
                warURL = war.getArchive().getURL();
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + war.getArchive() + "'.", e);
            }

            // File of this war
            File warFile = URLUtils.urlToFile(warURL);

            // docbase
            String docBase = warFile.getPath();

            // File and not a directory --> unpack it
            if (warFile.isFile()) {
                // Need to unpack the file
                File unpackDir = unpack(warFile, war, earURL);
                docBase = unpackDir.getPath();
            }

            // set the path to the war file (needs to be unpacked else it will
            // be unpacked by tomcat in the webapps folder and it will try to
            // deploy twice the webapp with wrong classloader)
            standardContext.setDocBase(docBase);

            // default XML files
            standardContext.setDefaultWebXml("conf/web.xml");
            standardContext.setDefaultContextXml("context.xml");

            File contextXmlFile = new File(docBase + File.separator + "META-INF" + File.separator + "context.xml");
            // META-INF/context.xml file support
            if (contextXmlFile.exists()) {
                standardContext.setConfigFile(contextXmlFile.getAbsolutePath());
            }

            // Set the parent class loader
            standardContext.setParentClassLoader(parentClassLoader);

            // Set the java delegation model
            standardContext.setDelegate(true);

            // Start the context
            try {
                standardContext.start();
            } catch (Exception e) {
                throw new DeployerException("Cannot start the context of the War '" + warURL + "'.", e);
            }

            // War has been deployed
View Full Code Here

      URL warUrl = new URL(warUrlStr);

      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      metaData.setContextLoader(loader);

      StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();

      DeploymentUnit depUnit = webApp.getDeploymentUnit();

      // Find all TLDs that have been processed by deployers, and place them in a map keyed by location
      Map<String, TldMetaData> tldMetaDataMap = new HashMap<String, TldMetaData>();
      Map<String, Object> attachements = depUnit.getAttachments();
      Iterator<String> attachementNames = attachements.keySet().iterator();
      while (attachementNames.hasNext()) {
         String name = attachementNames.next();
         Object attachement = depUnit.getAttachment(name);
         if (attachement != null && attachement instanceof TldMetaData
               && name.startsWith(TldMetaData.class.getName() + ":"))
         {
            tldMetaDataMap.put(name, (TldMetaData) attachement);
         }
      }
      List<TldMetaData> sharedTldMetaData = (List<TldMetaData>)
         depUnit.getAttachment(SharedTldMetaDataDeployer.SHARED_TLDS_ATTACHMENT_NAME);
      if (sharedTldMetaData != null)
      {
         for (TldMetaData tldMetaData : sharedTldMetaData)
         {
            tldMetaDataMap.put("shared:" + tldMetaData.toString(), tldMetaData);
         }
      }
     
      this.component = createJavaEEComponent();

      TomcatInjectionContainer injectionContainer =
         new TomcatInjectionContainer(webApp, depUnit, context,
               getPersistenceUnitDependencyResolver(), config.getDynamicClassloaders(), component, this.getInjectionManager());

      Loader webLoader = depUnit.getAttachment(Loader.class);
      if (webLoader == null)
         webLoader = getWebLoader(depUnit, metaData, loader, warUrl, injectionContainer);

      webApp.setName(warUrl.getPath());
      webApp.setClassLoader(loader);
      webApp.setURL(warUrl);

      String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
            + ",J2EEApplication=none,J2EEServer=none";

      ObjectName objectName = new ObjectName(objectNameS);

      if (Registry.getRegistry(null, null).getMBeanServer().isRegistered(objectName))
         throw new DeploymentException("Web mapping already exists for deployment URL " + warUrlStr);

      Registry.getRegistry(null, null).registerComponent(context, objectName, config.getContextClassName());

      context.setInstanceManager(injectionContainer);
      context.setPublicId(metaData.getPublicID());

      String docBase = depUnit.getAttachment("org.jboss.web.explicitDocBase", String.class);
      if (docBase == null)
         docBase = VFS.getChild(warUrl).getPhysicalFile().getAbsolutePath();

      context.setDocBase(docBase);

      // If there is an alt-dd set it
      if (metaData.getAlternativeDD() != null)
      {
         log.debug("Setting altDDName to: " + metaData.getAlternativeDD());
         context.setAltDDName(metaData.getAlternativeDD());
      }
      context.setJavaVMs(javaVMs);
      context.setServer(serverName);

      if (webLoader != null)
      {
         context.setLoader(webLoader);
      }
      else
      {
         context.setParentClassLoader(loader);
      }

      // Set the session cookies flag according to metadata
      switch (metaData.getSessionCookies())
      {
         case JBossWebMetaData.SESSION_COOKIES_ENABLED:
            context.setCookies(true);
            log.debug("Enabling session cookies");
            break;
         case JBossWebMetaData.SESSION_COOKIES_DISABLED:
            context.setCookies(false);
            log.debug("Disabling session cookies");
            break;
         default:
            log.debug("Using session cookies default setting");
      }

      String metaDataSecurityDomain = metaData.getSecurityDomain();
      if (metaDataSecurityDomain != null)
         metaDataSecurityDomain = metaDataSecurityDomain.trim();
     
      // Add a valve to establish security and naming context
      SecurityContextEstablishmentValve scevalve = new SecurityContextEstablishmentValve(metaDataSecurityDomain, SecurityUtil.unprefixSecurityDomain(config
            .getDefaultSecurityDomain()), SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement(), component);
      context.addValve(scevalve);

      // Add a valve to estalish the JACC context before authorization valves
      Certificate[] certs = null;
      CodeSource cs = new CodeSource(warUrl, certs);
      JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
      context.addValve(jaccValve);

      // Set listener
      context.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
      context.addLifecycleListener(new EncListener(loader, webLoader, injectionContainer, webApp));
     
      // Pass the metadata to the RunAsListener via a thread local
      RunAsListener.metaDataLocal.set(metaData);
      JBossContextConfig.metaDataLocal.set(metaData);
      JBossContextConfig.deployerConfig.set(config);
      JBossContextConfig.tldMetaDataMapLocal.set(tldMetaDataMap);
      NamingListener.idLocal.set(component);

      JBossContextConfig.kernelLocal.set(kernel);
      JBossContextConfig.deploymentUnitLocal.set(unit);
      try
      {
         // JBAS-8406: Temp hack, will move to NamingListener
         CurrentComponent.push(component);
         // Start it
         CDIExceptionStore.reset();
         context.start();
         // Build the ENC
         // JBAS-8278: abort deployment if there are CDI definitions errors
         if (CDIExceptionStore.currentExceptions().size()>0)
         {
            throw CDIExceptionStore.currentExceptions().get(0);
         }
      }
      catch (Throwable t)
      {
         context.destroy();
         DeploymentException.rethrowAsDeploymentException("URL " + warUrlStr + " deployment failed", t);
      }
      finally
      {
         RunAsListener.metaDataLocal.set(null);
         JBossContextConfig.metaDataLocal.set(null);
         JBossContextConfig.deployerConfig.set(null);
         JBossContextConfig.tldMetaDataMapLocal.set(null);
         NamingListener.idLocal.set(null);

         JBossContextConfig.kernelLocal.set(null);
         JBossContextConfig.deploymentUnitLocal.set(null);
         // JBAS-8406: Temp hack, will move to NamingListener
         CurrentComponent.pop();
         // JBAS-8278
         CDIExceptionStore.reset();
      }
      if (context.getState() != 1)
      {
         context.destroy();
         throw new DeploymentException("URL " + warUrlStr + " deployment failed");
      }

      /*
       * Add security association valve after the authorization valves so that the authenticated user may be associated
       * with the request thread/session.
       */
      if (!config.isStandalone())
      {
         SecurityAssociationValve securityAssociationValve = new SecurityAssociationValve(metaData, config.getSecurityManagerService());
         securityAssociationValve.setSubjectAttributeName(config.getSubjectAttributeName());
         context.addValve(securityAssociationValve);
      }

      /*
       * TODO: Retrieve the state, and throw an exception in case of a failure Integer state = (Integer)
       * server.getAttribute(objectName, "state"); if (state.intValue() != 1) { throw new DeploymentException("URL " +
View Full Code Here

      MockEngine engine = new MockEngine();
      engine.setJvmRoute(jvmRoute);
      MockHost host = new MockHost();
      host.setName("localhost");
      engine.addChild(host);
      StandardContext container = new StandardContext();
      container.setName(warName);
      host.addChild(container);
      container.setManager(mgr);
     
      // Do this after assigning the manager to the container, or else
      // the container's setting will override ours
      // Can't just set the container as their config is per minute not per second
      mgr.setMaxInactiveInterval(maxInactiveInterval);
View Full Code Here

   {
      MockEngine engine = new MockEngine();
      MockHost host = new MockHost();
      host.setName("localhost");
      engine.addChild(host);
      StandardContext container = new StandardContext();
      container.setPath(contextPath);
      host.addChild(container);
     
      SessionCookie cookie = container.getSessionCookie();
      if (cookiePath != null)
         cookie.setPath(cookiePath);
      if (cookieComment != null)
         cookie.setComment(cookieComment);
      if (cookieDomain != null)
View Full Code Here

      engine.setName("jboss.web");
      engine.setJvmRoute(jvmRoute);
      MockHost host = new MockHost();
      host.setName("localhost");
      engine.addChild(host);
      StandardContext container = new StandardContext();
      container.setName(warName);
      host.addChild(container);
      container.setManager(mgr);
   }
View Full Code Here

        Tomcat tomcat = getTomcatInstance();

        File appDir =
            new File("test/webapp-3.0");
        // app dir is relative to server home
        StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
                "/test", appDir.getAbsolutePath());

        // This test needs the JSTL libraries
        File lib = new File("webapps/examples/WEB-INF/lib");
        ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

        tomcat.start();

        int rc = getUrl("http://localhost:" + getPort() +
                "/test/bug48nnn/bug48701-fail.jsp", new ByteChunk(), null);
View Full Code Here

    public void testBug56265() throws Exception {
        Tomcat tomcat = getTomcatInstance();

        File appDir = new File("test/webapp-3.0");
        // app dir is relative to server home
        StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
                "/test", appDir.getAbsolutePath());

        // This test needs the JSTL libraries
        File lib = new File("webapps/examples/WEB-INF/lib");
        ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug5nnnn/bug56265.jsp");
View Full Code Here

    public void testBug56334And56561() throws Exception {
        Tomcat tomcat = getTomcatInstance();

        File appDir = new File("test/webapp-3.0");
        // app dir is relative to server home
        StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
                "/test", appDir.getAbsolutePath());

        // This test needs the JSTL libraries
        File lib = new File("webapps/examples/WEB-INF/lib");
        ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug5nnnn/bug56334and56561.jspx");
View Full Code Here

TOP

Related Classes of org.apache.catalina.core.StandardContext$DummyAnnotationProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.