KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > tools > generators > wsdl2 > HandlerConfigGenerator


1 package org.objectweb.celtix.tools.generators.wsdl2;
2
3 import java.io.Writer JavaDoc;
4
5 import org.w3c.dom.Element JavaDoc;
6 import org.w3c.dom.NodeList JavaDoc;
7
8 import org.objectweb.celtix.helpers.XMLUtils;
9 import org.objectweb.celtix.tools.common.ProcessorEnvironment;
10 import org.objectweb.celtix.tools.common.ToolConstants;
11 import org.objectweb.celtix.tools.common.ToolException;
12 import org.objectweb.celtix.tools.common.model.JavaAnnotation;
13 import org.objectweb.celtix.tools.common.model.JavaInterface;
14 import org.objectweb.celtix.tools.generators.AbstractGenerator;
15 import org.objectweb.celtix.tools.utils.ProcessorUtil;
16
17 public class HandlerConfigGenerator extends AbstractGenerator {
18
19     private static final String JavaDoc HANDLER_CHAIN_NAME = "";
20     private JavaInterface intf;
21     private JavaAnnotation handlerChainAnnotation;
22   
23     public HandlerConfigGenerator(JavaInterface i, ProcessorEnvironment env) {
24         
25         this.name = ToolConstants.HANDLER_GENERATOR;
26         this.intf = i;
27         super.setEnvironment(env);
28     }
29
30     public JavaAnnotation getHandlerAnnotation() {
31         return handlerChainAnnotation;
32     }
33
34     public boolean passthrough() {
35         if (this.intf.getHandlerChains() == null) {
36             return true;
37         }
38         return false;
39     }
40     
41     public void generate() throws ToolException {
42         if (passthrough()) {
43             return;
44         }
45
46         Element JavaDoc e = this.intf.getHandlerChains();
47         NodeList JavaDoc nl = e.getElementsByTagNameNS(ToolConstants.HANDLER_CHAINS_URI,
48                                                ToolConstants.HANDLER_CHAIN);
49         if (nl.getLength() > 0) {
50             String JavaDoc fName = ProcessorUtil.getHandlerConfigFileName(this.intf.getName());
51             handlerChainAnnotation = new JavaAnnotation("HandlerChain");
52             handlerChainAnnotation.addArgument("name", HANDLER_CHAIN_NAME);
53             handlerChainAnnotation.addArgument("file", fName + ".xml");
54             generateHandlerChainFile(e, parseOutputName(this.intf.getPackageName(),
55                                                         fName,
56                                                         ".xml"));
57         }
58     }
59
60     private void generateHandlerChainFile(Element JavaDoc hChains, Writer JavaDoc writer) throws ToolException {
61         XMLUtils xmlUtils = new XMLUtils();
62         xmlUtils.generateXMLFile(hChains, writer);
63     }
64 }
65
Popular Tags