Package org.jboss.metadata.javaee.spec

Examples of org.jboss.metadata.javaee.spec.ParamValueMetaData


            jbwmd.setContextParams(contextParams);
         }

         for (Map.Entry<String, String> entry : depCtxParams.entrySet())
         {
            ParamValueMetaData param = new ParamValueMetaData();
            param.setParamName(entry.getKey());
            param.setParamValue(entry.getValue());
            contextParams.add(param);
         }
      }

      String listenerClass = (String)dep.getProperty(HttpSpec.PROPERTY_WEBAPP_SERVLET_CONTEXT_LISTENER);
      if (listenerClass != null)
      {
         List<ListenerMetaData> listeners = jbwmd.getListeners();
         if (listeners == null)
         {
            listeners = new ArrayList<ListenerMetaData>();
            jbwmd.setListeners(listeners);
         }
         ListenerMetaData listener = new ListenerMetaData();
         listener.setListenerClass(listenerClass);
      }

      for (Iterator it = jbwmd.getServlets().iterator(); it.hasNext();)
      {
         JBossServletMetaData servlet = (JBossServletMetaData)it.next();
         List<ParamValueMetaData> initParams = servlet.getInitParam();
         if (initParams == null)
         {
            initParams = new ArrayList<ParamValueMetaData>();
            servlet.setInitParam(initParams);
         }

         String linkName = servlet.getServletName();

         // find the servlet-class
         String orgServletClassName = servlet.getServletClass();

         // JSP
         if (orgServletClassName == null)
            continue;

         // Get the servlet class
         Class orgServletClass = null;
         try
         {
            ClassLoader loader = dep.getInitialClassLoader();
            orgServletClass = loader.loadClass(orgServletClassName);
         }
         catch (ClassNotFoundException ex)
         {
            log.warn("Cannot load servlet class: " + orgServletClassName);
         }

         String targetBeanName = null;

         // Nothing to do if we have an <init-param>
         if (isAlreadyModified(servlet))
         {
            for (ParamValueMetaData initParam : initParams)
            {
               String paramName = initParam.getParamName();
               String paramValue = initParam.getParamValue();
               if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
               {
                  targetBeanName = paramValue;
               }
            }
         }
         else
         {
            // Check if it is a real servlet that we can ignore
            if (orgServletClass != null && javax.servlet.Servlet.class.isAssignableFrom(orgServletClass))
            {
               log.info("Ignore servlet: " + orgServletClassName);
               continue;
            }
            else if (orgServletClassName.endsWith("Servlet"))
            {
               log.info("Ignore <servlet-class> that ends with 'Servlet': " + orgServletClassName);
               continue;
            }

            servlet.setServletClass(servletClass);

            // add additional init params
            if (orgServletClassName.equals(servletClass) == false)
            {
               targetBeanName = orgServletClassName;
               ParamValueMetaData initParam = new ParamValueMetaData();
               initParam.setParamName(Endpoint.SEPID_DOMAIN_ENDPOINT);
               initParam.setParamValue(targetBeanName);
               initParams.add(initParam);
            }
         }

         if (targetBeanName == null)
View Full Code Here


                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("@WebInitParam requires name and value on " + 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
        final List<AnnotationInstance> webFilterAnnotations = index.getAnnotations(webFilter);
        if (webFilterAnnotations != null && webFilterAnnotations.size() > 0) {
            FiltersMetaData filters = new FiltersMetaData();
            List<FilterMappingMetaData> filterMappings = new ArrayList<FilterMappingMetaData>();
            for (final AnnotationInstance annotation : webFilterAnnotations) {
                FilterMetaData filter = new FilterMetaData();
                AnnotationTarget target = annotation.target();
                if (!(target instanceof ClassInfo)) {
                    throw new DeploymentUnitProcessingException("@WebFilter is only allowed at class level " + target);
                }
                ClassInfo classInfo = ClassInfo.class.cast(target);
                filter.setFilterClass(classInfo.toString());
                AnnotationValue nameValue = annotation.value("filterName");
                if (nameValue == null || nameValue.asString().isEmpty()) {
                    filter.setName(classInfo.toString());
                } else {
                    filter.setName(nameValue.asString());
                }
                AnnotationValue asyncSupported = annotation.value("asyncSupported");
                if (asyncSupported != null) {
                    filter.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("@WebInitParam requires name and value on " + 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);
                        }
                        filter.setInitParam(initParams);
View Full Code Here

      assertEquals("EJBOnStartupServlet", servlet10.getServletName());
      assertEquals("org.jboss.test.web.servlets.EJBOnStartupServlet", servlet10.getServletClass());
      assertEquals(1, servlet10.getLoadOnStartup());
      List<ParamValueMetaData> s10params = servlet10.getInitParam();
      assertEquals(1, s10params.size());
      ParamValueMetaData s10p0 = s10params.get(0);
      assertEquals("failOnError", s10p0.getParamName());
      assertEquals("false", s10p0.getParamValue());
      // servlet19
      JBossServletMetaData servlet19 = jbossWeb.getServletByName("UnsecureRunAsServletWithPrincipalNameAndRoles");
      assertNotNull(servlet19);
      assertEquals("servlet19", servlet19.getId());
      assertEquals("UnsecureRunAsServletWithPrincipalNameAndRoles", servlet19.getServletName());
      assertEquals("org.jboss.test.web.servlets.UnsecureRunAsServlet", servlet19.getServletClass());
      List<ParamValueMetaData> s19params = servlet19.getInitParam();
      assertEquals(1, s19params.size());
      ParamValueMetaData s19p0 = s19params.get(0);
      assertEquals("ejbName", s19p0.getParamName());
      assertEquals("ejb/UnsecureRunAsServletWithPrincipalNameAndRolesTarget", s19p0.getParamValue());
      RunAsMetaData s19RunAs = servlet19.getRunAs();
      assertEquals("Assume an InternalUser role to access a private EJB", getDescription(s19RunAs.getDescriptions()));
      assertEquals("InternalUser", s19RunAs.getRoleName());
      assertEquals("UnsecureRunAsServletWithPrincipalNameAndRolesPrincipal", servlet19.getRunAsPrincipal());
      RunAsIdentityMetaData s19RunAsID = jbossWeb.getRunAsIdentity("UnsecureRunAsServletWithPrincipalNameAndRoles");
      assertEquals("UnsecureRunAsServletWithPrincipalNameAndRolesPrincipal", s19RunAsID.getPrincipalName());
      Set<String> s19RunAsPrincipalRoles = jbossWeb.getSecurityRoles().getSecurityRoleNamesByPrincipal("UnsecureRunAsServletWithPrincipalNameAndRolesPrincipal");
      assertEquals(set("ExtraRole1"), s19RunAsPrincipalRoles);
      assertEquals(set("ExtraRole1", "InternalUser"), s19RunAsID.getRunAsRoles());
      assertEquals(true, s19RunAsID.doesUserHaveRole("ExtraRole1"));
      assertEquals(true, s19RunAsID.doesUserHaveRole("InternalUser"));
      // servlet20
      JBossServletMetaData servlet20 = jbossWeb.getServletByName("UnsecureRunAsJsp");
      assertNotNull(servlet20);
      assertEquals("servlet20", servlet20.getId());
      assertEquals("UnsecureRunAsJsp", servlet20.getServletName());
      assertEquals(null, servlet20.getServletClass());
      assertEquals("/runAs.jsp", servlet20.getJspFile());
      RunAsMetaData s20RunAs = servlet20.getRunAs();
      assertEquals("Assume an InternalUser role to access a private EJB", getDescription(s19RunAs.getDescriptions()));
      assertEquals("InternalUser", s20RunAs.getRoleName());
      assertEquals(null, servlet20.getRunAsPrincipal());
      RunAsIdentityMetaData s20RunAsID = jbossWeb.getRunAsIdentity("UnsecureRunAsJsp");
      assertEquals("anonymous", s20RunAsID.getPrincipalName());
      assertEquals(set("InternalUser"), s20RunAsID.getRunAsRoles());
      assertEquals(true, s20RunAsID.doesUserHaveRole("InternalUser"));
      // servlet27
      JBossServletMetaData servlet27 = jbossWeb.getServletByName("UserInRoleServlet");
      assertEquals("servlet27", servlet27.getId());
      assertEquals("UserInRoleServlet", servlet27.getServletName());
      assertEquals("org.jboss.test.web.servlets.UserInRoleServlet", servlet27.getServletClass());
      List<ParamValueMetaData> s27params = servlet27.getInitParam();
      assertEquals(2, s27params.size());
      ParamValueMetaData s27p0 = s27params.get(0);
      assertEquals("expectedUserRoles", s27p0.getParamName());
      assertEquals("AuthorizedUser,ServletUser", s27p0.getParamValue());
      ParamValueMetaData s27p1 = s27params.get(1);
      assertEquals("unexpectedUserRoles", s27p1.getParamName());
      assertEquals("Anonymous", s27p1.getParamValue());
      SecurityRoleRefsMetaData s27RoleRefs = servlet27.getSecurityRoleRefs();
      assertEquals(1, s27RoleRefs.size());
      SecurityRoleRefMetaData s27ServletUser = s27RoleRefs.get("ServletUser");
      assertEquals("ServletUser", s27ServletUser.getRoleName());
      assertEquals("ServletUserRole", s27ServletUser.getRoleLink());
View Full Code Here

        metadata.getServlets().add(servlet);
        addServletMapping("jsp", metadata, "*.jsp", "*.jspx");
    }

    static ParamValueMetaData createParameter(String name, String value) {
        ParamValueMetaData param = new ParamValueMetaData();
        param.setParamName(name);
        param.setParamValue(value);
        return param;
    }
View Full Code Here

            if (initParams == null) {
                initParams = new ArrayList<ParamValueMetaData>();
                rtFilter.setInitParam(initParams);
            }
            for (String paramName : RtFilterExtension.INIT_PARAMS.keySet()) {
                ParamValueMetaData initParam = new ParamValueMetaData();
                initParam.setParamName(paramName);
                String paramValue = RtFilterExtension.INIT_PARAMS.get(paramName);
                initParam.setParamValue(paramValue);
                initParams.add(initParam);
            }

            boolean filterMappingAlreadyConfigured = false;
            List<FilterMappingMetaData> filterMappings = webMetaData.getFilterMappings();
View Full Code Here

            jbwmd.setContextParams(contextParams);
         }

         for (Map.Entry<String, String> entry : depCtxParams.entrySet())
         {
            ParamValueMetaData param = new ParamValueMetaData();
            param.setParamName(entry.getKey());
            param.setParamValue(entry.getValue());
            contextParams.add(param);
         }
      }

      String listenerClass = (String)dep.getProperty(PROPERTY_WEBAPP_SERVLET_CONTEXT_LISTENER);
      if (listenerClass != null)
      {
         List<ListenerMetaData> listeners = jbwmd.getListeners();
         if (listeners == null)
         {
            listeners = new ArrayList<ListenerMetaData>();
            jbwmd.setListeners(listeners);
         }
         ListenerMetaData listener = new ListenerMetaData();
         listener.setListenerClass(listenerClass);
      }

      for (Iterator it = jbwmd.getServlets().iterator(); it.hasNext();)
      {
         JBossServletMetaData servlet = (JBossServletMetaData)it.next();
         List<ParamValueMetaData> initParams = servlet.getInitParam();
         if (initParams == null)
         {
            initParams = new ArrayList<ParamValueMetaData>();
            servlet.setInitParam(initParams);
         }
        
         String linkName = servlet.getServletName();

         // find the servlet-class
         String orgServletClassName = servlet.getServletClass();

         // JSP
         if (orgServletClassName == null)
            continue;

         // Get the servlet class
         Class orgServletClass = null;
         try
         {
            ClassLoader loader = dep.getInitialClassLoader();
            orgServletClass = loader.loadClass(orgServletClassName);
         }
         catch (ClassNotFoundException ex)
         {
            log.warn("Cannot load servlet class: " + orgServletClassName);
         }

         String targetBeanName = null;

         // Nothing to do if we have an <init-param>
         if (isAlreadyModified(servlet))
         {
            for (ParamValueMetaData initParam : initParams)
            {
               String paramName = initParam.getParamName();
               String paramValue = initParam.getParamValue();
               if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
               {
                  targetBeanName = paramValue;
               }
            }
         }
         else
         {
            // Check if it is a real servlet that we can ignore
            if (orgServletClass != null && javax.servlet.Servlet.class.isAssignableFrom(orgServletClass))
            {
               log.info("Ignore servlet: " + orgServletClassName);
               continue;
            }
            /*
            Legacy code: This shouldn't be used in recent AS 5 versions
           
            else if (orgServletClassName.endsWith("Servlet"))
            {
               log.info("Ignore <servlet-class> that ends with 'Servlet': " + orgServletClassName);
               continue;
            }*/

            servlet.setServletClass(servletClass);

            // add additional init params
            if (orgServletClassName.equals(servletClass) == false)
            {
               targetBeanName = orgServletClassName;
               ParamValueMetaData initParam = new ParamValueMetaData();
               initParam.setParamName(Endpoint.SEPID_DOMAIN_ENDPOINT);
               initParam.setParamValue(targetBeanName);
               initParams.add(initParam);
            }
         }

         if (targetBeanName == null)
View Full Code Here

        if (contextParams == null) {
            contextParams = new ArrayList<ParamValueMetaData>();
        }

        boolean isCDI = WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit);
        ParamValueMetaData param = new ParamValueMetaData();
        param.setParamName(IS_CDI_PARAM);
        param.setParamValue(Boolean.toString(isCDI));
        contextParams.add(param);

        webMetaData.setContextParams(contextParams);
    }
View Full Code Here

                throw new DeploymentUnitProcessingException(e);
            }
            if (Application.class.isAssignableFrom(clazz)) {
                servlet.setServletClass(HttpServlet30Dispatcher.class.getName());
                servlet.setAsyncSupported(true);
                ParamValueMetaData param = new ParamValueMetaData();
                param.setParamName("javax.ws.rs.Application");
                param.setParamValue(servletClass);
                List<ParamValueMetaData> params = servlet.getInitParam();
                if (params == null) {
                    params = new ArrayList<ParamValueMetaData>();
                    servlet.setInitParam(params);
                }
View Full Code Here

        for (ParamValueMetaData param : contextParams) {
            if (parameterName.equals(param.getParamName())) {
                return;
            }
        }
        ParamValueMetaData parameter = new ParamValueMetaData();
        parameter.setParamName(parameterName);
        parameter.setParamValue("false");
        contextParams.add(parameter);
    }
View Full Code Here

        final List<ParamValueMetaData> params = webdata.getContextParams();
        boolean entityExpandEnabled = false;
        if (params != null) {
            Iterator<ParamValueMetaData> it = params.iterator();
            while (it.hasNext()) {
                final ParamValueMetaData param = it.next();
                if (param.getParamName().equals(RESTEASY_SCAN)) {
                    it.remove();
                } else if (param.getParamName().equals(RESTEASY_SCAN_RESOURCES)) {
                    it.remove();
                } else if (param.getParamName().equals(RESTEASY_SCAN_PROVIDERS)) {
                    it.remove();
                } else if(param.getParamName().equals(ResteasyContextParameters.RESTEASY_EXPAND_ENTITY_REFERENCES)) {
                    entityExpandEnabled = true;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.jboss.metadata.javaee.spec.ParamValueMetaData

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.