public void engage(CodeGenConfiguration configuration) {
//test the databinding type. If not just fall through
if (testFallThrough(configuration.getDatabindingType())) {
return;
}
try {
// try dummy load of framework classes first to check missing jars
try {
ClassLoader cl = getClass().getClassLoader();
cl.loadClass(JAXB_RI_API_CLASS);
cl.loadClass(JAXB_RI_IMPL_CLASS);
cl.loadClass(JAXB_RI_XJC_CLASS);
} catch (ClassNotFoundException e) {
throw new RuntimeException("JAX-B RI JARs not on classpath");
}
// load the actual utility class
Class clazz = null;
try {
clazz = JAXBRIExtension.class.getClassLoader().loadClass(JAXB_RI_UTILITY_CLASS);
} catch (ClassNotFoundException e) {
throw new RuntimeException("JAX-B RI binding extension not in classpath");
}
// invoke utility class method for actual processing
Method method = clazz.getMethod(JAXB_RI_PROCESS_METHOD,
new Class[] { List.class, Element[].class,
CodeGenConfiguration.class });
List schemas = new ArrayList();
List axisServices = configuration.getAxisServices();
AxisService axisService = null;
for (Iterator iter = axisServices.iterator(); iter.hasNext();) {
axisService = (AxisService)iter.next();
schemas.addAll(axisService.getSchema());
}
Element[] additionalSchemas = loadAdditionalSchemas();
TypeMapper mapper = (TypeMapper)method.invoke(null,
new Object[] { schemas, additionalSchemas,
configuration });
// set the type mapper to the config
configuration.setTypeMapper(mapper);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new RuntimeException(e);
}
}
}
|