Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileOpenService intialization

 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just have started applets and I have a silly question. I know that the applet use the jnlp.jar in the jdk to retrieve data or save data in the file system. one of those services is FileOpenService which is initiated by the following code

why it is just initiated by like any object
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.jnlp.FileOpenService is an interface - you can't instantiate it directly.
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I agree. but how the lookup method instantiate a reference to object of it and cast it back to File Open Service.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By instantiating some class that implements the interface. You can find out which class that is on your particular JVM by printing out "fos.getClass().getName()". That likely won't do you much good, though, as it'll be an internal class of the JRE, and what's more, it'll be different on different OSes, so your code can't make assumptions what it's going to be.
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got you. You mean that JVM instantiate a class that implements this interface and the look up method bring the bject of this class. And because this new class not known to public it is casted to the type i want. Is that what you mean
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of - the cast is needed because ServiceManager can look up services of various kinds, so the object type it returns depends on the service name being passed in. See http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/examples.html for some examples of other services.
 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your quick response. I got it and i will read the link you put .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic