예제 #1
0
 public DatasourceFactory getDatasourceFactory(String name) {
   for (DatasourceFactory factory : factories) {
     if (factory.getName().equals(name)) {
       return factory;
     }
   }
   throw new NoSuchDatasourceException("Datasource factory could not be found: " + name);
 }
예제 #2
0
 public boolean hasDatasourceFactory(String name) {
   for (DatasourceFactory factory : factories) {
     if (factory.getName().equals(name)) {
       return true;
     }
   }
   return false;
 }
예제 #3
0
 @Nullable
 public DatasourceFactory removeFactory(String name) {
   for (Iterator<DatasourceFactory> i = factories.iterator(); i.hasNext(); ) {
     DatasourceFactory factory = i.next();
     if (factory.getName().equals(name)) {
       i.remove();
       return factory;
     }
   }
   return null;
 }
예제 #4
0
 public DatasourceFactory parse(
     DatasourceFactoryDto dto, DatasourceEncryptionStrategy encryptionStrategy)
     throws NoSuchDatasourceFactoryException {
   if (dto == null) throw new IllegalArgumentException("dto cannot be null");
   for (DatasourceFactoryDtoParser parser : parsers) {
     if (parser.canParse(dto)) {
       return parser.parse(dto, encryptionStrategy);
     }
   }
   DatasourceFactory factory = new NullDatasourceFactory();
   factory.setName(dto.getName());
   return factory;
 }
예제 #5
0
  public MagmaEngineFactory withFactory(DatasourceFactory factory) {

    // Replace the factory if already exist.
    boolean factoryExist = false;
    for (DatasourceFactory factoryInList : factories) {
      if (factoryInList.getName().equals(factory.getName())) {
        factories.add(factories.indexOf(factoryInList), factory);
        factories.remove(factoryInList);
        factoryExist = true;
        break;
      }
    }

    if (!factoryExist) {
      factories.add(factory);
    }

    return this;
  }