conf.getConfig("jetty.ws"), "jetty.ws"); WebSocketServerFactory webSocketServerFactory = new WebSocketServerFactory( sch.getServletContext(), wsConfig); webSocketServerFactory.setCreator((req, rsp) -> { JettyWebSocket ws = new JettyWebSocket();
@Override public void contextDestroyed(ServletContextEvent event) { Enumeration<String> e = _context.getServletContext().getAttributeNames(); while (e.hasMoreElements()) { String name = e.nextElement(); if (_managedAttributes.contains(name)) updateBean(name,event.getServletContext().getAttribute(name),null); } }
@Override public void contextDestroyed(ServletContextEvent event) { Enumeration<String> e = _context.getServletContext().getAttributeNames(); while (e.hasMoreElements()) { String name = e.nextElement(); if (_managedAttributes.contains(name)) updateBean(name,event.getServletContext().getAttribute(name),null); } }
private static void logStartupBanner(Server server) { Object banner = null; ContextHandler contextHandler = server.getChildHandlerByClass(ContextHandler.class); if (contextHandler != null) { Context context = contextHandler.getServletContext(); if (context != null) { banner = context.getAttribute("nexus-banner"); } } StringBuilder buf = new StringBuilder(); buf.append("\n-------------------------------------------------\n\n"); buf.append("Started ").append(banner instanceof String ? banner : "Nexus Repository Manager"); buf.append("\n\n-------------------------------------------------"); log.info(buf.toString()); } }
private static void logStartupBanner(Server server) { Object banner = null; ContextHandler contextHandler = server.getChildHandlerByClass(ContextHandler.class); if (contextHandler != null) { Context context = contextHandler.getServletContext(); if (context != null) { banner = context.getAttribute("nexus-banner"); } } StringBuilder buf = new StringBuilder(); buf.append("\n-------------------------------------------------\n\n"); buf.append("Started ").append(banner instanceof String ? banner : "Nexus Repository Manager"); buf.append("\n\n-------------------------------------------------"); log.info(buf.toString()); } }
public Object mangle( final Server server ) { ContextHandler ctx = getContext( server ); if ( ctx != null && ctx.getServletContext() != null ) { // try with servlet context is available, it falls back to attributes anyway return ctx.getServletContext().getAttribute( attributeKey ); } else if ( ctx != null ) { // try plain jetty attributes return ctx.getAttribute( attributeKey ); } else { return null; } } }
@Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { ContextHandler contextHandler = state().getContextHandler(); if (contextHandler != null) return contextHandler.getServletContext().createListener(clazz); try { return clazz.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new ServletException(e); } }
@Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { ContextHandler contextHandler = state().getContextHandler(); if (contextHandler != null) return contextHandler.getServletContext().createListener(clazz); try { return clazz.newInstance(); } catch (Exception e) { throw new ServletException(e); } }
@Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { ContextHandler contextHandler = state().getContextHandler(); if (contextHandler != null) return contextHandler.getServletContext().createListener(clazz); try { return clazz.newInstance(); } catch (Exception e) { throw new ServletException(e); } }
@Override public void dump(Appendable out, String indent) throws IOException { dumpBeans(out,indent,Collections.singletonList(new ClassLoaderDump(getClassLoader())), Collections.singletonList(new DumpableCollection("Handler attributes " + this,((AttributesMap)getAttributes()).getAttributeEntrySet())), Collections.singletonList(new DumpableCollection("Context attributes " + this,((Context)getServletContext()).getAttributeEntrySet())), Collections.singletonList(new DumpableCollection("Initparams " + this,getInitParams().entrySet()))); }
@Override public void dump(Appendable out, String indent) throws IOException { dumpBeans(out,indent, Collections.singletonList(new ClassLoaderDump(getClassLoader())), Collections.singletonList(new DumpableCollection("Handler attributes "+this,((AttributesMap)getAttributes()).getAttributeEntrySet())), Collections.singletonList(new DumpableCollection("Context attributes "+this,((Context)getServletContext()).getAttributeEntrySet())), Collections.singletonList(new DumpableCollection("Initparams "+this,getInitParams().entrySet())) ); }
/** * Get the WebSocketContainer out of the current ThreadLocal reference * of the active ContextHandler. * * @return the WebSocketContainer if found, null if not found. */ public static WebSocketContainer getWebSocketContainer() { ContextHandler.Context context = ContextHandler.getCurrentContext(); if (context == null) return null; ContextHandler handler = ContextHandler.getContextHandler(context); if (handler == null) return null; if (!(handler instanceof ServletContextHandler)) return null; return (javax.websocket.WebSocketContainer) handler.getServletContext().getAttribute("javax.websocket.server.ServerContainer"); }
conf.getConfig("jetty.ws"), "jetty.ws"); WebSocketServerFactory webSocketServerFactory = new WebSocketServerFactory( sch.getServletContext(), wsConfig); webSocketServerFactory.setCreator((req, rsp) -> { JettyWebSocket ws = new JettyWebSocket();
ServletContext sc = context.getServletContext(); handler.setServletContext(sc);
ServletContext sc = context.getServletContext(); handler.setServletContext(sc);
ServletContext sc = context.getServletContext(); handler.setServletContext(sc);