Class ComponentPageElementResourcesImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl
-
- All Implemented Interfaces:
ComponentPageElementResources
,OperationTracker
,ContextValueEncoder
public class ComponentPageElementResourcesImpl extends Object implements ComponentPageElementResources
-
-
Constructor Summary
Constructors Constructor Description ComponentPageElementResourcesImpl(ComponentResourceSelector selector, ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer, ComponentClassCache componentClassCache, ContextValueEncoder contextValueEncoder, LinkSource linkSource, RequestPageCache requestPageCache, ComponentClassResolver componentClassResolver, LoggerSource loggerSource, OperationTracker tracker, PerthreadManager perThreadManager, boolean productionMode, boolean componentTracingEnabled, RequestGlobals requestGlobals)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S,T>
Tcoerce(S input, Class<T> targetType)
Performs a coercion from an input type to a desired output type.Link
createComponentEventLink(ComponentResources resources, String eventType, boolean forForm, Object... context)
Creates a link on behalf of a component.Link
createPageRenderLink(Class pageClass, boolean override, Object... context)
Creates a page render request link to render a specific page.Link
createPageRenderLink(String pageName, boolean override, Object... context)
Creates a page render request link to render a specific page.<T> PerThreadValue<T>
createPerThreadValue()
Wrapper aroundPerthreadManager.createValue()
.org.slf4j.Logger
getEventLogger(org.slf4j.Logger componentLogger)
Returns the event logger for the provided component logger.Messages
getMessages(ComponentModel componentModel)
Used to obtain aMessages
instance for a particular component.ComponentResourceSelector
getSelector()
Returns the selector associated with this resources.<T> T
invoke(String description, Invokable<T> operation)
As withOperationTracker.run(String, Runnable)
, but the operation may return a value.boolean
isRenderTracingEnabled()
Returns true if component element tracing is enabled.<T> T
perform(String description, IOOperation<T> operation)
As withOperationTracker.invoke(String, Invokable)
, but the operation may throw anIOException
.void
run(String description, Runnable operation)
Executes the operation.Class
toClass(String className)
Gets the Class instance for then give name.String
toClient(Object value)
Converts a context value into a client-side string (that will ultimately be encoded into a URL).<T> T
toValue(Class<T> requiredType, String clientValue)
Converts a client value back into a server-side object.
-
-
-
Constructor Detail
-
ComponentPageElementResourcesImpl
public ComponentPageElementResourcesImpl(ComponentResourceSelector selector, ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer, ComponentClassCache componentClassCache, ContextValueEncoder contextValueEncoder, LinkSource linkSource, RequestPageCache requestPageCache, ComponentClassResolver componentClassResolver, LoggerSource loggerSource, OperationTracker tracker, PerthreadManager perThreadManager, boolean productionMode, boolean componentTracingEnabled, RequestGlobals requestGlobals)
-
-
Method Detail
-
getSelector
public ComponentResourceSelector getSelector()
Description copied from interface:ComponentPageElementResources
Returns the selector associated with this resources.- Specified by:
getSelector
in interfaceComponentPageElementResources
-
getMessages
public Messages getMessages(ComponentModel componentModel)
Description copied from interface:ComponentPageElementResources
Used to obtain aMessages
instance for a particular component. If the component extends from another component, then its localized properties will merge with its parent's properties (with the subclass overriding the super class on any conflicts).- Specified by:
getMessages
in interfaceComponentPageElementResources
- Returns:
- the message catalog for the component, in the indicated locale
- See Also:
ComponentMessagesSource
-
coerce
public <S,T> T coerce(S input, Class<T> targetType)
Description copied from interface:ComponentPageElementResources
Performs a coercion from an input type to a desired output type. When the target type is a primitive, the actual conversion will be to the equivalent wrapper type. In some cases, the TypeCoercer will need to search for an appropriate coercion, and may even combine existing coercions to form new ones; in those cases, the results of the search are cached.- Specified by:
coerce
in interfaceComponentPageElementResources
- Type Parameters:
S
- source type (input)T
- target type (output)targetType
- defines the target type- Returns:
- the coerced value
- See Also:
TypeCoercer
-
toClass
public Class toClass(String className)
Description copied from interface:ComponentPageElementResources
Gets the Class instance for then give name.- Specified by:
toClass
in interfaceComponentPageElementResources
- Parameters:
className
- fully qualified class name- Returns:
- the class instance
- See Also:
ComponentClassCache
-
createComponentEventLink
public Link createComponentEventLink(ComponentResources resources, String eventType, boolean forForm, Object... context)
Description copied from interface:ComponentPageElementResources
Creates a link on behalf of a component.- Specified by:
createComponentEventLink
in interfaceComponentPageElementResources
- Parameters:
resources
- resources for the componenteventType
- type of event to createforForm
- true if generating for a form submissioncontext
- additional event context associated with the link- Returns:
- the link
-
createPageRenderLink
public Link createPageRenderLink(String pageName, boolean override, Object... context)
Description copied from interface:ComponentPageElementResources
Creates a page render request link to render a specific page.- Specified by:
createPageRenderLink
in interfaceComponentPageElementResources
- Parameters:
pageName
- the logical name of the page to link tooverride
- if true, the context is used even if empty (normally, the target page is allowed to passivate, providing a context, when the provided context is empty)context
- the activation context for the page. If omitted, the activation context is obtained from the target page- Returns:
- link for a render request to the targetted page
-
createPageRenderLink
public Link createPageRenderLink(Class pageClass, boolean override, Object... context)
Description copied from interface:ComponentPageElementResources
Creates a page render request link to render a specific page. Using a page class, rather than a page name, is more refactoring safe (in the even the page is renamed or moved).- Specified by:
createPageRenderLink
in interfaceComponentPageElementResources
- Parameters:
pageClass
- identifies the page to link tooverride
- if true, the context is used even if empty (normally, the target page is allowed to passivate, providing a context, when the provided context is empty)context
- the activation context for the page. If omitted, the activation context is obtained from the target page- Returns:
- link for a render request to the targetted page
-
getEventLogger
public org.slf4j.Logger getEventLogger(org.slf4j.Logger componentLogger)
Description copied from interface:ComponentPageElementResources
Returns the event logger for the provided component logger. The event logger is based on the component logger's name (which matches the component class name) with a "tapestry..events." prefix.- Specified by:
getEventLogger
in interfaceComponentPageElementResources
- Parameters:
componentLogger
- provides base name for logger- Returns:
- the logger
-
toClient
public String toClient(Object value)
Description copied from interface:ContextValueEncoder
Converts a context value into a client-side string (that will ultimately be encoded into a URL).- Specified by:
toClient
in interfaceContextValueEncoder
- Parameters:
value
- to convert (may not be null)- Returns:
- string representation of the value
- See Also:
ValueEncoder.toClient(Object)
-
toValue
public <T> T toValue(Class<T> requiredType, String clientValue)
Description copied from interface:ContextValueEncoder
Converts a client value back into a server-side object.- Specified by:
toValue
in interfaceContextValueEncoder
- Parameters:
requiredType
- required type to convert the string toclientValue
- value obtained from context passed from client- Returns:
- the client value converted or coerced into a server value
- See Also:
ValueEncoder.toValue(String)
-
invoke
public <T> T invoke(String description, Invokable<T> operation)
Description copied from interface:OperationTracker
As withOperationTracker.run(String, Runnable)
, but the operation may return a value.- Specified by:
invoke
in interfaceOperationTracker
- Parameters:
description
- used if there is an exceptionoperation
- to invoke- Returns:
- result of operation
-
perform
public <T> T perform(String description, IOOperation<T> operation) throws IOException
Description copied from interface:OperationTracker
As withOperationTracker.invoke(String, Invokable)
, but the operation may throw anIOException
.- Specified by:
perform
in interfaceOperationTracker
- Parameters:
description
- used if there is an exception (outside of IOException)operation
- to perform- Returns:
- result of operation
- Throws:
IOException
-
run
public void run(String description, Runnable operation)
Description copied from interface:OperationTracker
Executes the operation. If the operation throws aRuntimeException
it will be logged and rethrown wrapped as aOperationException
.- Specified by:
run
in interfaceOperationTracker
- Parameters:
description
- used if there is an exceptionoperation
- to execute
-
createPerThreadValue
public <T> PerThreadValue<T> createPerThreadValue()
Description copied from interface:ComponentPageElementResources
Wrapper aroundPerthreadManager.createValue()
.- Specified by:
createPerThreadValue
in interfaceComponentPageElementResources
-
isRenderTracingEnabled
public boolean isRenderTracingEnabled()
Description copied from interface:ComponentPageElementResources
Returns true if component element tracing is enabled. When enabled, rendering of the component produces additional comments to identify what component and stage is rendering.- Specified by:
isRenderTracingEnabled
in interfaceComponentPageElementResources
-
-