I finally have some time to send my configuration and packaging.
ear:
web.war
web-ws.war
service.jar
util-dao.jar
util-platform.jar
util-messages.jar
util-security.jar
websphere-env-context.jar
...
hibernate, spring,jdbc,log4j, commons jars
web.xml from module "web"
Code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/strutsContext.xml, classpath:/messages-context.xml,
classpath:/validators-context.xml
</param-value>
</context-param>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>
classpath*:pl/web/context/*-env-context.xml
</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<param-value>servicesContext</param-value>
</context-param>
web.xml of module "web-ws"
Code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-ws.xml,
classpath:/validators-context.xml
</param-value>
</context-param>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>classpath*:pl/web/context/*-env-context.xml</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<param-value>servicesContext</param-value>
</context-param>
<servlet>
<display-name>
sss</display-name>
<servlet-name>spring-ws</servlet-name>
<servlet-class>
org.springframework.ws.transport.http.MessageDispatcherServlet
</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
locatorFactorySelector points to file pl/web/context/websphere-env-context.xml which is inside websphere-env-context.jar
The source of websphere-env-context.xml
Code:
<bean id="servicesContext" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value type="java.lang.String">service-context.xml</value>
<value type="java.lang.String">util-dao-context.xml</value>
<value type="java.lang.String">websphere-util-dao-context.xml</value>
<value type="java.lang.String">util-security-context.xml</value>
</list>
</constructor-arg>
</bean>
The source of service-context
Code:
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager" order="200"/>
<!-- <aop:aspectj-autoproxy/> -->
<context:annotation-config />
<bean id="timeMeasureinterceptor" class="pl.spring.interceptor.TimeMeasureInterceptor">
<property name="tier" value="tier"/>
</bean>
<bean id="modulesInterceptor" class="pl.spring.interceptor.ModulesInterceptor"/>
<aop:config proxy-target-class="false">
<aop:aspect ref="timeMeasureinterceptor" order="1">
<aop:around method="doBasicProfiling" pointcut="bean(*Validator) or bean(*Manager) or bean(*DAO)"/>
</aop:aspect>
</aop:config>
<aop:config proxy-target-class="false">
<aop:pointcut id="modulesInterceptor" expression="bean(authorizationModule) or bean(administrationModule) or bean(informationModule)"/>
<aop:advisor advice-ref="dracoModulesInterceptor" order="10" pointcut-ref="dracoModuleInvocations" />
</aop:config>
...
bussiness beans
</beans>
util-dao-context.xml consist of definition of HibernateTransactionManager and daos. It does not define any aop beans nor aop elements.
validators-context.xml define only validator (our custom validation ) beans, each of the validator bean is prototype. no aop configuration
websphere-util-dao-context.xml - websphere datasource and websphere specific lob handler, no aop configuration
util-security-context.xml :
Code:
<bean id="authorizationModule" class="pl.stub.AuthorizationModuleStub"/>
<bean id="administrationModule" class="pl.stub.AdministrationModuleStub"/>
<bean id="informationModule" class="pl.stub.InformationModuleStub"/>
<bean id="privilegesInterceptor" class="pl.spring.interceptor.PrivilegesInterceptor"/>
<aop:config proxy-target-class="false">
<aop:advisor advice-ref="privilegesInterceptor" pointcut="execution(* pl.api.information.InformationModule.getUserPrivileges(..))"/>
</aop:config>
As provided above web module has web context that consists of 3 files: strutsContext.xml, messages-context.xml, validators-context.xml.
Strutscontext.xml contains beans that act as Struts2 actions and has no aop configuration.
messages-context.xml defines single bean of type org.springframework.context.support.ResourceBundle MessageSource
validators - described above.
Web-ws module has 2 contexts: one defined by a file with the same name as servlet that handles web services requests calls, and the second that consists of 2 files: applicationContext-ws.xml, validators-context.xml.
spring-ws.xml;
Code:
<bean id="wsd" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schemaCollection" ref="schemaCollection"/>
<property name="portTypeName" value="port"/>
<property name="locationUri" value="http://localhost:9080/web-ws/services"/>
<property name="targetNamespace" value="http://www.foo.bar.pl/spring-ws/schemas/messages"/>
</bean>
validators-context - was described above (i know i could load validators-context.xml in shared context)
applicationContext-ws.xml:
Code:
<context:annotation-config/>
<bean id="messageFactory"
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<constructor-arg>
<bean
class="com.ibm.ws.webservices.engine.soap.MessageFactoryImpl" />
</constructor-arg>
</bean>
<oxm:jaxb2-marshaller id="marshaller"
contextPath="pl.ivmx.dol.ws.schema" />
<bean id="requestContextBindingAspect" class="pl.ws.aspects.RequestContextBindingAspect"/>
<aop:config proxy-target-class="false">
<aop:advisor advice-ref="requestContextBindingAspect" order="1" pointcut="execution(* org.springframework.ws.server.endpoint.MessageEndpoint.*(..))" />
</aop:config>
<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection"
lazy-init="true">
<description>
<property name="xsds" value="/messages.xsd" />
<property name="inline" value="true" />
</bean>
...
endpoints definition
Using the configuration i provided above all beans defined in applicationContext-ws.xml are intercepted by timeMeasureinterceptor.
If i added test.xml file:
Code:
<bean id="testKlasa" class="pl.ws.util.TestKlasa"/>
And add it to webservices module web.xml file, "testKlasa" bean is also wrapped in timeMeasureInterceptor proxy.
Marten, Can you explain me why all this happens...