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);
}
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;
}
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;
}
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());
}
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);
}
}
Aggregations