You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/05/10 23:20:43 UTC
DO NOT REPLY [Bug 39548] New: - [configuration] use a Strategy pattern for locating resources
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39548>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39548
Summary: [configuration] use a Strategy pattern for locating
resources
Product: Commons
Version: unspecified
Platform: Other
OS/Version: other
Status: NEW
Severity: enhancement
Priority: P2
Component: Configuration
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: nichoj@gentoo.org
Currently, the method for locating resources (ie ConfigurationUtils.locate )
uses a few means of finding the resource. However, the ways of finding resources
are set in stone.
At times, it would be useful to be able to pick and choose how resources are
located. Here's an example:
I have a webapp that builds a CompositeConfiguration composed of several
PropertiesConfigurations (we'll say my.properties and default.properties) via
spring. So, I go to kick off tomcat. If the current directory I'm in has a
my.properties or default.properties.... those files get used instead of the ones
on the classpath that I intended to be used. As a result, unexpected behavior of
the webapp ensues.
The solution to this is to encapsulate each algorithm for locating resoucess,
and be able to pick and choose. To me, this screamed of the strategy pattern.
A patch is forthcoming...
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39548] - [configuration] use a Strategy pattern for locating resources
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39548>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39548
------- Additional Comments From oliver.heger@t-online.de 2006-05-13 14:29 -------
The hard coded locating strategy is surely a weakness of this library. Your
patch is a step in the right direction.
Over a year a ago we had a discussion about this topic on the developers mailing
list. We all agreed that the current situation is not the optimum, but could not
find a consensus about how a better solution would look like.
Your implementation seems to be very similar to one of the suggestions made at
that time. A different suggestion was to have a Locator interface like the
following:
public interface Locator
{
URL locate() throws ConfigurationException;
}
So that the parameters needed for locating the file (e.g. base path and file
name) are not exposed in the interface, but are part of a specific
implementation. File-based configurations would then have to be changed to have
a new load() method, which accepts a Locator object.
A client would load a configuration the following way:
Locator loc = new URLLocator(<a URL>);
config.load(loc);
provided that URLLocator is an implementation of Locator. WDYT?
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39548] - [configuration] use a Strategy pattern for locating resources
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39548>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39548
------- Additional Comments From nichoj@gentoo.org 2006-05-10 21:24 -------
Created an attachment (id=18253)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18253&action=view)
locator-strategy.patch
This patch is against trunk from a month or two ago. I would have updated, but
for some reason the repository can't be found.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org