1 25 26 package org.objectweb.jonas_ws.wsgen.generator; 27 28 import org.objectweb.jonas_lib.I18n; 29 import org.objectweb.jonas_lib.genbase.GenBaseException; 30 import org.objectweb.jonas_lib.genbase.archive.Archive; 31 import org.objectweb.jonas_lib.genbase.generator.Config; 32 33 import org.objectweb.jonas_ws.deployment.api.ServiceDesc; 34 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc; 35 import org.objectweb.jonas_ws.wsgen.WsGenException; 36 import org.objectweb.jonas_ws.wsgen.ddmodifier.WebServicesDDModifier; 37 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier; 38 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier; 39 40 import org.objectweb.jonas.common.JProp; 41 import org.objectweb.jonas.common.Log; 42 43 import org.objectweb.util.monolog.api.BasicLevel; 44 import org.objectweb.util.monolog.api.Logger; 45 46 55 public abstract class GeneratorFactory implements org.objectweb.jonas_lib.genbase.generator.GeneratorFactory { 56 57 60 public static final String GENERATOR_FACTORY = "jonas.service.ws.wsgen.generator.factory"; 61 62 65 public static final String GENERATOR_FACTORY_DEFAULT = "org.objectweb.jonas_ws.wsgen.generator.axis.AxisGeneratorFactory"; 66 67 68 private static GeneratorFactory instance = null; 69 70 71 private static I18n i18n = I18n.getInstance(GeneratorFactory.class); 72 73 74 private static Logger logger = Log.getLogger(Log.JONAS_WSGEN_PREFIX); 75 76 77 private Config configuration; 78 79 86 public static GeneratorFactory getInstance() throws WsGenException { 87 if (instance == null) { 88 instance = newInstance(); 89 } 90 91 return instance; 92 } 93 94 105 private static GeneratorFactory newInstance() throws WsGenException { 106 JProp jp; 108 String classname = null; 109 110 try { 111 jp = JProp.getInstance(); 112 classname = jp.getValue(GENERATOR_FACTORY, GENERATOR_FACTORY_DEFAULT); 113 } catch (Exception e) { 114 logger.log(BasicLevel.WARN, "Cannot get '" + GENERATOR_FACTORY + "' value, default used : '" 116 + GENERATOR_FACTORY_DEFAULT + "'"); 117 classname = GENERATOR_FACTORY_DEFAULT; 118 } 119 120 GeneratorFactory gf = null; 122 123 try { 124 ClassLoader jcl = Thread.currentThread().getContextClassLoader(); 125 Class gfc = jcl.loadClass(classname); 126 gf = (GeneratorFactory) gfc.newInstance(); 127 } catch (Exception e) { 128 String err = i18n.getMessage("GeneratorFactory.newInstance.instance", classname); 129 throw new WsGenException(err, e); 130 } 131 132 return gf; 133 134 } 135 136 148 public abstract WsClientGenerator newGenerator(ServiceRefDesc serviceRef, WsClientDDModifier ddm, Archive archive) 149 throws GenBaseException; 150 151 163 public abstract WsEndpointGenerator newGenerator(ServiceDesc serviceDesc, WsEndpointDDModifier ddm, 164 WebServicesDDModifier wsddm, Archive arch) throws GenBaseException; 165 166 171 public void setConfiguration(Config config) { 172 this.configuration = config; 173 } 174 175 180 public Config getConfiguration() { 181 return configuration; 182 } 183 } | Popular Tags |