{"id":82877,"date":"2018-10-23T07:00:42","date_gmt":"2018-10-23T04:00:42","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=82877"},"modified":"2018-10-20T12:14:03","modified_gmt":"2018-10-20T09:14:03","slug":"resource-dependency-injection-java-ee-7","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html","title":{"rendered":"Resource and Dependency Injection in Java EE 7"},"content":{"rendered":"<h2>1. Overview<\/h2>\n<p>Contexts and Dependency Injection (CDI) is a feature of Java EE that helps meld the web tier and transactional tier of its platform that is included in Java EE 6 and higher. From a technical perspective, what this means is that CDI offers a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Dependency_injection\">dependency injection<\/a> framework and also manages the dependencies\u2019 lifecycle.<\/p>\n<p>In this tutorial today, we will be covering <strong>CDI for Java EE 7.<\/strong><\/p>\n<h3>1.1 Contexts and Dependency Injection Specification<\/h3>\n<p>As mentioned on <a href=\"https:\/\/docs.oracle.com\/javaee\/7\/tutorial\/partcdi.htm\">Oracle\u2019s Java EE 7 website<\/a>, Java EE 7 uses CDI 1.1, which is outlined in <a href=\"https:\/\/jcp.org\/en\/jsr\/detail?id=346\">JSR 346<\/a>.<\/p>\n<p>CDI 1.1 brought many major changes, as mentioned <a href=\"http:\/\/planet.jboss.org\/post\/cdi_1_1_available\">in this blog post by the CDI lead Pete Muir<\/a>, such as:<\/p>\n<ul>\n<li>Global enablement of interceptors, global enablement of decorators, and alternatives using the <em>@Priority <\/em>annotation<\/li>\n<li>Support for <em>@AroundConstruct <\/em>lifecycle callback for constructors<\/li>\n<li><em>EventMetadata<\/em> to allow inspection of event metadata<\/li>\n<li>Allowing binding interceptors to constructors<\/li>\n<\/ul>\n<p>As mentioned, other significant changes are mentioned in the blog post, and it is encouraged that they are all reviewed.<\/p>\n<h2>2.\u00a0Comparing Dependency Injection and Resource Injection<\/h2>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><strong>Injection Type<\/strong><\/td>\n<td><strong>Can Inject JNDI Resources Directly<\/strong><\/td>\n<td><strong>Can Inject Regular Classes Directly<\/strong><\/td>\n<td><strong>Resolves By<\/strong><\/td>\n<td><strong>Typesafe<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Resource Injection<\/td>\n<td>True<\/td>\n<td>False<\/td>\n<td>Resource name<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Dependency Injection<\/td>\n<td>False<\/td>\n<td>True<\/td>\n<td>Type<\/td>\n<td>Yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.1 Dependency Injection<\/h3>\n<p>Dependency injection allows us to turn regular Java classes into managed objects and to inject those managed objects into other managed objects. The hurdle is ensuring we are providing the correct managed object at the right time.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Here we have an <em>@Inject <\/em>annotation that denotes that we will be providing \u2013 also known as injecting \u2013 a dependency to this constructor:<\/p>\n<pre class=\"brush:java\">@Inject\r\n\tpublic MaskingDataProcessor(MaskingData maskingData) {\r\n\t\tthis.maskingData = maskingData;\r\n\r\n\t}<\/pre>\n<p>So, where does this dependency come from?<\/p>\n<p>We have two classes in this example:<em> SSNDataMasker<\/em> and <em>BirthdayMasker<\/em>, and they both implement the same interface.<\/p>\n<p><em>SSNDataMasker<\/em> is annotated to be the default and therefore will be chosen by default if available:<\/p>\n<pre class=\"brush:java\">@Default\r\npublic class SSNMasker implements MaskingData {\r\n\r\n\t...\r\n}<\/pre>\n<p><em>BirthdayMasker<\/em> is annotated to be the alternative dependency and therefore will be chosen if <em>SSNDataMasker<\/em> is unavailable:<\/p>\n<pre class=\"brush:java\">@Alternative\r\npublic class BirthdayMasker implements MaskingData {\r\n\r\n\t...\r\n}<\/pre>\n<h3>2.2 Resource Injection<\/h3>\n<p>Resource injection allows us to inject any resource available in the JNDI namespace into any object managed by the container. For instance, we can use resource injection to inject connectors, data sources, or any other resources available in the JNDI namespace.<\/p>\n<p>In the code below, we inject a data source object into a field and this kind of resource injection is appropriately called <strong>field-based injection:<\/strong><\/p>\n<pre class=\"brush:java\">public class MyClass {\r\n\t @Resource(name=\"java:comp\/SomeDataSource\")\r\n\tprivate DataSource myDataBase;\r\n\t...\r\n}<\/pre>\n<p>Another way of injecting resources is <strong>method-based injection<\/strong>. In method-based injection, the parameter that is passed is injected with the resource:<\/p>\n<pre class=\"brush:java\">public class MyClass {\r\n\t\r\n\tprivate DataSource myDataBase;\r\n        ...\r\n\r\n\t@Resource(name=\"java:comp\/SomeDataSource\")\r\n\tpublic void setMyDataSource(DataSource dataSource) {\r\n\t\tmyDataBase = dataSource;\r\n\t}\r\n}<\/pre>\n<h2>3. What\u2019s the Difference Between EJB and CDI?<\/h2>\n<p>As <a href=\"https:\/\/www.oracle.com\/technetwork\/articles\/java\/cdi-javaee-bien-225152.html\">this article on the Oracle website states<\/a>, the \u201cC\u201d in CDI is the main difference between EJB beans and CDI beans. EJB components might be stateful, but are not inherently contextual. When we reference a stateful component instance, it must be explicitly passed between clients and destroyed by the application. <strong>\u00a0CDI improves the EJB component model with contextual lifecycle management<\/strong>. However, there are times when we want to use one over another.<\/p>\n<h3>3.1 When to Use EJB<\/h3>\n<p>There are several useful container services that are available only if we make our CDI bean also an EJB by adding <em>@Stateful, @Stateless, or @Singleton<\/em>.<\/p>\n<p>Examples include:<\/p>\n<ul>\n<li>When we are exposing a JAX-WS <em>@WebService<\/em>, making it an EJB allows us to not have to list it and map it as a servlet in the <em>xml <\/em>file. This is available to <em>@Stateless and @Singleton.<\/em><\/li>\n<li>When we are exposing a JAX-RS resource via <em>@Path<\/em>. When the RESTful service is an EJB, we get automatic discovery and don\u2019t need to add it to a JAX-RS <em>Application <\/em>subclass or elsewhere. This is available to <em>@Stateless and @Singleton. <\/em><\/li>\n<li>When we are working in parallel, the <em>@Asynchronous <\/em>method invocation is useful. As we know, having too many thread can degrade performance. The <em>@Asynchronous <\/em>annotation allows us to parallelize things we do using the container\u2019s thread pool. This is available to <em>@Stateful, @Stateless and @Singleton.<\/em><\/li>\n<\/ul>\n<h3>3.2 When to Use CDI<\/h3>\n<p>Simply put, we should use CDI when we benefit from its use. When we need injection, events, interceptors, decorators, lifecycle tracking, and other features that CDI offers.<\/p>\n<h2>4. Conclusion<\/h2>\n<p>To quickly test the concepts we reviewed regarding CDI, let\u2019s add <a href=\"http:\/\/weld.cdi-spec.org\/\">Weld<\/a> to a Maven project:<\/p>\n<pre class=\"brush:xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.jboss.weld.se&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;weld-se-core&lt;\/artifactId&gt;\r\n    &lt;version&gt;2.4.1.Final&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>Assuming we already have code to test \u2013 such as the code previously mentioned in the blog post \u2013 we just need to execute Weld, like:<\/p>\n<pre class=\"brush:java\">public static void main(String[] args) {\r\n\t\t\r\n    Weld weld = new Weld();\r\n    WeldContainer container = weld.initialize();\r\n    MaskingDataProcessor maskingDataProcessor = container.select(MaskingDataProcessor.class).get();\r\n    container.shutdown();\r\n\t}<\/pre>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Java Code Geeks with permission by Michael Good, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/michaelcgood.com\/resource-dependency-injection-java-ee-7\/\" target=\"_blank\" rel=\"noopener\">Resource and Dependency Injection in Java EE 7<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Overview Contexts and Dependency Injection (CDI) is a feature of Java EE that helps meld the web tier and transactional tier of its platform that is included in Java EE 6 and higher. From a technical perspective, what this means is that CDI offers a dependency injection framework and also manages the dependencies\u2019 lifecycle. &hellip;<\/p>\n","protected":false},"author":5558,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-82877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Resource and Dependency Injection in Java EE 7 - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.\" \/>\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\/2018\/10\/resource-dependency-injection-java-ee-7.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Resource and Dependency Injection in Java EE 7 - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.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=\"2018-10-23T04:00:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-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=\"Michael Good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Good\" \/>\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\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html\"},\"author\":{\"name\":\"Michael Good\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d13cc729556b91450ae21878a82139ed\"},\"headline\":\"Resource and Dependency Injection in Java EE 7\",\"datePublished\":\"2018-10-23T04:00:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html\"},\"wordCount\":751,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html\",\"name\":\"Resource and Dependency Injection in Java EE 7 - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2018-10-23T04:00:42+00:00\",\"description\":\"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/10\\\/resource-dependency-injection-java-ee-7.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\":\"Resource and Dependency Injection in Java EE 7\"}]},{\"@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\\\/d13cc729556b91450ae21878a82139ed\",\"name\":\"Michael Good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"caption\":\"Michael Good\"},\"description\":\"Michael is a software engineer located in the Washington DC area that is interested in Java, cyber security, and open source technologies. Follow his personal blog to read more from Michael.\",\"sameAs\":[\"http:\\\/\\\/www.michaelcgood.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/michael-good\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Resource and Dependency Injection in Java EE 7 - Java Code Geeks","description":"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.","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\/2018\/10\/resource-dependency-injection-java-ee-7.html","og_locale":"en_US","og_type":"article","og_title":"Resource and Dependency Injection in Java EE 7 - Java Code Geeks","og_description":"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.","og_url":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-10-23T04:00:42+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Michael Good","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Michael Good","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html"},"author":{"name":"Michael Good","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d13cc729556b91450ae21878a82139ed"},"headline":"Resource and Dependency Injection in Java EE 7","datePublished":"2018-10-23T04:00:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html"},"wordCount":751,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html","url":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html","name":"Resource and Dependency Injection in Java EE 7 - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2018-10-23T04:00:42+00:00","description":"Interested to learn about Dependency Injection? Check our article examining the new Contexts and Dependency Injection feature for the java EE7.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/10\/resource-dependency-injection-java-ee-7.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":"Resource and Dependency Injection in Java EE 7"}]},{"@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\/d13cc729556b91450ae21878a82139ed","name":"Michael Good","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","caption":"Michael Good"},"description":"Michael is a software engineer located in the Washington DC area that is interested in Java, cyber security, and open source technologies. Follow his personal blog to read more from Michael.","sameAs":["http:\/\/www.michaelcgood.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/michael-good"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/82877","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\/5558"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=82877"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/82877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=82877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=82877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=82877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}