I solved this by using Delegate class from web application to access Spring 
module beans. I defined business services for the web application, I tried to 
make the web application as slim as possible.

Made a delegate class which extends the business interface. And for that class 
I get the business class from the Application Context.

  | public class BusinessSearchDelegateImpl implements BusinessSearch { 
  |         private ApplicationContext springModuleContext;
  |     private final String BEAN = "BusinessSearchService";
  | 
  |     public void setSpringModuleContext(ApplicationContext 
springModuleContext) {
  |             this.springModuleContext = springModuleContext;
  |     }
  | 
  |         private BusinessSearch getSearchService()
  |                     throws TechnicalException {
  | 
  |             if (springModuleContext.containsBean(BEAN)) {
  | 
  |                     BusinessSearch service = (GenericSearchService) 
springModuleContext
  |                                     .getBean(BEAN);
  |                     return service;
  |             } else {
  |                     LOG.error("Component with name(" + BEAN + ") not found. 
");
  |                     throw new TechnicalException("Component with name(" + 
BEAN
  |                                     + ") not found. ");
  |             }
  |     }
  | 
  | public Customer findCustomer(String id) throws TechnicalException {
  |             return getSearchService().findCustomer(id);
  |     }
  | 
  | }

This class is configured in web application context  as following:
<!--  Business Service beans  -->
  |     <bean id="BusinessContext"
  |             class="org.springframework.jndi.JndiObjectFactoryBean">
  |             <property name="cache">
  |                     <value>true</value>
  |             </property>
  |             <property name="jndiName">
  |                     <value>d_business-enabler</value>
  |             </property>
  |     </bean>
  | 
  |     <bean id="BusinessSearchDelegate"
  |             class="com.som.pac.web.BusinessSearchDelegateImpl">
  |             <property name="springModuleContext">
  |                     <ref bean="BusinessContext" />
  |             </property>
  |     </bean>

And then that BusinessSearchDelegate is given to those controllers which needs 
the business services. 

I made it his way, and best thing was that I could add this delegate class to 
our utility jar, which is a jar module in ear file. 


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017520#4017520

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017520
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to