You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by jo...@apache.org on 2006/10/14 15:13:52 UTC

svn commit: r463927 [2/2] - in /james/server/sandbox/osgi-experiments/conf_reader: ./ james/ james/conf/ lib/ src/ src/org/ src/org/apache/ src/org/apache/james/ src/org/apache/james/conf/ src/org/apache/james/conf/stub/

Added: james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfiguration.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfiguration.java?view=auto&rev=463927
==============================================================================
--- james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfiguration.java (added)
+++ james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfiguration.java Sat Oct 14 06:13:49 2006
@@ -0,0 +1,57 @@
+package org.apache.james.conf.stub;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+import org.apache.james.conf.ConfigurationUtil;
+import org.osgi.service.cm.Configuration;
+
+
+
+public class StubConfiguration implements Configuration {
+
+	String factoryPid;
+	String pid;
+	Dictionary properties;
+
+	public void delete() throws IOException {
+		throw new RuntimeException("not implemented");		
+	}
+
+	public String getBundleLocation() {
+		throw new RuntimeException("not implemented");	}
+
+	public String getFactoryPid() {
+		return factoryPid;
+	}
+
+	public String getPid() {
+		return pid;
+	}
+
+	public Dictionary getProperties() {
+		return properties;
+	}
+
+	public void setBundleLocation(String bundleLocation) {
+		throw new RuntimeException("not implemented");
+	}
+
+	public void update() throws IOException {
+		throw new RuntimeException("not implemented");
+	}
+
+	public void update(Dictionary properties) throws IOException {
+		this.properties=properties;
+	}
+
+	public void dump() {
+		ConfigurationUtil.dump(this);
+	}
+
+}

Added: james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfigurationAdmin.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfigurationAdmin.java?view=auto&rev=463927
==============================================================================
--- james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfigurationAdmin.java (added)
+++ james/server/sandbox/osgi-experiments/conf_reader/src/org/apache/james/conf/stub/StubConfigurationAdmin.java Sat Oct 14 06:13:49 2006
@@ -0,0 +1,69 @@
+package org.apache.james.conf.stub;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+public class StubConfigurationAdmin implements ConfigurationAdmin {
+
+	Map confs=new LinkedHashMap();
+	
+	Map factoryLastNumber=new HashMap();
+
+
+	public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
+		StubConfiguration configuration=new StubConfiguration();
+		configuration.factoryPid=factoryPid;
+		configuration.pid=factoryPid+"."+getNextFactoryNumber(factoryPid);
+		confs.put(configuration.pid,configuration);
+		return configuration;
+	}
+	
+	private int  getNextFactoryNumber(String factoryPid) {
+		Integer lastNumberObject=(Integer) factoryLastNumber.get(factoryPid);
+		if (lastNumberObject==null) {
+			lastNumberObject=new Integer(0);
+		}
+		int lastNumber=lastNumberObject.intValue();
+		factoryLastNumber.put(factoryPid,new Integer(lastNumber+1));
+		return lastNumber;
+	}
+
+	public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
+		throw new RuntimeException("not implemented");
+	}
+
+	public Configuration getConfiguration(String pid) throws IOException {
+		StubConfiguration configuration=(StubConfiguration) confs.get(pid);
+		if (configuration==null) {
+			configuration=new StubConfiguration();
+			configuration.pid=pid;
+			confs.put(configuration.pid, configuration);
+		}
+		return configuration;
+	}
+
+	public Configuration getConfiguration(String pid, String location) throws IOException {
+		throw new RuntimeException("not implemented");
+	}
+
+	public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException {
+		throw new RuntimeException("not implemented");
+	}
+	
+	public void dump() {
+		for (Iterator iter = confs.values().iterator(); iter.hasNext();) {
+			StubConfiguration configuration = (StubConfiguration) iter.next();
+			configuration.dump();
+		}
+	}
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org