Search in sources :

Example 11 with JDBCTemplate

use of com.ramussoft.jdbc.JDBCTemplate 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();
    }
}
Also used : DirectoryJournalFactory(com.ramussoft.common.journal.DirectoryJournalFactory) PersistentFactory(com.ramussoft.core.persistent.PersistentFactory) ArrayList(java.util.ArrayList) PluginProvider(com.ramussoft.common.PluginProvider) IOException(java.io.IOException) SQLException(java.sql.SQLException) JDBCTemplate(com.ramussoft.jdbc.JDBCTemplate) SimpleAttributePluginSuit(com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) JournaledEngine(com.ramussoft.common.journal.JournaledEngine) PluginFactory(com.ramussoft.common.PluginFactory) File(java.io.File)

Example 12 with JDBCTemplate

use of com.ramussoft.jdbc.JDBCTemplate in project ramus by Vitaliy-Yakovchuk.

the class H2Database method createTemplate.

public static JDBCTemplate createTemplate() throws SQLException, IOException {
    JDBCTemplate template = new JDBCTemplate(createConnection());
    template.executeResource("/com/ramussoft/jdbc/database.sql", PREFIX);
    return template;
}
Also used : JDBCTemplate(com.ramussoft.jdbc.JDBCTemplate)

Aggregations

JDBCTemplate (com.ramussoft.jdbc.JDBCTemplate)12 SQLException (java.sql.SQLException)11 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)8 ResultSet (java.sql.ResultSet)8 RowMapper (com.ramussoft.jdbc.RowMapper)7 ArrayList (java.util.ArrayList)6 Attribute (com.ramussoft.common.Attribute)5 Qualifier (com.ramussoft.common.Qualifier)5 Element (com.ramussoft.common.Element)4 Engine (com.ramussoft.common.Engine)4 IEngine (com.ramussoft.common.IEngine)4 DeleteStatus (com.ramussoft.common.DeleteStatus)3 PluginFactory (com.ramussoft.common.PluginFactory)3 PluginProvider (com.ramussoft.common.PluginProvider)3 SimpleAttributePluginSuit (com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit)3 AttributeType (com.ramussoft.common.AttributeType)2 Plugin (com.ramussoft.common.Plugin)2 AttributeEvent (com.ramussoft.common.event.AttributeEvent)2 ElementAdapter (com.ramussoft.common.event.ElementAdapter)2 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)2