Package com.aspectran.core.activity
Class CoreTranslet
java.lang.Object
com.aspectran.core.activity.AbstractTranslet
com.aspectran.core.activity.CoreTranslet
- All Implemented Interfaces:
Translet
The Class CoreTranslet.
This class is generally not thread-safe. It is primarily designed for use in a single thread only.
-
Constructor Summary
ConstructorsConstructorDescriptionCoreTranslet
(TransletRule transletRule, CoreActivity activity) Instantiates a new CoreTranslet. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsBean
(Class<?> type) Return whether a bean with the specified object type is present.boolean
containsBean
(Class<?> type, String id) Returns whether the bean corresponding to the specified object type and ID exists.boolean
containsBean
(String id) Return whether a bean with the specified id is present.void
dispatch
(DispatchRule dispatchRule) Dispatch to other resources as the given rule.void
Dispatch to other resources as the given name.void
Dispatch to other resources as the given name.<V> V
Evaluates a token expression.<V> V
Evaluates a token expression.void
extractParameters
(Map<String, Object> targetParameters) Extracts all the parameters and fills in the specified map.void
forward
(ForwardRule forwardRule) Forward according to a given rule.void
Forward to the specified translet immediately.Returns an Activity Data containing the activity result data.<V> V
getAfterAdviceResult
(String aspectId) Gets the after advice result.Return a mutable Map of the request parameters, with parameter names as map keys and parameter values as map values.Gets the application adapter.<V> V
getAroundAdviceResult
(String aspectId) Gets the around advice result.<V> V
getAspectAdviceBean
(String aspectId) Gets the aspect advice bean.<V> V
getAttribute
(String name) Returns the value of the named attribute as a given type, ornull
if no attribute of the given name exists.Returns aCollection
containing the names of the attributes available to this request.<V> V
Return an instance of the bean that matches the given object type.<V> V
Return an instance of the bean that matches the given object type.<V> V
Return an instance of the bean that matches the given id.<V> V
getBeforeAdviceResult
(String aspectId) Gets the before advice result.Returns the originally declared response.Returns a description of thisTranslet
.Returns the environment of the current activity context.getFileParameter
(String name) Returns aFileParameter
object as a given activity's request parameter name, ornull
if the parameter does not exist.Returns aCollection
ofString
objects containing the names of the file parameters contained in this request.getFileParameterValues
(String name) Returns an array ofFileParameter
objects containing all the values the given activity's request file parameter has, ornull
if the parameter does not exist.<V> V
getFinallyAdviceResult
(String aspectId) Gets the final advice result.Returns the intended request encoding.Returns the intended response encoding.getMessage
(String code) Try to resolve the message.getMessage
(String code, Object[] args) Try to resolve the message.getMessage
(String code, Object[] args, String defaultMessage) Try to resolve the message.getMessage
(String code, Object[] args, String defaultMessage, Locale locale) Try to resolve the message.getMessage
(String code, Object[] args, Locale locale) Try to resolve the message.getMessage
(String code, String defaultMessage) Try to resolve the message.getMessage
(String code, String defaultMessage, Locale locale) Try to resolve the message.getMessage
(String code, Locale locale) Try to resolve the message.getParameter
(String name) Returns the value of an activity's request parameter as aString
, ornull
if the parameter does not exist.Returns aCollection
ofString
objects containing the names of the parameters contained in this request.String[]
getParameterValues
(String name) Returns an array ofString
objects containing all the values the given activity's request parameter has, ornull
if the parameter does not exist.Returns the process result.getProcessResult
(String actionId) Returns an action result for the specified action id from the process result, ornull
if the action does not exist.<V> V
getProperty
(String name) Returns the value of the property on environment.Returns the raised exception instance.<V> V
Returns the adaptee object to provide request information.Gets the request adapter.<V> V
Returns the adaptee object to provide response information.Gets the response adapter.Returns the innermost one of the chained (wrapped) exceptions.<V> V
Returns the adaptee object to provide session information.Gets the session adapter.<V> V
getSetting
(String settingName) Gets the setting value in the translet scope.boolean
Returns whether the translet name has tokens for extracting parameters or attributes.boolean
Returns whether the exception was thrown.boolean
Returns whether the response is reserved.void
redirect
(RedirectRule redirectRule) Redirect a client according to the given rule.void
Redirect a client to a new target resource.void
Redirect to the other target resource.void
removeAttribute
(String name) Removes an attribute from this request.void
removeFileParameter
(String name) Removes the file parameter with the specified name.void
Remove the raised exception.void
response()
Respond immediately, and the remaining jobs will be canceled.void
Respond immediately, and the remaining jobs will be canceled.void
setAttribute
(String name, Object value) Stores an attribute in this request.void
setFileParameter
(String name, FileParameter fileParameter) Sets theFileParameter
object to the file parameter with the given name.void
setFileParameter
(String name, FileParameter[] fileParameters) Sets the value to the file parameter with the given name.void
setParameter
(String name, String value) Sets the value to the parameter with the given name.void
setParameter
(String name, String[] values) Sets the value to the parameter with the given name.void
setProcessResult
(ProcessResult processResult) Sets the process result.toString()
void
transform
(CustomTransformer transformer) void
transform
(TransformRule transformRule) Transformation according to a given rule, and transmits this response.Methods inherited from class com.aspectran.core.activity.AbstractTranslet
getRelativeName, getRequestMethod, getRequestName, getRequestRule, getResponseRule, getTransletName, getTransletRule, setRelativeName, setRequestMethod, setRequestName
-
Constructor Details
-
CoreTranslet
Instantiates a new CoreTranslet.- Parameters:
transletRule
- the translet ruleactivity
- the current Activity
-
-
Method Details
-
getContextPath
-
getDescription
Description copied from interface:Translet
Returns a description of thisTranslet
.- Returns:
- a description of this
Translet
-
getEnvironment
Description copied from interface:Translet
Returns the environment of the current activity context.- Returns:
- the environment
-
getApplicationAdapter
Description copied from interface:Translet
Gets the application adapter.- Returns:
- the application adapter
-
getSessionAdapter
Description copied from interface:Translet
Gets the session adapter.- Returns:
- the session adapter
-
getRequestAdapter
Description copied from interface:Translet
Gets the request adapter.- Returns:
- the request adapter
-
getResponseAdapter
Description copied from interface:Translet
Gets the response adapter.- Returns:
- the response adapter
-
getSessionAdaptee
public <V> V getSessionAdaptee()Description copied from interface:Translet
Returns the adaptee object to provide session information.- Type Parameters:
V
- the type of the session adaptee- Returns:
- the session adaptee object
-
getRequestAdaptee
public <V> V getRequestAdaptee()Description copied from interface:Translet
Returns the adaptee object to provide request information.- Type Parameters:
V
- the type of the request adaptee- Returns:
- the request adaptee object
-
getResponseAdaptee
public <V> V getResponseAdaptee()Description copied from interface:Translet
Returns the adaptee object to provide response information.- Type Parameters:
V
- the type of the response adaptee- Returns:
- the response adaptee object
-
getIntendedRequestEncoding
Description copied from interface:Translet
Returns the intended request encoding.- Returns:
- the intended request encoding
-
getIntendedResponseEncoding
Description copied from interface:Translet
Returns the intended response encoding.- Returns:
- the intended response encoding
-
getProcessResult
Description copied from interface:Translet
Returns the process result.- Returns:
- the process result
-
getProcessResult
Description copied from interface:Translet
Returns an action result for the specified action id from the process result, ornull
if the action does not exist.- Parameters:
actionId
- the specified action id- Returns:
- the action result
-
setProcessResult
Description copied from interface:Translet
Sets the process result.- Parameters:
processResult
- the new process result
-
getActivityData
Description copied from interface:Translet
Returns an Activity Data containing the activity result data.- Returns:
- the activity data
-
getSetting
Description copied from interface:Translet
Gets the setting value in the translet scope.- Type Parameters:
V
- the type of the value- Parameters:
settingName
- the setting name- Returns:
- the setting value
-
getProperty
Description copied from interface:Translet
Returns the value of the property on environment.- Type Parameters:
V
- the type of the value- Parameters:
name
- the given property name- Returns:
- the value of the property on environment
-
getParameter
Description copied from interface:Translet
Returns the value of an activity's request parameter as aString
, ornull
if the parameter does not exist.- Parameters:
name
- aString
specifying the name of the parameter- Returns:
- a
String
representing the single value of the parameter - See Also:
-
getParameterValues
Description copied from interface:Translet
Returns an array ofString
objects containing all the values the given activity's request parameter has, ornull
if the parameter does not exist.- Parameters:
name
- aString
specifying the name of the parameter- Returns:
- an array of
String
objects containing the parameter's values - See Also:
-
getParameterNames
Description copied from interface:Translet
Returns aCollection
ofString
objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an emptyCollection
.- Returns:
- an
Collection
ofString
objects, eachString
containing the name of a request parameter; or an emptyCollection
if the request has no parameters
-
setParameter
Description copied from interface:Translet
Sets the value to the parameter with the given name.- Parameters:
name
- aString
specifying the name of the parametervalue
- aString
representing the single value of the parameter- See Also:
-
setParameter
Description copied from interface:Translet
Sets the value to the parameter with the given name.- Parameters:
name
- aString
specifying the name of the parametervalues
- an array ofString
objects containing the parameter's values- See Also:
-
getAllParameters
Description copied from interface:Translet
Return a mutable Map of the request parameters, with parameter names as map keys and parameter values as map values. If the parameter value type is theString
then map value will be of typeString
. If the parameter value type is theString
array then map value will be of typeString
array.- Returns:
- the mutable parameter map
-
extractParameters
Description copied from interface:Translet
Extracts all the parameters and fills in the specified map.- Parameters:
targetParameters
- the target parameter map to be filled
-
getFileParameter
Description copied from interface:Translet
Returns aFileParameter
object as a given activity's request parameter name, ornull
if the parameter does not exist.- Parameters:
name
- aString
specifying the name of the file parameter- Returns:
- a
FileParameter
representing the single value of the parameter - See Also:
-
getFileParameterValues
Description copied from interface:Translet
Returns an array ofFileParameter
objects containing all the values the given activity's request file parameter has, ornull
if the parameter does not exist.- Parameters:
name
- aString
specifying the name of the file parameter- Returns:
- an array of
FileParameter
objects containing the parameter's values - See Also:
-
getFileParameterNames
Description copied from interface:Translet
Returns aCollection
ofString
objects containing the names of the file parameters contained in this request. If the request has no parameters, the method returns an emptyCollection
.- Returns:
- an
Collection
ofString
objects, eachString
containing the name of a file parameter; or an emptyCollection
if the request has no file parameters
-
setFileParameter
Description copied from interface:Translet
Sets theFileParameter
object to the file parameter with the given name.- Parameters:
name
- aString
specifying the name of the file parameterfileParameter
- aFileParameter
representing the single value of the parameter- See Also:
-
setFileParameter
Description copied from interface:Translet
Sets the value to the file parameter with the given name.- Parameters:
name
- aString
specifying the name of the file parameterfileParameters
- an array ofFileParameter
objects containing the file parameter's values- See Also:
-
removeFileParameter
Description copied from interface:Translet
Removes the file parameter with the specified name.- Parameters:
name
- aString
specifying the name of the file parameter
-
getAttribute
Description copied from interface:Translet
Returns the value of the named attribute as a given type, ornull
if no attribute of the given name exists.- Type Parameters:
V
- the type of attribute retrieved- Parameters:
name
- aString
specifying the name of the attribute- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist
-
setAttribute
Description copied from interface:Translet
Stores an attribute in this request.- Parameters:
name
- specifying the name of the attributevalue
- theObject
to be stored
-
getAttributeNames
Description copied from interface:Translet
Returns aCollection
containing the names of the attributes available to this request. This method returns an emptyCollection
if the request has no attributes available to it.- Returns:
- the attribute names
-
removeAttribute
Description copied from interface:Translet
Removes an attribute from this request.- Parameters:
name
- aString
specifying the name of the attribute to remove
-
transform
Description copied from interface:Translet
Transformation according to a given rule, and transmits this response.- Parameters:
transformRule
- the transformation rule
-
transform
-
dispatch
Description copied from interface:Translet
Dispatch to other resources as the given name.- Parameters:
name
- the dispatch name
-
dispatch
Description copied from interface:Translet
Dispatch to other resources as the given name.- Parameters:
name
- the dispatch namedispatcherName
- the id or class name of the view dispatcher bean
-
dispatch
Description copied from interface:Translet
Dispatch to other resources as the given rule.- Parameters:
dispatchRule
- the dispatch rule
-
forward
Description copied from interface:Translet
Forward to the specified translet immediately.- Parameters:
transletName
- the translet name of the target to be forwarded
-
forward
Description copied from interface:Translet
Forward according to a given rule.- Parameters:
forwardRule
- the forward rule
-
redirect
Description copied from interface:Translet
Redirect a client to a new target resource. If an intended redirect rule exists, that may be used.- Parameters:
path
- the redirect path
-
redirect
Description copied from interface:Translet
Redirect to the other target resource.- Parameters:
path
- the redirect pathparameters
- the parameters
-
redirect
Description copied from interface:Translet
Redirect a client according to the given rule.- Parameters:
redirectRule
- the redirect rule
-
response
Description copied from interface:Translet
Respond immediately, and the remaining jobs will be canceled.- Parameters:
response
- the response
-
response
public void response()Description copied from interface:Translet
Respond immediately, and the remaining jobs will be canceled. -
getDeclaredResponse
Description copied from interface:Translet
Returns the originally declared response.- Returns:
- the declared response
-
isResponseReserved
public boolean isResponseReserved()Description copied from interface:Translet
Returns whether the response is reserved.- Returns:
- true, if the response is reserved
-
isExceptionRaised
public boolean isExceptionRaised()Description copied from interface:Translet
Returns whether the exception was thrown.- Returns:
- true, if is exception raised
-
getRaisedException
Description copied from interface:Translet
Returns the raised exception instance.- Returns:
- the raised exception instance
-
removeRaisedException
public void removeRaisedException()Description copied from interface:Translet
Remove the raised exception. -
getRootCauseOfRaisedException
Description copied from interface:Translet
Returns the innermost one of the chained (wrapped) exceptions.- Returns:
- the innermost one of the chained (wrapped) exceptions
-
getAspectAdviceBean
Description copied from interface:Translet
Gets the aspect advice bean.- Type Parameters:
V
- the result type of the advice- Parameters:
aspectId
- the aspect id- Returns:
- the aspect advice bean
-
getBeforeAdviceResult
Description copied from interface:Translet
Gets the before advice result.- Type Parameters:
V
- the result type of the before advice- Parameters:
aspectId
- the aspect id- Returns:
- the before advice result
-
getAfterAdviceResult
Description copied from interface:Translet
Gets the after advice result.- Type Parameters:
V
- the result type of the after advice- Parameters:
aspectId
- the aspect id- Returns:
- the after advice result
-
getAroundAdviceResult
Description copied from interface:Translet
Gets the around advice result.- Type Parameters:
V
- the result type of the around advice- Parameters:
aspectId
- the aspect id- Returns:
- the around advice result
-
getFinallyAdviceResult
Description copied from interface:Translet
Gets the final advice result.- Type Parameters:
V
- the result type of the final advice- Parameters:
aspectId
- the aspect id- Returns:
- the result of final advice
-
hasPathVariables
public boolean hasPathVariables()Description copied from interface:Translet
Returns whether the translet name has tokens for extracting parameters or attributes.- Returns:
- true if the translet name has tokens for extracting parameters or attributes
-
toString
-
evaluate
Description copied from interface:Translet
Evaluates a token expression.- Type Parameters:
V
- the type of evaluation result value- Parameters:
expression
- the token expression to evaluate- Returns:
- if there are multiple tokens, the result of evaluating them is returned as a string. If there is only one token, it is returned as is.
-
evaluate
Description copied from interface:Translet
Evaluates a token expression.- Type Parameters:
V
- the type of evaluation result value- Parameters:
tokens
- the tokens to evaluate- Returns:
- if there are multiple tokens, the result of evaluating them is returned as a string. If there is only one token, it is returned as is.
-
getBean
Description copied from interface:Translet
Return an instance of the bean that matches the given id.- Type Parameters:
V
- the type of bean object retrieved- Parameters:
id
- the id of the bean to retrieve- Returns:
- an instance of the bean
-
getBean
Description copied from interface:Translet
Return an instance of the bean that matches the given object type.- Type Parameters:
V
- the type of bean object retrieved- Parameters:
type
- the type the bean must match; can be an interface or superclass.null
is disallowed.- Returns:
- an instance of the bean
-
getBean
Description copied from interface:Translet
Return an instance of the bean that matches the given object type.- Type Parameters:
V
- the type of bean object retrieved- Parameters:
type
- type the bean must match; can be an interface or superclass.null
is allowed.id
- the id of the bean to retrieve- Returns:
- an instance of the bean
-
containsBean
Description copied from interface:Translet
Return whether a bean with the specified id is present.- Parameters:
id
- the id of the bean to query- Returns:
- whether a bean with the specified id is present
-
containsBean
Description copied from interface:Translet
Return whether a bean with the specified object type is present.- Parameters:
type
- the object type of the bean to query- Returns:
- whether a bean with the specified type is present
-
containsBean
Description copied from interface:Translet
Returns whether the bean corresponding to the specified object type and ID exists.- Parameters:
type
- the object type of the bean to queryid
- the id of the bean to query- Returns:
- whether a bean with the specified type is present
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Treat as an error if the message can't be found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'- Returns:
- the resolved message
- Throws:
NoSuchMessageException
- if the message wasn't found- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Treat as an error if the message can't be found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'args
- Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.- Returns:
- the resolved message
- Throws:
NoSuchMessageException
- if the message wasn't found- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Return default message if no message was found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.defaultMessage
- String to return if the lookup fails- Returns:
- the resolved message if the lookup was successful; otherwise the default message passed as a parameter
- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Return default message if no message was found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.args
- array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.defaultMessage
- String to return if the lookup fails- Returns:
- the resolved message if the lookup was successful; otherwise the default message passed as a parameter
- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Treat as an error if the message can't be found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'locale
- the Locale in which to do the lookup- Returns:
- the resolved message
- Throws:
NoSuchMessageException
- if the message wasn't found- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Treat as an error if the message can't be found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'args
- Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.locale
- the Locale in which to do the lookup- Returns:
- the resolved message
- Throws:
NoSuchMessageException
- if the message wasn't found- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Return default message if no message was found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.defaultMessage
- String to return if the lookup failslocale
- the Locale in which to do the lookup- Returns:
- the resolved message if the lookup was successful; otherwise the default message passed as a parameter
- See Also:
-
getMessage
Description copied from interface:Translet
Try to resolve the message. Return default message if no message was found.- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.args
- array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.defaultMessage
- String to return if the lookup failslocale
- the Locale in which to do the lookup- Returns:
- the resolved message if the lookup was successful; otherwise the default message passed as a parameter
- See Also:
-