コード例 #1
0
 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);
   }
 }
コード例 #2
0
 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);
   }
 }