当前位置: 首页>>代码示例>>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;未经允许,请勿转载。