Package org.jboss.metadata.web.spec

Examples of org.jboss.metadata.web.spec.ServletsMetaData


    throws DeploymentUnitProcessingException {
        Web30MetaData metaData = new Web30MetaData();
        // @WebServlet
        final List<AnnotationInstance> webServletAnnotations = index.getAnnotations(webServlet);
        if (webServletAnnotations != null && webServletAnnotations.size() > 0) {
            ServletsMetaData servlets = new ServletsMetaData();
            List<ServletMappingMetaData> servletMappings = new ArrayList<ServletMappingMetaData>();
            for (final AnnotationInstance annotation : webServletAnnotations) {
                ServletMetaData servlet = new ServletMetaData();
                AnnotationTarget target = annotation.target();
                if (!(target instanceof ClassInfo)) {
                    throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidWebServletAnnotation(target));
                }
                ClassInfo classInfo = ClassInfo.class.cast(target);
                servlet.setServletClass(classInfo.toString());
                AnnotationValue nameValue = annotation.value("name");
                if (nameValue == null || nameValue.asString().isEmpty()) {
                    servlet.setName(classInfo.toString());
                } else {
                    servlet.setName(nameValue.asString());
                }
                AnnotationValue loadOnStartup = annotation.value("loadOnStartup");
                if (loadOnStartup != null && loadOnStartup.asInt() > 0) {
                    servlet.setLoadOnStartupInt(loadOnStartup.asInt());
                }
                AnnotationValue asyncSupported = annotation.value("asyncSupported");
                if (asyncSupported != null) {
                    servlet.setAsyncSupported(asyncSupported.asBoolean());
                }
                AnnotationValue initParamsValue = annotation.value("initParams");
                if (initParamsValue != null) {
                    AnnotationInstance[] initParamsAnnotations = initParamsValue.asNestedArray();
                    if (initParamsAnnotations != null && initParamsAnnotations.length > 0) {
                        List<ParamValueMetaData> initParams = new ArrayList<ParamValueMetaData>();
                        for (AnnotationInstance initParamsAnnotation : initParamsAnnotations) {
                            ParamValueMetaData initParam = new ParamValueMetaData();
                            AnnotationValue initParamName = initParamsAnnotation.value("name");
                            AnnotationValue initParamValue = initParamsAnnotation.value();
                            if (initParamName == null || initParamValue == null) {
                                throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidWebInitParamAnnotation(target));
                            }
                            AnnotationValue initParamDescription = initParamsAnnotation.value("description");
                            initParam.setParamName(initParamName.asString());
                            initParam.setParamValue(initParamValue.asString());
                            if (initParamDescription != null) {
                                Descriptions descriptions = getDescription(initParamDescription.asString());
                                if (descriptions != null) {
                                    initParam.setDescriptions(descriptions);
                                }
                            }
                            initParams.add(initParam);
                        }
                        servlet.setInitParam(initParams);
                    }
                }
                AnnotationValue descriptionValue = annotation.value("description");
                AnnotationValue displayNameValue = annotation.value("displayName");
                AnnotationValue smallIconValue = annotation.value("smallIcon");
                AnnotationValue largeIconValue = annotation.value("largeIcon");
                DescriptionGroupMetaData descriptionGroup =
                    getDescriptionGroup((descriptionValue == null) ? "" : descriptionValue.asString(),
                            (displayNameValue == null) ? "" : displayNameValue.asString(),
                            (smallIconValue == null) ? "" : smallIconValue.asString(),
                            (largeIconValue == null) ? "" : largeIconValue.asString());
                if (descriptionGroup != null) {
                    servlet.setDescriptionGroup(descriptionGroup);
                }
                ServletMappingMetaData servletMapping = new ServletMappingMetaData();
                servletMapping.setServletName(servlet.getName());
                List<String> urlPatterns = new ArrayList<String>();
                AnnotationValue urlPatternsValue = annotation.value("urlPatterns");
                if (urlPatternsValue != null) {
                    for (String urlPattern : urlPatternsValue.asStringArray()) {
                        urlPatterns.add(urlPattern);
                    }
                }
                urlPatternsValue = annotation.value();
                if (urlPatternsValue != null) {
                    for (String urlPattern : urlPatternsValue.asStringArray()) {
                        urlPatterns.add(urlPattern);
                    }
                }
                if (urlPatterns.size() > 0) {
                    servletMapping.setUrlPatterns(urlPatterns);
                    servletMappings.add(servletMapping);
                }
                servlets.add(servlet);
            }
            metaData.setServlets(servlets);
            metaData.setServletMappings(servletMappings);
        }
        // @WebFilter
View Full Code Here


      EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData();
      super.process(env, type);
      metaData.setJndiEnvironmentRefsGroup(env);

      // @RunAs
      ServletsMetaData servlets = metaData.getServlets();
      if(servlets == null)
      {
         servlets = new ServletsMetaData();
         metaData.setServlets(servlets);
      }
      super.processClass(servlets, type);
      // @DeclareRoles
      SecurityRolesMetaData securityRoles = metaData.getSecurityRoles();
View Full Code Here

    }

    WebMetaData create() {
        final WebMetaData metadata = new WebMetaData();

        metadata.setServlets(new ServletsMetaData());

        // Add DefaultServlet
        enableStaticResouces(metadata);
        // Add JSPServlet
        enableJsp(metadata);
View Full Code Here

      if(original != null)
         originalRoles = original.getSecurityRoles();
      securityRoles.merge(overrideRoles, originalRoles);

      JBossServletsMetaData soverride = null;
      ServletsMetaData soriginal = null;
      if(override != null)
         soverride = override.getServlets();
      if(original != null)
         soriginal = original.getServlets();
      servlets = JBossServletsMetaData.merge(soverride, soriginal);
View Full Code Here

        }
        filterMappings.add(filterMapping);
    }

    protected void setUpStaticResourceServlet(RackMetaData rackAppMetaData, WebMetaData webMetaData, boolean enablePageCache) {
        ServletsMetaData servlets = webMetaData.getServlets();
        if (servlets == null) {
            servlets = new ServletsMetaData();
            webMetaData.setServlets( servlets );
        }

        List<ServletMappingMetaData> servletMappings = webMetaData.getServletMappings();
        if (servletMappings == null) {
            servletMappings = new ArrayList<ServletMappingMetaData>();
            webMetaData.setServletMappings( servletMappings );
        }

        if (rackAppMetaData.getStaticPathPrefix() != null) {
            JBossServletMetaData staticServlet = new JBossServletMetaData();
            staticServlet.setServletClass( STATIC_RESOURCE_SERVLET_CLASS_NAME );
            staticServlet.setServletName( STATIC_RESROUCE_SERVLET_NAME );
            staticServlet.setId( STATIC_RESROUCE_SERVLET_NAME );

            List<ParamValueMetaData> paramsList = new ArrayList<ParamValueMetaData>();
            ParamValueMetaData resourceRootParam = new ParamValueMetaData();
            resourceRootParam.setParamName( "resource.root" );
            resourceRootParam.setParamValue( rackAppMetaData.getStaticPathPrefix() );
            paramsList.add( resourceRootParam );

            if (enablePageCache) {
                // TODO: Let users configure the cache directory and default extension
                ParamValueMetaData cacheDirectoryParam = new ParamValueMetaData();
                cacheDirectoryParam.setParamName( "cache.directory" );
                cacheDirectoryParam.setParamValue( rackAppMetaData.getStaticPathPrefix() );
                paramsList.add( cacheDirectoryParam );
                ParamValueMetaData cacheExtensionParam = new ParamValueMetaData();
                cacheExtensionParam.setParamName( "cache.extension" );
                cacheExtensionParam.setParamValue( ".html" );
                paramsList.add( cacheExtensionParam );
            }

            staticServlet.setInitParam( paramsList );
            servlets.add( staticServlet );

            ServletMappingMetaData staticMapping = new ServletMappingMetaData();
            staticMapping.setServletName( STATIC_RESROUCE_SERVLET_NAME );
            staticMapping.setUrlPatterns( Collections.singletonList( "/*" ) );

View Full Code Here

            servletMappings.add( staticMapping );
        }
    }

    protected void ensureSomeServlet(RackMetaData rackAppMetaData, WebMetaData webMetaData) {
        ServletsMetaData servlets = webMetaData.getServlets();

        if (servlets.isEmpty()) {
            JBossServletMetaData fiveHundredServlet = new JBossServletMetaData();
            fiveHundredServlet.setServletClass( FIVE_HUNDRED_SERVLET_CLASS_NAME );
            fiveHundredServlet.setServletName( FIVE_HUNDRED_SERVLET_NAME );
            fiveHundredServlet.setId( FIVE_HUNDRED_SERVLET_NAME );
            servlets.add( fiveHundredServlet );

            ServletMappingMetaData fiveHundredMapping = new ServletMappingMetaData();
            fiveHundredMapping.setServletName( FIVE_HUNDRED_SERVLET_NAME );
            fiveHundredMapping.setUrlPatterns( Collections.singletonList( "/*" ) );

View Full Code Here

      WebServlet webServlet = finder.getAnnotation(element, WebServlet.class);
      if (webServlet == null)
         return null;

      WebMetaData metaData = new WebMetaData();
      ServletsMetaData servlets = new ServletsMetaData();
      ServletMetaData servlet = new ServletMetaData();
      servlet.setServletClass(element.getName());
      String servletName = null;
      if (webServlet.name().length() == 0)
         servletName = element.getName();
      else
         servletName = webServlet.name();
      servlet.setServletName(servletName);
      if (webServlet.loadOnStartup() >= 0)
         servlet.setLoadOnStartupInt(webServlet.loadOnStartup());
      servlet.setAsyncSupported(webServlet.asyncSupported());
      if (webServlet.initParams() != null)
      {
         List<ParamValueMetaData> initParams = new ArrayList<ParamValueMetaData>();
         for (WebInitParam webInitParam : webServlet.initParams())
         {
            ParamValueMetaData paramValue = new ParamValueMetaData();
            paramValue.setParamName(webInitParam.name());
            paramValue.setParamValue(webInitParam.value());
            initParams.add(paramValue);
         }
         servlet.setInitParam(initParams);
      }
      DescriptionGroupMetaData descriptionGroup =
         ProcessorUtils.getDescriptionGroup(webServlet.description(), webServlet.displayName(),
               webServlet.smallIcon(), webServlet.largeIcon());
      if (descriptionGroup != null)
         servlet.setDescriptionGroup(descriptionGroup);
      servlets.add(servlet);
      metaData.setServlets(servlets);
      if (webServlet.urlPatterns() != null || webServlet.value() != null)
      {
         List<ServletMappingMetaData> servletMappings = new ArrayList<ServletMappingMetaData>();
         ServletMappingMetaData servletMapping = new ServletMappingMetaData();
View Full Code Here

    }

    WebMetaData create() {
        final WebMetaData metadata = new WebMetaData();

        metadata.setServlets(new ServletsMetaData());

        // Add DefaultServlet
        enableStaticResouces(metadata);
        // Add JSPServlet
        enableJsp(metadata);
View Full Code Here

    }

    WebMetaData create() {
        final WebMetaData metadata = new WebMetaData();

        metadata.setServlets(new ServletsMetaData());

        // Add DefaultServlet
        enableStaticResouces(metadata);
        // Add JSPServlet
        enableJsp(metadata);
View Full Code Here

    throws DeploymentUnitProcessingException {
        Web30MetaData metaData = new Web30MetaData();
        // @WebServlet
        final List<AnnotationInstance> webServletAnnotations = index.getAnnotations(webServlet);
        if (webServletAnnotations != null && webServletAnnotations.size() > 0) {
            ServletsMetaData servlets = new ServletsMetaData();
            List<ServletMappingMetaData> servletMappings = new ArrayList<ServletMappingMetaData>();
            for (final AnnotationInstance annotation : webServletAnnotations) {
                ServletMetaData servlet = new ServletMetaData();
                AnnotationTarget target = annotation.target();
                if (!(target instanceof ClassInfo)) {
                    throw new DeploymentUnitProcessingException(MESSAGES.invalidWebServletAnnotation(target));
                }
                ClassInfo classInfo = ClassInfo.class.cast(target);
                servlet.setServletClass(classInfo.toString());
                AnnotationValue nameValue = annotation.value("name");
                if (nameValue == null || nameValue.asString().isEmpty()) {
                    servlet.setName(classInfo.toString());
                } else {
                    servlet.setName(nameValue.asString());
                }
                AnnotationValue loadOnStartup = annotation.value("loadOnStartup");
                if (loadOnStartup != null && loadOnStartup.asInt() > 0) {
                    servlet.setLoadOnStartupInt(loadOnStartup.asInt());
                }
                AnnotationValue asyncSupported = annotation.value("asyncSupported");
                if (asyncSupported != null) {
                    servlet.setAsyncSupported(asyncSupported.asBoolean());
                }
                AnnotationValue initParamsValue = annotation.value("initParams");
                if (initParamsValue != null) {
                    AnnotationInstance[] initParamsAnnotations = initParamsValue.asNestedArray();
                    if (initParamsAnnotations != null && initParamsAnnotations.length > 0) {
                        List<ParamValueMetaData> initParams = new ArrayList<ParamValueMetaData>();
                        for (AnnotationInstance initParamsAnnotation : initParamsAnnotations) {
                            ParamValueMetaData initParam = new ParamValueMetaData();
                            AnnotationValue initParamName = initParamsAnnotation.value("name");
                            AnnotationValue initParamValue = initParamsAnnotation.value();
                            if (initParamName == null || initParamValue == null) {
                                throw new DeploymentUnitProcessingException(MESSAGES.invalidWebInitParamAnnotation(target));
                            }
                            AnnotationValue initParamDescription = initParamsAnnotation.value("description");
                            initParam.setParamName(initParamName.asString());
                            initParam.setParamValue(initParamValue.asString());
                            if (initParamDescription != null) {
                                Descriptions descriptions = getDescription(initParamDescription.asString());
                                if (descriptions != null) {
                                    initParam.setDescriptions(descriptions);
                                }
                            }
                            initParams.add(initParam);
                        }
                        servlet.setInitParam(initParams);
                    }
                }
                AnnotationValue descriptionValue = annotation.value("description");
                AnnotationValue displayNameValue = annotation.value("displayName");
                AnnotationValue smallIconValue = annotation.value("smallIcon");
                AnnotationValue largeIconValue = annotation.value("largeIcon");
                DescriptionGroupMetaData descriptionGroup =
                    getDescriptionGroup((descriptionValue == null) ? "" : descriptionValue.asString(),
                            (displayNameValue == null) ? "" : displayNameValue.asString(),
                            (smallIconValue == null) ? "" : smallIconValue.asString(),
                            (largeIconValue == null) ? "" : largeIconValue.asString());
                if (descriptionGroup != null) {
                    servlet.setDescriptionGroup(descriptionGroup);
                }
                ServletMappingMetaData servletMapping = new ServletMappingMetaData();
                servletMapping.setServletName(servlet.getName());
                List<String> urlPatterns = new ArrayList<String>();
                AnnotationValue urlPatternsValue = annotation.value("urlPatterns");
                if (urlPatternsValue != null) {
                    for (String urlPattern : urlPatternsValue.asStringArray()) {
                        urlPatterns.add(urlPattern);
                    }
                }
                urlPatternsValue = annotation.value();
                if (urlPatternsValue != null) {
                    for (String urlPattern : urlPatternsValue.asStringArray()) {
                        urlPatterns.add(urlPattern);
                    }
                }
                if (urlPatterns.size() > 0) {
                    servletMapping.setUrlPatterns(urlPatterns);
                    servletMappings.add(servletMapping);
                }
                servlets.add(servlet);
            }
            metaData.setServlets(servlets);
            metaData.setServletMappings(servletMappings);
        }
        // @WebFilter
View Full Code Here

TOP

Related Classes of org.jboss.metadata.web.spec.ServletsMetaData

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.