Search in sources :

Example 1 with UIServlet

use of org.commonjava.indy.bind.jaxrs.ui.UIServlet in project indy by Commonjava.

the class IndyDeployment method getDeployment.

public DeploymentInfo getDeployment(final String contextRoot) {
    final ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(this);
    deployment.setInjectorFactoryClass(CdiInjectorFactoryImpl.class.getName());
    final ServletInfo resteasyServlet = Servlets.servlet("REST", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/api*").addMapping("/api/*").addMapping("/api-docs*").addMapping("/api-docs/*").addMapping("/swagger.json").addMapping("/swagger.yaml");
    final BeanConfig beanConfig = new BeanConfig();
    beanConfig.setResourcePackage("org.commonjava.indy");
    beanConfig.setBasePath("/");
    beanConfig.setLicense("ASLv2");
    beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0");
    beanConfig.setScan(true);
    beanConfig.setVersion(versioning.getApiVersion());
    final FilterInfo resourceManagementFilter = Servlets.filter("Naming and Resource Management", ResourceManagementFilter.class, new ImmediateInstanceFactory<ResourceManagementFilter>(this.resourceManagementFilter));
    final DeploymentInfo di = new DeploymentInfo().addListener(Servlets.listener(RequestScopeListener.class)).setContextPath(contextRoot).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet).addFilter(resourceManagementFilter).addFilterUrlMapping(resourceManagementFilter.getName(), "/api/*", DispatcherType.REQUEST).setDeploymentName("Indy").setClassLoader(ClassLoader.getSystemClassLoader()).addOuterHandlerChainWrapper(new HeaderDebugger.Wrapper());
    if (deploymentProviders != null) {
        DeploymentInfoUtils.mergeFromProviders(di, deploymentProviders);
    }
    // Add UI servlet at the end so its mappings don't obscure any from add-ons.
    final ServletInfo uiServlet = Servlets.servlet("UI", UIServlet.class).setAsyncSupported(true).setLoadOnStartup(99).addMappings(UIServlet.PATHS);
    uiServlet.setInstanceFactory(new ImmediateInstanceFactory<Servlet>(ui));
    di.addServlet(uiServlet);
    return di;
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) ServletInfo(io.undertow.servlet.api.ServletInfo) ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) Servlet(javax.servlet.Servlet) UIServlet(org.commonjava.indy.bind.jaxrs.ui.UIServlet) RequestScopeListener(org.commonjava.indy.bind.jaxrs.util.RequestScopeListener) UIServlet(org.commonjava.indy.bind.jaxrs.ui.UIServlet) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) FilterInfo(io.undertow.servlet.api.FilterInfo) CdiInjectorFactoryImpl(org.commonjava.indy.bind.jaxrs.util.CdiInjectorFactoryImpl)

Aggregations

BeanConfig (io.swagger.jaxrs.config.BeanConfig)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 FilterInfo (io.undertow.servlet.api.FilterInfo)1 ServletInfo (io.undertow.servlet.api.ServletInfo)1 Servlet (javax.servlet.Servlet)1 UIServlet (org.commonjava.indy.bind.jaxrs.ui.UIServlet)1 CdiInjectorFactoryImpl (org.commonjava.indy.bind.jaxrs.util.CdiInjectorFactoryImpl)1 RequestScopeListener (org.commonjava.indy.bind.jaxrs.util.RequestScopeListener)1 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)1