00001
00026 package org.objectweb.jonas_ws.wsgen.generator;
00027
00028 import org.objectweb.jonas_lib.I18n;
00029 import org.objectweb.jonas_lib.genbase.GenBaseException;
00030 import org.objectweb.jonas_lib.genbase.archive.Archive;
00031 import org.objectweb.jonas_lib.genbase.generator.Config;
00032
00033 import org.objectweb.jonas_ws.deployment.api.ServiceDesc;
00034 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
00035 import org.objectweb.jonas_ws.wsgen.WsGenException;
00036 import org.objectweb.jonas_ws.wsgen.ddmodifier.WebServicesDDModifier;
00037 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier;
00038 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier;
00039
00040 import org.objectweb.jonas.common.JProp;
00041 import org.objectweb.jonas.common.Log;
00042
00043 import org.objectweb.util.monolog.api.BasicLevel;
00044 import org.objectweb.util.monolog.api.Logger;
00045
00055 public abstract class GeneratorFactory implements org.objectweb.jonas_lib.genbase.generator.GeneratorFactory {
00056
00060 public static final String GENERATOR_FACTORY = "jonas.service.ws.wsgen.generator.factory";
00061
00065 public static final String GENERATOR_FACTORY_DEFAULT = "org.objectweb.jonas_ws.wsgen.generator.axis.AxisGeneratorFactory";
00066
00068 private static GeneratorFactory instance = null;
00069
00071 private static I18n i18n = I18n.getInstance(GeneratorFactory.class);
00072
00074 private static Logger logger = Log.getLogger(Log.JONAS_WSGEN_PREFIX);
00075
00077 private Config configuration;
00078
00086 public static GeneratorFactory getInstance() throws WsGenException {
00087 if (instance == null) {
00088 instance = newInstance();
00089 }
00090
00091 return instance;
00092 }
00093
00105 private static GeneratorFactory newInstance() throws WsGenException {
00106
00107 JProp jp;
00108 String classname = null;
00109
00110 try {
00111 jp = JProp.getInstance();
00112 classname = jp.getValue(GENERATOR_FACTORY, GENERATOR_FACTORY_DEFAULT);
00113 } catch (Exception e) {
00114
00115 logger.log(BasicLevel.WARN, "Cannot get '" + GENERATOR_FACTORY + "' value, default used : '"
00116 + GENERATOR_FACTORY_DEFAULT + "'");
00117 classname = GENERATOR_FACTORY_DEFAULT;
00118 }
00119
00120
00121 GeneratorFactory gf = null;
00122
00123 try {
00124 ClassLoader jcl = Thread.currentThread().getContextClassLoader();
00125 Class gfc = jcl.loadClass(classname);
00126 gf = (GeneratorFactory) gfc.newInstance();
00127 } catch (Exception e) {
00128 String err = i18n.getMessage("GeneratorFactory.newInstance.instance", classname);
00129 throw new WsGenException(err, e);
00130 }
00131
00132 return gf;
00133
00134 }
00135
00148 public abstract WsClientGenerator newGenerator(ServiceRefDesc serviceRef, WsClientDDModifier ddm, Archive archive)
00149 throws GenBaseException;
00150
00163 public abstract WsEndpointGenerator newGenerator(ServiceDesc serviceDesc, WsEndpointDDModifier ddm,
00164 WebServicesDDModifier wsddm, Archive arch) throws GenBaseException;
00165
00171 public void setConfiguration(Config config) {
00172 this.configuration = config;
00173 }
00174
00180 public Config getConfiguration() {
00181 return configuration;
00182 }
00183 }