View Javadoc

1   //========================================================================
2   //Copyright (c) Webtide LLC
3   //------------------------------------------------------------------------
4   //All rights reserved. This program and the accompanying materials
5   //are made available under the terms of the Eclipse Public License v1.0
6   //and Apache License v2.0 which accompanies this distribution.
7   //
8   //The Eclipse Public License is available at
9   //http://www.eclipse.org/legal/epl-v10.html
10  //
11  //The Apache License v2.0 is available at
12  //http://www.apache.org/licenses/LICENSE-2.0.txt
13  //
14  //You may elect to redistribute this code under either of these licenses.
15  //========================================================================
16  
17  package org.eclipse.jetty.server.session.jmx;
18  
19  import org.eclipse.jetty.server.handler.AbstractHandlerContainer;
20  import org.eclipse.jetty.server.handler.ContextHandler;
21  import org.eclipse.jetty.server.handler.jmx.AbstractHandlerMBean;
22  import org.eclipse.jetty.server.session.AbstractSessionManager;
23  import org.eclipse.jetty.server.session.SessionHandler;
24  
25  public class AbstractSessionManagerMBean extends AbstractHandlerMBean
26  {
27      public AbstractSessionManagerMBean(Object managedObject)
28      {
29          super(managedObject);
30      }
31  
32      /* ------------------------------------------------------------ */
33      public String getObjectContextBasis()
34      {
35          if (_managed != null && _managed instanceof AbstractSessionManager)
36          {
37              AbstractSessionManager manager = (AbstractSessionManager)_managed;
38              
39              String basis = null;
40              SessionHandler handler = manager.getSessionHandler();
41              if (handler != null)
42              {
43                  ContextHandler context = 
44                      AbstractHandlerContainer.findContainerOf(handler.getServer(), 
45                                                               ContextHandler.class,
46                                                               handler);
47                  if (context != null)
48                      basis = getContextName(context);
49              }
50  
51              if (basis != null)
52                  return basis;
53          }
54          return super.getObjectContextBasis();
55      }
56  }