Translet
, BeanRegistry
, MessageSource
public class CoreTranslet extends java.lang.Object implements Translet
This class is generally not thread-safe. It is primarily designed for use in a single thread only.
Constructor | Description |
---|---|
CoreTranslet(CoreActivity activity) |
Instantiates a new CoreTranslet.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
acceptsProfiles(java.lang.String... profiles) |
Return whether the given profile is active.
|
boolean |
containsBean(java.lang.Class<?> requiredType) |
Return whether a bean with the specified object type is present.
|
boolean |
containsBean(java.lang.String id) |
Return whether a bean with the specified id is present.
|
java.util.Map<java.lang.String,java.lang.Object> |
copyAllParameters() |
Returns the parameter copied to the new instance.
|
void |
dispatch(DispatchResponseRule dispatchResponseRule) |
Dispatch to other resources as the given rule.
|
void |
dispatch(java.lang.String name) |
Dispatch to other resources as the given name.
|
void |
dispatch(java.lang.String name,
boolean immediately) |
Dispatch to other resources as the given name.
|
void |
fillAllParameters(java.util.Map<java.lang.String,java.lang.Object> targetParameters) |
Fills all parameters to the specified map.
|
void |
fillAttributeMap(java.util.Map<java.lang.String,java.lang.Object> attributeMap) |
Fills all attributes to the specified map.
|
void |
forward(ForwardResponseRule forwardResponseRule) |
Forward according to a given rule.
|
void |
forward(java.lang.String transletName) |
Forward to the specified translet immediately.
|
void |
forward(java.lang.String transletName,
boolean immediately) |
Forward to the specified translet.
|
ActivityDataMap |
getActivityDataMap() |
Returns an Activity Data Map containing the activity result data.
|
ActivityDataMap |
getActivityDataMap(boolean prefill) |
Returns an Activity Data Map containing the activity result data.
|
<T> T |
getAfterAdviceResult(java.lang.String aspectId) |
Gets the after advice result.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAllAttributes() |
Return a mutable
Map of the request attributes,
with attribute names as map keys and attribute value as map value. |
java.util.Map<java.lang.String,java.lang.Object> |
getAllParameters() |
Return an immutable Map of the request parameters,
with parameter names as map keys and parameter values as map values.
|
<T> T |
getApplicationAdaptee() |
Returns the adaptee object to provide application information.
|
ApplicationAdapter |
getApplicationAdapter() |
Gets the application adapter.
|
<T> T |
getAroundAdviceResult(java.lang.String aspectId) |
Gets the around advice result.
|
<T> T |
getAspectAdviceBean(java.lang.String aspectId) |
Gets the aspect advice bean.
|
<T> T |
getAttribute(java.lang.String name) |
Returns the value of the named attribute as a given type,
or
null if no attribute of the given name exists. |
java.util.Enumeration<java.lang.String> |
getAttributeNames() |
Returns an
Enumeration containing the
names of the attributes available to this request. |
<T> T |
getBean(java.lang.Class<T> requiredType) |
Return an instance of the bean that matches the given object type.
|
<T> T |
getBean(java.lang.Class<T> requiredType,
java.lang.String id) |
Return an instance of the bean that matches the given object type.
|
<T> T |
getBean(java.lang.String id) |
Return an instance of the bean that matches the given id.
|
<T> T |
getBean(java.lang.String id,
java.lang.Class<T> requiredType) |
Return an instance of the bean that matches the given id.
|
<T> T |
getBeforeAdviceResult(java.lang.String aspectId) |
Gets the before advice result.
|
<T> T |
getConfigBean(java.lang.Class<T> classType) |
Return the bean instance that matches the specified object type.
|
java.lang.String |
getDescription() |
Returns a description of this
Translet . |
Environment |
getEnvironment() |
Returns the environment of the current activity context.
|
FileParameter |
getFileParameter(java.lang.String name) |
Returns a
FileParameter object as a given activity's request parameter name,
or null if the parameter does not exist. |
java.util.Enumeration<java.lang.String> |
getFileParameterNames() |
Returns an
Enumeration of String objects containing
the names of the file parameters contained in this request. |
FileParameter[] |
getFileParameterValues(java.lang.String name) |
Returns an array of
FileParameter objects containing all
of the values the given activity's request parameter has,
or null if the parameter does not exist. |
<T> T |
getFinallyAdviceResult(java.lang.String aspectId) |
Gets the finally advice result.
|
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args) |
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage) |
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale) |
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale) |
Try to resolve the message.
|
java.lang.String |
getName() |
Returns the name of this
Translet . |
java.lang.String |
getParameter(java.lang.String name) |
Returns the value of an activity's request parameter as a
String ,
or null if the parameter does not exist. |
java.util.Enumeration<java.lang.String> |
getParameterNames() |
Returns an
Enumeration of String objects containing
the names of the parameters contained in this request. |
java.lang.String[] |
getParameterValues(java.lang.String name) |
Returns an array of
String objects containing all
of the values the given activity's request parameter has,
or null if the parameter does not exist. |
ProcessResult |
getProcessResult() |
Returns the process result.
|
java.lang.Object |
getProcessResult(java.lang.String actionId) |
Returns a action result for the specified action id from the process result,
or
null if the action does not exist. |
java.lang.Throwable |
getRaisedException() |
Returns the raised exception instance.
|
<T> T |
getRequestAdaptee() |
Returns the adaptee object to provide request information.
|
RequestAdapter |
getRequestAdapter() |
Gets the request adapter.
|
java.lang.String |
getRequestEncoding() |
Returns the request encoding.
|
MethodType |
getRequestMethod() |
Gets the request http method.
|
<T> T |
getResponseAdaptee() |
Returns the adaptee object to provide response information.
|
ResponseAdapter |
getResponseAdapter() |
Gets the response adapter.
|
java.lang.String |
getResponseEncoding() |
Returns the response encoding.
|
java.lang.Throwable |
getRootCauseOfRaisedException() |
Returns the innermost one of the chained (wrapped) exceptions.
|
<T> T |
getSessionAdaptee() |
Returns the adaptee object to provide session information.
|
SessionAdapter |
getSessionAdapter() |
Gets the session adapter.
|
<T> T |
getSetting(java.lang.String settingName) |
Gets the setting value in the translet scope.
|
java.lang.Class<? extends CoreTranslet> |
getTransletImplementationClass() |
Returns an implementation class for the
Translet . |
java.lang.Class<? extends Translet> |
getTransletInterfaceClass() |
Returns an interface class for the
Translet . |
boolean |
isExceptionRaised() |
Returns whether the exception was thrown.
|
void |
redirect(RedirectResponseRule redirectResponseRule) |
Redirect a client according to the given rule.
|
void |
redirect(java.lang.String target) |
Redirect a client to a new target resource.
|
void |
redirect(java.lang.String target,
boolean immediately) |
Redirect a client to a new target resource.
|
void |
redirect(java.lang.String target,
java.util.Map<java.lang.String,java.lang.String> parameters) |
Redirect to the other target resource.
|
void |
removeAttribute(java.lang.String name) |
Removes an attribute from this request.
|
void |
removeFileParameter(java.lang.String name) |
Removes the file parameter with the specified name.
|
void |
response() |
Respond immediately, and the remaining jobs will be canceled.
|
void |
response(Response response) |
Respond immediately, and the remaining jobs will be canceled.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
Stores an attribute in this request.
|
void |
setFileParameter(java.lang.String name,
FileParameter fileParameter) |
Sets the
FileParameter object to the file parameter with the given name. |
void |
setFileParameter(java.lang.String name,
FileParameter[] fileParameters) |
Sets the value to the file parameter with the given name.
|
void |
setParameter(java.lang.String name,
java.lang.String value) |
Sets the value to the parameter with the given name.
|
void |
setParameter(java.lang.String name,
java.lang.String[] values) |
Sets the value to the parameter with the given name.
|
void |
setProcessResult(ProcessResult processResult) |
Sets the process result.
|
ProcessResult |
touchProcessResult() |
Returns the ProcessResult.
|
ProcessResult |
touchProcessResult(java.lang.String contentsName) |
Returns the process result with the contents name.
|
ProcessResult |
touchProcessResult(java.lang.String contentsName,
int initialCapacity) |
Returns the process result with the contents name.
|
void |
transform(TransformRule transformRule) |
Transformation according to a given rule, and transmits this response.
|
public CoreTranslet(CoreActivity activity)
activity
- the current Activitypublic java.lang.String getName()
Translet
Translet
.public java.lang.String getDescription()
Translet
Translet
.getDescription
in interface Translet
Translet
public MethodType getRequestMethod()
Translet
getRequestMethod
in interface Translet
public Environment getEnvironment()
Translet
getEnvironment
in interface Translet
public ApplicationAdapter getApplicationAdapter()
Translet
getApplicationAdapter
in interface Translet
public SessionAdapter getSessionAdapter()
Translet
getSessionAdapter
in interface Translet
public RequestAdapter getRequestAdapter()
Translet
getRequestAdapter
in interface Translet
public ResponseAdapter getResponseAdapter()
Translet
getResponseAdapter
in interface Translet
public <T> T getApplicationAdaptee()
Translet
getApplicationAdaptee
in interface Translet
T
- the type of the application adapteepublic <T> T getSessionAdaptee()
Translet
getSessionAdaptee
in interface Translet
T
- the type of the session adapteepublic <T> T getRequestAdaptee()
Translet
getRequestAdaptee
in interface Translet
T
- the type of the request adapteepublic <T> T getResponseAdaptee()
Translet
getResponseAdaptee
in interface Translet
T
- the type of the response adapteepublic java.lang.String getRequestEncoding()
Translet
getRequestEncoding
in interface Translet
public java.lang.String getResponseEncoding()
Translet
getResponseEncoding
in interface Translet
public ProcessResult getProcessResult()
Translet
getProcessResult
in interface Translet
public java.lang.Object getProcessResult(java.lang.String actionId)
Translet
null
if the action does not exist.getProcessResult
in interface Translet
actionId
- the specified action idpublic void setProcessResult(ProcessResult processResult)
Translet
setProcessResult
in interface Translet
processResult
- the new process resultpublic ProcessResult touchProcessResult()
Translet
touchProcessResult
in interface Translet
public ProcessResult touchProcessResult(java.lang.String contentsName)
Translet
touchProcessResult
in interface Translet
contentsName
- the contents namepublic ProcessResult touchProcessResult(java.lang.String contentsName, int initialCapacity)
Translet
touchProcessResult
in interface Translet
contentsName
- the contents nameinitialCapacity
- the initial capacity of the process resultpublic ActivityDataMap getActivityDataMap()
Translet
getActivityDataMap
in interface Translet
public ActivityDataMap getActivityDataMap(boolean prefill)
Translet
getActivityDataMap
in interface Translet
prefill
- whether data pre-fill.public <T> T getSetting(java.lang.String settingName)
Translet
getSetting
in interface Translet
T
- the type of the valuesettingName
- the setting namepublic java.lang.String getParameter(java.lang.String name)
Translet
String
,
or null
if the parameter does not exist.getParameter
in interface Translet
name
- a String
specifying the name of the parameterString
representing the
single value of the parameterTranslet.getParameterValues(java.lang.String)
public java.lang.String[] getParameterValues(java.lang.String name)
Translet
String
objects containing all
of the values the given activity's request parameter has,
or null
if the parameter does not exist.getParameterValues
in interface Translet
name
- a String
specifying the name of the parameterString
objects
containing the parameter's valuesTranslet.getParameter(java.lang.String)
public java.util.Enumeration<java.lang.String> getParameterNames()
Translet
Enumeration
of String
objects containing
the names of the parameters contained in this request.
If the request has no parameters, the method returns an empty Enumeration
.getParameterNames
in interface Translet
Enumeration
of String
objects, each String
containing the name of a request parameter;
or an empty Enumeration
if the request has no parameterspublic void setParameter(java.lang.String name, java.lang.String value)
Translet
setParameter
in interface Translet
name
- a String
specifying the name of the parametervalue
- a String
representing the
single value of the parameterTranslet.setParameter(String, String[])
public void setParameter(java.lang.String name, java.lang.String[] values)
Translet
setParameter
in interface Translet
name
- a String
specifying the name of the parametervalues
- an array of String
objects
containing the parameter's valuesTranslet.setParameter(java.lang.String, java.lang.String)
public java.util.Map<java.lang.String,java.lang.Object> getAllParameters()
Translet
getAllParameters
in interface Translet
public java.util.Map<java.lang.String,java.lang.Object> copyAllParameters()
Translet
copyAllParameters
in interface Translet
public void fillAllParameters(java.util.Map<java.lang.String,java.lang.Object> targetParameters)
Translet
fillAllParameters
in interface Translet
targetParameters
- the target parameter map to be filledpublic FileParameter getFileParameter(java.lang.String name)
Translet
FileParameter
object as a given activity's request parameter name,
or null
if the parameter does not exist.getFileParameter
in interface Translet
name
- a String
specifying the name of the file parameterFileParameter
representing the
single value of the parameterTranslet.getFileParameterValues(java.lang.String)
public FileParameter[] getFileParameterValues(java.lang.String name)
Translet
FileParameter
objects containing all
of the values the given activity's request parameter has,
or null
if the parameter does not exist.getFileParameterValues
in interface Translet
name
- a String
specifying the name of the file parameterFileParameter
objects
containing the parameter's valuesTranslet.getFileParameter(java.lang.String)
public java.util.Enumeration<java.lang.String> getFileParameterNames()
Translet
Enumeration
of String
objects containing
the names of the file parameters contained in this request.
If the request has no parameters, the method returns an empty Enumeration
.getFileParameterNames
in interface Translet
Enumeration
of String
objects, each String
containing the name of a file parameter;
or an empty Enumeration
if the request has no file parameterspublic void setFileParameter(java.lang.String name, FileParameter fileParameter)
Translet
FileParameter
object to the file parameter with the given name.setFileParameter
in interface Translet
name
- a String
specifying the name of the file parameterfileParameter
- a FileParameter
representing the
single value of the parameterTranslet.setFileParameter(String, FileParameter[])
public void setFileParameter(java.lang.String name, FileParameter[] fileParameters)
Translet
setFileParameter
in interface Translet
name
- a String
specifying the name of the file parameterfileParameters
- an array of FileParameter
objects
containing the file parameter's valuesTranslet.setFileParameter(java.lang.String, com.aspectran.core.activity.request.parameter.FileParameter)
public void removeFileParameter(java.lang.String name)
Translet
removeFileParameter
in interface Translet
name
- a String
specifying the name of the file parameterpublic <T> T getAttribute(java.lang.String name)
Translet
null
if no attribute of the given name exists.getAttribute
in interface Translet
T
- the generic typename
- a String
specifying the name of the attributeObject
containing the value of the attribute,
or null
if the attribute does not existpublic void setAttribute(java.lang.String name, java.lang.Object value)
Translet
setAttribute
in interface Translet
name
- specifying the name of the attributevalue
- the Object
to be storedpublic java.util.Enumeration<java.lang.String> getAttributeNames()
Translet
Enumeration
containing the
names of the attributes available to this request.
This method returns an empty Enumeration
if the request has no attributes available to it.getAttributeNames
in interface Translet
public void removeAttribute(java.lang.String name)
Translet
removeAttribute
in interface Translet
name
- a String
specifying the name of the attribute to removepublic java.util.Map<java.lang.String,java.lang.Object> getAllAttributes()
Translet
Map
of the request attributes,
with attribute names as map keys and attribute value as map value.getAllAttributes
in interface Translet
public void fillAttributeMap(java.util.Map<java.lang.String,java.lang.Object> attributeMap)
Translet
fillAttributeMap
in interface Translet
attributeMap
- the attribute mappublic void response()
Translet
public void response(Response response)
Translet
public void transform(TransformRule transformRule)
Translet
public void dispatch(DispatchResponseRule dispatchResponseRule)
Translet
public void dispatch(java.lang.String name)
Translet
public void dispatch(java.lang.String name, boolean immediately)
Translet
public void redirect(RedirectResponseRule redirectResponseRule)
Translet
public void redirect(java.lang.String target)
Translet
public void redirect(java.lang.String target, boolean immediately)
Translet
immediately
is true, create a new redirect response rule
and override the intended redirect response rule.public void redirect(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> parameters)
Translet
public void forward(ForwardResponseRule forwardResponseRule)
Translet
public void forward(java.lang.String transletName)
Translet
public void forward(java.lang.String transletName, boolean immediately)
Translet
public boolean isExceptionRaised()
Translet
isExceptionRaised
in interface Translet
public java.lang.Throwable getRaisedException()
Translet
getRaisedException
in interface Translet
public java.lang.Throwable getRootCauseOfRaisedException()
Translet
getRootCauseOfRaisedException
in interface Translet
public boolean acceptsProfiles(java.lang.String... profiles)
Translet
acceptsProfiles
in interface Translet
profiles
- the profilestrue
if profile is active, otherwise false
public <T> T getAspectAdviceBean(java.lang.String aspectId)
Translet
getAspectAdviceBean
in interface Translet
T
- the generic typeaspectId
- the aspect idpublic <T> T getBeforeAdviceResult(java.lang.String aspectId)
Translet
getBeforeAdviceResult
in interface Translet
T
- the generic typeaspectId
- the aspect idpublic <T> T getAfterAdviceResult(java.lang.String aspectId)
Translet
getAfterAdviceResult
in interface Translet
T
- the generic typeaspectId
- the aspect idpublic <T> T getAroundAdviceResult(java.lang.String aspectId)
Translet
getAroundAdviceResult
in interface Translet
T
- the generic typeaspectId
- the aspect idpublic <T> T getFinallyAdviceResult(java.lang.String aspectId)
Translet
getFinallyAdviceResult
in interface Translet
T
- the generic typeaspectId
- the aspect idpublic java.lang.Class<? extends Translet> getTransletInterfaceClass()
Translet
Translet
.getTransletInterfaceClass
in interface Translet
public java.lang.Class<? extends CoreTranslet> getTransletImplementationClass()
Translet
Translet
.getTransletImplementationClass
in interface Translet
public <T> T getBean(java.lang.String id)
BeanRegistry
getBean
in interface BeanRegistry
T
- the generic typeid
- the id of the bean to retrievepublic <T> T getBean(java.lang.Class<T> requiredType)
BeanRegistry
getBean
in interface BeanRegistry
T
- the generic typerequiredType
- the type the bean must match; can be an interface or superclass. null
is disallowed.public <T> T getBean(java.lang.String id, java.lang.Class<T> requiredType)
BeanRegistry
getBean
in interface BeanRegistry
T
- the generic typeid
- the id of the bean to retrieverequiredType
- type the bean must match; can be an interface or superclass. null
is disallowed.public <T> T getBean(java.lang.Class<T> requiredType, java.lang.String id)
BeanRegistry
getBean
in interface BeanRegistry
T
- the generic typerequiredType
- type the bean must match; can be an interface or superclass. null
is allowed.id
- the id of the bean to retrieve; if requiredType is null
.public <T> T getConfigBean(java.lang.Class<T> classType)
BeanRegistry
BeanNotOfRequiredTypeException
.getConfigBean
in interface BeanRegistry
T
- the generic typeclassType
- type the bean must match; can be an interface or superclass. null
is disallowed.public boolean containsBean(java.lang.String id)
BeanRegistry
containsBean
in interface BeanRegistry
id
- the id of the bean to querypublic boolean containsBean(java.lang.Class<?> requiredType)
BeanRegistry
containsBean
in interface BeanRegistry
requiredType
- the object type of the bean to querypublic java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
MessageSource
getMessage
in interface MessageSource
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),
or null
if none.defaultMessage
- String to return if the lookup failslocale
- the Locale in which to do the lookupMessageFormat
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale) throws NoSuchMessageException
MessageSource
getMessage
in interface MessageSource
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),
or null
if none.locale
- the Locale in which to do the lookupNoSuchMessageException
- if the message wasn't foundMessageFormat
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage)
Translet
getMessage
in interface Translet
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),
or null
if none.defaultMessage
- String to return if the lookup failsMessageFormat
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args) throws NoSuchMessageException
Translet
getMessage
in interface Translet
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),
or null
if none.NoSuchMessageException
- if the message wasn't foundMessageFormat
Copyright © 2008–2018 The Aspectran Project. All rights reserved.