当前位置: 首页>>代码示例>>Java>>正文


Java Dynamic.setLoadOnStartup方法代码示例

本文整理汇总了Java中javax.servlet.ServletRegistration.Dynamic.setLoadOnStartup方法的典型用法代码示例。如果您正苦于以下问题:Java Dynamic.setLoadOnStartup方法的具体用法?Java Dynamic.setLoadOnStartup怎么用?Java Dynamic.setLoadOnStartup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.ServletRegistration.Dynamic的用法示例。


在下文中一共展示了Dynamic.setLoadOnStartup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inject

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
public Dynamic inject(ServletContext servletContext, String urlPattern) {
  String[] urlPatterns = splitUrlPattern(urlPattern);
  if (urlPatterns.length == 0) {
    LOGGER.warn("urlPattern is empty, ignore register {}.", SERVLET_NAME);
    return null;
  }

  String listenAddress = ServletConfig.getLocalServerAddress();
  if (!ServletUtils.canPublishEndpoint(listenAddress)) {
    LOGGER.warn("ignore register {}.", SERVLET_NAME);
    return null;
  }

  // dynamic deploy a servlet to handle serviceComb RESTful request
  Dynamic dynamic = servletContext.addServlet(SERVLET_NAME, RestServlet.class);
  dynamic.setAsyncSupported(true);
  dynamic.addMapping(urlPatterns);
  dynamic.setLoadOnStartup(0);
  LOGGER.info("RESTful servlet url pattern: {}.", Arrays.toString(urlPatterns));

  return dynamic;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:RestServletInjector.java

示例2: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
/**
 * Configure the given {@link ServletContext} with any servlets, filters, listeners
 * context-params and attributes necessary for initializing this web application. See examples
 * {@linkplain WebApplicationInitializer above}.
 *
 * @param servletContext the {@code ServletContext} to initialize
 * @throws ServletException if any call against the given {@code ServletContext} throws a {@code ServletException}
 */
public void onStartup(ServletContext servletContext) throws ServletException {
	// Spring Context Bootstrapping
	AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
	rootAppContext.register(AutoPivotConfig.class);
	servletContext.addListener(new ContextLoaderListener(rootAppContext));

	// Set the session cookie name. Must be done when there are several servers (AP,
	// Content server, ActiveMonitor) with the same URL but running on different ports.
	// Cookies ignore the port (See RFC 6265).
	CookieUtil.configure(servletContext.getSessionCookieConfig(), CookieUtil.COOKIE_NAME);

	// The main servlet/the central dispatcher
	final DispatcherServlet servlet = new DispatcherServlet(rootAppContext);
	servlet.setDispatchOptionsRequest(true);
	Dynamic dispatcher = servletContext.addServlet("springDispatcherServlet", servlet);
	dispatcher.addMapping("/*");
	dispatcher.setLoadOnStartup(1);

	// Spring Security Filter
	final FilterRegistration.Dynamic springSecurity = servletContext.addFilter(SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy());
	springSecurity.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:32,代码来源:AutoPivotWebAppInitializer.java

示例3: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext)
		throws ServletException {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.register(MyMvcConfig.class);
	ctx.setServletContext(servletContext); // ②

	Dynamic servlet = servletContext.addServlet("dispatcher",new DispatcherServlet(ctx)); // 3
	servlet.addMapping("/");
	servlet.setLoadOnStartup(1);
}
 
开发者ID:longjiazuo,项目名称:springMvc4.x-project,代码行数:12,代码来源:WebInitializer.java

示例4: initGitServlet

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
private void initGitServlet(Path gitWorkspace, ServletContext servletContext) throws IOException {
    if (!Files.exists(gitWorkspace)) {
        Files.createDirectories(gitWorkspace);
    }

    // add git servlet mapping
    Dynamic gitServlet = servletContext.addServlet("git-servlet", new GitServlet());
    gitServlet.addMapping("/git/*");
    gitServlet.setInitParameter("base-path", gitWorkspace.toString());
    gitServlet.setInitParameter("export-all", "true");
    gitServlet.setAsyncSupported(true);
    gitServlet.setLoadOnStartup(1);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:14,代码来源:AppInit.java

示例5: initialize

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
public static void initialize(ServletContext servletContext, boolean dev) throws ServletException {
	FacesInitializer facesInitializer = new FacesInitializer();

	servletContext.setInitParameter("primefaces.FONT_AWESOME", "true");
	servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
	if (dev) {
		servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "0");
		servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
	} else {
		servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "-1");
		servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Production");
	}
	servletContext.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));

	Set<Class<?>> clazz = new HashSet<Class<?>>();
	clazz.add(WebXmlSpringBoot.class);
	facesInitializer.onStartup(clazz, servletContext);

	Dynamic startBrowserServlet = servletContext.addServlet("StartBrowserServlet", StartBrowserServlet.class);
	startBrowserServlet.setLoadOnStartup(2);
}
 
开发者ID:jirkapinkas,项目名称:sitemonitoring-production,代码行数:22,代码来源:WebXmlCommon.java

示例6: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	AnnotationConfigWebApplicationContext applicationContext = buildApplicationContext();
	Dynamic appServlet = servletContext.addServlet("appServlet", new DispatcherServlet(applicationContext));
	appServlet.setLoadOnStartup(1);
	appServlet.addMapping("/api/*", "/app/*");
	
	MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet(applicationContext);
	messageDispatcherServlet.setTransformWsdlLocations(true);
	Dynamic wsServlet = servletContext.addServlet("wsServlet", messageDispatcherServlet);
	wsServlet.setLoadOnStartup(2);
	wsServlet.addMapping("/ws/*");
	
	FilterRegistration.Dynamic filter = servletContext.addFilter("openEntityManagerInViewFilter", buildOpenEntityManagerFilter());
	filter.addMappingForUrlPatterns(getDispatcherTypes(), false, "/api/*", "/app/*","/ws/*");
	
	servletContext.addListener(new ContextLoaderListener(applicationContext));
}
 
开发者ID:leosilvadev,项目名称:simplebank,代码行数:19,代码来源:Application.java

示例7: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException 
{
       AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
       ctx.register(WebAppConfig.class);
       servletContext.addListener(new ContextLoaderListener(ctx));
       
       // http://stackoverflow.com/questions/7903556/programming-spring-mvc-controller-and-jsp-for-httpdelete
       // https://cwiki.apache.org/confluence/display/GMOxDOC30/cviewer-javaee6+-+Programmatically+register+servlets+and+filters
       // https://gist.github.com/krams915/4238821        
       servletContext
       	.addFilter("hiddenHttpMethodFilter", "org.springframework.web.filter.HiddenHttpMethodFilter")
       	.addMappingForUrlPatterns(null, false, "/*");

       // This DispatcherServlet is a front controller that forwards the incoming HTTP requests to the specific controler classes
       Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
       servlet.addMapping("/");
       servlet.setLoadOnStartup(1);
}
 
开发者ID:willianantunes,项目名称:spring-crud-programmatically,代码行数:20,代码来源:Initializer.java

示例8: registerCXFServlet

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
private static void registerCXFServlet(ServletContext servletContext) {
	LOGGER.info("Registering CXF servlet...");
	Dynamic dynamic =
		servletContext.
			addServlet(
				"LDP4jFrontendServerServlet",
				"org.apache.cxf.transport.servlet.CXFServlet");
	dynamic.addMapping("/*");
	/** See https://issues.apache.org/jira/browse/CXF-5068 */
	dynamic.setInitParameter("disable-address-updates","true");
	/** Required for testing */
	dynamic.setInitParameter("static-welcome-file","/index.html");
	dynamic.setInitParameter("static-resources-list","/index.html");
	dynamic.setLoadOnStartup(1);
	LOGGER.info("CXF servlet registered.");
}
 
开发者ID:ldp4j,项目名称:ldp4j,代码行数:17,代码来源:BootstrapContextListener.java

示例9: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext)
		throws ServletException {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.register(MyMvcConfig.class);
	ctx.setServletContext(servletContext); // ②

	Dynamic servlet = servletContext.addServlet("dispatcher",new DispatcherServlet(ctx)); // ③
	servlet.addMapping("/");
	servlet.setLoadOnStartup(1);
}
 
开发者ID:longjiazuo,项目名称:springMvc4.x-project,代码行数:12,代码来源:WebInitializer.java

示例10: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext)
		throws ServletException {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.register(MyMvcConfig.class);
	ctx.setServletContext(servletContext); // ②

	Dynamic servlet = servletContext.addServlet("dispatcher",new DispatcherServlet(ctx)); // 3
	servlet.addMapping("/");
	servlet.setLoadOnStartup(1);
	servlet.setAsyncSupported(true);//①
}
 
开发者ID:longjiazuo,项目名称:springMvc4.x-project,代码行数:13,代码来源:WebInitializer.java

示例11: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.register(MyMvcConfig.class);
	context.setServletContext(servletContext);
	Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
	servlet.addMapping("/");
	servlet.setLoadOnStartup(1);
	// 开启异步支持
	servlet.setAsyncSupported(true);
}
 
开发者ID:zhazhapan,项目名称:hello-spring,代码行数:12,代码来源:WebInitializer.java

示例12: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
public void onStartup(ServletContext servletContext) throws ServletException {  
     AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();  
     ctx.register(AppConfig.class);  
     ctx.setServletContext(servletContext);    
     Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));  
     dynamic.addMapping("/");  
     dynamic.setLoadOnStartup(1);  
}
 
开发者ID:fgliu,项目名称:seckill,代码行数:9,代码来源:WebAppInitializer.java

示例13: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
public void onStartup(ServletContext servletContext) {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.setConfigLocation("org.audt4j.demo.hibernate.config");
	servletContext.addListener(new ContextLoaderListener(ctx));
	ctx.setServletContext(servletContext);
	Dynamic servlet = servletContext.addServlet("dispatcher",
			new DispatcherServlet(ctx));
	servlet.addMapping("/*");
	servlet.setLoadOnStartup(1);
	FilterRegistration.Dynamic springSecurityFilterChain = servletContext
			.addFilter("springSecurityFilterChain",
					new DelegatingFilterProxy());
	springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");
	springSecurityFilterChain.setAsyncSupported(true);
}
 
开发者ID:nipunthathsara,项目名称:Audit4j-Hibernate,代码行数:16,代码来源:WebInitializer.java

示例14: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
public void onStartup(ServletContext servletContext) throws ServletException {  
     AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
     ctx.getEnvironment().setActiveProfiles("Arquillian");
     ctx.register(ArquillianSpringMVCConfig.class);
     ctx.setServletContext(servletContext);
     Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
     dynamic.addMapping("/");
     dynamic.setLoadOnStartup(1);
}
 
开发者ID:kstateome,项目名称:lti-attendance,代码行数:10,代码来源:ArquillianWebAppInitializer.java

示例15: onStartup

import javax.servlet.ServletRegistration.Dynamic; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("org.synchronoss.cloud.nio.multipart.example.config");
    context.setServletContext(servletContext);
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
    dynamic.setAsyncSupported(true);
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);

}
 
开发者ID:synchronoss,项目名称:nio-multipart,代码行数:13,代码来源:WebAppInitializer.java


注:本文中的javax.servlet.ServletRegistration.Dynamic.setLoadOnStartup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。