I would get away with somthing like:
public class Warning implements java.io.Serializable, java.rmi.Remote
extends java.lang.Throwable {
private String warn="";
private Warning innerWarning=null;
public Warning(String s) {
warn = s;
}
public Warning(Warning w, String s) {
innerWarning = w;
warn = s;
}
public Warning getInnerWarning() {
return innerWarning;
}
public String toString() {
String m = s;
if (innerWarning!=null)
m += innerWarning.toString();
}
}
Whenever a new kind of warning is needed, simply create a new class that
extends Warning, i.e.:
public class SevereWarning extends Warning {
public String toString() {
//change
String m = "SevereWarning:" + s;
//change
if (innerWarning!=null)
m += innerWarning.toString();
}
}
using the right constructor, you can easily nest warnings(to send more than
one warning), so I'd rewrite your method as:
public Vector myMethod()
throws Warning
{
................
if (something) {
throw new Warning(.....);
}
}
HTH
JP
PS: I invented this as I wrote, but never truly coded something like this--
But I have every confidence that the list can contribute much to the idea,
and perhaps get you started.
> -----Original Message-----
> From: Arkady Kasianski [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, March 04, 2001 7:15 PM
> To: 'Juan Lorandi (Chile)'; '[EMAIL PROTECTED]'
> Subject: RE: EJB Remote calls
>
>
> Jaun, thanks again !
> - What is the log4j? Do you have a link ?
> - Suppose I have remote method :
> public Vector myMethod()
> {
> ................
> if (something) {
> // here I want to issue say message with Warning
> severity and not throw Exception
> return new Vector (.....);
> }
> }
>
> How can I handle it ? I can't rely only on exception ...
>
> Thanks in adavnce ...
>
> ____________________
> Arkady Kasyansky
> AMDOCS, R&D
> Tel. : + 972-9-77-61127
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Juan Lorandi (Chile) [mailto:[EMAIL PROTECTED]]
> Sent: Mon, March 05, 2001 12:06 AM
> To: 'Arkady Kasianski'; '[EMAIL PROTECTED]'
> Subject: RE: EJB Remote calls
>
> one thing is error handling, which should be done with exceptions.
> All methods in EJB's implicitly throw RemoteException's
>
> if you want logs, I suggest log4j.
>
> if what you want is a default return status (like in COM),
> you'll have to
> build it yourself.
> in java, exception handling and method status after execution are two
> separate things(as opossed to COM)
> also, if you're using distributed object systems, you have to
> bear in mind
> that there might be network partition(same for CORBA, EJB,
> MTS/COM+). All
> errors are usually critical, and are encapsulated in Exceptions.
>
> An example would surely help
>
> JP
>
> > -----Original Message-----
> > From: Arkady Kasianski [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, March 04, 2001 6:55 PM
> > To: 'Juan Lorandi (Chile)'
> > Subject: RE: EJB Remote calls
> >
> >
> > Thanks for replay. Exception is used for application flow ,
> > not for message
> > handling. For example , remote method does not throw
> > exception, it just put
> > warning message , and I want to have it on the client ...
> > ____________________
> > Arkady Kasyansky
> > AMDOCS, R&D
> > Tel. : + 972-9-77-61127
> > [EMAIL PROTECTED]
> >
> > -----Original Message-----
> > From: Juan Lorandi (Chile) [mailto:[EMAIL PROTECTED]]
> > Sent: Sun, March 04, 2001 11:48 PM
> > To: 'Arkady Kasianski'
> > Subject: RE: EJB Remote calls
> >
> > Use java.rmi.RemoteExceptions
> >
> >
> > > -----Original Message-----
> > > From: Arkady Kasianski [mailto:[EMAIL PROTECTED]]
> > > Sent: Sunday, March 04, 2001 6:22 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: EJB Remote calls
> > >
> > >
> > > Hi everybody ,
> > >
> > > I am new in EJB, but a have a lot of experience in other
> distributed
> > > architectures (DCOM,MTS,CORBA). Right now I am developing an
> > > application
> > > infrastructure based on the WebLogic App Server. Part of this
> > > infrastructure
> > > is client - server Error Handling mechanism. I'd like that
> > > every remote
> > > method will have implicit parameter, say Vector of
> serilizable Error
> > > objects.
> > > I want to transmit them implicitly(for application
> > > programmer) from the
> > > server to the client. Suppose, I have on the server singleton
> > > server-side
> > > ErrorHandlerr class, which keeps container of errors :
> where key =
> > > principal, value = vector of error objects. I also have on
> > > the client side
> > > the same singleton object - client -side ErrorHandler. On the
> > > server side
> > > for example a few errors have been occurred during nested
> > > invocation. All
> > > errors are entered into the vector of error for specific
> > > principal. When
> > > method is returned to the client, I want that this vector of
> > > errors will be
> > > taken with return params from the server to the client. On
> > > the other hand,
> > > on the client side, before control is passed to the client
> > > code, this
> > > error stack will be inserted into client-side error manager .
> > > Is it possible
> > > ? Any ideas ?
> > >
> > > 1. How to force that each remote method in EJB to
> > > have implicit
> > > parameter ? like default parameter in C++ ...
> > > I don't want to write it in each remote method.
> > Can I ask
> > > container to do that on the deployment stage for marashaling
> > > code generation ? Hook ??? API ???
> > >
> > > 2. Server: I'd like to intercept skeleton/ejbobject
> > > call, before
> > > it return result to the sub , it do something ... Hooks ????
> > >
> > > 3. Client: before result will be returned to the
> > > client code , I
> > > 'd like stub will do something Hooks ????
> > >
> > > Generally speaking I am skeptical, but anyway - any
> > ideas ...,
> > >
> > > Thanks
> > >
> > > ==============================================================
> > > =============
> > > To unsubscribe, send email to [EMAIL PROTECTED] and
> > > include in the body
> > > of the message "signoff EJB-INTEREST". For general help,
> > > send email to
> > > [EMAIL PROTECTED] and include in the body of the
> message "help".
> > >
> >
> > ##############################################################
> > ##############
> > This e-mail message has been scanned for Viruses and Content
> > and cleared
> > ##############################################################
> > ##############
> >
>
> ##############################################################
> ##############
> This e-mail message has been scanned for Viruses and Content
> and cleared
> ##############################################################
> ##############
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".