KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.HashMap JavaDoc;
25
26 import org.jboss.deployment.DeploymentException;
27 import org.w3c.dom.Element JavaDoc;
28
29 /** The meta data information specific to session beans.
30  *
31  * @author <a HREF="mailto:sebastien.alborini@m4x.org">Sebastien Alborini</a>
32  * @author Scott.Stark@jboss.org
33  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>.
34  * @version $Revision: 58473 $
35  */

36 public class SessionMetaData extends BeanMetaData
37 {
38    // Constants -----------------------------------------------------
39
public static final String JavaDoc DEFAULT_STATEFUL_INVOKER = "stateful-unified-invoker";
40    public static final String JavaDoc DEFAULT_CLUSTERED_STATEFUL_INVOKER = "clustered-stateful-rmi-invoker";
41    public static final String JavaDoc DEFAULT_STATELESS_INVOKER = "stateless-unified-invoker";
42    public static final String JavaDoc DEFAULT_CLUSTERED_STATELESS_INVOKER = "clustered-stateless-rmi-invoker";
43
44    // Attributes ----------------------------------------------------
45
/** whether it is a stateful or stateless bean */
46    private boolean stateful;
47
48    // Static --------------------------------------------------------
49

50    // Constructors --------------------------------------------------
51
public SessionMetaData(ApplicationMetaData app)
52    {
53       super(app, BeanMetaData.SESSION_TYPE);
54    }
55
56    // Public --------------------------------------------------------
57
public boolean isStateful()
58    {
59       return stateful;
60    }
61    
62    public void setStateful(boolean stateful)
63    {
64       this.stateful = stateful;
65    }
66
67    public boolean isStateless()
68    {
69       return !stateful;
70    }
71
72    public String JavaDoc getDefaultConfigurationName()
73    {
74       if (isStateful())
75       {
76          if (this.isClustered())
77             return ConfigurationMetaData.CLUSTERED_STATEFUL_13;
78          else
79             return ConfigurationMetaData.STATEFUL_13;
80       }
81       else
82       {
83          if (this.isClustered())
84             return ConfigurationMetaData.CLUSTERED_STATELESS_13;
85          else
86             return ConfigurationMetaData.STATELESS_13;
87       }
88    }
89
90    protected void defaultInvokerBindings()
91    {
92       invokerBindings = new HashMap JavaDoc();
93       if (isClustered())
94       {
95          if (stateful)
96          {
97             invokerBindings.put(DEFAULT_CLUSTERED_STATEFUL_INVOKER,
98                getJndiName());
99          }
100          else
101          {
102             invokerBindings.put(DEFAULT_CLUSTERED_STATELESS_INVOKER,
103                getJndiName());
104          }
105       }
106       else
107       {
108          if (stateful)
109          {
110             invokerBindings.put(DEFAULT_STATEFUL_INVOKER, getJndiName());
111          }
112          else
113          {
114             invokerBindings.put(DEFAULT_STATELESS_INVOKER, getJndiName());
115          }
116       }
117    }
118
119    public void importEjbJarXml(Element JavaDoc element) throws DeploymentException
120    {
121       super.importEjbJarXml(element);
122
123       // set the session type
124
String JavaDoc sessionType = getElementContent(getUniqueChild(element, "session-type"));
125       if (sessionType.equals("Stateful"))
126       {
127          stateful = true;
128       }
129       else if (sessionType.equals("Stateless"))
130       {
131          stateful = false;
132       }
133       else
134       {
135          throw new DeploymentException("session type should be 'Stateful' or 'Stateless'");
136       }
137
138       // set the transaction type
139
String JavaDoc transactionType = getElementContent(getUniqueChild(element, "transaction-type"));
140       if (transactionType.equals("Bean"))
141       {
142          containerManagedTx = false;
143       }
144       else if (transactionType.equals("Container"))
145       {
146          containerManagedTx = true;
147       }
148       else
149       {
150          throw new DeploymentException("transaction type should be 'Bean' or 'Container'");
151       }
152
153       serviceEndpointClass = getElementContent(getOptionalChild(element, "service-endpoint"));
154    }
155
156    public void importJbossXml(Element JavaDoc element) throws DeploymentException
157    {
158       super.importJbossXml(element);
159       // port-component optional element
160
Element JavaDoc portElement = getOptionalChild(element, "port-component");
161       if (portElement != null)
162       {
163          portComponent = new EjbPortComponentMetaData(this);
164          portComponent.importJBossXml(portElement);
165       }
166    }
167
168 }
169
Popular Tags