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"); }
private void unregisterServlets() { if (this.httpService != null) { logger.info("JERSEY BUNDLE: UNREGISTERING SERVLETS"); httpService.unregister("/jersey-http-service"); logger.info("JERSEY BUNDLE: SERVLETS UNREGISTERED"); } }
try { LOG.log(Level.INFO, "Unregistering previous instance of \"" + alias + "\" servlet"); httpService.unregister(alias); } catch (IllegalArgumentException e) { HttpContext context = httpService.createDefaultHttpContext(); 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);
@Reference protected void setHttpService(HttpService httpService) { try { httpService.registerServlet(IMAGES_ALIAS, this, null, httpService.createDefaultHttpContext()); } catch (Exception e) { logger.error("Could not register icon forwarder servlet: {}", e.getMessage()); } }
@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); }
/** * Creates a {@link HttpContext} * * @return a {@link HttpContext} */ protected HttpContext createHttpContext() { return httpService.createDefaultHttpContext(); }
@Activate protected void activate() throws NamespaceException { httpService.registerResources(HALBROWSER_URI_PREFIX, "/halbrowser-webapp", null); httpService.registerResources(HALBROWSER_URI_PREFIX_LEGACY, "/halbrowser-legacy-redirect", null); }
public void registerServlet(BundleContext bundleContext) throws Exception { HttpContext defaultHttpContext = httpService.createDefaultHttpContext(); Dictionary<String,String> servletParam = new Hashtable<String,String>(2); servletParam.put("-webAllowOthers", ""); httpService.registerServlet("/dbconsole", new WebServlet(), servletParam, defaultHttpContext); }
@Validate public void start() throws ServletException, NamespaceException { CamelHttpTransportServlet srvlet = new CamelHttpTransportServlet(); httpSevlet.registerServlet("/sally", srvlet, null, null); httpSevlet.registerResources("/sally/jobad", "/app/jobad", null); httpSevlet.registerResources("/sally/client", "/app/client", null); ServletComponent servletComponent = new ServletComponent(); servletComponent.setServletName(srvlet.getServletName()); camelContextProvider.registerGlobalComponent("sallyservlet", servletComponent); }
/** * Initializes this context * * @param httpService The parent HTTP service */ public XOWLMainHTTPContext(HttpService httpService) { this.delegate = httpService.createDefaultHttpContext(); }
public Object addingService(ServiceReference reference) { HttpService httpService = (HttpService) context.getService(reference); try { httpService.registerResources("/js", "/src-web", null); } catch (NamespaceException e) { e.printStackTrace(); } return null; }
/** {@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; }
/** {@inheritDoc} */ public void removedService(ServiceReference reference, Object service) { HttpService httpService = (HttpService) service; httpService.unregister(getServletAlias()); } }
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; }
@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+ " "); }
/** * Creates a {@link HttpContext} * * @return a {@link HttpContext} */ protected HttpContext createHttpContext() { HttpContext defaultHttpContext = httpService.createDefaultHttpContext(); return defaultHttpContext; }
@Activate void activate() throws NamespaceException { synchronized (resourceToRegistration) { for (Delegate registration : resourceToRegistration.values()) { registration.init(httpService); httpService.registerResources(registration.alias, registration.path, registration); } } }
/** * 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); }
private void unregisterResource(Delegate registration) { if (registration != null && httpService != null) { httpService.unregister(registration.alias); } } }
@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(); }