Package org.exoplatform.services.jdbc

Examples of org.exoplatform.services.jdbc.DataSourceProvider


      if (container == null)
      {
         LOG.warn("The current container cannot be found which prevents to retrieve the DataSourceProvider");
         return null;
      }
      DataSourceProvider dsProvider =
         (DataSourceProvider)container.getComponentInstanceOfType(DataSourceProvider.class);
      if (dsProvider == null)
      {
         LOG.warn("The DataSourceProvider cannot be found in the container " + container.getContext().getName()
            + ", it will be considered as non managed ");
View Full Code Here


   public void start() throws Exception
   {
      // A datasource will be registered in JNDI in the start portion of
      // its lifecycle, so now that we are in start() we can look it up

      DataSourceProvider dsProvider = getDataSourceProvider();
      InitialContext ctx = null;
      try
      {
         if (dsProvider == null)
         {
            ctx = new InitialContext();
            dataSource = (DataSource)ctx.lookup(datasourceName);
         }
         else
         {
            dataSource = dsProvider.getDataSource(datasourceName);
         }
         if (trace)
         {
            LOG.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
         }
View Full Code Here

      }
   }

   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"));
   }
View Full Code Here

      assertTrue(dsp.isManaged("ds-foo3"));
   }
  
   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);
View Full Code Here

      if (container == null)
      {
         LOG.warn("The current container cannot be found which prevents to retrieve the DataSourceProvider");
         return null;
      }
      DataSourceProvider dsProvider =
         (DataSourceProvider)container.getComponentInstanceOfType(DataSourceProvider.class);
      if (dsProvider == null)
      {
         LOG.warn("The DataSourceProvider cannot be found in the container " + container.getContext().getName()
            + ", it will be considered as non managed ");
View Full Code Here

   @Override
   public void start(ConnectionFactoryConfig config, ClassLoader classLoader) throws CacheLoaderException
   {
      InitialContext ctx = null;
      DataSourceProvider dsProvider = getDataSourceProvider();
      this.datasourceName = config.getDatasourceJndiLocation();
      try
      {
         if (dsProvider == null)
         {
            ctx = new InitialContext();
            dataSource = (DataSource)ctx.lookup(datasourceName);
         }
         else
         {
            dataSource = dsProvider.getDataSource(datasourceName);
            managed = dsProvider.isManaged(datasourceName);
         }
         if (trace)
         {
            LOG.trace("Datasource lookup for {} succeeded: {} of type {}", datasourceName, dataSource, managed);
         }
View Full Code Here

      if (container == null)
      {
         LOG.warn("The current container cannot be found which prevents to retrieve the DataSourceProvider");
         return null;
      }
      DataSourceProvider dsProvider =
         (DataSourceProvider)container.getComponentInstanceOfType(DataSourceProvider.class);
      if (dsProvider == null)
      {
         LOG.warn("The DataSourceProvider cannot be found in the container " + container.getContext().getName()
            + ", it will be considered as non managed ");
View Full Code Here

   public void start() throws Exception
   {
      // A datasource will be registered in JNDI in the start portion of
      // its lifecycle, so now that we are in start() we can look it up

      DataSourceProvider dsProvider = getDataSourceProvider();
      InitialContext ctx = null;
      try
      {
         if (dsProvider == null)
         {
            ctx = new InitialContext();
            dataSource = (DataSource)ctx.lookup(datasourceName);
         }
         else
         {
            dataSource = dsProvider.getDataSource(datasourceName);
         }
         if (trace)
         {
            LOG.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
         }
View Full Code Here

      if (container == null)
      {
         LOG.warn("The current container cannot be found which prevents to retrieve the DataSourceProvider");
         return null;
      }
      DataSourceProvider dsProvider =
         (DataSourceProvider)container.getComponentInstanceOfType(DataSourceProvider.class);
      if (dsProvider == null)
      {
         LOG.warn("The DataSourceProvider cannot be found in the container " + container.getContext().getName()
            + ", it will be considered as non managed ");
View Full Code Here

   public void start() throws Exception
   {
      // A datasource will be registered in JNDI in the start portion of
      // its lifecycle, so now that we are in start() we can look it up

      DataSourceProvider dsProvider = getDataSourceProvider();
      InitialContext ctx = null;
      try
      {
         if (dsProvider == null)
         {
            ctx = new InitialContext();
            dataSource = (DataSource)ctx.lookup(datasourceName);
         }
         else
         {
            dataSource = dsProvider.getDataSource(datasourceName);
         }
         if (trace)
         {
            LOG.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
         }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jdbc.DataSourceProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.