The Spring team's recommendation is that you only annotate concrete classes with the @Transactional annotation, as opposed to annotating interfaces. You certainly can place the @Transactional annotation on an interface (or an interface method), but this will only work as you would expect it to if you are using interface-based proxies. The fact that annotations are not inherited means that if you are using class-based proxies (proxy-target-class="true") or the weaving-based aspect (mode="aspectj") then the transaction settings will not be recognised by the proxying/weaving infrastructure and the object will not be wrapped in a transactional proxy (which would be decidedly bad). So please do take the Spring team's advice and only annotate concrete classes (and the methods of concrete classes) with the @Transactional annotation.
Note: In proxy mode (which is the default), only 'external' method calls coming in through the proxy will be intercepted. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object, won't lead to an actual transaction at runtime even if the invoked method is marked with @Transactional!
Consider the use of AspectJ mode if you expect self-invocations to be wrapped with transactions as well. In this case, there won't be a proxy in the first place; instead, the target class will be 'weaved' (i.e. its byte code will be modified) in order to turn @Transactional into runtime behavior on any kind of method.
Showing posts with label Spring. Show all posts
Showing posts with label Spring. Show all posts
Tuesday, 17 November 2009
Sunday, 22 March 2009
RIA - Flex with BlazeDS and Spring Integration
1. Create a new Flex Project with following selections :
Project name: HelloWorld
Application server type: J2EE
Select 'Use remote object access service with LiveCycle data Service'
Select 'Create combined Java/Flex project using WTP'
On Next screen -> Select the appropriate Target runtime.
Flex WAR File - point to blazeds.war file.
On Next screen -> select serverport as configured on your system.
Click, Finish.
2. Under src folder, create a new java class 'HelloWorld' with method signature as follows :
public String sayHello(String name)
3. Declare the spring dispatcher servlet in web.xml file as shown in following fig. All the spring beans will be defined in file 'web-application-config.xml'.

4. Create spring configuration file (helloworldservlet.xml) under WEB-INF folder. Do not declare any spring beans in this file.
5. Create web-application-config.xml under WEB-INF/config directory. Declare the HelloWorld bean and expose it as mentioned below.

6. Add the necessary libraries in lib folder in WEB-INF .
7. Add the default channel in service-config.xml file. This is very important. Enable the channels by providing server name, port name and content root.
8. Add the following code to HelloWorld.mxml file between mx:Application elements.

9. Start the server. Ensure that application is deployed properly.
10. Run the HelloWorld.html file under bin-debug by right click -> Run as -> Run On server by selecting proper server.
11. Enter your name and click the Submit button. Application should respond with Greetings to you !

Hope this helps you !
Project name: HelloWorld
Application server type: J2EE
Select 'Use remote object access service with LiveCycle data Service'
Select 'Create combined Java/Flex project using WTP'
On Next screen -> Select the appropriate Target runtime.
Flex WAR File - point to blazeds.war file.
On Next screen -> select serverport as configured on your system.
Click, Finish.
2. Under src folder, create a new java class 'HelloWorld' with method signature as follows :
public String sayHello(String name)
3. Declare the spring dispatcher servlet in web.xml file as shown in following fig. All the spring beans will be defined in file 'web-application-config.xml'.
4. Create spring configuration file (helloworldservlet.xml) under WEB-INF folder. Do not declare any spring beans in this file.
5. Create web-application-config.xml under WEB-INF/config directory. Declare the HelloWorld bean and expose it as mentioned below.

6. Add the necessary libraries in lib folder in WEB-INF .
7. Add the default channel in service-config.xml file. This is very important. Enable the channels by providing server name, port name and content root.
8. Add the following code to HelloWorld.mxml file between mx:Application elements.

9. Start the server. Ensure that application is deployed properly.
10. Run the HelloWorld.html file under bin-debug by right click -> Run as -> Run On server by selecting proper server.
11. Enter your name and click the Submit button. Application should respond with Greetings to you !

Hope this helps you !
Subscribe to:
Posts (Atom)