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  package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs;
17  
18  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
19  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
20  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
21  import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
22  import org.apache.geronimo.ews.ws4j2ee.toWs.Writer;
23  import org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.geronimo.InternalBasedWrapperClassWriter;
24  import org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.geronimo.RemoteInterfacedBasedWrapperClassWriter4Geronimo;
25  import org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.jboss.RemoteInterfacedBasedWrapperClassWriter4JBoss;
26  import org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.jonas.RemoteInterfacedBasedWrapperClassWriter4JOnAS;
27  
28  /***
29   * @author Srinath Perera(hemapani@opensource.lk)
30   */
31  public class WrapperClassGeneratorFactory {
32      public static Writer createInstance(J2EEWebServiceContext context) throws GenerationFault {
33          String implStyle = context.getMiscInfo().getImplStyle();
34          String container = context.getMiscInfo().getTargetJ2EEContainer();
35          if (!context.getMiscInfo().isImplwithEJB()) {
36              return new WebEndpointWrapperClassWriter(context);
37          } else if (GenerationConstants.USE_REMOTE.equals(implStyle)
38                  || GenerationConstants.USE_LOCAL_AND_REMOTE.equals(implStyle)) {
39              if (GenerationConstants.JBOSS_CONTAINER.equals(container))
40                  return new RemoteInterfacedBasedWrapperClassWriter4JBoss(context);
41              else if (GenerationConstants.GERONIMO_CONTAINER.equals(container))
42                  return new RemoteInterfacedBasedWrapperClassWriter4Geronimo(context);
43              else if (GenerationConstants.JONAS_CONTAINER.equals(container))
44                  return new RemoteInterfacedBasedWrapperClassWriter4JOnAS(context);
45              else
46                  throw new UnrecoverableGenerationFault("No proper Wrapper Class generator found");
47          } else if (GenerationConstants.USE_LOCAL.equals(implStyle)) {
48              return new SimpleLocalInterfaceBasedWrapperClassWriter(context);
49          } else if (GenerationConstants.USE_INTERNALS.equals(implStyle)) {
50              if (GenerationConstants.JBOSS_CONTAINER.equals(container)) {
51                  //jboss internals
52                  throw new UnrecoverableGenerationFault("This combination not supported" + implStyle + "|" + container);
53              } else if (GenerationConstants.GERONIMO_CONTAINER.equals(container)) {
54                  return new InternalBasedWrapperClassWriter(context);
55              } else if (GenerationConstants.JONAS_CONTAINER.equals(container))
56                  throw new UnrecoverableGenerationFault("This combination not supported" + implStyle + "|" + container);
57              else
58                  throw new UnrecoverableGenerationFault("No proper Wrapper Class generator found");
59          }
60          throw new UnrecoverableGenerationFault("No proper Wrapper Class generator found for " + implStyle + "|" + container);
61      }
62  }