1 /*****************************************************************************2 * Copyright (c) PicoContainer Organization. All rights reserved. *3 * ------------------------------------------------------------------------- *4 * The software in this package is published under the terms of the BSD *5 * style license a copy of which has been included with this distribution in *6 * the LICENSE.txt file. *7 * *8 * Idea by Rachel Davies, Original code by various *9 *****************************************************************************/10 package org.nanocontainer.aop.defaults;11 12 import org.nanocontainer.aop.AspectsApplicator;13 import org.picocontainer.ComponentAdapter;14 import org.picocontainer.PicoContainer;15 import org.picocontainer.PicoInitializationException;16 import org.picocontainer.PicoIntrospectionException;17 import org.picocontainer.defaults.AssignabilityRegistrationException;18 import org.picocontainer.defaults.DecoratingComponentAdapter;19 import org.picocontainer.defaults.NotConcreteRegistrationException;20 21 /**22 * @author Stephen Molitor23 */24 public class AspectsComponentAdapter extends DecoratingComponentAdapter {25 26 private final AspectsApplicator aspectsApplicator;27 28 public AspectsComponentAdapter(AspectsApplicator aspectsApplicator, ComponentAdapter delegate) {29 super(delegate);30 this.aspectsApplicator = aspectsApplicator;31 }32 33 public Object getComponentInstance(PicoContainer pico) throws PicoInitializationException, PicoIntrospectionException,34 AssignabilityRegistrationException, NotConcreteRegistrationException {35 Object component = super.getComponentInstance(pico);36 return aspectsApplicator.applyAspects(getComponentKey(), component, pico);37 }38 39 }