Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] debugging without stopping server

I asked this question (http://www.nabble.com/Re%3A-A-general-question-p19484058.html) in aspectwerkz  mailinglist and looks like this feature (online weaving) can be workaround. Does anyone know how to do it in aspectj? Or would anyone please point me where there contains such document or example?

Thank you very much,

--- On Sat, 13/9/08, Andrew Eisenberg <andrew@xxxxxxxxxxxx> wrote:

> From: Andrew Eisenberg <andrew@xxxxxxxxxxxx>
> Subject: Re: [aspectj-users] debugging without stopping server
> To: javadeveloper999@xxxxxxxxxxx, aspectj-users@xxxxxxxxxxx
> Date: Saturday, 13 September, 2008, 4:30 PM
> I think I am beginning to see what you want.  You want to
> take a
> server that is already running, and without stopping it,
> add some
> aspects to it that will perform logging and tracing.  Is
> that right?
> Unfortunately, this is not the way normal AspectJ load time
> weaving
> works.  All classes and aspects must be available at boot
> time.
> 
> So, the server must be brought down, and restarted with the
> aspects on
> the classpath and using the appropriate java agent and
> aop,xml.
> 
> However, there are some technologies that allow dynamic
> deployment of
> aspects like Equinox aspects and Spring dynamic server, but
> they both
> require that you use OSGi as an underlying architecture. 
> Similarly,
> this is how AspectWerkz and JBoss worked.
> 
> On Sat, Sep 13, 2008 at 6:54 AM, Neo Anderson
> <javadeveloper999@xxxxxxxxxxx> wrote:
> > Hi Simone,
> >
> > Thanks for spending time to explain it. : )
> >
> > But I think there is still something I do not
> understand very well and want to make it clear.
> >
> > In fact, I have successfully get load-time weaving
> example worked
> (http://www.nabble.com/Load-time-weaving-problem-tt19347338.html#a19357654).
> So I think I have some basic ideas about how load-time
> weaving processes. However, it looks like it is based on
> each time when a new jvm is launched (via executing `java
> -javaagent:...`), weaving aspect to the target classes. Now
> suppose if I have a server already running, it may execute
> command like 'java -classpath ....' or 'java
> -javaagent:...' (all is based on jdk 5.0 or higher
> version). If I want to capture/ trace information as you
> described below, what should I do in order to achieve it
> without stopping the server?
> >
> > For instance, I programme a mock server which only
> prints count on the screen (source is as A). How can I hook
> my aspect to capture when counter is equals to 7 (Then do
> something defined in the aspect like tracing or log value to
> somewhere, etc.) I completely have no idea about this (As I
> understand is this is run-time/ online weaving, which
> aspectj does not support, but aspectwerkz does, which now is
> merged with aspectj.) Would you please to give me a bit more
> explain on this (or some steps to perform this)? Or kindly
> pointing me where there contains such document for aspectj.
> >
> > I sincerely appreciate your help.
> >
> > A.)
> > package sys;
> >
> > public class Server{
> >        private static int count = 0;
> >
> >        private synchronized void start(){
> >                try{
> >                        while(true){
> >                               
> System.out.println("count:"+count);
> >                                count++;
> >                                new
> Thread().sleep(1000);
> >                        }
> >                }catch(Exception e){
> >                        e.printStackTrace();
> >                }
> >        }
> >
> >        public static void main(String args[]){
> >                new Server().start();
> >        }
> > }
> >
> >





Back to the top