PDA

View Full Version : Please help with declarative transaction config


CNemo7539
06-22-2007, 09:28 PM
Hi All!

I have following config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.ConfigParsersSectionHandler , Spring.Core"/>
</sectionGroup>
</configSections>

<spring>
<context>
<resource uri="config://spring/objects"/>
<resource uri="file://dbProviders.xml"/>
</context>
<parsers>
<parser namespace="http://www.springframework.net/database"
type="Spring.Data.DatabaseConfigParser, Spring.Data"
schemaLocation="assembly://Spring.Data/Spring.Data/spring-database.xsd" />
</parsers>

<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:v ="http://www.springframework.net/validation"
xmlns:tx="http://www.springframework.net/schema/tx"
xmlns:db="http://www.springframework.net/database"
xsi:schemaLocation=" http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects.xsd
http://www.springframework.net/schema/tx http://www.springframework.net/schema/tx/spring-tx-1.1.xsd
http://www.springframework.net/database http://www.springframework.net/schema/db/spring-database.xsd">

<db:dbProvider id="DbProvider" provider="DB2Provider" connectionString="database=pcow"/>

<object id="transactionManager" type="Spring.Data.AdoPlatformTransactionManager, Spring.Data">
<property name="DbProvider" ref="DbProvider"/>
</object>

<object id="adoTemplate" type="Spring.Data.AdoTemplate, Spring.Data">
<property name="DbProvider" ref="DbProvider"/>
</object>

<object id="StateInformationReader" type="SafeAuto.Framework.DataAccess.StateInformationRead er, SafeAuto.Framework.DataAccess">
<property name="Template" ref="adoTemplate"/>
</object>

<object id="StateInfo" type="SafeAuto.Framework.Business.StateInformation, SafeAuto.Framework.Business">
<property name="Reader" ref="StateInformationReader"/>
</object>

<tx:attribute-driven/>

</objects>
</spring>
</configuration>

When I run app it throws exception "The 'http://www.springframework.net/schema/tx:attribute-driven' element is not declared."

What I'm doinf wrong?

CNemo7539
06-22-2007, 09:50 PM
Ok!

I've figured how to solve this problem. But now i have another one.

StateInfo has method with [Transaction] attribute and I can see in debugger that it is not the real object but proxy, which is fine. The problem is that Reader is not injected in this instance.

Both classes are plain stupid tests and do not have anything other in functionality department.

Should i mark reader class somehow?

Bruno Baia
06-25-2007, 12:31 AM
Hi,

Have you try to desactivate <tx:attribute-driven/> and see if it works ?


- Bruno

CNemo7539
06-25-2007, 03:40 AM
Actually I've found that everything was working from very beginning.

That was kind of my fault, because I didn't defined interfaces and worked with classes, where methods where not virtual. Once I realized that field is injected in one instance but method called from another, I corrected the problem by doing method and property virtual.

Any way would be nice to read some information how proxies created and function, what is the rules of proxying, etc.

Bruno Baia
06-25-2007, 07:30 AM
Hi,

You'll find informations in the reference documentation :
12.5.3. Proxying Interfaces (http://www.springframework.net/doc-1.1-M1/reference/html/aop.html#aop-proxying-interfaces)
12.5.4. Proxying Classes (http://www.springframework.net/doc-1.1-M1/reference/html/aop.html#d0e7675)

HTH,
Bruno

CNemo7539
06-25-2007, 03:13 PM
Thanks!

I still have a lot docs to read!