Java Code Examples for org.eclipse.jetty.server.session.DatabaseAdaptor

Following code examples demonstrate how to use org.eclipse.jetty.server.session.DatabaseAdaptor from jetty. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.eclipse.jetty.server.session.DatabaseAdaptor and various code implementation of this class.
Example 1
Project : jetty Source File : MirthWebServer.java View Source Code on GitHub

    private SessionDataStoreFactory createSessionDataStoreFactory(String sessionStoreTable) throws SQLException {
        JDBCSessionDataStoreFactory jdbcSDSFactory = new JDBCSessionDataStoreFactory();
        SessionTableSchema schema = new SessionTableSchema();
        schema.setTableName(sessionStoreTable);
        jdbcSDSFactory.setSessionTableSchema(schema);

        
        DatabaseAdaptor dbAdapter = new DatabaseAdaptor() {
            @Override
            public String getBlobType() {
                if (_blobType == null && StringUtils.containsIgnoreCase(getDBName(), "sql server")) {
                    setBlobType("image");
                }
                return super.getBlobType();
            }
        };

        SqlSessionManager sqlSessionManager = SqlConfig.getSqlSessionManager();
        sqlSessionManager.startManagedSession();
        Connection connection = sqlSessionManager.getConnection();
        try {
            dbAdapter.adaptTo(connection.getMetaData());
            dbAdapter.setDatasource(sqlSessionManager.getConfiguration().getEnvironment().getDataSource());
        } finally {
            if (sqlSessionManager.isManagedSessionStarted()) {
                sqlSessionManager.close();
            }
        }
        jdbcSDSFactory.setDatabaseAdaptor(dbAdapter);

        return jdbcSDSFactory;
    }
			
Example 2
Project : jetty Source File : JettyServer.java View Source Code on GitHub

    private static SessionHandler createSessionHandler() {
        final DefaultSessionIdManager idmgr = new DefaultSessionIdManager(server);
        idmgr.setServer(server);
        try {
            idmgr.setWorkerName(InetAddress.getLocalHost().getHostAddress());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        server.setSessionIdManager(idmgr);
        JDBCSessionDataStore sessionStore = new JDBCSessionDataStore();
        DatabaseAdaptor databaseAdaptor = new DatabaseAdaptor();
        databaseAdaptor.setDatasource(dataSource);
        sessionStore.setDatabaseAdaptor(databaseAdaptor);
        SessionHandler sessionHandler = new SessionHandler();
        DefaultSessionCache cacheSession = new DefaultSessionCache(sessionHandler);
        sessionHandler.setSessionCache(cacheSession);
        cacheSession.setSessionDataStore(sessionStore);
        sessionHandler.setSessionIdManager(idmgr);

        return sessionHandler;
    }
			
Example 3
Project : jetty Source File : Sessions.java View Source Code on GitHub

    private static JDBCSessionDataStoreFactory jdbcDataStoreFactory(String driver, String url) {
        DatabaseAdaptor databaseAdaptor = new DatabaseAdaptor();
        databaseAdaptor.setDriverInfo(driver, url);
        JDBCSessionDataStoreFactory jdbcSessionDataStoreFactory = new JDBCSessionDataStoreFactory();
        jdbcSessionDataStoreFactory.setDatabaseAdaptor(databaseAdaptor);
        return jdbcSessionDataStoreFactory;
    }
			
Example 4
Project : jetty Source File : ClusteredSessionHandlerProvider.java View Source Code on GitHub

  public SessionHandler createSessionHandler( Server server ) {
    SessionHandler handler = new SessionHandler();
    DefaultSessionCache sessionCache = new DefaultSessionCache( handler );
    JDBCSessionDataStore sessionDataStore = new JDBCSessionDataStore();
    sessionCache.setSessionDataStore( sessionDataStore );
    DatabaseAdaptor databaseAdaptor = new DatabaseAdaptor();
    databaseAdaptor.setDriverInfo( databaseServer.getDriver(), databaseServer.getConnectionUrl() );
    sessionDataStore.setDatabaseAdaptor( databaseAdaptor );
    DefaultSessionIdManager sessionIdManager = new CleanJDBCSessionIdManager( server );
    sessionIdManager.setWorkerName( generateNodeName() );
    handler.setSessionCache( sessionCache );
    handler.setSessionIdManager( sessionIdManager );
    return handler;
  }