示例#1
0
 private DependencyEngine getDependencyEngine(String id) {
   for (DependencyEngine dependencyEngine : dependencyEngines) {
     if (dependencyEngine == null || dependencyEngine.getDependencyEngineId() == null) continue;
     if (dependencyEngine.getDependencyEngineId().equalsIgnoreCase(id)) return dependencyEngine;
   }
   return null;
 }
示例#2
0
 public synchronized List<String> getDependencyEngineIds() {
   List<String> list = new ArrayList<String>();
   for (DependencyEngine dependencyEngine : dependencyEngines) {
     if (dependencyEngine == null || dependencyEngine.getDependencyEngineId() == null) continue;
     list.add(new String(dependencyEngine.getDependencyEngineId()));
   }
   return list;
 }
示例#3
0
 public DependencyEnginePool(DependencyEngine... dependencyEngines) {
   if (dependencyEngines != null) {
     for (DependencyEngine dependencyEngine : dependencyEngines) {
       if (dependencyEngine.getDependencyEngineId() == null)
         dependencyEngine.setDependencyEngineId(dependencyEngine.getClass().getSimpleName());
       add(dependencyEngine.getDependencyEngineId(), dependencyEngine);
     }
   }
 }
示例#4
0
 public synchronized DependencyEngine get(Arguments arguments) {
   DependencyEngine dependencyEngine = null;
   try {
     dependencyEngine = findEngine(arguments);
   } catch (DtException ex) {
     dependencyEngine = getDefaultEngine();
   }
   if (arguments.getDependencyEngineId() != null
       && arguments.getDependencyEngineId().length() > 0) {
     if (!(dependencyEngine != null
         && dependencyEngine.getDependencyEngineId() != null
         && dependencyEngine
             .getDependencyEngineId()
             .equalsIgnoreCase(arguments.getDependencyEngineId()))) {
       throw new DtException(
           "unable to find a dependency engine with id: " + arguments.getDependencyEngineId());
     }
   }
   ;
   return dependencyEngine;
 }
示例#5
0
 private DependencyEngine findEngine(Arguments arguments) {
   DependencyEngine engineMaybe = null;
   boolean ambiguousSituation = false;
   for (DependencyEngine dependencyEngine : dependencyEngines) {
     if (dependencyEngine == null) continue;
     if (dependencyEngine.getArgumentsMatchThisEngine(arguments)
         == DependencyEngine.ArgumentsMatch.yes) return dependencyEngine;
     if (dependencyEngine.getArgumentsMatchThisEngine(arguments)
         == DependencyEngine.ArgumentsMatch.maybe) {
       if (engineMaybe == null) {
         engineMaybe = dependencyEngine;
       } else {
         ambiguousSituation = true;
       }
     }
   }
   if (!ambiguousSituation && engineMaybe != null) {
     return engineMaybe;
   }
   throw new DtException("unable to determine the dependency engine to be utilized");
 }
示例#6
0
 public synchronized void add(String id, DependencyEngine dependencyEngine) {
   if (id == null || id.length() == 0) {
     throw new DtException("Unable to load the dependency engine. Id not specified.");
   }
   if (getDependencyEngine(id) != null) {
     throw new DtException(
         "Unable to load the dependency engine. Dependency engine with id="
             + id
             + " already exists.");
   }
   dependencyEngine.setDependencyEngineId(id);
   addDependencyEngine(dependencyEngine);
 }