Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classloader refactoring

 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I tried that out but it doesn't pick up the file

 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic