public synchronized ExpressionFactory getExpressionFactory(CamelContext context) { if (expressionFactory == null && context != null) { try { FactoryFinder finder = context.getFactoryFinder("META-INF/services/org/apache/camel/language/"); Class<?> clazz = finder.findClass("el", "impl.", ExpressionFactory.class); if (clazz != null) { expressionFactory = (ExpressionFactory)clazz.newInstance(); } } catch (ClassNotFoundException e) { LOG.debug("'impl.class' not found", e); } catch (IOException e) { LOG.debug("No impl class for juel ExpressionFactory defined in 'META-INF/services/org/apache/camel/language/el'", e); } catch (InstantiationException e) { LOG.debug("Failed to instantiate juel ExpressionFactory implementation class.", e); } catch (IllegalAccessException e) { LOG.debug("Failed to instantiate juel ExpressionFactory implementation class.", e); } } return getExpressionFactory(); }
@SuppressWarnings("unchecked") public static CamelReactiveStreamsServiceFactory resolveServiceFactory(CamelContext context, String serviceType) { try { FactoryFinder finder = context.getFactoryFinder(ReactiveStreamsConstants.SERVICE_PATH); Class<?> serviceClass = finder.findClass(serviceType); return (CamelReactiveStreamsServiceFactory)context.getInjector().newInstance(serviceClass); } catch (ClassNotFoundException e) { throw new IllegalStateException("Class referenced in '" + ReactiveStreamsConstants.SERVICE_PATH + serviceType + "' not found", e); } catch (Exception e) { throw new IllegalStateException("Unable to create the reactive stream service defined in '" + ReactiveStreamsConstants.SERVICE_PATH + serviceType + "'", e); } } }
public synchronized EventCacheManager getEventCacheManager(CamelContext context, String type) throws Exception { EventCacheManager eventCacheManager = cacheMap.get(type); if (eventCacheManager == null) { FactoryFinder ff = context.getFactoryFinder("META-INF/services/org/fusesource/eca/eventcache/"); if (ff != null) { eventCacheManager = (EventCacheManager) ff.newInstance(type); cacheMap.put(type, eventCacheManager); if (context.getStatus().isStarted()) { eventCacheManager.start(); } } } return eventCacheManager; }
public synchronized EventEngine getEventEngine(CamelContext context, String type) throws Exception { EventEngine eventEngine = engineMap.get(type); if (eventEngine == null) { FactoryFinder ff = context.getFactoryFinder("META-INF/services/org/fusesource/eca/engine/"); if (ff != null) { eventEngine = (EventEngine) ff.newInstance(type); eventEngine.initialize(context, type); engineMap.put(type, eventEngine); if (context.getStatus().isStarted() || context.getStatus().isStarting()) { eventEngine.start(); } } } return eventEngine; }
/** * Try resolve binding creator for given endpoint name. * * @param name Name of endpoint, eg. DirectEndpoint. * @param context Camel context instance. * @return Dedicated BindingDataCreator or default if none found. */ public BindingDataCreator<?> resolveBindingCreator(String name, CamelContext context) { Class<?> type = null; try { if (_bindingDataCreatorFactory == null) { _bindingDataCreatorFactory = context.getFactoryFinder(BINDING_DATA_CREATOR_RESOURCE_PATH); } type = _bindingDataCreatorFactory.findClass(name); } catch (NoFactoryAvailableException e) { e.getMessage(); // ignore } catch (Exception e) { throw CommonCamelMessages.MESSAGES.invalidURINoBindingDataCreatorRegisteredForScheme(name, e); } if (type != null) { if (BindingDataCreator.class.isAssignableFrom(type)) { return (BindingDataCreator<?>) context.getInjector().newInstance(type); } else { throw CommonCamelMessages.MESSAGES.resolvingBindingDataCreatorForEndpointOfType(name, type.getName()); } } return new DefaultBindingDataCreator(); }
/** * Try resolve binding creator for given endpoint name. * * @param name Name of endpoint, eg. DirectEndpoint. * @param context Camel context instance. * @return Dedicated BindingDataCreator or default if none found. */ public BindingDataCreator<?> resolveBindingCreator(String name, CamelContext context) { Class<?> type = null; try { if (_bindingDataCreatorFactory == null) { _bindingDataCreatorFactory = context.getFactoryFinder(BINDING_DATA_CREATOR_RESOURCE_PATH); } type = _bindingDataCreatorFactory.findClass(name); } catch (NoFactoryAvailableException e) { e.getMessage(); // ignore } catch (Exception e) { throw CommonCamelMessages.MESSAGES.invalidURINoBindingDataCreatorRegisteredForScheme(name, e); } if (type != null) { if (BindingDataCreator.class.isAssignableFrom(type)) { return (BindingDataCreator<?>) context.getInjector().newInstance(type); } else { throw CommonCamelMessages.MESSAGES.resolvingBindingDataCreatorForEndpointOfType(name, type.getName()); } } return new DefaultBindingDataCreator(); }