Announcement Announcement Module
Collapse
No announcement yet.
using maven's war overlay plug-in to manage some dependency injection. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using maven's war overlay plug-in to manage some dependency injection.

    Dear all,
    I've two basic projects. A base project called 'stock'defining some interfaces and provides defaults interfaces of them. Then those defaults implementations are defines as spring beans in a file applicationContext-extentions.xml file like this:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        <bean class="org.adorsys.stock.business.impl.BarCodeUsingImpl" id="barCodeUsingImpl">
        </bean>
    
        <bean class="org.adorsys.stock.business.impl.ManualEditingImpl" id="manualEditingImpl">
        </bean>
    
        <bean class="org.adorsys.stock.business.impl.CommandProcecs" id="commandProcecs">
        </bean>
    
        <bean class="org.adorsys.stock.business.impl.ProductNumberingImpl" id="productNumberingImpl">
        </bean>
    </beans>
    .
    I use this beans as @resource in my controller and services classes.
    then, create a concrete project called 'concretestock', which overlay the 'stock' and provide another definition of theses interface. and create a file named applicationContext-extensions.xml in the same directory as the one in the stock projet. like this :
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    <!--  -->
            <context:component-scan base-package="org.adorsys.office"/>
        <bean class="org.adorsys.office.business.impl.OfficeBarCodeUsingImpl" id="barCodeUsingImpl">
        </bean>
    </beans
    .
    Normally I wanted beans in the concrete module being used in when controller of the base projet will call the @resource annotation due to the capability of the war overlays. but It din't work.
    So, I asked you please if there is another way to go.

    (excuse my poor english)
    best regards,

  • #2
    It is ok now, I solved the problem
    If it could help someone . It was a complicated spring and mvn:jetty bug. As I unsed the applicationContext-extentions.xml, it was finding both files. I had to change the context param in web.xml of stock to explicilty read applicationContext-extension.xml. so, it doesn't fall back in the wild card scanning defined in the web.xml classpath*:META-INF/applicationContext*.xml.
    Here is the context param before (when not working):
    Code:
       <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
        </context-param>
    and now (when working):
    Code:
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/spring/applicationContext*.xml,classpath:META-INF/spring/applicationContext-extensions.xml</param-value>
        </context-param>
    .

    Comment

    Working...
    X