Search in sources :

Example 21 with StandaloneSpringPentahoObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.

the class BaseTestCase method init.

protected void init(String solnPath) {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    // $NON-NLS-1$
    applicationContext = new StandaloneApplicationContext(solnPath, "");
    applicationContext.setFullyQualifiedServerURL(getFullyQualifiedServerURL());
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    PentahoSystem.init(applicationContext);
    // $NON-NLS-1$
    session = new StandaloneSession("system");
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 22 with StandaloneSpringPentahoObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.

the class MicroPlatform method setSpringConfig.

/**
 * Sets the StandaloneSpringPentahoObjectFactory for the Pentaho platform by xml path
 *
 * @return
 */
public void setSpringConfig(String cfgFile) {
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(cfgFile, null);
    setFactory(pentahoObjectFactory);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 23 with StandaloneSpringPentahoObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.

the class SystemSettingsTest method init.

public boolean init() {
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    File file = new File(SOLUTION_PATH + PENTAHO_XML_PATH);
    StandaloneApplicationContext applicationContext = null;
    if (file.exists()) {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.SOLUTION_PATH, "");
    } else {
        // $NON-NLS-1$
        applicationContext = new StandaloneApplicationContext(SystemSettingsTest.ALT_SOLUTION_PATH, "");
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    String inContainer = System.getProperty("incontainer", "false");
    if (inContainer.equalsIgnoreCase("false")) {
        // $NON-NLS-1$
        // Setup simple-jndi for datasources
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("org.osjava.sj.delimiter", "/");
    }
    // $NON-NLS-1$
    String objectFactoryCreatorCfgFile = getSolutionPath() + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME;
    IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
    pentahoObjectFactory.init(objectFactoryCreatorCfgFile, null);
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    return PentahoSystem.init(applicationContext);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings) File(java.io.File) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 24 with StandaloneSpringPentahoObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.

the class StandaloneSpringPentahoObjectFactoryTest method testGetAll.

public void testGetAll() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    PentahoSystem.registerObjectFactory(factory);
    List<MimeTypeListener> mimes = PentahoSystem.getAll(MimeTypeListener.class, session);
    assertNotNull(mimes);
    assertEquals(5, mimes.size());
    assertNotSame(mimes.get(0), mimes.get(1));
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Example 25 with StandaloneSpringPentahoObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.

the class StandaloneSpringPentahoObjectFactoryTest method testNoInit.

public void testNoInit() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    try {
        GoodObject obj = factory.get(GoodObject.class, session);
        assertNotNull(obj);
        assertFalse(true);
    } catch (ObjectFactoryException e) {
        assertTrue(true);
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)

Aggregations

StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)35 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)10 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)9 Test (org.junit.Test)8 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)8 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)7 File (java.io.File)5 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)5 AggregateObjectFactory (org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory)5 HashMap (java.util.HashMap)3 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)3 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)3 ApplicationContext (org.springframework.context.ApplicationContext)3 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)3 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)3 BeforeClass (org.junit.BeforeClass)2 IPentahoObjectRegistration (org.pentaho.platform.api.engine.IPentahoObjectRegistration)2 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)2 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)2