You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by Minto van der Sluis <mi...@xup.nl> on 2012/09/03 19:21:49 UTC

ResourceStreamSourceComposite is no composite

Hi folks,

While trying to figure out how the ISIS configuration/property file
reading works I added some log statements to PropertiesReader. This
resulted in the following log snippet related to property file reading.

<snip>
16:34:17,073  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,082  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,084  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,089  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,092  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,096  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,099  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,102  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]
initialising Isis System
16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]  working
directory:
C:\Dev\src\Werk\Ictu\Digimelding2.0\github\prime\src\tagstore\tagstore-webapp\.
16:34:17,106  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,110  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,117  [IsisSystemFixturesHookAbstract main       INFO ]
resource stream source: [servlet context ('/WEB-INF'), context loader
classpath, file system (directory '../../conf')]
16:34:17,124  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,127  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,155  [TemplateImageLoaderAwt main       INFO ]  images to be
loaded from images/
16:34:17,160  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,164  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,205  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,210  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,218  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,222  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
16:34:17,335  [ServicesInstallerFromConfiguration main       INFO ]
installing
org.apache.isis.runtimes.dflt.runtime.services.ServicesInstallerFromConfiguration
16:34:17,335  [PropertiesReader     main       DEBUG]  Reading
properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
context loader classpath, file system (directory '../../conf')]
16:34:17,339  [PropertiesReader     main       DEBUG]  Reading
properties from 'viewer_html.properties' using : [servlet context
('/WEB-INF'), context loader classpath, file system (directory
'../../conf')]
<snap>

Initially I was puzzled by the ResourceStreamSource being used. But them
I discoverd ResourceStreamSourceCompsite. While looking at the
implementation I discovered that IMHO it is not a Composite at all. The
following snippet comes from this class:

        for (final ResourceStreamSource rss : resourceStreamSources) {
            final InputStream resourceStream =
rss.readResource(resourcePath);
            if (resourceStream != null) {
                return resourceStream;
            }
        }

In it the composite bails out after the first stream that is
successfully read. Shouldn't a composite compose a stream of all
ResourceStreamSource's contained inside the composite?

(Me wonders how a write should work in that case)

Regards,

Minto
-- 
ir. ing. Minto van der Sluis
Software innovator / renovator


Re: ResourceStreamSourceComposite is no composite

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 4 September 2012 07:33, <mi...@xup.nl> wrote:

>


> When is the ResourceStreamSource.**writeResource() used? For my composite
> I intend to not implement it (return null).
>

It is used (it would seem) only by FileAuthorizor, which is the component
that reads from the authorization_file.allow file for reading security
roles.  It has a "learn" mode whereby it will allow all authorization
requests through, and write those requests back into the file.  This was
introduced for prototyping scenarios (though I admit I've not used it in
anger myself).

So, I think your plan should be fine.

Dan


> Regards,
>
> Minto
>
>
>
> Quoting Dan Haywood <da...@haywood-associates.co.uk>**:
>
>  Minto,
>> you are right... it's implementing a ChainOfResponsibility pattern.
>> I'll rename it.
>> Dan
>>
>>
>>
>> On 3 September 2012 18:21, Minto van der Sluis <mi...@xup.nl> wrote:
>>
>>  Hi folks,
>>>
>>> While trying to figure out how the ISIS configuration/property file
>>> reading works I added some log statements to PropertiesReader. This
>>> resulted in the following log snippet related to property file reading.
>>>
>>> <snip>
>>> 16:34:17,073  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,082  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,084  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,089  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,092  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,096  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,099  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,102  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,106  [**IsisSystemFixturesHookAbstract main       INFO ]
>>> initialising Isis System
>>> 16:34:17,106  [**IsisSystemFixturesHookAbstract main       INFO ]
>>>  working
>>> directory:
>>>
>>> C:\Dev\src\Werk\Ictu\**Digimelding2.0\github\prime\**
>>> src\tagstore\tagstore-webapp\.
>>> 16:34:17,106  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,110  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,117  [**IsisSystemFixturesHookAbstract main       INFO ]
>>> resource stream source: [servlet context ('/WEB-INF'), context loader
>>> classpath, file system (directory '../../conf')]
>>> 16:34:17,124  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,127  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,155  [TemplateImageLoaderAwt main       INFO ]  images to be
>>> loaded from images/
>>> 16:34:17,160  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,164  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,205  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,210  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,218  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,222  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> 16:34:17,335  [**ServicesInstallerFromConfigura**tion main       INFO ]
>>> installing
>>>
>>> org.apache.isis.runtimes.dflt.**runtime.services.**
>>> ServicesInstallerFromConfigura**tion
>>> 16:34:17,335  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>>> context loader classpath, file system (directory '../../conf')]
>>> 16:34:17,339  [PropertiesReader     main       DEBUG]  Reading
>>> properties from 'viewer_html.properties' using : [servlet context
>>> ('/WEB-INF'), context loader classpath, file system (directory
>>> '../../conf')]
>>> <snap>
>>>
>>> Initially I was puzzled by the ResourceStreamSource being used. But them
>>> I discoverd ResourceStreamSourceCompsite. While looking at the
>>> implementation I discovered that IMHO it is not a Composite at all. The
>>> following snippet comes from this class:
>>>
>>>         for (final ResourceStreamSource rss : resourceStreamSources) {
>>>             final InputStream resourceStream =
>>> rss.readResource(resourcePath)**;
>>>             if (resourceStream != null) {
>>>                 return resourceStream;
>>>             }
>>>         }
>>>
>>> In it the composite bails out after the first stream that is
>>> successfully read. Shouldn't a composite compose a stream of all
>>> ResourceStreamSource's contained inside the composite?
>>>
>>> (Me wonders how a write should work in that case)
>>>
>>> Regards,
>>>
>>> Minto
>>> --
>>> ir. ing. Minto van der Sluis
>>> Software innovator / renovator
>>>
>>>
>>>
>>
>

Re: ResourceStreamSourceComposite is no composite

Posted by mi...@xup.nl.
Hi Dan,

Hmm, that's a pity. I was actually looking for a real composite :-)

At least for reading properties. That way I could overload  
isis.properties with another properties file from an external (outside  
war) config directory.

I'll create the composite myself.

When is the ResourceStreamSource.writeResource() used? For my  
composite I intend to not implement it (return null).

Regards,

Minto


Quoting Dan Haywood <da...@haywood-associates.co.uk>:

> Minto,
> you are right... it's implementing a ChainOfResponsibility pattern.
> I'll rename it.
> Dan
>
>
>
> On 3 September 2012 18:21, Minto van der Sluis <mi...@xup.nl> wrote:
>
>> Hi folks,
>>
>> While trying to figure out how the ISIS configuration/property file
>> reading works I added some log statements to PropertiesReader. This
>> resulted in the following log snippet related to property file reading.
>>
>> <snip>
>> 16:34:17,073  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,082  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,084  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,089  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,092  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,096  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,099  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,102  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]
>> initialising Isis System
>> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]  working
>> directory:
>>
>> C:\Dev\src\Werk\Ictu\Digimelding2.0\github\prime\src\tagstore\tagstore-webapp\.
>> 16:34:17,106  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,110  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,117  [IsisSystemFixturesHookAbstract main       INFO ]
>> resource stream source: [servlet context ('/WEB-INF'), context loader
>> classpath, file system (directory '../../conf')]
>> 16:34:17,124  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,127  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,155  [TemplateImageLoaderAwt main       INFO ]  images to be
>> loaded from images/
>> 16:34:17,160  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,164  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,205  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,210  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,218  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,222  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,335  [ServicesInstallerFromConfiguration main       INFO ]
>> installing
>>
>> org.apache.isis.runtimes.dflt.runtime.services.ServicesInstallerFromConfiguration
>> 16:34:17,335  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,339  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> <snap>
>>
>> Initially I was puzzled by the ResourceStreamSource being used. But them
>> I discoverd ResourceStreamSourceCompsite. While looking at the
>> implementation I discovered that IMHO it is not a Composite at all. The
>> following snippet comes from this class:
>>
>>         for (final ResourceStreamSource rss : resourceStreamSources) {
>>             final InputStream resourceStream =
>> rss.readResource(resourcePath);
>>             if (resourceStream != null) {
>>                 return resourceStream;
>>             }
>>         }
>>
>> In it the composite bails out after the first stream that is
>> successfully read. Shouldn't a composite compose a stream of all
>> ResourceStreamSource's contained inside the composite?
>>
>> (Me wonders how a write should work in that case)
>>
>> Regards,
>>
>> Minto
>> --
>> ir. ing. Minto van der Sluis
>> Software innovator / renovator
>>
>>
>


Re: ResourceStreamSourceComposite is no composite

Posted by Minto van der Sluis <mi...@xup.nl>.
Hi Dan,

I was just probing interest ;-)

Anyway, I will create a jira issue and add a patch.

Regards,

Minto

Op 4-9-2012 16:50, Dan Haywood schreef:
> could I ask you to take a fork of my github repo?  then you can generate a
> patch really easily?
> 
> Thx
> Dan
> 
> 
> On 4 September 2012 15:42, <mi...@xup.nl> wrote:
> 
>> 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 <da...@haywood-associates.co.uk>**:
>>
>>  rev 1380404~1380407 or thereabouts.
>>>
>>>
>>> On 4 September 2012 00:06, Dan Haywood <da...@haywood-associates.co.uk>
>>> wrote:
>>>
>>>  Minto,
>>>> you are right... it's implementing a ChainOfResponsibility pattern.
>>>> I'll rename it.
>>>> Dan
>>>>
>>>>
>>>>
>>>>
> 


-- 
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV

Mobiel: +31 (0) 626 014541

Re: ResourceStreamSourceComposite is no composite

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
could I ask you to take a fork of my github repo?  then you can generate a
patch really easily?

Thx
Dan


On 4 September 2012 15:42, <mi...@xup.nl> wrote:

> 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 <da...@haywood-associates.co.uk>**:
>
>  rev 1380404~1380407 or thereabouts.
>>
>>
>> On 4 September 2012 00:06, Dan Haywood <da...@haywood-associates.co.uk>
>> wrote:
>>
>>  Minto,
>>> you are right... it's implementing a ChainOfResponsibility pattern.
>>> I'll rename it.
>>> Dan
>>>
>>>
>>>
>>>

Re: ResourceStreamSourceComposite is no composite

Posted by mi...@xup.nl.
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 <da...@haywood-associates.co.uk>:

> rev 1380404~1380407 or thereabouts.
>
>
> On 4 September 2012 00:06, Dan Haywood <da...@haywood-associates.co.uk> wrote:
>
>> Minto,
>> you are right... it's implementing a ChainOfResponsibility pattern.
>> I'll rename it.
>> Dan
>>
>>
>>

Re: ResourceStreamSourceComposite is no composite

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
rev 1380404~1380407 or thereabouts.


On 4 September 2012 00:06, Dan Haywood <da...@haywood-associates.co.uk> wrote:

> Minto,
> you are right... it's implementing a ChainOfResponsibility pattern.
> I'll rename it.
> Dan
>
>
>
> On 3 September 2012 18:21, Minto van der Sluis <mi...@xup.nl> wrote:
>
>> Hi folks,
>>
>> While trying to figure out how the ISIS configuration/property file
>> reading works I added some log statements to PropertiesReader. This
>> resulted in the following log snippet related to property file reading.
>>
>> <snip>
>> 16:34:17,073  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,082  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,084  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,089  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,092  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,096  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,099  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,102  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]
>> initialising Isis System
>> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]  working
>> directory:
>>
>> C:\Dev\src\Werk\Ictu\Digimelding2.0\github\prime\src\tagstore\tagstore-webapp\.
>> 16:34:17,106  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,110  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,117  [IsisSystemFixturesHookAbstract main       INFO ]
>> resource stream source: [servlet context ('/WEB-INF'), context loader
>> classpath, file system (directory '../../conf')]
>> 16:34:17,124  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,127  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,155  [TemplateImageLoaderAwt main       INFO ]  images to be
>> loaded from images/
>> 16:34:17,160  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,164  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,205  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,210  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,218  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,222  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> 16:34:17,335  [ServicesInstallerFromConfiguration main       INFO ]
>> installing
>>
>> org.apache.isis.runtimes.dflt.runtime.services.ServicesInstallerFromConfiguration
>> 16:34:17,335  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
>> context loader classpath, file system (directory '../../conf')]
>> 16:34:17,339  [PropertiesReader     main       DEBUG]  Reading
>> properties from 'viewer_html.properties' using : [servlet context
>> ('/WEB-INF'), context loader classpath, file system (directory
>> '../../conf')]
>> <snap>
>>
>> Initially I was puzzled by the ResourceStreamSource being used. But them
>> I discoverd ResourceStreamSourceCompsite. While looking at the
>> implementation I discovered that IMHO it is not a Composite at all. The
>> following snippet comes from this class:
>>
>>         for (final ResourceStreamSource rss : resourceStreamSources) {
>>             final InputStream resourceStream =
>> rss.readResource(resourcePath);
>>             if (resourceStream != null) {
>>                 return resourceStream;
>>             }
>>         }
>>
>> In it the composite bails out after the first stream that is
>> successfully read. Shouldn't a composite compose a stream of all
>> ResourceStreamSource's contained inside the composite?
>>
>> (Me wonders how a write should work in that case)
>>
>> Regards,
>>
>> Minto
>> --
>> ir. ing. Minto van der Sluis
>> Software innovator / renovator
>>
>>
>

Re: ResourceStreamSourceComposite is no composite

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Minto,
you are right... it's implementing a ChainOfResponsibility pattern.
I'll rename it.
Dan



On 3 September 2012 18:21, Minto van der Sluis <mi...@xup.nl> wrote:

> Hi folks,
>
> While trying to figure out how the ISIS configuration/property file
> reading works I added some log statements to PropertiesReader. This
> resulted in the following log snippet related to property file reading.
>
> <snip>
> 16:34:17,073  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,082  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,084  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,089  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,092  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,096  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,099  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,102  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]
> initialising Isis System
> 16:34:17,106  [IsisSystemFixturesHookAbstract main       INFO ]  working
> directory:
>
> C:\Dev\src\Werk\Ictu\Digimelding2.0\github\prime\src\tagstore\tagstore-webapp\.
> 16:34:17,106  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,110  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,117  [IsisSystemFixturesHookAbstract main       INFO ]
> resource stream source: [servlet context ('/WEB-INF'), context loader
> classpath, file system (directory '../../conf')]
> 16:34:17,124  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,127  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,155  [TemplateImageLoaderAwt main       INFO ]  images to be
> loaded from images/
> 16:34:17,160  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,164  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,205  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,210  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,218  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,222  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> 16:34:17,335  [ServicesInstallerFromConfiguration main       INFO ]
> installing
>
> org.apache.isis.runtimes.dflt.runtime.services.ServicesInstallerFromConfiguration
> 16:34:17,335  [PropertiesReader     main       DEBUG]  Reading
> properties from 'isis.properties' using : [servlet context ('/WEB-INF'),
> context loader classpath, file system (directory '../../conf')]
> 16:34:17,339  [PropertiesReader     main       DEBUG]  Reading
> properties from 'viewer_html.properties' using : [servlet context
> ('/WEB-INF'), context loader classpath, file system (directory
> '../../conf')]
> <snap>
>
> Initially I was puzzled by the ResourceStreamSource being used. But them
> I discoverd ResourceStreamSourceCompsite. While looking at the
> implementation I discovered that IMHO it is not a Composite at all. The
> following snippet comes from this class:
>
>         for (final ResourceStreamSource rss : resourceStreamSources) {
>             final InputStream resourceStream =
> rss.readResource(resourcePath);
>             if (resourceStream != null) {
>                 return resourceStream;
>             }
>         }
>
> In it the composite bails out after the first stream that is
> successfully read. Shouldn't a composite compose a stream of all
> ResourceStreamSource's contained inside the composite?
>
> (Me wonders how a write should work in that case)
>
> Regards,
>
> Minto
> --
> ir. ing. Minto van der Sluis
> Software innovator / renovator
>
>