net.sf.sasl.language.placeholder.aop.resolver.typevalue
Class TypeValuePlaceholderResolver

java.lang.Object
  extended by net.sf.sasl.language.placeholder.aop.resolver.typevalue.TypeValuePlaceholderResolver
All Implemented Interfaces:
IPlaceholderResolver

public class TypeValuePlaceholderResolver
extends Object
implements IPlaceholderResolver

Resolver offers placeholders for getting informations of the arguments and return value type values of target method invocation.
parametersToString{'strategy', ...}:
Will serialize the input parameters in a way that depends on the chosen serialize strategy.
Each strategy can have between [0,N] additional parameters.
Following strategies are currently offered:

parametersToString{'toString' [, 'seperator']}
Will concat all input parameters in order by calling the toString() method on non null input parameters. For a null parameter the output will be "null". The seperator is added between two following parameters. The default seperator is ", ".
The strategy could be useful to log parameters in a "method signature" style.
For example: "Person.whoIs(Elaine, the Lily Maid of Astolat)"

parametersToString{'xml'}
Will serialize each parameter as xml (powered by XStream-Library). The output will be of the form:
<parameterName>
<de.example.Person>
<firstName>Elaine</firstName>
<lastName>the Lily Maid of Astolat</lastName>
...
</parameterName>

Could be useful to get detail informations about the internal state of objects and log objects that do not override the default toString() method. For error cases the output could be simply unmarshelled with XStream to the passed in input objects.

parametersToString{'almostXml'}
Almost the same as the xml-strategy but the xml special chars >,<,& etc. will not get replaced with their entity code. So the output could possibly not readed by a xml parser, but is possibly more human readable friendly.

returnValueToString{'strategy', ...}:
Offers the same strategies like the parametersToString placeholder.
"returnValue" is used as a "fake" parameter name.

Since:
0.0.2 (sasl-common-aspect-library)
Author:
Philipp Förmer

Constructor Summary
TypeValuePlaceholderResolver()
           
 
Method Summary
 IParameterNameLoader getParameterNameLoader()
           
 Set<String> getResolveablePlaceholders()
          Returns a set of all placeholder procedures names that can be resolved by the placeholder.
 Object resolve(String placeholderName, Object[] placeholderArguments, IEnvironment environment)
          Resolves the given placeholder under the passed interpreter environment.
protected  String serializeOverStrategy(net.sf.sasl.language.placeholder.aop.resolver.typevalue.TypeValuePlaceholderResolver.SerializeStrategy strategy, Object[] serializeObjects, String[] parameterNames, Map<String,Object> argumentMap)
          Serializes the objects over the given strategy and returns the serialize output.
 void setParameterNameLoader(IParameterNameLoader parameterNameLoader)
          Sets a parameter name loader which will be used to get the parameter names of a target method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeValuePlaceholderResolver

public TypeValuePlaceholderResolver()
Method Detail

getParameterNameLoader

public IParameterNameLoader getParameterNameLoader()
Returns:
null or non null.
Since:
0.0.2 (sasl-common-aspect-library)
See Also:
setParameterNameLoader(IParameterNameLoader)

setParameterNameLoader

public void setParameterNameLoader(IParameterNameLoader parameterNameLoader)
                            throws IllegalArgumentException
Sets a parameter name loader which will be used to get the parameter names of a target method.

Parameters:
parameterNameLoader - non null
Throws:
IllegalArgumentException - if parameterNameLoader is null.
Since:
0.0.2 (sasl-common-aspect-library)

getResolveablePlaceholders

public Set<String> getResolveablePlaceholders()
Description copied from interface: IPlaceholderResolver
Returns a set of all placeholder procedures names that can be resolved by the placeholder.

Specified by:
getResolveablePlaceholders in interface IPlaceholderResolver
Returns:
non null.
Since:
0.0.2 (sasl-common-aspect-library)
See Also:
IPlaceholderResolver.getResolveablePlaceholders()

resolve

public Object resolve(String placeholderName,
                      Object[] placeholderArguments,
                      IEnvironment environment)
               throws ResolveException
Description copied from interface: IPlaceholderResolver
Resolves the given placeholder under the passed interpreter environment. The placeholderArguments are static defined (in a placeholder script) or dynamic created parameters (by other placeholder calls) that are passed to the placeholder as procedure arguments.
The resolve method is only invoked for placeholders that the resolver defines that he offers them (IPlaceholderResolver.getResolveablePlaceholders()).

Specified by:
resolve in interface IPlaceholderResolver
Parameters:
placeholderName - non null.
placeholderArguments - non null.
environment - non null
Returns:
null or non null.
Throws:
ResolveException - if the placeholder could not get resolved, for example because the parameters mismatch, or the resolution is only successful for a specific target method execution phase.
Since:
0.0.2 (sasl-common-aspect-library)
See Also:
IPlaceholderResolver.resolve(java.lang.String, java.lang.Object[], net.sf.sasl.language.placeholder.aop.interpreter.IEnvironment)

serializeOverStrategy

protected String serializeOverStrategy(net.sf.sasl.language.placeholder.aop.resolver.typevalue.TypeValuePlaceholderResolver.SerializeStrategy strategy,
                                       Object[] serializeObjects,
                                       String[] parameterNames,
                                       Map<String,Object> argumentMap)
Serializes the objects over the given strategy and returns the serialize output.

Parameters:
strategy - non null.
serializeObjects - non null.
parameterNames - non null.
argumentMap - non null.
Returns:
non null.
Since:
0.0.2 (sasl-common-aspect-library)


Copyright © 2010. All Rights Reserved.