org.eclipse.jetty.server.session.SessionHandler Java Examples

The following examples show how to use org.eclipse.jetty.server.session.SessionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionHandlerFactory.java    From commafeed with Apache License 2.0 6 votes vote down vote up
public SessionHandler build() {
	SessionHandler sessionHandler = new SessionHandler() {
		{
			// no setter available for maxCookieAge
			_maxCookieAge = (int) cookieMaxAge.toSeconds();
		}
	};
	SessionCache sessionCache = new DefaultSessionCache(sessionHandler);
	sessionHandler.setSessionCache(sessionCache);
	FileSessionDataStore dataStore = new FileSessionDataStore();
	sessionCache.setSessionDataStore(dataStore);

	sessionHandler.setHttpOnly(true);
	sessionHandler.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
	sessionHandler.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
	sessionHandler.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());

	dataStore.setDeleteUnrestorableFiles(true);
	dataStore.setStoreDir(new File(path));
	dataStore.setSavePeriodSec((int) savePeriod.toSeconds());

	return sessionHandler;
}
 
Example #2
Source File: TransactionServer.java    From tcc-transaction with Apache License 2.0 6 votes vote down vote up
private TransactionServer() {
	this.server = new Server(port);

	try {
		ServletContextHandler handler = new ServletContextHandler();
		handler.setContextPath("/");
		handler.setSessionHandler(new SessionHandler());
		handler.addServlet(EnvServlet.class, "/api/env");
		handler.addServlet(PropertiesServlet.class, "/api/props");
           handler.addServlet(TaskServlet.class, "/api/tasks");
           handler.addServlet(StaticContentServlet.class, "/*");
           handler.addServlet(StartServlet.class, "/api/start");

           server.setHandler(handler);
	} catch (Exception e) {
		log.error("Exception in building AdminResourcesContainer ", e);
	}
}
 
Example #3
Source File: WebMQ.java    From bidder with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the JETTY server
 */
 public void run() {
	Server server = new Server(port);
	Handler handler = new Handler();
	SessionHandler sh = new SessionHandler(); // org.eclipse.jetty.server.session.SessionHandler
	sh.setHandler(handler);

	server.setHandler(sh); // set session handle
	try {
		server.start();
		server.join();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #4
Source File: TransactionServer.java    From galaxy with Apache License 2.0 6 votes vote down vote up
private TransactionServer() {
	this.server = new Server(port);

	try {
		ServletContextHandler handler = new ServletContextHandler();
		handler.setContextPath("/");
		handler.setSessionHandler(new SessionHandler());
		handler.addServlet(EnvServlet.class, "/api/env");
		handler.addServlet(PropertiesServlet.class, "/api/props");
           handler.addServlet(TaskServlet.class, "/api/tasks");
           handler.addServlet(StaticContentServlet.class, "/*");
           handler.addServlet(StartServlet.class, "/api/start");

           server.setHandler(handler);
	} catch (Exception e) {
		log.error("Exception in building AdminResourcesContainer ", e);
	}
}
 
Example #5
Source File: BundleFactoryTest.java    From dropwizard-pac4j with Apache License 2.0 6 votes vote down vote up
@Test
public void emptyPac4jInConfig() {
    setup(App.class, "empty-pac4j.yaml");

    App app = dropwizardTestSupport.getApplication();
    ObjectMapper om = dropwizardTestSupport.getObjectMapper();
    Environment env = dropwizardTestSupport.getEnvironment();

    Config config = app.bundle.getConfig();
    assertThat(config).isNotNull();
    // this is the default url resolver!
    assertThat(config.getClients().getUrlResolver())
            .isInstanceOf(JaxRsUrlResolver.class);
    assertThat(om.findMixInClassFor(Client.class)).isNotNull();
    assertThat(env.jersey().getResourceConfig().getSingletons())
            .haveAtLeastOne(CONDSI);

    assertThat(env.getApplicationContext().getSessionHandler())
            .isInstanceOf(SessionHandler.class);
}
 
Example #6
Source File: ServerCmdlet.java    From HongsCORE with MIT License 6 votes vote down vote up
@Override
public void init(ServletContextHandler sc) {
    CoreConfig  cc = CoreConfig.getInstance("defines");
    String dh = cc.getProperty("jetty.session.manager.db", "default");

    Server                  sv = sc . getServer             (  );
    DefaultSessionIdManager im = new DefaultSessionIdManager(sv);
    im.setWorkerName       (Core.SERVER_ID);
    sv.setSessionIdManager (im);

    SessionHandler          sh = sc . getSessionHandler  (  );
    DefaultSessionCache     ch = new DefaultSessionCache (sh);
    JDBCSessionDataStore    sd = new JDBCSessionDataStore(  );
    sd.setDatabaseAdaptor  (getAdaptor(dh));
    ch.setSessionDataStore (sd);
    sh.setSessionCache     (ch);
    sc.setSessionHandler   (sh);
}
 
Example #7
Source File: ZeppelinServer.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) {
  final ServletHolder servletHolder =
      new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer());

  servletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName());
  servletHolder.setName("rest");
  servletHolder.setForcedPath("rest");
  webapp.setSessionHandler(new SessionHandler());
  webapp.addServlet(servletHolder, "/api/*");

  String shiroIniPath = conf.getShiroPath();
  if (!StringUtils.isBlank(shiroIniPath)) {
    webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
    webapp
        .addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class))
        .setInitParameter("staticSecurityManagerEnabled", "true");
    webapp.addEventListener(new EnvironmentLoaderListener());
  }
}
 
Example #8
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
protected SessionHandler findPeerSessionMarkedPreferred(String localSessionId, Handler[] handlers) {
    SessionHandler preferredHandler = null;
    // are any sessions themselves marked as primary
    if (handlers != null) {
        for (Handler h: handlers) {
            SessionHandler sh = (SessionHandler)h;
            Session sessionHere = sh.getSession(localSessionId);
            if (sessionHere!=null) {
                if (Boolean.TRUE.equals(sessionHere.getAttribute(KEY_IS_PREFERRED))) {
                    if (preferredHandler!=null) {
                        // could occasionally happen on race, but should be extremely unlikely
                        log.warn("Multiple sessions marked as preferred for "+localSessionId+"; using "+info(preferredHandler)+" not "+info(sh));
                        sessionHere.setAttribute(KEY_IS_PREFERRED, null);
                    } else {
                        preferredHandler = sh;
                    }
                }
            }
        }
    }
    return preferredHandler;
}
 
Example #9
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public void setAttribute(String name, Object value) {
    if (setAllKnownSessions) {
        Handler[] hh = getSessionHandlers();
        if (hh!=null) {
            for (Handler h: hh) {
                Session ss = ((SessionHandler)h).getSession(localSession.getId());
                if (ss!=null) {
                    ss.setAttribute(name, value);
                }
            }
            return;
        } else {
            if (!setLocalValuesAlso) {
                // can't do all, but at least to local
                configureWhetherToSetLocalValuesAlso(true);
            }
        }
    }
    preferredSession.setAttribute(name, value);
    if (setLocalValuesAlso) {
        localSession.setAttribute(name, value);
    }
}
 
Example #10
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public MultiSessionAttributeAdapter resetExpiration() {
    // force all sessions with this ID to be marked used so they are not expired
    // (if _any_ session with this ID is expired, then they all are, even if another
    // with the same ID is in use or has a later expiry)
    Integer maxInativeInterval = MAX_INACTIVE_INTERVAL.getDefaultValue();
    if(this.mgmt != null){
        maxInativeInterval = mgmt.getConfig().getConfig(MAX_INACTIVE_INTERVAL);
    }
    Handler[] hh = getSessionHandlers();
    if (hh!=null) {
        for (Handler h: hh) {
            Session ss = ((SessionHandler)h).getSession(getId());
            if (ss!=null) {
                ss.setMaxInactiveInterval(maxInativeInterval);
            }
        }
    }
    return this;
}
 
Example #11
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
private void invalidateAllSession(HttpSession preferredSession, HttpSession localSession) {
    Server server = ((Session)preferredSession).getSessionHandler().getServer();
    final Handler[] handlers = server.getChildHandlersByClass(SessionHandler.class);
    List<String> invalidatedSessions = new ArrayList<>();
    if (handlers!=null) {
        for (Handler h: handlers) {
            Session session = ((SessionHandler)h).getSession(preferredSession.getId());
            if (session!=null) {
                invalidatedSessions.add(session.getId());
                session.invalidate();
            }
        }
    }
    if(!invalidatedSessions.contains(localSession.getId())){
        localSession.invalidate();
    }
}
 
Example #12
Source File: ShiroBundle.java    From dw-shiro-bundle with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initializeShiro(final ShiroConfiguration config, Environment environment) {
    if (config.isEnabled()) {
        LOG.debug("Shiro is enabled");

        if (config.isDropwizardSessionHandler() && environment.getApplicationContext().getSessionHandler() == null) {
            LOG.debug("Adding DropWizard SessionHandler to environment.");
            environment.getApplicationContext().setSessionHandler(new SessionHandler());
        }

        // This line ensure Shiro is configured and its .ini file found in the designated location.
        // e.g., via the shiroConfigLocations ContextParameter with fall-backs to default locations if that parameter isn't specified.
        environment.servlets().addServletListeners( new EnvironmentLoaderListener() );

        final String filterUrlPattern = config.getSecuredUrlPattern();
        LOG.debug("ShiroFilter will check URLs matching '{}'.", filterUrlPattern);
        environment.servlets().addFilter("shiro-filter", new ShiroFilter()).addMappingForUrlPatterns( EnumSet.allOf(DispatcherType.class), true, filterUrlPattern );
    } else {
        LOG.debug("Shiro is not enabled");
    }
}
 
Example #13
Source File: ExplorerServer.java    From Explorer with Apache License 2.0 6 votes vote down vote up
/**
 * Swagger core handler - Needed for the RestFul api documentation
 *
 * @return ServletContextHandler of Swagger
 */
private static ServletContextHandler setupSwaggerContextHandler(int port) {
    // Configure Swagger-core
    final ServletHolder SwaggerServlet = new ServletHolder(
            new com.wordnik.swagger.jersey.config.JerseyJaxrsConfig());
    SwaggerServlet.setName("JerseyJaxrsConfig");
    SwaggerServlet.setInitParameter("api.version", "1.0.0");
    SwaggerServlet.setInitParameter("swagger.api.basepath", "http://localhost:" + port + "/api");
    SwaggerServlet.setInitOrder(2);

    // Setup the handler
    final ServletContextHandler handler = new ServletContextHandler();
    handler.setSessionHandler(new SessionHandler());
    handler.addServlet(SwaggerServlet, "/api-docs/*");
    return handler;
}
 
Example #14
Source File: WebMQ.java    From XRTB with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the JETTY server
 */
 public void run() {
	Server server = new Server(port);
	Handler handler = new Handler();
	SessionHandler sh = new SessionHandler(); // org.eclipse.jetty.server.session.SessionHandler
	sh.setHandler(handler);

	server.setHandler(sh); // set session handle
	try {
		server.start();
		server.join();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #15
Source File: SessionListenersSupport.java    From dropwizard-guicey with MIT License 6 votes vote down vote up
@Override
public void start() throws Exception {
    for (MutableServletContextHandler environment : listeners.keySet()) {
        final SessionHandler sessionHandler = environment.getSessionHandler();
        if (sessionHandler == null) {
            final String msg = String.format(
                    "Can't register session listeners for %s because sessions support is not enabled: %s",
                    environment.getDisplayName().toLowerCase(),
                    Joiner.on(',').join(listeners.get(environment).stream()
                            .map(it -> FeatureUtils.getInstanceClass(it).getSimpleName())
                            .collect(Collectors.toList())));
            if (failWithoutSession) {
                throw new IllegalStateException(msg);
            } else {
                logger.warn(msg);
            }
        } else {
            listeners.get(environment).forEach(sessionHandler::addEventListener);
        }
    }
}
 
Example #16
Source File: Zippy.java    From XRTB with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the JETTY server
 */

 public void run() {
	Server server = new Server(port);
	Handler handler = new Handler();

	try {
		SessionHandler sh = new SessionHandler(); // org.eclipse.jetty.server.session.SessionHandler
		sh.addEventListener(new CustomListener());
		sh.setHandler(handler);
		server.setHandler(sh);
		server.start();
		server.join();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #17
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public void removeAttribute(String name) {
    if (setAllKnownSessions) {
        Handler[] hh = getSessionHandlers();
        if (hh!=null) {
            for (Handler h: hh) {
                Session ss = ((SessionHandler)h).getSession(localSession.getId());
                if (ss!=null) {
                    ss.removeAttribute(name);
                }
            }
            return;
        } else {
            if (!setLocalValuesAlso) {
                // can't do all, but at least to local
                configureWhetherToSetLocalValuesAlso(true);
            }
        }
    }
    preferredSession.removeAttribute(name);
    if (setLocalValuesAlso) {
        localSession.removeAttribute(name);
    }
}
 
Example #18
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected static ContextHandler.Context getContext(SessionHandler sh) {
    try {
        Field f = SessionHandler.class.getDeclaredField("_context");
        f.setAccessible(true);
        return (ContextHandler.Context) f.get(sh);
    } catch (Exception e) {
        Exceptions.propagateIfFatal(e);
        // else ignore, security doesn't allow finding context
        return null;
    }
}
 
Example #19
Source File: Jetty9Server.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Override
public void setSessionConfig() {
    SessionHandler sessionHandler = webAppContext.getSessionHandler();
    SessionCookieConfig sessionCookieConfig = sessionHandler.getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
    sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
    sessionHandler.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}
 
Example #20
Source File: ApiServer.java    From lancoder with GNU General Public License v3.0 5 votes vote down vote up
private ContextHandler buildServletContextHandler() throws Exception {
	WebApi webapp = new WebApi(master, master.getMasterEventCatcher());
	final ResourceConfig app = new ResourceConfig()
               .packages("jersey.jetty.embedded")
               .register(webapp);

       ServletHolder servletHolder = new ServletHolder(new ServletContainer(app));
	ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
	servletContextHandler.setSessionHandler(new SessionHandler());
	servletContextHandler.addServlet(servletHolder, "/*");
	return servletContextHandler;
}
 
Example #21
Source File: BaseJPARestTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
  ServletContextHandler contextHandler = new ServletContextHandler();
  JPAWebConfigurer configurer = new JPAWebConfigurer();
  configurer.setContext(context);
  contextHandler.addEventListener(configurer);

  // Create the SessionHandler (wrapper) to handle the sessions
  HashSessionManager manager = new HashSessionManager();
  SessionHandler sessions = new SessionHandler(manager);
  contextHandler.setHandler(sessions);

  return contextHandler;
}
 
Example #22
Source File: Starter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void start() {

		Server server = new Server(9080);
		ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
		servletContextHandler.setContextPath("/");
		servletContextHandler.setResourceBase("src/main/webapp");

		final String webAppDirectory = JumbuneInfo.getHome() + "modules/webapp";
		final ResourceHandler resHandler = new ResourceHandler();
		resHandler.setResourceBase(webAppDirectory);
		final ContextHandler ctx = new ContextHandler("/");
		ctx.setHandler(resHandler);
		servletContextHandler.setSessionHandler(new SessionHandler());

		ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/apis/*");
		servletHolder.setInitOrder(0);
		servletHolder.setAsyncSupported(true);
		servletHolder.setInitParameter("jersey.config.server.provider.packages", "org.jumbune.web.services");
		servletHolder.setInitParameter("jersey.config.server.provider.classnames",
				"org.glassfish.jersey.media.multipart.MultiPartFeature");

		try {
			server.insertHandler(servletContextHandler);
			server.insertHandler(resHandler);
			server.start();
			server.join();
		} catch (Exception e) {
			LOGGER.error("Error occurred while starting Jetty", e);
			System.exit(1);
		}
	}
 
Example #23
Source File: EntitlementContextFilterTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureCXF(JAXRSServerFactoryBean sf) {
    BrooklynProperties props = (BrooklynProperties)getManagementContext().getConfig();
    props.put(BrooklynWebConfig.USERS, USER_PASS);
    props.put(BrooklynWebConfig.PASSWORD_FOR_USER(USER_PASS), USER_PASS);
    getManagementContext().getScratchpad().put(BrooklynWebConfig.SECURITY_PROVIDER_INSTANCE, new ExplicitUsersSecurityProvider(getManagementContext()));

    sf.setProvider(new SessionHandler());
    super.configureCXF(sf);
}
 
Example #24
Source File: TestServerUtil.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
  ServletContextHandler contextHandler = new ServletContextHandler();
  WebConfigurer configurer = new WebConfigurer();
  configurer.setContext(context);
  contextHandler.addEventListener(configurer);
  
  // Create the SessionHandler (wrapper) to handle the sessions
  HashSessionManager manager = new HashSessionManager();
  SessionHandler sessions = new SessionHandler(manager);
  contextHandler.setHandler(sessions);
  
  return contextHandler;
}
 
Example #25
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected Handler[] getSessionHandlers() {
    Server srv = getServer();
    Handler[] handlers = null;
    if (srv!=null) {
        handlers = srv.getChildHandlersByClass(SessionHandler.class);
    }
    return handlers;
}
 
Example #26
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private static String getContextPath(Handler h) {
    if (h instanceof SessionHandler) {
        ContextHandler.Context ctx = getContext((SessionHandler)h);
        if (ctx!=null) {
            return ctx.getContextPath();
        }
    }
    return null;
}
 
Example #27
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected SessionHandler getServerGlobalPreferredHandler(Server server) {
    SessionHandler preferredHandler = (SessionHandler) server.getAttribute(KEY_PREFERRED_SESSION_HANDLER_INSTANCE);
    if (preferredHandler!=null) {
        if (preferredHandler.isRunning()) {
            if (log.isTraceEnabled()) {
                log.trace("Found "+info(preferredHandler)+" as server-wide preferred handler");
            }
            return preferredHandler;
        }
        log.warn("Preferred session handler "+info(preferredHandler)+" detected on server is not running; resetting");
    }
    return null;
}
 
Example #28
Source File: JettyServer.java    From sumk with Apache License 2.0 5 votes vote down vote up
protected synchronized void init() {
	try {
		buildJettyProperties();
		server = new Server(new ExecutorThreadPool(HttpExcutors.getThreadPool()));
		ServerConnector connector = this.createConnector();
		Logs.http().info("listen port: {}", port);
		String host = StartContext.httpHost();
		if (host != null && host.length() > 0) {
			connector.setHost(host);
		}
		connector.setPort(port);

		server.setConnectors(new Connector[] { connector });
		ServletContextHandler context = createServletContextHandler();
		context.setContextPath(AppInfo.get("sumk.jetty.web.root", "/"));
		context.addEventListener(new SumkLoaderListener());
		addUserListener(context, Arrays.asList(ServletContextListener.class, ContextScopeListener.class));
		String resourcePath = AppInfo.get("sumk.jetty.resource");
		if (StringUtil.isNotEmpty(resourcePath)) {
			ResourceHandler resourceHandler = JettyHandlerSupplier.resourceHandlerSupplier().get();
			if (resourceHandler != null) {
				resourceHandler.setResourceBase(resourcePath);
				context.insertHandler(resourceHandler);
			}
		}

		if (AppInfo.getBoolean("sumk.jetty.session.enable", false)) {
			SessionHandler h = JettyHandlerSupplier.sessionHandlerSupplier().get();
			if (h != null) {
				context.insertHandler(h);
			}
		}
		server.setHandler(context);
	} catch (Throwable e) {
		Log.printStack("sumk.http", e);
		System.exit(1);
	}

}
 
Example #29
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private static String getBundle(Handler h) {
    if (h instanceof SessionHandler) {
        ContextHandler.Context ctx = getContext((SessionHandler)h);
        if (ctx!=null) {
            BundleContext bundle = (BundleContext) ctx.getAttribute("osgi-bundlecontext");
            if (bundle!=null) return bundle.getBundle().getSymbolicName();
        }
    }
    return null;
}
 
Example #30
Source File: MultiSessionAttributeAdapter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected SessionHandler findPreferredBundleHandler(Session localSession, Server server, Handler[] handlers) {
    if (PREFERRED_SYMBOLIC_NAME==null) return null;

    SessionHandler preferredHandler = null;

    if (handlers != null) {
        for (Handler handler: handlers) {
            SessionHandler sh = (SessionHandler) handler;
            ContextHandler.Context ctx = getContext(sh);
            if (ctx!=null) {
                BundleContext bundle = (BundleContext) ctx.getAttribute("osgi-bundlecontext");
                if (bundle!=null) {
                    if (PREFERRED_SYMBOLIC_NAME.equals(bundle.getBundle().getSymbolicName())) {
                        if (preferredHandler==null) {
                            preferredHandler = sh;
                            server.setAttribute(KEY_PREFERRED_SESSION_HANDLER_INSTANCE, sh);
                            log.trace("Recording "+info(sh)+" as server-wide preferred session handler");
                        } else {
                            log.warn("Multiple preferred session handlers detected; keeping "+info(preferredHandler)+", ignoring "+info(sh));
                        }
                    }
                }
            }
        }
    }
    if (preferredHandler==null) {
        log.warn("Did not find handler in bundle "+PREFERRED_SYMBOLIC_NAME+"; not using server-wide handler; check whether bundle is installed!");
    }
    return preferredHandler;
}