use of org.apache.camel.impl.converter.DefaultTypeConverter in project camel by apache.
the class DefaultCamelContext method createTypeConverter.
/**
* Lazily create a default implementation
*/
protected TypeConverter createTypeConverter() {
BaseTypeConverterRegistry answer;
if (isLazyLoadTypeConverters()) {
answer = new LazyLoadingTypeConverter(packageScanClassResolver, getInjector(), getDefaultFactoryFinder());
} else {
answer = new DefaultTypeConverter(packageScanClassResolver, getInjector(), getDefaultFactoryFinder());
}
answer.setCamelContext(this);
setTypeConverterRegistry(answer);
return answer;
}
use of org.apache.camel.impl.converter.DefaultTypeConverter 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.converter.DefaultTypeConverter 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;
}
Aggregations