001 /***************************************************************************** 002 * Copyright (c) PicoContainer Organization. All rights reserved. * 003 * ------------------------------------------------------------------------- * 004 * The software in this package is published under the terms of the BSD * 005 * style license a copy of which has been included with this distribution in * 006 * the LICENSE.txt file. * 007 * * 008 * Idea by Rachel Davies, Original code by various * 009 *****************************************************************************/ 010 package org.nanocontainer.aop.dynaop; 011 012 import dynaop.MixinFactory; 013 import dynaop.Proxy; 014 015 import java.util.Properties; 016 017 /** 018 * Produces mixin advice from a mixin instance object. 019 * 020 * @author Stephen Molitor 021 * @version $Revision: 3144 $ 022 */ 023 public class InstanceMixinFactory implements MixinFactory { 024 025 private final Object instance; 026 027 /** 028 * Creates a new <code>InstanceMixinFactory</code> with the given mixin 029 * instance. 030 * 031 * @param instance the mixin instance. 032 */ 033 public InstanceMixinFactory(Object instance) { 034 this.instance = instance; 035 } 036 037 /** 038 * Returns the mixin instance passed to the constructor. 039 * 040 * @param proxy not used. 041 * @return the mixin instance object passed to the constructor. 042 */ 043 public Object create(Proxy proxy) { 044 return instance; 045 } 046 047 /** 048 * Used for debugging. 049 * 050 * @return a set of properties useful for debugging. 051 */ 052 public Properties getProperties() { 053 Properties properties = new Properties(); 054 properties.setProperty("advice", "instance mixin"); 055 return properties; 056 } 057 058 }