Develop a session bean to have a No-Interface Local view
We can specify that a session bean have a No-Interface view.
A session bean has a No-Interface Local view when:
- The bean does not expose any other client views (Local, Remote, 2.x Remote Home, 2.x Local Home, Web Service) and its implements clause is empty.
- The bean exposes at least one other client view. The bean designates that it exposes a no-interface view with the @LocalBean annotation on the bean class or in the deployment descriptor.
We can also declare metadata for a session bean with No-Interface Local view in the deployment descriptor rather than using annotations.
The following steps contain code snippets that demonstrate the code to use for a No-Interface view.
- Specify that a session bean have No-Interface view because there are no declared interfaces.
@Stateless public class CartBean
- Specify that a session bean have No-Interface view using the @LocalBean annotation.
@Stateless @LocalBean @Remote( Cart.class ) public class CartBean implements Cart
- Specify metadata for a session bean with No-Interface Local view in the deployment descriptor.
<?xml version="1.0"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"> <enterprise-beans> <session> <ejb-name>CartBean</ejb-name> <local-bean/> <business-remote>com.ibm.example.Cart</business-remote> <ejb-class>com.ibm.example.CartBean</ejb-class> <session-type>Stateless</session-type> </session> </enterprise-beans> </ejb-jar>
Subtopics
- No-Interface Local View
New in EJB 3.1, session beans might now be exposed to clients through a No-Interface view. In prior versions of the specification, bean developers were required to provide an interface that would be used to expose the bean methods to a client.
- A session bean might now subclass another session bean
New in EJB 3.1, a session bean might now subclass another session bean. Prior versions of the EJB specification restricted a session bean from inheriting from another session bean.
Related concepts
No-Interface Local View A session bean might now subclass another session bean
Related tasks
Configure EJB 3.1 session bean methods to be asynchronous