• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Do I interface with another class or just call it with a constructor?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First let me say, thank you very much for having this place for Java Greenhorns and to the *many* who help answer questions.

I am very new and in charge of tying up loose ends behind consultants.

I am trying to determine what server I am on based on method written by the team like this:



This should return a boolean value. The class this method is in is called WebStoreContext..

I have tried to get the boolean value by using this.. I should note when I do it does find getProdServer() as an available choice in JBOSS DEV STUDIO


I have also tried:



But there is no true *Interface* class for WebStoreContext.java

What do I need to show further or do in next in order to get the boolean value?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dan,

The constructor path isn't going to work, I'm sure, because you don't want a new WebStoreContext -- you want one particular WebStoreContext, the one that's all configured already. WHat you need to find out it how to get access to that one particular WebStoreContext. Now, I don't know if that's part of an in-house framework, or some COTS framework, or what. But you'd think that the point of this class was to provide global access to those methods, so there must be some way to get ahold of it. Maybe it's stored in the session, or the server context? Do you have any examples or information on this framework?
 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is another file in the same package as WebStoreContext.java, it is WebStoreContextStaticAccessor.java. Not sure if it plays a role and if I need to use this like an interface.

 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, that looks like it, indeed. So it looks like you should just call the static method to get the instance of that class, and then call the other method on it -- like this:

boolean boolProd = WebStoreContextStaticAccessor.getWebStoreContext().getProdServer();

This assumes that something, somewhere, calls "init()" for you. I'd guess that's why that "@Create" annotation is there. Tough to learn Java when there's so much other black magic going on as well, isn't it!
 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That did the trick!!

Yes it has been difficult going at it all at once. Check this out. Java, EJB3, Hibernate, SEAM, JSF, Facelets, RichFaces -- all at once!! he


Sure appreciate the help. Thanks much.
 
Dan Acuff
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way. Is WebStoreContextStaticAccessor.java just a class file that was created to access WebStoreContext and it's methods?

Is this common in Java Programming? Does it have a name?

If anyone could explain more about it, it would be helpful in me learning architecture principals.
 
reply
    Bookmark Topic Watch Topic
  • New Topic