當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletModule類代碼示例

本文整理匯總了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;
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:24,代碼來源:GuiceApplication.java

示例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);
        }
      });
    }
  };
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:19,代碼來源:ShiroKerberosAuthenticationFilterTest.java

示例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;
	
}
 
開發者ID:Netflix,項目名稱:conductor,代碼行數:19,代碼來源:ServletContextListner.java

示例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);
        }
      }
    };
  }
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:25,代碼來源:ServerRpcProvider.java

示例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);
    }
  });
}
 
開發者ID:sonatype,項目名稱:nexus-public,代碼行數:26,代碼來源:SiestaModule.java

示例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);
}
 
開發者ID:sonatype,項目名稱:nexus-public,代碼行數:26,代碼來源:TestModule.java

示例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);
    }
  });
}
 
開發者ID:sonatype,項目名稱:nexus-public,代碼行數:22,代碼來源:WebResourcesModule.java

示例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);
    }
  });
}
 
開發者ID:sonatype,項目名稱:nexus-public,代碼行數:23,代碼來源:RaptureModule.java

示例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");
}
 
開發者ID:HuygensING,項目名稱:antioch,代碼行數:18,代碼來源:EndpointTest.java

示例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);
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:27,代碼來源:AbstractPreloadedPluginScanner.java

示例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);
}
 
開發者ID:jerolba,項目名稱:funsteroid,代碼行數:17,代碼來源:GuiceConfigListener.java

示例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;
}
 
開發者ID:kamegu,項目名稱:git-webapp,代碼行數:21,代碼來源:GuiceListener.java

示例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;
}
 
開發者ID:dharmab,項目名稱:sheets,代碼行數:25,代碼來源:AppContextListener.java

示例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)
									);
	}
 
開發者ID:inepex,項目名稱:ineform,代碼行數:22,代碼來源:ShowcaseServletConfig.java


注:本文中的com.google.inject.servlet.ServletModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。