The Artima Developer Community
Sponsored Link

Java Buzz Forum
Intercepts Has Mixins

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Intercepts Has Mixins Posted: Jan 5, 2004 12:46 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Intercepts Has Mixins
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

Bo requested mixin support for Yet-Another-Intercept-Library (YAIL) so I just checked in support.

The mixin support is completely orthogonal to the interceptor support, and works like:


    public void testMixer()
    {
        Mixer mixer = new Mixer();
        mixer.addMixin(Map.class, new HashMap());
        Object base = new Object();
        Object mixed = mixer.mix(base);
        assertTrue(mixed instanceof Map);
    }

It works fine with the interception library as well:


    public void testInterceptMixins()
    {
        InterceptionBroker broker = new InterceptionBroker();
        MockInterceptor mock = new MockInterceptor();
        broker.addInterceptor(mock, new ClassSignature(Map.class));

        Mixer mixer = new Mixer();
        mixer.addMixin(Map.class, new HashMap());
        Object base = new Object();
        Object mixed = mixer.mix(base);

        Map wrapped = (Map) broker.wrap(mixed);
        wrapped.put("1", "2");
        assertTrue(mock.value);
    }

The mixin support is little more than a thin veneer around cglib's mixins. Adding additional utility to the Mixer class will probably happen once I actually use mixins. I can see places where it will be awfully convenient for passing information down interceptor stacks though.

Finally, unrelated, YAIL and Nanning are getting pretty similar, which bugs me. Jon mentioned that he is considering adding cglib support back into Nanning for people who don't mind aspected classes being non-serializable. This seems like silly duplication, but ah well, is all fun. On a side note I implemeneted a quick-and-dirty Nanning backend to the InterceptionBroker and it worked pretty transparently. None of the unit tests passed though as I tend to use HashMap for the base object, and nanning cannot intercept classes, just interfaces.

Pushed another development snbapshot with this.

Read: Intercepts Has Mixins

Topic: Windows Mobile UI Tutorial Previous Topic   Next Topic Topic: Aspect Oriented Programming Talk

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use