This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Classloader refactoring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Classloader refactoring" Watch "Classloader refactoring" New topic
Author

Classloader refactoring

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
I have something that is already working but wanted to refactor it to work the right way. I have properties file which is setup in the JVM path of websphere (I understand that this is wrong) and then picked up in the code as follows.


I wanted to prevent picking it up from the JVM and just access it from within the ear context (URLLoader Info)

I can't use the following since it is a static method. Devx tips

Any ideas on how I can refactor this.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

If the object is an instance of class X, then this.getClass() == X.class. You will have to hard-code the class though; no polymorphism is possible (actually, it never is in a static context).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
Thanks, I tried that out but it doesn't pick up the file

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

What's the resource name? Are you aware that the resource name must be absolute (e.g. java/lang/resource.txt) without a leading /?
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
In the existing code it works well with

where the file resides in
/ProjectWeb/WebContent/properties/SQLDefinitions.properties

Do you think I need to change this to

 
 
subject: Classloader refactoring
 
Similar Threads
simple search v/s classpath search
URL->filename conversion problem
Iterating all classes in package - of different Java project
java.io.FileNotFoundException
open excel file