org.apache.ojb.broker.core.proxy
Interface ProxyFactory

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractProxyFactory, ProxyFactoryCGLIBImpl, ProxyFactoryJDKImpl

public interface ProxyFactory
extends java.io.Serializable

Factory class for creating instances of the indirection handler used by OJB's proxies, and for the collection proxies.

Version:
$Id: ProxyFactory.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Dudziak

Method Summary
 ManageableCollection createCollectionProxy(PBKey brokerKey, Query query, java.lang.Class collectionClass)
          Create a Collection Proxy for a given context.
 IndirectionHandler createIndirectionHandler(PBKey pbKey, Identity id)
          Creates a new indirection handler instance.
 OJBProxy createProxy(java.lang.Class baseClass, IndirectionHandler handler)
           
 CollectionProxy getCollectionProxy(java.lang.Object item)
          Return CollectionProxy for item is item is a CollectionProxy, otherwise return null
 java.lang.Class getCollectionProxyClass()
          Returns the collection proxy class.
 java.lang.Class getDefaultIndirectionHandlerClass()
          Returns the class of a default IndirectionHandler that can be used for this implementaiton if now IndirectionHandlerClass implementation is given.
 IndirectionHandler getIndirectionHandler(java.lang.Object obj)
          Returns the invocation handler object of the given proxy object.
 java.lang.Class getIndirectionHandlerBaseClass()
          Returns the class of the base class that the given IndirectionHandler must extend/implement
 java.lang.Class getIndirectionHandlerClass()
          Returns the indirection handler class.
 java.lang.Class getListProxyClass()
          Returns the list proxy class.
 java.lang.Class getRealClass(java.lang.Object objectOrProxy)
          Get the real Class
 java.lang.Object getRealObject(java.lang.Object objectOrProxy)
          Get the real Object
 java.lang.Object getRealObjectIfMaterialized(java.lang.Object objectOrProxy)
          Get the real Object for already materialized Handler
 java.lang.Class getSetProxyClass()
          Returns the set proxy class.
 boolean interfaceRequiredForProxyGeneration()
          Method that returns whether or not this ProxyFactory can generate reference Proxies for classes regardless if they extend an interface or not.
 boolean isCollectionProxy(java.lang.Object item)
          Reports if item is a CollectionProxy.
 boolean isMaterialized(java.lang.Object object)
          Determines whether the object is a materialized object, i.e. no proxy or a proxy that has already been loaded from the database.
 boolean isNormalOjbProxy(java.lang.Object proxyOrObject)
          Determines whether the given object is an OJB proxy.
 boolean isProxy(java.lang.Object proxyOrObject)
          Returns true if the given object is a Proxy or a VirtualProxy instance.
 boolean isVirtualOjbProxy(java.lang.Object proxyOrObject)
          Determines whether the given object is an OJB virtual proxy.
 void setCollectionProxyClass(java.lang.Class collectionProxyClass)
          Dets the proxy class to use for generic collection classes implementing the Collection interface.
 void setIndirectionHandlerClass(java.lang.Class indirectionHandlerClass)
          Sets the indirection handler class.
 void setListProxyClass(java.lang.Class listProxyClass)
          Dets the proxy class to use for collection classes that implement the List interface.
 void setSetProxyClass(java.lang.Class setProxyClass)
          Dets the proxy class to use for collection classes that implement the Set interface.
 java.lang.String toString(java.lang.Object proxy)
          Materialization-safe version of toString.
 

Method Detail

getIndirectionHandlerClass

java.lang.Class getIndirectionHandlerClass()
Returns the indirection handler class.

Returns:
The class for indirection handlers

setIndirectionHandlerClass

void setIndirectionHandlerClass(java.lang.Class indirectionHandlerClass)
Sets the indirection handler class.

Parameters:
indirectionHandlerClass - The class for indirection handlers

getDefaultIndirectionHandlerClass

java.lang.Class getDefaultIndirectionHandlerClass()
Returns the class of a default IndirectionHandler that can be used for this implementaiton if now IndirectionHandlerClass implementation is given.


getIndirectionHandlerBaseClass

java.lang.Class getIndirectionHandlerBaseClass()
Returns the class of the base class that the given IndirectionHandler must extend/implement


createIndirectionHandler

IndirectionHandler createIndirectionHandler(PBKey pbKey,
                                            Identity id)
Creates a new indirection handler instance.

Parameters:
persistenceConf - The persistence configuration
id - The subject's ids
Returns:
The new instance

getListProxyClass

java.lang.Class getListProxyClass()
Returns the list proxy class.

Returns:
The class used for list proxies

setListProxyClass

void setListProxyClass(java.lang.Class listProxyClass)
Dets the proxy class to use for collection classes that implement the List interface. Notes that the proxy class must implement the List interface, and have a constructor of the signature (PBKey, Class, Query).

Parameters:
listProxyClass - The proxy class

getSetProxyClass

java.lang.Class getSetProxyClass()
Returns the set proxy class.

Returns:
The class used for set proxies

setSetProxyClass

void setSetProxyClass(java.lang.Class setProxyClass)
Dets the proxy class to use for collection classes that implement the Set interface.

Parameters:
setProxyClass - The proxy class

getCollectionProxyClass

java.lang.Class getCollectionProxyClass()
Returns the collection proxy class.

Returns:
The class used for collection proxies

setCollectionProxyClass

void setCollectionProxyClass(java.lang.Class collectionProxyClass)
Dets the proxy class to use for generic collection classes implementing the Collection interface.

Parameters:
collectionProxyClass - The proxy class

createCollectionProxy

ManageableCollection createCollectionProxy(PBKey brokerKey,
                                           Query query,
                                           java.lang.Class collectionClass)
Create a Collection Proxy for a given context.

Parameters:
persistenceConf - The persistence configuration that the proxy will be bound to
context - The creation context
Returns:
The collection proxy

createProxy

OJBProxy createProxy(java.lang.Class baseClass,
                     IndirectionHandler handler)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getRealObject

java.lang.Object getRealObject(java.lang.Object objectOrProxy)
Get the real Object

Parameters:
objectOrProxy -
Returns:
Object

getRealObjectIfMaterialized

java.lang.Object getRealObjectIfMaterialized(java.lang.Object objectOrProxy)
Get the real Object for already materialized Handler

Parameters:
objectOrProxy -
Returns:
Object or null if the Handel is not materialized

getRealClass

java.lang.Class getRealClass(java.lang.Object objectOrProxy)
Get the real Class

Parameters:
objectOrProxy -
Returns:
Class

isNormalOjbProxy

boolean isNormalOjbProxy(java.lang.Object proxyOrObject)
Determines whether the given object is an OJB proxy.

Returns:
true if the object is an OJB proxy

isVirtualOjbProxy

boolean isVirtualOjbProxy(java.lang.Object proxyOrObject)
Determines whether the given object is an OJB virtual proxy.

Returns:
true if the object is an OJB virtual proxy

isProxy

boolean isProxy(java.lang.Object proxyOrObject)
Returns true if the given object is a Proxy or a VirtualProxy instance.


getIndirectionHandler

IndirectionHandler getIndirectionHandler(java.lang.Object obj)
Returns the invocation handler object of the given proxy object.

Parameters:
obj - The object
Returns:
The invocation handler if the object is an OJB proxy, or null otherwise

isMaterialized

boolean isMaterialized(java.lang.Object object)
Determines whether the object is a materialized object, i.e. no proxy or a proxy that has already been loaded from the database.

Parameters:
object - The object to test
Returns:
true if the object is materialized

getCollectionProxy

CollectionProxy getCollectionProxy(java.lang.Object item)
Return CollectionProxy for item is item is a CollectionProxy, otherwise return null


isCollectionProxy

boolean isCollectionProxy(java.lang.Object item)
Reports if item is a CollectionProxy. TODO: Provide handling for pluggable collection proxy implementations


toString

java.lang.String toString(java.lang.Object proxy)
Materialization-safe version of toString. If the object is a yet-unmaterialized proxy, then only the text "unmaterialized proxy for ..." is returned and the proxy is NOT materialized. Otherwise, the normal toString method is called. This useful e.g. for logging etc.

Parameters:
object - The object for which a string representation shall be generated
Returns:
The string representation

interfaceRequiredForProxyGeneration

boolean interfaceRequiredForProxyGeneration()
Method that returns whether or not this ProxyFactory can generate reference Proxies for classes regardless if they extend an interface or not.



(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30