Issue 1:
Deepak Kalra opened SPR-586 and commented

Hi,

I am in the process of designing the architecture using Spring Framwork.

We are looking for the solution as follows

Client calls the EJB Layer and EJB Layer initiates the transaction management i.e. Stateless Session Bean with CMT. Stateless Session Bean in turn calls the Spring Service Layer Which in turn calls the POJO i.e. Hibernate.

My Question is If I will set the Session Beam Transaction as REQUIRES_NEW i.e. JTA Application Server and Service Layer of Spring Framework will be using JTATransaction and method is having PROPAGATION as Required Transaction.

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">

<property name="jndiName"><value>jdbc/jpetstore</value></property>

</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">

<property name="dataSource"><ref local="dataSource"/></property>

<property name="mappingResources">

<value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">${hibernate.dialect}</prop>

</props>

</property>

</bean>

<bean id="transactionManager"

class="org.springframework.transaction.jta.JtaTransactionManager"/>

Will this work architecture work. As EJB has initiated the transaction. Will it possible that POJO method works in the same transaction or Not. I will appreciate If you guys can help me out.

Kind Regards

Deepak

Issue Links:

#5318 Integration of EJB CMT with Spring Framework ("duplicates")

Issue 2:
Rodrigo Urubatan Ferreira Jardim opened SPR-1987 and commented

I think some bean definitions are just configuration, as the Data Source, Transaction Manager, Mail Server, ...

but most of then are the application code, and not configuration.

for the seccond case, I think it would be very easy and clean, to register it on the application with annotations, because it would use a lot less code than the XML approach, and this beans registrations (like my application DAOs, or my Spring MVC controllers), does not change during the life time of any application.

for this to be reached it would be necessary to scan the classpath for the annotated classes.

I have wrote a litle bouch of classes that make the application context behave exaclty this way, enabling it to use bean registration by annotations.

please consider including it in spring framework as an optional extension.

I`m not sure the application way I did it (creating another application context class) is the best one, but it is an idea of implementation for it :D

the code I have wrote is atacched.

what it does right now is:

@Bean - equals to <bean>

autoWire (NO, BY_NAME, BY_TYPE, INHERITED)

dependencyCheck

destroyMethod

factoryMethod

initMethod

lazy

name

scope (APPLICATION, REQUEST, SESSION) - short cut to aop:scope

singleton

@UrlMapping - attaches the bean to a URL using an bean factor post processor (AnnotationHandlerMaping)

@UrlMappings - enables multiple UrlMappings per bean

@Property

@ConstructorArgs

in the code, there is an example applicationContext.xml that enables WebServices using JSR 181 webservices through xfire/spring integration, and has already a propertyPlaceholderConfigurer.

the annotation scan, for now scans every directory/jar in the classpath, that contains a file names to.properties in the root, and the propertyPlaceholderConfigurer uses this files too.

with this jar, I was able to define only a datasource, transaction manager,sessionFactory,tx:annotation-driven,and a defaultViewResolver

and write all the rest of my application without touching in a XML file.

this way, all I need to know about my beans was in the bean code.

the installation of it is preaty clean too:

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" version="2.4"

xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>TO - Novo Site</display-name>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath*:applicationContext.xml</param-value>

</context-param>

<context-param>

<param-name>contextClass</param-name>

<param-value>

br.com.techoffice.spring.web.TOAnnotationXmlWebApplicationContext

</param-value>

</context-param>

<listener>

<listener-class>

org.springframework.web.context.ContextLoaderListener

</listener-class>

</listener>

<filter>

<filter-name>requestContext</filter-name>

<filter-class>

org.springframework.web.filter.RequestContextFilter

</filter-class>

</filter>

<filter-mapping>

<filter-name>requestContext</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

<servlet>

<servlet-name>dispatcher</servlet-name>

<servlet-class>

org.springframework.web.servlet.DispatcherServlet

</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>dispatcher</servlet-name>

<url-pattern>*.to</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>dispatcher</servlet-name>

<url-pattern>/web/*</url-pattern>

</servlet-mapping>

</web-app>

a blank dispatcher-servlet.xml (does this is really needed? what if I want all my configuration to be application-wide, I really need to create a xml file to each servlet, or in this case to the only servlet I have?)

again, please consider it as an optional module for spring framework.

and thanks for the great framework, it has saved a few of my projects in clients in the last 2 years.

Attachments:

spring-annotations.zip (13.03 kB)

Issue Links:

#8169 Enable the definition of beans in the application context using annotations instead of XML, but do it right ("is duplicated by")

4 votes, 5 watchers