Java 类org.apache.catalina.session.StandardManager 实例源码

项目:tomcat7    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:lams    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:jerrydog    文件:StandardServer.java   
/**
 * Is this an instance of the default <code>Manager</code> configuration,
 * with all-default properties?
 *
 * @param manager Manager to be tested
 */
private boolean isDefaultManager(Manager manager) {

    if (!(manager instanceof StandardManager)) {
        return (false);
    }
    StandardManager smanager = (StandardManager) manager;
    if ((smanager.getDebug() != 0) ||
        !smanager.getPathname().equals("SESSIONS.ser") ||
        (smanager.getCheckInterval() != 60) ||
        !smanager.getRandomClass().equals("java.security.SecureRandom") ||
        (smanager.getMaxActiveSessions() != -1) ||
        !smanager.getAlgorithm().equals("MD5")) {
        return (false);
    }
    return (true);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:lazycat    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent
 *            MBean Name of the associated parent component
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public String createStandardManager(String parent) throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    }
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:class-guard    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:apache-tomcat-7.0.57    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:apache-tomcat-7.0.57    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:HowTomcatWorks    文件:StandardServer.java   
/**
 * Is this an instance of the default <code>Manager</code> configuration,
 * with all-default properties?
 *
 * @param manager Manager to be tested
 */
private boolean isDefaultManager(Manager manager) {

    if (!(manager instanceof StandardManager)) {
        return (false);
    }
    StandardManager smanager = (StandardManager) manager;
    if ((smanager.getDebug() != 0) ||
        !smanager.getPathname().equals("SESSIONS.ser") ||
        (smanager.getCheckInterval() != 60) ||
        !smanager.getRandomClass().equals("java.security.SecureRandom") ||
        (smanager.getMaxActiveSessions() != -1) ||
        !smanager.getAlgorithm().equals("MD5")) {
        return (false);
    }
    return (true);

}
项目:WBSAirback    文件:MBeanFactory.java   
/**
 * Create a new StandardManager.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardManager(String parent)
    throws Exception {

    // Create a new StandardManager instance
    StandardManager manager = new StandardManager();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setManager(manager);
    } 
    ObjectName oname = manager.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }

}
项目:tomcat7    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:apache-tomcat-7.0.73-with-comment    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:appng-tomcat-session    文件:UtilsTest.java   
@Test
public void test() throws Exception {
    MockServletContext ctx = new MockServletContext();
    StandardManager manager = new StandardManager();
    manager.setContext(new StandardContext());
    StandardSession session = new StandardSession(manager);
    session.setId("4711");
    session.setValid(true);
    session.setAttribute("foo", "bar");
    session.setAttribute("property", new SimpleProperty("foo", "bar"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    session.writeObjectData(oos);
    oos.flush();
    oos.close();
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    ObjectInputStream ois = Utils.getObjectInputStream(contextClassLoader, ctx, baos.toByteArray());

    StandardSession newSession = new StandardSession(manager);
    newSession.readObjectData(ois);
    Assert.assertEquals(session.getId(), newSession.getId());
    Assert.assertEquals("4711", newSession.getId());
    Assert.assertEquals(session.getAttribute("foo"), newSession.getAttribute("foo"));
    Assert.assertEquals("bar", newSession.getAttribute("foo"));
    Assert.assertEquals(SimpleProperty.class, newSession.getAttribute("property").getClass());
    Assert.assertEquals("bar", ((Property) newSession.getAttribute("property")).getString());

}
项目:lazycat    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if (manager instanceof BackupManager)
        return ((BackupManager) manager).getClassLoaders();
    else if (manager instanceof ClusterManagerBase)
        return ((ClusterManagerBase) manager).getClassLoaders();
    else if (manager instanceof StandardManager) {
        StandardManager sm = (StandardManager) manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if (manager instanceof ManagerBase) {
        ManagerBase mb = (ManagerBase) manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    } // end if
    return null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TomcatEmbeddedServletContainerFactory.java   
private void configurePersistSession(Manager manager) {
    Assert.state(manager instanceof StandardManager,
            "Unable to persist HTTP session state using manager type "
                    + manager.getClass().getName());
    File dir = getValidSessionStoreDir();
    File file = new File(dir, "SESSIONS.ser");
    ((StandardManager) manager).setPathname(file.getAbsolutePath());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TomcatEmbeddedServletContainerFactory.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (event.getType().equals(Lifecycle.START_EVENT)) {
        Context context = (Context) event.getLifecycle();
        Manager manager = context.getManager();
        if (manager != null && manager instanceof StandardManager) {
            ((StandardManager) manager).setPathname(null);
        }
    }
}
项目:spring-boot-concourse    文件:TomcatEmbeddedServletContainerFactory.java   
private void configurePersistSession(Manager manager) {
    Assert.state(manager instanceof StandardManager,
            "Unable to persist HTTP session state using manager type "
                    + manager.getClass().getName());
    File dir = getValidSessionStoreDir();
    File file = new File(dir, "SESSIONS.ser");
    ((StandardManager) manager).setPathname(file.getAbsolutePath());
}
项目:spring-boot-concourse    文件:TomcatEmbeddedServletContainerFactory.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (event.getType().equals(Lifecycle.START_EVENT)) {
        Context context = (Context) event.getLifecycle();
        Manager manager = context.getManager();
        if (manager != null && manager instanceof StandardManager) {
            ((StandardManager) manager).setPathname(null);
        }
    }
}
项目:contestparser    文件:TomcatEmbeddedServletContainerFactory.java   
private void configurePersistSession(Manager manager) {
    Assert.state(manager instanceof StandardManager,
            "Unable to persist HTTP session state using manager type "
                    + manager.getClass().getName());
    File folder = getValidSessionStoreDir();
    File file = new File(folder, "SESSIONS.ser");
    ((StandardManager) manager).setPathname(file.getAbsolutePath());
}
项目:class-guard    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:apache-tomcat-7.0.57    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:apache-tomcat-7.0.57    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:WBSAirback    文件:DeltaSession.java   
public ClassLoader[] getClassLoaders() {
    if ( manager instanceof BackupManager ) return ((BackupManager)manager).getClassLoaders();
    else if ( manager instanceof ClusterManagerBase ) return ((ClusterManagerBase)manager).getClassLoaders();
    else if ( manager instanceof StandardManager ) {
        StandardManager sm = (StandardManager)manager;
        return ClusterManagerBase.getClassLoaders(sm.getContainer());
    } else if ( manager instanceof ManagerBase ) {
        ManagerBase mb = (ManagerBase)manager;
        return ClusterManagerBase.getClassLoaders(mb.getContainer());
    }//end if
    return null;
}
项目:embed-apache-tomcat    文件:TomcatApplicationBuilderImpl.java   
/**
 * @param parent
 * @param config
 */
public TomcatApplicationBuilderImpl(TomcatHostBuilderImpl parent, Map<String, String> config) {
    super(parent);
    this.context = InstanceConfigurer.instantiate(loader(), StandardContext.class, CONTEXT, config);
    context.addLifecycleListener(new FixContextListener());
    StandardManager manager = new StandardManager();
    manager.setSecureRandomAlgorithm("SHA1PRNG");
    manager.setContext(context);
    context.setManager(manager);

    this.initializer = new InternalContainerInitializer();
    context.addServletContainerInitializer(initializer, null);

    setContainer(context);
}
项目:lams    文件:Tomcat.java   
/** Init default servlets for the context. This should be the programmatic
 * equivalent of the default web.xml. 
 * 
 *  TODO: in normal tomcat, if default-web.xml is not found, use this 
 *  method
 */
protected void initWebappDefaults(StandardContext ctx) {
    // Default servlet 
    StandardWrapper servlet = 
        addServlet(ctx, "default", 
                //new DefaultServlet());
    // Or:
                "org.apache.catalina.servlets.DefaultServlet");
    servlet.addInitParameter("listings", "false");
    servlet.setLoadOnStartup(1);

    // class name - to avoid loading all deps
    servlet = addServlet(ctx, "jsp", 
        "org.apache.jasper.servlet.JspServlet");
    servlet.addInitParameter("fork", "false");
    servlet.addInitParameter("xpoweredBy", "false");

    // in default web.xml - but not here, only needed if you have
    // jsps.
    //servlet.setLoadOnStartup(3);

    ctx.addServletMapping("/", "default");
    ctx.addServletMapping("*.jsp", "jsp");
    ctx.addServletMapping("*.jspx", "jsp");
    // Sessions
    ctx.setManager( new StandardManager());
    ctx.setSessionTimeout(30);

    // TODO: read mime from /etc/mime.types on linux, or some
    // resource
    for (int i = 0; i < DEFAULT_MIME_MAPPINGS.length; ) {
        ctx.addMimeMapping(DEFAULT_MIME_MAPPINGS[i++],
                DEFAULT_MIME_MAPPINGS[i++]);
    }
    ctx.addWelcomeFile("index.html");
    ctx.addWelcomeFile("index.htm");
    ctx.addWelcomeFile("index.jsp");

    ctx.setLoginConfig( new LoginConfig("NONE", null, null, null));

    // TODO: set a default realm, add simple API to add users
}
项目:contestparser    文件:TomcatEmbeddedServletContainerFactory.java   
private void disablePersistSession(Manager manager) {
    if (manager instanceof StandardManager) {
        ((StandardManager) manager).setPathname(null);
    }
}
项目:HowTomcatWorks    文件:Bootstrap.java   
public static void main(String[] args) {

    //invoke: http://localhost:8080/myApp/Session

    System.setProperty("catalina.base", System.getProperty("user.dir"));
    Connector connector = new HttpConnector();
    Wrapper wrapper1 = new SimpleWrapper();
    wrapper1.setName("Session");
    wrapper1.setServletClass("SessionServlet");

    Context context = new StandardContext();
    // StandardContext's start method adds a default mapper
    context.setPath("/myApp");
    context.setDocBase("myApp");

    context.addChild(wrapper1);

    // context.addServletMapping(pattern, name);
    // note that we must use /myApp/Session, not just /Session
    // because the /myApp section must be the same as the path, so the cookie will
    // be sent back.
    context.addServletMapping("/myApp/Session", "Session");
    // add ContextConfig. This listener is important because it configures
    // StandardContext (sets configured to true), otherwise StandardContext
    // won't start
    LifecycleListener listener = new SimpleContextConfig();
    ((Lifecycle) context).addLifecycleListener(listener);

    // here is our loader
    Loader loader = new WebappLoader();
    // associate the loader with the Context
    context.setLoader(loader);

    connector.setContainer(context);

    // add a Manager
    Manager manager = new StandardManager();
    context.setManager(manager);

    try {
      connector.initialize();
      ((Lifecycle) connector).start();

      ((Lifecycle) context).start();

      // make the application wait until we press a key.
      System.in.read();
      ((Lifecycle) context).stop();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
项目:EmbeddedTomcatLauncher    文件:SimpleServerConfigurator1.java   
/**
 * もっとも単純なTomcatの独自のスタートアップ方法による初期化.<br>
 */
@Override
public void init() throws IOException, ServletException {
    if (tomcat != null) {
        throw new IllegalStateException("already initialized");
    }

    // Tomcatの組み込み or テストの構成用のヘルパクラスを構築.
    tomcat = new Tomcat();

    // リスンするポートの指定
    tomcat.setPort(port);

    // --------------------------------
    // ベースディレクトリの指定.
    // --------------------------------
    // CATALINA_HOME, CATALINA_BASEシステムプロパティの設定.
    // このディレクトリ下でJSPのコンパイルやセッションの永続化など
    // さまざまなデータの保存が行われる.
    String baseDir = new File(getAppRootDir(), "work").getCanonicalPath();
    tomcat.setBaseDir(baseDir);

    // --------------------------------
    // 自動的に構成された標準構成のHostインスタンスを取得する
    // --------------------------------
    Host host = tomcat.getHost();
    // 仮想ホストのアプリケーションディレクトリを指定する.
    // baseDirからの相対で指定するか、もしくは絶対パスを指定する.
    String appbase = new File(getAppRootDir(), "webapp1").getCanonicalPath();
    host.setAppBase(appbase);

    // --------------------------------
    // アプリケーションを1つ構成する.
    // --------------------------------
    // 1つのアプリだけで良いのでアプリケーションフォルダ自身とする.
    ctx = (StandardContext) tomcat.addWebapp("/", appbase);

    // --------------------------------
    // コンテキストマネージャを設定する
    // --------------------------------
    StandardManager manager = new StandardManager();
    // セッションをファイルにシリアライズさせないためファイル名をnullにする.
    // (デフォルトではワークディレクトリ上にSESSIONS.SERファイルが生成される)
    manager.setPathname(null);
    ctx.setManager(manager);
}
项目:EmbeddedTomcatLauncher    文件:SimpleServerConfigurator2.java   
/**
 * ローカルマシンでのバインドに限定するようにコネクタを構成したTomcatを構成する.<br>
 */
@Override
public void init() throws IOException, ServletException {
    if (tomcat != null) {
        throw new IllegalStateException("already initialized");
    }

    // Tomcatのバージョンを確認する.
    logger.log(Level.INFO, "Tomcat version=" + ServerInfo.getServerInfo());

    // 基本的なTomcatの構成のヘルパクラスを構築する.
    // (このあとで必要に応じて構成をカスタマイズする.)
    tomcat = new Tomcat();

    // リスンするポートの指定
    tomcat.setPort(-1);

    // --------------------------------
    // ベースディレクトリの指定.
    // --------------------------------
    // CATALINA_HOME, CATALINA_BASEシステムプロパティの設定.
    // このディレクトリ下でJSPのコンパイルやセッションの永続化など
    // さまざまなデータの保存が行われる.
    String baseDir = new File(getAppRootDir(), "work").getCanonicalPath();
    tomcat.setBaseDir(baseDir);

    // --------------------------------
    // ローカルマシン専用とするため、
    // 独自のコネクタとスレッドプールを設定する
    // --------------------------------
    initConnectors();

    // --------------------------------
    // クラスローダを設定する.
    // JavaFXのローダと組み合わせる場合は必須である.
    // Tomcatを構築するクラス自身がJavaFXの独自のクラスローダ上にいるため、
    // クラスローダーの関係性については十分に注意が必要となる.
    // --------------------------------
    ClassLoader cl = AbstractServerConfigurator.class.getClassLoader();
    logger.log(Level.INFO, "setParentClassLoader: " + cl);
    tomcat.getEngine().setParentClassLoader(cl);
    tomcat.getHost().setParentClassLoader(cl);
    tomcat.getServer().setParentClassLoader(cl);
    tomcat.getService().setParentClassLoader(cl);

    // --------------------------------
    // ウェブアプリケーションを設定する
    // --------------------------------
    initWebApp();

    // --------------------------------
    // コンテキストマネージャを設定する
    // --------------------------------
    StandardManager manager = new StandardManager();
    // セッションをファイルにシリアライズさせないためファイル名をnullにする.
    // (デフォルトではワークディレクトリ上にSESSIONS.SERファイルが生成される)
    manager.setPathname(null);
    ctx.setManager(manager);
}