Search in sources :

Example 6 with ValueParam

use of org.exoplatform.container.xml.ValueParam in project kernel by exoplatform.

the class TestSimpleReplicatedExoCache method init.

@Before
public void init() throws Exception {
    container = PortalContainer.getInstance();
    ConfigurationManager configManager = container.getComponentInstanceOfType(ConfigurationManager.class);
    InitParams params = new InitParams();
    ValueParam paramConf = new ValueParam();
    paramConf.setName("jgroups-configuration");
    paramConf.setValue("jar:/conf/portal/udp.xml");
    params.addParameter(paramConf);
    service1 = new RPCServiceImpl(container.getContext(), params, configManager);
    service2 = new RPCServiceImpl(container.getContext(), params, configManager);
    cache1 = new SimpleReplicatedExoCache<String, String>(container.getContext(), service1);
    cache2 = new SimpleReplicatedExoCache<String, String>(container.getContext(), service2);
    cache1.setName("TestSimpleReplicatedExoCache");
    cache2.setName("TestSimpleReplicatedExoCache");
    service1.start();
    service2.start();
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ValueParam(org.exoplatform.container.xml.ValueParam) ConfigurationManager(org.exoplatform.container.configuration.ConfigurationManager) RPCServiceImpl(org.exoplatform.services.rpc.jgv3.RPCServiceImpl) Before(org.junit.Before)

Example 7 with ValueParam

use of org.exoplatform.container.xml.ValueParam in project kernel by exoplatform.

the class ExoCacheFactoryImpl method getValueParam.

/**
 * Returns the value of the ValueParam if and only if the value is not empty
 */
private static String getValueParam(InitParams params, String key) {
    if (params == null) {
        return null;
    }
    final ValueParam vp = params.getValueParam(key);
    String result;
    if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0) {
        return null;
    }
    return result;
}
Also used : ValueParam(org.exoplatform.container.xml.ValueParam)

Example 8 with ValueParam

use of org.exoplatform.container.xml.ValueParam in project kernel by exoplatform.

the class TestPersistedQuartzScheduler method setUp.

public void setUp() throws Exception {
    manager = PortalContainer.getInstance();
    manager.getComponentInstanceOfType(InitialContextInitializer.class);
    DataSource dataSource = (DataSource) new InitialContext().lookup("jdbcjcr");
    connection = dataSource.getConnection();
    connection.setAutoCommit(true);
    st = connection.createStatement();
    /**
     *init quartz tables**
     */
    String scripts = IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream("/quartz_hsqldb.sql"));
    for (String query : splitWithSQLDelimiter(scripts)) {
        st.executeUpdate(query);
    }
    /**
     *init QuartzSheduler Service**
     */
    InitParams initParams = new InitParams();
    ValueParam valueParam = new ValueParam();
    valueParam.setName("org.quartz.dataSource.quartzDS.jndiURL");
    valueParam.setValue("jdbcjcr");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.driverDelegateClass");
    valueParam.setValue("org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.class");
    valueParam.setValue("org.quartz.impl.jdbcjobstore.JobStoreTX");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.threadPool.threadCount");
    valueParam.setValue("5");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.dataSource");
    valueParam.setValue("quartzDS");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.tablePrefix");
    valueParam.setValue("QRTZ_");
    initParams.addParameter(valueParam);
    valueParam = new ValueParam();
    valueParam.setName("org.quartz.jobStore.useProperties");
    valueParam.setValue("true");
    initParams.addParameter(valueParam);
    QueueTasks queueTasks = new QueueTasks();
    QuartzSheduler quartzSheduler = new QuartzSheduler(PortalContainer.getInstance().getContext(), initParams);
    jobSchedulerService = new JobSchedulerServiceImpl(quartzSheduler, queueTasks);
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) QuartzSheduler(org.exoplatform.services.scheduler.impl.QuartzSheduler) ValueParam(org.exoplatform.container.xml.ValueParam) InitialContext(javax.naming.InitialContext) JobSchedulerServiceImpl(org.exoplatform.services.scheduler.impl.JobSchedulerServiceImpl) DataSource(javax.sql.DataSource)

Example 9 with ValueParam

use of org.exoplatform.container.xml.ValueParam in project kernel by exoplatform.

the class TestDataSourceProviderImpl method testIsManaged.

public void testIsManaged() throws Exception {
    DataSourceProvider dsp = new DataSourceProviderImpl(null);
    assertFalse(dsp.isManaged(DS_NAME));
    InitParams params = new InitParams();
    dsp = new DataSourceProviderImpl(params);
    assertFalse(dsp.isManaged(DS_NAME));
    ValueParam paramConf = new ValueParam();
    paramConf.setName(DataSourceProviderImpl.PARAM_ALWAYS_MANAGED);
    paramConf.setValue("true");
    params.addParameter(paramConf);
    dsp = new DataSourceProviderImpl(params);
    assertTrue(dsp.isManaged(DS_NAME));
    paramConf.setValue("false");
    dsp = new DataSourceProviderImpl(params);
    assertFalse(dsp.isManaged(DS_NAME));
    ValuesParam paramsConf = new ValuesParam();
    paramsConf.setName(DataSourceProviderImpl.PARAM_MANAGED_DS);
    ArrayList<String> values = new ArrayList<String>();
    values.add(DS_NAME);
    values.add(" ds-foo1, ds-foo2 ");
    values.add("ds-foo3");
    paramsConf.setValues(values);
    params.addParameter(paramsConf);
    dsp = new DataSourceProviderImpl(params);
    assertTrue(dsp.isManaged(DS_NAME));
    assertTrue(dsp.isManaged("ds-foo1"));
    assertTrue(dsp.isManaged("ds-foo2"));
    assertTrue(dsp.isManaged("ds-foo3"));
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ValuesParam(org.exoplatform.container.xml.ValuesParam) DataSourceProvider(org.exoplatform.services.jdbc.DataSourceProvider) ArrayList(java.util.ArrayList) ValueParam(org.exoplatform.container.xml.ValueParam)

Example 10 with ValueParam

use of org.exoplatform.container.xml.ValueParam in project kernel by exoplatform.

the class TestDataSourceProviderImpl method testGetDataSource.

public void testGetDataSource() throws Exception {
    DataSourceProvider dsp = new DataSourceProviderImpl(null);
    DataSource ds = dsp.getDataSource(DS_NAME);
    assertNotNull(ds);
    Connection con = ds.getConnection();
    con.commit();
    assertTrue(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertTrue(mds.con.committed);
    MyTransactionService mts = new MyTransactionService();
    mts.tm.setStatus(Status.STATUS_ACTIVE);
    dsp = new DataSourceProviderImpl(null, mts);
    ds = dsp.getDataSource(DS_NAME);
    assertNotNull(ds);
    con = ds.getConnection();
    con.commit();
    assertTrue(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertTrue(mds.con.committed);
    mts.tm.setStatus(Status.STATUS_NO_TRANSACTION);
    con = ds.getConnection();
    con.commit();
    assertTrue(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertTrue(mds.con.committed);
    InitParams params = new InitParams();
    ValueParam paramConf = new ValueParam();
    paramConf.setName(DataSourceProviderImpl.PARAM_ALWAYS_MANAGED);
    paramConf.setValue("true");
    params.addParameter(paramConf);
    dsp = new DataSourceProviderImpl(params, mts);
    ds = dsp.getDataSource(DS_NAME);
    assertNotNull(ds);
    mts.tm.setStatus(Status.STATUS_ACTIVE);
    con = ds.getConnection();
    con.commit();
    assertFalse(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertFalse(mds.con.committed);
    mts.tm.setStatus(Status.STATUS_NO_TRANSACTION);
    con = ds.getConnection();
    con.commit();
    assertTrue(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertTrue(mds.con.committed);
    paramConf = new ValueParam();
    paramConf.setName(DataSourceProviderImpl.PARAM_CHECK_TX);
    paramConf.setValue("false");
    params.addParameter(paramConf);
    dsp = new DataSourceProviderImpl(params, mts);
    ds = dsp.getDataSource(DS_NAME);
    assertNotNull(ds);
    mts.tm.setStatus(Status.STATUS_ACTIVE);
    con = ds.getConnection();
    con.commit();
    assertFalse(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertFalse(mds.con.committed);
    mts.tm.setStatus(Status.STATUS_NO_TRANSACTION);
    con = ds.getConnection();
    con.commit();
    assertFalse(mds.con.committed);
    con = ds.getConnection(null, null);
    con.commit();
    assertFalse(mds.con.committed);
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) DataSourceProvider(org.exoplatform.services.jdbc.DataSourceProvider) Connection(java.sql.Connection) ValueParam(org.exoplatform.container.xml.ValueParam) DataSource(javax.sql.DataSource)

Aggregations

ValueParam (org.exoplatform.container.xml.ValueParam)20 InitParams (org.exoplatform.container.xml.InitParams)16 RPCServiceImpl (org.exoplatform.services.rpc.jgv3.RPCServiceImpl)7 RemoteCommand (org.exoplatform.services.rpc.RemoteCommand)5 RPCException (org.exoplatform.services.rpc.RPCException)4 ArrayList (java.util.ArrayList)3 Component (org.exoplatform.container.xml.Component)3 Configuration (org.exoplatform.container.xml.Configuration)3 Serializable (java.io.Serializable)2 DataSource (javax.sql.DataSource)2 DataSourceProvider (org.exoplatform.services.jdbc.DataSourceProvider)2 MemberHasLeftException (org.exoplatform.services.rpc.impl.AbstractRPCService.MemberHasLeftException)2 URL (java.net.URL)1 Connection (java.sql.Connection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 InitialContext (javax.naming.InitialContext)1 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)1