use of com.ramussoft.common.Plugin in project ramus by Vitaliy-Yakovchuk.
the class AbstractDatabase method createPluginFactory.
protected PluginFactory createPluginFactory(List<PluginProvider> list) {
ArrayList<Plugin> plugins = new ArrayList<Plugin>();
for (PluginProvider suit : list) {
plugins.addAll(suit.getPlugins());
}
PluginFactory factory = new PluginFactory(plugins);
return factory;
}
use of com.ramussoft.common.Plugin in project ramus by Vitaliy-Yakovchuk.
the class TcpLightClient method getEngine.
@SuppressWarnings("rawtypes")
@Override
protected Engine getEngine(PluginFactory factory, PersistentFactory persistentFactory) {
tcpClientEngine = new TcpClientEngine((EngineInvocker) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { EngineInvocker.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return connection.invoke(method.getName(), args);
}
}), connection);
List<Class> interfaces = new ArrayList<Class>();
interfaces.add(Engine.class);
interfaces.add(Journaled.class);
interfaces.add(ILog.class);
for (Plugin plugin : factory.getPlugins()) if (plugin.getFunctionalInterface() != null)
interfaces.add(plugin.getFunctionalInterface());
final Engine engine1 = (Engine) Proxy.newProxyInstance(getClass().getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), tcpClientEngine);
final Engine cachedEngine = createCachedEngine(engine1);
final Hashtable<Method, Object> hashtable = new Hashtable<Method, Object>();
for (Method m : Engine.class.getMethods()) {
hashtable.put(m, cachedEngine);
}
for (Method m : Cached.class.getMethods()) {
hashtable.put(m, cachedEngine);
}
interfaces.add(Cached.class);
Engine engine = (Engine) Proxy.newProxyInstance(getClass().getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object o = hashtable.get(method);
if (o == null)
return tcpClientEngine.invoke(proxy, method, args);
return method.invoke(o, args);
}
});
tcpClientEngine.setEngine(engine);
for (Plugin plugin : factory.getPlugins()) plugin.init(engine, rules);
return engine;
}
use of com.ramussoft.common.Plugin in project ramus by Vitaliy-Yakovchuk.
the class SuperEngineFactory method createTransactionalEngine.
@SuppressWarnings("unchecked")
public static Object createTransactionalEngine(Engine engine, Journaled journal) {
String[] classes = engine.getAllImplementationClasseNames();
Class[] clazzes = new Class[classes.length];
for (int i = 0; i < classes.length; i++) {
try {
clazzes[i] = Class.forName(classes[i]);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
SuperInvoker invoker = null;
if (engine instanceof AbstractJournaledEngine) {
AbstractJournaledEngine abstractJournaledEngine = (AbstractJournaledEngine) engine;
invoker = abstractJournaledEngine.createSuperInvoker(classes, clazzes, journal);
} else if (engine instanceof CachedEngine) {
Object[] objects = new Object[classes.length];
Engine engine2 = ((CachedEngine) engine).getSource();
AbstractJournaledEngine abstractJournaledEngine = null;
if (engine2 instanceof AbstractJournaledEngine) {
abstractJournaledEngine = (AbstractJournaledEngine) engine2;
invoker = abstractJournaledEngine.createSuperInvoker(classes, clazzes, journal);
}
for (int i = 0; i < objects.length; i++) {
String className = classes[i];
if (className.equals(Engine.class.getName())) {
objects[i] = engine;
} else if (className.equals(Journaled.class.getName())) {
objects[i] = new UserTransactional(journal);
} else {
for (Plugin plugin : abstractJournaledEngine.pluginFactory.getPlugins()) {
Class class1 = plugin.getFunctionalInterface();
if (class1 != null)
if (class1.equals(clazzes[i])) {
objects[i] = plugin.createFunctionalInterfaceObject(engine, engine.getDeligate());
}
}
}
}
invoker = new SuperInvoker(classes, clazzes, objects);
}
return Proxy.newProxyInstance(SuperEngineFactory.class.getClassLoader(), clazzes, new Caller(invoker));
}
use of com.ramussoft.common.Plugin in project ramus by Vitaliy-Yakovchuk.
the class Navigator method createPluginFactory.
private PluginFactory createPluginFactory(List<PluginProvider> list) {
ArrayList<Plugin> plugins = new ArrayList<Plugin>();
for (PluginProvider suit : list) {
plugins.addAll(suit.getPlugins());
}
PluginFactory factory = new PluginFactory(plugins);
return factory;
}
use of com.ramussoft.common.Plugin in project ramus by Vitaliy-Yakovchuk.
the class EngineFactory method createJournaledEngine.
public Engine createJournaledEngine(DirectoryJournalFactory journalFactory) {
try {
JDBCTemplate template = new JDBCTemplate(createNewConnectionA());
suits = new ArrayList<PluginProvider>();
suits.add(new SimpleAttributePluginSuit());
suits.add(new IDEF0PluginProvider());
Properties ps = getPropeties();
if (ps != null) {
String suitNames = ps.getProperty("AdditionalSuits");
if (suitNames != null)
PluginFactory.loadAdditionalSuits(suitNames, suits);
canUndoRedo = !"false".equals(ps.getProperty("CanUndoRedo"));
}
suits.addAll(getAdditionalSuits());
createUniversalPersistentFactory(template, (ps == null) ? null : ps.getProperty("PersistentPluginsProvider"));
factory = createPluginFactory(suits);
String prefix = "ramus_";
impl = new ServerIEngineImpl(0, template, prefix, factory);
accessor = impl.getAccessor();
persistentFactory = new PersistentFactory(prefix, factory.getAttributePlugins(), template);
persistentFactory.rebuild();
checkIfGroupsExists();
Engine result;
Journaled journaled;
if (cachedData == null) {
JournaledEngine journaledEngine2 = new JournaledEngine(factory, impl, persistentFactory.getRows(), journalFactory, accessor);
result = journaledEngine2;
journaled = journaledEngine2.getJournal();
} else {
JournaledEngine engine = new JournaledEngine(factory, impl, persistentFactory.getRows(), journalFactory, accessor) {
@Override
protected void initPlugins(PluginFactory pluginFactory, AccessRules accessor) {
}
};
journaled = engine.getJournal();
CachedEngine cachedEngine = new CachedEngine(engine, cachedData);
for (Plugin plugin : factory.getPlugins()) plugin.init(cachedEngine, accessor);
result = cachedEngine;
}
EngineLogExtension engineLogExtension = new EngineLogExtension(result, journaled);
log = new Log(result, journaled) {
protected Event createEvent(String type, UpdateEventCallback callback) {
String user = "admin";
if (impl.getServerAccessRules() != null)
user = impl.getServerAccessRules().getUser().getLogin();
long id = impl.nextValue("qualifiers_log_seq");
return callback.createEvent(this, id, new Timestamp(System.currentTimeMillis()), type, user, null);
}
};
log.addExtension(engineLogExtension);
log.addExtension(new StorageLogExtension(new JDBCTemplate(createNewConnection()), prefix));
return result;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations