本文整理汇总了Java中com.google.inject.servlet.ServletModule类的典型用法代码示例。如果您正苦于以下问题:Java ServletModule类的具体用法?Java ServletModule怎么用?Java ServletModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServletModule类属于com.google.inject.servlet包,在下文中一共展示了ServletModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureGuice
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
private Injector configureGuice(T configuration, Environment environment) throws Exception {
// setup our core modules...
appModules.add(new MetricRegistryModule(environment.metrics()));
appModules.add(new ServletModule());
// ...and add the app's modules
appModules.addAll(addModules(configuration, environment));
final Injector injector = Guice.createInjector(ImmutableList.copyOf(this.appModules));
// Taken from https://github.com/Squarespace/jersey2-guice/wiki#complex-example. HK2 is no fun.
JerseyGuiceUtils.install((name, parent) -> {
if (!name.startsWith("__HK2_Generated_")) {
return null;
}
return injector.createChildInjector(Lists.newArrayList(new JerseyGuiceModule(name)))
.getInstance(ServiceLocator.class);
});
injector.injectMembers(this);
registerWithInjector(environment, injector);
return injector;
}
示例2: getChildServletModule
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
public Module getChildServletModule() {
return new ServletModule() {
@Override
protected void configureServlets() {
filter(PATH).through(filter);
serve(PATH).with(new HttpServlet() {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
mockServlet.service(req, resp);
resp.setStatus(HttpServletResponse.SC_OK);
}
});
}
};
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:ShiroKerberosPermissiveAuthenticationFilterTest.java
示例3: getChildServletModule
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
public Module getChildServletModule() {
return new ServletModule() {
@Override
protected void configureServlets() {
filter(PATH).through(filter);
serve(PATH).with(new HttpServlet() {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
getMockServlet().service(req, resp);
resp.setStatus(HttpServletResponse.SC_OK);
}
});
}
};
}
示例4: getSwagger
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
private ServletModule getSwagger() {
String resourceBasePath = ServletContextListner.class.getResource("/swagger-ui").toExternalForm();
DefaultServlet ds = new DefaultServlet();
ServletModule sm = new ServletModule() {
@Override
protected void configureServlets() {
Map<String, String> params = new HashMap<>();
params.put("resourceBase", resourceBasePath);
params.put("redirectWelcome", "true");
serve("/*").with(ds, params);
}
};
return sm;
}
示例5: getServletModule
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
public ServletModule getServletModule(final Injector injector) {
return new ServletModule() {
@Override
protected void configureServlets() {
// We add servlets here to override the DefaultServlet automatic registered by WebAppContext
// in path "/" with our WaveClientServlet. Any other way to do this?
// Related question (unanswered 08-Apr-2011)
// http://web.archiveorange.com/archive/v/d0LdlXf1kN0OXyPNyQZp
for (Pair<String, ServletHolder> servlet : servletRegistry) {
String url = servlet.getFirst();
@SuppressWarnings("unchecked")
Class<HttpServlet> clazz = (Class<HttpServlet>) servlet.getSecond().getHeldClass();
Map<String,String> params = servlet.getSecond().getInitParameters();
serve(url).with(clazz,params);
bind(clazz).in(Singleton.class);
}
for (Pair<String, Class<? extends Filter>> filter : filterRegistry) {
filter(filter.first).through(filter.second);
}
}
};
}
示例6: doConfigure
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
private void doConfigure() {
install(new ResteasyModule());
install(new ServletModule()
{
@Override
protected void configureServlets() {
log.debug("Mount point: {}", MOUNT_POINT);
bind(SiestaServlet.class);
serve(MOUNT_POINT + "/*").with(SiestaServlet.class, ImmutableMap.of(
"resteasy.servlet.mapping.prefix", MOUNT_POINT
));
filter(MOUNT_POINT + "/*").through(SecurityFilter.class);
}
});
install(new FilterChainModule()
{
@Override
protected void configure() {
addFilterChain(MOUNT_POINT + "/**", NexusAuthenticationFilter.NAME, AnonymousFilter.NAME);
}
});
}
示例7: configure
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected void configure() {
install(new ResteasyModule());
install(new ValidationModule());
install(new ServletModule()
{
@Override
protected void configureServlets() {
serve(MOUNT_POINT + "/*").with(SiestaServlet.class, ImmutableMap.of(
"resteasy.servlet.mapping.prefix", MOUNT_POINT
));
}
});
// register exception mappers required by tests
register(ValidationErrorsExceptionMapper.class);
register(WebappExceptionMapper.class);
// register test resources
register(EchoResource.class);
register(ErrorsResource.class);
register(UserResource.class);
register(ValidationErrorsResource.class);
}
示例8: configure
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected void configure() {
final Binder lowPriorityBinder = binder().withSource(Sources.prioritize(Integer.MIN_VALUE));
lowPriorityBinder.install(new ServletModule()
{
@Override
protected void configureServlets() {
serve("/*").with(WebResourceServlet.class);
filter("/*").through(SecurityFilter.class);
}
});
lowPriorityBinder.install(new FilterChainModule()
{
@Override
protected void configure() {
addFilterChain("/**", AnonymousFilter.NAME);
}
});
}
示例9: configure
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected void configure() {
bind(filterKey(SessionAuthenticationFilter.NAME)).to(SessionAuthenticationFilter.class);
install(new ServletModule()
{
@Override
protected void configureServlets() {
serve(SESSION_MP).with(SessionServlet.class);
filter(SESSION_MP).through(SecurityFilter.class);
filter(SESSION_MP).through(CookieFilter.class);
}
});
install(new FilterChainModule()
{
@Override
protected void configure() {
addFilterChain(SESSION_MP, SessionAuthenticationFilter.NAME);
}
});
}
示例10: setupWithModule
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
protected static void setupWithModule(Module baseModule) {
Log.debug("Setting up Jersey");
application = new TestApplication();
Log.trace("+- application=[{}]", application);
Log.debug("Bootstrapping Jersey2-Guice bridge");
ServiceLocator locator = BootstrapUtils.newServiceLocator();
Log.trace("+- locator=[{}]", locator);
final List<Module> modules = Arrays.asList(new ServletModule(), baseModule);
final Injector injector = BootstrapUtils.newInjector(locator, modules);
Log.trace("+- injector=[{}]", injector);
BootstrapUtils.install(locator);
Log.trace("+- done: locator installed");
}
示例11: scanGuiceModules
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
private void scanGuiceModules(Set<Class<?>> classes) throws IOException {
try {
Class<?> sysModuleBaseClass = Module.class;
Class<?> httpModuleBaseClass = ServletModule.class;
Class<?> sshModuleBaseClass = Class.forName("com.google.gerrit.sshd.CommandModule");
sshModuleClass = null;
httpModuleClass = null;
sysModuleClass = null;
for (Class<?> clazz : classes) {
if (clazz.isLocalClass()) {
continue;
}
if (sshModuleBaseClass.isAssignableFrom(clazz)) {
sshModuleClass = getUniqueGuiceModule(sshModuleBaseClass, sshModuleClass, clazz);
} else if (httpModuleBaseClass.isAssignableFrom(clazz)) {
httpModuleClass = getUniqueGuiceModule(httpModuleBaseClass, httpModuleClass, clazz);
} else if (sysModuleBaseClass.isAssignableFrom(clazz)) {
sysModuleClass = getUniqueGuiceModule(sysModuleBaseClass, sysModuleClass, clazz);
}
}
} catch (ClassNotFoundException e) {
throw new IOException("Cannot find base Gerrit classes for Guice Plugin Modules", e);
}
}
示例12: getInjector
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected Injector getInjector() {
ServletModule servletModule=new ServletModule(){
@Override
protected void configureServlets() {
filter("/*").through(FunrouteFilter.class);
}
};
Module[] all=new Module[otherModules.length+2];
all[0]=cfg;
all[1]=servletModule;
for(int i=0;i<otherModules.length;i++){
all[i+2]=otherModules[i];
}
return Guice.createInjector(all);
}
示例13: getInjector
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected Injector getInjector() {
injector = Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
String persistenceUnitName = PersistenceInitializeListener.getPersistenceUnitName();
install(new JpaPersistModule(persistenceUnitName));
filter("/*").through(PersistFilter.class);
requestStaticInjection(EntityOperatorProvider.class);
bind(GitOperation.class).in(Singleton.class);
bind(GitApi.class).in(Singleton.class);
ClassFinder.findClasses("gw.service").forEach(clazz -> bind(clazz).in(Singleton.class));
}
});
return injector;
}
示例14: createInjector
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
private Injector createInjector() {
Injector injector;
try {
final DataSource dataSource = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/postgresql");
injector = Guice.createInjector(
new DatabaseModule(dataSource),
new ServletModule() {
@Override
protected void configureServlets() {
// Hibernate thread-scoped sessions
filter("/*").through(DatabaseSessionFilter.class);
// RequestFactory servlet mapping
install(new InjectableRequestFactoryModule());
serve("/gwtRequest").with(InjectableRequestFactoryServlet.class);
// RPC servlet mappings go here
// example:
//serve("/sheets/myurl").with(MyServiceImpl.class);
}
});
} catch (NamingException e) {
throw new RuntimeException(e);
}
return injector;
}
示例15: getInjector
import com.google.inject.servlet.ServletModule; //导入依赖的package包/类
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule() {
protected void configureServlets() {
install(new JpaPersistModule("IneFormShowCaseWithEjbs"));
filter("/*").through(PersistFilter.class);
};
}
, new IneFrameBaseServletModule("ineformshowcasewithejbs", ShowcaseDispatchServlet.class)
// , new IneCoreBaseServletModule("ineformshowcasewithejbs", ShowcaseDispatchServlet.class)
, new UploadServletModule()
, new TestServletModule()
, new IneFrameBaseActionHanlderModule()
, new IneFrameBaseModule()
, new IneFormActionHanlderModule()
, new IneFormDispatcherGuiceModule()
// , new IneFrameModuleGuiceModule()
, new IneModuleGuiceModule(false)
);
}