use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class JcrConverterTest method init.
@Before
public void init() throws Exception {
converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(), new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new DefaultClassResolver()));
ServiceHelper.startService(converter);
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class OsgiTypeConverter method createRegistry.
protected DefaultTypeConverter createRegistry() {
// base the osgi type converter on the default type converter
DefaultTypeConverter answer = new DefaultTypeConverter(new DefaultPackageScanClassResolver() {
@Override
public Set<ClassLoader> getClassLoaders() {
// we don't need any classloaders as we use OSGi service tracker instead
return Collections.emptySet();
}
}, injector, factoryFinder);
// inject CamelContext
answer.setCamelContext(camelContext);
try {
// only load the core type converters, as OSGi activator will keep track on bundles
// being installed/uninstalled and load type converters as part of that process
answer.loadCoreTypeConverters();
} catch (Exception e) {
throw new RuntimeCamelException("Error loading CoreTypeConverter due: " + e.getMessage(), e);
}
// Load the type converters the tracker has been tracking
// Here we need to use the ServiceReference to check the ranking
ServiceReference<TypeConverterLoader>[] serviceReferences = this.tracker.getServiceReferences();
if (serviceReferences != null) {
ArrayList<ServiceReference<TypeConverterLoader>> servicesList = new ArrayList<ServiceReference<TypeConverterLoader>>(Arrays.asList(serviceReferences));
// Just make sure we install the high ranking fallback converter at last
Collections.sort(servicesList);
for (ServiceReference<TypeConverterLoader> sr : servicesList) {
try {
LOG.debug("loading type converter from bundle: {}", sr.getBundle().getSymbolicName());
((TypeConverterLoader) this.tracker.getService(sr)).load(answer);
} catch (Throwable t) {
throw new RuntimeCamelException("Error loading type converters from service: " + sr + " due: " + t.getMessage(), t);
}
}
}
LOG.trace("Created TypeConverter: {}", answer);
return answer;
}
use of org.apache.camel.impl.DefaultPackageScanClassResolver in project camel by apache.
the class ModelSanityCheckerTest method discoverJaxbClasses.
private Set<Class<?>> discoverJaxbClasses() {
PackageScanClassResolver resolver = new DefaultPackageScanClassResolver();
String[] packages = Constants.JAXB_CONTEXT_PACKAGES.split(":");
return resolver.findAnnotated(XmlAccessorType.class, packages);
}
Aggregations