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.metadata;
023:
024: import org.w3c.dom.Element;
025:
026: import org.jboss.deployment.DeploymentException;
027: import org.jboss.system.server.ServerConfig;
028: import org.jboss.system.server.ServerConfigUtil;
029:
030: /**
031: * The meta data object for the cluster-config element.
032: * This element only defines the HAPartition name at this time. It will be
033: * expanded to include other cluster configuration parameters later on.
034:
035: * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>.
036: * @version $Revision: 57209 $
037: */
038: public class ClusterConfigMetaData extends MetaData {
039: public final static String JNDI_PREFIX_FOR_SESSION_STATE = "/HASessionState/";
040: public final static String DEFAULT_SESSION_STATE_NAME = JNDI_PREFIX_FOR_SESSION_STATE
041: + "Default";
042:
043: private String partitionName = ServerConfigUtil
044: .getDefaultPartitionName();
045: private String homeLoadBalancePolicy = null;
046: private String beanLoadBalancePolicy = null;
047:
048: private String haSessionStateName = DEFAULT_SESSION_STATE_NAME;
049:
050: public String getPartitionName() {
051: return partitionName;
052: }
053:
054: public String getHomeLoadBalancePolicy() {
055: return homeLoadBalancePolicy;
056: }
057:
058: public String getBeanLoadBalancePolicy() {
059: return beanLoadBalancePolicy;
060: }
061:
062: // SFSB only
063: //
064: public String getHaSessionStateName() {
065: return this .haSessionStateName;
066: }
067:
068: public void init(BeanMetaData data) {
069: homeLoadBalancePolicy = "org.jboss.ha.framework.interfaces.RoundRobin";
070: if (beanLoadBalancePolicy == null) {
071: if (data.isSession()) {
072: if (((SessionMetaData) data).isStateful()) {
073: beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable";
074: } else {
075: beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.RoundRobin";
076: }
077: } else if (data.isEntity()) {
078: beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable";
079: } else {
080: beanLoadBalancePolicy = "org.jboss.ha.framework.interfaces.FirstAvailable";
081: }
082: }
083: }
084:
085: public void importJbossXml(Element element)
086: throws DeploymentException {
087: partitionName = getElementContent(getOptionalChild(element,
088: "partition-name"), null);
089: if (partitionName == null)
090: partitionName = ServerConfigUtil.getDefaultPartitionName();
091: homeLoadBalancePolicy = getElementContent(getOptionalChild(
092: element, "home-load-balance-policy"),
093: homeLoadBalancePolicy);
094: beanLoadBalancePolicy = getElementContent(getOptionalChild(
095: element, "bean-load-balance-policy"),
096: beanLoadBalancePolicy);
097:
098: // SFSB settings only
099: //
100: haSessionStateName = getElementContent(getOptionalChild(
101: element, "session-state-manager-jndi-name"),
102: DEFAULT_SESSION_STATE_NAME);
103: }
104: }
|