nyla.solutions.global.patterns.aop.TransformationAroundCommandAdvice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.global Show documentation
Show all versions of nyla.solutions.global Show documentation
Nyla Solutions Global Java API provides support for basic application
utilities (application configuration, data encryption, debugger and text
processing).
The newest version!
package nyla.solutions.global.patterns.aop;
import nyla.solutions.global.patterns.command.Command;
import nyla.solutions.global.util.Organizer;
import org.aspectj.lang.ProceedingJoinPoint;
public class TransformationAroundCommandAdvice
{
/**
* transform the arguments and return for a join point
* @param proceedingJoinPoint
* @return
* @throws Throwable
*/
public Object transform(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
{
Object[] arguments = proceedingJoinPoint.getArgs();
if(beforeCommand != null)
{
Object inputArgument = arguments;
if(arguments != null && arguments.length == 1)
{
//only use a single argument
inputArgument = arguments[0];
}
Object resultArguments = beforeCommand.execute(inputArgument);
arguments = Organizer.toArray(resultArguments);
}
// proceeding processing and get results
Object retVal = proceedingJoinPoint.proceed(arguments);
if(afterCommand != null)
{
retVal = afterCommand.execute(retVal);
}
return retVal;
}// ------------------------------------------------
/**
* @return the beforeCommand
*/
public Command