File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Casting EJBHome and EJBRemotes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Casting EJBHome and EJBRemotes" Watch "Casting EJBHome and EJBRemotes" New topic
Author

Casting EJBHome and EJBRemotes

Andrew Rutherford
Greenhorn

Joined: Aug 16, 2001
Posts: 1
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
findbean()
{
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();
......

Cheers
Andy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Casting EJBHome and EJBRemotes