Fixing error-reporting pointcuts for plugin manager changes I just checked in.

git-svn-id: 2c527eb49caa05e19d6b2be874bf74fa9d7ea670@646544 13f79535-47bb-0310-9956-ffa450edef68

package org.apache.maven.errors;

import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.loader.PluginLoader;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.plan.BuildPlanner;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.lifecycle.statemgmt.StateManagementUtils;
import org.apache.maven.lifecycle.DefaultLifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.plan.LifecyclePlannerException;
import org.apache.maven.project.DuplicateArtifactAttachmentException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.DefaultPluginManager;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.Mojo;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.PlexusContainer;

import java.util.List;

public privileged aspect LifecycleErrorReporterAspect
    extends AbstractCoreReporterAspect
{

    private pointcut le_executeGoalAndHandleFailures( MojoBinding binding ):
        execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, .. ) )
        && args( binding, .. );

    private pointcut le_executeGoalAndHandleFailures_withSession( MojoBinding binding,
                                                                  MavenSession session ):
        execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, MavenSession, .. ) )
        && args( binding, session, .. );

    private pointcut pm_executeMojo( MavenProject project ):
        execution( void PluginManager+.executeMojo( MavenProject, .. ) )
        && args( project, .. );

    private pointcut within_pm_executeMojo( MavenProject project ):
        withincode( void PluginManager+.executeMojo( MavenProject, .. ) )
        && args( project, .. );

    after( MojoBinding binding,
           MavenProject project) throwing ( PluginLoaderException cause ):
        ( cflow( le_executeGoalAndHandleFailures( MojoBinding ) )
          || cflow( execution( * LifecycleExecutor+.isTaskValid( .. ) ) ) )
        && execution( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, .. ) )
        && args( binding, project, .. )
    {
        getReporter().reportErrorLoadingPlugin( binding, project, cause );
    }

    after( String task,
           MavenSession session,
           MavenProject project) throwing ( InvalidPluginException cause ):
        execution( private * DefaultLifecycleExecutor.getMojoDescriptorForDirectInvocation( String, MavenSession, MavenProject ) )
        && args( task, session, project )
    {
        getReporter().reportInvalidPluginForDirectInvocation( task, session, project, cause );
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( DuplicateArtifactAttachmentException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( void Mojo+.execute() )
    {
        getReporter().reportDuplicateAttachmentException( binding, project, cause );
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( MojoExecutionException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( void Mojo+.execute() )
    {
        // this will be covered by the reportErrorLoadingPlugin(..) method.
        if ( !StateManagementUtils.RESOLVE_LATE_BOUND_PLUGIN_GOAL.equals( binding.getGoal() ) )
        {
            getReporter().reportMojoExecutionException( binding, project, cause );
        }
    }

    PluginExecutionException around( MojoBinding binding,
                                     MavenProject project ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( PluginExecutionException.new( .., String ) )
    {
        PluginExecutionException cause = proceed( binding, project );
        getReporter().reportInvalidPluginExecutionEnvironment( binding, project, cause );

        return cause;
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( ComponentLookupException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && withincode( Mojo DefaultPluginManager.getConfiguredMojo( .. ) )
        && call( Object PlexusContainer+.lookup( .. ) )
    {
        getReporter().reportMojoLookupError( binding, project, cause );
    }

    Parameter currentParameter;

    private pointcut paramGetName( Parameter parameter ):
        call( String Parameter.getName() )
        && target( parameter );

    private pointcut pm_validatePomConfig():
        execution( void DefaultPluginManager.validatePomConfiguration( .. ) );

    private pointcut within_pm_validatePomConfig():
        withincode( void DefaultPluginManager.validatePomConfiguration( .. ) );

    private pointcut pm_checkRequiredParameters():
        execution( void DefaultPluginManager.checkRequiredParameters( .. ) );

    private pointcut within_pm_checkRequiredParameters():
        withincode( void DefaultPluginManager.checkRequiredParameters( .. ) );

    before( Parameter parameter ):
        ( within_pm_validatePomConfig()
          || within_pm_checkRequiredParameters() )
        && paramGetName( parameter )
    {
        currentParameter = parameter;
    }

    after() returning:
        pm_validatePomConfig() ||
        pm_checkRequiredParameters()
    {
        currentParameter = null;
    }

    private pointcut pm_executeMojoWithSessionAndExec( MavenProject project,
                                                       MojoExecution exec,
                                                       MavenSession session,
                                                       DefaultPluginManager manager ):
        execution( void DefaultPluginManager.executeMojo( MavenProject, MojoExecution, MavenSession ) )
        && args( project, exec, session )
        && this( manager );

    after( MojoBinding binding,
           MavenProject project,
           MojoExecution exec,
           MavenSession session,
           DefaultPluginManager manager) throwing( PluginConfigurationException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojoWithSessionAndExec( project, exec, session, manager ) )
        && pm_validatePomConfig()
    {
        PathTranslator translator = manager.pathTranslator;
        Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "error reporting" );
        getReporter().reportAttemptToOverrideUneditableMojoParameter( currentParameter,
                                                                      binding,
                                                                      project,
                                                                      session,
                                                                      exec,
                                                                      translator,
                                                                      logger,
                                                                      cause );
    }

    PluginParameterException around( MojoBinding binding,
                                     MavenProject project,
                                     List invalidParameters ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && call( PluginParameterException.new( .., List ) )
        && args( .., invalidParameters )
    {
        PluginParameterException err = proceed( binding, project, invalidParameters );

        getReporter().reportMissingRequiredMojoParameter( binding, project, invalidParameters, err );

        return err;
    }

    private pointcut ppee_evaluate( String expression ):
        execution( Object PluginParameterExpressionEvaluator.evaluate( String ) )
        && args( expression );

    private pointcut within_ppee_evaluate( String expression ):
        withincode( Object PluginParameterExpressionEvaluator.evaluate( String ) )
        && args( expression );

    before( MojoBinding binding,
            MavenProject project,
            String expression,
            ExpressionEvaluationException err ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && cflow( ppee_evaluate( expression ) )
        && execution( ExpressionEvaluationException.new( String ) )
        && this( err )
    {
        getReporter().reportUseOfBannedMojoParameter( currentParameter,
                                                      binding,
                                                      project,
                                                      expression,
                                                      (String) PluginParameterExpressionEvaluator.BANNED_EXPRESSIONS.get( expression ),
                                                      err );
    }

    after( MojoBinding binding,
           MavenProject project,
           String expression) throwing ( Exception cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && cflow( ppee_evaluate( expression ) )
        && within( PluginParameterExpressionEvaluator )
        && call( Object ReflectionValueExtractor.evaluate( String, Object ) )
    {
        getReporter().reportReflectionErrorWhileEvaluatingMojoParameter( currentParameter,
                                                                         binding,
                                                                         project,
                                                                         expression,
                                                                         cause );
    }

    after( MojoBinding binding,
           MavenProject project,
           PlexusConfiguration config) throwing( PluginConfigurationException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && execution( void DefaultPluginManager.populatePluginFields( *, *, PlexusConfiguration, .. ) )
        && args( *, *, config, .. )
    {
        getReporter().reportErrorApplyingMojoConfiguration( binding, project, config, cause );
    }

    private pointcut pm_resolveTransitiveDependencies( MavenProject project,
                                                       String scope ):
        execution( void DefaultPluginManager.resolveTransitiveDependencies( *, *, String, *, MavenProject, * ) )
        && args( *, *, scope, *, project, * );

    after( MavenProject project,
           String scope) throwing( ArtifactNotFoundException cause ):
        pm_resolveTransitiveDependencies( project, scope )
    {
        getReporter().reportProjectDependenciesNotFound( project, scope, cause );
    }

    after( MavenProject project,
           String scope) throwing( ArtifactResolutionException cause ):
        pm_resolveTransitiveDependencies( project, scope )
    {
        if ( cause instanceof MultipleArtifactsNotFoundException )
        {
            getReporter().reportProjectDependenciesNotFound( project,
                                                             scope,
                                                             (MultipleArtifactsNotFoundException) cause );
        }
        else
        {
            getReporter().reportProjectDependenciesUnresolvable( project, scope, cause );
        }
    }

    private pointcut le_getLifecycleBindings( List tasks,
                                              MavenProject configuringProject,
                                              String targetDescription ):
        execution( List DefaultLifecycleExecutor.getLifecycleBindings( List, MavenProject, *, String ) )
        && args( tasks, configuringProject, *, targetDescription );

    BuildPlan around( List tasks,
                      MavenProject project,
                      MavenSession session )
        throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException:
            cflow( execution( * DefaultLifecycleExecutor.*( .. ) ) )
            && execution( BuildPlan BuildPlanner+.constructBuildPlan( List, MavenProject, MavenSession, * ) )
            && args( tasks, project, session, * )
    {
        try
        {
            return proceed( tasks, project, session );
        }
        catch ( LifecycleLoaderException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
        catch ( LifecyclePlannerException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
        catch ( LifecycleSpecificationException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
    }

}

package org.apache.maven.errors;

import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.loader.PluginLoader;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.plan.BuildPlanner;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.lifecycle.statemgmt.StateManagementUtils;
import org.apache.maven.lifecycle.DefaultLifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.plan.LifecyclePlannerException;
import org.apache.maven.project.DuplicateArtifactAttachmentException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.DefaultPluginManager;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.Mojo;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.PlexusContainer;

import java.util.List;

public privileged aspect LifecycleErrorReporterAspect
    extends AbstractCoreReporterAspect
{

    private pointcut le_executeGoalAndHandleFailures( MojoBinding binding ):
        execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, .. ) )
        && args( binding, .. );

    private pointcut le_executeGoalAndHandleFailures_withSession( MojoBinding binding,
                                                                  MavenSession session ):
        execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, MavenSession, .. ) )
        && args( binding, session, .. );

    private pointcut pm_executeMojo( MavenProject project ):
        execution( void PluginManager+.executeMojo( MavenProject, .. ) )
        && args( project, .. );

    private pointcut within_pm_executeMojo( MavenProject project ):
        withincode( void PluginManager+.executeMojo( MavenProject, .. ) )
        && args( project, .. );

    after( MojoBinding binding,
           MavenProject project) throwing ( PluginLoaderException cause ):
        ( cflow( le_executeGoalAndHandleFailures( MojoBinding ) )
          || cflow( execution( * LifecycleExecutor+.isTaskValid( .. ) ) ) )
        && execution( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, .. ) )
        && args( binding, project, .. )
    {
        getReporter().reportErrorLoadingPlugin( binding, project, cause );
    }

    after( String task,
           MavenSession session,
           MavenProject project) throwing ( InvalidPluginException cause ):
        execution( private * DefaultLifecycleExecutor.getMojoDescriptorForDirectInvocation( String, MavenSession, MavenProject ) )
        && args( task, session, project )
    {
        getReporter().reportInvalidPluginForDirectInvocation( task, session, project, cause );
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( DuplicateArtifactAttachmentException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( void Mojo+.execute() )
    {
        getReporter().reportDuplicateAttachmentException( binding, project, cause );
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( MojoExecutionException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( void Mojo+.execute() )
    {
        // this will be covered by the reportErrorLoadingPlugin(..) method.
        if ( !StateManagementUtils.RESOLVE_LATE_BOUND_PLUGIN_GOAL.equals( binding.getGoal() ) )
        {
            getReporter().reportMojoExecutionException( binding, project, cause );
        }
    }

    PluginExecutionException around( MojoBinding binding,
                                     MavenProject project ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && call( PluginExecutionException.new( .., String ) )
    {
        PluginExecutionException cause = proceed( binding, project );
        getReporter().reportInvalidPluginExecutionEnvironment( binding, project, cause );

        return cause;
    }

    after( MojoBinding binding,
           MavenProject project) throwing ( ComponentLookupException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && withincode( Mojo DefaultPluginManager.getConfiguredMojo( .. ) )
        && call( Object PlexusContainer+.lookup( .. ) )
    {
        getReporter().reportMojoLookupError( binding, project, cause );
    }

    Parameter currentParameter;

    private pointcut paramGetName( Parameter parameter ):
        call( String Parameter.getName() )
        && target( parameter );

    private pointcut pm_validatePomConfig():
        execution( void DefaultPluginManager.validatePomConfiguration( .. ) );

    private pointcut within_pm_validatePomConfig():
        withincode( void DefaultPluginManager.validatePomConfiguration( .. ) );

    private pointcut pm_checkRequiredParameters():
        execution( void DefaultPluginManager.checkRequiredParameters( .. ) );

    private pointcut within_pm_checkRequiredParameters():
        withincode( void DefaultPluginManager.checkRequiredParameters( .. ) );

    before( Parameter parameter ):
        ( within_pm_validatePomConfig()
          || within_pm_checkRequiredParameters() )
        && paramGetName( parameter )
    {
        currentParameter = parameter;
    }

    after() returning:
        pm_validatePomConfig() ||
        pm_checkRequiredParameters()
    {
        currentParameter = null;
    }

    private pointcut pm_executeMojoWithSessionAndExec( MavenProject project,
                                                       MojoExecution exec,
                                                       MavenSession session,
                                                       DefaultPluginManager manager ):
        execution( void DefaultPluginManager.executeMojo( MavenProject, MojoExecution, MavenSession ) )
        && args( project, exec, session )
        && this( manager );

    after( MojoBinding binding,
           MavenProject project,
           MojoExecution exec,
           MavenSession session,
           DefaultPluginManager manager) throwing( PluginConfigurationException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojoWithSessionAndExec( project, exec, session, manager ) )
        && pm_validatePomConfig()
    {
        PathTranslator translator = manager.pathTranslator;
        Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "error reporting" );
        getReporter().reportAttemptToOverrideUneditableMojoParameter( currentParameter,
                                                                      binding,
                                                                      project,
                                                                      session,
                                                                      exec,
                                                                      translator,
                                                                      logger,
                                                                      cause );
    }

    PluginParameterException around( MojoBinding binding,
                                     MavenProject project,
                                     List invalidParameters ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && call( PluginParameterException.new( .., List ) )
        && args( .., invalidParameters )
    {
        PluginParameterException err = proceed( binding, project, invalidParameters );

        getReporter().reportMissingRequiredMojoParameter( binding, project, invalidParameters, err );

        return err;
    }

    private pointcut ppee_evaluate( String expression ):
        execution( Object PluginParameterExpressionEvaluator.evaluate( String ) )
        && args( expression );

    private pointcut within_ppee_evaluate( String expression ):
        withincode( Object PluginParameterExpressionEvaluator.evaluate( String ) )
        && args( expression );

    before( MojoBinding binding,
            MavenProject project,
            String expression,
            ExpressionEvaluationException err ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && cflow( ppee_evaluate( expression ) )
        && execution( ExpressionEvaluationException.new( String ) )
        && this( err )
    {
        getReporter().reportUseOfBannedMojoParameter( currentParameter,
                                                      binding,
                                                      project,
                                                      expression,
                                                      (String) PluginParameterExpressionEvaluator.BANNED_EXPRESSIONS.get( expression ),
                                                      err );
    }

    after( MojoBinding binding,
           MavenProject project,
           String expression) throwing ( Exception cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && cflow( pm_checkRequiredParameters() )
        && cflow( ppee_evaluate( expression ) )
        && within( PluginParameterExpressionEvaluator )
        && call( Object ReflectionValueExtractor.evaluate( String, Object ) )
    {
        getReporter().reportReflectionErrorWhileEvaluatingMojoParameter( currentParameter,
                                                                         binding,
                                                                         project,
                                                                         expression,
                                                                         cause );
    }

    after( MojoBinding binding,
           MavenProject project,
           PlexusConfiguration config) throwing( PluginConfigurationException cause ):
        cflow( le_executeGoalAndHandleFailures( binding ) )
        && cflow( pm_executeMojo( project ) )
        && execution( void DefaultPluginManager.populatePluginFields( *, *, PlexusConfiguration, .. ) )
        && args( *, *, config, .. )
    {
        getReporter().reportErrorApplyingMojoConfiguration( binding, project, config, cause );
    }

    private pointcut pm_resolveTransitiveDependencies( MavenProject project,
                                                       String scope ):
        execution( void DefaultPluginManager.resolveTransitiveDependencies( *, *, String, *, MavenProject ) )
        && args( *, *, scope, *, project );

    after( MavenProject project,
           String scope) throwing( ArtifactNotFoundException cause ):
        pm_resolveTransitiveDependencies( project, scope )
    {
        getReporter().reportProjectDependenciesNotFound( project, scope, cause );
    }

    after( MavenProject project,
           String scope) throwing( ArtifactResolutionException cause ):
        pm_resolveTransitiveDependencies( project, scope )
    {
        if ( cause instanceof MultipleArtifactsNotFoundException )
        {
            getReporter().reportProjectDependenciesNotFound( project,
                                                             scope,
                                                             (MultipleArtifactsNotFoundException) cause );
        }
        else
        {
            getReporter().reportProjectDependenciesUnresolvable( project, scope, cause );
        }
    }

    private pointcut le_getLifecycleBindings( List tasks,
                                              MavenProject configuringProject,
                                              String targetDescription ):
        execution( List DefaultLifecycleExecutor.getLifecycleBindings( List, MavenProject, *, String ) )
        && args( tasks, configuringProject, *, targetDescription );

    BuildPlan around( List tasks,
                      MavenProject project,
                      MavenSession session )
        throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException:
            cflow( execution( * DefaultLifecycleExecutor.*( .. ) ) )
            && execution( BuildPlan BuildPlanner+.constructBuildPlan( List, MavenProject, MavenSession, * ) )
            && args( tasks, project, session, * )
    {
        try
        {
            return proceed( tasks, project, session );
        }
        catch ( LifecycleLoaderException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
        catch ( LifecyclePlannerException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
        catch ( LifecycleSpecificationException cause )
        {
            getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
            throw cause;
        }
    }

}


change access method for LaunchImpl.jobInstance = > use getter...

/*
 *     ParallelJ, framework for parallel computing
 *
 *     Copyright (C) 2010, 2011, 2012 Atos Worldline or third-party contributors as
 *     indicated by the @author tags or express copyright attribution
 *     statements applied by the authors.
 *
 *     This library is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public
 *     License as published by the Free Software Foundation; either
 *     version 2.1 of the License.
 *
 *     This library is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public
 *     License along with this library; if not, write to the Free Software
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.parallelj.launching.internal;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;

import org.parallelj.Programs;
import org.parallelj.internal.conf.ConfigurationService;
import org.parallelj.internal.conf.ParalleljConfigurationManager;
import org.parallelj.internal.conf.pojos.CExecutor;
import org.parallelj.internal.conf.pojos.CExecutors;
import org.parallelj.internal.conf.pojos.ParalleljConfiguration;
import org.parallelj.internal.kernel.KProcessor;
import org.parallelj.internal.kernel.procedure.CallableProcedure.CallableCall.CallableCallRunnable;
import org.parallelj.internal.kernel.procedure.RunnableProcedure.RunnableCall.RunnableCallRunnable;
import org.parallelj.internal.kernel.procedure.SubProcessProcedure.SubProcessCall.SubProcessRunnable;
import org.parallelj.internal.reflect.ProcessHelperImpl;
import org.parallelj.internal.reflect.ProgramAdapter.Adapter;
import org.parallelj.launching.Launch;
import org.parallelj.launching.LaunchException;
import org.parallelj.launching.LaunchingMessageKind;
import org.parallelj.launching.ProgramReturnCodes;
import org.parallelj.mirror.ExecutorServiceKind;
import org.parallelj.mirror.ParallelJThreadFactory;

/**
 * Implements the synchLaunch(..) and aSynchLaunch(..) methods of Launch.
 *
 *
 */
privileged aspect LaunchManagement {

	private static Map<KProcessor, LaunchImpl> phl = new ConcurrentHashMap<>();

	static privileged public aspect LaunchAdapter percflow(launchInstance() ) {

		declare precedence :
			org.parallelj.internal.kernel.Identifiers,
			org.parallelj.internal.reflect.ProgramAdapter,
			org.parallelj.internal.util.sm.impl.KStateMachines,
			org.parallelj.internal.util.sm.impl.KStateMachines.PerMachine,
			org.parallelj.Executables$PerExecutable,
			org.parallelj.internal.reflect.ProgramAdapter.PerProgram,
			org.parallelj.internal.log.Logs;

		pointcut launchInstance() : execution(* Launch+.*(..));

		interface IKProcessorLaunch {}
		LaunchImpl IKProcessorLaunch.launch;
		declare parents: KProcessor implements IKProcessorLaunch;

		interface ILaunchExecutors {}
		Map<String, ExecutorService> ILaunchExecutors.executors = new ConcurrentHashMap<>();
		ExecutorService ILaunchExecutors.defaultExecutor = null;
		declare parents: LaunchImpl implements ILaunchExecutors;

		private LaunchingObservable observable = new LaunchingObservable();

		boolean stopExecutorServiceAfterExecution = false;

		private static class AsyncThread implements Runnable {

			private LaunchAdapter launchAdapter;
			private LaunchImpl<?> launch;

			public AsyncThread(LaunchImpl<?> launch, LaunchAdapter launchAdapter) {
				this.launch = launch;
				this.launchAdapter = launchAdapter;
			}

			@Override
			public void run() {
				this.launchAdapter.internalSyncLaunch(this.launch);
			}
		}

		@SuppressWarnings({ "rawtypes", "unchecked" })
		Launch around(LaunchImpl launch) throws LaunchException:
					execution(public Launch Launch+.synchLaunch(..) throws LaunchException)
						&& this(launch) {
			proceed(launch);
			launch.processHelper = Programs.as(launch.getJobInstance());
			launch.getLaunchResult().setStatusCode(ProgramReturnCodes.RUNNING);
			this.observable.prepareLaunching(launch);

			return internalSyncLaunch(launch);
		}

		@SuppressWarnings({ "rawtypes", "unchecked" })
		Launch around(LaunchImpl launch) throws LaunchException:
					execution(public Launch Launch+.aSynchLaunch() throws LaunchException)
						&& this(launch) {
			proceed(launch);
			launch.processHelper = Programs.as(launch.getJobInstance());
			launch.getLaunchResult().setStatusCode(ProgramReturnCodes.RUNNING);
			this.observable.prepareLaunching(launch);
			if (launch.getExecutorService()!=null) {
				launch.getExecutorService().execute(new AsyncThread(launch, this));
			} else {
				ParallelJThreadFactory.getInstance().newThread(new AsyncThread(launch, this)).start();
	 		}
			return launch;
		}

		@SuppressWarnings("rawtypes")
		private Launch<?> internalSyncLaunch(LaunchImpl<?> launch) {
			LaunchingMessageKind.ILAUNCH0002.format(launch.getJobInstance()
					.getClass().getCanonicalName(), launch.getLaunchId());
			initializeExecutors(launch);
			ProcessHelperImpl processHelper = (ProcessHelperImpl)launch.getProcessHelper();
			KProcessor processor = processHelper.processor;
			if (processor == null) {
				if ( ((ILaunchExecutors)launch).defaultExecutor!=null) {
					processor = new KProcessor(((ILaunchExecutors)launch).defaultExecutor);
				} else {
					processor = new KProcessor(launch.getExecutorService());
				}
				((IKProcessorLaunch)processor).launch = launch;
				phl.put(processor, launch);
			}
			processor.execute(processHelper.process);
			launch.getProcessHelper().join();
			this.observable.finalizeLaunching(launch);
			launch.complete();
			cleanExecutors(launch);
			phl.remove(processor);

			if (launch.getLaunchResult().getStatusCode()!=ProgramReturnCodes.FAILURE
					&&launch.getLaunchResult().getStatusCode()!=ProgramReturnCodes.ABORTED) {
				launch.getLaunchResult().setStatusCode(ProgramReturnCodes.SUCCESS);
			}
			LaunchingMessageKind.ILAUNCH0003.format(launch.getJobInstance()
					.getClass().getCanonicalName(), launch.getLaunchId(), launch
					.getLaunchResult().getStatusCode(), launch.getLaunchResult()
					.getReturnCode());
			return launch;
		}

		private void initializeExecutors(LaunchImpl<?> launch) {
			ParalleljConfiguration configuration = (ParalleljConfiguration) ConfigurationService
					.getConfigurationService().getConfigurationManager()
					.get(ParalleljConfigurationManager.class)
					.getConfiguration();
			Map<String, ExecutorService> executors = ((ILaunchExecutors) launch).executors;
			CExecutors cExecutors = configuration != null ? configuration
					.getExecutorServices() : null;
			if (cExecutors != null) {
				if (cExecutors.getDefaultServiceType() != null
						|| cExecutors.getDefaultPoolSize() != null
						|| cExecutors.getDefaultServiceClass() != null) {
					try {
						int size = cExecutors.getDefaultPoolSize() != null ? cExecutors.getDefaultPoolSize().intValue() : 0;
						ExecutorService defaultService = ExecutorServiceKind
								.valueOf(
										cExecutors.getDefaultServiceType()
												.value()).create(
										size,
										cExecutors.getDefaultServiceClass());
						((ILaunchExecutors) launch).defaultExecutor = defaultService;
					} catch (Exception e) {
						LaunchingMessageKind.ELAUNCH0011.format(e);
					}
				}
				if (cExecutors.getExecutorService() != null) {
					for (CExecutor cExecutor : cExecutors.getExecutorService()) {
						String[] names = cExecutor.getProgramName().split(",");
						boolean instanciate = false;
						for (String name : names) {
							if (name.length() > 0 && name.trim().length() > 0) {
								instanciate = true;
							}
						}
						if (instanciate) {
							ExecutorService executor = null;
							if (cExecutor.getServiceType() != null) {
								String type = cExecutor.getServiceType()
										.value();
								try {
									int size = cExecutor.getPoolSize() != null ? cExecutor
											.getPoolSize().intValue() : 0;
									executor = ExecutorServiceKind
											.valueOf(type)
											.create(size,
													cExecutor.getServiceClass());
									boolean foundProgram = false;
									for (String name : names) {
										if (name.length() > 0 && name.trim().length() > 0) {
											executors.put(
													name,
													executor);
											foundProgram = true;
										}
									}
									if (!foundProgram) {
										executor.shutdown();
									}
								} catch (Exception e) {
									LaunchingMessageKind.ELAUNCH0012.format(e);
								}
							}
						}
					}
				}
			}
		}

		private void cleanExecutors(LaunchImpl<?> launch) {
			Map<String, ExecutorService> executors = ((ILaunchExecutors)launch).executors;
			for (String key : executors.keySet()) {
				executors.get(key).shutdown();
				executors.remove(key);
			}
			if (((ILaunchExecutors)launch).defaultExecutor!=null) {
				((ILaunchExecutors)launch).defaultExecutor.shutdown();
			}
		}
	}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, SubProcessRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor){

		Adapter context = (Adapter)runnable.getSubProcessCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, CallableCallRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor){

		Adapter context = (Adapter)runnable.getCallableCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
	}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, RunnableCallRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor) {

		Adapter context = (Adapter)runnable.getRunnableCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
	}
}

/*
 *     ParallelJ, framework for parallel computing
 *
 *     Copyright (C) 2010, 2011, 2012 Atos Worldline or third-party contributors as
 *     indicated by the @author tags or express copyright attribution
 *     statements applied by the authors.
 *
 *     This library is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public
 *     License as published by the Free Software Foundation; either
 *     version 2.1 of the License.
 *
 *     This library is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public
 *     License along with this library; if not, write to the Free Software
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.parallelj.launching.internal;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;

import org.parallelj.Programs;
import org.parallelj.internal.conf.ConfigurationService;
import org.parallelj.internal.conf.ParalleljConfigurationManager;
import org.parallelj.internal.conf.pojos.CExecutor;
import org.parallelj.internal.conf.pojos.CExecutors;
import org.parallelj.internal.conf.pojos.ParalleljConfiguration;
import org.parallelj.internal.kernel.KProcessor;
import org.parallelj.internal.kernel.procedure.CallableProcedure.CallableCall.CallableCallRunnable;
import org.parallelj.internal.kernel.procedure.RunnableProcedure.RunnableCall.RunnableCallRunnable;
import org.parallelj.internal.kernel.procedure.SubProcessProcedure.SubProcessCall.SubProcessRunnable;
import org.parallelj.internal.reflect.ProcessHelperImpl;
import org.parallelj.internal.reflect.ProgramAdapter.Adapter;
import org.parallelj.launching.Launch;
import org.parallelj.launching.LaunchException;
import org.parallelj.launching.LaunchingMessageKind;
import org.parallelj.launching.ProgramReturnCodes;
import org.parallelj.mirror.ExecutorServiceKind;
import org.parallelj.mirror.ParallelJThreadFactory;

/**
 * Implements the synchLaunch(..) and aSynchLaunch(..) methods of Launch.
 *
 *
 */
privileged aspect LaunchManagement {

	private static Map<KProcessor, LaunchImpl> phl = new ConcurrentHashMap<>();

	static privileged public aspect LaunchAdapter percflow(launchInstance() ) {

		declare precedence :
			org.parallelj.internal.kernel.Identifiers,
			org.parallelj.internal.reflect.ProgramAdapter,
			org.parallelj.internal.util.sm.impl.KStateMachines,
			org.parallelj.internal.util.sm.impl.KStateMachines.PerMachine,
			org.parallelj.Executables$PerExecutable,
			org.parallelj.internal.reflect.ProgramAdapter.PerProgram,
			org.parallelj.internal.log.Logs;

		pointcut launchInstance() : execution(* Launch+.*(..));

		interface IKProcessorLaunch {}
		LaunchImpl IKProcessorLaunch.launch;
		declare parents: KProcessor implements IKProcessorLaunch;

		interface ILaunchExecutors {}
		Map<String, ExecutorService> ILaunchExecutors.executors = new ConcurrentHashMap<>();
		ExecutorService ILaunchExecutors.defaultExecutor = null;
		declare parents: LaunchImpl implements ILaunchExecutors;

		private LaunchingObservable observable = new LaunchingObservable();

		boolean stopExecutorServiceAfterExecution = false;

		private static class AsyncThread implements Runnable {

			private LaunchAdapter launchAdapter;
			private LaunchImpl<?> launch;

			public AsyncThread(LaunchImpl<?> launch, LaunchAdapter launchAdapter) {
				this.launch = launch;
				this.launchAdapter = launchAdapter;
			}

			@Override
			public void run() {
				this.launchAdapter.internalSyncLaunch(this.launch);
			}
		}

		@SuppressWarnings({ "rawtypes", "unchecked" })
		Launch around(LaunchImpl launch) throws LaunchException:
					execution(public Launch Launch+.synchLaunch(..) throws LaunchException)
						&& this(launch) {
			proceed(launch);
			launch.processHelper = Programs.as(launch.jobInstance);
			launch.getLaunchResult().setStatusCode(ProgramReturnCodes.RUNNING);
			this.observable.prepareLaunching(launch);

			return internalSyncLaunch(launch);
		}

		@SuppressWarnings({ "rawtypes", "unchecked" })
		Launch around(LaunchImpl launch) throws LaunchException:
					execution(public Launch Launch+.aSynchLaunch() throws LaunchException)
						&& this(launch) {
			proceed(launch);
			launch.processHelper = Programs.as(launch.getJobInstance());
			launch.getLaunchResult().setStatusCode(ProgramReturnCodes.RUNNING);
			this.observable.prepareLaunching(launch);
			if (launch.getExecutorService()!=null) {
				launch.getExecutorService().execute(new AsyncThread(launch, this));
			} else {
				ParallelJThreadFactory.getInstance().newThread(new AsyncThread(launch, this)).start();
	 		}
			return launch;
		}

		@SuppressWarnings("rawtypes")
		private Launch<?> internalSyncLaunch(LaunchImpl<?> launch) {
			LaunchingMessageKind.ILAUNCH0002.format(launch.getJobInstance()
					.getClass().getCanonicalName(), launch.getLaunchId());
			initializeExecutors(launch);
			ProcessHelperImpl processHelper = (ProcessHelperImpl)launch.getProcessHelper();
			KProcessor processor = processHelper.processor;
			if (processor == null) {
				if ( ((ILaunchExecutors)launch).defaultExecutor!=null) {
					processor = new KProcessor(((ILaunchExecutors)launch).defaultExecutor);
				} else {
					processor = new KProcessor(launch.getExecutorService());
				}
				((IKProcessorLaunch)processor).launch = launch;
				phl.put(processor, launch);
			}
			processor.execute(processHelper.process);
			launch.getProcessHelper().join();
			this.observable.finalizeLaunching(launch);
			launch.complete();
			cleanExecutors(launch);
			phl.remove(processor);

			if (launch.getLaunchResult().getStatusCode()!=ProgramReturnCodes.FAILURE
					&&launch.getLaunchResult().getStatusCode()!=ProgramReturnCodes.ABORTED) {
				launch.getLaunchResult().setStatusCode(ProgramReturnCodes.SUCCESS);
			}
			LaunchingMessageKind.ILAUNCH0003.format(launch.getJobInstance()
					.getClass().getCanonicalName(), launch.getLaunchId(), launch
					.getLaunchResult().getStatusCode(), launch.getLaunchResult()
					.getReturnCode());
			return launch;
		}

		private void initializeExecutors(LaunchImpl<?> launch) {
			ParalleljConfiguration configuration = (ParalleljConfiguration) ConfigurationService
					.getConfigurationService().getConfigurationManager()
					.get(ParalleljConfigurationManager.class)
					.getConfiguration();
			Map<String, ExecutorService> executors = ((ILaunchExecutors) launch).executors;
			CExecutors cExecutors = configuration != null ? configuration
					.getExecutorServices() : null;
			if (cExecutors != null) {
				if (cExecutors.getDefaultServiceType() != null
						|| cExecutors.getDefaultPoolSize() != null
						|| cExecutors.getDefaultServiceClass() != null) {
					try {
						int size = cExecutors.getDefaultPoolSize() != null ? cExecutors.getDefaultPoolSize().intValue() : 0;
						ExecutorService defaultService = ExecutorServiceKind
								.valueOf(
										cExecutors.getDefaultServiceType()
												.value()).create(
										size,
										cExecutors.getDefaultServiceClass());
						((ILaunchExecutors) launch).defaultExecutor = defaultService;
					} catch (Exception e) {
						LaunchingMessageKind.ELAUNCH0011.format(e);
					}
				}
				if (cExecutors.getExecutorService() != null) {
					for (CExecutor cExecutor : cExecutors.getExecutorService()) {
						String[] names = cExecutor.getProgramName().split(",");
						boolean instanciate = false;
						for (String name : names) {
							if (name.length() > 0 && name.trim().length() > 0) {
								instanciate = true;
							}
						}
						if (instanciate) {
							ExecutorService executor = null;
							if (cExecutor.getServiceType() != null) {
								String type = cExecutor.getServiceType()
										.value();
								try {
									int size = cExecutor.getPoolSize() != null ? cExecutor
											.getPoolSize().intValue() : 0;
									executor = ExecutorServiceKind
											.valueOf(type)
											.create(size,
													cExecutor.getServiceClass());
									boolean foundProgram = false;
									for (String name : names) {
										if (name.length() > 0 && name.trim().length() > 0) {
											executors.put(
													name,
													executor);
											foundProgram = true;
										}
									}
									if (!foundProgram) {
										executor.shutdown();
									}
								} catch (Exception e) {
									LaunchingMessageKind.ELAUNCH0012.format(e);
								}
							}
						}
					}
				}
			}
		}

		private void cleanExecutors(LaunchImpl<?> launch) {
			Map<String, ExecutorService> executors = ((ILaunchExecutors)launch).executors;
			for (String key : executors.keySet()) {
				executors.get(key).shutdown();
				executors.remove(key);
			}
			if (((ILaunchExecutors)launch).defaultExecutor!=null) {
				((ILaunchExecutors)launch).defaultExecutor.shutdown();
			}
		}
	}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, SubProcessRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor){

		Adapter context = (Adapter)runnable.getSubProcessCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, CallableCallRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor){

		Adapter context = (Adapter)runnable.getCallableCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
	}

	@SuppressWarnings("rawtypes")
	void around(KProcessor kProcessor, RunnableCallRunnable runnable):execution(public void submit(..))
		&& args(runnable)
		&&this(kProcessor) {

		Adapter context = (Adapter)runnable.getRunnableCall().getProcess().getContext();
		LaunchImpl launch = phl.get(kProcessor);
		if (launch!=null) {
			ExecutorService service = launch.executors.get(context.getClass().getCanonicalName());
			if (service!=null) {
				kProcessor.submit(runnable, service);
			} else {
				proceed(kProcessor, runnable);
			}
		} else {
			proceed(kProcessor, runnable);
		}
	}
}


Fix problem caused by Spring's ConfigurableDeserializationSupport marker interface being package-private.

/*
 * Copyright (C) 2011 Archie L. Cobbs and other authors. All rights reserved.
 *
 * $Id: SpringContextApplication.java 160 2011-10-24 18:00:49Z archie.cobbs $
 */

package org.dellroad.stuff.vaadin;

import java.io.ObjectStreamException;
import java.io.Serializable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.ConfigurableObject;

/**
 * Aspect that autowires classes marked with the Spring's {@link Configurable @Configurable} annotation to a
 * {@link SpringContextApplication} application context.
 *
 *

 * This aspect does the same thing that Spring's {@code AnnotationBeanConfigurerAspect} aspect does,
 * except that this aspect configures beans using the application context associated with the current
 * {@link SpringContextApplication} Vaadin application rather than the one associated with the overall
 * servlet context (i.e., its parent).
 *

 *
 *

 * As a result, objects so annotated will be configured for their specific {@link SpringContextApplication}
 * instance, and therefore can only be instantiated by threads associated with a current {@link SpringContextApplication}
 * (see {@link ContextApplication#get}). This will be the case when executing within a {@link SpringContextApplication}
 * Vaadin application HTTP request or an invocation of {@link ContextApplication#invoke} on same.
 *

 *
 *

 * This implementation is derived from Spring's {@code AnnotationBeanConfigurerAspect} implementation
 * and therefore shares its license (also Apache).
 *

 *
 * @see SpringContextApplication
 * @see ContextApplication#get
 * @see Configurable
 */
public aspect VaadinConfigurableAspect extends AbstractDependencyInjectionAspect {

// Stuff copied from AbstractInterfaceDrivenDependencyInjectionAspect.aj

    public pointcut beanConstruction(Object bean) :
        initialization(ConfigurableObject+.new(..)) && this(bean);

    public pointcut beanDeserialization(Object bean) :
        execution(Object ConfigurableDeserializationSupport+.readResolve()) &&
        this(bean);

    public pointcut leastSpecificSuperTypeConstruction() : initialization(ConfigurableObject.new(..));

    static interface ConfigurableDeserializationSupport extends Serializable {
    }

    public Object ConfigurableDeserializationSupport.readResolve() throws ObjectStreamException {
        return this;
    }

// Stuff copied from AnnotationBeanConfigurerAspect.aj

    public pointcut inConfigurableBean() : @this(Configurable);

    public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*);

    declare parents: @Configurable * implements ConfigurableObject;

    private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction());

	declare parents: @Configurable Serializable+ implements ConfigurableDeserializationSupport;

// Our implementation

    @Override
    public void configureBean(Object bean) {
        SpringContextApplication.get().configureBean(bean);
    }
}

/*
 * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.
 *
 * $Id: SpringContextApplication.java 160 2011-10-24 18:00:49Z archie.cobbs $
 */

package org.dellroad.stuff.vaadin;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractInterfaceDrivenDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.ConfigurableObject;

/**
 * Aspect that autowires classes marked with the Spring's {@link Configurable @Configurable} annotation to a
 * {@link SpringContextApplication} application context.
 *
 *

 * This aspect does the same thing that Spring's {@code AnnotationBeanConfigurerAspect} aspect does,
 * except that this aspect configures beans using the application context associated with the current
 * {@link SpringContextApplication} Vaadin application rather than the one associated with the overall
 * servlet context (i.e., its parent).
 *

 *
 *

 * As a result, objects so annotated will be configured for their specific {@link SpringContextApplication}
 * instance, and therefore can only be instantiated by threads associated with a current {@link SpringContextApplication}
 * (see {@link ContextApplication#get}). This will be the case when executing within a {@link SpringContextApplication}
 * Vaadin application HTTP request or an invocation of {@link ContextApplication#invoke} on same.
 *

 *
 *

 * This implementation is derived from Spring's {@code AnnotationBeanConfigurerAspect} implementation
 * and therefore shares its license (also Apache).
 *

 *
 * @see SpringContextApplication
 * @see ContextApplication#get
 * @see Configurable
 */
public aspect VaadinConfigurableAspect extends AbstractInterfaceDrivenDependencyInjectionAspect {

	public pointcut inConfigurableBean() : @this(Configurable);

	public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*);

	declare parents: @Configurable * implements ConfigurableObject;

    @Override
	public void configureBean(Object bean) {
        SpringContextApplication.get().configureBean(bean);
    }

	private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction());
}


Small extension to test case.

Small extension to test case.

package cl.pleiad.ajlmp.testITD;

public aspect FirstAspect {
	before(): execution(* BaseClass.*1(..)) {
		BaseClass base = ((BaseClass)thisJoinPoint.getTarget());
		System.out.println("FirstAspect-BeforeCall-1");
		base.itdA();
	}

	public void BaseClass.itdA(){
		System.out.println("FirstAspect-ITD");
	}

	void around(BaseClass base): execution(* Base*.*1(..)) && target(base){
		System.out.println("FirstAspect-BeforeCall-1");
		base.itdC();
	}
	public void BaseClass.itdC(){
		System.out.println("FirstAspect-ITD2");
	}
}

package cl.pleiad.ajlmp.testITD;

public aspect FirstAspect {
	before(): execution(* BaseClass.*1(..)) {
		BaseClass base = ((BaseClass)thisJoinPoint.getTarget());
		System.out.println("FirstAspect-BeforeCall-1");
		base.itdA();
	}

	public void BaseClass.itdA(){
		System.out.println("FirstAspect-ITD");
	}

}


Suppress save action clean ups other than code formatting (cherry picked from c135a51217511084c56f4b892604d25a6eb4f5fa)

/*
 * Copyright 2005-2010 LAMP/EPFL
 */
// $Id$

package scala.tools.eclipse.contribution.weaving.jdt.ui.javaeditor.formatter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring;
import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.CleanUpChange;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.corext.fix.CodeFormatFix;
import org.eclipse.jdt.internal.ui.fix.CodeFormatCleanUp;
import org.eclipse.jdt.ui.cleanup.CleanUpContext;
import org.eclipse.jdt.ui.cleanup.ICleanUp;
import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
import org.eclipse.jface.text.IRegion;

@SuppressWarnings("restriction")
public privileged aspect FormatterCleanUpRegistryAspect {

	pointcut calculateChange(CleanUpContext cleanUpContext, ICleanUp[] cleanUps, List undoneCleanUps, HashSet slowCleanUps) :
		args(cleanUpContext, cleanUps, undoneCleanUps, slowCleanUps) &&
	   execution(CleanUpChange CleanUpRefactoring.calculateChange(CleanUpContext, ICleanUp[] , List , HashSet ));

	pointcut createCleanUp(ICompilationUnit cu, IRegion[] regions,
			boolean format, boolean removeTrailingWhitespacesAll,
			boolean removeTrailingWhitespacesIgnorEmpty,
			boolean correctIndentation) :
	 args(cu, regions, format, removeTrailingWhitespacesAll, removeTrailingWhitespacesIgnorEmpty, correctIndentation) &&
	 execution(ICleanUpFix CodeFormatFix.createCleanUp(ICompilationUnit , IRegion[] , boolean , boolean , boolean , boolean ));

	ICleanUpFix around(ICompilationUnit cu, IRegion[] regions, boolean format,
			boolean removeTrailingWhitespacesAll,
			boolean removeTrailingWhitespacesIgnorEmpty,
			boolean correctIndentation) :
				createCleanUp(cu, regions, format, removeTrailingWhitespacesAll, removeTrailingWhitespacesIgnorEmpty, correctIndentation) {
		if ("scala".equals(cu.getResource().getFileExtension()))
			if (format)
				for (IFormatterCleanUpProvider provider : FormatterCleanUpRegistry
					.getInstance().getProviders())
				return provider.createCleanUp(cu);
		return proceed(cu, regions, format, removeTrailingWhitespacesAll, removeTrailingWhitespacesIgnorEmpty, correctIndentation);
	}

	// Filter out CleanUps that aren't yet Scala compatible:
	CleanUpChange around(CleanUpContext cleanUpContext, ICleanUp[] cleanUps, List undoneCleanUps, HashSet slowCleanUps):
		calculateChange(cleanUpContext, cleanUps, undoneCleanUps, slowCleanUps) {
		ICleanUp[] newCleanUps;
		if ("scala".equals(cleanUpContext.getCompilationUnit().getResource().getFileExtension())) {
    		List<ICleanUp> newCleanUpList = new ArrayList<ICleanUp>();
	    	for (ICleanUp cleanUp : cleanUps)
		    	if (cleanUp instanceof CodeFormatCleanUp)
			    	newCleanUpList.add(cleanUp);
		    newCleanUps = (ICleanUp[]) newCleanUpList.toArray(new ICleanUp[newCleanUpList.size()]);
		} else
			newCleanUps = cleanUps;
		return proceed(cleanUpContext, newCleanUps, undoneCleanUps, slowCleanUps);
	}

}

/*
 * Copyright 2005-2010 LAMP/EPFL
 */
// $Id$

package scala.tools.eclipse.contribution.weaving.jdt.ui.javaeditor.formatter;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.corext.fix.CodeFormatFix;
import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
import org.eclipse.jface.text.IRegion;

@SuppressWarnings("restriction")
public privileged aspect FormatterCleanUpRegistryAspect {

	pointcut createCleanUp(ICompilationUnit cu, IRegion[] regions,
			boolean format, boolean removeTrailingWhitespacesAll,
			boolean removeTrailingWhitespacesIgnorEmpty,
			boolean correctIndentation) :
	 args(cu, regions, format, removeTrailingWhitespacesAll, removeTrailingWhitespacesIgnorEmpty, correctIndentation) &&
	 execution(ICleanUpFix CodeFormatFix.createCleanUp(ICompilationUnit , IRegion[] , boolean , boolean , boolean , boolean ));

	ICleanUpFix around(ICompilationUnit cu, IRegion[] regions, boolean format,
			boolean removeTrailingWhitespacesAll,
			boolean removeTrailingWhitespacesIgnorEmpty,
			boolean correctIndentation) :
				createCleanUp(cu, regions, format, removeTrailingWhitespacesAll, removeTrailingWhitespacesIgnorEmpty, correctIndentation) {
		if ("scala".equals(cu.getResource().getFileExtension()))
			if (format)
				for (IFormatterCleanUpProvider provider : FormatterCleanUpRegistry
					.getInstance().getProviders())
					return provider.createCleanUp(cu);
				else
					return null;
		return proceed(cu, regions, format, removeTrailingWhitespacesAll,
				removeTrailingWhitespacesIgnorEmpty, correctIndentation);
	}

}


[minor] Add missing closing parenthesis in some javadoc

/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package compatibility.com.xpn.xwiki.api;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.xpn.xwiki.api.Util;
import com.xpn.xwiki.web.Utils;

/**
 * Add a backward compatibility layer to the {@link Util} class.
 *
 * @version $Id$
 */
public privileged aspect UtilCompatibilityAspect
{
    /**
     * Creates a {@link HashMap}, a generic map implementation optimized for performance. This is useful from Velocity
     * since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link HashMap} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.map} ({@link org.xwiki.velocity.tools.CollectionsTool#getMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getHashMap()
    {
        return new HashMap<T, U>();
    }

    /**
     * Creates a {@link TreeMap}, a map implementation which always maintains the natural order of the elements. This is
     * useful from Velocity since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link TreeMap} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.sortedMap}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getSortedMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getTreeMap()
    {
        return new TreeMap<T, U>();
    }

    /**
     * Creates a {@link LinkedHashMap}, a map implementation which preserves the order of insertion. This is useful from
     * Velocity since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link LinkedHashMap} object
     * @since 2.2 Milestone 1
     * @deprecated use {@code $collectionstool.orderedMap}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getOrderedMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getLinkedHashMap()
    {
        return new LinkedHashMap<T, U>();
    }

    /**
     * Creates an {@link ArrayList}. This is useful from Velocity since new objects cannot be created.
     *
     * @param T the type of the elements in the list
     * @return an {@link ArrayList} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.arrayList}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getArrayList()})
     */
    @Deprecated
    public <T> List<T> Util.getArrayList()
    {
        return new ArrayList<T>();
    }

    /**
     * Reverse the order of the elements within a list, so that the last element is moved to the beginning of the list,
     * the next-to-last element to the second position, and so on. This is useful from Velocity since classes and their
     * static methods cannot be accessed.
     *
     * @param list the list to reverse
     * @return the reversed list
     * @since 1.4 Milestone 1
     * @deprecated use {@code $collectionstool.reverse($list}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#reverse(List)})
     */
    @Deprecated
    public <T> List<T> Util.reverseList(List<T> list)
    {
        Collections.reverse(list);
        return list;
    }

    /**
     * Sort a list using a standard comparator. Elements need to be mutually comparable and implement the Comparable
     * interface. This is useful from Velocity since classes and their static methods cannot be accessed.
     *
     * @param list the list to sort
     * @return the sorted list (as the same object reference)
     * @see {@link java.util.Collections#sort(java.util.List)}
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.sort($list} ({@link org.xwiki.velocity.tools.CollectionsTool#sort(List)})
     */
    @Deprecated
    public <T extends Comparable<T>> List<T> Util.sort(List<T> list)
    {
        Collections.sort(list);
        return list;
    }

    /**
     * Split a text into an array of texts, according to a list of separator characters.
     *
     * @param text the original text
     * @param separator the separator characters
     * @return an array containing the resulting text fragments
     * @since 1.3 Milestone 2
     * @deprecated use {@code $stringtool.split($string, $separators)}
     *             ({@link org.apache.commons.lang3.StringUtils#split(String, String)})
     */
    @Deprecated
    public String[] Util.split(String text, String separator)
    {
        return this.xwiki.split(text, separator);
    }

    /**
     * Convert an Object to a number and return {@code null} if the object is not a Number.
     *
     * @param object the object to convert
     * @return the object as a {@link Number}, or {@code null}
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toNumber($string)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toNumber(Object)})
     */
    @Deprecated
    public Number Util.toNumber(java.lang.Object object)
    {
        try {
            return new Long(object.toString());
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code long}.
     *
     * @param str the String to convert to a long
     * @return the parsed long or zero if the string is not a valid long number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toNumber($string).longValue()}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toNumber(Object)})
     */
    @Deprecated
    public long Util.parseLong(String str)
    {
        try {
            return Long.parseLong(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code int}.
     *
     * @param str the String to convert to an integer
     * @return the parsed integer or zero if the string is not a valid integer number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toInteger($string)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toInteger(Object)})
     */
    @Deprecated
    public int Util.parseInt(String str)
    {
        try {
            return Integer.parseInt(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to an {@code Integer} object.
     *
     * @param str the String to convert to an Integer Object
     * @return the parsed integer or zero if the string is not a valid integer number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toInteger($string)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toInteger(Object)})
     */
    @Deprecated
    public Integer Util.parseInteger(String str)
    {
        return Integer.valueOf(parseInt(str));
    }

    /**
     * Convert a {@code String} to a primitive {@code float}.
     *
     * @param str the String to convert to a float
     * @return the parsed float or zero if the string is not a valid float number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toDouble($string).floatValue()}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toDouble(Object)})
     */
    @Deprecated
    public float Util.parseFloat(String str)
    {
        try {
            return Float.parseFloat(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code double}.
     *
     * @param str the String to convert to a double
     * @return the parsed double or zero if the string is not a valid double number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toDouble($string)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toDouble(Object)})
     */
    @Deprecated
    public double Util.parseDouble(String str)
    {
        try {
            return Double.parseDouble(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Escape text so that it can be used in a HQL/SQL query, in a like clause or in a test for equality clause. For
     * example it escapes single quote characters.
     *
     * @param text the text to escape
     * @return filtered text
     * @since 1.3 Milestone 2
     * @deprecated values should be passed as positional parameters, not concatenated in the query; see
     *             {@link XWiki#searchDocuments(String, List)}; if escaping SQL is really needed, use {@code
     *             $escapetool.sql($string)} ({@link org.xwiki.velocity.tools.EscapeTool#sql(Object)})
     */
    @Deprecated
    public String Util.escapeSQL(String text)
    {
        return Utils.SQLFilter(text);
    }

    /**
     * Add two integer numbers. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a the first number to add
     * @param b the second number to add
     * @return the sum of the two parameters
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add($n1, $n2)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#add(Object, Object)})
     */
    @Deprecated
    public int Util.add(int a, int b)
    {
        return a + b;
    }

    /**
     * Add two long numbers. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a the first number to add
     * @param b the second number to add
     * @return the sum of the two parameters
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add($n1, $n2)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#add(Object, Object)})
     */
    @Deprecated
    public long Util.add(long a, long b)
    {
        return a + b;
    }

    /**
     * Add two numbers, specified as strings. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a a string representing a number to add
     * @param b a string representing a number to add
     * @return the sum of the two parameters, as a String
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add} and {@code $mathtool.toNumber} to get the same result
     */
    @Deprecated
    public String Util.add(String a, String b)
    {
        long c = Long.parseLong(a) + Long.parseLong(b);
        return "" + c;
    }

    /**
     * Protect Text from Wiki transformation. This method is useful for preventing content generated with Velocity from
     * being interpreted in the xwiki/1.0 rendering engine, and should not be used in xwiki/2.0 code. The result is
     * valid only in HTML or XML documents.
     *
     * @param text the text to escape
     * @return the escaped text
     * @since 1.3 Milestone 2
     * @deprecated this method only works for {@code xwiki/1.0} wiki syntax, and it doesn't even escape all the syntax
     */
    @Deprecated
    public String Util.escapeText(String text)
    {
        return com.xpn.xwiki.util.Util.escapeText(text);
    }

    /**
     * Protect URLs from Wiki transformation. This method is useful for preventing content generated with Velocity from
     * being interpreted in the xwiki/1.0 rendering engine, and should not be used in xwiki/2.0 code. The result is
     * valid only in HTML or XML documents.
     *
     * @param url the url to escape
     * @return the encoded URL, which can be used in the HTML output
     * @since 1.3 Milestone 2
     * @deprecated this method only works for {@code xwiki/1.0} wiki syntax when outputting HTML
     */
    @Deprecated
    public String Util.escapeURL(String url)
    {
        return com.xpn.xwiki.util.Util.escapeURL(url);
    }

    /**
     * Translates a string into application/x-www-form-urlencoded format, so that it can be safely used in
     * a query string as a parameter value.
     *
     * @param text the non encoded text
     * @return encoded text
     * @since 1.3 Milestone 2
     * @see #decodeURI(String)
     * @deprecated use {@code $escapetool.url($string)} ({@link org.xwiki.velocity.tools.EscapeTool#url(Object)})
     */
    @Deprecated
    public String Util.encodeURI(String text)
    {
        return com.xpn.xwiki.util.Util.encodeURI(text, this.context);
    }
}

/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package compatibility.com.xpn.xwiki.api;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.xpn.xwiki.api.Util;
import com.xpn.xwiki.web.Utils;

/**
 * Add a backward compatibility layer to the {@link Util} class.
 *
 * @version $Id$
 */
public privileged aspect UtilCompatibilityAspect
{
    /**
     * Creates a {@link HashMap}, a generic map implementation optimized for performance. This is useful from Velocity
     * since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link HashMap} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.map} ({@link org.xwiki.velocity.tools.CollectionsTool#getMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getHashMap()
    {
        return new HashMap<T, U>();
    }

    /**
     * Creates a {@link TreeMap}, a map implementation which always maintains the natural order of the elements. This is
     * useful from Velocity since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link TreeMap} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.sortedMap}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getSortedMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getTreeMap()
    {
        return new TreeMap<T, U>();
    }

    /**
     * Creates a {@link LinkedHashMap}, a map implementation which preserves the order of insertion. This is useful from
     * Velocity since new objects cannot be created.
     *
     * @param <T> the type of keys maintained by this map
     * @param  the type of mapped values
     * @return a {@link LinkedHashMap} object
     * @since 2.2 Milestone 1
     * @deprecated use {@code $collectionstool.orderedMap}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getOrderedMap()})
     */
    @Deprecated
    public <T, U> Map<T, U> Util.getLinkedHashMap()
    {
        return new LinkedHashMap<T, U>();
    }

    /**
     * Creates an {@link ArrayList}. This is useful from Velocity since new objects cannot be created.
     *
     * @param T the type of the elements in the list
     * @return an {@link ArrayList} object
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.arrayList}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#getArrayList()})
     */
    @Deprecated
    public <T> List<T> Util.getArrayList()
    {
        return new ArrayList<T>();
    }

    /**
     * Reverse the order of the elements within a list, so that the last element is moved to the beginning of the list,
     * the next-to-last element to the second position, and so on. This is useful from Velocity since classes and their
     * static methods cannot be accessed.
     *
     * @param list the list to reverse
     * @return the reversed list
     * @since 1.4 Milestone 1
     * @deprecated use {@code $collectionstool.reverse($list}
     *             ({@link org.xwiki.velocity.tools.CollectionsTool#reverse(List)})
     */
    @Deprecated
    public <T> List<T> Util.reverseList(List<T> list)
    {
        Collections.reverse(list);
        return list;
    }

    /**
     * Sort a list using a standard comparator. Elements need to be mutually comparable and implement the Comparable
     * interface. This is useful from Velocity since classes and their static methods cannot be accessed.
     *
     * @param list the list to sort
     * @return the sorted list (as the same object reference)
     * @see {@link java.util.Collections#sort(java.util.List)}
     * @since 1.3 Milestone 2
     * @deprecated use {@code $collectionstool.sort($list} ({@link org.xwiki.velocity.tools.CollectionsTool#sort(List)})
     */
    @Deprecated
    public <T extends Comparable<T>> List<T> Util.sort(List<T> list)
    {
        Collections.sort(list);
        return list;
    }

    /**
     * Split a text into an array of texts, according to a list of separator characters.
     *
     * @param text the original text
     * @param separator the separator characters
     * @return an array containing the resulting text fragments
     * @since 1.3 Milestone 2
     * @deprecated use {@code $stringtool.split($string, $separators)}
     *             ({@link org.apache.commons.lang3.StringUtils#split(String, String)})
     */
    @Deprecated
    public String[] Util.split(String text, String separator)
    {
        return this.xwiki.split(text, separator);
    }

    /**
     * Convert an Object to a number and return {@code null} if the object is not a Number.
     *
     * @param object the object to convert
     * @return the object as a {@link Number}, or {@code null}
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toNumber($string)}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toNumber(Object)})
     */
    @Deprecated
    public Number Util.toNumber(java.lang.Object object)
    {
        try {
            return new Long(object.toString());
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code long}.
     *
     * @param str the String to convert to a long
     * @return the parsed long or zero if the string is not a valid long number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toNumber($string).longValue()}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toNumber(Object)})
     */
    @Deprecated
    public long Util.parseLong(String str)
    {
        try {
            return Long.parseLong(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code int}.
     *
     * @param str the String to convert to an integer
     * @return the parsed integer or zero if the string is not a valid integer number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toInteger($string}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toInteger(Object)})
     */
    @Deprecated
    public int Util.parseInt(String str)
    {
        try {
            return Integer.parseInt(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to an {@code Integer} object.
     *
     * @param str the String to convert to an Integer Object
     * @return the parsed integer or zero if the string is not a valid integer number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toInteger($string}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toInteger(Object)})
     */
    @Deprecated
    public Integer Util.parseInteger(String str)
    {
        return Integer.valueOf(parseInt(str));
    }

    /**
     * Convert a {@code String} to a primitive {@code float}.
     *
     * @param str the String to convert to a float
     * @return the parsed float or zero if the string is not a valid float number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toDouble($string).floatValue()}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toDouble(Object)})
     */
    @Deprecated
    public float Util.parseFloat(String str)
    {
        try {
            return Float.parseFloat(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Convert a {@code String} to a primitive {@code double}.
     *
     * @param str the String to convert to a double
     * @return the parsed double or zero if the string is not a valid double number
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.toDouble($string}
     *             ({@link org.apache.velocity.tools.generic.MathTool#toDouble(Object)})
     */
    @Deprecated
    public double Util.parseDouble(String str)
    {
        try {
            return Double.parseDouble(str);
        } catch (Exception e) {
            return 0;
        }
    }

    /**
     * Escape text so that it can be used in a HQL/SQL query, in a like clause or in a test for equality clause. For
     * example it escapes single quote characters.
     *
     * @param text the text to escape
     * @return filtered text
     * @since 1.3 Milestone 2
     * @deprecated values should be passed as positional parameters, not concatenated in the query; see
     *             {@link XWiki#searchDocuments(String, List)}; if escaping SQL is really needed, use {@code
     *             $escapetool.sql($string} ({@link org.xwiki.velocity.tools.EscapeTool#sql(Object)})
     */
    @Deprecated
    public String Util.escapeSQL(String text)
    {
        return Utils.SQLFilter(text);
    }

    /**
     * Add two integer numbers. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a the first number to add
     * @param b the second number to add
     * @return the sum of the two parameters
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add($n1, $n2}
     *             ({@link org.apache.velocity.tools.generic.MathTool#add(Object, Object)})
     */
    @Deprecated
    public int Util.add(int a, int b)
    {
        return a + b;
    }

    /**
     * Add two long numbers. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a the first number to add
     * @param b the second number to add
     * @return the sum of the two parameters
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add($n1, $n2}
     *             ({@link org.apache.velocity.tools.generic.MathTool#add(Object, Object)})
     */
    @Deprecated
    public long Util.add(long a, long b)
    {
        return a + b;
    }

    /**
     * Add two numbers, specified as strings. Useful in Velocity, since arithmetical operations are not always working.
     *
     * @param a a string representing a number to add
     * @param b a string representing a number to add
     * @return the sum of the two parameters, as a String
     * @since 1.3 Milestone 2
     * @deprecated use {@code $mathtool.add} and {@code $mathtool.toNumber} to get the same result
     */
    @Deprecated
    public String Util.add(String a, String b)
    {
        long c = Long.parseLong(a) + Long.parseLong(b);
        return "" + c;
    }

    /**
     * Protect Text from Wiki transformation. This method is useful for preventing content generated with Velocity from
     * being interpreted in the xwiki/1.0 rendering engine, and should not be used in xwiki/2.0 code. The result is
     * valid only in HTML or XML documents.
     *
     * @param text the text to escape
     * @return the escaped text
     * @since 1.3 Milestone 2
     * @deprecated this method only works for {@code xwiki/1.0} wiki syntax, and it doesn't even escape all the syntax
     */
    @Deprecated
    public String Util.escapeText(String text)
    {
        return com.xpn.xwiki.util.Util.escapeText(text);
    }

    /**
     * Protect URLs from Wiki transformation. This method is useful for preventing content generated with Velocity from
     * being interpreted in the xwiki/1.0 rendering engine, and should not be used in xwiki/2.0 code. The result is
     * valid only in HTML or XML documents.
     *
     * @param url the url to escape
     * @return the encoded URL, which can be used in the HTML output
     * @since 1.3 Milestone 2
     * @deprecated this method only works for {@code xwiki/1.0} wiki syntax when outputting HTML
     */
    @Deprecated
    public String Util.escapeURL(String url)
    {
        return com.xpn.xwiki.util.Util.escapeURL(url);
    }

    /**
     * Translates a string into application/x-www-form-urlencoded format, so that it can be safely used in
     * a query string as a parameter value.
     *
     * @param text the non encoded text
     * @return encoded text
     * @since 1.3 Milestone 2
     * @see #decodeURI(String)
     * @deprecated use {@code $escapetool.url($string)} ({@link org.xwiki.velocity.tools.EscapeTool#url(Object)})
     */
    @Deprecated
    public String Util.encodeURI(String text)
    {
        return com.xpn.xwiki.util.Util.encodeURI(text, this.context);
    }
}