1 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.server.ClusterPartitionMBean; 31 import org.jboss.ha.hasessionstate.server.HASessionStateImpl; 32 33 42 43 public class HASessionStateService 44 extends ServiceMBeanSupport 45 implements HASessionStateServiceMBean 46 { 47 protected String jndiName; 48 protected String haPartitionName; 49 protected ClusterPartitionMBean clusterPartition; 50 protected long beanCleaningDelay = 0; 51 52 protected HASessionStateImpl sessionState; 53 54 public String getName () 55 { 56 return this.getJndiName (); 57 } 58 59 public String getJndiName () 60 { 61 return this.jndiName; 62 } 63 64 public void setJndiName (String newName) 65 { 66 this.jndiName = newName; 67 } 68 69 public String getPartitionName () 70 { 71 return this.haPartitionName; 72 } 73 74 public void setPartitionName (String 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 102 protected ObjectName getObjectName (MBeanServer server, ObjectName name) 103 throws MalformedObjectNameException 104 { 105 return name == null ? OBJECT_NAME : name; 106 } 107 108 110 111 protected void createService() 112 throws Exception 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 130 { 131 this.sessionState.start (); 132 } 133 134 protected void stopService() throws Exception 135 { 136 this.sessionState.stop (); 137 } 138 139 protected void destroyService() throws Exception 141 { 142 this.sessionState.destroy(); 143 this.sessionState = null; 144 } 145 146 } 147 148 | Popular Tags |