Save This Page
Home » jboss-5.0.0.CR1-src » org.jboss.ha.hasessionstate » server » [javadoc | source]
    1   /*
    2     * JBoss, Home of Professional Open Source
    3     * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4     * by the @authors tag. See the copyright.txt in the distribution for a
    5     * full listing of individual contributors.
    6     *
    7     * This is free software; you can redistribute it and/or modify it
    8     * under the terms of the GNU Lesser General Public License as
    9     * published by the Free Software Foundation; either version 2.1 of
   10     * the License, or (at your option) any later version.
   11     *
   12     * This software is distributed in the hope that it will be useful,
   13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   15     * Lesser General Public License for more details.
   16     *
   17     * You should have received a copy of the GNU Lesser General Public
   18     * License along with this software; if not, write to the Free
   19     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   20     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   21     */
   22   package org.jboss.ha.hasessionstate.server;
   23   
   24   import org.jboss.system.ServiceMBeanSupport;
   25   
   26   import javax.management.MBeanServer;
   27   import javax.management.ObjectName;
   28   import javax.management.MalformedObjectNameException;
   29   
   30   import org.jboss.ha.framework.interfaces.HAPartition;
   31   import org.jboss.ha.hasessionstate.server.HASessionStateImpl;
   32   
   33   /**
   34    *   Service class for HASessionState
   35    *
   36    *   @see org.jboss.ha.hasessionstate.interfaces.HASessionState
   37    *   @author sacha.labourey@cogito-info.ch
   38    *   @version $Revision: 63985 $
   39    *
   40    * <p><b>Revisions:</b><br>
   41    */
   42   
   43   public class HASessionStateService 
   44      extends ServiceMBeanSupport 
   45      implements HASessionStateServiceMBean
   46   {
   47      protected String jndiName;
   48      protected HAPartition clusterPartition;
   49      protected long beanCleaningDelay = 0;   
   50      protected HASessionStateImpl sessionState;
   51      
   52      public String getName ()
   53      {
   54         return this.getJndiName ();
   55      }
   56   
   57      public String getJndiName ()
   58      {
   59         return this.jndiName;
   60      }
   61      
   62      public void setJndiName (String newName)
   63      {
   64         this.jndiName = newName;
   65      }
   66      
   67      public String getPartitionName ()
   68      {
   69         return clusterPartition.getPartitionName();
   70      }
   71      
   72      public HAPartition getHAPartition()
   73      {
   74         return clusterPartition;
   75      }
   76   
   77      public void setHAPartition(HAPartition clusterPartition)
   78      {
   79         this.clusterPartition = clusterPartition;
   80      }
   81   
   82      public long getBeanCleaningDelay ()
   83      {
   84         if (this.sessionState == null)
   85            return this.beanCleaningDelay;
   86         else
   87            return this.sessionState.beanCleaningDelay;
   88      }   
   89      
   90      public void setBeanCleaningDelay (long newDelay)
   91      {
   92         this.beanCleaningDelay = newDelay;
   93      }
   94      
   95      // ******************************************************************
   96      
   97      protected ObjectName getObjectName (MBeanServer server, ObjectName name)
   98         throws MalformedObjectNameException
   99      {
  100         return name == null ? OBJECT_NAME : name;
  101      }
  102      
  103      // ******************************************************************
  104      
  105      
  106      protected void createService()
  107         throws Exception
  108      {
  109         if (clusterPartition == null)
  110         {
  111            throw new IllegalStateException("HAPartition property must be set before starting SessionState service");
  112         }
  113   
  114         sessionState = new HASessionStateImpl (jndiName, clusterPartition, beanCleaningDelay);
  115         sessionState.init ();
  116      }
  117   
  118      protected void startService () throws Exception
  119      {
  120         this.sessionState.start ();
  121      }
  122      
  123      protected void stopService() throws Exception
  124      {
  125         this.sessionState.stop ();
  126      }
  127   
  128      protected void destroyService() throws Exception
  129      {
  130         this.sessionState.destroy();
  131         this.sessionState = null;
  132      }
  133      
  134   }
  135   

Save This Page
Home » jboss-5.0.0.CR1-src » org.jboss.ha.hasessionstate » server » [javadoc | source]