KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > hasessionstate > server > HASessionStateService


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 JavaDoc;
27 import javax.management.ObjectName JavaDoc;
28 import javax.management.MalformedObjectNameException JavaDoc;
29
30 import org.jboss.ha.framework.server.ClusterPartitionMBean;
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: 43856 $
39  *
40  * <p><b>Revisions:</b><br>
41  */

42
43 public class HASessionStateService
44    extends ServiceMBeanSupport
45    implements HASessionStateServiceMBean
46 {
47    protected String JavaDoc jndiName;
48    protected String JavaDoc haPartitionName;
49    protected ClusterPartitionMBean clusterPartition;
50    protected long beanCleaningDelay = 0;
51    
52    protected HASessionStateImpl sessionState;
53    
54    public String JavaDoc getName ()
55    {
56       return this.getJndiName ();
57    }
58
59    public String JavaDoc getJndiName ()
60    {
61       return this.jndiName;
62    }
63    
64    public void setJndiName (String JavaDoc newName)
65    {
66       this.jndiName = newName;
67    }
68    
69    public String JavaDoc getPartitionName ()
70    {
71       return this.haPartitionName;
72    }
73    
74    public void setPartitionName (String JavaDoc name)
75    {
76       this.haPartitionName = name;
77    }
78    
79    public ClusterPartitionMBean getClusterPartition()
80    {
81       return clusterPartition;
82    }
83
84    public void setClusterPartition(ClusterPartitionMBean clusterPartition)
85    {
86       this.clusterPartition = clusterPartition;
87    }
88
89    public long getBeanCleaningDelay ()
90    {
91       if (this.sessionState == null)
92          return this.beanCleaningDelay;
93       else
94          return this.sessionState.beanCleaningDelay;
95    }
96    
97    public void setBeanCleaningDelay (long newDelay)
98    { this.beanCleaningDelay = newDelay; }
99    
100    // ******************************************************************
101

102    protected ObjectName JavaDoc getObjectName (MBeanServer JavaDoc server, ObjectName JavaDoc name)
103       throws MalformedObjectNameException JavaDoc
104    {
105       return name == null ? OBJECT_NAME : name;
106    }
107    
108    // ******************************************************************
109

110    
111    protected void createService()
112       throws Exception JavaDoc
113    {
114       if (this.clusterPartition == null)
115       {
116          this.sessionState = new HASessionStateImpl (this.jndiName,
117                this.haPartitionName,
118                     this.beanCleaningDelay);
119       }
120       else
121       {
122          this.sessionState = new HASessionStateImpl (this.jndiName,
123                this.clusterPartition.getHAPartition(),
124                this.beanCleaningDelay);
125       }
126       this.sessionState.init ();
127    }
128
129    protected void startService () throws Exception JavaDoc
130    {
131       this.sessionState.start ();
132    }
133    
134    protected void stopService() throws Exception JavaDoc
135    {
136       this.sessionState.stop ();
137    }
138
139    //[JBCLUSTER-38]
140
protected void destroyService() throws Exception JavaDoc
141    {
142       this.sessionState.destroy();
143       this.sessionState = null;
144    }
145    
146 }
147
148
Popular Tags