Announcement Announcement Module
Collapse
No announcement yet.
ProxyFactoryBean overrides equals() method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ProxyFactoryBean overrides equals() method

    I am introducing a new interface (Markable) to my object. In my object's implementation, I have overridden the .equals() method to do custom comparison.

    However, after I inject the new interface into my class, the .equals() method gets overridden back to a default or some other implementation.

    Also, please note, if i add the final keyword to my equals method, then the desired behavior occurs. However, this implies that I am using AOP, and I would prefer not to use the final keyword.

    Code:
    public boolean equals&#40;Object arg0&#41; <-- correct but does not work
    
    public final boolean equals&#40;Object arg0&#41; <-- incorrect but works
    I am hoping to introduce a new interface via the ProxyFactoryBean but somehow turn off the .equals() automatic override. Also, if possible, I'd prefer to do this at the interface level rather than at the class level using CGLIB.

    This is my Interceptor code which introduces the new interface:

    Code:
    public interface Markable
    &#123;    
        public MarkableStatus getMarkableStatus&#40;&#41;;
        
        public void setMarkableStatus&#40;MarkableStatus status&#41;;
    &#125;
    
    public class MarkableMixin extends DelegatingIntroductionInterceptor implements Markable
    &#123;
        private MarkableStatus markableStatus = MarkableStatus.DELETED;
    
        public MarkableStatus getMarkableStatus&#40;&#41;
        &#123;
            return this.markableStatus;
        &#125;
    
        public void setMarkableStatus&#40;MarkableStatus status&#41;
        &#123;
            this.markableStatus = status;
        &#125;
    
        public Object invoke&#40;MethodInvocation invocation&#41; throws Throwable
        &#123;
            // TODO&#58; implement thsi
            return super.invoke&#40;invocation&#41;;
        &#125;
    &#125;
    My Xml Configuration looks like this:

    Code:
    <bean id="markableIntroductionAdvisor" class="com.archinsurance.integration.policy.archlink.impl.MarkableMixin"/>
    <bean id="roeProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="target">
    			<ref local="roeTarget"/>
    		</property>
    		<property name="interceptorNames">
    			<list>
    				<value>markableIntroductionAdvisor</value>
    			</list>
    		</property>
    		<property name="proxyTargetClass">
    			<value>true</value>
    		</property>
    	</bean>
    	<bean id="roeTarget" class="com.archinsurance.integration.policy.archlink.impl.RiskObjectExposureImpl" />
    Any pointers in the right direction would be appreciated!
    Thanks!

    Adam
Working...
X