0

When I see the example about Stateful Session Bean Java EE 6, I never see the create method, here is the interface:

public interface Cart {
 public void initialize(String person) throws BookException;
 public void initialize(String person, String id)
     throws BookException;
 public void addBook(String title);
 public void removeBook(String title) throws BookException;
 public List<String> getContents();
 public void remove();
}

But in the client's application, I see it invokes the create method, like that:

cart.create("Duke DeEarl", "123");

I cannot understand, can you help me?

Source example: http://docs.oracle.com/javaee/6/tutorial/doc/bnbod.html

MasterDark116
  • 88
  • 1
  • 1
  • 4
  • If you read the tutorial even cursorily, you'll notice the line you're quoting occurs under the `Business Methods` section meaning it's referring to an arbitrary set of business operations the EJB could implement. It also has `addBooks` and `getContent` and `removeBook` there. Why have you not cited those? – kolossus Jan 13 '13 at 03:28

1 Answers1

0

Simply it's a typo in the Java EE 6 Tutorial, the correct code should be

cart.initialize("Duke DeEarl", "123");
remigio
  • 4,101
  • 1
  • 26
  • 28
  • I don't think the guidance from Oracle (Java owner) is wrong. Because when I use "Insert code" function in Netbean, I see a option "Creat method" => It's automatically create 2 method: "XYZRemote create()" and "ejbCreate()". Therefore, there is something special with "creat method" – MasterDark116 Jan 13 '13 at 01:41
  • @MasterDark116 Sorry you're wrong, that's a mistake, you can check the source code for the cart example, included with the tutorial, and you'll see that the client code calls the `initialize` method. As to the `create` or `ejbCreate` method, they are simply an alternative to annotating a void method with `@PostConstruct` and are called by the application server upon creating the session bean. You never create a session bean explicitly, they are always created by the app server. – remigio Jan 13 '13 at 14:40