Class JdbcCpoAdapterFactory

java.lang.Object
org.synchronoss.cpo.jdbc.JdbcCpoAdapterFactory
All Implemented Interfaces:
CpoAdapterFactory

public class JdbcCpoAdapterFactory extends Object implements CpoAdapterFactory
JDBC implementation of CpoAdapterFactory, vending JdbcCpoAdapter, transaction-scoped JdbcCpoTrxAdapter, and JdbcCpoXaAdapter instances backed by a single underlying JdbcCpoAdapter.
Author:
dberry
  • Constructor Details

    • JdbcCpoAdapterFactory

      public JdbcCpoAdapterFactory(JdbcCpoAdapter jdbcCpoAdapter)
      Constructs a JdbcCpoAdapterFactory from a JdbcCpoAdapter
      Parameters:
      jdbcCpoAdapter - A JdbcCpoAdapter
  • Method Details

    • getCpoAdapter

      public CpoAdapter getCpoAdapter() throws CpoException
      Description copied from interface: CpoAdapterFactory
      Gets a CpoAdapter that manages its own connections per call (no explicit transaction control).
      Specified by:
      getCpoAdapter in interface CpoAdapterFactory
      Returns:
      a usable CpoAdapter
      Throws:
      CpoException - if the adapter cannot be created
    • getCpoTrxAdapter

      public CpoTrxAdapter getCpoTrxAdapter() throws CpoException
      Provides a mechanism for the user to obtain a CpoTrxAdapter object. This object allows the to control when commits and rollbacks occur on CPO.
      Example:
       
       class SomeObject so = null;
       class CpoAdapter cpo = null;
       class CpoTrxAdapter cpoTrx = null;
       try {
       	cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
       	cpoTrx = cpo.getCpoTrxAdapter();
       } catch (CpoException ce) {
       	// Handle the error
       	cpo = null;
       }
       if (cpo!=null) {
       	try{
       		for (int i=0; i<3; i++){
       			so = new SomeObject();
       			so.setId(1);
       			so.setName("SomeName");
       			cpo.updateObject("myUpdate",so);
          }
       		cpoTrx.commit();
        } catch (CpoException ce) {
       		// Handle the error
       		cpoTrx.rollback();
        }
       }
       
       
      Specified by:
      getCpoTrxAdapter in interface CpoAdapterFactory
      Returns:
      A CpoTrxAdapter to manage the transactionality of CPO
      Throws:
      CpoException - Thrown if there are errors accessing the datasource
      See Also:
    • getCpoXaAdapter

      public CpoXaResource getCpoXaAdapter() throws CpoException
      Description copied from interface: CpoAdapterFactory
      Gets a CpoXaResource that participates in a JTA-managed distributed transaction.
      Specified by:
      getCpoXaAdapter in interface CpoAdapterFactory
      Returns:
      a usable CpoXaResource
      Throws:
      CpoException - if the resource cannot be created