java - BeanPostProcessor not called -


here's config.xml

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-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">      <context:component-scan base-package="com">        <context:include-filter type="assignable" expression="com.coc.frmwk.cmd.command"/>        <context:include-filter type="assignable" expression="com.coc.apps.sample.dao.sampledao"/>     </context:component-scan>  <bean id="mypostprocessor" class="com.coc.frmwrk.processors.mypostprocessor"> </beans> 

i know when using component-scan, default scope assigned beans "singleton" unless it's specified otherwise in xml configuration or using annotation @scope, that's cool, since i've figured out in application beans implementing specific interface (com.coc.frmwk.cmd.command) need have scope set "prototype", added class "scoperesolver" implements scopemetadataresolver , made little modification config.xml container takes account scope resolver :

<context:component-scan base-package="com" scope-resolver="com.coc.frmwk.processors.scoperesolver"> 

my problem beanpostprocessor used work perfectly, stops being called whenever add scope resolver ( context:component-scan base-package="com" scope-resolver="com.xxx.frmwk.processors.scoperesolver" ) , works again when omit stuff in bold.

any idea on how make beanpostprocessor works when scoperesolver configured ? thanks, mehdi.

edit: here's content of scope resolver

package com.coc.frmwk.processors;  import org.springframework.beans.factory.config.beandefinition; import org.springframework.context.annotation.scopemetadata; import org.springframework.context.annotation.scopemetadataresolver;  import com.coc.frmwk.cmd.command;  public class scoperesolver implements scopemetadataresolver{      @suppresswarnings("unchecked")     @override     public scopemetadata resolvescopemetadata(beandefinition definition) {         scopemetadata result = new scopemetadata();          class c= null;         try {             c = class.forname(definition.getbeanclassname());         } catch (classnotfoundexception e) {             e.printstacktrace();         }         if (command.class.isassignablefrom(c))         result.setscopename("prototype");         else         result.setscopename("singleton");          system.out.println("[scope resolver] " + definition.getbeanclassname() + "[" + result.getscopename() + "]");          return result;     }  } 

edit2: want point out beanpostprocessor in fact being called, apparently works beans except having scope changed scopemetedataresolver.

the behavior describe behavior expect. (at least @ startup), beanpostprocessor called bean constructed, prototype scoped bean constructed when requested. if don't use bean anywhere beanpostprocessor not called.

however judging want want modify recipe (the beandefinition , not created bean instance). chancing recipes need use beanfactorypostprocessor.

the difference beanpostprocessor operates on bean instances beanfactorypostprocessor works on bean creation recipes (the beandefinitions).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -