Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Changes import dynamilly?

Sergio,

This may or may not work depending on the relationship
between your jframe objects in the two packages.  If
charvax.swing.JFrame is a subclass of
javax.swing.JFrame,  you can write the following
aspect:


Assume the following class is already defined
(MyClass.java)

import javax.swing.JFrame;

public class MyFrame extends JFrame {
  class definition
}

Now create the following Aspect in AspectJ
(ChangeImport.java) :

import charvax.swing.*;

public aspect ChangeImport {
  declare parents : MyFrame extends JFrame;
}

However, this approach probably won't work with inner
classes or autonomous classes.  You will have to
create your JFrame in a separate file as a public
class for this method to work.  

For the regular graphical version of your app, simply
compile normally with javac, for the character mode,
compile with the ajc compiler, which will weave the
aspect into your code.

If that doesn't work, there is always the Abstract
Factory pattern.


Hope this helps.

-George

--- Sergio Szychowski <sunmix@xxxxxxxxxxxxxx> wrote:
> 
> 
> Hello,
> 	May be you can help me, I need develop un
> application that run
> in graphical mode(swing) and character mode(charva,
> www.pitman.co.za/projects/charva ), this is made
> with:
> 
> graphical mode:
> 
> 	import javax.swing.jframe;
> 
> in character mode:
> 
> 	import charvax.swing.jframe;
> 
> for this I need to write two similar classes, this
> differ only in the
> import clause. One work around is using a
> pre-compiler, this is static
> approach, with this I have two applications.
>  
> Whith aspectj, can I do dynamilly?. One application
> for two
> plataforms, graphic and character mode?
> 
> 
> Thanks you very much.
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top