org.apache.avalon.fortress.impl.factory
Class ProxyObjectFactory

java.lang.Object
  extended byorg.apache.avalon.fortress.impl.factory.AbstractObjectFactory
      extended byorg.apache.avalon.fortress.impl.factory.ProxyObjectFactory
All Implemented Interfaces:
Instrumentable, org.d_haven.mpool.ObjectFactory

public final class ProxyObjectFactory
extends AbstractObjectFactory

An ObjectFactory that delegates to another ObjectFactory and proxies results of that factory.

Version:
$Revision: 1.4 $ $Date: 2004/02/28 15:16:25 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from class org.apache.avalon.fortress.impl.factory.AbstractObjectFactory
m_delegateFactory
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
ProxyObjectFactory(org.d_haven.mpool.ObjectFactory objectFactory)
          Create factory that delegates to specified factory.
 
Method Summary
static Component createProxy(java.lang.Object service)
          Get the Component wrapped in the proxy.
 void dispose(java.lang.Object object)
          Dispose of objects created by this factory.
static java.lang.Object getObject(java.lang.Object proxy)
          Get the target object from specified proxy.
 java.lang.Object newInstance()
          Create a new instance from delegated factory and proxy it.
 
Methods inherited from class org.apache.avalon.fortress.impl.factory.AbstractObjectFactory
getChildInstrumentables, getCreatedClass, getInstrumentableName, getInstruments, guessWorkInterfaces, setInstrumentableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyObjectFactory

public ProxyObjectFactory(org.d_haven.mpool.ObjectFactory objectFactory)
                   throws java.lang.NullPointerException
Create factory that delegates to specified factory.

Parameters:
objectFactory - the factory to delegate to
Throws:
java.lang.NullPointerException - if the supplied object factory is null
Method Detail

newInstance

public java.lang.Object newInstance()
                             throws java.lang.Exception
Create a new instance from delegated factory and proxy it.

Specified by:
newInstance in interface org.d_haven.mpool.ObjectFactory
Specified by:
newInstance in class AbstractObjectFactory
Returns:
the proxied object
Throws:
java.lang.Exception - if unable to create new instance
See Also:
ObjectFactory.newInstance()

dispose

public void dispose(java.lang.Object object)
             throws java.lang.Exception
Dispose of objects created by this factory. Involves deproxying object and delegating to real ObjectFactory.

Specified by:
dispose in interface org.d_haven.mpool.ObjectFactory
Specified by:
dispose in class AbstractObjectFactory
Parameters:
object - the proxied object
Throws:
java.lang.Exception - if unable to dispose of object
See Also:
ObjectFactory.dispose(Object)

createProxy

public static Component createProxy(java.lang.Object service)
Get the Component wrapped in the proxy.

Parameters:
service - the service object to proxy

getObject

public static java.lang.Object getObject(java.lang.Object proxy)
Get the target object from specified proxy.

Parameters:
proxy - the proxy object
Returns:
the target object
Throws:
java.lang.NullPointerException - if unable to aquire target object, or specified object is not a proxy


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.