

In this example, let's use a standalone java class which through its main() method, looks up the remote view of the AccountManagerBean and invokes the operations. The next step is to write a simple client which access the AccountManager to perform the operations. That's it! You now have the beans deployed on the server. jar and deploy it to the server, you built earlier.

These 2 methods of the AccountManagerBean demonstrate the 2 ways in which you can get hold of the no-interface view of the bean. The credit() method looks up the no-interface view by the JNDI name, whereas the debit() method uses an injected reference of the no-interface view Calculator. The AccountManagerBean has 2 methods, each of which uses the no-interface view Calculator bean. * int debit(long accountNumber, int amount) Return calculator.add(currentBalance, amount) Throw new RuntimeException("Could not lookup no-interface view of calculator: ", ne)
#Beancounter java version 2 how to
in this method we wanted to demonstrate how to lookup an no-interface viewĬalculator = (Calculator) context.lookup(() + "/no-interface") We could have used the injected Calculator too, but lookup the no-interface view of the Calculator But for this example let's just hardcode it get current account balance of this account number, from DB. * int credit(long accountNumber, int amount) * Inject the no-interface view of the Calculator simpleCalculator Import class AccountManagerBean implements AccountManager * Debits the amount from the account corresponding to the * credit(long accountNumber, int amount) * Credits the amount from the account corresponding to the Here's the AccountManagerBean stateless bean which exposes a view: So for the sake of simplicity, in this example, let's create another bean which acts as a client of this no-interface view bean. Remember that the no-interface view is a local view, which means that the client has to run in the same JVM as the bean. Now let's write a client which uses this no-interface view bean. Let's first look at a simple EJB3.1 nointerface view bean: The next step would be to deploy a EJB3.1 app into this server. After downloading, start and stop the server once to ensure that it boots fine. JBoss AS 6.0.0.M2 can be downloaded from. More specifically, it includes support for: JBoss AS 6.0.0.M2 which has been released on Feb 16th 2010, contains the initial support for EJB3.1.
