Search in sources :

Example 31 with StandaloneSpringPentahoObjectFactory

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

the class AggregateObjectFactoryTest method testByKey.

@Test
public void testByKey() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    AggregateObjectFactory aggFactory = new AggregateObjectFactory();
    aggFactory.registerObjectFactory(factory);
    GoodObject info = aggFactory.get(GoodObject.class, "GoodObject", session);
    assertNotNull(info);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) Test(org.junit.Test)

Example 32 with StandaloneSpringPentahoObjectFactory

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

the class AggregateObjectFactoryTest method testRePublish.

@Test
public void testRePublish() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/republish.spring.xml", null);
    PentahoSystem.registerObjectFactory(factory);
    MimeTypeListener republished = PentahoSystem.get(MimeTypeListener.class, session, Collections.singletonMap("republished", "true"));
    assertNotNull(republished);
    assertEquals("Higher Priority MimeTypeListener", republished.name);
    IMimeTypeListener republishedAsInterface = PentahoSystem.get(IMimeTypeListener.class, session, Collections.singletonMap("republishedAsInterface", "true"));
    assertNotNull(republishedAsInterface);
    assertEquals("Higher Priority MimeTypeListener", ((MimeTypeListener) republishedAsInterface).name);
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) Test(org.junit.Test)

Example 33 with StandaloneSpringPentahoObjectFactory

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

the class AggregateObjectFactoryTest method testGetById.

@Test
public void testGetById() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
    MimeTypeListener info = aggFactory.get(MimeTypeListener.class, session, Collections.singletonMap("id", "someID"));
    assertNotNull(info);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) Test(org.junit.Test)

Example 34 with StandaloneSpringPentahoObjectFactory

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

the class PluginManagerNotConfiguredIT method setUp.

public void setUp() {
    List<?> messages = TestManager.getMessagesList();
    if (messages == null) {
        messages = new ArrayList<String>();
    }
    if (initOk) {
        return;
    }
    PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
    if (PentahoSystem.getApplicationContext() == null) {
        // $NON-NLS-1$
        StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
        // $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", "/");
        }
        ApplicationContext springApplicationContext = getSpringApplicationContext();
        IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
        pentahoObjectFactory.init(null, springApplicationContext);
        PentahoSystem.registerObjectFactory(pentahoObjectFactory);
        // force Spring to populate PentahoSystem
        // $NON-NLS-1$
        springApplicationContext.getBean("pentahoSystemProxy");
        initOk = PentahoSystem.init(applicationContext);
    } else {
        initOk = true;
    }
    initOk = true;
}
Also used : StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) 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 35 with StandaloneSpringPentahoObjectFactory

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

the class PentahoSystemHelper method init.

public static void init() {
    if (PentahoSystem.getInitializedOK()) {
        return;
    }
    try {
        PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
        if (PentahoSystem.getApplicationContext() == null) {
            StandaloneApplicationContext applicationContext = // $NON-NLS-1$
            new StandaloneApplicationContext(getSolutionPath(), "");
            // set the base url assuming there is a running server on port 8080
            if (PentahoRequestContextHolder.getRequestContext() != null) {
                applicationContext.setFullyQualifiedServerURL(PentahoRequestContextHolder.getRequestContext().getContextPath());
            }
            // $NON-NLS-1$ //$NON-NLS-2$
            String inContainer = System.getProperty("incontainer", "false");
            if (inContainer.equalsIgnoreCase("false")) {
                // $NON-NLS-1$
                // Setup simple-jndi for datasources
                System.setProperty("java.naming.factory.initial", // $NON-NLS-1$ //$NON-NLS-2$
                "org.osjava.sj.SimpleContextFactory");
                System.setProperty("org.osjava.sj.root", // $NON-NLS-1$ //$NON-NLS-2$
                getSolutionPath() + "/system/simple-jndi");
                // $NON-NLS-1$ //$NON-NLS-2$
                System.setProperty("org.osjava.sj.delimiter", "/");
            }
            ApplicationContext springApplicationContext = getSpringApplicationContext();
            IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
            pentahoObjectFactory.init(null, springApplicationContext);
            PentahoSystem.registerObjectFactory(pentahoObjectFactory);
            // force Spring to inject PentahoSystem, there has got to be a better way than this,
            // perhaps an alternate way of initting spring's app context
            // $NON-NLS-1$
            springApplicationContext.getBean("pentahoSystemProxy");
            PentahoSystem.init(applicationContext);
        }
    } catch (Exception e) {
        logger.error(e);
    }
}
Also used : StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) 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)

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