1 22 package org.jboss.metadata; 23 24 import org.w3c.dom.Element ; 25 26 import org.jboss.deployment.DeploymentException; 27 import org.jboss.system.server.ServerConfig; 28 import org.jboss.system.server.ServerConfigUtil; 29 30 38 public class ClusterConfigMetaData extends MetaData 39 { 40 public final static String JNDI_PREFIX_FOR_SESSION_STATE = "/HASessionState/"; 41 public final static String DEFAULT_SESSION_STATE_NAME = JNDI_PREFIX_FOR_SESSION_STATE + "Default"; 42 43 private String partitionName = ServerConfigUtil.getDefaultPartitionName(); 44 private String homeLoadBalancePolicy = null; 45 private String beanLoadBalancePolicy = null; 46 47 private String haSessionStateName = DEFAULT_SESSION_STATE_NAME; 48 49 public String getPartitionName() 50 { 51 return partitionName; 52 } 53 54 public String getHomeLoadBalancePolicy() 55 { 56 return homeLoadBalancePolicy; 57 } 58 59 public String getBeanLoadBalancePolicy() 60 { 61 return beanLoadBalancePolicy; 62 } 63 64 public String getHaSessionStateName() 67 { 68 return this.haSessionStateName; 69 } 70 71 public void setPartitionName(String partitionName) 72 { 73 this.partitionName = partitionName; 74 } 75 76 public void setHomeLoadBalancePolicy(String homeLoadBalancePolicy) 77 { 78 this.homeLoadBalancePolicy = homeLoadBalancePolicy; 79 } 80 81 public void setBeanLoadBalancePolicy(String beanLoadBalancePolicy) 82 { 83 this.beanLoadBalancePolicy = beanLoadBalancePolicy; 84 } 85 86 public void setHaSessionStateName(String haSessionStateName) 87 { 88 this.haSessionStateName = haSessionStateName; 89 } 90 91 public void init(BeanMetaData data) 92 { 93 homeLoadBalancePolicy = "org.jboss.ha.framework.interfaces.RoundRobin"; 94 if (beanLoadBalancePolicy == null) 95 { 96 if (data.isSession()) 97 { 98 if (((SessionMetaData) data).isStateful()) 99 { 100 beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable"; 101 } 102 else 103 { 104 beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.RoundRobin"; 105 } 106 } 107 else if (data.isEntity()) 108 { 109 beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable"; 110 } 111 else 112 { 113 beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable"; 114 } 115 } 116 } 117 118 public void importJbossXml(Element element) throws DeploymentException 119 { 120 partitionName = getElementContent(getOptionalChild(element, "partition-name"), null); 121 if (partitionName == null) 122 partitionName = ServerConfigUtil.getDefaultPartitionName(); 123 homeLoadBalancePolicy = getElementContent(getOptionalChild(element, "home-load-balance-policy"), homeLoadBalancePolicy); 124 beanLoadBalancePolicy = getElementContent(getOptionalChild(element, "bean-load-balance-policy"), beanLoadBalancePolicy); 125 126 haSessionStateName = getElementContent(getOptionalChild(element, "session-state-manager-jndi-name"), DEFAULT_SESSION_STATE_NAME); 129 } 130 } 131 | Popular Tags |