org.apache.cocoon.components.source.impl
Class AvalonToCocoonSourceInvocationHandler

java.lang.Object
  extended by org.apache.cocoon.components.source.impl.AvalonToCocoonSourceInvocationHandler
All Implemented Interfaces:
InvocationHandler

public class AvalonToCocoonSourceInvocationHandler
extends Object
implements InvocationHandler

An InvocationHandler which acts as a proxy for excalibur Source objects to make them compatible with the cocoon Source interface. Much of the code was taken from AvalonToCocoonSource.

Version:
CVS $Id: AvalonToCocoonSourceInvocationHandler.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stefan Köhler, Carsten Ziegeler

Field Summary
protected  Environment environment
          The environment
protected  ComponentManager manager
          The manager
protected  SourceResolver resolver
          The source resolver
protected  Source source
          The real source
 
Constructor Summary
AvalonToCocoonSourceInvocationHandler(Source source, SourceResolver resolver, Environment environment, ComponentManager manager)
          Constructor
 
Method Summary
static Source createProxy(Source source, SourceResolver resolver, Environment environment, ComponentManager manager)
          Creates a dynamic proxy for an excalibur Source object to make it behave like a cocoon Source.
 InputSource getInputSource()
          Return an InputSource object to read the XML content.
 InputStream getInputStream()
          Return an InputStream object to read from the source.
 String getSystemId()
          Return the unique identifer for this source
 Object invoke(Object proxy, Method method, Object[] args)
          Processes a method invocation on a proxy instance and returns the result.
 void recycle()
           
 void refresh()
           
 void toSAX(ContentHandler handler)
          Stream content to a content handler or to an XMLConsumer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected Source source
The real source


resolver

protected SourceResolver resolver
The source resolver


environment

protected Environment environment
The environment


manager

protected ComponentManager manager
The manager

Constructor Detail

AvalonToCocoonSourceInvocationHandler

public AvalonToCocoonSourceInvocationHandler(Source source,
                                             SourceResolver resolver,
                                             Environment environment,
                                             ComponentManager manager)
Constructor

Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Processes a method invocation on a proxy instance and returns the result. It invokes the corresponding method of the wrapped excalibur source.

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - the Cocoon source proxy instance that the method was invoked on
method - the Method instance corresponding to the interface method invoked on the proxy instance.
args - the arguments for the interface method
Returns:
the result of the proxy method
Throws:
Throwable

getInputStream

public InputStream getInputStream()
                           throws ProcessingException,
                                  IOException
Return an InputStream object to read from the source.

Throws:
ProcessingException
IOException

getInputSource

public InputSource getInputSource()
                           throws ProcessingException,
                                  IOException
Return an InputSource object to read the XML content.

Returns:
an InputSource value
Throws:
ProcessingException - if an error occurs
IOException - if an error occurs

getSystemId

public String getSystemId()
Return the unique identifer for this source


recycle

public void recycle()

refresh

public void refresh()

toSAX

public void toSAX(ContentHandler handler)
           throws SAXException
Stream content to a content handler or to an XMLConsumer.

Throws:
SAXException - if failed to parse source document.

createProxy

public static Source createProxy(Source source,
                                 SourceResolver resolver,
                                 Environment environment,
                                 ComponentManager manager)
                          throws SourceException
Creates a dynamic proxy for an excalibur Source object to make it behave like a cocoon Source.

Parameters:
source - the source object to be wrapped
Returns:
a proxy object which implements the cocoon Source interface and all of the interfaces that the wrapped object implements
Throws:
SourceException - in case of an error


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.