Java 类org.springframework.boot.context.embedded.ServletRegistrationBean 实例源码

项目:lemonaid    文件:CxfServletRegister.java   
@Bean
public ServletRegistrationBean getODataServletRegistrationBean() {
    ServletRegistrationBean odataServletRegistrationBean = new ServletRegistrationBean(new CXFNonSpringJaxrsServlet(), "/odata.svc/*");
    Map<String, String> initParameters = new HashMap<String, String>();
    initParameters.put("javax.ws.rs.Application", "org.apache.olingo.odata2.core.rest.app.ODataApplication");
    initParameters.put("org.apache.olingo.odata2.service.factory", "com.sap.mentors.lemonaid.odata.JPAServiceFactory");
    odataServletRegistrationBean.setInitParameters(initParameters);
    return odataServletRegistrationBean;
}
项目:Voting_2b    文件:Main.java   
@Bean
public ServletRegistrationBean facesServletRegistraiton() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new javax.faces.webapp.FacesServlet(),
            "*.xhtml");

    registration.setName("Faces Servlet");

    registration.setLoadOnStartup(1);

    return registration;
}
项目:Voting_2b    文件:Application.java   
@Bean
public ServletRegistrationBean facesServletRegistraiton() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new FacesServlet(), "*.xhtml");
    registration.setName("Faces Servlet");
    registration.setLoadOnStartup(1);
    return registration;
}
项目:VoteCounting_2b    文件:Main.java   
@Bean
public ServletRegistrationBean facesServletRegistraiton() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new javax.faces.webapp.FacesServlet(),
            "*.xhtml");

    registration.setName("Faces Servlet");

    registration.setLoadOnStartup(1);

    return registration;
}
项目:odata-boilerplate    文件:CxfServletRegister.java   
@Bean
public ServletRegistrationBean getODataServletRegistrationBean() {
    ServletRegistrationBean odataServletRegistrationBean = new ServletRegistrationBean(new CXFNonSpringJaxrsServlet(), "/odata.svc/*");
    Map<String, String> initParameters = new HashMap<String, String>();
    initParameters.put("javax.ws.rs.Application", "org.apache.olingo.odata2.core.rest.app.ODataApplication");
    initParameters.put("org.apache.olingo.odata2.service.factory", "com.penninkhof.odata.utils.JPAServiceFactory");
    odataServletRegistrationBean.setInitParameters(initParameters);
    return odataServletRegistrationBean;
}
项目:contestparser    文件:DispatcherServletAutoConfiguration.java   
@Bean(name = DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)
public ServletRegistrationBean dispatcherServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            dispatcherServlet(), this.server.getServletMapping());
    registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    if (this.multipartConfig != null) {
        registration.setMultipartConfig(this.multipartConfig);
    }
    return registration;
}
项目:trader    文件:TraderUI.java   
@Bean(name="springBootServletRegistrationBean")
 public ServletRegistrationBean servletRegistrationBean() {
     SpringVaadinServlet servlet = new SpringVaadinServlet() {

         private static final long serialVersionUID = 1L;

@Override
         public void servletInitialized() throws ServletException {
             super.servletInitialized();
             getService().addSessionInitListener(new TraderSessionInitListener());
         }

     };

     return new ServletRegistrationBean(servlet, "/ui/*", "/VAADIN/*");
 }
项目:spring-configuration-support    文件:SampleApplication.java   
@Bean(name = "configServlet")
public ServletRegistrationBean configServlet() {
    DispatcherServlet dispatcherServlet = new DispatcherServlet();
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(ConfigServletConfig.class);
    dispatcherServlet.setApplicationContext(applicationContext);
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(dispatcherServlet, "/config/*");
    registrationBean.setLoadOnStartup(1);
    return registrationBean;
}
项目:various_demos    文件:ServletConfig.java   
@Bean
public ServletRegistrationBean registerServlet(){
    ServletRegistrationBean statViewServletRegistrationBean = 
            new ServletRegistrationBean(dispatchDruidServlet(), "/druid/*");
    /* 
     * According to the definition of StatViewServlet, the white-list of druid StatViewServlet
     * can be specifed with the format as "xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy" to limit the access to 
     * the StatViewServlet.  
     */
    statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_ALLOW,  "127.0.0.1");
    statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_USERNAME, "admin");
    statViewServletRegistrationBean.addInitParameter(StatViewServlet.PARAM_NAME_PASSWORD, "password");
    return statViewServletRegistrationBean;
}
项目:xroad-catalog    文件:WebServiceConfig.java   
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/ws/*");
}
项目:BCDS    文件:WebServiceConfiguration.java   
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
    log.info("Registering message dispatcher servlet.");
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/soap-api/*");
}
项目:api-server-seed    文件:WebConfig.java   
@Bean
@Order
public ServletRegistrationBean statViewServlet() {
    StatViewServlet servlet = new StatViewServlet();
    ServletRegistrationBean bean = new ServletRegistrationBean(servlet, "/druid/*");
    return bean;
}
项目:VotingSystem_1b    文件:Main.java   
@Bean
public ServletRegistrationBean facesServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new FacesServlet(), "*.xhtml");
    registration.setLoadOnStartup(1);     
    return registration;
}
项目:pebble-spring-boot-starter    文件:WebServletHandler.java   
@Override
public void doHandle(Map<String, Object> attributes, BeanDefinition beanDefinition,
        BeanDefinitionRegistry registry) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServletRegistrationBean.class);
    builder.addPropertyValue("asyncSupported", attributes.get("asyncSupported"));
    builder.addPropertyValue("initParameters", extractInitParameters(attributes));
    builder.addPropertyValue("loadOnStartup", attributes.get("loadOnStartup"));
    String name = determineName(attributes, beanDefinition);
    builder.addPropertyValue("name", name);
    builder.addPropertyValue("servlet", beanDefinition);
    builder.addPropertyValue("urlMappings", extractUrlPatterns("urlPatterns", attributes));
    registry.registerBeanDefinition(name, builder.getBeanDefinition());
}
项目:Voting_2b    文件:WebConfiguration.java   
@Bean
ServletRegistrationBean h2servletRegistration()
{
    ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
    registrationBean.addUrlMappings("/console/*");
    return registrationBean;
}
项目:Voting_2b    文件:Application.java   
@Bean
public ServletRegistrationBean facesServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new FacesServlet(), "*.xhtml");
    registration.setLoadOnStartup(1);
    return registration;
}
项目:Voting_1b    文件:Main.java   
@Bean
public ServletRegistrationBean facesServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new FacesServlet(), "*.xhtml");
    registration.setLoadOnStartup(1);     
    return registration;
}
项目:springJpaKata    文件:MetricsConfig.java   
@Bean
@Autowired
public ServletRegistrationBean servletRegistrationBean(MetricRegistry metricRegistry) {
    MetricsServlet ms = new MetricsServlet(metricRegistry);
    ServletRegistrationBean srb = new ServletRegistrationBean(ms, "/stats/*");
    srb.setLoadOnStartup(1);
    return srb;
}
项目:springJpaKata    文件:MetricsConfig.java   
@Bean
@Autowired
public ServletRegistrationBean servletHealthRegistryBean(HealthCheckRegistry healthCheckRegistry) {
    HealthCheckServlet hc = new HealthCheckServlet(healthCheckRegistry);
    ServletRegistrationBean srb = new ServletRegistrationBean(hc, "/health/*");
    srb.setLoadOnStartup(2);
    return srb;
}
项目:graphite-monitor-example    文件:WebConfiguration.java   
@Bean
ServletRegistrationBean h2servletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
    registration.addUrlMappings("/console/*");
    registration.addInitParameter("webAllowOthers", "true");
    return registration;
}
项目:voters_2b    文件:WebConfiguration.java   
@Bean
ServletRegistrationBean h2servletRegistration()
{
    ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
    registrationBean.addUrlMappings("/console/*");
    return registrationBean;
}
项目:spring-boot-security-saml-samples    文件:FilterCleanupConfig.java   
@Bean
public static BeanDefinitionRegistryPostProcessor removeUnwantedAutomaticFilterRegistration() {
    return new BeanDefinitionRegistryPostProcessor() {
        @Override
        public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        }

        @Override
        public void postProcessBeanFactory(ConfigurableListableBeanFactory bf) throws BeansException {
            DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) bf;
            Set<String> filtersToDisable = ImmutableSet.of("samlEntryPoint", "samlFilter", "samlIDPDiscovery", "metadataDisplayFilter",
                    "samlWebSSOHoKProcessingFilter", "samlWebSSOProcessingFilter",
                    "samlLogoutProcessingFilter", "samlLogoutFilter", "metadataGeneratorFilter");
            Arrays.stream(beanFactory.getBeanNamesForType(javax.servlet.Filter.class))
                    .filter(filtersToDisable::contains)
                    .forEach(name -> {
                        BeanDefinition definition = BeanDefinitionBuilder
                                .genericBeanDefinition(FilterRegistrationBean.class)
                                .setScope(BeanDefinition.SCOPE_SINGLETON)
                                .addConstructorArgReference(name)
                                .addConstructorArgValue(new ServletRegistrationBean[]{})
                                .addPropertyValue("enabled", false)
                                .getBeanDefinition();
                        beanFactory.registerBeanDefinition(name + "FilterRegistrationBean", definition);
                    });
        }
    };
}
项目:moneta    文件:MonetaSpringBootApplication.java   
@Bean
public ServletRegistrationBean memoryMonitorStartupServlet() {
    ServletRegistrationBean registration =
            new ServletRegistrationBean(new MemoryMonitorStartupServlet(), "/admin4j/memory");
    registration.setLoadOnStartup(1);
    return registration;
}
项目:moneta    文件:MonetaSpringBootApplication.java   
@Bean
public ServletRegistrationBean monetaServlet() {
    ServletRegistrationBean registration =
            new ServletRegistrationBean(new MonetaServlet(),
                    "/moneta/topic/*");
    registration.addInitParameter(
            MonetaServlet.CONFIG_IGNORED_CONTEXT_PATH_NODES, "moneta,topic");
    return registration;
}
项目:moneta    文件:MonetaSpringBootApplication.java   
@Bean
public ServletRegistrationBean monetaTopicListServlet() {
    ServletRegistrationBean registration =
            new ServletRegistrationBean(new MonetaTopicListServlet(),
                    "/moneta/topics/*");
    return registration;
}
项目:contestparser    文件:WebServletHandler.java   
@Override
public void doHandle(Map<String, Object> attributes, BeanDefinition beanDefinition,
        BeanDefinitionRegistry registry) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder
            .rootBeanDefinition(ServletRegistrationBean.class);
    builder.addPropertyValue("asyncSupported", attributes.get("asyncSupported"));
    builder.addPropertyValue("initParameters", extractInitParameters(attributes));
    builder.addPropertyValue("loadOnStartup", attributes.get("loadOnStartup"));
    String name = determineName(attributes, beanDefinition);
    builder.addPropertyValue("name", name);
    builder.addPropertyValue("servlet", beanDefinition);
    builder.addPropertyValue("urlMappings",
            extractUrlPatterns("urlPatterns", attributes));
    registry.registerBeanDefinition(name, builder.getBeanDefinition());
}
项目:contestparser    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void errorPage404() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
    assertThat(getResponse(getLocalUrl("/not-found")), equalTo("Hello World"));
}
项目:contestparser    文件:JettyEmbeddedServletContainerFactoryTests.java   
@Override
@SuppressWarnings("serial")
// Workaround for Jetty issue - https://bugs.eclipse.org/bugs/show_bug.cgi?id=470646
protected String setUpFactoryForCompression(final int contentSize, String[] mimeTypes,
        String[] excludedUserAgents) throws Exception {
    char[] chars = new char[contentSize];
    Arrays.fill(chars, 'F');
    final String testContent = new String(chars);
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    Compression compression = new Compression();
    compression.setEnabled(true);
    if (mimeTypes != null) {
        compression.setMimeTypes(mimeTypes);
    }
    if (excludedUserAgents != null) {
        compression.setExcludedUserAgents(excludedUserAgents);
    }
    factory.setCompression(compression);
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new HttpServlet() {
                @Override
                protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                    resp.setContentLength(contentSize);
                    resp.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
                    resp.getWriter().print(testContent);
                }
            }, "/test.txt"));
    this.container.start();
    return testContent;
}
项目:contestparser    文件:DispatcherServletAutoConfiguration.java   
private ConditionOutcome checkServletRegistrations(
        ConfigurableListableBeanFactory beanFactory) {
    List<String> registrations = Arrays.asList(beanFactory
            .getBeanNamesForType(ServletRegistrationBean.class, false, false));
    boolean containsDispatcherRegistrationBean = beanFactory
            .containsBean(DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    if (registrations.isEmpty()) {
        if (containsDispatcherRegistrationBean) {
            return ConditionOutcome.noMatch("found no ServletRegistrationBean "
                    + "but a non-ServletRegistrationBean named "
                    + DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        }
        return ConditionOutcome.match("no ServletRegistrationBean found");
    }
    if (registrations
            .contains(DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)) {
        return ConditionOutcome.noMatch("found ServletRegistrationBean named "
                + DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    }
    if (containsDispatcherRegistrationBean) {
        return ConditionOutcome.noMatch("found non-ServletRegistrationBean named "
                + DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    }
    return ConditionOutcome
            .match("one or more ServletRegistrationBeans is found and none is named "
                    + DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);

}
项目:contestparser    文件:JerseyAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(name = "jerseyServletRegistration")
@ConditionalOnProperty(prefix = "spring.jersey", name = "type", havingValue = "servlet", matchIfMissing = true)
public ServletRegistrationBean jerseyServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new ServletContainer(this.config), this.path);
    addInitParameters(registration);
    registration.setName("jerseyServlet");
    return registration;
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Test
public void registrationProperties() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(ServerPropertiesAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    assertNotNull(this.context.getBean(DispatcherServlet.class));
    ServletRegistrationBean registration = this.context
            .getBean(ServletRegistrationBean.class);
    assertEquals("[/]", registration.getUrlMappings().toString());
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Test
public void registrationOverride() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(CustomDispatcherRegistration.class,
            ServerPropertiesAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    ServletRegistrationBean registration = this.context
            .getBean(ServletRegistrationBean.class);
    assertEquals("[/foo]", registration.getUrlMappings().toString());
    assertEquals("customDispatcher", registration.getServletName());
    assertEquals(0, this.context.getBeanNamesForType(DispatcherServlet.class).length);
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Test(expected = UnsatisfiedDependencyException.class)
public void registrationOverrideWithAutowiredServlet() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(CustomAutowiredRegistration.class,
            ServerPropertiesAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    ServletRegistrationBean registration = this.context
            .getBean(ServletRegistrationBean.class);
    assertEquals("[/foo]", registration.getUrlMappings().toString());
    assertEquals("customDispatcher", registration.getServletName());
    assertEquals(1, this.context.getBeanNamesForType(DispatcherServlet.class).length);
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Test
public void servletPath() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(ServerPropertiesAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "server.servlet_path:/spring");
    this.context.refresh();
    assertNotNull(this.context.getBean(DispatcherServlet.class));
    ServletRegistrationBean registration = this.context
            .getBean(ServletRegistrationBean.class);
    assertEquals("[/spring/*]", registration.getUrlMappings().toString());
    assertNull(registration.getMultipartConfig());
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Test
public void multipartConfig() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(MultipartConfiguration.class,
            ServerPropertiesAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    this.context.refresh();
    ServletRegistrationBean registration = this.context
            .getBean(ServletRegistrationBean.class);
    assertNotNull(registration.getMultipartConfig());
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            new DispatcherServlet(), "/foo");
    registration.setName("customDispatcher");
    return registration;
}
项目:contestparser    文件:DispatcherServletAutoConfigurationTests.java   
@Bean
public ServletRegistrationBean dispatcherServletRegistration(
        DispatcherServlet dispatcherServlet) {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            dispatcherServlet, "/foo");
    registration.setName("customDispatcher");
    return registration;
}
项目:contestparser    文件:H2ConsoleAutoConfigurationTests.java   
@Test
public void consoleIsDisabledByDefault() {
    this.context.register(H2ConsoleAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBeansOfType(ServletRegistrationBean.class).size(),
            is(equalTo(0)));
}
项目:contestparser    文件:H2ConsoleAutoConfigurationTests.java   
@Test
public void propertyCanEnableConsole() {
    this.context.register(H2ConsoleAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.h2.console.enabled:true");
    this.context.refresh();
    assertThat(this.context.getBeansOfType(ServletRegistrationBean.class).size(),
            is(equalTo(1)));
    assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(),
            hasItems("/h2-console/*"));
}
项目:contestparser    文件:H2ConsoleAutoConfigurationTests.java   
@Test
public void customPathWithTrailingSlash() {
    this.context.register(H2ConsoleAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.h2.console.enabled:true", "spring.h2.console.path:/custom/");
    this.context.refresh();
    assertThat(this.context.getBeansOfType(ServletRegistrationBean.class).size(),
            is(equalTo(1)));
    assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(),
            hasItems("/custom/*"));
}