prain
asked on
EJB Example Question
Folling is an EJB example I pulled off from one of the SUN's tutorials. Well it workes fine. But I have a question.???
Here is the question...
No where in the example program shows the IP address of the EJB server. So howcome the Client found the EJBServer????????.
//Here is the code for remote Interface
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Converter extends EJBObject {
public double dollarToYen(double dollars) throws RemoteException;
public double yenToEuro(double yen) throws RemoteException;
}
Here is the Home Interface
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface ConverterHome extends EJBHome {
Converter create() throws RemoteException, CreateException; }
Here is the EJB
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class ConverterEJB implements SessionBean {
public double dollarToYen(double dollars) {
return dollars * 121.6000;
}
public double yenToEuro(double yen) {
return yen * 0.0077;
}
public ConverterEJB() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionC ontext sc) {}
}
And finally here is the Client
import javax.naming.Context;
import javax.naming.InitialContex t;
import javax.rmi.PortableRemoteOb ject;
import Converter;
import ConverterHome;
public class ConverterClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("MyConverte r");
ConverterHome home =
(ConverterHome)PortableRem oteObject. narrow(obj ref,
ConverterHome.class);
Converter currencyConverter = home.create();
double amount = currencyConverter.dollarTo Yen(100.00 );
System.out.println(String. valueOf(am ount));
amount = currencyConverter.yenToEur o(100.00);
System.out.println(String. valueOf(am ount));
currencyConverter.remove() ;
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}}}
Your input is very valuable.
-prain
Here is the question...
No where in the example program shows the IP address of the EJB server. So howcome the Client found the EJBServer????????.
//Here is the code for remote Interface
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Converter extends EJBObject {
public double dollarToYen(double dollars) throws RemoteException;
public double yenToEuro(double yen) throws RemoteException;
}
Here is the Home Interface
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface ConverterHome extends EJBHome {
Converter create() throws RemoteException, CreateException; }
Here is the EJB
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class ConverterEJB implements SessionBean {
public double dollarToYen(double dollars) {
return dollars * 121.6000;
}
public double yenToEuro(double yen) {
return yen * 0.0077;
}
public ConverterEJB() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionC
}
And finally here is the Client
import javax.naming.Context;
import javax.naming.InitialContex
import javax.rmi.PortableRemoteOb
import Converter;
import ConverterHome;
public class ConverterClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("MyConverte
ConverterHome home =
(ConverterHome)PortableRem
ConverterHome.class);
Converter currencyConverter = home.create();
double amount = currencyConverter.dollarTo
System.out.println(String.
amount = currencyConverter.yenToEur
System.out.println(String.
currencyConverter.remove()
} catch (Exception ex) {
System.err.println("Caught
ex.printStackTrace();
}}}
Your input is very valuable.
-prain
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question appears to have been abandoned. In fact, I will include links to ALL your open questions
below:
Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you
wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with
details and we'll respond with the process.
4. Delete the question. Again, you must tell the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below, include the question
QID/link.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click this Help Desk link for Member Guidelines, Member Agreement and the Question/Answer process:
Click you Member Profile to view your question history and keep them all current with updates as the
collaboration effort continues.
https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
PLEASE DO NOT AWARD THE POINTS TO ME.
------------> EXPERTS:
Please leave any comments regarding this question here on closing recommendations if this item remains
inactive another three days.
Thank you everyone.
Open Qs:
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11862698
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11874078
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20059847
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20138628
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20158216
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20158215
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20167637
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20167641
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20270929
Tuvok
Moderator @ Experts Exchange
P.S. For year 2000 question, special attention is needed to ensure the first correct response is awarded,
since they are not in the comment date order, but rather in Member ID order.
below:
Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you
wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with
details and we'll respond with the process.
4. Delete the question. Again, you must tell the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below, include the question
QID/link.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click this Help Desk link for Member Guidelines, Member Agreement and the Question/Answer process:
Click you Member Profile to view your question history and keep them all current with updates as the
collaboration effort continues.
https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
PLEASE DO NOT AWARD THE POINTS TO ME.
------------> EXPERTS:
Please leave any comments regarding this question here on closing recommendations if this item remains
inactive another three days.
Thank you everyone.
Open Qs:
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11862698
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11874078
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20059847
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20138628
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20158216
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20158215
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20167637
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20167641
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20270929
Tuvok
Moderator @ Experts Exchange
P.S. For year 2000 question, special attention is needed to ensure the first correct response is awarded,
since they are not in the comment date order, but rather in Member ID order.
deleting the question would be my suggestion
black:
Thank you for returning to this question!
I will wait for a couple of days before deletion, in case prain returns to the question.
Tuvok,
Moderator@Experts-Exchange
Thank you for returning to this question!
I will wait for a couple of days before deletion, in case prain returns to the question.
Tuvok,
Moderator@Experts-Exchange
prain:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[deleted and points not refunded]
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
I will leave a recommendation in the Cleanup topic area that this question is:
[deleted and points not refunded]
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
Server running on the same machine as the client.