Re: [picocontainer-dev] FactoryAdapter patch

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Is this what you mean Jörg ?  ....

public class LoggingDecorator extends AbstractBehaviorFactory {
    public <T> ComponentAdapter<T> createComponentAdapter(
                         ComponentMonitor componentMonitor,
			LifecycleStrategy lifecycleStrategy,
			Properties componentProperties, Object componentKey,
			Class<T> componentImplementation, Parameter... parameters)
			throws PicoCompositionException {
         ComponentAdapter componentAdapter =  
super.createComponentAdapter(componentMonitor, lifecycleStrategy,
                                                                          componentProperties 
, componentKey, componentImplementation, parameters);
         return new LoggingDecorated(componentAdapter);
    }
}

public class LoggingDecorated<T> extends AbstractBehavior<T> {
       public LoggingDecorated(ComponentAdapter<T> delegate) {
         super(delegate);
     }
     public T getComponentInstance(final PicoContainer container, Type  
into) throws PicoCompositionException {
         Object inst = getDelegate().getComponentInstance(container,  
into)
          
inst 
.getClass 
().getField("log").setValue(LogFactory.getLogger(inst.getClass()));
         return inst;
     }
}

Or a design that looked for more than the field, and called a setter  
from an interface ?

- Paul

On Apr 23, 2008, at 9:29 AM, Paul Hammant wrote:

> Oh sorry, didn't see this before the commit Jörg - I'll answer  
> shortly.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.