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


Java ResourceConfig類代碼示例

本文整理匯總了Java中com.sun.jersey.api.core.ResourceConfig的典型用法代碼示例。如果您正苦於以下問題:Java ResourceConfig類的具體用法?Java ResourceConfig怎麽用?Java ResourceConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResourceConfig類屬於com.sun.jersey.api.core包,在下文中一共展示了ResourceConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureWebAppServlets

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
protected void configureWebAppServlets() {
  // Add in the web services filters/serves if app has them.
  // Using Jersey/guice integration module. If user has web services
  // they must have also bound a default one in their webapp code.
  if (this.wsName != null) {
    // There seems to be an issue with the guice/jersey integration
    // where we have to list the stuff we don't want it to serve
    // through the guicecontainer. In this case its everything except
    // the the web services api prefix. We can't just change the filter
    // from /* below - that doesn't work.
    String regex = "(?!/" + this.wsName + ")";
    serveRegex(regex).with(DefaultWrapperServlet.class);

    Map<String, String> params = new HashMap<String, String>();
    params.put(ResourceConfig.FEATURE_IMPLICIT_VIEWABLES, "true");
    params.put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, "true");
    params.put(FeaturesAndProperties.FEATURE_XMLROOTELEMENT_PROCESSING, "true");
    params.put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, GZIPContentEncodingFilter.class.getName());
    params.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, GZIPContentEncodingFilter.class.getName());
    filter("/*").through(getWebAppFilterClass(), params);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:WebApp.java

示例2: CCOWContextListener

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
public CCOWContextListener(final ContextState commonContext, final Module... behaviourModules) {
	super();
	SLF4JBridgeHandler.removeHandlersForRootLogger();
	SLF4JBridgeHandler.install();
	logger.info("Starting up servlet ...");
	this.modules = ImmutableList.<Module> builder().add(behaviourModules).add(new EndpointModule(commonContext))
			.add(new JerseyServletModule() {

				@Override
				protected void configureServlets() {
					final Map<String, String> params = ImmutableMap.<String, String> builder()
							.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
									GZIPContentEncodingFilter.class.getName())
							.build();
					bind(CORSFilter.class).in(Singleton.class);
					bind(UrlRewriteFilter.class).in(Singleton.class);
					serve("/*").with(GuiceContainer.class, params);
					filter("/*").through(CORSFilter.class);
					filter("/*").through(UrlRewriteFilter.class);

					requestStaticInjection(WebSocketsConfigurator.class);
				}
			}).build();
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:25,代碼來源:CCOWContextListener.java

示例3: initiate

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
    try {
        //Register the OfflineRestFilter
        String filters = (String) rc.getProperties().get(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS);
        rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
                filters + ",org.artifactory.rest.filter.OfflineRestFilter");
        //Register the lICENSERestFilter
        filters = (String) rc.getProperties().get(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS);
        rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
                filters + ",org.artifactory.rest.filter.LicenseRestFilter");
        //Register spring as component provider
        ArtifactoryContext artifactoryContext = (ArtifactoryContext) getServletContext().getAttribute(
                ArtifactoryContext.APPLICATION_CONTEXT_KEY);
        SpringComponentProviderFactory springComponentProviderFactory =
                new SpringComponentProviderFactory(rc, (ConfigurableApplicationContext) artifactoryContext);
        wa.initiate(rc, springComponentProviderFactory);
    } catch (RuntimeException e) {
        log.error("Exception in initialization of the Rest servlet");
        throw e;
    }
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:23,代碼來源:ArtifactoryRestServlet.java

示例4: testClassesFromProvidesMethodsWithModuleInjectsAndNoInjectsConstructorAreRegistered

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Test
public void testClassesFromProvidesMethodsWithModuleInjectsAndNoInjectsConstructorAreRegistered() {
    ResourceConfig config = new DefaultResourceConfig();
    ObjectGraph objectGraph = ObjectGraph.create(SomeInjectableProvidesModule.class,
            new SomeOtherInjectableProvidesModule());
    IoCComponentProviderFactory factory = new DaggerComponentProviderFactory(config, objectGraph,
            new Object[]{SomeInjectableProvidesModule.class, new SomeOtherInjectableProvidesModule()});

    assertTrue(config.getClasses().contains(SomeProvidesInjectableResource.class));
    assertTrue(config.getClasses().contains(SomeOtherProvidesInjectableResource.class));
    assertTrue(config.getClasses().contains(SomeProvidesInjectableProvider.class));

    SomeProvidesInjectableResource someResource = (SomeProvidesInjectableResource) factory.
            getComponentProvider(SomeProvidesInjectableResource.class).getInstance();
    SomeOtherProvidesInjectableResource someOtherResource = (SomeOtherProvidesInjectableResource) factory
            .getComponentProvider(SomeOtherProvidesInjectableResource.class).getInstance();
    SomeProvidesInjectableProvider someProvider = (SomeProvidesInjectableProvider) factory
            .getComponentProvider(SomeProvidesInjectableProvider.class).getInstance();

    assertNotNull(someResource);
    assertNotNull(someOtherResource);
    assertNotNull(someProvider);
}
 
開發者ID:johnlcox,項目名稱:dagger-servlet,代碼行數:24,代碼來源:DaggerComponentProviderFactoryTest.java

示例5: configure

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Override
protected AppDescriptor configure() {
    this.requestConfiguration = RequestConfiguration.builder().withApiKeyQueryParamName("passkey")
            .withSignatureHttpHeader("duck-duck-signature-header")
            .withTimestampHttpHeader("duck-duck-timestamp-header")
            .withVersionHttpHeader("duck-duck-version-header")
            .build();
    final Authenticator<String> authenticator = new Authenticator<String>() {
        @Override
        public String authenticate(Credentials credentials) {
            if (GOOD_API_KEY.equals(credentials.getApiKey())) {
                return GOOD_API_KEY;
            }
            if (INTERNAL_ERROR.equals(credentials.getApiKey())) {
                throw new IllegalStateException("An internal error occurred");
            }
            return null;
        }
    };

    ResourceConfig config = new ScanningResourceConfig();
    config.getSingletons().add(new HmacAuthProvider<String>(new DefaultRequestHandler<String>(authenticator, requestConfiguration)));
    config.getSingletons().add(new AuthResource());
    return new LowLevelAppDescriptor.Builder(config).build();
}
 
開發者ID:bazaarvoice,項目名稱:jersey-hmac-auth,代碼行數:26,代碼來源:HmacAuthProviderTest.java

示例6: register

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
/**
 * Registers any Guice-bound providers or root resources.
 *
 * @param config   the resource configuration
 * @param injector the Guice injector
 */
private void register(ResourceConfig config, Injector injector) {
    while (injector != null) {
        for (Key<?> key : injector.getBindings().keySet()) {
            Type type = key.getTypeLiteral().getType();
            if (type instanceof Class) {
                Class<?> c = (Class) type;
                if (ResourceConfig.isProviderClass(c)) {
                    LOGGER.log(Level.INFO, "Registering {0} as a provider class", c.getName());
                    config.getClasses().add(c);
                } else if (ResourceConfig.isRootResourceClass(c)) {
                    LOGGER.log(Level.INFO, "Registering {0} as a root resource class", c.getName());
                    config.getClasses().add(c);
                }
            }
        }
        injector = injector.getParent();
    }
}
 
開發者ID:rridgley1,項目名稱:agon,代碼行數:25,代碼來源:GuiceComponentProviderFactory.java

示例7: configureServlets

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Override
public void configureServlets() {
  setup();

  serve("/", "/__stop").with(Dispatcher.class);

  for (String path : this.getServePathSpecs()) {
    serve(path).with(Dispatcher.class);
  }

  String regex = "(?!/ws)";
  serveRegex(regex).with(SliderDefaultWrapperServlet.class);

  Map<String, String> params = new HashMap<String, String>();
  params.put(ResourceConfig.FEATURE_IMPLICIT_VIEWABLES, "true");
  params.put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, "true");
  params.put(ResourceConfig.FEATURE_XMLROOTELEMENT_PROCESSING, "true");
  params.put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, GZIPContentEncodingFilter.class.getName());
  params.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, GZIPContentEncodingFilter.class.getName());
  //params.put("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
  //params.put("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
  //params.put("com.sun.jersey.config.feature.Trace", "true");
  params.put("com.sun.jersey.config.property.WadlGeneratorConfig",
      AMWadlGeneratorConfig.CLASSNAME);
  filter("/*").through(GuiceContainer.class, params);
}
 
開發者ID:apache,項目名稱:incubator-slider,代碼行數:27,代碼來源:SliderAMWebApp.java

示例8: RestApplication

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
/**
 * Constructor.
 * @param manager
 */
public RestApplication( Manager manager ) {
	super();

	this.applicationResource = new ApplicationResource( manager );
	this.managementResource = new ManagementResource( manager );
	this.debugResource = new DebugResource( manager );
	this.targetResource = new TargetResource( manager );
	this.preferencesResource = new PreferencesResource( manager );
	this.schedulerResource = new SchedulerResource( manager );
	this.authenticationResource = new AuthenticationResource( manager );
	this.historyResource = new HistoryResource( manager );

	getFeatures().put( "com.sun.jersey.api.json.POJOMappingFeature", Boolean.TRUE );
	getFeatures().put( ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE );
}
 
開發者ID:roboconf,項目名稱:roboconf-platform,代碼行數:20,代碼來源:RestApplication.java

示例9: main

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
  Map<String, String> mapArgs = parseArgs(args);
  System.out.println("Starting Ambari API server using the following properties: " + mapArgs);
  System.setProperty("ambariapi.dbfile", mapArgs.get("db"));

  ResourceConfig config = new PackagesResourceConfig("org.apache.ambari.server.api.services");
  System.out.println("Starting server: http://localhost:" + mapArgs.get("port") + '/');
  HttpServer server = HttpServerFactory.create("http://localhost:" + mapArgs.get("port") + '/', config);
  server.start();

  System.out.println("SERVER RUNNING: http://localhost:" + mapArgs.get("port") + '/');
  System.out.println("Hit return to stop...");
  System.in.read();
  System.out.println("Stopping server");
  server.stop(0);
  System.out.println("Server stopped");
}
 
開發者ID:telefonicaid,項目名稱:fiware-cosmos-ambari,代碼行數:18,代碼來源:StartServer.java

示例10: configureServlets

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Override
protected void configureServlets() {
	
	// filters
	// Objectify filter
	filter("/*").through(ObjectifyFilter.class);

	// servlets
	serve("/home").with(HomeServlet.class);
	
	// Jersey restful servlet
    HashMap<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "uk.co.inetria.appstart.frontend.rest");
       params.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
       // speed up jersey startup under appengine
       params.put(ResourceConfig.FEATURE_DISABLE_WADL, "true");
       
       serve("/api/*").with(GuiceContainer.class, params);
	
	
}
 
開發者ID:omerio,項目名稱:appstart,代碼行數:22,代碼來源:AppServletModule.java

示例11: configure

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Override
protected void configure() {
	bind(RefAppResource.class);

	// Install servlet module setting a the Jersey/Guice integration.
	install(new ServletModule() {
		@Override
		protected void configureServlets() {
			filter("/*").through(GuiceContainer.class,
					ImmutableMap.of(JSONConfiguration.FEATURE_POJO_MAPPING, "true",
							ResourceConfig.FEATURE_TRACE, "true",
							ResourceConfig.FEATURE_TRACE_PER_REQUEST, "true",
							ServletContainer.FEATURE_FILTER_FORWARD_ON_404, "true"));
		}
	});
}
 
開發者ID:mgm-tp,項目名稱:perfload-refapp,代碼行數:17,代碼來源:RefAppModule.java

示例12: testInvokeResourceWithCategory

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Test
public void testInvokeResourceWithCategory() throws Exception {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(NewRelicResourceFilterFactory.TRANSACTION_CATEGORY_PROP, "someCategory");
    initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
        NewRelicResourceFilterFactory.class.getCanonicalName());

    server = getServer(getInjector(initParams).getInstance(GuiceFilter.class));
    server.start();

    Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo").execute().get();

    assertEquals(200, response.getStatusCode());

    assertEquals(newArrayList("someCategory:/foo GET"), wrapper.getNames());
    assertTrue(wrapper.getThrowables().isEmpty());
}
 
開發者ID:palominolabs,項目名稱:jersey-new-relic,代碼行數:18,代碼來源:FullStackTest.java

示例13: testInvokeResourceWithoutCategory

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Test
public void testInvokeResourceWithoutCategory() throws Exception {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
        NewRelicResourceFilterFactory.class.getCanonicalName());

    server = getServer(getInjector(initParams).getInstance(GuiceFilter.class));
    server.start();

    Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo").execute().get();

    assertEquals(200, response.getStatusCode());

    assertEquals(newArrayList("/foo GET"), wrapper.getNames());
    assertTrue(wrapper.getThrowables().isEmpty());
}
 
開發者ID:palominolabs,項目名稱:jersey-new-relic,代碼行數:17,代碼來源:FullStackTest.java

示例14: testInvokeThrowsResource

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Test
public void testInvokeThrowsResource() throws Exception {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
        NewRelicResourceFilterFactory.class.getCanonicalName());

    server = getServer(getInjector(initParams).getInstance(GuiceFilter.class));
    server.start();

    Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo/throw").execute().get();

    assertEquals(500, response.getStatusCode());

    assertEquals(newArrayList("/foo/throw GET"), wrapper.getNames());
    assertEquals(1, wrapper.getThrowables().size());
    assertEquals("zomg", wrapper.getThrowables().get(0).getMessage());
}
 
開發者ID:palominolabs,項目名稱:jersey-new-relic,代碼行數:18,代碼來源:FullStackTest.java

示例15: testInvokeThrowsMappedResource

import com.sun.jersey.api.core.ResourceConfig; //導入依賴的package包/類
@Test
public void testInvokeThrowsMappedResource() throws Exception {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
        NewRelicResourceFilterFactory.class.getCanonicalName());

    server = getServer(getInjector(initParams).getInstance(GuiceFilter.class));
    server.start();

    Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo/throwMapped").execute().get();

    assertEquals(javax.ws.rs.core.Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode());

    assertEquals(newArrayList("/foo/throwMapped GET"), wrapper.getNames());
    assertEquals(1, wrapper.getThrowables().size());
    assertEquals("asdf", wrapper.getThrowables().get(0).getMessage());
}
 
開發者ID:palominolabs,項目名稱:jersey-new-relic,代碼行數:18,代碼來源:FullStackTest.java


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