Attempting to describe basic steps/changes I am trying to 1>support
policies/intents and
2>external connection passing in DAS. These two need to go together, as
trying
transaction(y/n) intent at present and for this to test, need ability to
support passing db
connection from component impl to DAS instance.
-----------------------------------------------------------------------------------------------------------------------------
Requirements:(specific to implementation.das) -
1) intents and policies can be defined at implementation level. With this
one
implementation.das gets tied to one set of policies defined in
das.compositeat assembly
time. So to use same DAS config with different set of policies, another
component with
another implementation.das is required. implementation.das will ignore
intents and policies
defined at any other level (at least for the time being)

To begin with only 2 intents are experimented with
a> transaction (tx controlled by SCA runtime), b> noTransaction (tx
controlled by DAS)

e.g.
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
    xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0";
    targetNamespace="http://sample/das";
    name="das">

    <component name="DASServiceComponentExtTxn">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
           requires="transaction">
        <tuscany:connectionInfo>
        <tuscany:connectionProperties
            driverClass="org.apache.derby.jdbc.EmbeddedDriver"
            databaseURL="jdbc:derby:target/test-classes/dastest; create =
true"
            loginTimeout="600000"/>
        </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>

    <component name="DASServiceComponentDASTxn">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
           requires="noTransaction">
          <tuscany:connectionInfo>
        <tuscany:connectionProperties
            driverClass="org.apache.derby.jdbc.EmbeddedDriver"
            databaseURL="jdbc:derby:target/test-classes/dastest; create =
true"
            loginTimeout="600000"/>
      </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>
</composite>
-----------------------------------------------------------------------------------------------------------------------------
2) At present, implementation.das has provision to define connectionInfo
which helps DAS to
create and manage Connection and Txn internally. (equiv. managedtx=true).
This is eqiv. to
intent b> "noTransaction".

In order to support intent a> "transaction", (equiv. managedtx=false),
implementation.das needs a way to pass external connection to DAS instance.
Details of DAS Txn control -
http://incubator.apache.org/tuscany/rdb-das-transaction-control.html.

The externally passed Connection can be JDBC or JTA. Also a JDBC connection
can come from DriverManager or DataSource. implementation.das needs to
support all of this.
-----------------------------------------------------------------------------------------------------------------------------
3) validations:
There is a possibility that the DAS Config (may it be a separate file like
one from above
example CompanyConfig.xml or may it be the info passed from das.composite to
DAS instance  through <tuscany:connectionInfo>) , there is a chance that
there can be conflicts
in the DAS Config and intent/policies.

e.g. intent=transaction, managedtx=true(or absent which means true -as it is
the default value)
OR
intent=noTransaction, managedtx=false.

For such conflicts, I am throwing different exceptions at present. Will this
be the right thing
to do or is it better to define some overriding logic (like intents have
higher priority over DAS Config ...Suggestions?)

so I am trying to throw exceptions for below cases
a> DAS Config (dasconfig.xml/das.composite portion) has ConnectionInfo with
either ConnectionProps  or DataSource and intent=transaction

Exception: DAS is internally managing Connection/Transaction, can not
support intent "transaction"

b> Both , dasconfig.xml and das.composite provide ConnectionInfo

Exception: ConnectionInfo defined in multiple places.

c> DAS Config has managedtx=true, das.composite has intent="transaction"

Exception: Intent and DAS Config in conflict:- Intent "transaction" can not
be supported when DAS manages connection/transaction internally

d>  DAS Config has managedtx=false, das.composite has intent="noTransaction"

Exception: Intent and DAS Config in conflict:- Intent "noTransaction" can
not be supported when DAS does not manage connection/transaction internally

e> intent=transaction and DAS Config has not defined managedtx (so default
true)

Exception: When intent="transaction", DAS Config needs to explicitly define
managedtx=false

f> It is acceptable if intent=noTransaction(and managedtx=true) and
connection is passed to DAS from SCA Runtime, the user needs to ensure that
DAS alone is managing Txn
-----------------------------------------------------------------------------------------------------------------------------
4) At present, the below 2 examples show that implementation.das (and
dasconfig.xml) support a way to provide connection info to DAS instance for
internally created/managed connection

e.g.
/*Driver Manager*/

    <component name="DASServiceComponent"  requires="transaction">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
          requires="transaction">
          <tuscany:connectionInfo>
        <tuscany:connectionProperties
            driverClass="org.apache.derby.jdbc.EmbeddedDriver"
            databaseURL="jdbc:derby:target/test-classes/dastest; create =
true"
            loginTimeout="600000"/>
      </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>

/*DataSource*/
    <component name="DASServiceComponent"  requires="transaction">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
          requires="transaction">
       <tuscany:connectionInfo datasource="mydsname">
       </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>

-----------------------------------------------------------------------------------------------------------------------------
But we need a way for the other option - pass external
(JDBC-DriverManager/DataSource OR JTA)  connection to DAS instance.

For this I propose changes like below examples. This way it will be
consistent to the current design.
e.g.
Note: externalConnection=false by default
/*Driver Manager*/
    <component name="DASServiceComponent"  requires="transaction">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
           requires="transaction">
          <tuscany:connectionInfo externalConnection="true"
mode="jdbc-driverManager">
        <tuscany:connectionProperties
            driverClass="org.apache.derby.jdbc.EmbeddedDriver"
            databaseURL="jdbc:derby:target/test-classes/dastest; create =
true"
            loginTimeout="600000"/>
      </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>
-----------------------------------------------------------------------------------------------------------------------------
Note:For below, the SCA runtime (by itself or from its container) should
have a JNDI Context entry for the datasource, das.implementation will look
it up and pass to DAS instance. At present  attempting the same through a
test case.
/*DataSource*/
    <component name="DASServiceComponent"  requires="transaction">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
          requires="transaction">
       <tuscany:connectionInfo datasource="mydsname"
externalConnection="true"
         mode="jdbc-dataSource">
       </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>
-----------------------------------------------------------------------------------------------------------------------------
Note: For below assuming the SCA runtime should supply a Transaction Manager
instance
(like Geronimo) and implementation.das is responsible for using it by tying
a xaconnection
resource to the transaction support provided by TM. At present mimicing it
by having a small
package in tuscany-implementation-das for Geronimo Transaction Manager. This
can be obsoleted when the same is available from SCA runtime. Also, it is
seen that different XADataSource impls require diff set of setter methods,
so trying to keep it flexible.
e.g.
MySQL:
((MysqlXADataSource) xads).setUser(dbcfg.getConnectionInfo
().getConnectionProperties().getUserName());
((MysqlXADataSource) xads).setPassword(dbcfg.getConnectionInfo
().getConnectionProperties().getPassword());
((MysqlXADataSource) xads).setUrl(dbcfg.getConnectionInfo
().getConnectionProperties().getDatabaseURL());

Derby:
((EmbeddedXADataSource) xads).setCreateDatabase("create");
((EmbeddedXADataSource) xads).setDatabaseName("target/dastest");

/*XA*/
    <component name="DASServiceComponent"  requires="transaction">
        <tuscany:implementation.das config="/CompanyConfig.xml"
dataAccessType="rdb"
          requires="transaction">
       <tuscany:connectionInfo datasource="mydsname"
externalConnection="true" mode="jta">
          <tuscany:xaConnectionProperties
              xaDataSouceClass="
com.mysql.jdbc.optional.xyz.MysqlXADataSource">
                <tuscany:xaDataSourceConfig>
                   <tuscany:xaMethod name="setXXX" value="valXXX" />
                   <tuscany:xaMethod name="setYYY" value="valYYY" />
          </tuscany:xaDataSourceConfig>
          </tuscany:xaConnectionProperties>
       </tuscany:connectionInfo>
    </tuscany:implementation.das>
    </component>
-----------------------------------------------------------------------------------------------------------------------------
Please give me all comments/feedback to refine the above.

regards,
amita

On 9/14/07, Luciano Resende <[EMAIL PROTECTED]> wrote:
>
> Hey, very good, some comments inline
>
> One question that I have is regarding the Transaction Manager, who is
> responsible for creating the transaction manager ? The SCA runtime, or
> implementations ? In the case of SCA runtime, we need to investigate
> that part, but I guess we can start by having it under the
> implementation as a proof of concept for now.
>
> On 9/13/07, Amita Vadhavkar <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I have given this a try based on what I tried in JIRA-1665 (Sample Using
> > JOTM with DAS)
> > Here also I am using JOTM with SCA+DAS. Currently played with 2 simple
> > intents:
>
> I think we are going to use geronimo transaction manager with SCA
> integration, and there is a sample on implementation.bepel on how to
> use it, it's very simple, could you try using that one ?
>
> > a> transaction (Tx management from External TM), b> noTransaction (Tx
> > management from DAS)
> >
> > The only changes needed are as below:-
> > A> tuscany-data-engine-helper:-
> > 1)DataAccessEngineManager
> > new method getDAS(String config, ConnectionInfo connectionInfo,
> List<Intent>
> > intents, List<PolicySet> policySets)
> > Here if intent "a>transaction" is detected, ConnectionInfo.setManagedTx
> (false)
> > will be called.
> > This modified connnectionInfo will be passed through configHelper to the
> new
> > DAS instance.
> > This way if external TM is going to manage Tx, DAS is signaled for it.
> >
>
> Great... I'll leave comments on the policy side to Venkat or Sebastien
> or others that have been playing on this area...
>
> > And logic to support this method
> >
> > 2) ConnectionInfo
> > new attribute managedtx with setter/getter
> >
>
> Ok
>
> > B> tuscany-implementation-das
> > 1) DASImplementation implements PolicyAttachPoint
> >
> > 2) DASImplementationProcessor
> > read(reader) - will read policies and intents on DASImplementation from
> > .composite
> >
>
> Who should read here, implementation.das or we should delegate to the
> policy artifact processors ?
>
> Ans: it will be done by policy processor




> 3) DASImplementationProvider
> > createInvoker() will call getDAS(passing config, connectioninfo,
> intents,
> > policies)
> > same will be for createCallbackInvoker()
> >
>
> What other information you will need from intents and policies when
> creating DAS ? you already passed the managed transaction flag inside
> the connectionInfo, right ? Note that there is still support for a das
> config file, how are you going to manage that ? We probably need to
> throw an exception if DAS config file sets does NOT set the managed
> transaction flag, but transaction policy is set.
>
> > With these above changes and with setup similar to JIRA-1665 sample, I
> could
> > see
> > that the external connection is being used by DAS (naming service is
> > resolving
> > datasource properly).
> >
> > The point I am stuck at is, in RDB-DAS, when we use external DS, we do
> not
> > pass
> > userName, password. But MYSQL (which with InnoDB supports Txn and works
> well
> > with JOTM) does need id, pwd in ds.getConnection(). This can be case
> with
> > other DBs as well.
> >
> > So, it looks like DAS config.xsd needs to allow passing userName,
> password
> > in ConnectionInfo too ( and not just for ConnectionProperties).
> >
> > Thus below will be the changed DAS config portion:-
> >    <xsd:complexType name="ConnectionInfo">
> >       <xsd:sequence>
> >         <xsd:element  maxOccurs="1" minOccurs="0"
> > name="ConnectionProperties" type="config:ConnectionProperties"/>
> >       </xsd:sequence>
> >       <xsd:attribute name="dataSource" type="xsd:string"/>
> >       <xsd:attribute name="managedtx" type="xsd:boolean"
> default="true"/>
> >       <xsd:attribute name="userName" type="xsd:string" default=""/>
> >       <xsd:attribute name="password" type="xsd:string" default=""/>
> >    </xsd:complexType>
> >
> >    <xsd:complexType name="ConnectionProperties">
> >          <xsd:attribute name="driverClass" type="xsd:string"/>
> >          <xsd:attribute name="databaseURL" type="xsd:string"/>
> >          <xsd:attribute name="loginTimeout" type="xsd:int"
> > default="0"/>
> >    </xsd:complexType>
> >
>
> Create a DAS jira for this, and we can investigate further...
>
> > Suggestion? If this looks OK, I would like to make the above changes and
> > create a sample in tuscany-implementation-das demoing use of intent and
> ext
> > TM.
>
> I have a demo in progress, probably is good to have a test case for
> now, and we could incorporate transaction support on the demo.
>
> > Will give a try with geronimo as well.
>
>
> >
> > Regards,
> > Amita
> >
> > On 9/2/07, Jean-Sebastien Delfino <[EMAIL PROTECTED]> wrote:
> > >
> > > [snip]
> > > Luciano Resende wrote:
> > > > I guess your suggestion for starting simple is fine, and I guess
> > > > implementation.das could get integrated with SCA Policy and DAS
> would
> > > > have the necessary support, unless we find some bugs on the DAS
> side.
> > > > I'll see if I can get to this in the coming weeks...
> > > >
> > > > BTW, what transaction manager are we going to use in Tuscany ?  Do
> we
> > > > have any today ?
> > > >
> > >
> > > Two suggestions:
> > > - in a standalone environment, use JOTM [1]
> > > - in Geronimo, get the TM from Geronimo, as done in the
> Tuscany/Geronimo
> > > plugin at [2]
> > >
> > > [1] http://jotm.objectweb.org/
> > > [2] http://svn.apache.org/repos/asf/geronimo/plugins/tuscany
> > >
> > > --
> > > Jean-Sebastien
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
>
>
> --
> Luciano Resende
> Apache Tuscany Committer
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to