Announcement Announcement Module
Collapse
No announcement yet.
stereotype component and abstract Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • stereotype component and abstract

    hi

    I try to declare two bean, one wich is abstract and one wich extends the first one with the @component annotation but i don't know how to make it works


    Here is the XML i try to remove with the annotations
    Code:
    <bean id="abstractProcessor"
    		class="com.domain.AbstractProcessor"
    		abstract="true">
    	</bean>
    
    	<bean id=processor1"
    		class="com.domain.Processor1"
    		parent="abstractGeonamesProcessor">
    	</bean>
    Is there a way to do it with annotations

    Thanks
    David

  • #2
    Post your code what you have.

    Comment


    • #3
      Originally posted by david masclet View Post
      Here is the XML i try to remove with the annotations

      [....]

      Is there a way to do it with annotations
      The xml you can simplify to
      Code:
      <bean id=processor1" class="com.domain.Processor1"/>
      With annotations you get the same effect when you just annotate Processor1 with @Component (and turn on component scanning).

      It is important in this context that an abstract bean definition doesn't have the same relationship to its children as a superclass to it's subclasses. See http://static.springframework.org/sp...an-definitions

      Comment


      • #4
        hi, the abstract com.domain.AbstractProcessor and com.domain.Processor1 are effectively subclass (even if irt is not a correct design)

        i can not change it and it works in xml

        i ve made a test
        Code:
        public class Spring25Test extends AbstractDependencyInjectionSpringContextTests {
        
            private IProcessor processor1
            
           
        
            public void testIt(){
               assertNotNull(processor1);
            }
            
            @Required
            public void setProcessor1(IProcessor processor1) {
                this.processor1 = processor1;
            }
        the autowire is byName and when i run the test it says :
        processor1 is required for bean 'com.domain.Spring25Test'

        It works in xml...

        here is my class
        Code:
        @Component
        public class Processor1 extends AbstractProcessor
        Code:
        @Component
        public abstract class AbstractProcessor implements IProcessor
        here is my xml

        Code:
        <bean id="abstractProcessor"
        		class="com.domain.AbstractProcessor"
        		abstract="true">
        		<property name="transactionManager" ref="transactionManager" />
        		<property name="importerConfig" ref="importerConfig"></property>
        	</bean>
        
        <bean id="processor1"
        		class="com.domain.Processor1"
        		parent="abstractProcessor">
        	</bean>
        Last edited by david masclet; Mar 13th, 2008, 11:11 AM.

        Comment

        Working...
        X