/
AbstractBootstrap.java
executable file
·32 lines (24 loc) · 1.2 KB
/
AbstractBootstrap.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.alvazan.orm.api.base;
import java.util.Map;
import com.alvazan.orm.api.spi.layer2.Converter;
@SuppressWarnings("rawtypes")
public abstract class AbstractBootstrap {
public synchronized static NoSqlEntityManagerFactory create(DbTypeEnum type, Map<String, String> properties, Map<Class, Converter> converters) {
return create(type, "com.alvazan.orm.impl.bindings.Bootstrap", properties, converters);
}
public synchronized static NoSqlEntityManagerFactory create(DbTypeEnum type, String impl, Map<String, String> properties, Map<Class, Converter> converters) {
try {
Class<?> clazz = Class.forName(impl);
AbstractBootstrap newInstance = (AbstractBootstrap) clazz.newInstance();
NoSqlEntityManagerFactory inst = newInstance.createInstance(type, properties, converters);
return inst;
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
protected abstract NoSqlEntityManagerFactory createInstance(DbTypeEnum type, Map<String, String> properties, Map<Class, Converter> converters);
}