private static ITransportFactory getTransportFactory(String transportFactory) { try { Class<?> factory = Class.forName(transportFactory); if (!ITransportFactory.class.isAssignableFrom(factory)) throw new IllegalArgumentException( String.format( "transport factory '%s' " + "not derived from ITransportFactory", transportFactory)); return (ITransportFactory) factory.newInstance(); } catch (Exception e) { throw new IllegalArgumentException( String.format("Cannot create a transport factory '%s'.", transportFactory), e); } }
private static ITransportFactory getTransportFactory(String factoryClassName) { try { return (ITransportFactory) Class.forName(factoryClassName).newInstance(); } catch (Exception e) { throw new RuntimeException("Failed to instantiate transport factory:" + factoryClassName, e); } }