Search in sources :

Example 1 with DynamicXJC

use of io.fabric8.jaxb.dynamic.DynamicXJC in project fabric8 by jboss-fuse.

the class ProfileDynamicJaxbCompiler method recompile.

protected void recompile() {
    LOG.debug("Looking for XSDs to recompile");
    Set<String> urls = new TreeSet<String>();
    FabricService fabric = getFabricService();
    Container container = fabric.getCurrentContainer();
    String versionId = container.getVersion().getId();
    List<String> profileIds = Containers.overlayProfiles(container);
    Collection<String> names = listFiles(versionId, profileIds, schemaPath);
    for (String name : names) {
        if (name.endsWith(".xsd")) {
            String prefix = schemaPath;
            if (Strings.isNotBlank(prefix)) {
                prefix += "/";
            }
            urls.add("profile:" + prefix + name);
        }
    }
    LOG.info("Recompiling XSDs at URLs: " + urls);
    startedFlag.set(false);
    ClassLoader classLoader = AriesFrameworkUtil.getClassLoader(bundleContext.getBundle());
    if (classLoader == null) {
        classLoader = getClass().getClassLoader();
    }
    DynamicXJC xjc = new DynamicXJC(classLoader);
    xjc.setSchemaUrls(new ArrayList<String>(urls));
    compileResults = xjc.compileSchemas();
    if (handler != null) {
        handler.onCompileResults(compileResults);
    }
    if (introspector != null) {
        introspector.setClassLoaderProvider("dynamic.jaxb", new ClassLoaderProvider() {

            @Override
            public ClassLoader getClassLoader() {
                return compileResults.getClassLoader();
            }
        });
    }
}
Also used : Container(io.fabric8.api.Container) TreeSet(java.util.TreeSet) FabricService(io.fabric8.api.FabricService) ClassLoaderProvider(io.hawt.util.introspect.ClassLoaderProvider) DynamicXJC(io.fabric8.jaxb.dynamic.DynamicXJC)

Aggregations

Container (io.fabric8.api.Container)1 FabricService (io.fabric8.api.FabricService)1 DynamicXJC (io.fabric8.jaxb.dynamic.DynamicXJC)1 ClassLoaderProvider (io.hawt.util.introspect.ClassLoaderProvider)1 TreeSet (java.util.TreeSet)1