public interface Writer {
        public void write(String s);
}

public class SystemOutPrinter {
        public void printToSystemOut(String s) {
                System.out.println(s);
        }
}

public aspect PrinterAdapter { 
    
        declare parents: SystemOutPrinter implements Writer;
        public void SystemOutPrinter.write(String s) {
                printToSystemOut(s);
        }
}

public class Main { 
         * In this implementation, the Adaptee becomes its own
         * Adapter, so only one variable is needed. 
        public static void main(String[] args) {

                System.out.println("Creating Adaptee (which is its own 
Adapter)...");
                adaptee = new SystemOutPrinter();

                System.out.print  ("Adapter and Adaptee are the same object: ");
                System.out.println(adaptee == adaptee);

                System.out.println("Issuing the request() to the Adapter...");
                adaptee.write("Test successful.");
        }
}


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251011#4251011

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251011
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to