Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 3.1 RC2
    • Component/s: Core, Core:AOP
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Equivalent to <context:spring-configured/>

      Because @Configuration classes don't produce bean definitions in quite the same way that XML configuration files do, an annotation-based @SpringConfigured annotation must work differently than <context:spring-configured/>. Consider the following approach:

      @Configurationpublic class SpringConfiguredBeans {

      @SpringConfigured
      public void someEntity(MyEntity entity)

      { entity.setRepository(myRepository()); }

      @Bean
      public MyRepository myRepository()

      { return new MyRepository(dataSource()); }

      // ...}

        Issue Links

          Activity

          Hide
          Chris Beams added a comment -

          Hi Marcel, No exact date at the moment, but generally you can expect RC1 within the next month.

          Show
          Chris Beams added a comment - Hi Marcel, No exact date at the moment, but generally you can expect RC1 within the next month.
          Hide
          Chris Beams added a comment -

          RC1 is pending release later today, and there's still a bit of thought to give to this one before going ahead with it. Given that there's a decent alternative (as described above), we'll wait for RC2 to introduce this.

          Show
          Chris Beams added a comment - RC1 is pending release later today, and there's still a bit of thought to give to this one before going ahead with it. Given that there's a decent alternative (as described above), we'll wait for RC2 to introduce this.
          Hide
          Chris Beams added a comment -

          This is complete, please give @EnableSpringConfigured a try!

          commit be29c57ce063f51a215ffa1b9d0df0678121eb41
          Author: Chris Beams <cbeams@vmware.com>
          Date:   Sun Nov 27 22:34:16 2011 -0800
          
              Introduce @EnableSpringConfigured
              
              Equivalent to <context:spring-configured/>.
              
              Also update @EnableLoadTimeWeaving Javadoc and spring-configured XSD
              documentation to reflect.
          
          Show
          Chris Beams added a comment - This is complete, please give @EnableSpringConfigured a try! commit be29c57ce063f51a215ffa1b9d0df0678121eb41 Author: Chris Beams <cbeams@vmware.com> Date: Sun Nov 27 22:34:16 2011 -0800 Introduce @EnableSpringConfigured Equivalent to <context:spring-configured/>. Also update @EnableLoadTimeWeaving Javadoc and spring-configured XSD documentation to reflect.
          Hide
          Marcel Overdijk added a comment -

          I tried this but I'm having issues deploying to Google App Engine infrastructure. In @Configured classes dependencies are not injected.
          Note that in the local dev environment this is working without any problem.

          I'm wondering 2 things:
          1) Is @EnableSpringConfigured doing something sepcial that might break on GAE
          2) Is there a way I can debug this? All I have now is:
          [s~vootynl-development/0-1.355018655005944620].<stdout>: 06:21:45,181 ERROR [org.springframework.web.context.ContextLoader] U: - Context initialization failed
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootStrap': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Objectify Factory has not been injected
          at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:393)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1437)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
          at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
          at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
          at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
          at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
          at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
          at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
          at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202)
          at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
          at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
          at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:392)
          at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
          at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
          at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
          at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
          at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
          at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
          at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:162)
          at java.lang.Thread.run(Thread.java:679)
          which does not give me an idea why the injection in @Configured classes is not working.

          Show
          Marcel Overdijk added a comment - I tried this but I'm having issues deploying to Google App Engine infrastructure. In @Configured classes dependencies are not injected. Note that in the local dev environment this is working without any problem. I'm wondering 2 things: 1) Is @EnableSpringConfigured doing something sepcial that might break on GAE 2) Is there a way I can debug this? All I have now is: [s~vootynl-development/0-1.355018655005944620] .<stdout>: 06:21:45,181 ERROR [org.springframework.web.context.ContextLoader] U: - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootStrap': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Objectify Factory has not been injected at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:393) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1437) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548) at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:392) at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449) at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455) at com.google.tracing.TraceContext.runInContext(TraceContext.java:695) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325) at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453) at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:162) at java.lang.Thread.run(Thread.java:679) which does not give me an idea why the injection in @Configured classes is not working.
          Hide
          Chris Beams added a comment - - edited

          Marcel,

          Do you get the same behavior using <context:spring-configured/> instead of @EnableSpringConfigured? What if you don't use either?

          Also, you mention @Configured – there is no such annotation in Spring. Do you mean @Configurable, or @Configuration? Keep in mind that @EnableSpringConfigured enables dependency injection for @Configurable classes not otherwise managed by the Spring container, e.g. domain objects/entities, etc.

          If this continues to be an issue for you, please create a new issue for it and reference this one.

          Thanks,

          Chris

          Show
          Chris Beams added a comment - - edited Marcel, Do you get the same behavior using <context:spring-configured/> instead of @EnableSpringConfigured ? What if you don't use either? Also, you mention @Configured – there is no such annotation in Spring. Do you mean @Configurable , or @Configuration ? Keep in mind that @EnableSpringConfigured enables dependency injection for @Configur able classes not otherwise managed by the Spring container, e.g. domain objects/entities, etc. If this continues to be an issue for you, please create a new issue for it and reference this one. Thanks, Chris

            People

            • Assignee:
              Chris Beams
              Reporter:
              Chris Beams
              Last updater:
              Trevor Marshall
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 20 weeks, 3 days ago