Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 89764

Pages: 1
JavaWorld
addict


Reged: 06/20/03
Posts: 482
Implement crosscutting concerns with Spring 2.0
      #42156 - 01/05/07 05:10 PM

Implement crosscutting concerns with Spring 2.0

Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: JavaWorld]
      #42499 - 01/15/07 11:40 AM

Nice article. Other than the JDBC transaction manager, does spring provide other transaction managers or are there example of custom transaction managrs. AOP sounds perfect for a need we have where we have to provide transactions for a custom data source (not jdbc)

Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: JavaWorld]
      #42624 - 01/16/07 06:37 PM

Hi,

It's a bit confusing to see System.out statements in your security aspect as you just laid out the logging aspect to get rid of System.out statements. Not sure whether you can solve it though.

Other than that, nice article.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ganesh_ghag
stranger


Reged: 01/10/07
Posts: 2
Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #42661 - 01/17/07 01:13 AM

Hi,
Apart from the JDBC (DataSource) Transaction Manager, spring supports Hibernate and JTA Transaction Manager(for distributed transactions requirement)
for non-JDBC custom datasources, you can write custom transaction manager in Spring, by implementing
interface PlatformTransactionManager and extending the abstract base class AbstractPlatformTransactionManager

http://www.springframework.org/docs/api/...ionManager.html

cheers,
Ganesh


Post Extras: Print Post   Remind Me!   Notify Moderator  
ganesh_ghag
stranger


Reged: 01/10/07
Posts: 2
Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #42662 - 01/17/07 01:22 AM

Hi,
Sys.outs in security logging, are only to test functioning of the security aspect as it executes.
I agree, even the security aspect, itself can be further enhanced and made to use logging aspect, using (aspect ordering), but depicting that (aspect using another aspect)might have confused the reader, so have not included that in the example source

cheers,
Ganesh


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2.0 [Re: JavaWorld]
      #43098 - 01/30/07 05:17 PM

Hi,

It looks I am missing
com.myorg.soa.services.entity.spring.test.EntityServiceSpringTest;
Could you kindly tell me where can I get the package?

Thanks
Feng


Post Extras: Print Post   Remind Me!   Notify Moderator  
Drew Gulino
Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #43301 - 02/06/07 03:17 PM

Nice article. Two fixes needed to get it to work:
1) The article used jdbc:odbc bridge for the security manager. It's easier to use the embedded DB HSQLDB that is included with Spring 2.0. Add lib\hsqldb\hsqldb.jar to the classpath and then modify the my-spring-config.xml:
<!--
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver"/>
<property name="url" value="jdbc:odbc:soadb"/>
<property name="username" value="admin"/>
<property name="password" value="password"/>
</bean>
-->

<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
<property name="url">
<value>jdbc:hsqldb:d:/workspace/Spring2aop/db/test</value>
</property>
<property name="username"><value>sa</value></property>
<property name="password"><value></value></property>
</bean>

2) Don't know what the EntityServiceSpringTest does but you can get the examples to work by changing MyTest.java:
From:
AuthenticationManager authenticationManager
=
(AuthenticationManager)EntityServiceSpringTest.context.getBean("authenticationManager");
To:
AuthenticationManager authenticationManager
= (AuthenticationManager)context.getBean("authenticationManager");


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #44060 - 03/03/07 03:51 AM

Hi,

When I try to start the source code that accompanies this article I get an error message:

Code:

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.aop.aspectj.AspectJExpressionPointcut
Caused by:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.aop.aspectj.AspectJExpressionPointcut
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.springframework.aop.config.ConfigBeanDefinitionParser.class$(ConfigBeanDefinitionParser.java:232)
at org.springframework.aop.config.ConfigBeanDefinitionParser.createPointcutDefinition(ConfigBeanDefinitionParser.java:544)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parsePointcut(ConfigBeanDefinitionParser.java:466)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parseAspect(ConfigBeanDefinitionParser.java:258)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parse(ConfigBeanDefinitionParser.java:157)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:78)
***



Thanks, M


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #44073 - 03/03/07 01:09 PM

^
My mistake. I had forgotten to include AspectJ library.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Lihua Gao
Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #47207 - 05/13/07 01:40 PM

You don't need the class. The application context "context" is defined in the class (MyTest) as a static variable.

Lihua Gao
gao@sinonet.de


Post Extras: Print Post   Remind Me!   Notify Moderator  
Annonymous
Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: ganesh_ghag]
      #49527 - 06/25/07 12:23 PM

Good article Ganesh.
I'm following exactly what you have mentioned for Transaction Management but somehow the transaction management is not working. I've spend lot of time figuring out whats going wrong. Following is my configuration file details:
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="applicationServiceMethods" expression="execution(* com.a.w.applicationservice.BaseService*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="applicationServiceMethods"/>
</aop:config>

I've XYZApplicationService which implements BaseService and has two DAO's inside(which I've specified in Bean.xml). To check the transaction management I'm calling one Dao method first (insert) and then another which trows NullPointerException. But first method inserts record in database even though second throws exception. Ideally the first method execution should have been rolled back but it doesn't. The DAO's extend HibernateDaoSupport.
Any idea whats going wrong ?


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implement crosscutting concerns with Spring 2. [Re: Anonymous]
      #55580 - 10/10/07 04:37 AM

Quote:

Hi,

When I try to start the source code that accompanies this article I get an error message:

Code:

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.aop.aspectj.AspectJExpressionPointcut
Caused by:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.aop.aspectj.AspectJExpressionPointcut
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.springframework.aop.config.ConfigBeanDefinitionParser.class$(ConfigBeanDefinitionParser.java:232)
at org.springframework.aop.config.ConfigBeanDefinitionParser.createPointcutDefinition(ConfigBeanDefinitionParser.java:544)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parsePointcut(ConfigBeanDefinitionParser.java:466)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parseAspect(ConfigBeanDefinitionParser.java:258)
at org.springframework.aop.config.ConfigBeanDefinitionParser.parse(ConfigBeanDefinitionParser.java:157)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:78)
***



Thanks, M




Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 8259

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5