[jboss-cvs] JBossAS SVN: r63985 - in trunk/cluster/src: main/org/jboss/ha/hasessionstate/server and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 11 17:28:55 EDT 2007
Author: jerrygauth
Date: 2007-07-11 17:28:55 -0400 (Wed, 11 Jul 2007)
New Revision: 63985
Modified:
trunk/cluster/src/etc/cluster-beans.xml
trunk/cluster/src/etc/cluster-service.xml
trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateImpl.java
trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateService.java
trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateServiceMBean.java
Log:
JBAS-4276, partition injection changes for SessionStateService
Modified: trunk/cluster/src/etc/cluster-beans.xml
===================================================================
--- trunk/cluster/src/etc/cluster-beans.xml 2007-07-11 21:16:58 UTC (rev 63984)
+++ trunk/cluster/src/etc/cluster-beans.xml 2007-07-11 21:28:55 UTC (rev 63985)
@@ -148,7 +148,7 @@
<depends>HAPartition</depends>
- <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ <property name="HAPartition"><inject bean="HAPartition"/></property>
<!-- JNDI name under which the service is bound -->
<property name="jndiName">/HASessionState/Default</property>
<!-- Max delay before cleaning unreclaimed state.
Modified: trunk/cluster/src/etc/cluster-service.xml
===================================================================
--- trunk/cluster/src/etc/cluster-service.xml 2007-07-11 21:16:58 UTC (rev 63984)
+++ trunk/cluster/src/etc/cluster-service.xml 2007-07-11 21:28:55 UTC (rev 63985)
@@ -124,7 +124,7 @@
name="jboss:service=HASessionState">
<!-- We now inject the partition into the HA Session State service instead
of requiring that the partition name be passed -->
- <depends optional-attribute-name="ClusterPartition"
+ <depends optional-attribute-name="HAPartition"
proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}</depends>
<!-- JNDI name under which the service is bound -->
<attribute name="JndiName">/HASessionState/Default</attribute>
Modified: trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateImpl.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateImpl.java 2007-07-11 21:16:58 UTC (rev 63984)
+++ trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateImpl.java 2007-07-11 21:28:55 UTC (rev 63985)
@@ -48,7 +48,6 @@
import org.jboss.ha.hasessionstate.interfaces.PackagedSession;
import org.jboss.logging.Logger;
import org.jboss.naming.NonSerializableFactory;
-import org.jboss.system.server.ServerConfigUtil;
import EDU.oswego.cs.dl.util.concurrent.Mutex;
@@ -81,31 +80,26 @@
protected long beanCleaningDelay;
protected String haPartitionName;
- protected String haPartitionJndiName;
- protected final String DEFAULT_PARTITION_JNDI_NAME = ServerConfigUtil.getDefaultPartitionName();
- protected final String JNDI_FOLDER_NAME_FOR_HASESSIONSTATE = org.jboss.metadata.ClusterConfigMetaData.JNDI_PREFIX_FOR_SESSION_STATE;
- protected final String JNDI_FOLDER_NAME_FOR_HAPARTITION = "/HAPartition/";
protected final long MAX_DELAY_BEFORE_CLEANING_UNRECLAIMED_STATE = 30L * 60L * 1000L; // 30 minutes... should be set externally or use cache settings
protected static final String HA_SESSION_STATE_STATE_TRANSFER = "HASessionStateTransfer";
protected HashMap locks = new HashMap ();
- public HASessionStateImpl ()
+ private HASessionStateImpl ()
{}
public HASessionStateImpl (String sessionStateName,
HAPartition partition,
long beanCleaningDelay)
{
- this(sessionStateName, partition.getPartitionName(), beanCleaningDelay);
+ if (partition == null)
+ {
+ throw new IllegalArgumentException("HAPartition must not be null when constructing HASessionImpl");
+ }
+
this.hapGeneral = partition;
- }
-
- public HASessionStateImpl (String sessionStateName,
- String mainHAPartitionName,
- long beanCleaningDelay)
- {
+
if (sessionStateName == null)
this._sessionStateName = org.jboss.metadata.ClusterConfigMetaData.DEFAULT_SESSION_STATE_NAME;
else
@@ -113,37 +107,18 @@
this.sessionStateIdentifier = "SessionState-'" + this._sessionStateName + "'";
- if (mainHAPartitionName == null)
- haPartitionName = DEFAULT_PARTITION_JNDI_NAME;
- else
- haPartitionName = mainHAPartitionName;
+ haPartitionName = partition.getPartitionName();
- haPartitionJndiName = JNDI_FOLDER_NAME_FOR_HAPARTITION + haPartitionName;
-
if (beanCleaningDelay > 0)
this.beanCleaningDelay = beanCleaningDelay;
else
this.beanCleaningDelay = MAX_DELAY_BEFORE_CLEANING_UNRECLAIMED_STATE;
-
}
public void init () throws Exception
{
this.log = Logger.getLogger(HASessionStateImpl.class.getName() + "." + this._sessionStateName);
-
- // BES 20060416 -- if people used an old config, we may not
- // have been passed the partition, so have to find in JNDI
- // JNDI work s/b done in start(), but we have no choice, as
- // we must register for state transfer in init
- if (this.hapGeneral == null)
- {
- Context ctx = new InitialContext ();
- this.hapGeneral = (HAPartition)ctx.lookup (haPartitionJndiName);
- }
- if (hapGeneral == null)
- log.error ("Unable to get default HAPartition under name '" + haPartitionJndiName + "'.");
-
this.hapGeneral.registerRPCHandler (this.sessionStateIdentifier, this);
this.hapGeneral.subscribeToStateTransferEvents (HA_SESSION_STATE_STATE_TRANSFER, this);
}
Modified: trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateService.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateService.java 2007-07-11 21:16:58 UTC (rev 63984)
+++ trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateService.java 2007-07-11 21:28:55 UTC (rev 63985)
@@ -27,7 +27,7 @@
import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;
-import org.jboss.ha.framework.server.ClusterPartitionMBean;
+import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.hasessionstate.server.HASessionStateImpl;
/**
@@ -45,10 +45,8 @@
implements HASessionStateServiceMBean
{
protected String jndiName;
- protected String haPartitionName;
- protected ClusterPartitionMBean clusterPartition;
- protected long beanCleaningDelay = 0;
-
+ protected HAPartition clusterPartition;
+ protected long beanCleaningDelay = 0;
protected HASessionStateImpl sessionState;
public String getName ()
@@ -68,20 +66,15 @@
public String getPartitionName ()
{
- return this.haPartitionName;
+ return clusterPartition.getPartitionName();
}
- public void setPartitionName (String name)
+ public HAPartition getHAPartition()
{
- this.haPartitionName = name;
- }
-
- public ClusterPartitionMBean getClusterPartition()
- {
return clusterPartition;
}
- public void setClusterPartition(ClusterPartitionMBean clusterPartition)
+ public void setHAPartition(HAPartition clusterPartition)
{
this.clusterPartition = clusterPartition;
}
@@ -95,7 +88,9 @@
}
public void setBeanCleaningDelay (long newDelay)
- { this.beanCleaningDelay = newDelay; }
+ {
+ this.beanCleaningDelay = newDelay;
+ }
// ******************************************************************
@@ -111,23 +106,17 @@
protected void createService()
throws Exception
{
- if (this.clusterPartition == null)
+ if (clusterPartition == null)
{
- this.sessionState = new HASessionStateImpl (this.jndiName,
- this.haPartitionName,
- this.beanCleaningDelay);
+ throw new IllegalStateException("HAPartition property must be set before starting SessionState service");
}
- else
- {
- this.sessionState = new HASessionStateImpl (this.jndiName,
- this.clusterPartition.getHAPartition(),
- this.beanCleaningDelay);
- }
- this.sessionState.init ();
+
+ sessionState = new HASessionStateImpl (jndiName, clusterPartition, beanCleaningDelay);
+ sessionState.init ();
}
protected void startService () throws Exception
- {
+ {
this.sessionState.start ();
}
@@ -136,7 +125,6 @@
this.sessionState.stop ();
}
- //[JBCLUSTER-38]
protected void destroyService() throws Exception
{
this.sessionState.destroy();
Modified: trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateServiceMBean.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateServiceMBean.java 2007-07-11 21:16:58 UTC (rev 63984)
+++ trunk/cluster/src/main/org/jboss/ha/hasessionstate/server/HASessionStateServiceMBean.java 2007-07-11 21:28:55 UTC (rev 63985)
@@ -23,7 +23,7 @@
import javax.management.ObjectName;
-import org.jboss.ha.framework.server.ClusterPartitionMBean;
+import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.mx.util.ObjectNameFactory;
/**
@@ -45,35 +45,26 @@
void setJndiName(String newName);
/**
- * Gets the name of the HAPartition used by this service.
+ * Gets the name of the partition used by this service. This is a
+ * convenience method as the partition name is an attribute of HAPartition.
*
* @return the name of the partition
- *
- * @deprecated use {@link #getClusterPartition()}
*/
String getPartitionName();
- /**
- * Sets the name of the HAPartition used by this service.
- *
- * @param name the name of the partition
- *
- * @deprecated use {@link #setClusterPartition(ClusterPartitionMBean)}
- */
- void setPartitionName(String name);
/**
* Get the underlying partition used by this service.
*
* @return the partition
*/
- ClusterPartitionMBean getClusterPartition();
+ HAPartition getHAPartition();
/**
* Sets the underlying partition used by this service.
*
* @param clusterPartition the partition
*/
- void setClusterPartition(ClusterPartitionMBean clusterPartition);
+ void setHAPartition(HAPartition clusterPartition);
long getBeanCleaningDelay();
void setBeanCleaningDelay(long newDelay);
More information about the jboss-cvs-commits
mailing list