001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ha.hasessionstate.server;
023:
024: import org.jboss.system.ServiceMBeanSupport;
025:
026: import javax.management.MBeanServer;
027: import javax.management.ObjectName;
028: import javax.management.MalformedObjectNameException;
029:
030: import org.jboss.ha.framework.server.ClusterPartitionMBean;
031: import org.jboss.ha.hasessionstate.server.HASessionStateImpl;
032:
033: /**
034: * Service class for HASessionState
035: *
036: * @see org.jboss.ha.hasessionstate.interfaces.HASessionState
037: * @author sacha.labourey@cogito-info.ch
038: * @version $Revision: 57188 $
039: *
040: * <p><b>Revisions:</b><br>
041: */
042:
043: public class HASessionStateService extends ServiceMBeanSupport
044: implements HASessionStateServiceMBean {
045: protected String jndiName;
046: protected String haPartitionName;
047: protected ClusterPartitionMBean clusterPartition;
048: protected long beanCleaningDelay = 0;
049:
050: protected HASessionStateImpl sessionState;
051:
052: public String getName() {
053: return this .getJndiName();
054: }
055:
056: public String getJndiName() {
057: return this .jndiName;
058: }
059:
060: public void setJndiName(String newName) {
061: this .jndiName = newName;
062: }
063:
064: public String getPartitionName() {
065: return this .haPartitionName;
066: }
067:
068: public void setPartitionName(String name) {
069: this .haPartitionName = name;
070: }
071:
072: public ClusterPartitionMBean getClusterPartition() {
073: return clusterPartition;
074: }
075:
076: public void setClusterPartition(
077: ClusterPartitionMBean clusterPartition) {
078: this .clusterPartition = clusterPartition;
079: }
080:
081: public long getBeanCleaningDelay() {
082: if (this .sessionState == null)
083: return this .beanCleaningDelay;
084: else
085: return this .sessionState.beanCleaningDelay;
086: }
087:
088: public void setBeanCleaningDelay(long newDelay) {
089: this .beanCleaningDelay = newDelay;
090: }
091:
092: // ******************************************************************
093:
094: protected ObjectName getObjectName(MBeanServer server,
095: ObjectName name) throws MalformedObjectNameException {
096: return name == null ? OBJECT_NAME : name;
097: }
098:
099: // ******************************************************************
100:
101: protected void createService() throws Exception {
102: if (this .clusterPartition == null) {
103: this .sessionState = new HASessionStateImpl(this .jndiName,
104: this .haPartitionName, this .beanCleaningDelay);
105: } else {
106: this .sessionState = new HASessionStateImpl(this .jndiName,
107: this .clusterPartition.getHAPartition(),
108: this .beanCleaningDelay);
109: }
110: this .sessionState.init();
111: }
112:
113: protected void startService() throws Exception {
114: this .sessionState.start();
115: }
116:
117: protected void stopService() throws Exception {
118: this .sessionState.stop();
119: }
120:
121: //NR 200505:[JBCLUSTER-38]
122: protected void destroyService() throws Exception {
123: this.sessionState.destroy();
124: this.sessionState = null;
125: }
126:
127: }
|