Package javax.servlet.annotation

Examples of javax.servlet.annotation.WebFilter


            }
            for (ClassListInfo info : webAppInfo.webAnnotatedClasses) {
                final String url = info.name;
                for (String filterPath : info.list) {
                    final Class<?> clazz = loadFromUrls(webContext.getClassLoader(), url, filterPath);
                    final WebFilter annotation = clazz.getAnnotation(WebFilter.class);
                    if (annotation != null) {
                        final Properties initParams = new Properties();
                        for (WebInitParam param : annotation.initParams()) {
                            initParams.put(param.name(), param.value());
                        }

                        final FilterConfig config = new SimpleFilterConfig(sce.getServletContext(), info.name, initParams);
                        for (String mapping : annotation.urlPatterns()) {
                            try {
                                addFilterMethod.invoke(null, clazz.getName(), webContext, mapping, config);
                                deployedWebObjects.filterMappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
                            }
                        }
                    }
                }
            }

            final Map<String, PortInfo> ports = new TreeMap<String, PortInfo>();
            for (final PortInfo port : webAppInfo.portInfos) {
                ports.put(port.serviceLink, port);
            }

            // register servlets
            for (ServletInfo info : webAppInfo.servlets) {
                if ("true".equalsIgnoreCase(appInfo.properties.getProperty("openejb.jaxrs.on", "true"))) {
                    // skip jaxrs servlets
                    boolean skip = false;
                    for (ParamValueInfo pvi : info.initParams) {
                        if ("javax.ws.rs.Application".equals(pvi.name) || Application.class.getName().equals(pvi.name)) {
                            skip = true;
                        }
                    }

                    if (skip) {
                        continue;
                    }

                    if (info.servletClass == null) {
                        try {
                            if (Application.class.isAssignableFrom(classLoader.loadClass(info.servletName))) {
                                continue;
                            }
                        } catch (Exception e) {
                            // no-op
                        }
                    }
                }

                // If POJO web services, it will be overriden with WsServlet
                if (ports.containsKey(info.servletName) || ports.containsKey(info.servletClass)) {
                    continue;
                }

                // deploy
                for (String mapping : info.mappings) {
                    try {
                        addServletMethod.invoke(null, info.servletClass, webContext, mapping);
                        deployedWebObjects.mappings.add(mapping);
                    } catch (Exception e) {
                        LOGGER.warning(e.getMessage(), e);
                    }
                }
            }

            for (ClassListInfo info : webAppInfo.webAnnotatedClasses) {
                final String url = info.name;
                for (String servletPath : info.list) {
                    final Class<?> clazz = loadFromUrls(webContext.getClassLoader(), url, servletPath);
                    final WebServlet annotation = clazz.getAnnotation(WebServlet.class);
                    if (annotation != null) {
                        for (String mapping : annotation.urlPatterns()) {
                            try {
                                addServletMethod.invoke(null, clazz.getName(), webContext, mapping);
                                deployedWebObjects.mappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
View Full Code Here


     * Process the application classes annotations, if it exists.
     */
    protected void processConfigAnnotations(Class<?> clazz) {

        if (clazz.isAnnotationPresent(WebFilter.class)) {
            WebFilter annotation = clazz.getAnnotation(WebFilter.class);
            // Add servlet filter
            String filterName = annotation.filterName();
            FilterDef filterDef = new FilterDef();
            filterDef.setFilterName(annotation.filterName());
            filterDef.setFilterClass(clazz.getName());
            WebInitParam[] params = annotation.initParams();
            for (int i = 0; i < params.length; i++) {
                filterDef.addInitParameter(params[i].name(), params[i].value());
            }
            context.addFilterDef(filterDef);
            FilterMap filterMap = new FilterMap();
            filterMap.setFilterName(filterName);
            String[] urlPatterns = annotation.urlPatterns();
            if (urlPatterns != null) {
                for (int i = 0; i < urlPatterns.length; i++) {
                    filterMap.addURLPattern(urlPatterns[i]);
                }
            }
            String[] servletNames = annotation.servletNames();
            if (servletNames != null) {
                for (int i = 0; i < servletNames.length; i++) {
                    filterMap.addServletName(servletNames[i]);
                }
            }
            DispatcherType[] dispatcherTypes = annotation.dispatcherTypes();
            if (dispatcherTypes != null) {
                for (int i = 0; i < dispatcherTypes.length; i++) {
                    filterMap.setDispatcher(dispatcherTypes[i].toString());
                }
            }
            context.addFilterMap(filterMap);
        }
        if (clazz.isAnnotationPresent(WebServlet.class)) {
            WebServlet annotation = clazz.getAnnotation(WebServlet.class);
            // Add servlet
            Wrapper wrapper = context.createWrapper();
            wrapper.setName(annotation.name());
            wrapper.setServletClass(clazz.getName());
            wrapper.setLoadOnStartup(annotation.loadOnStartup());
            WebInitParam[] params = annotation.initParams();
            for (int i = 0; i < params.length; i++) {
                wrapper.addInitParameter(params[i].name(), params[i].value());
            }
            context.addChild(wrapper);
            String[] urlPatterns = annotation.urlPatterns();
            if (urlPatterns != null) {
                for (int i = 0; i < urlPatterns.length; i++) {
                    context.addServletMapping(urlPatterns[i], annotation.name());
                }
            }
        }
        if (clazz.isAnnotationPresent(WebListener.class)) {
            // Add listener
View Full Code Here

                "The Class {0} having annotation {1} need to implement the interface {2}.",
                new Object[] { filterClass.getName(), WebFilter.class.getName(), javax.servlet.Filter.class.getName() }));
            return getDefaultFailedResult();
        }

        WebFilter webFilterAn = (WebFilter)ainfo.getAnnotation();
        String filterName = webFilterAn.filterName();
        if (filterName == null || filterName.length() == 0) {
            filterName = filterClass.getName();
        }

        ServletFilterDescriptor servletFilterDesc = null;
        for (ServletFilter sfDesc : webBundleDesc.getServletFilters()) {
            if (filterName.equals(sfDesc.getName())) {
                servletFilterDesc = (ServletFilterDescriptor)sfDesc;
                break;
            }
        }

        if (servletFilterDesc == null) {
            servletFilterDesc = new ServletFilterDescriptor();
            servletFilterDesc.setName(filterName);
            webBundleDesc.addServletFilter(servletFilterDesc);
        } else {
            String filterImpl = servletFilterDesc.getClassName();
            if (filterImpl != null && filterImpl.length() > 0 &&
                    !filterImpl.equals(filterClass.getName())) {
                log(Level.SEVERE, ainfo,
                    localStrings.getLocalString(
                    "enterprise.deployment.annotation.handlers.filternamedontmatch",
                    "The filter '{0}' has implementation '{1}' in xml. It does not match with '{2}' from annotation @{3}.",
                    new Object[] { filterName, filterImpl, filterClass.getName(),
                    WebFilter.class.getName() }));
                return getDefaultFailedResult();
            }
        }

        servletFilterDesc.setClassName(filterClass.getName());
        if (servletFilterDesc.getDescription() == null ||
                servletFilterDesc.getDescription().length() == 0) {

            servletFilterDesc.setDescription(webFilterAn.description());
        }
        if (servletFilterDesc.hasSetDisplayName()) {
            servletFilterDesc.setDisplayName(webFilterAn.displayName());
        }

        if (servletFilterDesc.getInitializationParameters().size() == 0) {
            WebInitParam[] initParams = webFilterAn.initParams();
            if (initParams != null && initParams.length > 0) {
                for (WebInitParam initParam : initParams) {
                    servletFilterDesc.addInitializationParameter(
                        new EnvironmentProperty(
                            initParam.name(), initParam.value(),
                            initParam.description()));
                }
            }
        }

        if (servletFilterDesc.getSmallIconUri() == null) {
            servletFilterDesc.setSmallIconUri(webFilterAn.smallIcon());
        }
        if (servletFilterDesc.getLargeIconUri() == null) {
            servletFilterDesc.setLargeIconUri(webFilterAn.largeIcon());
        }

        if (servletFilterDesc.isAsyncSupported() == null) {
            servletFilterDesc.setAsyncSupported(webFilterAn.asyncSupported());
        }

        ServletFilterMapping servletFilterMappingDesc = null;
        boolean hasUrlPattern = false;
        boolean hasServletName = false;

        for (ServletFilterMapping sfm : webBundleDesc.getServletFilterMappings()) {
            if (filterName.equals(sfm.getName())) {
                servletFilterMappingDesc = sfm;
                hasUrlPattern = hasUrlPattern || (sfm.getURLPatterns().size() > 0);
                hasServletName = hasServletName || (sfm.getServletNames().size() > 0);
            }
        }

        if (servletFilterMappingDesc == null) {
            servletFilterMappingDesc = new ServletFilterMappingDescriptor();
            servletFilterMappingDesc.setName(filterName);
            webBundleDesc.addServletFilterMapping(servletFilterMappingDesc);
        }

        if (!hasUrlPattern) {
            String[] urlPatterns = webFilterAn.urlPatterns();
            if (urlPatterns == null || urlPatterns.length == 0) {
                urlPatterns = webFilterAn.value();
            }

            // accept here as url patterns may be defined in top level xml
            boolean validUrlPatterns = true;
            if (urlPatterns != null && urlPatterns.length > 0) {
                for (String up : urlPatterns) {
                    if (!URLPattern.isValid(up)) {
                        validUrlPatterns = false;
                        break;
                    }
                    servletFilterMappingDesc.addURLPattern(up);
                }
            }

            if (!validUrlPatterns) {
                String urlPatternString =
                    (urlPatterns != null) ? Arrays.toString(urlPatterns) : "";

                throw new IllegalArgumentException(localStrings.getLocalString(
                        "enterprise.deployment.annotation.handlers.invalidUrlPatterns",
                        "Invalid url patterns: {0}.",
                        urlPatternString));
            }
        }

        if (!hasServletName) {
            String[] servletNames = webFilterAn.servletNames();
            if (servletNames != null && servletNames.length > 0) {
                for (String sn : servletNames) {
                    servletFilterMappingDesc.addServletName(sn);
                }
            }
        }

        if (servletFilterMappingDesc.getDispatchers().size() == 0) {
            DispatcherType[] dispatcherTypes = webFilterAn.dispatcherTypes();
                if (dispatcherTypes != null && dispatcherTypes.length > 0) {
                for (DispatcherType dType : dispatcherTypes) {
                    servletFilterMappingDesc.addDispatcher(dType.name());
                }
            }
View Full Code Here

     * Process the application classes annotations, if it exists.
     */
    protected void processConfigAnnotations(Class<?> clazz) {

        if (clazz.isAnnotationPresent(WebFilter.class)) {
            WebFilter annotation = clazz.getAnnotation(WebFilter.class);
            // Add servlet filter
            String filterName = annotation.filterName();
            FilterDef filterDef = new FilterDef();
            filterDef.setFilterName(annotation.filterName());
            filterDef.setFilterClass(clazz.getName());
            WebInitParam[] params = annotation.initParams();
            for (int i = 0; i < params.length; i++) {
                filterDef.addInitParameter(params[i].name(), params[i].value());
            }
            context.addFilterDef(filterDef);
            FilterMap filterMap = new FilterMap();
            filterMap.setFilterName(filterName);
            String[] urlPatterns = annotation.urlPatterns();
            if (urlPatterns != null) {
                for (int i = 0; i < urlPatterns.length; i++) {
                    filterMap.addURLPattern(urlPatterns[i]);
                }
            }
            String[] servletNames = annotation.servletNames();
            if (servletNames != null) {
                for (int i = 0; i < servletNames.length; i++) {
                    filterMap.addServletName(servletNames[i]);
                }
            }
            DispatcherType[] dispatcherTypes = annotation.dispatcherTypes();
            if (dispatcherTypes != null) {
                for (int i = 0; i < dispatcherTypes.length; i++) {
                    filterMap.setDispatcher(dispatcherTypes[i].toString());
                }
            }
            context.addFilterMap(filterMap);
        }
        if (clazz.isAnnotationPresent(WebServlet.class)) {
            WebServlet annotation = clazz.getAnnotation(WebServlet.class);
            // Add servlet
            Wrapper wrapper = context.createWrapper();
            wrapper.setName(annotation.name());
            wrapper.setServletClass(clazz.getName());
            wrapper.setLoadOnStartup(annotation.loadOnStartup());
            WebInitParam[] params = annotation.initParams();
            for (int i = 0; i < params.length; i++) {
                wrapper.addInitParameter(params[i].name(), params[i].value());
            }
            context.addChild(wrapper);
            String[] urlPatterns = annotation.urlPatterns();
            if (urlPatterns != null) {
                for (int i = 0; i < urlPatterns.length; i++) {
                    context.addServletMapping(urlPatterns[i], annotation.name());
                }
            }
        }
        if (clazz.isAnnotationPresent(WebListener.class)) {
            // Add listener
View Full Code Here

        } else {
          patterns = servlet.value();
        }
      }
    } else {
      WebFilter filter = getClass().getAnnotation(WebFilter.class);
      if (filter != null) {
        if (filter.urlPatterns().length > 0) {
          patterns = filter.urlPatterns();
        } else {
          patterns = filter.value()
        }
      }
    }
    if (patterns != null && patterns.length > 0) {
      String pattern = patterns[0];
View Full Code Here

                final String url = info.name;
                for (String filterPath : info.list) {
                    String classname = nameFromUrls(url, filterPath);

                    final Class<?> clazz = webContext.getClassLoader().loadClass(classname);
                    final WebFilter annotation = clazz.getAnnotation(WebFilter.class);
                    if (annotation != null) {
                        final Properties initParams = new Properties();
                        for (WebInitParam param : annotation.initParams()) {
                            initParams.put(param.name(), param.value());
                        }

                        final FilterConfig config = new SimpleFilterConfig(sce.getServletContext(), info.name, initParams);
                        for (String mapping: annotation.urlPatterns()) {
                            try {
                                addFilterMethod.invoke(null, classname, webContext, mapping, config);
                                deployedWebObjects.filterMappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
                            }
                        }
                    }
                }
            }

            // register servlets
            for (ServletInfo info : webAppInfo.servlets) {
                if ("true".equalsIgnoreCase(appInfo.properties.getProperty("openejb.jaxrs.on", "true"))) {
                    // skip jaxrs servlets
                    boolean skip = false;
                    for (ParamValueInfo pvi : info.initParams) {
                        if ("javax.ws.rs.Application".equals(pvi.name) || Application.class.getName().equals(pvi.name)) {
                            skip = true;
                        }
                    }

                    if (skip) {
                        continue;
                    }

                    if (info.servletClass == null) {
                        try {
                            if (Application.class.isAssignableFrom(classLoader.loadClass(info.servletName))) {
                                continue;
                            }
                        } catch (Exception e) {
                            // no-op
                        }
                    }
                } // else let the user manage itself a rest servlet etc...

                // deploy
                for (String mapping : info.mappings) {
                    try {
                        addServletMethod.invoke(null, info.servletClass, webContext, mapping);
                        deployedWebObjects.mappings.add(mapping);
                    } catch (Exception e) {
                        LOGGER.warning(e.getMessage(), e);
                    }
                }
            }
            for (ClassListInfo info : webAppInfo.webAnnotatedClasses) {
                final String url = info.name;
                for (String servletPath : info.list) {
                    String classname = nameFromUrls(url, servletPath);

                    final Class<?> clazz = webContext.getClassLoader().loadClass(classname);
                    final WebServlet annotation = clazz.getAnnotation(WebServlet.class);
                    if (annotation != null) {
                        for (String mapping: annotation.urlPatterns()) {
                            try {
                                addServletMethod.invoke(null, classname, webContext, mapping);
                                deployedWebObjects.mappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
View Full Code Here

      super(finder);
   }

   public WebMetaData create(Class<?> element)
   {
      WebFilter webFilter = finder.getAnnotation(element, WebFilter.class);
      if (webFilter == null)
         return null;

      WebMetaData metaData = new WebMetaData();
      FiltersMetaData filters = new FiltersMetaData();
      FilterMetaData filter = new FilterMetaData();
      filter.setFilterClass(element.getName());
      String filterName = null;
      if (webFilter.filterName().length() == 0)
         filterName = element.getName();
      else
         filterName = webFilter.filterName();
      filter.setFilterName(filterName);
      filter.setAsyncSupported(webFilter.asyncSupported());
      if (webFilter.initParams() != null)
      {
         List<ParamValueMetaData> initParams = new ArrayList<ParamValueMetaData>();
         for (WebInitParam webInitParam : webFilter.initParams())
         {
            ParamValueMetaData paramValue = new ParamValueMetaData();
            paramValue.setParamName(webInitParam.name());
            paramValue.setParamValue(webInitParam.value());
            initParams.add(paramValue);
         }
         filter.setInitParam(initParams);
      }
      DescriptionGroupMetaData descriptionGroup =
         ProcessorUtils.getDescriptionGroup(webFilter.description(), webFilter.displayName(),
            webFilter.smallIcon(), webFilter.largeIcon());
      if (descriptionGroup != null)
         filter.setDescriptionGroup(descriptionGroup);
      filters.add(filter);
      metaData.setFilters(filters);
      if (webFilter.urlPatterns() != null || webFilter.value() != null || webFilter.servletNames() != null)
      {
         List<FilterMappingMetaData> filterMappings = new ArrayList<FilterMappingMetaData>();
         FilterMappingMetaData filterMapping = new FilterMappingMetaData();
         filterMapping.setFilterName(filterName);
         if (webFilter.urlPatterns() != null || webFilter.value() != null)
         {
            List<String> urlPatterns = new ArrayList<String>();
            if (webFilter.urlPatterns() != null)
            {
               for (String urlPattern : webFilter.urlPatterns())
               {
                  urlPatterns.add(urlPattern);
               }
            }
            if (webFilter.value() != null)
            {
               for (String urlPattern : webFilter.value())
               {
                  urlPatterns.add(urlPattern);
               }
            }
            filterMapping.setUrlPatterns(urlPatterns);
         }
         if (webFilter.servletNames() != null)
         {
            List<String> servletNames = new ArrayList<String>();
            for (String servletName : webFilter.servletNames())
            {
               servletNames.add(servletName);
            }
            filterMapping.setServletNames(servletNames);
         }
         if (webFilter.dispatcherTypes() != null)
         {
            List<DispatcherType> dispatcherTypes = new ArrayList<DispatcherType>();
            for (javax.servlet.DispatcherType dispatcherType : webFilter.dispatcherTypes())
            {
               dispatcherTypes.add(DispatcherType.valueOf(dispatcherType.toString()));
            }
            filterMapping.setDispatchers(dispatcherTypes);
         }
View Full Code Here

      return metaData;
   }

   public void process(WebMetaData metaData, Class<?> type)
   {
      WebFilter annotation = finder.getAnnotation(type, WebFilter.class);
      if(annotation == null)
         return;

      WebMetaData filterMetaData = create(type);
      if (metaData.getFilters() == null)
View Full Code Here

                "The Class {0} having annotation {1} need to implement the interface {2}.",
                new Object[] { filterClass.getName(), WebFilter.class.getName(), javax.servlet.Filter.class.getName() }));
            return getDefaultFailedResult();
        }

        WebFilter webFilterAn = (WebFilter)ainfo.getAnnotation();
        String filterName = webFilterAn.filterName();
        if (filterName == null || filterName.length() == 0) {
            filterName = filterClass.getName();
        }

        ServletFilterDescriptor servletFilterDesc = null;
        for (ServletFilter sfDesc : webBundleDesc.getServletFilters()) {
            if (filterName.equals(sfDesc.getName())) {
                servletFilterDesc = (ServletFilterDescriptor)sfDesc;
                break;
            }
        }

        if (servletFilterDesc == null) {
            servletFilterDesc = new ServletFilterDescriptor();
            servletFilterDesc.setName(filterName);
            webBundleDesc.addServletFilter(servletFilterDesc);
        } else {
            String filterImpl = servletFilterDesc.getClassName();
            if (filterImpl != null && filterImpl.length() > 0 &&
                    !filterImpl.equals(filterClass.getName())) {
                log(Level.SEVERE, ainfo,
                    localStrings.getLocalString(
                    "web.deployment.annotation.handlers.filternamedontmatch",
                    "The filter '{0}' has implementation '{1}' in xml. It does not match with '{2}' from annotation @{3}.",
                    new Object[] { filterName, filterImpl, filterClass.getName(),
                    WebFilter.class.getName() }));
                return getDefaultFailedResult();
            }
        }

        servletFilterDesc.setClassName(filterClass.getName());
        if (servletFilterDesc.getDescription() == null ||
                servletFilterDesc.getDescription().length() == 0) {

            servletFilterDesc.setDescription(webFilterAn.description());
        }
        if (servletFilterDesc.hasSetDisplayName()) {
            servletFilterDesc.setDisplayName(webFilterAn.displayName());
        }

        if (servletFilterDesc.getInitializationParameters().size() == 0) {
            WebInitParam[] initParams = webFilterAn.initParams();
            if (initParams != null && initParams.length > 0) {
                for (WebInitParam initParam : initParams) {
                    servletFilterDesc.addInitializationParameter(
                        new EnvironmentProperty(
                            initParam.name(), initParam.value(),
                            initParam.description()));
                }
            }
        }

        if (servletFilterDesc.getSmallIconUri() == null) {
            servletFilterDesc.setSmallIconUri(webFilterAn.smallIcon());
        }
        if (servletFilterDesc.getLargeIconUri() == null) {
            servletFilterDesc.setLargeIconUri(webFilterAn.largeIcon());
        }

        if (servletFilterDesc.isAsyncSupported() == null) {
            servletFilterDesc.setAsyncSupported(webFilterAn.asyncSupported());
        }

        ServletFilterMapping servletFilterMappingDesc = null;
        boolean hasUrlPattern = false;
        boolean hasServletName = false;

        for (ServletFilterMapping sfm : webBundleDesc.getServletFilterMappings()) {
            if (filterName.equals(sfm.getName())) {
                servletFilterMappingDesc = sfm;
                hasUrlPattern = hasUrlPattern || (sfm.getUrlPatterns().size() > 0);
                hasServletName = hasServletName || (sfm.getServletNames().size() > 0);
            }
        }

        if (servletFilterMappingDesc == null) {
            servletFilterMappingDesc = new ServletFilterMappingDescriptor();
            servletFilterMappingDesc.setName(filterName);
            webBundleDesc.addServletFilterMapping(servletFilterMappingDesc);
        }

        if (!hasUrlPattern) {
            String[] urlPatterns = webFilterAn.urlPatterns();
            if (urlPatterns == null || urlPatterns.length == 0) {
                urlPatterns = webFilterAn.value();
            }

            // accept here as url patterns may be defined in top level xml
            boolean validUrlPatterns = true;
            if (urlPatterns != null && urlPatterns.length > 0) {
                for (String up : urlPatterns) {
                    if (!URLPattern.isValid(up)) {
                        validUrlPatterns = false;
                        break;
                    }
                    servletFilterMappingDesc.addURLPattern(up);
                }
            }

            if (!validUrlPatterns) {
                String urlPatternString =
                    (urlPatterns != null) ? Arrays.toString(urlPatterns) : "";

                throw new IllegalArgumentException(localStrings.getLocalString(
                        "web.deployment.annotation.handlers.invalidUrlPatterns",
                        "Invalid url patterns: {0}.",
                        urlPatternString));
            }
        }

        if (!hasServletName) {
            String[] servletNames = webFilterAn.servletNames();
            if (servletNames != null && servletNames.length > 0) {
                for (String sn : servletNames) {
                    servletFilterMappingDesc.addServletName(sn);
                }
            }
        }

        if (servletFilterMappingDesc.getDispatchers().size() == 0) {
            DispatcherType[] dispatcherTypes = webFilterAn.dispatcherTypes();
                if (dispatcherTypes != null && dispatcherTypes.length > 0) {
                for (DispatcherType dType : dispatcherTypes) {
                    servletFilterMappingDesc.addDispatcher(dType.name());
                }
            }
View Full Code Here

                final String url = info.name;
                for (String filterPath : info.list) {
                    String classname = nameFromUrls(url, filterPath);

                    final Class<?> clazz = webContext.getClassLoader().loadClass(classname);
                    final WebFilter annotation = clazz.getAnnotation(WebFilter.class);
                    if (annotation != null) {
                        final Properties initParams = new Properties();
                        for (WebInitParam param : annotation.initParams()) {
                            initParams.put(param.name(), param.value());
                        }

                        final FilterConfig config = new SimpleFilterConfig(sce.getServletContext(), info.name, initParams);
                        for (String mapping: annotation.urlPatterns()) {
                            try {
                                addFilterMethod.invoke(null, classname, webContext, mapping, config);
                                deployedWebObjects.filterMappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
                            }
                        }
                    }
                }
            }

            // register servlets
            for (ServletInfo info : webAppInfo.servlets) {
                for (String mapping : info.mappings) {
                    try {
                        addServletMethod.invoke(null, info.servletClass, webContext, mapping);
                        deployedWebObjects.mappings.add(mapping);
                    } catch (Exception e) {
                        LOGGER.warning(e.getMessage(), e);
                    }
                }
            }
            for (ClassListInfo info : webAppInfo.webAnnotatedClasses) {
                final String url = info.name;
                for (String servletPath : info.list) {
                    String classname = nameFromUrls(url, servletPath);

                    final Class<?> clazz = webContext.getClassLoader().loadClass(classname);
                    final WebServlet annotation = clazz.getAnnotation(WebServlet.class);
                    if (annotation != null) {
                        for (String mapping: annotation.urlPatterns()) {
                            try {
                                addServletMethod.invoke(null, classname, webContext, mapping);
                                deployedWebObjects.mappings.add(mapping);
                            } catch (Exception e) {
                                LOGGER.warning(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of javax.servlet.annotation.WebFilter

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.