{"id":840,"date":"2012-01-11T21:03:00","date_gmt":"2012-01-11T21:03:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/simulating-cdis-session-and-request-scope-in-a-j2se-app.html"},"modified":"2012-10-21T22:47:35","modified_gmt":"2012-10-21T22:47:35","slug":"simulating-cdis-session-and-request","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html","title":{"rendered":"Simulating CDI&#8217;s Session and Request Scope in a J2SE app"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI). Using vanilla JSR-330 is a no-brainer, but there are also some nice features in JSR-299 that we\u2019d like to exploit (such as events and decorators). The snag? The Naked Objects must also run transparently in J2SE environments.<\/p>\n<p>Now JSR-299 (at least, the Weld reference implementation) can run on J2SE, but it isn\u2019t possible to use beans that are annotated as either @SessionScoped or @RequestScoped\u2026 not surprising really, because there is no HttpSession or HttpServletRequest to hook into. On the other hand, at least in the Naked Objects framework in a J2SE context, we do have the ability to map these concepts onto its own internal lifecycle \u2026 eg, for a client-side app, the user is always in deemed to be running in one long session.<\/p>\n<p>How, then, to setup contexts for these scopes, and make them automatically active when running in J2SE?<\/p>\n<p>First, let\u2019s look at the code we want to run:<\/p>\n<pre class=\"brush:java\">package org.nakedobjects.experiments.cdi;\r\n\r\nimport java.util.List;\r\nimport javax.enterprise.context.RequestScoped;\r\nimport javax.enterprise.event.Observes;\r\nimport org.jboss.weld.environment.se.bindings.Parameters;\r\nimport org.jboss.weld.environment.se.events.ContainerInitialized;\r\n\r\n@RequestScoped\r\npublic class HelloWorld {\r\n    public static void main(String[] args) {\r\n        \/\/ bootstrap\r\n        org.jboss.weld.environment.se.StartMain.main(new String[]{\"JSR\",\"299\"});\r\n    }\r\n    public void printHello(@Observes ContainerInitialized event, @Parameters List&lt;String&gt; args) {\r\n        System.out.println(\"Hello \" + args);\r\n        System.out.flush();\r\n    }\r\n}\r\n<\/pre>\n<p>Because this is a CDI bean, we need an empty <span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">META-INF\/beans.xml.<\/span><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The above class would print out \u201cHello [JSR, 299]\u201d if annotated as <span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">@ApplicationScoped<\/span>, but not with it being annotated as <span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">@RequestScoped<\/span>. What we therefore need to do is write an extension. It\u2019s a bit hacky, but it works:<\/p>\n<pre class=\"brush:java\">package org.jboss.weld.manager; \/\/ required for visibility to BeanManagerImpl#getContexts()\r\n\r\nimport java.lang.annotation.Annotation;\r\n\r\nimport javax.enterprise.context.RequestScoped;\r\nimport javax.enterprise.context.SessionScoped;\r\nimport javax.enterprise.event.Observes;\r\nimport javax.enterprise.inject.spi.AfterDeploymentValidation;\r\nimport javax.enterprise.inject.spi.BeanManager;\r\nimport javax.enterprise.inject.spi.Extension;\r\n\r\nimport org.jboss.weld.context.AbstractThreadLocalMapContext;\r\nimport org.jboss.weld.context.beanstore.HashMapBeanStore;\r\n\r\npublic class WeldServletScopesSupportForSe implements Extension {\r\n\r\n public void afterDeployment(@Observes AfterDeploymentValidation event,\r\n   BeanManager beanManager) {\r\n\r\n  setContextActive(beanManager, SessionScoped.class);\r\n  setContextActive(beanManager, RequestScoped.class);\r\n }\r\n\r\n private void setContextActive(BeanManager beanManager,\r\n   Class&lt;? extends Annotation&gt; cls) {\r\n  BeanManagerImpl beanManagerImpl = (BeanManagerImpl) beanManager;\r\n  AbstractThreadLocalMapContext context = (AbstractThreadLocalMapContext) beanManagerImpl\r\n    .getContexts().get(cls).get(0);\r\n  context.setBeanStore(new HashMapBeanStore());\r\n  context.setActive(true);\r\n }\r\n}\r\n<\/pre>\n<p>Like all Weld extensions, this needs to be registered in <span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">META-INF\/services<\/span>, in this case in a file called<span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\"> javax.enterprise.inject.spi.Extension<\/span> containing the fully-qualified class name.<\/p>\n<p>Now, when we run the application, the session and request scopes will both be set up, and our HelloWorld bean will fire.<\/p>\n<p>For developers writing apps in Naked Objects they will need to include a dependency to an additional module, if deploying a client (<span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">-t client<\/span> or a server on a non-web backend (<span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">-t server<\/span> with socket-level remoting, say). For the latter, we\u2019ll need to include some smarts to figure out whether we are running in a webapp or not, and only set up the Contexts if we determine that we\u2019re not (eg can\u2019t find <span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">javax.servlet<\/span> classes on the classpath.<\/p>\n<p>If you want to try out the code, you can check it out using<\/p>\n<pre class=\"brush:java\">svn co https:\/\/nakedobjects.svn.sourceforge.net\/svnroot\/nakedobjects\/framework\/trunk\/experiments .\r\n<\/pre>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/danhaywood.com\/2010\/08\/12\/simulating-cdis-session-and-request-scope-in-a-j2se-app\/\">Simulating CDI&#8217;s Session and Request Scope in a J2SE app<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a>&nbsp;Dan Haywood at the&nbsp;<a href=\"http:\/\/danhaywood.com\/\">Dan Haywood blog<\/a>.<\/p>\n<p><strong><i>Related Articles :<\/i><\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/11\/spring-singleton-request-session-beans.html\">Spring Singleton, Request, Session Beans and Thread Safety<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/11\/what-is-cdi-how-does-it-relate-to-ejb.html\">What Is CDI, How Does It Relate to @EJB And Spring?<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/java-ee6-cdi-named-components-and.html\">Java EE6 CDI, Named Components and Qualifiers<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/java-ee6-decorators-decorating-classes.html\">Java EE6 Decorators: Decorating classes at injection time<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/java-ee6-events-lightweight-alternative.html\">Java EE6 Events: A lightweight alternative to JMS<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI). Using vanilla JSR-330 is a no-brainer, but there are also some nice features in JSR-299 that we\u2019d like to exploit (such as events and decorators). The snag? The Naked Objects must also run transparently in J2SE &hellip;<\/p>\n","protected":false},"author":125,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[290],"class_list":["post-840","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-cdi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Simulating CDI&#039;s Session and Request Scope in a J2SE app - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).\" \/>\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\/2012\/01\/simulating-cdis-session-and-request.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simulating CDI&#039;s Session and Request Scope in a J2SE app - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.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=\"2012-01-11T21:03:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T22:47:35+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=\"Dan Haywood\" \/>\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=\"Dan Haywood\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html\"},\"author\":{\"name\":\"Dan Haywood\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/097f2a343c5a25f5902838872b9a3c46\"},\"headline\":\"Simulating CDI&#8217;s Session and Request Scope in a J2SE app\",\"datePublished\":\"2012-01-11T21:03:00+00:00\",\"dateModified\":\"2012-10-21T22:47:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html\"},\"wordCount\":458,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"CDI\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html\",\"name\":\"Simulating CDI's Session and Request Scope in a J2SE app - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2012-01-11T21:03:00+00:00\",\"dateModified\":\"2012-10-21T22:47:35+00:00\",\"description\":\"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/simulating-cdis-session-and-request.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\\\/2012\\\/01\\\/simulating-cdis-session-and-request.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\":\"Simulating CDI&#8217;s Session and Request Scope in a J2SE app\"}]},{\"@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\\\/097f2a343c5a25f5902838872b9a3c46\",\"name\":\"Dan Haywood\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g\",\"caption\":\"Dan Haywood\"},\"sameAs\":[\"http:\\\/\\\/danhaywood.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Dan-Haywood\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simulating CDI's Session and Request Scope in a J2SE app - Java Code Geeks","description":"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).","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\/2012\/01\/simulating-cdis-session-and-request.html","og_locale":"en_US","og_type":"article","og_title":"Simulating CDI's Session and Request Scope in a J2SE app - Java Code Geeks","og_description":"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).","og_url":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-01-11T21:03:00+00:00","article_modified_time":"2012-10-21T22:47:35+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":"Dan Haywood","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Dan Haywood","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html"},"author":{"name":"Dan Haywood","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/097f2a343c5a25f5902838872b9a3c46"},"headline":"Simulating CDI&#8217;s Session and Request Scope in a J2SE app","datePublished":"2012-01-11T21:03:00+00:00","dateModified":"2012-10-21T22:47:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html"},"wordCount":458,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["CDI"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html","url":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html","name":"Simulating CDI's Session and Request Scope in a J2SE app - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2012-01-11T21:03:00+00:00","dateModified":"2012-10-21T22:47:35+00:00","description":"We\u2019re currently considering refactoring the Naked Objects framework to use JSR-330 (dependency injection) and EE-oriented big brother, JSR-299 (CDI).","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/simulating-cdis-session-and-request.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\/2012\/01\/simulating-cdis-session-and-request.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":"Simulating CDI&#8217;s Session and Request Scope in a J2SE app"}]},{"@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\/097f2a343c5a25f5902838872b9a3c46","name":"Dan Haywood","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f2802d65ad9600e86cb3c09b9183ffaaa1a819d8b245682055e4728b3b03af9c?s=96&d=mm&r=g","caption":"Dan Haywood"},"sameAs":["http:\/\/danhaywood.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Dan-Haywood"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/840","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\/125"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=840"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/840\/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=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}