Hi Dan,

Creating a ResourceStreamSourceComposite turned out to be pretty easy by using the standard SequenceInputStream. Only part of the doReadREsource() method needs changes. See the following snippet:

    @Override
    protected InputStream doReadResource(final String resourcePath) {
        Vector<InputStream> compositionStreams = new Vector<InputStream>();
        for (final ResourceStreamSource rss : resourceStreamSources) {
            final InputStream resourceStream = rss.readResource(resourcePath);
            if (resourceStream != null) {
                compositionStreams.add(resourceStream);
            }
        }
        if (!compositionStreams.isEmpty()) {
            return new SequenceInputStream(compositionStreams.elements());
        }
        if (LOG.isDebugEnabled()) {
LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
        }
        return null;
    }

If you would like to add this class to Isis please change the getName() as well otherwise the chained and composite output will look the same. I add "chain" and "composite" to the respective getName() methods.

Regards,

Minto


Quoting Dan Haywood <[email protected]>:

rev 1380404~1380407 or thereabouts.


On 4 September 2012 00:06, Dan Haywood <[email protected]> wrote:

Minto,
you are right... it's implementing a ChainOfResponsibility pattern.
I'll rename it.
Dan



Reply via email to