All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bsc.reporting.sink.SinkDelegate Maven / Gradle / Ivy

Go to download

plugin that document a project (using maven site style) and send result to a live confluence site [http://www.atlassian.com/software/confluence/]

There is a newer version: 8.0-beta1
Show newest version
package org.bsc.reporting.sink;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import javax.swing.text.AttributeSet;

import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;

public class SinkDelegate implements InvocationHandler
	    {
	        private final Sink sink;

	        public SinkDelegate( Sink sink ) {
	            this.sink = sink;
	        }
	
	        /** {@inheritDoc} */
	        public Object invoke( Object proxy, Method method, Object[] args )
	            throws Throwable
	        {
	            Class[] parameterTypes = method.getParameterTypes();
	
	            for ( int i = parameterTypes.length - 1; i >= 0; i-- )
	            {
	                if ( AttributeSet.class.isAssignableFrom( parameterTypes[i] ) )
	                {
	                    parameterTypes[i] = SinkEventAttributes.class;
	                }
	            }
	
	            if ( args != null )
	            {
	                for ( int i = args.length - 1; i >= 0; i-- )
	                {
	                    if ( AttributeSet.class.isInstance( args[i] ) )
	                    {
	                        args[i] = new SinkEventAttributeSet( (AttributeSet) args[i] );
	                    }
	                }
	            }
	
	            Method target = Sink.class.getMethod( method.getName(), parameterTypes );
	
	            return target.invoke( sink, args );
	        }
	    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy