use of org.pentaho.platform.api.engine.IPentahoObjectFactory 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);
}
}
use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.
the class DefaultBackingRepositoryLifecycleManager method getTenantManager.
/**
* @return the {@link IBackingRepositoryLifecycleManager} that this instance will use. If none has been
* specified, it will default to getting the information from {@link PentahoSystem.get()}
*/
public ITenantManager getTenantManager() {
// Check ... if we haven't been injected with a lifecycle manager, get one from PentahoSystem
try {
IPentahoObjectFactory objectFactory = PentahoSystem.getObjectFactory();
IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
return (null != tenantManager ? tenantManager : objectFactory.get(ITenantManager.class, "tenantMgrProxy", pentahoSession));
} catch (ObjectFactoryException e) {
return null;
}
}
use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.
the class BaseTest method setUp.
@Override
public void setUp() {
// used by test repository impl such as FileSystemRepositoryFileDao
System.setProperty("solution.root.dir", getSolutionPath());
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(), "");
// set the base url assuming there is a running server on port 8080
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", "/");
}
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");
// Initialize SecurityHelper with a mock for testing
SecurityHelper.setMockInstance(new MockSecurityHelper());
initOk = PentahoSystem.init(applicationContext);
} else {
initOk = true;
}
// $NON-NLS-1$
assertTrue(Messages.getInstance().getString("BaseTest.ERROR_0001_FAILED_INITIALIZATION"), initOk);
}
use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project data-access by pentaho.
the class DatasourceServiceTest method setUpClass.
@BeforeClass
public static void setUpClass() throws ObjectFactoryException {
authorizationPolicy = mock(IAuthorizationPolicy.class);
when(authorizationPolicy.isAllowed(RepositoryReadAction.NAME)).thenReturn(true);
when(authorizationPolicy.isAllowed(RepositoryCreateAction.NAME)).thenReturn(true);
IPentahoObjectFactory pentahoObjectFactory = mock(IPentahoObjectFactory.class);
when(pentahoObjectFactory.objectDefined(anyString())).thenReturn(true);
when(pentahoObjectFactory.get(anyClass(), anyString(), any(IPentahoSession.class))).thenAnswer((Answer<Object>) invocation -> {
if (invocation.getArguments()[0].equals(IAuthorizationPolicy.class)) {
return authorizationPolicy;
}
return null;
});
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
}
use of org.pentaho.platform.api.engine.IPentahoObjectFactory in project pentaho-platform by pentaho.
the class SystemResourceIT method setUp.
@Before
public void setUp() throws Exception {
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
ISystemConfig systemConfig = new SystemConfig();
IConfiguration securityConfig = mock(IConfiguration.class);
Properties props = new Properties();
props.setProperty("provider", "jackrabbit");
when(securityConfig.getProperties()).thenReturn(props);
when(securityConfig.getId()).thenReturn("security");
systemConfig.registerConfiguration(securityConfig);
systemResource = new SystemResource(systemConfig);
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to populate PentahoSystem
boolean initOk = PentahoSystem.init(applicationContext);
/*
* StandaloneSession session = new StandaloneSession();
*
* StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
*
* File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
* FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
* XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
*
* factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
*/
}
Aggregations