use of com.ramussoft.common.PluginFactory 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);
}
}
use of com.ramussoft.common.PluginFactory in project ramus by Vitaliy-Yakovchuk.
the class EngineFactory method createPluginFactory.
protected PluginFactory createPluginFactory(List<PluginProvider> list) {
ArrayList<Plugin> plugins = new ArrayList<Plugin>();
for (PluginProvider suit : list) {
plugins.addAll(suit.getPlugins());
}
plugins.add(new AbstractPlugin() {
@Override
public String getName() {
return "Log";
}
@Override
public Class getFunctionalInterface() {
return ILog.class;
}
@Override
public Object createFunctionalInterfaceObject(Engine engine, IEngine iEngine) {
return log;
}
});
PluginFactory factory = new PluginFactory(plugins);
return factory;
}
use of com.ramussoft.common.PluginFactory in project ramus by Vitaliy-Yakovchuk.
the class InternetServer method loadAllData.
public byte[] loadAllData() {
synchronized (saveLock) {
MemoryDatabase database = new MemoryDatabase() {
@Override
protected void loadSuits(List<PluginProvider> suits) {
suits.addAll(engineFactory.getSuits());
}
@Override
protected File getFile() {
return null;
}
@Override
public Connection createConnection() throws SQLException {
return engineFactory.createConnection();
}
@Override
protected String getJournalDirectoryName(String tmp) {
return null;
}
@Override
protected FileIEngineImpl createFileIEngine(PluginFactory factory) throws ClassNotFoundException, ZipException, IOException {
return new FileIEngineImpl(0, template, factory, null);
}
};
Engine s = database.getEngine(null);
FileIEngineImpl impl = (FileIEngineImpl) s.getDeligate();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ZipOutputStream out;
try {
out = impl.writeToStream(stream);
out.close();
return stream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
use of com.ramussoft.common.PluginFactory in project ramus by Vitaliy-Yakovchuk.
the class StandardAttributesPlugin method isSystem.
protected boolean isSystem(AttributeType attributeType) {
PluginFactory factory = (PluginFactory) engine.getPluginProperty("Core", "PluginFactory");
if (factory == null)
return false;
AttributePlugin plugin = factory.getAttributePlugin(attributeType);
if (plugin == null) {
System.err.println("WARNING: Attribute plugin for attribute type " + attributeType + " not found");
return false;
}
return plugin.isSystem();
}
use of com.ramussoft.common.PluginFactory in project ramus by Vitaliy-Yakovchuk.
the class H2Database method createEngines.
private void createEngines() {
try {
JDBCTemplate template = createTemplate();
List<PluginProvider> suits = new ArrayList<PluginProvider>();
suits.add(new SimpleAttributePluginSuit());
PluginFactory factory = createPluginFactory(suits);
IEngineImpl impl = new IEngineImpl(0, template, PREFIX, factory) {
@Override
protected boolean deleteStreamBytes(String path) {
return false;
}
@Override
public byte[] getStream(String path) {
return null;
}
@Override
protected void writeStream(String path, byte[] bytes) {
}
};
accessor = impl.getAccessor();
PersistentFactory persistentFactory = new PersistentFactory(PREFIX, factory.getAttributePlugins(), template);
persistentFactory.rebuild();
String tmp = System.getProperty("java.io.tmpdir");
engine = new JournaledEngine(factory, impl, persistentFactory.getRows(), new DirectoryJournalFactory(new File(tmp)), accessor);
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new RuntimeException();
}
}
Aggregations