View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.context.impl;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext;
21  import org.apache.geronimo.ews.ws4j2ee.context.MiscInfo;
22  import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
23  import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
24  import org.apache.geronimo.ews.ws4j2ee.context.webservices.client.interfaces.ServiceReferanceContext;
25  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext;
26  import org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext;
27  import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
28  import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
29  
30  import java.util.Vector;
31  
32  /***
33   * <p>Code should use parsers and create runtime representation
34   * of the information taken fom the WSDL and configaration files.</p>
35   * <p>depend on hasWSDL or the not the implementation should
36   * <ol>
37   * <li>parse the WSDL and populate informatio in <code>WSDLContext</code></li>
38   * <li>parse the SEI or EJB and populate the information in <code>WSDLContext</code>
39   * with the help of the jaxrpc mapping file information.
40   * </li>
41   * </ol>
42   * </p>
43   *
44   * @author Srinath Perera(hemapani@opensorce.lk)
45   * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext
46   */
47  public class J2EEWebServiceContextImpl implements J2EEWebServiceContext {
48      private boolean hasWSDL = true;
49      private WSCFContext wscfcontext;
50      private WSDLContext wsdlcontext;
51      private JaxRpcMapperContext jaxrpcmappingcontext;
52      private MiscInfo miscInfo;
53      private Ws4J2eeFactory factory;
54      private Vector srcontext;
55      private EJBContext ejbcontext;
56      private WebContext webcontext;
57  
58      public J2EEWebServiceContextImpl(boolean hasWSDL) {
59          this.hasWSDL = hasWSDL;
60          srcontext = new Vector();
61      }
62  
63      /* (non-Javadoc)
64       * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext#getWSDLContext()
65       */
66      public WSDLContext getWSDLContext() {
67          return wsdlcontext;
68      }
69  
70      /* (non-Javadoc)
71       * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext#setWSDLContext(org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext)
72       */
73      public void setWSDLContext(WSDLContext wsdlcontext) {
74          this.wsdlcontext = wsdlcontext;
75      }
76  
77      /* (non-Javadoc)
78       * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext#getJAXRPCMappingContext()
79       */
80      public JaxRpcMapperContext getJAXRPCMappingContext() {
81          return jaxrpcmappingcontext;
82      }
83  
84      /* (non-Javadoc)
85       * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext#setJAXRPCMappingContext(org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext)
86       */
87      public void setJAXRPCMappingContext(JaxRpcMapperContext context) {
88          this.jaxrpcmappingcontext = context;
89      }
90  
91      public WSCFContext getWSCFContext() {
92          return wscfcontext;
93      }
94  
95      /* (non-Javadoc)
96       * @see org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext#setWSCFContext(org.apache.geronimo.ews.ws4j2ee.context.webservices.interfaces.WSCFContext)
97       */
98      public void setWSCFContext(WSCFContext wscfcontext) {
99          this.wscfcontext = wscfcontext;
100     }
101 
102     public MiscInfo getMiscInfo() {
103         return miscInfo;
104     }
105 
106     /***
107      * @param info
108      */
109     public void setMiscInfo(MiscInfo info) {
110         this.miscInfo = info;
111     }
112 
113     public void validate() {
114         if (wscfcontext == null || miscInfo == null ||
115                 (hasWSDL && wsdlcontext == null) || jaxrpcmappingcontext == null)
116             throw new UnrecoverableGenerationFault("valdation of the j2ee context failed");
117         miscInfo.validate();
118     }
119 
120     public void setFactory(Ws4J2eeFactory factory) {
121         this.factory = factory;
122     }
123 
124     public Ws4J2eeFactory getFactory() {
125         return this.factory;
126     }
127 
128     public void addServiceReferanceContext(ServiceReferanceContext context) {
129         srcontext.add(context);
130     }
131 
132     public EJBContext getEJBDDContext() {
133         return ejbcontext;
134     }
135 
136     public ServiceReferanceContext getServiceReferanceContext(int index) {
137         return (ServiceReferanceContext) srcontext.get(index);
138     }
139 
140     public int getServiceReferanceContextCount() {
141         return srcontext.size();
142     }
143 
144     public WebContext getWebDDContext() {
145         return webcontext;
146     }
147 
148     public void setEJBDDContext(EJBContext context) {
149         this.ejbcontext = context;
150     }
151 
152     public void setWebDDContext(WebContext context) {
153         webcontext = context;
154     }
155 
156 }