Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11871/src/java/net/sf/asterisk/fastagi
Modified Files:
DefaultAGIServer.java
Log Message:
Added configuration via fastagi.properties
Index: DefaultAGIServer.java
===================================================================
RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/DefaultAGIServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -p -r1.3 -r1.4
--- DefaultAGIServer.java 10 Mar 2005 21:31:30 -0000 1.3
+++ DefaultAGIServer.java 10 Mar 2005 23:42:35 -0000 1.4
@@ -17,6 +17,8 @@
package net.sf.asterisk.fastagi;
import java.io.IOException;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -29,6 +31,11 @@ import net.sf.asterisk.util.ThreadPool;
public class DefaultAGIServer implements AGIServer
{
/**
+ * The default name of the resource bundle that contains the config.
+ */
+ private static final String DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME = "fastagi";
+
+ /**
* The default bind port.
*/
private static final int DEFAULT_BIND_PORT = 4573;
@@ -82,6 +89,8 @@ public class DefaultAGIServer implements
this.bindPort = DEFAULT_BIND_PORT;
this.poolSize = DEFAULT_POOL_SIZE;
this.mappingStrategy = new ResourceBundleMappingStrategy();
+
+ loadConfig();
}
/**
@@ -117,6 +126,45 @@ public class DefaultAGIServer implements
this.mappingStrategy = mappingStrategy;
}
+ private void loadConfig()
+ {
+ ResourceBundle resourceBundle;
+
+ try
+ {
+ resourceBundle = ResourceBundle
+ .getBundle(DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME);
+ }
+ catch (MissingResourceException e)
+ {
+ return;
+ }
+
+ try
+ {
+ String bindPortString;
+
+ bindPortString = resourceBundle.getString("bindPort");
+ bindPort = Integer.parseInt(bindPortString);
+ }
+ catch(Exception e)
+ {
+ //swallow
+ }
+
+ try
+ {
+ String poolSizeString;
+
+ poolSizeString = resourceBundle.getString("poolSize");
+ poolSize = Integer.parseInt(poolSizeString);
+ }
+ catch(Exception e)
+ {
+ //swallow
+ }
+ }
+
protected ServerSocketFacade createServerSocket() throws IOException
{
return new ServerSocketFacadeImpl(bindPort, 0, null);
|