• Post Reply Bookmark Topic Watch Topic
  • New Topic

Casting EJBHome and EJBRemotes  RSS feed

Andrew Rutherford
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I've been having problems with the following scenario. I'm writing a tool that can create a specified amount of beans within a JAR, and also create a single client to execute them all at once.
During the JNDI lookup I've been coding the following to a) find the Home, b) do a home.create() to create an instance of the bean, ready for business method logic.
As there are potentially hundreds of beans that need to have their homes found and a bean instance created I thought of some code that basically looped through each bean, found the home, created an instance, ran some business methods, and then went onto the next bean and did the same.
In effect I need it to do something like
testBean1Home tb1h = (testBean1HomeHelloWorldHome)PortableRemoteObject.narrow(temporaryObject,testBean1Home.class);
testBean1Remote remote = tb1h.create()
Buton the second time around the loop, it would be testBean2Home in each case, and then testBean3Home,....

I've made an attemt at the code below, but it is a nigtmare, hope some bright spark can help
String home_name = new String theBeanName+aCurrentBeanNumber+"Home");
javax.ejb.EJBHome aHome = (javax.ejb.EJBHome)Class.forName(home_name);
aHome = (Class.forName(home_name));PortableRemoteObject.narrow(temporayObject,(Class.forName(home_name)));
String remote_name = new String(theBeanName+aCurrentBeanNumber+"Remote");
javax.ejb.EJBObject aRemote = Class.forName(remote_name);
aRemote = aHome.create();

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!