|
Groovy 1.7.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.lang.GroovyObjectSupport
groovy.lang.Binding
groovy.util.FactoryBuilderSupport
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 String |
CHILD_BUILDER
|
static String |
CURRENT_BUILDER
|
static String |
CURRENT_FACTORY
|
static String |
CURRENT_NAME
|
static String |
CURRENT_NODE
|
static String |
OWNER
|
static String |
PARENT_BUILDER
|
static String |
PARENT_CONTEXT
|
static String |
PARENT_FACTORY
|
static String |
PARENT_NAME
|
static String |
PARENT_NODE
|
protected LinkedList |
attributeDelegates
|
protected boolean |
autoRegistrationComplete
|
protected boolean |
autoRegistrationRunning
|
protected Map |
explicitMethods
|
protected Map |
explicitProperties
|
protected LinkedList |
postInstantiateDelegates
|
protected LinkedList |
postNodeCompletionDelegates
|
protected LinkedList |
preInstantiateDelegates
|
protected Map |
registrationGroup
|
protected String |
registrationGroupName
|
Constructor Summary | |
FactoryBuilderSupport()
|
|
FactoryBuilderSupport(boolean init)
|
|
FactoryBuilderSupport(Closure nameMappingClosure)
|
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)
Add a postInstantiate delegate so it can intercept nodes after they are created. |
Closure
|
addPostNodeCompletionDelegate(Closure delegate)
Add a nodeCompletion delegate so it can intercept nodes after they done with building. |
Closure
|
addPreInstantiateDelegate(Closure delegate)
Add a preInstantiate delegate so it can intercept nodes before they are created. |
void
|
autoRegisterNodes()
Ask the nodes to be registered |
Object
|
build(Class viewClass)
|
Object
|
build(Script script)
|
Object
|
build(String script, GroovyClassLoader loader)
|
protected boolean
|
checkExplicitMethod(String methodName, Object args, Reference result)
|
static void
|
checkValueIsNull(Object value, Object name)
Throws an exception if value is null. |
static boolean
|
checkValueIsType(Object value, Object name, Class type)
Checks type of value against builder type is null. |
static boolean
|
checkValueIsTypeNotString(Object value, Object name, Class type)
Checks values against factory's type null or a String. |
protected Object
|
createNode(Object name, Map attributes, Object value)
This method is responsible for instanciating a node and configure its properties. |
protected Object
|
dispathNodeCall(Object name, Object args)
|
void
|
dispose()
|
List
|
getAttributeDelegates()
|
FactoryBuilderSupport
|
getChildBuilder()
|
Map
|
getContext()
|
Object
|
getContextAttribute(String key)
|
protected LinkedList
|
getContexts()
|
protected Map
|
getContinuationData()
Stores the thread local states in a Map that can be passed across threads |
Object
|
getCurrent()
|
FactoryBuilderSupport
|
getCurrentBuilder()
|
Factory
|
getCurrentFactory()
|
String
|
getCurrentName()
|
Map
|
getExplicitMethods()
|
Map
|
getExplicitProperties()
|
Map
|
getFactories()
|
Map
|
getLocalExplicitMethods()
|
Map
|
getLocalExplicitProperties()
|
Map
|
getLocalFactories()
|
Object
|
getName(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()
|
Map
|
getParentContext()
|
Factory
|
getParentFactory()
|
String
|
getParentName()
|
Object
|
getParentNode()
|
List
|
getPostInstantiateDelegates()
|
List
|
getPostNodeCompletionDelegates()
|
List
|
getPreInstantiateDelegates()
|
Object
|
getProperty(String property)
Overloaded to make variables appear as bean properties or via the subscript operator |
protected FactoryBuilderSupport
|
getProxyBuilder()
Proxy builders are useful for changing the building context, thus enabling mix & match builders. |
Set
|
getRegistrationGroupItems(String group)
|
Set
|
getRegistrationGroups()
|
Object
|
getVariable(String name)
|
Map
|
getVariables()
|
protected void
|
handleNodeAttributes(Object node, Map attributes)
Assigns any existing properties to the node. |
Object
|
invokeMethod(String methodName)
Convenience method when no arguments are required |
Object
|
invokeMethod(String methodName, Object args)
|
protected void
|
newContext()
Pushes a new context on the stack. |
protected void
|
nodeCompleted(Object parent, Object node)
A hook to allow nodes to be processed once they have had all of their children applied. |
protected Map
|
popContext()
Removes the last context from the stack. |
protected void
|
postInstantiate(Object name, Map attributes, Object node)
A hook after the factory creates the node and before attributes are set. |
protected Object
|
postNodeCompletion(Object parent, Object node)
A hook to allow nodes to be processed once they have had all of their children applied and allows the actual node object that represents the Markup element to be changed. |
protected void
|
preInstantiate(Object name, Map attributes, Object value)
A hook before the factory creates the node. |
void
|
registerBeanFactory(String theName, Class beanClass)
Registers a factory for a JavaBean. |
void
|
registerBeanFactory(String theName, String groupName, Class beanClass)
Registers a factory for a JavaBean. |
void
|
registerExplicitMethod(String name, Closure closure)
|
void
|
registerExplicitMethod(String name, String groupName, Closure closure)
|
void
|
registerExplicitProperty(String name, Closure getter, Closure setter)
|
void
|
registerExplicitProperty(String name, String groupName, Closure getter, Closure setter)
|
void
|
registerFactory(String name, Factory factory)
Registers a factory for a node name. |
void
|
registerFactory(String name, String groupName, Factory factory)
Registers a factory for a node name. |
void
|
removeAttributeDelegate(Closure attrDelegate)
Remove the most recently added instance of the attribute delegate. |
void
|
removePostInstantiateDelegate(Closure delegate)
Remove the most recently added instance of the postInstantiate delegate. |
void
|
removePostNodeCompletionDelegate(Closure delegate)
Remove the most recently added instance of the nodeCompletion delegate. |
void
|
removePreInstantiateDelegate(Closure delegate)
Remove the most recently added instance of the preInstantiate delegate. |
protected void
|
reset()
Clears the context stack. |
protected Closure
|
resolveExplicitMethod(String methodName, Object args)
This is a hook for subclasses to plugin a custom strategy for mapping names to explicit methods. |
protected Closure[]
|
resolveExplicitProperty(String propertyName)
This is a hook for subclasses to plugin a custom strategy for mapping names to property methods. |
protected Factory
|
resolveFactory(Object name, Map attributes, Object value)
This is a hook for subclasses to plugin a custom strategy for mapping names to factories. |
protected void
|
restoreFromContinuationData(Map data)
Restores the state of the current builder to the same state as an older build. |
protected void
|
setClosureDelegate(Closure closure, Object node)
A strategy method to allow derived builders to use builder-trees and switch in different kinds of builders. |
void
|
setNameMappingClosure(Closure nameMappingClosure)
|
protected void
|
setNodeAttributes(Object node, Map attributes)
Maps attributes key/values to properties on node. |
protected void
|
setParent(Object parent, Object child)
Strategy method to establish parent/child relationships. |
void
|
setProperty(String property, Object newValue)
Overloaded to make variables appear as bean properties or via the subscript operator |
protected void
|
setProxyBuilder(FactoryBuilderSupport proxyBuilder)
Sets the builder to be used as a proxy. |
void
|
setVariable(String name, Object value)
Sets the value of the given variable |
Object
|
withBuilder(FactoryBuilderSupport builder, Closure closure)
Switches the builder's proxyBuilder during the execution of a closure. |
Object
|
withBuilder(FactoryBuilderSupport builder, String name, Closure closure)
Switches the builder's proxyBuilder during the execution of a closure. |
Object
|
withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure)
Switches the builder's proxyBuilder during the execution of a closure. |
Methods inherited from class Binding | |
---|---|
getProperty, getVariable, getVariables, setProperty, setVariable |
Methods inherited from class GroovyObjectSupport | |
---|---|
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty |
Methods inherited from class Object | |
---|---|
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll |
Field Detail |
---|
static final String CHILD_BUILDER
static final String CURRENT_BUILDER
static final String CURRENT_FACTORY
static final String CURRENT_NAME
static final String CURRENT_NODE
static final String OWNER
static final String PARENT_BUILDER
static final String PARENT_CONTEXT
static final String PARENT_FACTORY
static final String PARENT_NAME
static final String PARENT_NODE
protected LinkedList attributeDelegates
protected boolean autoRegistrationComplete
protected boolean autoRegistrationRunning
protected Map explicitMethods
protected Map explicitProperties
protected LinkedList postInstantiateDelegates
protected LinkedList postNodeCompletionDelegates
protected LinkedList preInstantiateDelegates
protected Map registrationGroup
protected String registrationGroupName
Constructor Detail |
---|
public FactoryBuilderSupport()
public FactoryBuilderSupport(boolean init)
@Deprecated public FactoryBuilderSupport(Closure nameMappingClosure)
Method Detail |
---|
public Closure addAttributeDelegate(Closure attrDelegate)
public void addDisposalClosure(Closure closure)
public Closure addPostInstantiateDelegate(Closure delegate)
public Closure addPostNodeCompletionDelegate(Closure delegate)
public Closure addPreInstantiateDelegate(Closure delegate)
public void autoRegisterNodes()
public Object build(Class viewClass)
public Object build(Script script)
public Object build(String script, GroovyClassLoader loader)
protected boolean checkExplicitMethod(String methodName, Object args, Reference result)
public static void checkValueIsNull(Object value, Object name)
public static boolean checkValueIsType(Object value, Object name, Class type)
public static boolean checkValueIsTypeNotString(Object value, Object name, Class type)
protected Object createNode(Object name, Map attributes, Object value)
protected Object dispathNodeCall(Object name, Object args)
public void dispose()
public List getAttributeDelegates()
public FactoryBuilderSupport getChildBuilder()
public Map getContext()
public Object getContextAttribute(String key)
protected LinkedList getContexts()
protected Map getContinuationData()
public Object getCurrent()
public FactoryBuilderSupport getCurrentBuilder()
public Factory getCurrentFactory()
public String getCurrentName()
public Map getExplicitMethods()
public Map getExplicitProperties()
public Map getFactories()
public Map getLocalExplicitMethods()
public Map getLocalExplicitProperties()
public Map getLocalFactories()
public Object getName(String methodName)
public Closure getNameMappingClosure()
public Map getParentContext()
public Factory getParentFactory()
public String getParentName()
public Object getParentNode()
public List getPostInstantiateDelegates()
public List getPostNodeCompletionDelegates()
public List getPreInstantiateDelegates()
public Object getProperty(String property)
protected FactoryBuilderSupport getProxyBuilder()
public Set getRegistrationGroupItems(String group)
public Set getRegistrationGroups()
public Object getVariable(String name)
public Map getVariables()
protected void handleNodeAttributes(Object node, Map attributes)
public Object invokeMethod(String methodName)
public Object invokeMethod(String methodName, Object args)
protected void newContext()
protected void nodeCompleted(Object parent, Object node)
protected Map popContext()
protected void postInstantiate(Object name, Map attributes, Object node)
protected Object postNodeCompletion(Object parent, Object node)
protected void preInstantiate(Object name, Map attributes, Object value)
public void registerBeanFactory(String theName, Class beanClass)
public void registerBeanFactory(String theName, String groupName, Class beanClass)
public void registerExplicitMethod(String name, Closure closure)
public void registerExplicitMethod(String name, String groupName, Closure closure)
public void registerExplicitProperty(String name, Closure getter, Closure setter)
public void registerExplicitProperty(String name, String groupName, Closure getter, Closure setter)
public void registerFactory(String name, Factory factory)
public void registerFactory(String name, 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()
@SuppressWarnings({"UnusedDeclaration"}) protected Closure resolveExplicitMethod(String methodName, Object args)
protected Closure[] resolveExplicitProperty(String propertyName)
protected Factory resolveFactory(Object name, Map attributes, Object value)
protected void restoreFromContinuationData(Map data)
@SuppressWarnings({"UnusedDeclaration"}) protected void setClosureDelegate(Closure closure, Object node)
public void setNameMappingClosure(Closure nameMappingClosure)
protected void setNodeAttributes(Object node, Map attributes)
protected void setParent(Object parent, Object child)
public void setProperty(String property, Object newValue)
protected void setProxyBuilder(FactoryBuilderSupport proxyBuilder)
public void setVariable(String name, Object value)
public Object withBuilder(FactoryBuilderSupport builder, Closure closure)
public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure)
public Object withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure)
Copyright © 2003-2009 The Codehaus. All rights reserved.