private void rawRegisterServlets() throws ServletException, NamespaceException, InterruptedException { logger.info("JERSEY BUNDLE: REGISTERING SERVLETS"); logger.info("JERSEY BUNDLE: HTTP SERVICE = " + httpService.toString()); // TODO - temporary workaround // This is a workaround related to issue JERSEY-2093; grizzly (1.9.5) needs to have the correct context // classloader set ClassLoader myClassLoader = getClass().getClassLoader(); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(myClassLoader); httpService.registerServlet("/jersey-http-service", new ServletContainer(), getJerseyServletParams(), null); } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } // END of workaround - after grizzly updated to the recent version, only the inner call from try block will remain: // httpService.registerServlet("/jersey-http-service", new ServletContainer(), getJerseyServletParams(), null); sendAdminEvent(); logger.info("JERSEY BUNDLE: SERVLETS REGISTERED"); }
/** {@inheritDoc} */ public Object addingService(ServiceReference reference) { HttpService service = (HttpService) context.getService(reference); try { service.registerServlet(getServletAlias(), new JolokiaServlet(context,restrictor), getConfiguration(), getHttpContext()); } catch (ServletException e) { LogHelper.logError(bundleContext, "Servlet Exception: " + e, e); } catch (NamespaceException e) { LogHelper.logError(bundleContext, "Namespace Exception: " + e, e); } return service; }
try { LOG.log(Level.INFO, "Registering new instance of \"" + alias + "\" servlet"); httpService.registerServlet(alias, servlet, sprops, context); } catch (Exception e) { LOG.log(Level.WARNING, "Error registering CXF OSGi servlet " + e.getMessage(), e);
/** * Registers a RESTEasy servlet. * @param alias alias * @param servlet RESTEasy servlet * @param initparams servlet init params * @param context HttpContext * @throws Exception if it fails to register a servlet */ public void registerRESTEasyServlet(String alias, OsgiRESTEasyServletWrapper servlet, Dictionary<?,?> initparams, HttpContext context) throws Exception { _httpService.registerServlet(alias, servlet, initparams, context); _servlets.put(alias, servlet); }
protected void activate(String alias, HttpContext httpContext) { try { logger.debug("Starting up {} at {}", getClass().getSimpleName(), alias); Hashtable<String, String> props = new Hashtable<String, String>(); httpService.registerServlet(alias, this, props, httpContext); } catch (NamespaceException e) { logger.error("Error during servlet registration - alias {} already in use", alias, e); } catch (ServletException e) { logger.error("Error during servlet registration", e); } }
@Override public Object addingService(ServiceReference ref) { HttpService httpService = (HttpService) bundleContext.getService(ref); try { httpService.registerServlet("/servlet-example", new ExampleServlet(), null, null); } catch (Exception e) { throw new RuntimeException(e); } return httpService; }
private void registerServlet(Map<String, ?> config) throws ServletException, NamespaceException { servletPath = getServletPath(config); if(servletPath == null) { log.info("Servlet path is null, not registering with HttpService"); } else { httpService.registerServlet(servletPath, this, null, null); log.info("Servlet registered at {}", servletPath); } }
private void registerServlet(String url) { try { httpService.registerServlet(url, getRemoteServlet(), null, null); } catch (Exception e) { throw new RuntimeException(e); } }
@Activate protected void activate() throws NamespaceException, ServletException { httpService.registerServlet(METRICS_URI, new MetricsServlet(metricRegistry), null, null); httpService.registerServlet(HEALTH_URI, new HealthCheckServlet(healthCheckRegistry), null, null); httpService.registerServlet(PING_URI, new PingServlet(), null, null); httpService.registerServlet(THREADS_URI, new ThreadDumpServlet(), null, null); }
protected void activate(BundleContext bundleContext) { try { logger.debug("Starting up CMD servlet at " + WEBAPP_ALIAS + "/" + SERVLET_NAME); Hashtable<String, String> props = new Hashtable<String, String>(); httpService.registerServlet(WEBAPP_ALIAS + "/" + SERVLET_NAME, this, props, createHttpContext(bundleContext.getBundle())); } catch (NamespaceException e) { logger.error("Error during servlet startup", e); } catch (ServletException e) { logger.error("Error during servlet startup", e); } }
private void addProxyInternal(String url, String proxyTo) { LOG.debug("adding proxy alias: " + url + ", proxied to: " + proxyTo); try { ProxyServlet proxyServlet = new ProxyServlet(); proxyServlet.setProxyTo(proxyTo); httpService.registerServlet(url, proxyServlet, new Hashtable(), null); proxies.put(url, proxyTo); } catch (Exception e) { LOG.error("could not add proxy alias: " + url + ", proxied to: " + proxyTo + ", reason: " + e.getMessage()); } }
@Override public HttpService addingService(ServiceReference<HttpService> sref) { HttpService service = super.addingService(sref); try { RuntimeLogger.LOGGER.info("Register system HttpService with alias: " + SYSTEM_ALIAS); service.registerServlet(SYSTEM_ALIAS, new HttpServiceServlet(module), null, null); } catch (Exception ex) { throw new IllegalStateException(ex); } return service; }
@Activate protected void activate() throws NamespaceException, ServletException { // Mount some static resources from classpath of this bundle. httpService.registerResources(HYSTRIX_DASHBOARD_URI, "/hystrix-dashboard", null); // Mount hystrix metrix stream servlet to be used by hystrix dashboard. httpService.registerServlet(HYSTRIX_METRICS_STREAM_URI, new HystrixMetricsStreamServlet(), null, null); }
@Activate void activate(Map<String, ?> configuration) throws ServletException, NamespaceException { httpService.get().registerServlet("/*", redirectServlet, null, null); activateComponent(); }
@Activate public void activate() throws Exception { httpService.registerServlet("/example-websocket", new WebsocketExampleServlet(), null, null); notification = true; Thread notification = new Thread(new NotificationThread(sessions)); notification.start(); }
public void register() throws Exception { ObjectHelper.notEmpty(alias, "alias", this); ObjectHelper.notEmpty(servletName, "servletName", this); HttpContext actualHttpContext = (httpContext == null) ? httpService.createDefaultHttpContext() : httpContext; final Dictionary<String, String> initParams = new Hashtable<>(); initParams.put("matchOnUriPrefix", matchOnUriPrefix ? "true" : "false"); initParams.put("servlet-name", servletName); httpService.registerServlet(alias, servlet, initParams, actualHttpContext); alreadyRegistered = true; }
protected void activate(Map<String, Object> config) { try { Servlet servlet = getImpl(); logger.debug("Starting up '{}' servlet at /{}", servlet.getServletInfo(), PROXY_ALIAS); Hashtable<String, String> props = propsFromConfig(config); httpService.registerServlet("/" + PROXY_ALIAS, servlet, props, createHttpContext()); } catch (NamespaceException | ServletException e) { logger.error("Error during servlet startup: {}", e.getMessage()); } }
@Activate void activate(ComponentContext context, Map<String, ?> properties) { try { FabricDiscoveryServlet discoveryServlet = new FabricDiscoveryServlet(); discoveryServlet.setCurator(curator.get()); HttpContext base = httpService.get().createDefaultHttpContext(); httpService.get().registerServlet("/mq-discovery", discoveryServlet, createParams("mq-discovery"), base); } catch (Throwable t) { LOGGER.warn("Failed to register fabric maven proxy servlets, due to:" + t.getMessage()); } activateComponent(); }
@Validate public void start() throws ServletException, NamespaceException { CamelHttpTransportServlet srvlet = new CamelHttpTransportServlet(); httpSevlet.registerServlet("/sally", srvlet, null, null); httpSevlet.registerResources("/sally/static", "/static", null); servletComponent = new ServletComponent(); servletComponent.setServletName(srvlet.getServletName()); log.info("SallyURL "+SallyURL+ " "); }
@Override public Endpoint publish(ServiceDomain domain, String context, InboundHandler handler) throws Exception { String alias = "/" + context; HttpGatewayServlet servlet = new HttpGatewayServlet(); servlet.setHandler(handler); servlet.setClassLoader(Classes.getTCCL()); _httpService.registerServlet(alias, servlet, null, null); return new OsgiHttpEndpoint(_httpService, alias); }