Class ComponentPageElementResourcesImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl
-
- All Implemented Interfaces:
ComponentPageElementResources
,OperationTracker
,ContextValueEncoder
public class ComponentPageElementResourcesImpl extends java.lang.Object implements ComponentPageElementResources
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.tapestry5.ioc.OperationTracker
OperationTracker.NonLoggableException
-
-
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, java.lang.Class<T> targetType)
Performs a coercion from an input type to a desired output type.Link
createComponentEventLink(ComponentResources resources, java.lang.String eventType, boolean forForm, java.lang.Object... context)
Creates a link on behalf of a component.Link
createPageRenderLink(java.lang.Class pageClass, boolean override, java.lang.Object... context)
Creates a page render request link to render a specific page.Link
createPageRenderLink(java.lang.String pageName, boolean override, java.lang.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(java.lang.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(java.lang.String description, IOOperation<T> operation)
As withOperationTracker.invoke(String, Invokable)
, but the operation may throw anIOException
.void
run(java.lang.String description, java.lang.Runnable operation)
Executes the operation.java.lang.Class
toClass(java.lang.String className)
Gets the Class instance for then give name.java.lang.String
toClient(java.lang.Object value)
Converts a context value into a client-side string (that will ultimately be encoded into a URL).<T> T
toValue(java.lang.Class<T> requiredType, java.lang.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, java.lang.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 java.lang.Class toClass(java.lang.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, java.lang.String eventType, boolean forForm, java.lang.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(java.lang.String pageName, boolean override, java.lang.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(java.lang.Class pageClass, boolean override, java.lang.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 java.lang.String toClient(java.lang.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(java.lang.Class<T> requiredType, java.lang.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(java.lang.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(java.lang.String description, IOOperation<T> operation) throws java.io.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:
java.io.IOException
-
run
public void run(java.lang.String description, java.lang.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
-
-