|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.lang.GroovyObjectSupport groovy.lang.Binding groovy.util.FactoryBuilderSupport
public abstract class FactoryBuilderSupport extends Binding
Mix of BuilderSupport and SwingBuilder's factory support. Warning: this implementation is not thread safe and should not be used across threads in a multi-threaded environment. A locking mechanism should be implemented by the subclass if use is expected across multiple threads.
Field Summary | |
---|---|
static java.lang.String |
CHILD_BUILDER
|
static java.lang.String |
CURRENT_BUILDER
|
static java.lang.String |
CURRENT_FACTORY
|
static java.lang.String |
CURRENT_NAME
|
static java.lang.String |
CURRENT_NODE
|
static java.lang.String |
OWNER
|
static java.lang.String |
PARENT_BUILDER
|
static java.lang.String |
PARENT_CONTEXT
|
static java.lang.String |
PARENT_FACTORY
|
static java.lang.String |
PARENT_NAME
|
static java.lang.String |
PARENT_NODE
|
static java.lang.String |
SCRIPT_CLASS_NAME
|
protected java.util.LinkedList |
attributeDelegates
|
protected boolean |
autoRegistrationComplete
|
protected boolean |
autoRegistrationRunning
|
protected java.util.Map |
explicitMethods
|
protected java.util.Map |
explicitProperties
|
protected Closure |
methodMissingDelegate
|
protected java.util.LinkedList |
postInstantiateDelegates
|
protected java.util.LinkedList |
postNodeCompletionDelegates
|
protected java.util.LinkedList |
preInstantiateDelegates
|
protected Closure |
propertyMissingDelegate
|
protected java.util.Map |
registrationGroup
|
protected java.lang.String |
registrationGroupName
|
Constructor Summary | |
FactoryBuilderSupport()
|
|
FactoryBuilderSupport(boolean init)
|
Method Summary | |
---|---|
Closure
|
addAttributeDelegate(Closure attrDelegate)
Add an attribute delegate so it can intercept attributes being set. |
void
|
addDisposalClosure(Closure closure)
|
Closure
|
addPostInstantiateDelegate(Closure delegate)
|
Closure
|
addPostNodeCompletionDelegate(Closure delegate)
|
Closure
|
addPreInstantiateDelegate(Closure delegate)
|
void
|
autoRegisterNodes()
Ask the nodes to be registered |
java.lang.Object
|
build(java.lang.Class viewClass)
|
java.lang.Object
|
build(Script script)
|
java.lang.Object
|
build(java.lang.String script, GroovyClassLoader loader)
|
protected boolean
|
checkExplicitMethod(java.lang.String methodName, java.lang.Object args, Reference result)
|
static void
|
checkValueIsNull(java.lang.Object value, java.lang.Object name)
Throws an exception if value is null. |
static boolean
|
checkValueIsType(java.lang.Object value, java.lang.Object name, java.lang.Class type)
Checks type of value against builder type |
static boolean
|
checkValueIsTypeNotString(java.lang.Object value, java.lang.Object name, java.lang.Class type)
Checks values against factory's type |
protected java.lang.Object
|
createNode(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
|
protected java.lang.Object
|
dispathNodeCall(java.lang.Object name, java.lang.Object args)
|
void
|
dispose()
|
java.util.List
|
getAttributeDelegates()
|
FactoryBuilderSupport
|
getChildBuilder()
|
java.util.Map
|
getContext()
|
java.lang.Object
|
getContextAttribute(java.lang.String key)
|
protected java.util.LinkedList
|
getContexts()
Restores the state of the current builder to the same state as an older build. |
protected java.util.Map
|
getContinuationData()
|
java.lang.Object
|
getCurrent()
@return the current node being built. |
FactoryBuilderSupport
|
getCurrentBuilder()
@return the node of the parent of the current node. |
Factory
|
getCurrentFactory()
@return the factory of the parent of the current node. |
java.lang.String
|
getCurrentName()
@return the builder that built the current node. |
java.util.Map
|
getExplicitMethods()
@return the explicit properties map (Unmodifiable Map). |
java.util.Map
|
getExplicitProperties()
@return the factory map (Unmodifiable Map). |
java.util.Map
|
getFactories()
@return the factory map (Unmodifiable Map). |
java.util.Map
|
getLocalExplicitMethods()
@return the explicit properties map (Unmodifiable Map). |
java.util.Map
|
getLocalExplicitProperties()
|
java.util.Map
|
getLocalFactories()
@return the explicit methods map (Unmodifiable Map). |
Closure
|
getMethodMissingDelegate()
|
java.lang.Object
|
getName(java.lang.String methodName)
A hook to allow names to be converted into some other object such as a QName in XML or ObjectName in JMX. |
Closure
|
getNameMappingClosure()
|
java.util.Map
|
getParentContext()
@return the name of the parent of the current node. |
Factory
|
getParentFactory()
@return the context of the parent of the current node. |
java.lang.String
|
getParentName()
|
java.lang.Object
|
getParentNode()
@return the factory of the parent of the current node. |
java.util.List
|
getPostInstantiateDelegates()
|
java.util.List
|
getPostNodeCompletionDelegates()
|
java.util.List
|
getPreInstantiateDelegates()
|
java.lang.Object
|
getProperty(java.lang.String property)
|
Closure
|
getPropertyMissingDelegate()
|
protected FactoryBuilderSupport
|
getProxyBuilder()
|
java.util.Set
|
getRegistrationGroupItems(java.lang.String group)
|
java.util.Set
|
getRegistrationGroups()
|
java.lang.Object
|
getVariable(java.lang.String name)
@param name the name of the variable to lookup |
java.util.Map
|
getVariables()
|
protected void
|
handleNodeAttributes(java.lang.Object node, java.util.Map attributes)
|
java.lang.Object
|
invokeMethod(java.lang.String methodName)
Convenience method when no arguments are required |
java.lang.Object
|
invokeMethod(java.lang.String methodName, java.lang.Object args)
|
protected void
|
newContext()
A hook to allow nodes to be processed once they have had all of their children applied. |
protected void
|
nodeCompleted(java.lang.Object parent, java.lang.Object node)
|
protected java.util.Map
|
popContext()
|
protected void
|
postInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object node)
|
protected java.lang.Object
|
postNodeCompletion(java.lang.Object parent, java.lang.Object node)
A hook before the factory creates the node. |
protected void
|
preInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
A strategy method to allow derived builders to use builder-trees and switch in different kinds of builders. |
void
|
registerBeanFactory(java.lang.String theName, java.lang.Class beanClass)
|
void
|
registerBeanFactory(java.lang.String theName, java.lang.String groupName, java.lang.Class beanClass)
|
void
|
registerExplicitMethod(java.lang.String name, Closure closure)
|
void
|
registerExplicitMethod(java.lang.String name, java.lang.String groupName, Closure closure)
|
void
|
registerExplicitProperty(java.lang.String name, Closure getter, Closure setter)
|
void
|
registerExplicitProperty(java.lang.String name, java.lang.String groupName, Closure getter, Closure setter)
|
void
|
registerFactory(java.lang.String name, Factory factory)
Registers a factory for a node name. |
void
|
registerFactory(java.lang.String name, java.lang.String groupName, Factory factory)
|
void
|
removeAttributeDelegate(Closure attrDelegate)
|
void
|
removePostInstantiateDelegate(Closure delegate)
|
void
|
removePostNodeCompletionDelegate(Closure delegate)
|
void
|
removePreInstantiateDelegate(Closure delegate)
|
protected void
|
reset()
|
protected Closure
|
resolveExplicitMethod(java.lang.String methodName, java.lang.Object args)
|
protected Closure[]
|
resolveExplicitProperty(java.lang.String propertyName)
|
protected Factory
|
resolveFactory(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
This is a hook for subclasses to plugin a custom strategy for mapping names to factories. |
protected void
|
restoreFromContinuationData(java.util.Map data)
|
protected void
|
setClosureDelegate(Closure closure, java.lang.Object node)
|
void
|
setMethodMissingDelegate(Closure delegate)
|
void
|
setNameMappingClosure(Closure nameMappingClosure)
|
protected void
|
setNodeAttributes(java.lang.Object node, java.util.Map attributes)
|
protected void
|
setParent(java.lang.Object parent, java.lang.Object child)
@return the stack of available contexts. |
void
|
setProperty(java.lang.String property, java.lang.Object newValue)
Overloaded to make variables appear as bean properties or via the subscript operator |
void
|
setPropertyMissingDelegate(Closure delegate)
@return the context of the current node. |
protected void
|
setProxyBuilder(FactoryBuilderSupport proxyBuilder)
Assigns any existing properties to the node. |
void
|
setVariable(java.lang.String name, java.lang.Object value)
|
java.lang.Object
|
withBuilder(FactoryBuilderSupport builder, Closure closure)
|
java.lang.Object
|
withBuilder(FactoryBuilderSupport builder, java.lang.String name, Closure closure)
Switches the builder's proxyBuilder during the execution of a closure. |
java.lang.Object
|
withBuilder(java.util.Map attributes, FactoryBuilderSupport builder, java.lang.String name, Closure closure)
|
Methods inherited from class Binding | |
---|---|
getProperty, getVariable, getVariables, hasVariable, setProperty, setVariable |
Methods inherited from class GroovyObjectSupport | |
---|---|
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final java.lang.String CHILD_BUILDER
public static final java.lang.String CURRENT_BUILDER
public static final java.lang.String CURRENT_FACTORY
public static final java.lang.String CURRENT_NAME
public static final java.lang.String CURRENT_NODE
public static final java.lang.String OWNER
public static final java.lang.String PARENT_BUILDER
public static final java.lang.String PARENT_CONTEXT
public static final java.lang.String PARENT_FACTORY
public static final java.lang.String PARENT_NAME
public static final java.lang.String PARENT_NODE
public static final java.lang.String SCRIPT_CLASS_NAME
protected java.util.LinkedList attributeDelegates
protected boolean autoRegistrationComplete
protected boolean autoRegistrationRunning
protected java.util.Map explicitMethods
protected java.util.Map explicitProperties
protected Closure methodMissingDelegate
protected java.util.LinkedList postInstantiateDelegates
protected java.util.LinkedList postNodeCompletionDelegates
protected java.util.LinkedList preInstantiateDelegates
protected Closure propertyMissingDelegate
protected java.util.Map registrationGroup
protected java.lang.String registrationGroupName
Constructor Detail |
---|
public FactoryBuilderSupport()
public FactoryBuilderSupport(boolean init)
Method Detail |
---|
public Closure addAttributeDelegate(Closure attrDelegate)
attrDelegate
- the closure to be called
public void addDisposalClosure(Closure closure)
public Closure addPostInstantiateDelegate(Closure delegate)
public Closure addPostNodeCompletionDelegate(Closure delegate)
public Closure addPreInstantiateDelegate(Closure delegate)
public void autoRegisterNodes()
public java.lang.Object build(java.lang.Class viewClass)
public java.lang.Object build(Script script)
public java.lang.Object build(java.lang.String script, GroovyClassLoader loader)
protected boolean checkExplicitMethod(java.lang.String methodName, java.lang.Object args, Reference result)
public static void checkValueIsNull(java.lang.Object value, java.lang.Object name)
value
- the node's valuename
- the node's name
public static boolean checkValueIsType(java.lang.Object value, java.lang.Object name, java.lang.Class type)
value
- the node's valuename
- the node's nametype
- a Class that may be assignable to the value's class
public static boolean checkValueIsTypeNotString(java.lang.Object value, java.lang.Object name, java.lang.Class type)
value
- the node's valuename
- the node's nametype
- a Class that may be assignable to the value's class
protected java.lang.Object createNode(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
protected java.lang.Object dispathNodeCall(java.lang.Object name, java.lang.Object args)
public void dispose()
public java.util.List getAttributeDelegates()
public FactoryBuilderSupport getChildBuilder()
public java.util.Map getContext()
public java.lang.Object getContextAttribute(java.lang.String key)
protected java.util.LinkedList getContexts()
data
- the data retrieved from a compatible getContinuationData call
protected java.util.Map getContinuationData()
public java.lang.Object getCurrent()
public FactoryBuilderSupport getCurrentBuilder()
public Factory getCurrentFactory()
public java.lang.String getCurrentName()
public java.util.Map getExplicitMethods()
public java.util.Map getExplicitProperties()
public java.util.Map getFactories()
public java.util.Map getLocalExplicitMethods()
public java.util.Map getLocalExplicitProperties()
public java.util.Map getLocalFactories()
public Closure getMethodMissingDelegate()
public java.lang.Object getName(java.lang.String methodName)
methodName
- the name of the desired method
public Closure getNameMappingClosure()
public java.util.Map getParentContext()
public Factory getParentFactory()
public java.lang.String getParentName()
public java.lang.Object getParentNode()
public java.util.List getPostInstantiateDelegates()
public java.util.List getPostNodeCompletionDelegates()
public java.util.List getPreInstantiateDelegates()
public java.lang.Object getProperty(java.lang.String property)
public Closure getPropertyMissingDelegate()
protected FactoryBuilderSupport getProxyBuilder()
public java.util.Set getRegistrationGroupItems(java.lang.String group)
public java.util.Set getRegistrationGroups()
public java.lang.Object getVariable(java.lang.String name)
name
- the name of the variable to lookup
public java.util.Map getVariables()
protected void handleNodeAttributes(java.lang.Object node, java.util.Map attributes)
public java.lang.Object invokeMethod(java.lang.String methodName)
methodName
- the name of the method to invoke
public java.lang.Object invokeMethod(java.lang.String methodName, java.lang.Object args)
protected void newContext()
node
- the current node being processedparent
- the parent of the node being processed
protected void nodeCompleted(java.lang.Object parent, java.lang.Object node)
protected java.util.Map popContext()
protected void postInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object node)
protected java.lang.Object postNodeCompletion(java.lang.Object parent, java.lang.Object node)
name
- the name of the nodeattributes
- the attributes of the nodevalue
- the value argument(s) of the node
protected void preInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
closure
- the closure on which to call setDelegate()node
- the node value that we've just created, which could be a
builder
public void registerBeanFactory(java.lang.String theName, java.lang.Class beanClass)
public void registerBeanFactory(java.lang.String theName, java.lang.String groupName, java.lang.Class beanClass)
public void registerExplicitMethod(java.lang.String name, Closure closure)
public void registerExplicitMethod(java.lang.String name, java.lang.String groupName, Closure closure)
public void registerExplicitProperty(java.lang.String name, Closure getter, Closure setter)
public void registerExplicitProperty(java.lang.String name, java.lang.String groupName, Closure getter, Closure setter)
public void registerFactory(java.lang.String name, Factory factory)
name
- the name of the nodefactory
- the factory to return the values
public void registerFactory(java.lang.String name, java.lang.String groupName, Factory factory)
public void removeAttributeDelegate(Closure attrDelegate)
public void removePostInstantiateDelegate(Closure delegate)
public void removePostNodeCompletionDelegate(Closure delegate)
public void removePreInstantiateDelegate(Closure delegate)
protected void reset()
*/ protected Closure resolveExplicitMethod(java.lang.String methodName, java.lang.Object args)
protected Closure[] resolveExplicitProperty(java.lang.String propertyName)
protected Factory resolveFactory(java.lang.Object name, java.util.Map attributes, java.lang.Object value)
name
- the name of the factoryattributes
- the attributes from the nodevalue
- value arguments from te node
protected void restoreFromContinuationData(java.util.Map data)
* @param parent the object from the parent node protected void setClosureDelegate(Closure closure, java.lang.Object node)
public void setMethodMissingDelegate(Closure delegate)
public void setNameMappingClosure(Closure nameMappingClosure)
protected void setNodeAttributes(java.lang.Object node, java.util.Map attributes)
protected void setParent(java.lang.Object parent, java.lang.Object child)
public void setProperty(java.lang.String property, java.lang.Object newValue)
public void setPropertyMissingDelegate(Closure delegate)
protected void setProxyBuilder(FactoryBuilderSupport proxyBuilder)
node
- the object returned by tne node factoryattributes
- the attributes for the node
public void setVariable(java.lang.String name, java.lang.Object value)
public java.lang.Object withBuilder(FactoryBuilderSupport builder, Closure closure)
public java.lang.Object withBuilder(FactoryBuilderSupport builder, java.lang.String name, Closure closure)
builder
- the temporary builder to switch to as proxyBuilder.name
- the node to build on the 'parent' builder.closure
- the closure to be executed under the temporary builder.
public java.lang.Object withBuilder(java.util.Map attributes, FactoryBuilderSupport builder, java.lang.String name, Closure closure)
Groovy Documentation