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.toWs.handlers;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFHandler;
21  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
22  import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
23  import org.apache.geronimo.ews.ws4j2ee.toWs.Writer;
24  
25  import java.util.HashMap;
26  
27  /***
28   * <p>Genarate the signature of the handlers as given by the webservices.xml file.</p>
29   *
30   * @author Srinath Perera(hemapani@opensource.lk)
31   */
32  public class HandlerGenerator implements Generator {
33      private J2EEWebServiceContext j2eewscontext;
34      private Writer[] writers = new Writer[0];
35  
36      private static HashMap handlermap = new HashMap();
37  
38      static {
39          handlermap.put("org.apache.ws.axis.security.CheckPoint4J2EEHandler",
40                  "org.apache.ws.axis.security.CheckPoint4J2EEHandler");
41      };
42  
43  
44      public HandlerGenerator(J2EEWebServiceContext j2eewscontext) throws GenerationFault {
45          this.j2eewscontext = j2eewscontext;
46          WSCFHandler[] handlers = j2eewscontext.getMiscInfo().getHandlers();
47          if (handlers != null) {
48              writers = new Writer[handlers.length];
49              for (int i = 0; i < handlers.length; i++) {
50                  if (!handlermap.containsKey(handlers[i].getHandlerClass())) {
51                      writers[i] = new HandlerWriter(j2eewscontext, handlers[i]);
52                  }
53              }
54          }
55      }
56  
57      /***
58       * genarate the handlers
59       */
60      public void generate() throws GenerationFault {
61          for (int i = 0; i < writers.length; i++) {
62              if (writers[i] != null) {
63                  writers[i].write();
64              }
65          }
66      }
67  }