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.defaults; 011 012 import org.nanocontainer.aop.AspectsApplicator; 013 import org.picocontainer.ComponentAdapter; 014 import org.picocontainer.PicoContainer; 015 import org.picocontainer.PicoInitializationException; 016 import org.picocontainer.PicoIntrospectionException; 017 import org.picocontainer.defaults.AssignabilityRegistrationException; 018 import org.picocontainer.defaults.DecoratingComponentAdapter; 019 import org.picocontainer.defaults.NotConcreteRegistrationException; 020 021 /** 022 * @author Stephen Molitor 023 */ 024 public class AspectsComponentAdapter extends DecoratingComponentAdapter { 025 026 private final AspectsApplicator aspectsApplicator; 027 028 public AspectsComponentAdapter(AspectsApplicator aspectsApplicator, ComponentAdapter delegate) { 029 super(delegate); 030 this.aspectsApplicator = aspectsApplicator; 031 } 032 033 public Object getComponentInstance(PicoContainer pico) throws PicoInitializationException, PicoIntrospectionException, 034 AssignabilityRegistrationException, NotConcreteRegistrationException { 035 Object component = super.getComponentInstance(pico); 036 return aspectsApplicator.applyAspects(getComponentKey(), component, pico); 037 } 038 039 }