river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sijs...@apache.org
Subject svn commit: r1058464 - in /incubator/river/jtsk/trunk/src/org/apache/river/config/builder: ConfigurationBuilder.java Example.java TextConfigurationBuilder.java
Date Thu, 13 Jan 2011 09:09:24 GMT
Author: sijskes
Date: Thu Jan 13 09:09:24 2011
New Revision: 1058464

URL: http://svn.apache.org/viewvc?rev=1058464&view=rev
Log:
moved ConfigurationBuilder and implemented

Added:
    incubator/river/jtsk/trunk/src/org/apache/river/config/builder/TextConfigurationBuilder.java
      - copied, changed from r1058036, incubator/river/jtsk/trunk/src/org/apache/river/config/builder/ConfigurationBuilder.java
Removed:
    incubator/river/jtsk/trunk/src/org/apache/river/config/builder/ConfigurationBuilder.java
Modified:
    incubator/river/jtsk/trunk/src/org/apache/river/config/builder/Example.java

Modified: incubator/river/jtsk/trunk/src/org/apache/river/config/builder/Example.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/config/builder/Example.java?rev=1058464&r1=1058463&r2=1058464&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/config/builder/Example.java (original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/config/builder/Example.java Thu Jan 13
09:09:24 2011
@@ -35,6 +35,7 @@ public class Example {
     {
         System.setSecurityManager(new SecurityManager() {
 
+            @Override
             public void checkPermission(Permission perm)
             {
                 // ignore
@@ -43,8 +44,10 @@ public class Example {
         } );
 
 
-        ConfigurationBuilder cb = new ConfigurationBuilder();
+        TextConfigurationBuilder cb = new TextConfigurationBuilder();
 
+        cb.setServicePort(1234);
+        
         //TODO: cb.setThisHere(true);
         //TODO: cb.setThatThere(false);
 

Copied: incubator/river/jtsk/trunk/src/org/apache/river/config/builder/TextConfigurationBuilder.java
(from r1058036, incubator/river/jtsk/trunk/src/org/apache/river/config/builder/ConfigurationBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/config/builder/TextConfigurationBuilder.java?p2=incubator/river/jtsk/trunk/src/org/apache/river/config/builder/TextConfigurationBuilder.java&p1=incubator/river/jtsk/trunk/src/org/apache/river/config/builder/ConfigurationBuilder.java&r1=1058036&r2=1058464&rev=1058464&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/config/builder/ConfigurationBuilder.java
(original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/config/builder/TextConfigurationBuilder.java
Thu Jan 13 09:09:24 2011
@@ -23,24 +23,87 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
+import java.util.HashMap;
 import net.jini.config.Configuration;
 import net.jini.config.ConfigurationException;
 import net.jini.config.ConfigurationFile;
+import net.jini.jeri.Endpoint;
+import net.jini.jeri.tcp.TcpEndpoint;
 
 /**
- *
  * @author sim
  */
-public class ConfigurationBuilder
+public class TextConfigurationBuilder
     implements ConfigurationFactory
 {
+    private HashMap<String,Object> specialEntryMap = new HashMap<String,Object>();
 
-    public ConfigurationBuilder()
+    private String serviceHost ;
+
+    private int servicePort = -1 ;
+
+    private String registryHost ;
+
+    private int registryPort = -1 ;
+
+    public TextConfigurationBuilder()
+    {
+        setServiceHost("localhost"); 
+        setRegistryHost("localhost");
+    }
+
+    public int getServicePort()
+    {
+        return servicePort;
+    }
+
+    public void setServicePort(int servicePort)
     {
+        this.servicePort = servicePort;
+    }
+
+    public String getServiceHost()
+    {
+        return serviceHost;
+    }
+
+    public void setServiceHost(String serviceHost)
+    {
+        this.serviceHost = serviceHost;
+    }
+
+    public String getRegistryHost()
+    {
+        return registryHost;
+    }
+
+    public void setRegistryHost(String registryHost)
+    {
+        this.registryHost = registryHost;
+    }
+
+    public int getRegistryPort()
+    {
+        return registryPort;
+    }
+
+    public void setRegistryPort(int registryPort)
+    {
+        this.registryPort = registryPort;
     }
 
     public String getConfigurationText() throws IOException
     {
+        {
+            Endpoint ep = TcpEndpoint.getInstance(serviceHost,servicePort);
+            specialEntryMap.put("$serviceEndpoint", ep);
+        }
+
+        {
+            Endpoint ep = TcpEndpoint.getInstance(registryHost,registryPort);
+            specialEntryMap.put("$registryEndpoint", ep);
+        }
+        
         //TODO: create real implementation.
 
         InputStream is = getClass().getResourceAsStream("example.config");
@@ -70,19 +133,31 @@ public class ConfigurationBuilder
             super(reader, options);
         }
 
+        @Override
         protected Object getSpecialEntry(String name) throws ConfigurationException
         {
             if( "$configuration".equals(name) ) {
                 return this ;
             }
+            if( specialEntryMap.containsKey(name) ) {
+                return specialEntryMap.get(name);
+            }
             return super.getSpecialEntry(name);
         }
 
+        @Override
         protected Class getSpecialEntryType(String name) throws ConfigurationException
         {
             if( "$configuration".equals(name) ) {
                 return this.getClass();
             }
+            if( specialEntryMap.containsKey(name) ) {
+                Object obj = specialEntryMap.get(name);
+                if( obj == null ) {
+                    return null ;
+                }
+                return obj.getClass();
+            }
             return super.getSpecialEntryType(name);
         }
 



Mime
View raw message