Search in sources :

Example 1 with IPentahoDefinableObjectFactory

use of org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory in project pentaho-platform by pentaho.

the class BootTest method testBootListeners.

@Test
public void testBootListeners() throws Exception {
    PentahoSystemBoot boot = new PentahoSystemBoot();
    boot.setFilePath("src/test/resources/solution");
    boot.define(ISolutionEngine.class.getSimpleName(), Object1.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
    TestLifecycleListener lifecycleListener1 = new TestLifecycleListener();
    TestLifecycleListener lifecycleListener2 = new TestLifecycleListener();
    boot.addLifecycleListener(lifecycleListener1);
    List<IPentahoSystemListener> lifecycleListeners1 = boot.getLifecycleListeners();
    assertEquals(1, lifecycleListeners1.size());
    assertEquals(lifecycleListener1, lifecycleListeners1.get(0));
    assertFalse(TestLifecycleListener.startupCalled);
    assertFalse(TestLifecycleListener.shutdownCalled);
    List<IPentahoSystemListener> lifecycleListeners2 = new ArrayList<IPentahoSystemListener>();
    lifecycleListeners2.add(lifecycleListener2);
    boot.setLifecycleListeners(lifecycleListeners2);
    List<IPentahoSystemListener> lifecycleListeners3 = boot.getLifecycleListeners();
    assertEquals(1, lifecycleListeners3.size());
    assertEquals(lifecycleListener2, lifecycleListeners3.get(0));
    assertEquals(lifecycleListeners2, lifecycleListeners3);
    IPentahoObjectFactory factory = boot.getFactory();
    assertNotNull("object factory is null", factory);
    assertTrue("object factory not definable", factory instanceof IPentahoDefinableObjectFactory);
    assertFalse(boot.isInitialized());
    boolean ok = boot.start();
    assertNull(boot.getSettingsProvider());
    assertTrue(boot.isInitialized());
    assertTrue(ok);
    assertTrue(TestLifecycleListener.startupCalled);
    assertFalse(TestLifecycleListener.shutdownCalled);
    boot.stop();
    assertFalse(boot.isInitialized());
    assertTrue(TestLifecycleListener.startupCalled);
    assertTrue(TestLifecycleListener.shutdownCalled);
}
Also used : PentahoSystemBoot(org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot) IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoSystemListener(org.pentaho.platform.api.engine.IPentahoSystemListener) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with IPentahoDefinableObjectFactory

use of org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory in project pentaho-platform by pentaho.

the class PentahoSystemBoot method define.

/**
 * Define an arbitrarily scoped object
 *
 * @param key
 *          the key to retrieval of this object
 * @param implClassName
 *          the actual type that is served back to you when requested.
 * @param scope
 *          the scope of the object
 * @return the current {@link PentahoSystemBoot} instance, for chaining
 * @throws NoSuchMethodError
 *           if the object factory does not support runtime object definition
 */
public PentahoSystemBoot define(String key, String implClassName, Scope scope) {
    if (factory instanceof IPentahoDefinableObjectFactory) {
        IPentahoDefinableObjectFactory definableFactory = (IPentahoDefinableObjectFactory) getFactory();
        definableFactory.defineObject(key, implClassName, scope);
    } else {
        // $NON-NLS-1$
        throw new NoSuchMethodError("define is only supported by IPentahoDefinableObjectFactory");
    }
    return this;
}
Also used : IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)

Example 3 with IPentahoDefinableObjectFactory

use of org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory in project pentaho-platform by pentaho.

the class PentahoSystemBoot method define.

/**
 * Hold an object instance by key name.
 *
 * @param key
 *          the key to retrieval of this object
 * @param instance
 *          the actual instance that is served back to you when requested.
 * @return the current MicroPlatform instance, for chaining
 */
public PentahoSystemBoot define(String key, Object instance) {
    if (factory instanceof IPentahoDefinableObjectFactory) {
        IPentahoDefinableObjectFactory definableFactory = (IPentahoDefinableObjectFactory) getFactory();
        definableFactory.defineInstance(key, instance);
    } else {
        // $NON-NLS-1$
        throw new NoSuchMethodError("defineInstance is only supported by IPentahoDefinableObjectFactory");
    }
    return this;
}
Also used : IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)

Example 4 with IPentahoDefinableObjectFactory

use of org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory in project pentaho-platform by pentaho.

the class PentahoBoot method enableOlap.

/**
 * Enables the components necessary to create reports
 */
public void enableOlap() {
    IPentahoObjectFactory objectFactory = getFactory();
    if (objectFactory instanceof IPentahoDefinableObjectFactory) {
        // $NON-NLS-1$
        define("connection-MDX", MDXConnection.class.getName(), Scope.LOCAL);
    }
    addLifecycleListener(new MondrianSystemListener());
}
Also used : IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory) MDXConnection(org.pentaho.platform.plugin.services.connections.mondrian.MDXConnection) MondrianSystemListener(org.pentaho.platform.plugin.action.mondrian.MondrianSystemListener) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory)

Example 5 with IPentahoDefinableObjectFactory

use of org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory in project pentaho-platform by pentaho.

the class PentahoBoot method configure.

/**
 * Sets up the defaults: - File-based repository - SQL datasource connections - MXL datasources - File outputs
 */
@Override
protected void configure(String solutionPath, String baseUrl, IPentahoDefinableObjectFactory factory) {
    super.configure(null, null, null);
    IPentahoObjectFactory objectFactory = getFactory();
    if (objectFactory instanceof IPentahoDefinableObjectFactory) {
        define(ISolutionEngine.class, SolutionEngine.class, Scope.LOCAL);
        define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.SESSION);
        // $NON-NLS-1$
        define("connection-XML", XQConnection.class, Scope.LOCAL);
        // $NON-NLS-1$
        define("connection-SQL", SQLConnection.class, Scope.LOCAL);
        // $NON-NLS-1$
        define("file", FileOutputHandler.class, Scope.LOCAL);
    }
}
Also used : IPentahoDefinableObjectFactory(org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory)

Aggregations

IPentahoDefinableObjectFactory (org.pentaho.platform.api.engine.IPentahoDefinableObjectFactory)10 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)6 Test (org.junit.Test)3 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)3 PentahoSystemBoot (org.pentaho.platform.engine.core.system.boot.PentahoSystemBoot)3 ArrayList (java.util.ArrayList)2 IPentahoSystemListener (org.pentaho.platform.api.engine.IPentahoSystemListener)1 ISessionStartupAction (org.pentaho.platform.api.engine.ISessionStartupAction)1 PooledDatasourceSystemListener (org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledDatasourceSystemListener)1 MondrianSystemListener (org.pentaho.platform.plugin.action.mondrian.MondrianSystemListener)1 MDXConnection (org.pentaho.platform.plugin.services.connections.mondrian.MDXConnection)1 PluginAdapter (org.pentaho.platform.plugin.services.pluginmgr.PluginAdapter)1