Package org.codehaus.enunciate.main.webapp

Examples of org.codehaus.enunciate.main.webapp.WebAppComponent


    //servlets.
    ArrayList<WebAppComponent> servlets = new ArrayList<WebAppComponent>();
    for (WsdlInfo wsdlInfo : getModel().getNamespacesToWSDLs().values()) {
      for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
        WebAppComponent gwtServlet = new WebAppComponent();
        gwtServlet.setClassname(ei.getPackage().getQualifiedName() + ".gwt.GWT" + ei.getSimpleName() + "Impl");
        gwtServlet.setName("GWT" + ei.getSimpleName());
        TreeSet<String> urlMappings = new TreeSet<String>();
        urlMappings.add(getGwtSubcontext() + '/' + ei.getServiceName());
        gwtServlet.setUrlMappings(urlMappings);
        servlets.add(gwtServlet);
      }
    }
    webAppFragment.setServlets(servlets);
View Full Code Here


    List<WebAppComponent> servlets = new ArrayList<WebAppComponent>();
    ArrayList<WebAppComponent> filters = new ArrayList<WebAppComponent>();
    for (WsdlInfo wsdlInfo : getModel().getNamespacesToWSDLs().values()) {
      TreeSet<String> urlMappings = new TreeSet<String>();
      for (EndpointInterface endpointInterface : wsdlInfo.getEndpointInterfaces()) {
        WebAppComponent servletComponent = new WebAppComponent();
        servletComponent.setName("jaxws-" + endpointInterface.getServiceName());
        String servletClass = isSpringEnabled() ? "org.codehaus.enunciate.modules.jaxws_ri.WSSpringServlet" : "com.sun.xml.ws.transport.http.servlet.WSServlet";
        servletComponent.setClassname(servletClass);
        String soapPath = String.valueOf(endpointInterface.getMetaData().get("soapPath"));
        if (soapPath != null) {
          servletComponent.setUrlMappings(new TreeSet<String>(Arrays.asList(soapPath)));
          servlets.add(servletComponent);
          urlMappings.add(soapPath);
        }
      }

      String redirectLocation = (String) wsdlInfo.getProperty("redirectLocation");
      if (redirectLocation != null && isUseWsdlRedirectFilter()) {
        WebAppComponent wsdlFilter = new WebAppComponent();
        wsdlFilter.setName("wsdl-redirect-filter-" + wsdlInfo.getId());
        wsdlFilter.setClassname(WSDLRedirectFilter.class.getName());
        wsdlFilter.addInitParam(WSDLRedirectFilter.WSDL_LOCATION_PARAM, redirectLocation);
        wsdlFilter.setUrlMappings(urlMappings);
        filters.add(wsdlFilter);
      }
    }
    webappFragment.setServlets(servlets);
    webappFragment.setFilters(filters);
View Full Code Here

    ArrayList<WebAppComponent> servlets = new ArrayList<WebAppComponent>();
    ArrayList<WebAppComponent> filters = new ArrayList<WebAppComponent>();
    if (enableJaxws) {
      //jax-ws servlet config.
      WebAppComponent jaxwsServletComponent = new WebAppComponent();
      jaxwsServletComponent.setName("cxf-jaxws");
      jaxwsServletComponent.setClassname(CXFServlet.class.getName());
      TreeSet<String> jaxwsUrlMappings = new TreeSet<String>();
      for (WsdlInfo wsdlInfo : getModel().getNamespacesToWSDLs().values()) {
        TreeSet<String> urlMappingsForNs = new TreeSet<String>();
        for (EndpointInterface endpointInterface : wsdlInfo.getEndpointInterfaces()) {
          urlMappingsForNs.add(String.valueOf(endpointInterface.getMetaData().get("soapPath")));
        }
        jaxwsUrlMappings.addAll(urlMappingsForNs);

        String redirectLocation = (String) wsdlInfo.getProperty("redirectLocation");
        if (redirectLocation != null && isUseWsdlRedirectFilter()) {
          WebAppComponent wsdlFilter = new WebAppComponent();
          wsdlFilter.setName("wsdl-redirect-filter-" + wsdlInfo.getId());
          wsdlFilter.setClassname(WSDLRedirectFilter.class.getName());
          wsdlFilter.addInitParam(WSDLRedirectFilter.WSDL_LOCATION_PARAM, redirectLocation);
          wsdlFilter.setUrlMappings(urlMappingsForNs);
          filters.add(wsdlFilter);
        }
      }
      jaxwsServletComponent.setUrlMappings(jaxwsUrlMappings);
      File transform = null;
      if (jaxwsServletTransform != null) {
        transform = enunciate.resolvePath(jaxwsServletTransform);
      }

      transformAndCopy(new File(getGenerateDir(), "cxf-jaxws-servlet.xml"), new File(webinf, "cxf-jaxws-servlet.xml"), transform);
      jaxwsServletComponent.addInitParam("config-location", "/WEB-INF/cxf-jaxws-servlet.xml");
      servlets.add(jaxwsServletComponent);

      WebAppComponent filterComponent = new WebAppComponent();
      filterComponent.setName("cxf-filter");
      filterComponent.setClassname(CXFAdaptedServletFilter.class.getName());
      filterComponent.setUrlMappings(jaxwsUrlMappings);
      filters.add(filterComponent);
    }

    if (enableJaxrs) {
      WebAppComponent jaxrsServletComponent = new WebAppComponent();
      jaxrsServletComponent.setName("cxf-jaxrs");
      jaxrsServletComponent.setClassname(CXFServlet.class.getName());
      TreeSet<String> jaxrsUrlMappings = new TreeSet<String>();
      for (RootResource rootResource : getModel().getRootResources()) {
        for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
          for (Set<String> subcontextList : ((Map<String, Set<String>>) resourceMethod.getMetaData().get("subcontexts")).values()) {
            for (String subcontext : subcontextList) {
              jaxrsUrlMappings.add(subcontext + "/*");
            }
          }
        }
      }

      jaxrsServletComponent.setUrlMappings(jaxrsUrlMappings);
      File transform = null;
      if (jaxrsServletTransform != null) {
        transform = enunciate.resolvePath(jaxrsServletTransform);
      }

      transformAndCopy(new File(getGenerateDir(), "cxf-jaxrs-servlet.xml"), new File(webinf, "cxf-jaxrs-servlet.xml"), transform);
      jaxrsServletComponent.addInitParam("config-location", "/WEB-INF/cxf-jaxrs-servlet.xml");
      servlets.add(jaxrsServletComponent);
    }
    webappFragment.setServlets(servlets);
    webappFragment.setFilters(filters);
    enunciate.addWebAppFragment(webappFragment);
View Full Code Here

    //add the webapp fragment...
    BaseWebAppFragment webAppFragment = new BaseWebAppFragment(getName());
    webAppFragment.setBaseDir(getGenerateDir());
    ArrayList<WebAppComponent> filters = new ArrayList<WebAppComponent>();
    if (isApplyBaseUriFilter()) {
      WebAppComponent swaggerFilter = new WebAppComponent();
      swaggerFilter.setName("swagger-ui-filter");
      swaggerFilter.setClassname("org.codehaus.enunciate.webapp.IDLFilter");
      HashMap<String, String> initParams = new HashMap<String, String>();
      initParams.put("assumed-base-address", getModel().getBaseDeploymentAddress());
      initParams.put("match-prefix", "\"");
      initParams.put("content-type", "application/json");
      swaggerFilter.setInitParams(initParams);
      TreeSet<String> paths = new TreeSet<String>();

      for (File json : jsonFilesToValidate) {
        paths.add("/" + artifactDir.getName() + "/" + json.getName());
      }

      swaggerFilter.setUrlMappings(paths);
      filters.add(swaggerFilter);
    }

    webAppFragment.setFilters(filters);
    getEnunciate().addWebAppFragment(webAppFragment);
View Full Code Here

    ArrayList<WebAppComponent> servlets = new ArrayList<WebAppComponent>();
    if (this.enableJaxws) {
      for (WsdlInfo wsdlInfo : getModelInternal().getNamespacesToWSDLs().values()) {
        for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
          String path = (String) ei.getMetaData().get("soapPath");
          WebAppComponent wsComponent = new WebAppComponent();
          wsComponent.setName(ei.getServiceName());
          wsComponent.setClassname(ei.getEndpointImplementations().iterator().next().getQualifiedName());
          wsComponent.setUrlMappings(new TreeSet<String>(Arrays.asList(path)));
          servlets.add(wsComponent);
        }
      }
    }

    if (this.enableJaxrs) {
      WebAppComponent jaxrsServletComponent = new WebAppComponent();
      jaxrsServletComponent.setName("resteasy-jaxrs");
      jaxrsServletComponent.setClassname(EnunciateJBossHttpServletDispatcher.class.getName());
      TreeSet<String> jaxrsUrlMappings = new TreeSet<String>();
      StringBuilder resources = new StringBuilder();
      for (RootResource rootResource : getModel().getRootResources()) {
        if (resources.length() > 0) {
          resources.append(',');
        }
        resources.append(rootResource.getQualifiedName());

        for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
          String resourceMethodPattern = resourceMethod.getServletPattern();
          for (Set<String> subcontextList : ((Map<String, Set<String>>) resourceMethod.getMetaData().get("subcontexts")).values()) {
            for (String subcontext : subcontextList) {
              String servletPattern;
              if ("".equals(subcontext)) {
                servletPattern = resourceMethodPattern;
              }
              else {
                servletPattern = subcontext + resourceMethodPattern;
              }

              if (jaxrsUrlMappings.add(servletPattern)) {
                debug("Resource method %s of resource %s to be made accessible by servlet pattern %s.",
                      resourceMethod.getSimpleName(), resourceMethod.getParent().getQualifiedName(), servletPattern);
              }
            }
          }
        }
      }

      if (jaxrsUrlMappings.contains("/*")) {
        jaxrsUrlMappings.clear();
        jaxrsUrlMappings.add("/*");
      }
      else {
        Iterator<String> iterator = jaxrsUrlMappings.iterator();
        while (iterator.hasNext()) {
          String mapping = iterator.next();
          if (!mapping.endsWith("/*") && jaxrsUrlMappings.contains(mapping + "/*")) {
            iterator.remove();
          }
        }
      }

      StringBuilder providers = new StringBuilder();
      for (TypeDeclaration provider : getModel().getJAXRSProviders()) {
        if (providers.length() > 0) {
          providers.append(',');
        }

        providers.append(provider.getQualifiedName());
      }

      if (jacksonAvailable) {
        if (providers.length() > 0) {
          providers.append(',');
        }

        providers.append("org.codehaus.enunciate.jboss.ResteasyJacksonJaxbProvider");
      }

      if (getEnunciate().isModuleEnabled("amf")) {
        if (providers.length() > 0) {
          providers.append(',');
        }

        providers.append("org.codehaus.enunciate.modules.amf.JAXRSProvider");
      }

      jaxrsServletComponent.setUrlMappings(jaxrsUrlMappings);
      jbossContextParameters.put(ResteasyContextParameters.RESTEASY_RESOURCES, resources.toString());
      jbossContextParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS, providers.toString());
      String mappingPrefix = this.useSubcontext ? getRestSubcontext() : "";
      if (!"".equals(mappingPrefix)) {
        jbossContextParameters.put("resteasy.servlet.mapping.prefix", mappingPrefix);
        jaxrsServletComponent.addInitParam("resteasy.servlet.mapping.prefix", mappingPrefix);
      }
      if (isUsePathBasedConneg()) {
        Map<String, String> contentTypesToIds = getModelInternal().getContentTypesToIds();
        if (contentTypesToIds != null && contentTypesToIds.size() > 0) {
          StringBuilder builder = new StringBuilder();
View Full Code Here

      debug("No flex apps were found.");
    }
    webAppFragment.setBaseDir(webappDir);

    //servlets.
    WebAppComponent messageServlet = new WebAppComponent();
    messageServlet.setClassname(MessageBrokerServlet.class.getName());
    messageServlet.setName("AMFMessageServlet");
    TreeSet<String> urlMappings = new TreeSet<String>();
    for (WsdlInfo wsdlInfo : getModel().getNamespacesToWSDLs().values()) {
      for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
        urlMappings.add(getAmfSubcontext() + ei.getServiceName());
      }
    }
    messageServlet.setUrlMappings(urlMappings);
    TreeMap<String, String> initParams = new TreeMap<String, String>();
    initParams.put("services.configuration.file", "/WEB-INF/flex/services-config.xml");
    initParams.put("flex.write.path", "/WEB-INF/flex");
    messageServlet.setInitParams(initParams);
    webAppFragment.setServlets(Arrays.asList(messageServlet));

    getEnunciate().addWebAppFragment(webAppFragment);
  }
View Full Code Here

    getEnunciate().copyFile(new File(getGenerateDir(), "media-type-mappings.properties"), new File(webinfClasses, "media-type-mappings.properties"));
    getEnunciate().copyFile(new File(getGenerateDir(), "ns2prefix.properties"), new File(webinfClasses, "ns2prefix.properties"));

    BaseWebAppFragment webappFragment = new BaseWebAppFragment(getName());
    webappFragment.setBaseDir(webappDir);
    WebAppComponent servletComponent = new WebAppComponent();
    servletComponent.setName("jersey");
    servletComponent.setClassname(EnunciateJerseyServletContainer.class.getName());
    TreeMap<String, String> initParams = new TreeMap<String, String>();
    initParams.putAll(getServletInitParams());
    if (!isUsePathBasedConneg()) {
      initParams.put(JerseyAdaptedHttpServletRequest.FEATURE_PATH_BASED_CONNEG, Boolean.FALSE.toString());
    }
    if (isUseSubcontext()) {
      initParams.put(JerseyAdaptedHttpServletRequest.PROPERTY_SERVLET_PATH, getRestSubcontext());
    }
    if (getResourceProviderFactory() != null) {
      initParams.put(JerseyAdaptedHttpServletRequest.PROPERTY_RESOURCE_PROVIDER_FACTORY, getResourceProviderFactory());
    }
    if (getApplicationClass() != null) {
      initParams.put("javax.ws.rs.Application", getApplicationClass());
    }
    if (getLoadOnStartup() != null) {
      servletComponent.setLoadOnStartup(getLoadOnStartup());
    }
    servletComponent.setInitParams(initParams);

    TreeSet<String> urlMappings = new TreeSet<String>();
    for (RootResource rootResource : getModel().getRootResources()) {
      for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
        String resourceMethodPattern = resourceMethod.getServletPattern();
        for (Set<String> subcontextList : ((Map<String, Set<String>>) resourceMethod.getMetaData().get("subcontexts")).values()) {
          for (String subcontext : subcontextList) {
            String servletPattern;
            if ("".equals(subcontext)) {
              servletPattern = isUseWildcardServletMapping() ? "/*" : resourceMethodPattern;
            }
            else {
              servletPattern = isUseWildcardServletMapping() ? subcontext + "/*" : subcontext + resourceMethodPattern;
            }

            if (urlMappings.add(servletPattern)) {
              debug("Resource method %s of resource %s to be made accessible by servlet pattern %s.",
                    resourceMethod.getSimpleName(), resourceMethod.getParent().getQualifiedName(), servletPattern);
            }
          }
        }
      }
    }

    if (urlMappings.contains("/*")) {
      urlMappings.clear();
      urlMappings.add("/*");
    }
    else {
      Iterator<String> iterator = urlMappings.iterator();
      while (iterator.hasNext()) {
        String mapping = iterator.next();
        if (!mapping.endsWith("/*") && urlMappings.contains(mapping + "/*")) {
          iterator.remove();
        }
      }
    }

    servletComponent.setUrlMappings(urlMappings);
    webappFragment.setServlets(Arrays.asList(servletComponent));
    getEnunciate().addWebAppFragment(webappFragment);
  }
View Full Code Here

    mimeMappings.put("wsdl", "text/xml");
    mimeMappings.put("xsd", "text/xml");
    webAppFragment.setMimeMappings(mimeMappings);
    ArrayList<WebAppComponent> filters = new ArrayList<WebAppComponent>();
    if (isApplyWsdlFilter() && !getModelInternal().getNamespacesToWSDLs().isEmpty()) {
      WebAppComponent wsdlFilter = new WebAppComponent();
      wsdlFilter.setName("wsdl-filter");
      wsdlFilter.setClassname("org.codehaus.enunciate.webapp.IDLFilter");
      HashMap<String, String> initParams = new HashMap<String, String>();
      initParams.put("assumed-base-address", getModel().getBaseDeploymentAddress());
      initParams.put("match-prefix", ":address location=\"");
      wsdlFilter.setInitParams(initParams);
      TreeSet<String> wsdls = new TreeSet<String>();

      for (WsdlInfo wsdlInfo : getModelInternal().getNamespacesToWSDLs().values()) {
        String wsdlLocation = (String) wsdlInfo.getProperty("redirectLocation");
        if (wsdlLocation != null) {
          wsdls.add(wsdlLocation);
        }
      }
      wsdlFilter.setUrlMappings(wsdls);
      filters.add(wsdlFilter);
    }

    if (isApplyWadlFilter() && getModelInternal().getWadlFile() != null) {
      WebAppComponent wadlFilter = new WebAppComponent();
      wadlFilter.setName("wadl-filter");
      wadlFilter.setClassname("org.codehaus.enunciate.webapp.IDLFilter");
      HashMap<String, String> initParams = new HashMap<String, String>();
      initParams.put("assumed-base-address", getModel().getBaseDeploymentAddress());
      initParams.put("match-prefix", ":resources base=\"");
      wadlFilter.setInitParams(initParams);
      TreeSet<String> wadls = new TreeSet<String>();
      String docsDir = getDocsDir() == null ? "" : getDocsDir();
      if (!docsDir.startsWith("/")) {
        docsDir = "/" + docsDir;
      }
      while (docsDir.endsWith("/")) {
        docsDir = docsDir.substring(0, docsDir.length() - 1);
      }

      wadls.add(docsDir + "/" + getModelInternal().getWadlFile().getName());
      wadlFilter.setUrlMappings(wadls);
      filters.add(wadlFilter);
    }

    webAppFragment.setFilters(filters);
    getEnunciate().addWebAppFragment(webAppFragment);
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.main.webapp.WebAppComponent

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.