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


Java WebappContext.setInitParameter方法代码示例

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


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

示例1: startServer

import org.glassfish.grizzly.servlet.WebappContext; //导入方法依赖的package包/类
/**
 * Starts Grizzly HTTP server exposing SMAPH JAX-RS resources.
 * 
 * @throws URISyntaxException
 * @throws ProcessingException
 */
public static void startServer(String serverUri, Path storageBase, String watGcubeToken) throws ProcessingException, URISyntaxException {
	LOG.info("Initializing SMAPH services.");
	LOG.info("Storage path: {}", storageBase.toAbsolutePath());

	HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(new URI(serverUri));
	httpServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("src/main/webapp/"), "/*");

	WebappContext context = new WebappContext("smaph");
	ResourceConfig rc = new ResourceConfig().packages("it.unipi.di.acube.smaph.servlet");
	ServletRegistration registration = context.addServlet("ServletContainer", new ServletContainer(rc));
	registration.addMapping("/smaph/*");
	context.addListener(SmaphContextListener.class);
	context.setInitParameter(SmaphContextListener.WIKI_PAGES_DB, storageBase.resolve("mapdb/wikipedia_pages.db").toString());
	context.setInitParameter(SmaphContextListener.FREEBASE_DIR, storageBase.resolve("mapdb/freebase.db").toString());
	context.setInitParameter(SmaphContextListener.ENTITY_TO_ANCHORS_DB, storageBase.resolve("mapdb/e2a.db").toString());
	context.setInitParameter(SmaphContextListener.WAT_GCUBE_TOKEN, watGcubeToken);
	context.deploy(httpServer);
	try {
		httpServer.start();
		LOG.info("Smaph started with WADL available at " + "{}application.wadl\nPress CTRL^C (SIGINT) to terminate.",
		        serverUri);
		Thread.currentThread().join();
		LOG.info("Shutting server down..");
	} catch (Exception e) {
		LOG.error("There was an error while starting Grizzly HTTP server.", e);
	}
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:34,代码来源:ServerMain.java

示例2: configureContext

import org.glassfish.grizzly.servlet.WebappContext; //导入方法依赖的package包/类
protected void configureContext(WebappContext context) {
	context.setInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, AnnotationConfigWebApplicationContext.class.getName());
	context.setInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, ExtendedApplicationContextInitializer.class.getName());
	if (javaConfigClass != null) {
		context.setInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, javaConfigClass.getName());
	}
	
	context.addListener(SLF4JLoggingListener.class);
	context.addListener(ContextLoaderListener.class);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:11,代码来源:RestServerTestResource.java

示例3: configureContext

import org.glassfish.grizzly.servlet.WebappContext; //导入方法依赖的package包/类
protected void configureContext(WebappContext context) {
	context.setInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, AnnotationConfigWebApplicationContext.class.getName());
	context.setInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, ExtendedApplicationContextInitializer.class.getName());
	if (javaConfigClass != null) {
		context.setInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, javaConfigClass.getName());
	}
	
	context.addListener(SLF4JLoggingListener.class);
	context.addListener(ContextLoaderListener.class);
	context.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter())
			.addMappingForUrlPatterns(null, "/*");
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:13,代码来源:RestServerTestResource.java

示例4: _createContext

import org.glassfish.grizzly.servlet.WebappContext; //导入方法依赖的package包/类
@Nonnull
private static WebappContext _createContext (final URI u,
                                             final Class <? extends Servlet> aServletClass,
                                             final Servlet aServlet,
                                             final Map <String, String> aInitParams,
                                             final Map <String, String> aContextInitParams)
{
  String path = u.getPath ();
  if (path == null)
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be non-null");
  if (path.isEmpty ())
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be present");
  if (path.charAt (0) != '/')
    throw new IllegalArgumentException ("The URI path, of the URI " + u + ". must start with a '/'");
  path = String.format ("/%s", UriComponent.decodePath (u.getPath (), true).get (1).toString ());

  final WebappContext aContext = new WebappContext ("GrizzlyContext", path);
  ServletRegistration registration;
  if (aServletClass != null)
    registration = aContext.addServlet (aServletClass.getName (), aServletClass);
  else
    registration = aContext.addServlet (aServlet.getClass ().getName (), aServlet);
  registration.addMapping ("/*");

  if (aContextInitParams != null)
    for (final Map.Entry <String, String> e : aContextInitParams.entrySet ())
      aContext.setInitParameter (e.getKey (), e.getValue ());

  if (aInitParams != null)
    registration.setInitParameters (aInitParams);

  return aContext;
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:34,代码来源:MockServer.java


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