KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > ClusterConfigMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.metadata;
23
24 import org.w3c.dom.Element JavaDoc;
25
26 import org.jboss.deployment.DeploymentException;
27 import org.jboss.system.server.ServerConfig;
28 import org.jboss.system.server.ServerConfigUtil;
29
30 /**
31  * The meta data object for the cluster-config element.
32  * This element only defines the HAPartition name at this time. It will be
33  * expanded to include other cluster configuration parameters later on.
34
35  * @author <a HREF="mailto:bill@burkecentral.com">Bill Burke</a>.
36  * @version $Revision: 58192 $
37  */

38 public class ClusterConfigMetaData extends MetaData
39 {
40    public final static String JavaDoc JNDI_PREFIX_FOR_SESSION_STATE = "/HASessionState/";
41    public final static String JavaDoc DEFAULT_SESSION_STATE_NAME = JNDI_PREFIX_FOR_SESSION_STATE + "Default";
42
43    private String JavaDoc partitionName = ServerConfigUtil.getDefaultPartitionName();
44    private String JavaDoc homeLoadBalancePolicy = null;
45    private String JavaDoc beanLoadBalancePolicy = null;
46
47    private String JavaDoc haSessionStateName = DEFAULT_SESSION_STATE_NAME;
48
49    public String JavaDoc getPartitionName()
50    {
51       return partitionName;
52    }
53
54    public String JavaDoc getHomeLoadBalancePolicy()
55    {
56       return homeLoadBalancePolicy;
57    }
58
59    public String JavaDoc getBeanLoadBalancePolicy()
60    {
61       return beanLoadBalancePolicy;
62    }
63
64    // SFSB only
65
//
66
public String JavaDoc getHaSessionStateName()
67    {
68       return this.haSessionStateName;
69    }
70
71    public void setPartitionName(String JavaDoc partitionName)
72    {
73       this.partitionName = partitionName;
74    }
75
76    public void setHomeLoadBalancePolicy(String JavaDoc homeLoadBalancePolicy)
77    {
78       this.homeLoadBalancePolicy = homeLoadBalancePolicy;
79    }
80
81    public void setBeanLoadBalancePolicy(String JavaDoc beanLoadBalancePolicy)
82    {
83       this.beanLoadBalancePolicy = beanLoadBalancePolicy;
84    }
85
86    public void setHaSessionStateName(String JavaDoc 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 JavaDoc 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       // SFSB settings only
127
//
128
haSessionStateName = getElementContent(getOptionalChild(element, "session-state-manager-jndi-name"), DEFAULT_SESSION_STATE_NAME);
129    }
130 }
131
Popular Tags