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 java.util.Map;
20  
21  import org.apache.axis.wsdl.symbolTable.SymbolTable;
22  import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
23  import org.apache.geronimo.ews.jaxrpcmapping.JaxRpcMapper;
24  import org.apache.geronimo.ews.ws4j2ee.context.ContextFactory;
25  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
26  import org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext;
27  import org.apache.geronimo.ews.ws4j2ee.context.MiscInfo;
28  import org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext;
29  import org.apache.geronimo.ews.ws4j2ee.context.wsdl.impl.AxisWSDLContext;
30  import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
31  
32  /***
33   * <p>This class decouple the concreate implementations of the
34   * class from the rest of the code</p>
35   *
36   * @author Srinath Perera(hemapani@opensource.lk)
37   */
38  public class ContextFactoryImpl implements ContextFactory {
39      private J2EEWebServiceContext currentContext;
40  
41      public WSDLContext createWSDLContext(Object info) {
42          if (info instanceof SymbolTable)
43              return new AxisWSDLContext((SymbolTable) info);
44          throw new UnrecoverableGenerationFault("unknown context type");
45      }
46  
47      public JaxRpcMapperContext createJaxRpcMapperContext(JaxRpcMapper mapper, J2eeEmitter emitter) {
48          return new JaxRpcMapperImpl(mapper, emitter);
49      }
50  
51  //    public WSCFContext createWSCFContext(InputStream in)
52  //        throws GenerationFault {
53  //        try {
54  //            return new WSCFContextImpl(in);
55  //        } catch (WSCFException e) {
56  //            e.printStackTrace();
57  //            throw new GenerationFault(e.getMessage());
58  //        }
59  //    }
60  
61      public MiscInfo createMiscInfo(Map map) {
62          return new MiscInfoImpl(map);
63      }
64  
65  //    public static J2EEWebServiceContext getCurrentJ2EEWsContext() {
66  //        return currentContext;
67  //    }
68      public J2EEWebServiceContext getJ2EEWsContext(boolean hasWSDL) {
69          currentContext = new J2EEWebServiceContextImpl(hasWSDL);
70          return currentContext;
71      }
72  
73  }