Persistence Model – Using Abstract Connection factory Pattern

Discussions

J2EE patterns: Persistence Model – Using Abstract Connection factory Pattern

  1. We have a Problem of Data Access to Multiple Data Sources (Siebel,Active Directory , Oracle ) simlatenously.
    Client should not be aware of which Datasource we are using.
    Flexiblity of adding new Data Sources to application.
    Flexiblity of Switching the Data Sources using Configuration.

    In Our Approach we will be using IConnection Interface, which will encapsulate the methods for Data Operation, Add, Update, delete, execute and get. Different type of connection can have the concrete implementation differently.

    The Concrete Connection for Java Data Bean Implementation will have the implementation of Data Operation using Java Data Bean. It will be using SiebelConnectionManager to get the physical connection from the Siebel.

    The DAO will be calling Connection Factory which Returns the instances of Concrete IConnection Based on Parameter passed, eg. JDBConnection, SiebelWeBservicesConnection, SiebelBusinessServicesConnection, Oracle Connection. The Parameter are the key to the Mapping which determines which Connection Implemntation is used.

    Using the Concrete connection DAO will call the data base operation on the connection.
  2. The UML Diagram assoicated with this pattern are available at

    Class_Diagram_for_Persistence_Model.doc
  3. Looks like JCA.
  4. iBatis DAO Framework[ Go to top ]

    Please look at iBatis DAO Framework. It provides the necessary "context" for each data source and is a clean approach.
  5. We have a Problem of Data Access to Multiple Data Sources (Siebel,Active Directory , Oracle ) simlatenously. Client should not be aware of which Datasource we are using.Flexiblity of adding new Data

    It seems to me that the below defeats the above.
    The DAO will be calling Connection Factory which Returns the instances of Concrete IConnection Based on Parameter passed, eg. JDBConnection, SiebelWeBservicesConnection, SiebelBusinessServicesConnection, Oracle Connection. The Parameter are the key to the Mapping which determines which Connection Implemntation is used.Using the Concrete connection DAO will call the data base operation on the connection.
  6. Keep it simple[ Go to top ]

    Its said that if it is a pattern then it is nothing new it is an age old solution. Following this idiom, what you trying to do not qualify as any pattern. What you are doing out of track is:
    "In Our Approach we will be using IConnection Interface, which will encapsulate the methods for Data Operation, Add, Update, delete, execute and get."
    What is the motivation of putting CRUD operation methods in IConnection interface?


    Your problem can be solved by the two standard data access pattern:
        1. Data Access Object - J2EE pattern
        2. Factory - Java pattern
        3. Program to an interface - basic design principle
    1.Define DAOs with interfaces so that the concrete implementations are available only through DAO factory based on your configuration
    2.Let your concrete implementation know about its specific connection type
    3.Its better if you have a service locator which returns the data source to some connection util/helper, which you use in your daos to get connection handle
    So its simple. Lets not complicate matters