public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
/** * @param location * @return * @throws IOException */ public static TransportFactory findTransportFactory(URI location) throws IOException { String scheme = location.getScheme(); if (scheme == null) { throw new IOException("Transport not scheme specified: [" + location + "]"); } TransportFactory tf = TRANSPORT_FACTORYS.get(scheme); if (tf == null) { // Try to load if from a META-INF property. try { tf = (TransportFactory)TRANSPORT_FACTORY_FINDER.newInstance(scheme); TRANSPORT_FACTORYS.put(scheme, tf); } catch (Throwable e) { throw IOExceptionSupport.create("Transport scheme NOT recognized: [" + scheme + "]", e); } } return tf; }
/** * @param uri * @return * @throws IOException */ private static DiscoveryAgentFactory findDiscoveryAgentFactory(URI uri) throws IOException { String scheme = uri.getScheme(); if (scheme == null) { throw new IOException("DiscoveryAgent scheme not specified: [" + uri + "]"); } DiscoveryAgentFactory daf = DISCOVERY_AGENT_FACTORYS.get(scheme); if (daf == null) { // Try to load if from a META-INF property. try { daf = (DiscoveryAgentFactory)DISCOVERY_AGENT_FINDER.newInstance(scheme); DISCOVERY_AGENT_FACTORYS.put(scheme, daf); } catch (Throwable e) { throw IOExceptionSupport.create("DiscoveryAgent scheme NOT recognized: [" + scheme + "]", e); } } return daf; }
public WireFormatFactory findWireFormatFactory(String scheme, Map<String, Map<String, Object>> options) throws IOException { WireFormatFactory wff = null; try { wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(scheme); if (options != null) { final Map<String, Object> wfOptions = new HashMap<>(); if (options.get(AutoTransportUtils.ALL) != null) { wfOptions.putAll(options.get(AutoTransportUtils.ALL)); } if (options.get(scheme) != null) { wfOptions.putAll(options.get(scheme)); } IntrospectionSupport.setProperties(wff, wfOptions); } if (wff instanceof OpenWireFormatFactory) { protocolVerifiers.put(AutoTransportUtils.OPENWIRE, new OpenWireProtocolVerifier((OpenWireFormatFactory) wff)); } return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + scheme + ", reason: " + e, e); } }
public static MessageGroupMapFactory createMessageGroupMapFactory(String type) throws IOException { try { Map<String,String> properties = null; String factoryType = type.trim(); int p = factoryType.indexOf('?'); if (p >= 0){ String propertiesString = factoryType.substring(p+1); factoryType = factoryType.substring(0,p); properties = URISupport.parseQuery(propertiesString); } MessageGroupMapFactory result = (MessageGroupMapFactory)GROUP_FACTORY_FINDER.newInstance(factoryType); if (properties != null && result != null){ IntrospectionSupport.setProperties(result,properties); } return result; } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
private Object loadAdapter(FactoryFinder finder, String kind) throws IOException { Object adapter = null; TransactionContext c = getTransactionContext(); try { try { // Make the filename file system safe. String dirverName = c.getConnection().getMetaData().getDriverName(); dirverName = dirverName.replaceAll("[^a-zA-Z0-9\\-]", "_").toLowerCase(Locale.ENGLISH); try { adapter = finder.newInstance(dirverName); LOG.info("Database " + kind + " driver override recognized for : [" + dirverName + "] - adapter: " + adapter.getClass()); } catch (Throwable e) { LOG.info("Database " + kind + " driver override not found for : [" + dirverName + "]. Will use default implementation."); } } catch (SQLException e) { LOG.warn("JDBC error occurred while trying to detect database type for overrides. Will use default implementations: " + e.getMessage()); JDBCPersistenceAdapter.log("Failure Details: ", e); } } finally { c.close(); } return adapter; }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
public TransportFactory findTransportFactory(String scheme, Map<String, ?> options) throws IOException { scheme = append(scheme, "nio"); scheme = append(scheme, "ssl"); if (scheme.isEmpty()) { scheme = "tcp"; } TransportFactory tf = transportFactories.get(scheme); if (tf == null) { // Try to load if from a META-INF property. try { tf = (TransportFactory)TRANSPORT_FACTORY_FINDER.newInstance(scheme); if (options != null) { IntrospectionSupport.setProperties(tf, options); } transportFactories.put(scheme, tf); } catch (Throwable e) { throw IOExceptionSupport.create("Transport scheme NOT recognized: [" + scheme + "]", e); } } return tf; }
public static BrokerCoordinator getCoordinator(String type) throws Exception { return (BrokerCoordinator) FINDER.newInstance(type); } }
public static BrokerCoordinator getCoordinator(String type) throws Exception { return (BrokerCoordinator) FINDER.newInstance(type); } }
public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
private CommandHandler createHandler() throws IllegalAccessException, IOException, ClassNotFoundException, InstantiationException { FactoryFinder factoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/broker/"); return (CommandHandler)factoryFinder.newInstance("agent"); } }
public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
protected FrameTranslator findTranslator(String header) { FrameTranslator translator = frameTranslator; try { if (header != null) { translator = (FrameTranslator) FRAME_TRANSLATOR_FINDER .newInstance(header); if (translator instanceof BrokerContextAware) { ((BrokerContextAware)translator).setBrokerContext(brokerContext); } } } catch (Exception ignore) { // if anything goes wrong use the default translator } return translator; }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }
protected WireFormatFactory createWireFormatFactory(Map<String, String> options) throws IOException { String wireFormat = (String)options.remove("wireFormat"); if (wireFormat == null) { wireFormat = getDefaultWireFormatType(); } try { WireFormatFactory wff = (WireFormatFactory)WIREFORMAT_FACTORY_FINDER.newInstance(wireFormat); IntrospectionSupport.setProperties(wff, options, "wireFormat."); return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + wireFormat + ", reason: " + e, e); } }