[ 
https://issues.apache.org/jira/browse/DELTASPIKE-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13851912#comment-13851912
 ] 

Christian Kaltepoth commented on DELTASPIKE-399:
------------------------------------------------

Hey John,

first of all, thanks for starting to work on this. I really think this will be 
a very useful feature.

I just had a quick look at the code and want to give some feedback.

#1 Regarding ExternalResourceProviderComparator. As we now have some APIs that 
use some kind of priority/ordinal for ordering, we should think about creating 
an interface for this. This way we could build a single comparator that would 
work for all the classes that implement this interface. I'm thinking about 
something like [1]. Thoughts?

#2 To be honest, I'm not quite happy with the fact that the code currently 
tries all ExternalResourceProviders to find a matching resource. As Gerhard 
already pointed out, this may lead to weird effects if more than one provider 
returns a result. I was thinking if we could instead use some kind of prefix in 
the resource name to identifier which provider to use. Something like:

{code}
@Inject
@ExternalResource("classpath:myconfig.properties")
private InputStream inputStream;
{code}

Spring uses a similar concept. I think this would make sense because the users 
typically know from which place the resource should be loaded. So we should 
allow them to specify it. I think this will be easy to implement if the 
provider API supports this concept. 

#3 We could think about adding an ExternalResourceProvider for web resources 
which uses ServletContext.getResource() and add it to the Servlet module.
 

[1] 
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/Weighted.java

> Incorporate Solder's ResourceLoader features into DeltaSpike
> ------------------------------------------------------------
>
>                 Key: DELTASPIKE-399
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-399
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 0.4
>            Reporter: Aaron Siri
>            Assignee: John D. Ament
>            Priority: Minor
>             Fix For: 0.6
>
>
> Seam 3's Solder module had some nice resource loading functionality within 
> the org.jboss.solder.resourceLoader packages.  With it you could do the 
> following:
> // Load a properties file
> @Inject @Resource("app.properties")
> private Properties appProperties;
> or:
> @Inject
> private ResourceProvider resourceProvider
> public Properties getHostProperties() {
>    String hostname = java.net.InetAddress.getLocalHost().getHostName();
>    return resourceProvider.loadPropertiesBundle(hostname + ".properties");
> }



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Reply via email to