@Test public void testMultiplePublishSameAddress() throws Exception { server.start(); String contextPath = "/ctxt"; String path = "/echo"; for (int i = 0; i < 3; i++) { HttpContext ctx = UndertowContextFactory.createHttpContext(server, contextPath, path); String address = "http://localhost:" + currentPort + contextPath + path; Endpoint endpoint = Endpoint.create(new EndpointBean()); endpoint.publish(ctx); // Use httpserver context for publishing invokeEndpoint(address); endpoint.stop(); } }
@Test public void testMultipleEndpointsSameContext() throws Exception { server.start(); String contextPath = "/ctxt"; String path = "/echo"; int k = 3; Endpoint[] endpoints = new Endpoint[k]; HttpContext[] contexts = new HttpContext[k]; String[] addresses = new String[k]; for (int i = 0; i < k; i++) { addresses[i] = "http://localhost:" + currentPort + contextPath + path + i; contexts[i] = UndertowContextFactory.createHttpContext(server, contextPath, path + i); endpoints[i] = Endpoint.create(new EndpointBean()); endpoints[i].publish(contexts[i]); } for (int i = 0; i < k; i++) { invokeEndpoint(addresses[i]); } for (int i = 0; i < k; i++) { endpoints[i].stop(); } }
@Test public void testMultipleEndpointsDifferentContexts() throws Exception { server.start(); String contextPath = "/ctxt"; String path = "/echo"; int k = 3; Endpoint[] endpoints = new Endpoint[k]; HttpContext[] contexts = new HttpContext[k]; String[] addresses = new String[k]; for (int i = 0; i < k; i++) { addresses[i] = "http://localhost:" + currentPort + contextPath + i + path; contexts[i] = UndertowContextFactory.createHttpContext(server, contextPath + i, path); endpoints[i] = Endpoint.create(new EndpointBean()); endpoints[i].publish(contexts[i]); } for (int i = 0; i < k; i++) { invokeEndpoint(addresses[i]); } for (int i = 0; i < k; i++) { endpoints[i].stop(); } }
public void publish(Object serverContext) { canPublish(); if (!com.sun.net.httpserver.HttpContext.class.isAssignableFrom(serverContext.getClass())) { throw new IllegalArgumentException(serverContext.getClass() + " is not a supported context."); } createEndpoint(((com.sun.net.httpserver.HttpContext)serverContext).getPath()); ((HttpEndpoint) actualEndpoint).publish(serverContext); }
@Override public void publish(Object serverContext) { canPublish(); if (!com.sun.net.httpserver.HttpContext.class.isAssignableFrom(serverContext.getClass())) { throw new IllegalArgumentException(serverContext.getClass() + " is not a supported context."); } createEndpoint(((com.sun.net.httpserver.HttpContext)serverContext).getPath()); ((HttpEndpoint) actualEndpoint).publish(serverContext); }
@Override public HttpContext getHttpContext() { if (context == null) { context = new UndertowHttpContext(new PathHandler(), PathUtils.getContextPathFromRequest(undertowExchange.getRequestPath()), PathUtils.getPathFromRequest(undertowExchange.getRequestPath())); } return context; }
public void publish(HttpContext serverContext) { canPublish(); createEndpoint(serverContext.getPath()); ((HttpEndpoint) actualEndpoint).publish(serverContext); }
@Override public void publish(HttpContext serverContext) { canPublish(); createEndpoint(serverContext.getPath()); ((HttpEndpoint) actualEndpoint).publish(serverContext); }
public static HttpContext createHttpContext(UndertowServer server, String contextPath, String path) { return new UndertowHttpContext(server.getPathHandler(), contextPath, path); }
@Test public void testSingleEndpoint() throws Exception { String contextPath = "/ctxt"; String path = "/echo"; String address = "http://localhost:" + currentPort + contextPath + path; HttpContext context = UndertowContextFactory.createHttpContext(server, contextPath, path); Endpoint endpoint = Endpoint.create(new EndpointBean()); endpoint.publish(context); // Use httpserver context for publishing server.start(); invokeEndpoint(address); endpoint.stop(); }
/** * Publishes this endpoint at the provided server context. * A server context encapsulates the server infrastructure * and addressing information for a particular transport. * For a call to this method to succeed, the server context * passed as an argument to it MUST be compatible with the * endpoint's binding. * * <p> * This is meant for container developers to publish the * the endpoints portably and not intended for the end * developers. * * * @param serverContext An object representing a server * context to be used for publishing the endpoint. * * @throws java.lang.IllegalArgumentException * If the provided server context is not * supported by the implementation or turns * out to be unusable in conjunction with the * endpoint's binding. * * @throws java.lang.IllegalStateException * If the endpoint has been published already or it has been stopped. * * @throws java.lang.SecurityException * If a <code>java.lang.SecurityManger</code> * is being used and the application doesn't have the * <code>WebServicePermission("publishEndpoint")</code> permission. * @since JAX-WS 2.2 */ public void publish(HttpContext serverContext) { throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour."); }
/** * Publishes this endpoint at the provided server context. * A server context encapsulates the server infrastructure * and addressing information for a particular transport. * For a call to this method to succeed, the server context * passed as an argument to it MUST be compatible with the * endpoint's binding. * * <p> * This is meant for container developers to publish the * the endpoints portably and not intended for the end * developers. * * * @param serverContext An object representing a server * context to be used for publishing the endpoint. * * @throws java.lang.IllegalArgumentException * If the provided server context is not * supported by the implementation or turns * out to be unusable in conjunction with the * endpoint's binding. * * @throws java.lang.IllegalStateException * If the endpoint has been published already or it has been stopped. * * @throws java.lang.SecurityException * If a {@code java.lang.SecurityManger} * is being used and the application doesn't have the * {@code WebServicePermission("publishEndpoint")} permission. * @since 1.7, JAX-WS 2.2 */ public void publish(HttpContext serverContext) { throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour."); }