本文整理了Java中org.apache.catalina.Context.setManager()
方法的一些代码示例,展示了Context.setManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.setManager()
方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:setManager
[英]Set the Manager with which this Context is associated.
[中]设置与此上下文关联的管理器。
代码示例来源:origin: apache/geode
public static void setupServer(DeltaSessionManager manager) throws Exception {
FileUtils.copyDirectory(Paths.get("..", "resources", "integrationTest", "tomcat").toFile(),
new File("./tomcat"));
port = AvailablePortHelper.getRandomAvailableTCPPort();
server = new EmbeddedTomcat("/test", port, "JVM-1");
PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener();
p2pListener.setProperty(MCAST_PORT, "0");
p2pListener.setProperty(LOG_LEVEL, "config");
server.getEmbedded().addLifecycleListener(p2pListener);
sessionManager = manager;
sessionManager.setEnableCommitValve(true);
server.getRootContext().setManager(sessionManager);
servlet = server.addServlet("/test/*", "default", CommandServlet.class.getName());
server.startContainer();
/*
* Can only retrieve the region once the container has started up (and the cache has started
* too).
*/
region = sessionManager.getSessionCache().getSessionRegion();
}
代码示例来源:origin: org.springframework.boot/spring-boot
private void configureSession(Context context) {
long sessionTimeout = getSessionTimeoutInMinutes();
context.setSessionTimeout((int) sessionTimeout);
Boolean httpOnly = getSession().getCookie().getHttpOnly();
if (httpOnly != null) {
context.setUseHttpOnly(httpOnly);
}
if (getSession().isPersistent()) {
Manager manager = context.getManager();
if (manager == null) {
manager = new StandardManager();
context.setManager(manager);
}
configurePersistSession(manager);
}
else {
context.addLifecycleListener(new DisablePersistSessionListener());
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Remove an existing Manager.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeManager(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setManager(null);
}
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Remove an existing Manager.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeManager(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setManager(null);
}
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Remove an existing Manager.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeManager(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setManager(null);
}
}
代码示例来源:origin: stackoverflow.com
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) container;
containerFactory.addContextValves(new RedisSessionHandlerValve());
ArrayList<MyTomcatContextCustomizer> customizers = Lists.newArrayList(new MyTomcatContextCustomizer());
containerFactory.setTomcatContextCustomizers(customizers);
}
};
}
public class MyTomcatContextCustomizer implements TomcatContextCustomizer {
@Override
public void customize(Context context) {
context.setSessionTimeout(30);
context.setManager(new RedisSessionManager() {{
setHost("127.0.0.1");
}});
}
}
代码示例来源:origin: apache/tomcat-maven-plugin
private void constructSessionManager(Context ctx, String sessionManagerFactoryClassName, boolean cookies) {
try {
debugMessage("Constructing session manager with factory " + sessionManagerFactoryClassName);
Class sessionManagerClass = Class.forName(sessionManagerFactoryClassName);
Object managerFactory = (Object) sessionManagerClass.newInstance();
Method method = managerFactory.getClass().getMethod("createSessionManager");
if (method != null) {
Manager manager = (Manager) method.invoke(managerFactory, null);
ctx.setManager(manager);
ctx.setCookies(cookies);
} else {
System.out.print(sessionManagerFactoryClassName + " does not have a method createSessionManager()");
}
} catch (Exception e) {
System.err.println("Unable to construct specified session manager '" +
sessionManagerFactoryClassName + "': " + e.getLocalizedMessage());
e.printStackTrace();
}
}
代码示例来源:origin: org.glassfish.main.web/web-core
/**
* Set up a manager.
*/
protected synchronized void managerConfig() {
if (context.getManager() == null) {
context.setManager(new StandardManager());
}
}
代码示例来源:origin: jsimone/webapp-runner
RedissonSessionManager redisManager = new RedissonSessionManager();
redisManager.setConfigPath(configFile.getAbsolutePath());
ctx.setManager(redisManager);
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Create a new StandardManager.
*
* @param parent MBean Name of the associated parent component
* @return the object name of the created manager
*
* @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);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setManager(manager);
} else {
throw new Exception(sm.getString("mBeanFactory.managerContext"));
}
ObjectName oname = manager.getObjectName();
if (oname != null) {
return oname.toString();
} else {
return null;
}
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* 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);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setManager(manager);
} else {
throw new Exception(sm.getString("mBeanFactory.managerContext"));
}
ObjectName oname = manager.getObjectName();
if (oname != null) {
return (oname.toString());
} else {
return null;
}
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Create a new StandardManager.
*
* @param parent MBean Name of the associated parent component
* @return the object name of the created manager
*
* @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);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setManager(manager);
} else {
throw new Exception(sm.getString("mBeanFactory.managerContext"));
}
ObjectName oname = manager.getObjectName();
if (oname != null) {
return oname.toString();
} else {
return null;
}
}
代码示例来源:origin: org.apache.meecrowave/meecrowave-core
@Override
public void start() throws LifecycleException {
// Use fast, insecure session ID generation for all tests
final Server server = getServer();
for (final Service service : server.findServices()) {
final org.apache.catalina.Container e = service.getContainer();
for (final org.apache.catalina.Container h : e.findChildren()) {
for (final org.apache.catalina.Container c : h.findChildren()) {
Manager m = ((org.apache.catalina.Context) c).getManager();
if (m == null) {
m = new StandardManager();
org.apache.catalina.Context.class.cast(c).setManager(m);
}
if (m instanceof ManagerBase) {
ManagerBase.class.cast(m).setSecureRandomClass(
"org.apache.catalina.startup.FastNonSecureRandom");
}
}
}
}
super.start();
}
}
代码示例来源:origin: apache/meecrowave
@Override
public void start() throws LifecycleException {
// Use fast, insecure session ID generation for all tests
final Server server = getServer();
for (final Service service : server.findServices()) {
final org.apache.catalina.Container e = service.getContainer();
for (final org.apache.catalina.Container h : e.findChildren()) {
for (final org.apache.catalina.Container c : h.findChildren()) {
Manager m = ((org.apache.catalina.Context) c).getManager();
if (m == null) {
m = new StandardManager();
org.apache.catalina.Context.class.cast(c).setManager(m);
}
if (m instanceof ManagerBase) {
ManagerBase.class.cast(m).setSecureRandomClass(
"org.apache.catalina.startup.FastNonSecureRandom");
}
}
}
}
super.start();
}
}
代码示例来源:origin: com.github.bordertech.lde/lde-tomcat
/**
* @param context the context to configure
* @throws IOException an IO Exception
* @throws ServletException a Servlet Exception
*/
protected void configWebApp(final Context context) throws IOException, ServletException {
final String libDir = getLibDir();
final String classesDir = getClassesDir();
configJarScanner(context);
WebResourceRoot resources = new StandardRoot(context);
context.setResources(resources);
// Declare an alternative location for the "WEB-INF/lib" dir
if (libDir != null && !libDir.isEmpty()) {
resources.addPreResources(new DirResourceSet(resources, Constants.WEB_INF_LIB, libDir, "/"));
}
// Declare an alternative location for the "WEB-INF/classes" dir
if (classesDir != null && !classesDir.isEmpty()) {
resources.addPreResources(new DirResourceSet(resources, Constants.WEB_INF_CLASSES, classesDir, "/"));
}
// Stop persistent sessions
StandardManager mgr = new StandardManager();
mgr.setPathname(null);
context.setManager(mgr);
// Delay for requets to stop processing in milliseconds
((StandardContext) context).setUnloadDelay(10000);
}
代码示例来源:origin: org.glassfish.web/web-glue
ctx.setManager(mgr);
代码示例来源:origin: org.glassfish.web/web-glue
public void initializePersistenceStrategy(
Context ctx,
SessionManager smBean,
ServerConfigLookup serverConfigLookup) {
super.initializePersistenceStrategy(ctx, smBean, serverConfigLookup);
CookiePersistentManager mgr = new CookiePersistentManager();
if (sessionFilename == null) {
mgr.setPathname(sessionFilename);
} else {
mgr.setPathname(prependContextPathTo(sessionFilename, ctx));
}
mgr.setMaxActiveSessions(maxSessions);
mgr.setCookieName(persistentCookieName);
// START OF 6364900
mgr.setSessionLocker(new PESessionLocker(ctx));
// END OF 6364900
ctx.setManager(mgr);
if (!((StandardContext)ctx).isSessionTimeoutOveridden()) {
mgr.setMaxInactiveInterval(sessionMaxInactiveInterval);
}
}
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
ctx.setManager( new StandardManager());
ctx.setSessionTimeout(30);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
ctx.setManager( new StandardManager());
ctx.setSessionTimeout(30);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
ctx.setManager( new StandardManager());
ctx.setSessionTimeout(30);
内容来源于网络,如有侵权,请联系作者删除!