当前位置: 首页>>代码示例>>Java>>正文


Java PackagesResourceConfig类代码示例

本文整理汇总了Java中com.sun.jersey.api.core.PackagesResourceConfig的典型用法代码示例。如果您正苦于以下问题:Java PackagesResourceConfig类的具体用法?Java PackagesResourceConfig怎么用?Java PackagesResourceConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PackagesResourceConfig类属于com.sun.jersey.api.core包,在下文中一共展示了PackagesResourceConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WebServer

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
public WebServer(URI endpoint) throws IOException {
  this.server = GrizzlyServerFactory.createHttpServer(endpoint, new HttpHandler() {

    @Override
    public void service(Request rqst, Response rspns) throws Exception {
      rspns.setStatus(HttpStatus.NOT_FOUND_404.getStatusCode(), "Not found");
      rspns.getWriter().write("404: not found");
    }
  });

  WebappContext context = new WebappContext("WebappContext", BASE_PATH);
  ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
  registration.setInitParameter(ServletContainer.RESOURCE_CONFIG_CLASS,
      PackagesResourceConfig.class.getName());

  StringJoiner sj = new StringJoiner(",");
  for (String s : PACKAGES) {
    sj.add(s);
  }

  registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, sj.toString());
  registration.addMapping(BASE_PATH);
  context.deploy(server);
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:25,代码来源:WebServer.java

示例2: createComputeRealtimeServer

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
/**
 * Creates a new {@link ComputeRealtimeServer}
 *
 * @param config
 *            The chatalytics config
 * @return A newly created {@link ComputeRealtimeServer}
 */
public ComputeRealtimeServer createComputeRealtimeServer() {
    Server server = new Server(config.computeConfig.rtComputePort);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
    jerseyServlet.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES,
                                   StatusResource.class.getPackage().toString());
    server.setHandler(context);
    ServerContainer wscontainer;
    try {
        wscontainer = WebSocketServerContainerInitializer.configureContext(context);
        wscontainer.addEndpoint(RealtimeResource.class);
    } catch (ServletException | DeploymentException e) {
        throw new RuntimeException("Can't instantiate websocket. Reason: " + e.getMessage());
    }

    return new ComputeRealtimeServer(server);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:27,代码来源:ComputeRealtimeServerFactory.java

示例3: configureServlets

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Override
protected void configureServlets() {
	super.configureServlets();
	
	//get the bootstrapping Properties file
	install(new BootstrapPropertiesModule());
	
	//Initialize Persistence JPA Unit of Work if present
	//install(new MyUnitOfWorkModule());
	//Initialize Apache Shiro if present
	//install(new YourShiroModule(getServletContext()));
	
	Map<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, propertyPackages);
       //if you had a Persistence Service like JPA Unit of Work you would need to add this PersistFilter also.
       //filter("/*").through(PersistFilter.class);
       //if you had a ShiroWebModule installed above you would need to add this GuiceShiroFilter also.
       //filter("/*").through(GuiceShiroFilter.class);
       serve("/rest/*").with(GuiceContainer.class, params);
       
}
 
开发者ID:pabiagioli,项目名称:jersey-guice-bootstrap,代码行数:22,代码来源:BootstrapServletModule.java

示例4: configureServlets

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Override
protected void configureServlets() {
	super.configureServlets();
	
	//get the bootstrapping Properties file
	install(new BootstrapPropertiesModule());
	
	//Initialize Persistence JPA Unit of Work if present
	//install(new MyUnitOfWorkModule());
	//Initialize Apache Shiro if present
	install(new BootstrapShiroModule(getServletContext()));
	//This allows Shiro AOP Annotations http://shiro.apache.org/java-authorization-guide.html
	install(new ShiroAnnotationsModule());
	
	Map<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, propertyPackages);
       //if you had a Persistence Service like JPA Unit of Work you would need to add this PersistFilter also.
       //filter("/*").through(PersistFilter.class);
       //if you had a ShiroWebModule installed above you would need to add this GuiceShiroFilter also.
       filter("/*").through(GuiceShiroFilter.class);
       serve("/rest/*").with(GuiceContainer.class, params);
       
}
 
开发者ID:pabiagioli,项目名称:secure-rest-webapp-archetype,代码行数:24,代码来源:BootstrapServletModule.java

示例5: main

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的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

示例6: configureServlets

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的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

示例7: init

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@BeforeClass 
public static void init() throws Exception {
    PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.ribbon.test.resources");
    port = (new Random()).nextInt(1000) + 4000;
    SERVICE_URI = "http://localhost:" + port + "/";
    ExecutorService service = Executors.newFixedThreadPool(20);
    try{
        server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
        server.setExecutor(service);
        server.start();
    } catch(Exception e) {
        e.printStackTrace();
        fail("Unable to start server");
    }
    // LogManager.getRootLogger().setLevel(Level.DEBUG);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:NettyClientTest.java

示例8: runApp

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@edu.umd.cs.findbugs.annotations.SuppressWarnings
public final void runApp() throws Exception {
    PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.ribbon.examples.server");
    ExecutorService service = Executors.newFixedThreadPool(50);
    try{
        server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
        server.setExecutor(service);
        server.start();
        run();
    } finally {
        System.err.println("Shut down server ...");
        if (server != null) {
            server.stop(1);
        }
        service.shutdownNow();
    }
    System.exit(0);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:ExampleAppWithLocalResource.java

示例9: testHttpServerStartStop

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Test
public void testHttpServerStartStop() {
    // setup
    this.resourceConfig = new PackagesResourceConfig("com.bt.pi.sss.test");

    // act
    this.httpServer = new HttpServer(resourceConfig);
    this.httpServer.setPort("9090");
    this.httpServer.setApplicationContext(new StaticApplicationContext());
    try {
        this.httpServer.init();
        assertTrue(Boolean.getBoolean("com.sun.grizzly.util.buf.UDecoder.ALLOW_ENCODED_SLASH"));
    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        this.httpServer.destroy();
    }

    // assert
}
 
开发者ID:barnyard,项目名称:pi,代码行数:21,代码来源:HttpServerTest.java

示例10: start

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
public static void start() {
    WebappContext webappContext = new WebappContext("TestContext");
    ServletRegistration registration = webappContext.addServlet("ServletContainer", ServletContainer.class);
    registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, "org.moskito.central.connectors.rest;org.codehaus.jackson.jaxrs");
    registration.addMapping("/*");

    SSLContextConfigurator sslConfigurator = new SSLContextConfigurator();
    sslConfigurator.setKeyStoreFile("./target/test-classes/central_server_keystore.jks");
    sslConfigurator.setKeyStorePass("moskito");
    SSLContext sslContext = sslConfigurator.createSSLContext();

    try {
        server = GrizzlyServerFactory.createHttpServer(
                getBaseURI(),
                null,
                true,
                new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false)
        );

        webappContext.deploy(server);
        server.start();
    } catch (Exception e) {
        System.out.println("Error while starting the test server: " + e);
    }
}
 
开发者ID:anotheria,项目名称:moskito-central,代码行数:26,代码来源:RESTConnectorHttpsTest.java

示例11: configureServlets

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Override
protected void configureServlets() {
    ResourceConfig rc = new PackagesResourceConfig(
            "dk.dma.ais.abnormal.event.rest",
            "dk.dma.ais.abnormal.stat.rest",
            "dk.dma.commons.web.rest.defaults",
            "org.codehaus.jackson.jaxrs"
    );

    for ( Class<?> resource : rc.getClasses() ) {
        String packageName = resource.getPackage().getName();
        if (packageName.equals("dk.dma.commons.web.rest.defaults") || packageName.equals("org.codehaus.jackson.jaxrs")) {
            bind(resource).in(Scopes.SINGLETON);
        } else {
            bind(resource);
        }
    }

    serve("/rest/*").with( GuiceContainer.class );
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:RestModule.java

示例12: startHttpServer

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
private void startHttpServer() throws Exception {
    server = new Server();
    SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
    selectChannelConnector.setPort(11060);
    server.setConnectors(new Connector[]{selectChannelConnector});

    PackagesResourceConfig packagesResourceConfig = new PackagesResourceConfig("com/ngdata/hbaseindexer/rest");

    ServletHolder servletHolder = new ServletHolder(new ServletContainer(packagesResourceConfig));
    servletHolder.setName("HBase-Indexer");


    Context context = new Context(server, "/", Context.NO_SESSIONS);
    context.addServlet(servletHolder, "/*");
    context.setContextPath("/");
    context.setAttribute("indexerModel", indexerModel);
    context.setAttribute("indexerSupervisor", indexerSupervisor);

    server.setHandler(context);
    server.start();
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:22,代码来源:Main.java

示例13: configureServlets

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Override
    protected void configureServlets() {
        bind(MetricsServlet.class).asEagerSingleton();

        Map<String, String> parameters = new HashMap<>();
        parameters.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
//        parameters.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
//        parameters.put("com.sun.jersey.config.property.packages", packageName);
        parameters.put("jersey.config.beanValidation.enableOutputValidationErrorEntity.server", "true");
        parameters.put("com.sun.jersey.api.json.POJOMappingFeature", "true");

        ResourceConfig rc = new PackagesResourceConfig(packageName);
        for (Class<?> resource : rc.getClasses()) {
            bind(resource).asEagerSingleton();
        }

        serve("/metrics").with(MetricsServlet.class);
        serve("/rest/*").with(GuiceContainer.class, parameters);
    }
 
开发者ID:enigma11,项目名称:jetty-guice,代码行数:20,代码来源:MainModule.java

示例14: getInjector

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
@Override
protected Injector getInjector() {
    final ResourceConfig rc = new PackagesResourceConfig( PredictableResponseService.class.getPackage().getName() );

    return Guice.createInjector( new ServletModule() {
        @Override
        protected void configureServlets() {
            bind( ResponsesProvider.class ).to( PreFabricatedResponses.class );
            bind( ResourceLoader.class ).to( FileResourceLoader.class );

            for ( Class<?> resource : rc.getClasses() ) {
                System.out.println( "Binding resource: " + resource.getName() );
                bind( resource );
            }

            serve( "/loadtest/*" ).with( GuiceContainer.class );
        }
    } );
}
 
开发者ID:SmartBear,项目名称:load-test-target,代码行数:20,代码来源:AppServletContextListener.java

示例15: getInjector

import com.sun.jersey.api.core.PackagesResourceConfig; //导入依赖的package包/类
/**
 * Creates guice injector with servlet's jersey resource class and mocked acl store
 * @return
 */
@Override
protected Injector getInjector() {
    return Guice.createInjector(new JerseyServletModule() {
        @Override
        protected void configureServlets() {
            bind(GuiceContainer.class);
            // bind Jersey resources
            PackagesResourceConfig resourceConfig = new PackagesResourceConfig("io.joynr.accesscontrol.global");
            for (Class<?> resource : resourceConfig.getClasses()) {
                bind(resource);
            }

            bindConstant().annotatedWith(Names.named("joynr.messaging.domainaccesscontrollerchannelid"))
                          .to("gdac_channelid");
            bindConstant().annotatedWith(Names.named("joynr.messaging.discoverydirectoriesdomain")).to("io.joynr");

            bind(DomainAccessControlStore.class).toInstance(mockedStore);
            bind(GlobalDomainAccessStoreAdmin.class).toInstance(mockedStore);
            serve("/*").with(GuiceContainer.class);
            serve("/accesscontrol/*").with(AccessControlEditorServlet.class);

        }
    });
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:29,代码来源:TestContextListener.java


注:本文中的com.sun.jersey.api.core.PackagesResourceConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。