01: package org.objectweb.celtix.tools.generators.wsdl2;
02:
03: import java.io.Writer;
04:
05: import org.w3c.dom.Element;
06: import org.w3c.dom.NodeList;
07:
08: import org.objectweb.celtix.helpers.XMLUtils;
09: 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 HANDLER_CHAIN_NAME = "";
20: private JavaInterface intf;
21: private JavaAnnotation handlerChainAnnotation;
22:
23: public HandlerConfigGenerator(JavaInterface i,
24: ProcessorEnvironment env) {
25:
26: this .name = ToolConstants.HANDLER_GENERATOR;
27: this .intf = i;
28: super .setEnvironment(env);
29: }
30:
31: public JavaAnnotation getHandlerAnnotation() {
32: return handlerChainAnnotation;
33: }
34:
35: public boolean passthrough() {
36: if (this .intf.getHandlerChains() == null) {
37: return true;
38: }
39: return false;
40: }
41:
42: public void generate() throws ToolException {
43: if (passthrough()) {
44: return;
45: }
46:
47: Element e = this .intf.getHandlerChains();
48: NodeList nl = e.getElementsByTagNameNS(
49: ToolConstants.HANDLER_CHAINS_URI,
50: ToolConstants.HANDLER_CHAIN);
51: if (nl.getLength() > 0) {
52: String fName = ProcessorUtil
53: .getHandlerConfigFileName(this .intf.getName());
54: handlerChainAnnotation = new JavaAnnotation("HandlerChain");
55: handlerChainAnnotation.addArgument("name",
56: HANDLER_CHAIN_NAME);
57: handlerChainAnnotation.addArgument("file", fName + ".xml");
58: generateHandlerChainFile(e, parseOutputName(this .intf
59: .getPackageName(), fName, ".xml"));
60: }
61: }
62:
63: private void generateHandlerChainFile(Element hChains, Writer writer)
64: throws ToolException {
65: XMLUtils xmlUtils = new XMLUtils();
66: xmlUtils.generateXMLFile(hChains, writer);
67: }
68: }
|