public abstract class AbstractOutputStreamResource extends Object implements SAXVisitBefore, DOMVisitBefore, Consumer, VisitLifecycleCleanable, ExecutionLifecycleCleanable
Writer can also be opened on a stream resource. If a Writer
has been opened on a resource, an OutputStream cannot also be opened (and visa versa).
Example configuration:
<resource-config selector="#document">
<resource>org.milyn.io.ConcreateImpl</resource>
<param name="resourceName">resourceName</param>
<param name="writerEncoding">UTF-8</param> <!-- Optional -->
</resource-config>
Description of configuration properties:
resource: should be a concreate implementation of this classresourceName: the name of this resouce. Will be used to identify this resourcewriterEncoding: (Optional) the encoding to be used by any writers opened on this resource (Default is "UTF-8")| Modifier and Type | Field and Description |
|---|---|
protected static String |
RESOURCE_CONTEXT_KEY_PREFIX |
| Constructor and Description |
|---|
AbstractOutputStreamResource() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
closeCondition(ExecutionContext executionContext) |
protected void |
closeResource(ExecutionContext executionContext)
Close the resource output stream.
|
boolean |
consumes(Object object)
Does this consumer consume the specified named object.
|
void |
executeExecutionLifecycleCleanup(ExecutionContext executionContext)
Cleanup the resources allocated by this resource for the specified ExecutionContext.
|
void |
executeVisitLifecycleCleanup(Fragment fragment,
ExecutionContext executionContext)
Cleanup the resources allocated by this resource for the specified ExecutionContext.
|
abstract OutputStream |
getOutputStream(ExecutionContext executionContext)
Retrieve/create an output stream that is appropriate for the concreate implementation
|
static OutputStream |
getOutputStream(String resourceName,
ExecutionContext executionContext)
Get an
OutputStream to the named Resource. |
static Writer |
getOutputWriter(String resourceName,
ExecutionContext executionContext)
Get a
Writer to the named OutputStream Resource. |
String |
getResourceName()
Get the name of this resource
|
Charset |
getWriterEncoding() |
AbstractOutputStreamResource |
setResourceName(String resourceName)
Set the name of this resource
|
AbstractOutputStreamResource |
setWriterEncoding(Charset writerEncoding) |
void |
visitBefore(Element element,
ExecutionContext executionContext)
Visit the supplied element before visiting its child elements.
|
void |
visitBefore(SAXElement element,
ExecutionContext executionContext)
Visit the supplied element before visiting its child elements.
|
protected static final String RESOURCE_CONTEXT_KEY_PREFIX
public abstract OutputStream getOutputStream(ExecutionContext executionContext) throws IOException
executionContext - Execution Context.IOExceptionpublic String getResourceName()
public boolean consumes(Object object)
ConsumerProducer that is executing
on the same element. The consumer should only return false if it knows for
certain that it doesn't consumer the specified named object. If uncertain, it should
error on the side of saying that it does consume the object.public AbstractOutputStreamResource setResourceName(String resourceName)
resourceName - The name of the resourcepublic AbstractOutputStreamResource setWriterEncoding(Charset writerEncoding)
public Charset getWriterEncoding()
public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException
SAXVisitBeforevisitBefore in interface SAXVisitBeforeelement - The SAX element being visited.executionContext - Execution context.SmooksException - Event processing failure.IOException - Error writing event to output writer.public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException
DOMVisitBeforevisitBefore in interface DOMVisitBeforeelement - The DOM element being visited.executionContext - Request relative instance.SmooksException - Element processing failure.public void executeVisitLifecycleCleanup(Fragment fragment, ExecutionContext executionContext)
VisitLifecycleCleanableexecuteVisitLifecycleCleanup in interface VisitLifecycleCleanablefragment - The fragment.executionContext - The ExecutionContext.public void executeExecutionLifecycleCleanup(ExecutionContext executionContext)
ExecutionLifecycleCleanableexecuteExecutionLifecycleCleanup in interface ExecutionLifecycleCleanableexecutionContext - The ExecutionContext.protected boolean closeCondition(ExecutionContext executionContext)
public static OutputStream getOutputStream(String resourceName, ExecutionContext executionContext) throws SmooksException
OutputStream to the named Resource.resourceName - The resource name.executionContext - The current ExececutionContext.OutputStream to the named Resource.SmooksException - Unable to access OutputStream.public static Writer getOutputWriter(String resourceName, ExecutionContext executionContext) throws SmooksException
Writer to the named OutputStream Resource.
Wraps the OutputStream in a Writer. Uses the "writerEncoding"
param to set the encoding on the Writer.resourceName - The resource name.executionContext - The current ExececutionContext.Writer to the named OutputStream Resource.SmooksException - Unable to access OutputStream.protected void closeResource(ExecutionContext executionContext)
executionContext - Smooks ExecutionContextCopyright © 2020. All rights reserved.