1 package org.objectweb.celtix.tools.generators.wsdl2; 2 3 import java.io.Writer ; 4 5 import org.w3c.dom.Element ; 6 import org.w3c.dom.NodeList ; 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 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 e = this.intf.getHandlerChains(); 47 NodeList nl = e.getElementsByTagNameNS(ToolConstants.HANDLER_CHAINS_URI, 48 ToolConstants.HANDLER_CHAIN); 49 if (nl.getLength() > 0) { 50 String 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 hChains, Writer writer) throws ToolException { 61 XMLUtils xmlUtils = new XMLUtils(); 62 xmlUtils.generateXMLFile(hChains, writer); 63 } 64 } 65 | Popular Tags |