You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/09/30 01:34:53 UTC
svn commit: r700306 [2/2] - in /ode/branches/APACHE_ODE_1.X:
axis2-war/src/main/webapp/WEB-INF/conf/
axis2-war/src/test/java/org/apache/ode/axis2/
axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/
axis2-war/src/test/resources/TestEndpointProper...
Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/jpa/DbConfStoreConnectionFactory.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/jpa/DbConfStoreConnectionFactory.java?rev=700306&r1=700305&r2=700306&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/jpa/DbConfStoreConnectionFactory.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/jpa/DbConfStoreConnectionFactory.java Mon Sep 29 16:34:52 2008
@@ -35,13 +35,13 @@
private DataSource _ds;
private EntityManagerFactory _emf;
- public DbConfStoreConnectionFactory(DataSource ds, boolean auto) {
+ public DbConfStoreConnectionFactory(DataSource ds, boolean createDatamodel) {
_ds = ds;
HashMap propMap = new HashMap();
propMap.put("javax.persistence.nonJtaDataSource", ds);
propMap.put("openjpa.Log", "log4j");
// propMap.put("openjpa.jdbc.DBDictionary", "org.apache.openjpa.jdbc.sql.DerbyDictionary");
- if (auto) propMap.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
+ if (createDatamodel) propMap.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
_emf = Persistence.createEntityManagerFactory("ode-store", propMap);
}
Modified: ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/HierarchicalProperties.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/HierarchicalProperties.java?rev=700306&r1=700305&r2=700306&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/HierarchicalProperties.java (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/HierarchicalProperties.java Mon Sep 29 16:34:52 2008
@@ -20,6 +20,7 @@
package org.apache.ode.utils;
import org.apache.commons.collections.map.MultiKeyMap;
+import org.apache.commons.collections.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -27,16 +28,18 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Collections;
-import java.util.Iterator;
+import java.util.Arrays;
+import java.util.List;
/**
- * This class load a regular property file in {@link java.util.Properties} instance. The main feature is that property can
+ * This class load a list of regular property files (order matters). The main feature is that property can
* be chained in three levels. Then when querying for a property, if it's not found in the deepest level,
* the parent will be queryed and so on.
* <p/>
@@ -51,22 +54,24 @@
* <p/>
* For instance, if the property file looks like this:
* <pre>
+ *alias.foo_ns=http://foo.com
+ *
* timeout=40000
- * film-service.port-of-cannes.ode.timeout=50000
+ * a_namespace_with_no_alias_defined.film-service.port-of-cannes.ode.timeout=50000
* <p/>
* max-redirects=30
- * brel-service.ode.max-redirects=40
- * brel-service.port-of-amsterdam.ode.max-redirects=60
+ * foo_ns.brel-service.ode.max-redirects=40
+ * foo_ns.brel-service.port-of-amsterdam.ode.max-redirects=60
* </pre>
* The following values may be expected:
* <pre>
- * getProperty("max-redirects") => 30
- * getProperty("brel-service", "max-redirects") => 40
- * getProperty("brel-service", "port-of-amsterdam", "max-redirects") => 60
+ * getProperty("max-redirects") => 30
+ * getProperty("http://foo.com", "brel-service", "max-redirects") => 40
+ * getProperty("http://foo.com", "brel-service", "port-of-amsterdam", "max-redirects") => 60
* <p/>
- * getProperty("film-service", "timeout") => 40000
- * getProperty("film-service", "port-of-cannes", "timeout") => 50000
- * getProperty("brel-service", "port-of-amsterdam", "timeout") => 40000
+ * getProperty("a_namespace_with_no_alias_defined", "film-service", "timeout") => 40000
+ * getProperty("a_namespace_with_no_alias_defined", "film-service", "port-of-cannes", "timeout") => 50000
+ * getProperty("http://foo.com", "port-of-amsterdam", "timeout") => 40000
* </pre>
* <p/>
* Values may contain some environment variables. For instance, message=You're using ${java.version}.
@@ -81,14 +86,11 @@
public static final String ODE_PREFFIX = "ode";
- // the raw properties as of loaded from the filesystem
- private Properties props = new Properties();
- private Map<String, String> aliases = new HashMap<String, String>();
- private File file;
+ private File[] files;
private String prefix;
private String dotted_prefix;
/*
- This map contains ChainedMap instances chained according to the service and/or port they are associated with.
+ This map contains ChainedMap instances chained according to the (qualified) service and/or port they are associated with.
All ChainedMap instances has a common parent.
The ChainedMap instances are chained to each others so that if a property is not found for [service, port],
the ChainedMap associated to [service] will be queried, and if still not found, then the common parent.
@@ -105,35 +107,54 @@
private transient MultiKeyMap cacheOfImmutableMaps = new MultiKeyMap();
/**
- * @param file the property file to be loaded. The file may not exist.
+ * @param files the property file to be loaded. The file may not exist.
* But if the file exists it has to be a file (not a directory), otherwhise an IOException is thrown.
* @param prefix the property prefix
* @throws IOException
*/
- public HierarchicalProperties(File file, String prefix) throws IOException {
- this.file = file;
+ public HierarchicalProperties(File[] files, String prefix) throws IOException {
+ this.files = files;
this.prefix = prefix;
this.dotted_prefix = "." + prefix + ".";
- loadFile();
+ loadFiles();
+ }
+
+ public HierarchicalProperties(File[] files) throws IOException {
+ this(files, ODE_PREFFIX);
+ }
+
+ public HierarchicalProperties(File file, String prefix) throws IOException {
+ this(new File[]{file}, prefix);
}
public HierarchicalProperties(File file) throws IOException {
- this(file, ODE_PREFFIX);
+ this(new File[]{file}, ODE_PREFFIX);
+ }
+
+ public HierarchicalProperties(List<File> propFiles) throws IOException {
+ this(propFiles.toArray(new File[propFiles.size()]), ODE_PREFFIX);
}
/**
- * Clear all existing content, read the file and parse each property. Simply logs a message and returns if the file does not exist.
+ * Clear all existing content, then read the file and parse each property. Simply logs a message and returns if the file does not exist.
*
* @throws IOException if the file is a Directory
*/
- public void loadFile() throws IOException {
- if (!file.exists()) {
- if (log.isDebugEnabled()) log.debug("File does not exist [" + file + "] Properties will be empty.");
- return;
- }
+ public void loadFiles() throws IOException {
// #1. clear all existing content
clear();
+ // #3. put the root map
+ hierarchicalMap.put(null, null, new ChainedMap());
+ for (File file : files) loadFile(file);
+ }
+
+ protected void loadFile(File file) throws IOException {
+ if (!file.exists()) {
+ if (log.isDebugEnabled()) log.debug("File does not exist [" + file + "]");
+ return;
+ }
+ Properties props = new Properties();
// #2. read the file
FileInputStream fis = new FileInputStream(file);
try {
@@ -143,64 +164,77 @@
fis.close();
}
- // #3. put the root map
- hierarchicalMap.put(null, null, new ChainedMap());
-
- // #4. process each property
+ // gather all aliases
+ Map<String, String> nsByAlias = new HashMap<String, String>();
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
Map.Entry e = (Map.Entry) it.next();
String key = (String) e.getKey();
- String value = (String) e.getValue();
+ String namespace = (String) e.getValue();
+
// replace any env variables by its value
- value = SystemUtils.replaceSystemProperties(value);
- props.put(key, value);
+ namespace = SystemUtils.replaceSystemProperties(namespace);
+ props.put(key, namespace);
if (key.startsWith("alias.")) {
final String alias = key.substring("alias.".length(), key.length());
- if(log.isDebugEnabled()) log.debug("Alias found: "+alias+" -> "+value);
- aliases.put(value, alias);
- } else {
- // parse the property name
- String[] info = parseProperty((String) key);
- String nsalias = info[0];
- String service = info[1];
- String port = info[2];
- String targetedProperty = info[3];
-
- QName qname = nsalias != null ? new QName(nsalias, service) : null;
- // get the map associated to this port
- ChainedMap p = (ChainedMap) hierarchicalMap.get(qname, port);
- if (p == null) {
- // create it if necessary
- // get the associated service map
- ChainedMap s = (ChainedMap) hierarchicalMap.get(qname, null);
- if (s == null) {
- // create the service map if necessary, the parent is the root map.
- s = new ChainedMap(getRootMap());
- // put it in the multi-map
- hierarchicalMap.put(qname, null, s);
- }
+ if (log.isDebugEnabled()) log.debug("Alias found: " + alias + " -> " + namespace);
+ if (nsByAlias.containsKey(alias) && namespace.equals(nsByAlias.get(alias)))
+ throw new RuntimeException("Same alias used twice for 2 different namespaces! file=" + file + ", alias=" + alias);
+ nsByAlias.put(alias, namespace);
+ // remove the pair
+ it.remove();
+ }
+ }
+
+ // #4. process each property
+
+ for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
+ Map.Entry e = (Map.Entry) it.next();
+ String key = (String) e.getKey();
+ String value = (String) e.getValue();
+
- // create the map itself and link it to theservice map
- p = new ChainedMap(s);
+ // parse the property name
+ String[] info = parseProperty(key);
+ String nsalias = info[0];
+ String service = info[1];
+ String port = info[2];
+ String targetedProperty = info[3];
+
+ QName qname = null;
+ if (nsalias != null) {
+ qname = new QName(nsByAlias.get(nsalias) != null ? nsByAlias.get(nsalias) : nsalias, service);
+ }
+ // get the map associated to this port
+ ChainedMap p = (ChainedMap) hierarchicalMap.get(qname, port);
+ if (p == null) {
+ // create it if necessary
+ // get the associated service map
+ ChainedMap s = (ChainedMap) hierarchicalMap.get(qname, null);
+ if (s == null) {
+ // create the service map if necessary, the parent is the root map.
+ s = new ChainedMap(getRootMap());
// put it in the multi-map
- hierarchicalMap.put(qname, port, p);
+ hierarchicalMap.put(qname, null, s);
}
- // save the key/value in its chained map
- p.put(targetedProperty, value);
+ // create the map itself and link it to the service map
+ p = new ChainedMap(s);
+ // put it in the multi-map
+ hierarchicalMap.put(qname, port, p);
}
+
+ // save the key/value in its chained map
+ p.put(targetedProperty, value);
}
}
/**
- * Clear all content. If {@link #loadFile()} is not invoked later, all returned values will be null.
+ * Clear all content. If {@link #loadFiles()} is not invoked later, all returned values will be null.
*/
public void clear() {
- props.clear();
- aliases.clear();
hierarchicalMap.clear();
cacheOfImmutableMaps.clear();
}
@@ -243,7 +277,6 @@
// no need to go further if no properties
if (hierarchicalMap.isEmpty()) return Collections.EMPTY_MAP;
- service = resolveAlias(service);
// else check the cache of ChainedMap already converted into immutable maps
Map cachedMap = (Map) this.cacheOfImmutableMaps.get(service, port);
if (cachedMap != null) {
@@ -287,23 +320,14 @@
}
public String getProperty(QName service, String port, String property) {
- ChainedMap cm = (ChainedMap) hierarchicalMap.get(resolveAlias(service), port);
- // if this port is not explicitly mentioned in the multimap, get the default values.
- if (cm == null) cm = getRootMap();
- return (String) cm.get(property);
+ return (String) getProperties(service, port).get(property);
}
public String getPrefix() {
return prefix;
}
- private QName resolveAlias(QName service) {
- if (service != null && aliases.containsKey(service.getNamespaceURI())) {
- return new QName(aliases.get(service.getNamespaceURI()), service.getLocalPart());
- }
- return service;
- }
-
+
private String[] parseProperty(String property) {
// aliaas ns, service, port, targeted property
String[] res = new String[4];
Modified: ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/WatchDog.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/WatchDog.java?rev=700306&r1=700305&r2=700306&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/WatchDog.java (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/WatchDog.java Mon Sep 29 16:34:52 2008
@@ -22,6 +22,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.io.File;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.List;
+
/**
* This class is based on {@link org.apache.log4j.helpers.FileWatchdog}.<p/>
* Modifications have been made to support additional abstract ressource and more events (creation, deletion and updates), and to allow "manual"
@@ -36,15 +42,19 @@
*
* @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
*/
-public class WatchDog<T> implements Runnable {
+public class WatchDog<T, C extends WatchDog.Observer> implements Runnable {
static final public long DEFAULT_DELAY = 30000;
final Log log = LogFactory.getLog(WatchDog.class);
private long expire;
private T lastModif;
- private long delay;
+ private long delay = DEFAULT_DELAY;
private boolean existedBefore, warnedAlready, interrupted;
- protected final Mutable<T> mutable;
+ protected Mutable<T> mutable;
+ protected C observer;
+
+ public WatchDog() {
+ }
/**
* @param mutable the object to watch closely
@@ -55,45 +65,25 @@
this.delay = delay;
}
+ public WatchDog(Mutable<T> mutable, C observer) {
+ this.mutable = mutable;
+ this.observer = observer;
+ }
+
/**
* @see #WatchDog(org.apache.ode.utils.WatchDog.Mutable, long)
*/
public WatchDog(Mutable<T> mutable) {
this.mutable = mutable;
- this.delay = DEFAULT_DELAY;
- }
-
- protected boolean isInitialized() {
- return true;
}
- /**
- * Called by {@link #check()} if the object is not {@link #isInitialized initialized} and the {@link WatchDog.Mutable#exists()} resource does not exist}.
- * <br/> This method might called to reset the object.
- *
- * @throws Exception
- */
- protected void init() {
- }
- /**
- * Called only if the resource previously existed and now does not exist.
- * <br/>The default implementation invokes {@link #init()} .
- *
- * @throws Exception
- */
- protected void doOnDelete() {
- init();
+ public Mutable<T> getMutable() {
+ return mutable;
}
- /**
- * Called only if the resource previously existed but the {@link WatchDog.Mutable#lastModified()} timestamp has changed (greater than the previous value).
- * <br/>The default implementation invokes {@link #init()} .
- *
- * @throws Exception
- */
- protected void doOnUpdate() {
- init();
+ public C getObserver() {
+ return observer;
}
public long getDelay() {
@@ -123,24 +113,24 @@
long now = System.currentTimeMillis();
if (expire <= now) {
expire = now + delay;
- if (log.isDebugEnabled()) log.debug("Check for changes: "+mutable);
+ if (log.isDebugEnabled()) log.debug("Check for changes: " + mutable);
if (mutable.exists()) {
existedBefore = true;
- if (lastModif==null || mutable.hasChangedSince(lastModif)) {
+ if (lastModif == null || mutable.hasChangedSince(lastModif)) {
lastModif = mutable.lastModified();
- doOnUpdate();
+ observer.onUpdate();
if (log.isInfoEnabled()) log.info(mutable + " updated");
warnedAlready = false;
}
- } else if (!isInitialized()) {
+ } else if (!observer.isInitialized()) {
// no resource and first time
- init();
+ observer.init();
if (log.isInfoEnabled()) log.info(mutable + " initialized");
} else {
if (existedBefore) {
existedBefore = false;
lastModif = null;
- doOnDelete();
+ observer.onDelete();
if (log.isInfoEnabled()) log.info(mutable + " deleted");
}
if (!warnedAlready) {
@@ -151,6 +141,14 @@
}
}
+ public static <C extends Observer> WatchDog<Long, C> watchFile(File file, C handler) {
+ return new WatchDog<Long, C>(new FileMutable(file), handler);
+ }
+
+ public static <C extends Observer> WatchDog<Map<File, Long>, C> watchFiles(List<File> files, C handler) {
+ return new WatchDog<Map<File, Long>, C>(new FileSetMutable(files), handler);
+ }
+
/**
* have you said that duck typing would be nice?
*/
@@ -162,4 +160,123 @@
T lastModified();
}
+ static public class FileMutable implements WatchDog.Mutable<Long> {
+ File file;
+
+ public FileMutable(File file) {
+ this.file = file;
+ }
+
+ public boolean exists() {
+ return file.exists();
+ }
+
+ public boolean hasChangedSince(Long since) {
+ // do use 'greater than' to handle file deletion. The timestamp of a non-exising file is 0L.
+ return lastModified().longValue() != since.longValue();
+ }
+
+ public Long lastModified() {
+ return Long.valueOf(file.lastModified());
+ }
+
+ public String toString() {
+ return file.toString();
+ }
+ }
+
+ static public class FileSetMutable implements WatchDog.Mutable<Map<File, Long>> {
+
+ File[] files;
+
+ public FileSetMutable(Collection<File> files) {
+ this.files = new File[files.size()];
+ files.toArray(this.files);
+ }
+
+ public FileSetMutable(File[] files) {
+ this.files = files;
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public boolean hasChangedSince(Map<File, Long> since) {
+ Map<File, Long> snapshot = lastModified();
+ return !CollectionUtils.equals(snapshot, since);
+ }
+
+ public Map<File, Long> lastModified() {
+ Map<File, Long> m = new HashMap<File, Long>(files.length * 15 / 10);
+ for (File f : files) m.put(f, Long.valueOf(f.lastModified()));
+ return m;
+ }
+ }
+
+ public interface Observer {
+
+ boolean isInitialized();
+
+
+ /**
+ * Called by {@link WatchDog#check()} if the underlying object is not {@link #isInitialized initialized} and the {@link WatchDog.Mutable#exists()} resource does not exist}.
+ * <br/> This method might called to reset the underlying object.
+ *
+ * @throws Exception
+ */
+ void init();
+
+ /**
+ * Called only if the resource previously existed and now does not exist.
+ * <br/>The default implementation invokes {@link #init()} .
+ *
+ * @throws Exception
+ */
+ void onDelete();
+
+ /**
+ * Called only if the resource previously existed but the {@link WatchDog.Mutable#lastModified()} timestamp has changed (greater than the previous value).
+ * <br/>The default implementation invokes {@link #init()} .
+ *
+ * @throws Exception
+ */
+ void onUpdate();
+
+ }
+
+ /**
+ * A default implementation of #ChangeHandler. Delete and Update will both invoke the #init method which satifies most use cases.
+ * So subclasses may simply override the #init method to fit their own needs.
+ */
+ public static class DefaultObserver implements Observer {
+
+ /**
+ * @return true
+ */
+ public boolean isInitialized() {
+ return true;
+ }
+
+ /**
+ * empty implementation
+ */
+ public void init() {
+ }
+
+ /**
+ * delegate to #init
+ */
+ public void onDelete() {
+ init();
+ }
+
+ /**
+ * delegate to #init
+ */
+ public void onUpdate() {
+ init();
+ }
+
+ }
}
Modified: ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/HierarchicalPropertiesTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/HierarchicalPropertiesTest.java?rev=700306&r1=700305&r2=700306&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/HierarchicalPropertiesTest.java (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/HierarchicalPropertiesTest.java Mon Sep 29 16:34:52 2008
@@ -23,9 +23,9 @@
import java.io.File;
import java.io.IOException;
-import java.util.Map;
-import java.util.List;
import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
@@ -34,35 +34,27 @@
protected HierarchicalProperties hp;
protected void setUp() throws Exception {
- File file = new File(getClass().getResource("/hierarchical.properties").toURI());
- hp = new HierarchicalProperties(file);
- }
-
- public void testGetPropertyUsingAliases() {
- String msg = "Returned value does not match expected value for this property!";
- assertEquals(msg, hp.getProperty("max-redirects"), "30");
- assertEquals(msg, hp.getProperty("bar", "brel-service", "max-redirects"), "40");
- assertEquals(msg, hp.getProperty("bar", "brel-service", "port-of-amsterdam", "max-redirects"), "60");
- assertEquals(msg, hp.getProperty("bar", "brel-service", "port-of-amsterdam", "timeout"), "40000");
- assertEquals(msg, hp.getProperty("foo", "film-service", "timeout"), "40000");
- assertEquals(msg, hp.getProperty("foo", "film-service", "port-of-cannes", "timeout"), "50000");
- assertEquals(msg, hp.getProperty("ode.a.property.beginning.with.the.prefix.but.no.service"), "so green or red?");
+ File[] files = new File[]{new File(getClass().getResource("/hierarchical-2.properties").toURI()),
+ new File(getClass().getResource("/hierarchical-1.properties").toURI())};
+ hp = new HierarchicalProperties(files);
}
- public void testGetPropertyUsingURI() {
+ public void testGetProperty() {
String msg = "Returned value does not match expected value for this property!";
- assertEquals(msg, hp.getProperty("max-redirects"), "30");
- assertEquals(msg, hp.getProperty("http://bar.com", "brel-service", "max-redirects"), "40");
- assertEquals(msg, hp.getProperty("http://bar.com", "brel-service", "port-of-amsterdam", "max-redirects"), "60");
- assertEquals(msg, hp.getProperty("http://bar.com", "brel-service", "port-of-amsterdam", "timeout"), "40000");
- assertEquals(msg, hp.getProperty("http://foo.com", "film-service", "timeout"), "40000");
- assertEquals(msg, hp.getProperty("http://foo.com", "film-service", "port-of-cannes", "timeout"), "50000");
- assertEquals(msg, hp.getProperty("ode.a.property.beginning.with.the.prefix.but.no.service"), "so green or red?");
+ assertEquals(msg, "30", hp.getProperty("max-redirects"));
+ assertEquals(msg, "40", hp.getProperty("http://bar.com", "brel-service", "max-redirects"));
+ assertEquals(msg, "60", hp.getProperty("http://bar.com", "brel-service", "port-of-amsterdam", "max-redirects"));
+ assertEquals(msg, "40000", hp.getProperty("http://bar.com", "brel-service", "port-of-amsterdam", "timeout"));
+ assertEquals(msg, "40000", hp.getProperty("http://foo.com", "film-service", "timeout"));
+ assertEquals(msg, "hi!", hp.getProperty("http://hello.com", "a_service", "worldproperty"));
+ assertEquals(msg, "4", hp.getProperty("a_namespace_with_no_alias", "a_service", "poolsize"));
+ assertEquals("If the same property is set by two different files, the order of precedence should be the alphabetical order.", "60000", hp.getProperty("http://foo.com", "film-service", "port-of-cannes", "timeout"));
+ assertEquals("The prefix could be use without interfering", "so green or red?", hp.getProperty("ode.a.property.beginning.with.the.prefix.but.no.service"));
}
public void testGetProperties() {
final List keys = Arrays.asList("timeout", "max-redirects", "ode.a.property.beginning.with.the.prefix.but.no.service");
- Map map = hp.getProperties("foo", "film-service");
+ Map map = hp.getProperties("http://foo.com", "film-service");
assertEquals("Number of properties is wrong", keys.size(), map.size());
assertEquals("40000", map.get("timeout"));
assertEquals("30", map.get("max-redirects"));
Copied: ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-1.properties (from r700303, ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical.properties)
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-1.properties?p2=ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-1.properties&p1=ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical.properties&r1=700303&r2=700306&rev=700306&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical.properties (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-1.properties Mon Sep 29 16:34:52 2008
@@ -10,3 +10,5 @@
bar.brel-service.port-of-amsterdam.ode.max-redirects=60
ode.a.property.beginning.with.the.prefix.but.no.service=so green or red?
+
+a_namespace_with_no_alias.a_service.ode.poolsize=4
Added: ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-2.properties
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-2.properties?rev=700306&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-2.properties (added)
+++ ode/branches/APACHE_ODE_1.X/utils/src/test/resources/hierarchical-2.properties Mon Sep 29 16:34:52 2008
@@ -0,0 +1,8 @@
+# define a different alias for the same namespace
+alias.foo2=http://foo.com
+alias.hello=http://hello.com
+
+
+foo2.film-service.port-of-cannes.ode.timeout=60000
+
+hello.a_service.ode.worldproperty=hi!