Jingyi Wang

+ Follow
since Jul 30, 2003
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jingyi Wang

1.5 N, right

[ December 08, 2004: Message edited by: Jingyi Wang ]

[ December 08, 2004: Message edited by: Jingyi Wang ]
[ December 08, 2004: Message edited by: Jingyi Wang ]
19 years ago
Yes, this way is better than counting the nodes. Counting the nodes need 1.5N traverses, but this way only need N traverses. Very smart! Anybody else can come up a better way ( less than N traverses? ).
19 years ago
This is single Linkedlist, you are not able to find the last one in the first place
19 years ago
That is not homework. That is an interview problem by some company that I couldn't figure it out even now. So, I just posted here to see if somebody can give an answer. Not a big deal !
19 years ago
Anybody can teach me a way to find the mid-node of a single linkedlist without counting the list. ( the more efficient, the better)
[ December 07, 2004: Message edited by: Jingyi Wang ]
19 years ago
OK, we have three objects: ejb A, ejb B and client R. R is remote to A and B, A and B are not on the same heap ( Remote each other ).
Suppose I have a buiness method in ejb A:

// in ejb A, get remote component interface reference of B
public BRemote getB () throws RemoteException {
Context cxt = new InitialContext ();
Object o = cxt.lookup ( "java:comp/env/ejb/B" );
BHome bh = (BHome) PortableRemoteObject.narrow ( o, BHome.class );
BRemote br = bh.create ();
return br;

// in client R
public void doSth () throws RemoteException {
Context cxt = new InitialContext ();
Object o = cxt.lookup ( "java:comp/env/ejb/A" );
AHome ah = (AHome) PortableRemoteObject.narrow ( o, AHome.class );
ARemote ar = ah.create ();
BHome br = ar.getB (); // call ejb A's buiness method to get B's
// component interface reference
br.callSomeBusinessMethod (); // does work here?
I mean ejb A and ejb B are not in the same heap.
Suppose I have a remote Client R and two remote ejb A and B. A and B are remote as well.

I have a business method in A like this:

BRemote getB () throws RemoteException {
Context ct = new InitialContext ();
HomeB hb = (HomeB) PortableRemoteObject.narrow ( ct.lookup ( "java:comp/env/B" ), HomeB.class );
BRemote rb = hb.create ();
return rb;

Then in client R:
void doSth () throws RemoteException {
//after get Remote component reference for A, ar
BRemote br = ar.getB ();
br.callBussinessMethod ();

Would the above code work?
Should the Bean Provider put some code in the ejbRemove () of entity bean? If so, what kind of code should the bean provider put?
What would happen if an onMessage method return before commiting a transaction? How about stateless session bean ?

How can we deal with getEJBHome () and getEJBObject () in EJBContext interface? I mean how can we cast the general EJBHome and EJBOjbect to the application specific EJB home reference and EJB object reference.

EJBHome ejbo = context.getEJBHome ();
CartHome ch = (CartHome) ejbo;
// or CartHome ch = (CartHome) PortableRemoteObject.narrow ( ch, CartHome.class );

How about the EJBObject?

Thank you guys very much
Suppose I have two beans: Movie and Director
In bean Movie, I have virtual CMRs:

public abstract Director getDirector ();
public abstract void setDirector ( Director d );

I also need a business method getMovieDirector () to get
a given movie's director, IMPORTANT HERE, the client is a remote client, how can I deal with it. In P386, there is a method like

public Director getMovieDirector () {
return getDirector ();

but the Director has to reference a local reference. I need a method like:

DirectorRemote getMovieDirector ();
How can I deal with that, or I am in total wrong way here.