public void engage(CodeGenConfiguration configuration) {
//test the databinding type. If not just fall through
if (testFallThrough(configuration.getDatabindingType())) {
return;
}
// check the JiBX binding definition file specified
String typeSystemName = (String)configuration.getProperties().get(TYPESYSTEMNAME_OPTION);
try {
// try dummy load of framework class first to check missing jars
try {
getClass().getClassLoader().loadClass(XMLBEANS_CONFIG_CLASS);
} catch (ClassNotFoundException e) {
throw new RuntimeException("XMLBeans framework jars not in classpath");
}
// load the actual utility class
Class clazz = null;
try {
clazz = getClass().getClassLoader().loadClass(XMLBEANS_UTILITY_CLASS);
} catch (ClassNotFoundException e) {
throw new RuntimeException("XMLBeans binding extension not in classpath");
}
// invoke utility class method for actual processing
Method method = clazz.getMethod(XMLBEANS_PROCESS_METHOD,
new Class[] { List.class, Element[].class,
CodeGenConfiguration.class, String.class });
List schemas = new ArrayList();
List axisServices = configuration.getAxisServices();
AxisService axisService = null;
AxisServiceTopElementSchemaGenerator schemaGenerator = null;
for (Iterator iter = axisServices.iterator(); iter.hasNext();) {
axisService = (AxisService)iter.next();
if (configuration.getProperties().containsKey(
CommandLineOptionConstants.ExtensionArguments.WITHOUT_DATABIND_CODE)){
// use the dummy code
schemaGenerator = new AxisServiceTopElementSchemaGenerator(axisService);
schemas.addAll(schemaGenerator.getDummySchemaList());
} else {
schemas.addAll(axisService.getSchema());
}
}
Element[] additionalSchemas = loadAdditionalSchemas();
TypeMapper mapper = (TypeMapper)method.invoke(null,
new Object[] { schemas, additionalSchemas,
configuration, typeSystemName });
// 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);
}
}
}
|