Results 1 to 6 of 6

Thread: How did AnnotationConfigWebApplicationContext setup the rootBeanDefinition ?

  1. #1
    Join Date
    Jan 2013
    Location
    Dalian,PRC
    Posts
    5

    Exclamation How did AnnotationConfigWebApplicationContext setup the rootBeanDefinition ?

    Hi, Spring experts and Forum Friends,

    I've issue confused me , How many steps need to be made sure when change XML based applicationContext to Annotation-based applicationContext.

    When I do this things , I've successfully changed applicationContext configuration of spring-ws, by overwrite the method
    "protected WebApplicationContext createWebApplicationContext(ApplicationContext parent)".
    In it, I just copy all of the statements of the method in super Class MessageDispatcherServlet, and add this
    "
    Code:
    ((AnnotationConfigWebApplicationContext)wac).register(MyOwnConfiguration.class);
    " before was.refresh(), of course "
    Code:
    this.setContextClass(AnnotationConfigWebApplicationContext.class);
    " is required in the constructor. It's really can do bean Injection after I did this. Then I read the "web-services-2.0.xsd" file to configur some ws required beans in MyOwConfiguration.class, it also worked. Then I'm sure I did successfully in spring-ws.

    But while I did the same operation in apache-cxf , It's failed, in the same MyOwnConfiguration.class, in it, I found the
    @Bean BeanType beanName(){} , although which can prepared beans, but after it was called, the @Resource public void setBean(BeanType bean) did not execute. And deeply, I found in AbstractBeanFactory, the statements below are executed in wrong case:
    Code:
    final RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
    			checkMergedBeanDefinition(mbd, beanName, args);
    The gotten mbd is wrong , because it bring a Root[null] info. But the check statements could execute without any exception throwout.


    So Here I consult every friend , do you have any idea on config rootBeanDefinition for AnnotationConfigWebApplicationContext?
    Last edited by palmtale; Feb 1st, 2013 at 02:53 AM. Reason: Add code tag

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    One question... Why on earth are you doing that, why aren't you using springs own mechanisms instead of hacking your own together.. Specify the contextConfigClass property and simply use the contextConfigLocation to specify which classes to load.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jan 2013
    Location
    Dalian,PRC
    Posts
    5

    Default

    Sorry, What did you mean? Also specified stuff in web.xml?
    I did just want to know why it can go well in spring-ws MessageDispatcherServlet, but cannot go well in apache-cxf CXFServlet.
    These 2 Servlets both reconfigurated XmlApplicationContext as the self-def sub-applicationContext,
    I just want to change it to AnnotationConfigWebApplicationContext, so overwrite the createApplicationContext(parentAppContext) method.
    Last edited by palmtale; Feb 1st, 2013 at 03:02 AM. Reason: Update

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Why are you overriding those methods just to add a configuration class, that can all be done by configuration instead of hacking together your own servlet.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jan 2013
    Location
    Dalian,PRC
    Posts
    5

    Default

    Thanks, you mean set initParam to point the self-def configedBeans.xml? But I don't want to setup any configuration.xml, Just use one properties file to arrange configuration.

  6. #6
    Join Date
    Jan 2013
    Location
    Dalian,PRC
    Posts
    5

    Default

    Well, I've found the cause by checking tomcat console log, It's necessary to execute the bean's init-method. So when init a new EndpointImpl(org.apache.cxf.jaxws.EndpointImpl), should call it's init method publish(). For my case, 2 ways:
    Code:
    @Bean(initMethod="publish")
    	EndpointImpl commonEndpoint(){
    		EndpointImpl cxfEndpoint = new JAXWS22SpringEndpointImpl(bus,new CXFCommonEndpoint());
    //		cxfEndpoint.publish();
    		return cxfEndpoint;
    	}
    1, Add initMethod property of Bean Annotation,
    2, The method annotated by @Bean itself, is a initial progress of the bean, so just call the method in it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •