Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / November 2006

Tip: Looking for answers? Try searching our database.

Overriding (or something similar) Exceptions

Thread view: 
graham.parsons@reflective.com - 13 Nov 2006 17:33 GMT
Hi guys,

We have a "legacy" Java application that has been developed by many
developers - some handle exceptions nicely, others not so.

What I would like to do is create a log of all the exceptions and
messages that are being thrown internally without changing the code.

I was thinking around the classloader - create my own Exception class
which uses the standard one but before passing the call to the standard
one, writes out to the log.

So mine is loaded by the JVM but all I do is extend the standard one
and override a method - is this "cyclic dependancy possible"?

If not, can anyone suggest any other route I could take to get the
desired functionality?

Cheers

Graham
Oliver Wong - 13 Nov 2006 19:43 GMT
> Hi guys,
>
[quoted text clipped - 13 lines]
> If not, can anyone suggest any other route I could take to get the
> desired functionality?

   Look into Aspect Oriented Programming, and AspectJ.

   - Oliver
Tris Orendorff - 13 Nov 2006 23:45 GMT
> Hi guys,
>
[quoted text clipped - 10 lines]
> So mine is loaded by the JVM but all I do is extend the standard one
> and override a method - is this "cyclic dependancy possible"?

If I understand you, you can do this.  Exceptions and classes are very
similar so you can say, "public class Mine extends IOException {}" and
write a new constructor.  You still have to change the code to use your
new exceptions.

So my second suggestion would be to add the logging code to the runtime
library and whip up a special rt.jar file.

Signature

Sincerely,

Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.