1 25 26 package org.objectweb.jonas_ws.wsgen.modifier; 27 28 import java.io.File ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 32 import org.w3c.dom.Document ; 33 import org.w3c.dom.Element ; 34 35 import org.objectweb.jonas_lib.genbase.GenBaseException; 36 import org.objectweb.jonas_lib.genbase.archive.Archive; 37 import org.objectweb.jonas_lib.genbase.archive.WebApp; 38 import org.objectweb.jonas_lib.genbase.modifier.ArchiveModifier; 39 40 import org.objectweb.jonas_ws.deployment.api.ServiceDesc; 41 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc; 42 import org.objectweb.jonas_ws.wsgen.ddmodifier.WebServicesDDModifier; 43 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier; 44 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier; 45 import org.objectweb.jonas_ws.wsgen.generator.Generator; 46 import org.objectweb.jonas_ws.wsgen.generator.GeneratorFactory; 47 48 import org.objectweb.util.monolog.api.BasicLevel; 49 50 55 public class WebAppModifier extends ArchiveModifier { 56 57 58 private WebApp web; 59 60 66 public WebAppModifier(WebApp webapp) { 67 super(webapp); 68 web = webapp; 69 } 70 71 79 public Archive modify() throws GenBaseException { 80 81 getLogger().log(BasicLevel.INFO, "Processing WebApp " + web.getName()); 82 83 GeneratorFactory gf = GeneratorFactory.getInstance(); 84 Document jwebapp = web.getJonasWebAppDoc(); 85 Document webapp = web.getWebAppDoc(); 86 Document webservices = web.getWebservicesDoc(); 87 88 List refs = web.getServiceRefDescs(); 89 90 for (Iterator i = refs.iterator(); i.hasNext();) { 91 ServiceRefDesc ref = (ServiceRefDesc) i.next(); 92 93 Element base = null; 95 if (jwebapp != null) { 96 base = jwebapp.getDocumentElement(); 97 } 98 WsClientDDModifier ddm = new WsClientDDModifier(ref.getServiceRefName(), jwebapp, base); 99 100 Generator g = gf.newGenerator(ref, ddm, web); 102 g.generate(); 103 g.compile(); 104 105 g.addFiles(web); 107 } 108 109 WsEndpointDDModifier ddm = new WsEndpointDDModifier(webapp); 111 WebServicesDDModifier wsddm = null; 112 if (webservices != null) { 113 wsddm = new WebServicesDDModifier(webservices); 114 } 115 116 List sds = web.getServiceDescs(); 117 118 for (Iterator i = sds.iterator(); i.hasNext();) { 119 ServiceDesc sd = (ServiceDesc) i.next(); 120 121 Generator g = gf.newGenerator(sd, ddm, wsddm, web); 123 g.generate(); 124 g.compile(); 125 126 g.addFiles(web); 128 129 } 130 131 return save(gf.getConfiguration(), "webapps" + File.separator 132 + web.getName()); 133 } 134 } | Popular Tags |