• Post Reply Bookmark Topic Watch Topic
  • New Topic

Again Location Transparency dobt  RSS feed

 
Poornachandran R
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai all,
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
weblogic.jndi.T3InitialContextFactory");
p.put(Context.PROVIDER_URL, "T3://localhost:7001");
Context ctx = new InitialContext(p);
InterestSLHome home = (InterestSLHome)ctx.lookup
("InterestSLJNDI");
InterestSL obj = home.create(10);
System.out.println(obj.calculate(100, 100, 100));
obj.remove();
Above is my client code for accessing an ejb object in weblogic. You could the provider url is "localhost". The ejb appl. is deployed in my local system.
Suppose if I move my ejb appl. from local system to some other system which is in the same network. Do I have to do anything in the client code ? Why I am asking is, if I do so, it is not working. Cant I locate an EJB object which is in some other system in the network using JNDI service which is running in my system ?
Poorna
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Poornachandran R:
Suppose if I move my ejb appl. from local system to some other system which is in the same network. Do I have to do anything in the client code ? Why I am asking is, if I do so, it is not working. Cant I locate an EJB object which is in some other system in the network using JNDI service which is running in my system?

Of course, you will need to tell your client where the remote system is (via a url). This is not what location transparency is all about.
BTW, like I mentioned in your previous post... the JNDI properties do not have to be hardcoded in the client. You can place them in a jndi.properties file and include them on the CLASSPATH. Therefore, if the properties change it merely involves updating a properties file and not changing code.
 
Poornachandran R
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Chris
But, could u please tell me what is location transparency is all about ? I am not still comfortable.
Poorna
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Poornachandran R:

location transparency is all about ? I am not still comfortable.


Now let me try explaining this to myself first :-)
1. By having remote interfaces, we are in a position to interface with components residing on different systems instead of just having them locally. So yes the location of the component is not restricted to the local machine.
2. Client code is unaffected.
Imagine the component residing in say a solaris box / NT Box and we don't have a middleware layer like EJB.
If we were to talk to these different OSs by opening raw sockets , the client code will change depending upon the OS. Agree?
3. We need to know where to connect to . It's no magic after all :-)
As they say most problems in computer science have been solved with another level of indirection. The same applies here too.
The client code is defintely location transparent except that it's been achieved by another level of indirection. So the responsibility has shifted. But then someone has to know whom talk to.
Everybody says "Program to an interface" because that is what the client sees. As long as the interface remains the same, the underlying implementation does'nt matter. But then we (or the service provider) still have to instantiate one of the several available implementations (using say a factory class?). But then the factory class has to base it's decision on something. (which is what we do by supplying the parameters to the JNDI context).
I know that am probably not convincing , probably because I too am not convinced yet :-)
I personally think that "Location transparency" cannot be taken literally bcos i simply believe that it's no magic after all. It's more like a buzzword coined to sell something (important yes).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!