Beispiel #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);
 }
Beispiel #2
0
 public boolean hasDatasourceFactory(String name) {
   for (DatasourceFactory factory : factories) {
     if (factory.getName().equals(name)) {
       return true;
     }
   }
   return false;
 }
Beispiel #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;
 }
 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;
 }
Beispiel #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;
  }