{"id":135,"date":"2008-03-11T12:41:00","date_gmt":"2008-03-11T12:41:00","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=135"},"modified":"2008-03-11T12:41:00","modified_gmt":"2008-03-11T12:41:00","slug":"neues-aus-ejb-3-1","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2008\/03\/neues-aus-ejb-3-1\/","title":{"rendered":"Neues aus EJB 3.1"},"content":{"rendered":"<p>Einige \u00c4nderungen aus dem <a href=\"http:\/\/jcp.org\/aboutJava\/communityprocess\/edr\/jsr318\/index.html\">Preview der EJB 3.1 Specification<\/a>.<\/p>\n<p>Es gibt neu auch Singleton Session Beans, die mit @Singleton annotiert sind:<\/p>\n<blockquote>\n<p>The EJB specification defines stateful, stateless, and <strong>singleton session beans<\/strong>. There are differences in<br \/>the API between stateful session beans, stateless session beans, and singleton session beans.<\/p>\n<\/blockquote>\n<blockquote>\n<p>4.7 Singleton Session Beans<br \/>A Singleton session bean is a session bean component that is instantiated once per application. In cases<br \/>where the container is distributed over many virtual machines, each application will have one bean<br \/>instance of the Singleton for each JVM.<br \/>Once instantiated, a Singleton session bean instance lives for the duration of the container in which it is<br \/>created. It maintains its state between client invocations but that state is not required to survive container<br \/>shutdown or crash.<\/p>\n<\/blockquote>\n<p>Man kann f\u00fcr lokale Beans auf eine Business-Schnittstelle verzichten:<\/p>\n<blockquote>\n<p>In EJB 3.x, a local client accesses a session bean through the bean\u2019s local business interface <strong>or through<br \/>a no-interface client view representing all the public methods of the bean clas<\/strong>s. <\/p>\n<\/blockquote>\n<blockquote>\n<p>3.4.2 Obtaining a Reference to the No-interface Local View<br \/>A client can obtain a reference to a Session Bean\u2019s No-interface Local View through dependency injection<br \/>or lookup in the JNDI namespace.<br \/>For example, the No-interface Local view of the CartBean session bean with bean class com.acme.Cart-<br \/>Bean may be obtained using dependency injection as follows :<br \/>@EJB CartBean cart;<br \/>The CartBean No-interface view could also be looked up via JNDI as shown in the following code segment<br \/>using the lookup method provided by the EJBContext interface. In this example, a reference to<br \/>the client bean\u2019s SessionContext is obtained through dependency injection:<br \/>@Resource SessionContext ctx;<br \/>&#8230;<br \/>CartBean cart = (CartBean)ctx.lookup(\u201ccart\u201d);<br \/>Despite the fact that the client reference for the No-interface Local view has type &lt;bean class&gt; , the client<br \/>never directly uses the new operator to acquire the reference.<\/p>\n<\/blockquote>\n<blockquote>\n<p>3.4.4 Session Bean\u2019s No-Interface Local View<br \/>A Session Bean\u2019s no-interface view is a variation of the Local view that exposes the public methods of<br \/>the bean class without the use of a separate business interface.<br \/>A reference to the no-interface view may be passed as a parameter or return value of any Local business<br \/>interface or no-interface view method.<br \/>The container provides an implementation of a reference to a no-interface view such that when the client<br \/>invokes a method on the reference, the business method on the session bean instance and any interceptor<br \/>methods are invoked as needed.<br \/>Only public methods of the bean class (and any super-classes) may be invoked through the no-interface<br \/>view. Attempted invocations of methods with any other access modifiers via the no-interface view reference<br \/>result in the javax.ejb.EJBException.<br \/>It is invalid to reference a session object that does not exist. If a stateful session bean has been removed,<br \/>attempted invocations on the no-interface view reference result in the javax.ejb.NoSuchEJBException.<\/p>\n<\/blockquote>\n<p>Neu ist, das eine Session-Bean synchron oder asynchron aufgerufen werden kann:  <\/p>\n<blockquote>\n<p>3.4.8 Asynchronous Invocations<br \/>By default, session bean invocations through the Remote, Local, and no-interface views are synchronous,<br \/>meaning the client blocks for the duration of the invocation and is returned control only after all<br \/>invocation processing has completed. Clients can achieve asynchronous behavior by invoking session<br \/>bean methods that have been designed to support asynchrony.<\/p>\n<p>When a client invokes an asynchronous method, the container returns control to the client and continues<br \/>processing the asynchronous invocation on a separate thread of execution.<\/p>\n<\/blockquote>\n<blockquote>\n<p>3.4.8.1 Return Values<br \/>Asynchronous methods have a return type of void or Future&lt;V&gt;, where V represents the result value<br \/>of the asynchronous invocation.<br \/>In the case of a Future&lt;V&gt; return type, the object returned to the client is a container provided object.<br \/>This object allows the client to retrieve the invocation result value, discover any invocation exception,<br \/>or attempt to cancel the asynchronous invocation.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Einige \u00c4nderungen aus dem Preview der EJB 3.1 Specification. Es gibt neu auch Singleton Session Beans, die mit @Singleton annotiert sind: The EJB specification defines stateful, stateless, and singleton session beans. There are differences inthe API between stateful session beans, stateless session beans, and singleton session beans. 4.7 Singleton Session BeansA Singleton session bean is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9],"tags":[],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-java-ee"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":0,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}