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


Java ResteasyDeployment类代码示例

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


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

示例1: doStart

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:22,代码来源:DubboHttpServer.java

示例2: testEngineWithInjectedClientPost2

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
@Test
public void testEngineWithInjectedClientPost2() {

    final ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.start();
    final ResteasyProviderFactory providerFactory = deployment.getProviderFactory();
    final HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
    final Client client = new ResteasyClientBuilder()
        .providerFactory(providerFactory)
        .httpEngine(new VertxClientEngine(httpClient))
        .register(GsonMessageBodyHandler.class)
        .build();
    final Form xform = new Form();
    xform.param("userName", "ca1\\\\meowmix");
    xform.param("password", "mingnamulan");
    xform.param("state", "authenticate");
    xform.param("style", "xml");
    xform.param("xsl", "none");

    final Response response = client.target("https://httpbin.org/post").request(MediaType.APPLICATION_JSON)
        .post(Entity.form(xform), Response.class);
    assertFalse(response.getStringHeaders().isEmpty());
    System.out.println(response.getStringHeaders());
    assertFalse(response.getHeaders().isEmpty());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType());
    assertTrue(response.hasEntity());
    final JsonObject arsString = response.readEntity(JsonObject.class);
    assertEquals("xml", arsString.getAsJsonObject("form").get("style").getAsString());
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:30,代码来源:SpringJaxrsHandlerTest.java

示例3: start

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public void start() {

		ResteasyDeployment dp = new ResteasyDeployment();

		Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
		Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();

		Assert.notEmpty(controllers);

		// extract providers
		if (providers != null) {
			dp.getProviders().addAll(providers);
		}
		// extract only controller annotated beans
		dp.getResources().addAll(controllers);
		
        netty = new NettyJaxrsServer();
		netty.setDeployment(dp);
        netty.setIoWorkerCount(ioWorkerCount);
        netty.setExecutorThreadCount(executorThreadCount);
		netty.setPort(port);
        netty.setRootResourcePath(rootResourcePath);
		netty.setSecurityDomain(null);
		netty.start();
        LOGGER.info("rest-netty-server started , port {}", port);
	}
 
开发者ID:netboynb,项目名称:coco,代码行数:27,代码来源:CocoRestServer.java

示例4: doStart

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
protected void doStart(URL url) {
	// TODO jetty will by default enable keepAlive so the xml config has no
	// effect now
	httpServer = httpBinder.bind(url, new RestHandler());

	ServletContext servletContext = BaseContext.CTX.getServletContext(url.getPort());

	if (servletContext == null) {
		throw new JahhanException("No servlet context found. If you are using server='servlet', "
				+ "make sure that you've configured  in web.xml");
	}

	servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

	try {
		dispatcher.init(new SimpleServletConfig(servletContext));
	} catch (ServletException e) {
		throw new JahhanException(e);
	}
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:21,代码来源:DubboHttpServer.java

示例5: doInit

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
private void doInit(final ServletConfig servletConfig) throws ServletException {
  deployment.start();

  servletConfig.getServletContext().setAttribute(ResteasyDeployment.class.getName(), deployment);

  super.init(servletConfig);

  if (log.isDebugEnabled()) {
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
    log.debug("Provider factory: {}", providerFactory);
    log.debug("Configuration: {}", providerFactory.getConfiguration());
    log.debug("Runtime type: {}", providerFactory.getRuntimeType());
    log.debug("Built-ins registered: {}", providerFactory.isBuiltinsRegistered());
    log.debug("Properties: {}", providerFactory.getProperties());
    log.debug("Dynamic features: {}", providerFactory.getServerDynamicFeatures());
    log.debug("Enabled features: {}", providerFactory.getEnabledFeatures());
    log.debug("Class contracts: {}", providerFactory.getClassContracts());
    log.debug("Reader interceptor registry: {}", providerFactory.getServerReaderInterceptorRegistry());
    log.debug("Writer interceptor registry: {}", providerFactory.getServerWriterInterceptorRegistry());
    log.debug("Injector factory: {}", providerFactory.getInjectorFactory());
    log.debug("Instances: {}", providerFactory.getInstances());
    log.debug("Exception mappers: {}", providerFactory.getExceptionMappers());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:ComponentContainerImpl.java

示例6: main

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String host = "0.0.0.0";
    int port = 8080;
    if (args.length > 0) {
        host = args[0];
    }
    if (args.length > 1) {
        port = Integer.parseInt(args[1]);
    }


    NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(new MyApplication());
    netty.setDeployment(deployment);
    netty.setHostname(host);
    netty.setPort(port);
    netty.setRootResourcePath("/");
    netty.setSecurityDomain(null);
    netty.start();
}
 
开发者ID:smallnest,项目名称:Jax-RS-Performance-Comparison,代码行数:22,代码来源:Main.java

示例7: undertowDeployment

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
static DeploymentInfo undertowDeployment(ResteasyDeployment deployment, String mapping) {
    if (mapping == null) {
        mapping = "/";
    }

    if (!mapping.startsWith("/")) {
        mapping = '/' + mapping;
    }

    if (!mapping.endsWith("/")) {
        mapping = mapping + '/';
    }

    mapping = mapping + '*';
    String prefix = null;
    if (!mapping.equals("/*")) {
        prefix = mapping.substring(0, mapping.length() - 2);
    }

    ServletInfo resteasyServlet = Servlets.servlet("ResteasyServlet", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping(mapping);
    if (prefix != null) {
        resteasyServlet.addInitParam("resteasy.servlet.mapping.prefix", prefix);
    }

    return (new DeploymentInfo()).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet);
}
 
开发者ID:automenta,项目名称:spimedb,代码行数:27,代码来源:WebServer.java

示例8: testInit

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
@Test
public void testInit() throws InterruptedException {
    /**
     * Some TODOs:
     *
     * 1. Add an extension that observes ProcessAnnotatedType, keeps in a class, and then add a getter to get the list of these that are annotated @Path
     * 2. Override CDIRequestDispatcher to start a request context, and then stop when done.
     *
     */
    BasicConfigurator.configure();
    Weld weld = new Weld();
    weld.initialize();
    LoadPathsExtension paths = CDI.current().select(LoadPathsExtension.class).get();
    CDINettyJaxrsServer netty = new CDINettyJaxrsServer();
    ResteasyDeployment rd = new ResteasyDeployment();
    rd.setActualResourceClasses(paths.getResources());
    rd.setInjectorFactoryClass(CdiInjectorFactory.class.getName());
    netty.setDeployment(rd);
    netty.setPort(8087);
    netty.setRootResourcePath("");
    netty.setSecurityDomain(null);
    netty.start();
    Client c = ClientBuilder.newClient();
    String result = c.target("http://localhost:8087").path("/").request("text/plain").accept("text/plain").get(String.class);
    Assert.assertEquals("pong", result);
}
 
开发者ID:johnament,项目名称:resteasy-netty-cdi,代码行数:27,代码来源:NettyTest.java

示例9: createServer

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
private static NettyJaxrsServer createServer(ResteasyDeployment deployment) throws Exception {
    NettyJaxrsServer netty = new NettyJaxrsServer();
    netty.setDeployment(deployment);
    netty.setPort(8080);
    netty.setRootResourcePath("");
    netty.setSecurityDomain(null);
    return netty;
}
 
开发者ID:Archistar,项目名称:archistar-core,代码行数:9,代码来源:ArchistarS3.java

示例10: VertxPluginRequestHandler

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public VertxPluginRequestHandler(Vertx vertx, ResteasyDeployment deployment, String servletMappingPrefix, SecurityDomain domain, List<Plugin> plugins)
{
   this.vertx = vertx;
   this.dispatcher = new PluginRequestDispatcher((SynchronousDispatcher) deployment.getDispatcher(), deployment.getProviderFactory(), domain, plugins);
   this.servletMappingPrefix = servletMappingPrefix;
   appGlobals = AppGlobals.get();
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:8,代码来源:VertxPluginRequestHandler.java

示例11: main

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public static void main(String[]args){
 
 //Get Port
 String host="0.0.0.0";
 int port = Integer.parseInt(System.getProperty("port"));
 //Create the JAXRS Server
  UndertowJaxrsServer server = new UndertowJaxrsServer();
     Undertow.Builder serverBuilder = Undertow.builder().addHttpListener(port, host);
     server.start(serverBuilder);
     
     //Create the deployment
     ResteasyDeployment deployment = new ResteasyDeployment();
     deployment.setApplicationClass(MoneyTransfertApp.class.getName());
     deployment.setInjectorFactoryClass(org.jboss.resteasy.cdi.CdiInjectorFactory.class.getName());
     
     
     //Configure the deployment info
     DeploymentInfo di = server.undertowDeployment(deployment, "/api");
      di.setClassLoader(MoneyTransferServer.class.getClassLoader())
     .setContextPath("/beosbank-undertow-service")
     .setDeploymentName("BeosBank Services");
      
      //Add CDI listener
      di.addListeners(Servlets.listener(org.jboss.weld.environment.servlet.Listener.class));
      
      //Deploy the API 
      server.deploy(di);
 	  System.out.println("Undertow MoneyTransfert started on "+host+":"+port);

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:31,代码来源:MoneyTransferServer.java

示例12: init

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
@BeforeClass
public static void init() {
	server = new UndertowJaxrsServer();
	server.start();

	// deploy
	ResteasyDeployment deployment = new ResteasyDeployment();
	deployment.setApplication(new Config());
	server.deploy(deployment, "/",
			Collections.singletonMap("resteasy.resources", "com.holonplatform.json.gson.jaxrs.GsonFeature"),
			Collections.emptyMap());
}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:13,代码来源:TestResteasyIntegrationContext.java

示例13: main

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public static void main(String[] args) {
  final Builder builder = Undertow
      .builder()
      .setDirectBuffers(true)
      .setServerOption(UndertowOptions.ENABLE_HTTP2 , true);

  final Application jaxRsActivator = new Application() {
    @Override
    public Set<Class<?>> getClasses() {
      final Set<Class<?>> classes = new HashSet<>();
      classes.add(ServiceREST.class);
      classes.add(LoginREST.class);
      return classes;
    }
  };

  final String realRestPort = System.getProperty(REST_PORT_PROPERTY , DEFAULT_REST_PORT + "");
  final String realRestHost = System.getProperty(REST_HOST_PROPERTY , MainRest.DEFAULT_HOST);

  System.setProperty(RESTEASY_PORT_PROPERTY , realRestPort);
  System.setProperty(RESTEASY_HOST_PROPERTY , realRestHost);

  builder.addHttpListener(Integer.parseInt(realRestPort) , realRestHost);
  jaxrsServer = new UndertowJaxrsServer().start(builder);
  final ResteasyDeployment deployment = new ResteasyDeployment();
  deployment.setApplication(jaxRsActivator);
  jaxrsServer.deploy(jaxrsServer.undertowDeployment(deployment)
                                .setDeploymentName("Rest")
                                .setContextPath(CONTEXT_PATH_REST)
                                .setClassLoader(MainRest.class.getClassLoader()));
}
 
开发者ID:Java-Publications,项目名称:javamagazin-009-microkernel,代码行数:32,代码来源:MainRest.java

示例14: test_host_for_LISTEN_ADDRESS

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
/**
 * // lsof -i:8990
 * // COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
 * 
 * @throws InterruptedException
 */
@Test
public void test_host_for_LISTEN_ADDRESS() throws InterruptedException {

    // String hostname = "10.100.0.25";
    // String hostname = "127.0.0.1";//java 29782 username 146u IPv6 0x41980098a5e8db51 0t0 TCP localhost:8990 (LISTEN)
    // String hostname = "localhost";

    String hostname = "0.0.0.0";// java 29827 username 146u IPv6 0x41980098a5e8db51 0t0 TCP *:8990 (LISTEN)
    int port = 8990;
    SecurityDomain securityDomain = null;
    String rootResourcePath = "/";
    int ioWorkerCount = Runtime.getRuntime().availableProcessors() * 2;
    int executorThreadCount = 12;

    NettyJaxrsServer nettyJaxrsServer = new NettyJaxrsServer();

    nettyJaxrsServer.setHostname(hostname);
    nettyJaxrsServer.setPort(port);
    nettyJaxrsServer.setSecurityDomain(securityDomain);
    nettyJaxrsServer.setRootResourcePath(rootResourcePath);

    nettyJaxrsServer.setIoWorkerCount(ioWorkerCount);
    nettyJaxrsServer.setExecutorThreadCount(executorThreadCount);

    ResteasyDeployment deployment = nettyJaxrsServer.getDeployment();
    List<Object> resources = new ArrayList<Object>();
    deployment.setResources(resources);
    nettyJaxrsServer.start();
    ResourceMethodRegistry resourceMethodRegistry = (ResourceMethodRegistry) deployment.getRegistry();
    resourceMethodRegistry.setWiderMatching(true);// 不设置也可以

    deployment.getRegistry().addSingletonResource(new RestServiceImpl());
    // TimeUnit.MINUTES.sleep(1);

}
 
开发者ID:sdcuike,项目名称:dubbo-rpc-rest,代码行数:42,代码来源:RestProtocolTest.java

示例15: start

import org.jboss.resteasy.spi.ResteasyDeployment; //导入依赖的package包/类
public void start() {
	ResteasyDeployment dp = new ResteasyDeployment();
	Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
	Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();
	Assert.notEmpty(controllers);
	// extract providers
	if (providers != null) {
		dp.getProviders().addAll(providers);
	}
	// extract only controller annotated beans
	dp.getResources().addAll(controllers);
	Map<String, Object> channelOptions = new HashMap<String, Object>();
	channelOptions.put("reuseAddress", true);
	List<ChannelHandler> channelHandlerList = new ArrayList<ChannelHandler>();
	channelHandlerList.add(channelHandler);
	channelHandlerList.add(idleStateHandler);
	channelHandlerList.add(healthCheckHandler);
	netty = new NettyJaxrsServer();
	netty.setChannelOptions(channelOptions);
	netty.setDeployment(dp);
	netty.setPort(port);
	netty.setRootResourcePath("/resteasy");
	netty.setIoWorkerCount(ioWorkerCount);
	netty.setExecutorThreadCount(executorThreadCount);
	netty.setMaxRequestSize(maxRequestSize);
	netty.setSSLContext(sslContext);
	netty.setKeepAlive(true);
	netty.setChannelHandlers(channelHandlerList);
	netty.setSecurityDomain(null);
	netty.start();
}
 
开发者ID:tangaiyun,项目名称:Netty-Resteasy-Spring,代码行数:32,代码来源:NettyServer.java


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