Пример #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;
  }