本文整理汇总了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);
}
}
示例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);
}
示例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, "/*");
}
示例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;
}