Search in sources :

Example 1 with PersistentsPlugin

use of com.ramussoft.core.persistent.PersistentsPlugin in project ramus by Vitaliy-Yakovchuk.

the class EngineFactory method createUniversalPersistentFactory.

private void createUniversalPersistentFactory(JDBCTemplate template, String pluginsString) throws SQLException {
    UniversalPersistentFactory factory = new UniversalPersistentFactory(template);
    Collection<PersistentsPlugin> pls = getPersistentPlugins();
    ArrayList<PersistentsPlugin> plugins = new ArrayList<PersistentsPlugin>();
    plugins.addAll(pls);
    if (pluginsString != null) {
        StringTokenizer st = new StringTokenizer(pluginsString, ", ");
        while (st.hasMoreTokens()) {
            try {
                String className = st.nextToken();
                Class<?> clazz = Class.forName(className);
                PersistentsPluginProvider plugin = (PersistentsPluginProvider) clazz.newInstance();
                plugins.addAll(plugin.getPersistentsPlugins());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    for (PluginProvider pp : suits) {
        if (pp instanceof PersistentsPluginProvider) {
            plugins.addAll(((PersistentsPluginProvider) pp).getPersistentsPlugins());
        }
    }
    for (PersistentsPlugin pp : plugins) {
        List<Class> list = new ArrayList<Class>();
        pp.addPersistents(list, factory);
        factory.addClasses(list);
    }
    factory.rebuild();
}
Also used : UniversalPersistentFactory(com.ramussoft.core.persistent.UniversalPersistentFactory) PersistentsPluginProvider(com.ramussoft.core.persistent.PersistentsPluginProvider) PersistentsPlugin(com.ramussoft.core.persistent.PersistentsPlugin) ArrayList(java.util.ArrayList) PersistentsPluginProvider(com.ramussoft.core.persistent.PersistentsPluginProvider) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) PluginProvider(com.ramussoft.common.PluginProvider) SQLException(java.sql.SQLException) StringTokenizer(java.util.StringTokenizer)

Aggregations

PluginProvider (com.ramussoft.common.PluginProvider)1 PersistentsPlugin (com.ramussoft.core.persistent.PersistentsPlugin)1 PersistentsPluginProvider (com.ramussoft.core.persistent.PersistentsPluginProvider)1 UniversalPersistentFactory (com.ramussoft.core.persistent.UniversalPersistentFactory)1 IDEF0PluginProvider (com.ramussoft.idef0.IDEF0PluginProvider)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1