Package javax.servlet

Examples of javax.servlet.ServletContainerInitializer


            {
               VirtualFile virtualFile = VFS.getChild(jarURL);
               VirtualFile sci = virtualFile.getChild("META-INF/services/javax.servlet.ServletContainerInitializer");
               if (sci.exists())
               {
                  ServletContainerInitializer service = loadSci(unit, sci, jarURL.getPath(), false);
                  if (service != null)
                  {
                     scis.add(service);
                  }
               }
            }
            catch (URISyntaxException e)
            {
               DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jarURL, e);
            }
         }
      }
      // Find local ServletContainerInitializer services
      List<String> order =
         (List<String>) unit.getAttachment(MergedJBossWebMetaDataDeployer.WEB_ORDER_ATTACHMENT_NAME);
      Map<String, VirtualFile> localScis = (Map<String, VirtualFile>)
         unit.getAttachment(MergedJBossWebMetaDataDeployer.WEB_SCIS_ATTACHMENT_NAME);
      if (order != null && localScis != null)
      {
         for (String jar : order)
         {
            VirtualFile sci = localScis.get(jar);
            if (sci != null)
            {
               ServletContainerInitializer service = loadSci(unit, sci, jar, true);
               if (service != null)
               {
                  scis.add(service);
               }
            }
         }
      }
      unit.addAttachment(SCI_ATTACHMENT_NAME, scis);

      // Process HandlesTypes for ServletContainerInitializer
      Map<Class<?>, Set<ServletContainerInitializer>> typesMap =
         new HashMap<Class<?>, Set<ServletContainerInitializer>>();
      Map<ServletContainerInitializer, Set<Class<?>>> handlesTypes =
         new HashMap<ServletContainerInitializer, Set<Class<?>>>();
      for (ServletContainerInitializer service : scis)
      {
         if (service.getClass().isAnnotationPresent(HandlesTypes.class))
         {
            HandlesTypes handlesTypesAnnotation = service.getClass().getAnnotation(HandlesTypes.class);
            Class<?>[] typesArray = handlesTypesAnnotation.value();
            if (typesArray != null)
            {
               for (Class<?> type : typesArray)
               {
View Full Code Here


  
  
   private ServletContainerInitializer loadSci(DeploymentUnit unit, VirtualFile sci, String jar, boolean error)
      throws DeploymentException
   {
      ServletContainerInitializer service = null;
      InputStream is = null;
      try
      {
         // Get the ServletContainerInitializer class name
         is = sci.openStream();
View Full Code Here

     */
    @Override
    public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException {

        for (Class<?> clazz : INITIALIZERS) {
            ServletContainerInitializer initializer = null;

            try {
                initializer = (ServletContainerInitializer) clazz.newInstance();
            } catch (Exception e) {
                LOGGER.error("Failed to instantiate servlet initializer " + clazz.getName(), e);
            }

            if (initializer != null) {
                try {
                    initializer.onStartup(null, servletContext);
                } catch (Exception e) {
                    LOGGER.error("Failed to initialize servlet by " + clazz.getName(), e);
                }
            }
        }
View Full Code Here

       
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            JarFile jarFile = null;
            InputStream is = null;
            ServletContainerInitializer sci = null;
            try {
                if ("jar".equals(url.getProtocol())) {
                    JarURLConnection conn =
                        (JarURLConnection) url.openConnection();
                    jarFile = conn.getJarFile();
                    ZipEntry entry = jarFile.getEntry(SCI_LOCATION);
                    if (entry != null) {
                        is = jarFile.getInputStream(entry);
                    }
                } else if ("file".equals(url.getProtocol())) {
                    String path = url.getPath();
                    File file = new File(path, SCI_LOCATION);
                    if (file.exists()) {
                        is = new FileInputStream(file);
                    }
                }
                if (is != null) {
                    sci = getServletContainerInitializer(is);
                }
            } catch (IOException ioe) {
                log.error(sm.getString(
                        "contextConfig.servletContainerInitializerFail", url,
                        context.getName()));
                ok = false;
                return;
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
                if (jarFile != null) {
                    try {
                        jarFile.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
            }
           
            if (sci == null) {
                continue;
            }

            initializerClassMap.put(sci, new HashSet<Class<?>>());
           
            HandlesTypes ht =
                sci.getClass().getAnnotation(HandlesTypes.class);
            if (ht != null) {
                Class<?>[] types = ht.value();
                if (types != null) {
                    for (Class<?> type : types) {
                        Set<ServletContainerInitializer> scis =
View Full Code Here

                // Should never happen with UTF-8
                // If it does - ignore & return null
            }
        }
       
        ServletContainerInitializer sci = null;
        try {
            Class<?> clazz = Class.forName(className,true,
                    context.getLoader().getClassLoader());
             sci = (ServletContainerInitializer) clazz.newInstance();
        } catch (ClassNotFoundException e) {
View Full Code Here

                Iterator<ServletContainerInitializerInfo> initializers =
                    getServletContainerInitializerInfo().values().iterator();
                while (initializers.hasNext()) {
                    ServletContainerInitializerInfo service = initializers.next();
                    try {
                        ServletContainerInitializer servletContainerInitializer =
                            (ServletContainerInitializer) service.getServletContainerInitializer().newInstance();
                        servletContainerInitializer.onStartup(service.getStartupNotifySet(), context.getServletContext());
                    } catch (Throwable t) {
                        log.error(sm.getString("contextConfig.servletContainerInitializer",
                                service.getServletContainerInitializer().getName()), t);
                        ok = false;
                    }
View Full Code Here

        Map<String, VirtualFile> localScis = warMetaData.getScis();
        if (order != null && localScis != null) {
            for (String jar : order) {
                VirtualFile sci = localScis.get(jar);
                if (sci != null) {
                    ServletContainerInitializer service = loadSci(classLoader, sci, jar, true);
                    if (service != null) {
                        scis.add(service);
                    }
                }
            }
        }
        // Process HandlesTypes for ServletContainerInitializer
        Map<Class<?>, Set<ServletContainerInitializer>> typesMap = new HashMap<Class<?>, Set<ServletContainerInitializer>>();
        for (ServletContainerInitializer service : scis) {
            if (service.getClass().isAnnotationPresent(HandlesTypes.class)) {
                HandlesTypes handlesTypesAnnotation = service.getClass().getAnnotation(HandlesTypes.class);
                Class<?>[] typesArray = handlesTypesAnnotation.value();
                if (typesArray != null) {
                    for (Class<?> type : typesArray) {
                        Set<ServletContainerInitializer> servicesSet = typesMap.get(type);
                        if (servicesSet == null) {
View Full Code Here

    public void undeploy(final DeploymentUnit context) {
    }

    private ServletContainerInitializer loadSci(ClassLoader classLoader, VirtualFile sci, String jar, boolean error) throws DeploymentUnitProcessingException {
        ServletContainerInitializer service = null;
        InputStream is = null;
        try {
            // Get the ServletContainerInitializer class name
            is = sci.openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
View Full Code Here

        lc.setAuthMethod("BASIC");
        ctx.setLoginConfig(lc);
        ctx.getPipeline().addValve(new BasicAuthenticator());

        // Add ServletContainerInitializer
        ServletContainerInitializer sci = new Bug50015SCI();
        ctx.addServletContainerInitializer(sci, null);

        // Start the context
        tomcat.start();
View Full Code Here

        lc.setAuthMethod("BASIC");
        ctx.setLoginConfig(lc);
        ctx.getPipeline().addValve(new BasicAuthenticator());

        // Add ServletContainerInitializer
        ServletContainerInitializer sci = new Bug50015SCI();
        ctx.addServletContainerInitializer(sci, null);
       
        // Start the context
        tomcat.start();
       
View Full Code Here

TOP

Related Classes of javax.servlet.ServletContainerInitializer

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.