KickJava   Java API By Example, From Geeks To Geeks.

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


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 // $Id: EjbPortComponentMetaData.java 58231 2006-11-09 13:52:10Z alex.loubyansky@jboss.com $
25

26 import java.util.StringTokenizer JavaDoc;
27
28 import org.jboss.deployment.DeploymentException;
29 import org.w3c.dom.Element JavaDoc;
30
31 /** The metdata data for session/port-component element from jboss.xml
32  *
33  * @author Scott.Stark@jboss.org
34  * @version $Revision: 58231 $
35  */

36 public class EjbPortComponentMetaData
37 {
38    private SessionMetaData sessionMetaData;
39
40    private String JavaDoc portComponentName;
41    private String JavaDoc portComponentURI;
42    private String JavaDoc authMethod;
43    private String JavaDoc transportGuarantee;
44    
45    public EjbPortComponentMetaData(SessionMetaData sessionMetaData)
46    {
47       this.sessionMetaData = sessionMetaData;
48       portComponentURI = "/" + sessionMetaData.getEjbName();
49    }
50
51    public String JavaDoc getPortComponentName()
52    {
53       return portComponentName;
54    }
55
56    public String JavaDoc getPortComponentURI()
57    {
58       return portComponentURI;
59    }
60
61    public String JavaDoc getURLPattern()
62    {
63       String JavaDoc pattern = "/*";
64       if (portComponentURI != null)
65       {
66          return portComponentURI;
67       }
68       return pattern;
69    }
70
71    public String JavaDoc getAuthMethod()
72    {
73       return authMethod;
74    }
75
76    public String JavaDoc getTransportGuarantee()
77    {
78       return transportGuarantee;
79    }
80
81    public void setPortComponentName(String JavaDoc portComponentName)
82    {
83       this.portComponentName = portComponentName;
84    }
85
86    public void setPortComponentURI(String JavaDoc portComponentURI)
87    {
88       ApplicationMetaData appMetaData = sessionMetaData.getApplicationMetaData();
89       String JavaDoc contextRoot = appMetaData.getWebServiceContextRoot();
90
91       if(portComponentURI.charAt(0) != '/')
92       {
93          portComponentURI = "/" + portComponentURI;
94       }
95
96       if(contextRoot == null)
97       {
98          // The first token is the webservice context root
99
StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(portComponentURI, "/");
100          if(st.countTokens() < 2)
101          {
102             throw new IllegalStateException JavaDoc("Expected at least two tokens <port-component-uri>");
103          }
104
105          contextRoot = "/" + st.nextToken();
106          String JavaDoc prevContextRoot = contextRoot;
107          if(prevContextRoot != null && prevContextRoot.equals(contextRoot) == false)
108          {
109             throw new IllegalStateException JavaDoc("Invalid <port-component-uri>, expected to start with: " + prevContextRoot);
110          }
111
112          appMetaData.setWebServiceContextRoot(contextRoot);
113          portComponentURI = portComponentURI.substring(portComponentURI.indexOf('/', 1));
114       }
115       else if(portComponentURI.startsWith(contextRoot))
116       {
117          portComponentURI = portComponentURI.substring(contextRoot.length());
118       }
119    }
120
121    public void setAuthMethod(String JavaDoc authMethod)
122    {
123       this.authMethod = authMethod;
124    }
125
126    public void setTransportGuarantee(String JavaDoc transportGuarantee)
127    {
128       this.transportGuarantee = transportGuarantee;
129    }
130
131    public void importStandardXml(Element JavaDoc element)
132       throws DeploymentException
133    {
134    }
135
136    /** Parse the port-component contents
137     * @param element
138     * @throws DeploymentException
139     */

140    public void importJBossXml(Element JavaDoc element) throws DeploymentException
141    {
142       // port-component/port-component-name
143
portComponentName = MetaData.getUniqueChildContent(element, "port-component-name");
144       
145       // port-component/port-component-uri?
146
portComponentURI = MetaData.getOptionalChildContent(element, "port-component-uri");
147       if(portComponentURI != null)
148       {
149          setPortComponentURI(portComponentURI);
150       }
151       else
152       {
153          portComponentURI = "/" + sessionMetaData.getEjbName();
154          // The context root will be derived from deployment short name
155
}
156
157       // port-component/auth-method?,
158
authMethod = MetaData.getOptionalChildContent(element, "auth-method");
159       // port-component/transport-guarantee?
160
transportGuarantee = MetaData.getOptionalChildContent(element, "transport-guarantee");
161
162       // Deprecated in jboss-4.0.1
163
if (MetaData.getOptionalChildContent(element, "port-uri") != null)
164          throw new DeploymentException("Deprecated element <port-uri>, use <port-component-uri> instead");
165    }
166 }
167
Popular Tags