{"id":17530,"date":"2013-09-24T01:00:55","date_gmt":"2013-09-23T22:00:55","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=17530"},"modified":"2013-09-23T12:38:49","modified_gmt":"2013-09-23T09:38:49","slug":"injecting-spring-beans-into-non-managed-objects","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html","title":{"rendered":"Injecting Spring beans into non-managed objects"},"content":{"rendered":"<p>Advantages coming from dependency injection can be addicting. It&#8217;s a lot easier to configure application structure using injections than doing all resolutions manually. It&#8217;s hard to resign from it when we have some non-managed classes that are instantiated outside of the container &#8211; for example being part of other frameworks like <a href=\"https:\/\/vaadin.com\/\" target=\"_blank\">Vaadin<\/a> UI components or JPA entities. The latter are especially important when we&#8217;re using <a href=\"http:\/\/en.wikipedia.org\/wiki\/Domain-driven_design\" target=\"_blank\">Domain Driven Design<\/a>. During DDD training ran by <a href=\"http:\/\/www.bottega.com.pl\/index_en.xhtm\" target=\"_blank\">Slawek Sobotka<\/a>\u00a0we were talking about options to remove &#8220;bad coupling&#8221; from aggregate factories. I&#8217;m sure you&#8217;ll admit, that it&#8217;s better to have generic mechanism able to &#8220;energize&#8221; objects by dependencies defined by e.g. @Inject annotation than inject all necessary dependencies into particular factory and then pass them into object by constructor, builder or simple setters.<\/p>\n<p>Spring framework brings us two different solutions to achieve such requirement. I&#8217;ll now describe them both of them. Let&#8217;s start with with simpler one.<\/p>\n<p><a name=\"more\"><\/a>It&#8217;s especially powerful when we&#8217;ve case such as generic repository, mentioned earlier aggregate factory, or even any other factory just ensuring that we have only few places in our code where will instantiate objects outside of the container. In this case we can make use of <a href=\"http:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/beans\/factory\/config\/AutowireCapableBeanFactory.html\" target=\"_blank\">AutowireCapableBeanFactory<\/a>\u00a0class. In particular we will be interested in two methods:<\/p>\n<ul>\n<li>void autowireBean(Object existingBean)<\/li>\n<li>Object initializeBean(Object existingBean, String beanName)<\/li>\n<\/ul>\n<p>The first one just populates our bean without applying specific post processors (e.g. @PostConstruct, etc). The second one additionally applies factory callbacks like setBeanName and setBeanFactory, as well as any other post processors with @PostConstruct of course. In our code it&#8217;ll look like this:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">public abstract class GenericFactory&lt;T&gt; {\r\n\r\n  @Autowired\r\n  private AutowireCapableBeanFactory autowireBeanFactory;\r\n\r\n  public T createBean() {\r\n    \/\/ creation logic\r\n    autowireBeanFactory.autowireBean(createdBean);\r\n    return createdBean;\r\n  }\r\n}<\/pre>\n<p>Simple and powerful &#8211; my favorite composition.<\/p>\n<p>But what can we do when we have plenty places in our code where objects get born? That&#8217;s for example case of building <a href=\"https:\/\/vaadin.com\/\" target=\"_blank\">Vaadin<\/a> layouts in Spring web application. Injecting custom bean configurer objects invoking autowireBean method won&#8217;t be the peak of productivity. Happily Spring developers brought us <a href=\"http:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/beans\/factory\/annotation\/Configurable.html\" target=\"_blank\">@Configurable<\/a> annotation. This annotation connected with aspects will configure each annotated object even if we will create it outside of the container using new operator. Like with any other aspects we can choose between<\/p>\n<ul>\n<li>load-time-waving (LTW)<\/li>\n<li>build-time-waving (BTW).<\/li>\n<\/ul>\n<p>The first one is easier to configure but we become (due to instrumentation) dependent from application server, which can be undesirable in some cases. \u00a0To use it we need to annotate our @Configuration class by @EnableLoadTimeWeaving (or add\u00a0&lt;context:load-time-weaver\/&gt; tag if you like Flintstones and XML configuration) After completing configuration just annotate class by @Configurable:<\/p>\n<pre class=\" brush:java\">@Configurable\r\npublic class MyCustomButton extends Button {\r\n\r\n  @Autowired\r\n  private MyAwesomeService myAwesomeService;\r\n\r\n  \/\/ handlers making use of injected service\r\n}<\/pre>\n<p>The second option is a little bit more complex to setup but after this it will be a lot lighter in runtime. Because now we want to load aspects till compilation we have to integrate aspectj compiler into our build. In Maven you need to add few dependencies:<\/p>\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;org.aspectj&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;aspectjrt&lt;\/artifactId&gt;\r\n  &lt;version&gt;1.7.3&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-aspects&lt;\/artifactId&gt;\r\n  &lt;version&gt;3.2.4.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-tx&lt;\/artifactId&gt;\r\n  &lt;version&gt;3.2.4.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;javax.persistence&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;persistence-api&lt;\/artifactId&gt;\r\n  &lt;version&gt;1.0&lt;\/version&gt;\r\n  &lt;scope&gt;provided&lt;\/scope&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>I hope you are curious why above you can see persistence-api. That was also strange for me, when I saw &#8220;can&#8217;t determine annotations of missing type javax.persistence.Entity&#8221; error during aspectj compilation. The answer can be found in SpringFramework JIRA in issue <a href=\"https:\/\/jira.springsource.org\/browse\/SPR-6819\" target=\"_blank\">SPR-6819<\/a>. This happens when you configure spring-aspects as a aspectLibrary in aspectj-maven-plugin. Issue is unresolved for over three year so better get used to it. The last thing we need to do is to include\u00a0above-mentioned plugin into our plugins section.<\/p>\n<pre class=\" brush:xml\">&lt;plugin&gt;\r\n  &lt;groupId&gt;org.codehaus.mojo&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;aspectj-maven-plugin&lt;\/artifactId&gt;\r\n  &lt;version&gt;1.5&lt;\/version&gt;\r\n  &lt;configuration&gt;\r\n    &lt;source&gt;1.7&lt;\/source&gt;\r\n    &lt;target&gt;1.7&lt;\/target&gt;\r\n    &lt;complianceLevel&gt;1.7&lt;\/complianceLevel&gt;\r\n    &lt;showWeaveInfo&gt;true&lt;\/showWeaveInfo&gt;\r\n    &lt;aspectLibraries&gt;\r\n      &lt;aspectLibrary&gt;\r\n        &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-aspects&lt;\/artifactId&gt;\r\n      &lt;\/aspectLibrary&gt;\r\n    &lt;\/aspectLibraries&gt;\r\n  &lt;\/configuration&gt;\r\n  &lt;executions&gt;\r\n    &lt;execution&gt;\r\n      &lt;goals&gt;\r\n        &lt;goal&gt;compile&lt;\/goal&gt;\r\n      &lt;\/goals&gt;\r\n    &lt;\/execution&gt;\r\n  &lt;\/executions&gt;\r\n&lt;\/plugin&gt;<\/pre>\n<p>And that&#8217;s all folks!<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.kubrynski.com\/2013\/09\/injecting-spring-dependencies-into-non.html\">Injecting Spring beans into non-managed objects<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Jakub Kubrynski at the <a href=\"http:\/\/www.kubrynski.com\/\">Java(B)Log<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Advantages coming from dependency injection can be addicting. It&#8217;s a lot easier to configure application structure using injections than doing all resolutions manually. It&#8217;s hard to resign from it when we have some non-managed classes that are instantiated outside of the container &#8211; for example being part of other frameworks like Vaadin UI components or &hellip;<\/p>\n","protected":false},"author":489,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-17530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Injecting Spring beans into non-managed objects<\/title>\n<meta name=\"description\" content=\"Advantages coming from dependency injection can be addicting. It&#039;s a lot easier to configure application structure using injections than doing all\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Injecting Spring beans into non-managed objects\" \/>\n<meta property=\"og:description\" content=\"Advantages coming from dependency injection can be addicting. It&#039;s a lot easier to configure application structure using injections than doing all\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-23T22:00:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jakub Kubrynski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/jkubrynski\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jakub Kubrynski\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html\"},\"author\":{\"name\":\"Jakub Kubrynski\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b1260c8ca896862412b021458fd60186\"},\"headline\":\"Injecting Spring beans into non-managed objects\",\"datePublished\":\"2013-09-23T22:00:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html\"},\"wordCount\":594,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html\",\"name\":\"Injecting Spring beans into non-managed objects\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2013-09-23T22:00:55+00:00\",\"description\":\"Advantages coming from dependency injection can be addicting. It's a lot easier to configure application structure using injections than doing all\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/09\\\/injecting-spring-beans-into-non-managed-objects.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Injecting Spring beans into non-managed objects\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b1260c8ca896862412b021458fd60186\",\"name\":\"Jakub Kubrynski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g\",\"caption\":\"Jakub Kubrynski\"},\"description\":\"I'm software developer by vocation. Java team leader at work and open source enthusiast at home. Strongly interested in new technologies. Fan of java.util.concurrent and sun.misc.Unsafe. My motto is \\\"minimum code, maximum functionality.\",\"sameAs\":[\"http:\\\/\\\/www.kubrynski.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/jkubrynski\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/jkubrynski\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/jakub-kubrynski\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Injecting Spring beans into non-managed objects","description":"Advantages coming from dependency injection can be addicting. It's a lot easier to configure application structure using injections than doing all","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html","og_locale":"en_US","og_type":"article","og_title":"Injecting Spring beans into non-managed objects","og_description":"Advantages coming from dependency injection can be addicting. It's a lot easier to configure application structure using injections than doing all","og_url":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-09-23T22:00:55+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Jakub Kubrynski","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/jkubrynski","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jakub Kubrynski","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html"},"author":{"name":"Jakub Kubrynski","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b1260c8ca896862412b021458fd60186"},"headline":"Injecting Spring beans into non-managed objects","datePublished":"2013-09-23T22:00:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html"},"wordCount":594,"commentCount":4,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html","url":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html","name":"Injecting Spring beans into non-managed objects","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2013-09-23T22:00:55+00:00","description":"Advantages coming from dependency injection can be addicting. It's a lot easier to configure application structure using injections than doing all","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/09\/injecting-spring-beans-into-non-managed-objects.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Injecting Spring beans into non-managed objects"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b1260c8ca896862412b021458fd60186","name":"Jakub Kubrynski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/588d285a5dc1328cd70199e10df27722277e5cfcd13fc51c40413c788110ce47?s=96&d=mm&r=g","caption":"Jakub Kubrynski"},"description":"I'm software developer by vocation. Java team leader at work and open source enthusiast at home. Strongly interested in new technologies. Fan of java.util.concurrent and sun.misc.Unsafe. My motto is \"minimum code, maximum functionality.","sameAs":["http:\/\/www.kubrynski.com\/","http:\/\/www.linkedin.com\/in\/jkubrynski","https:\/\/x.com\/https:\/\/twitter.com\/jkubrynski"],"url":"https:\/\/www.javacodegeeks.com\/author\/jakub-kubrynski"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/17530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/489"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=17530"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/17530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=17530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=17530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=17530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}