Author: thobbs
Date: Thu Apr 12 15:05:14 2012
New Revision: 1325306

URL: http://svn.apache.org/viewvc?rev=1325306&view=rev
Log:
Config working for mahalo

Added:
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/LookupServiceConfiguration.java
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/TransactionServiceConfiguration.java
Removed:
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/ConventionalLookupServiceConfiguration.java
Modified:
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/CheckServices.java
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartLookupService.java
    
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartMahaloService.java

Modified: 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/CheckServices.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/CheckServices.java?rev=1325306&r1=1325305&r2=1325306&view=diff
==============================================================================
--- 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/CheckServices.java
 (original)
+++ 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/CheckServices.java
 Thu Apr 12 15:05:14 2012
@@ -48,7 +48,7 @@ public class CheckServices {
                checkHttpServer(port);
                checkLookupServices();
                checkSpaces();
-//             checkTransactionManagers();
+               checkTransactionManagers();
 //             
 //             checkAll();
        }

Modified: 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartLookupService.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartLookupService.java?rev=1325306&r1=1325305&r2=1325306&view=diff
==============================================================================
--- 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartLookupService.java
 (original)
+++ 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartLookupService.java
 Thu Apr 12 15:05:14 2012
@@ -22,7 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.logging.Logger;
 
-import 
org.apache.river.extra.easystart.config.ConventionalLookupServiceConfiguration;
+import org.apache.river.extra.easystart.config.LookupServiceConfiguration;
 
 import net.jini.config.Configuration;
 import net.jini.config.ConfigurationException;
@@ -85,7 +85,7 @@ public class StartLookupService {
 //             Configuration config = vcb.createConfiguration();
                
 //             Configuration config = new 
ConventionalLookupServiceConfiguration(new String[0]);
-               Configuration config = 
ConventionalLookupServiceConfiguration.config();
+               Configuration config = LookupServiceConfiguration.config();
                ServiceStarter.main(config);
                
        }

Modified: 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartMahaloService.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartMahaloService.java?rev=1325306&r1=1325305&r2=1325306&view=diff
==============================================================================
--- 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartMahaloService.java
 (original)
+++ 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/StartMahaloService.java
 Thu Apr 12 15:05:14 2012
@@ -19,10 +19,14 @@
 package org.apache.river.extra.easystart;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.logging.Logger;
 
+import net.jini.config.Configuration;
 import net.jini.config.ConfigurationException;
 
+import org.apache.river.extra.easystart.config.TransactionServiceConfiguration;
+
 import com.sun.jini.start.ServiceStarter;
 
 public class StartMahaloService {
@@ -36,8 +40,9 @@ public class StartMahaloService {
        /**
         * @param args
         * @throws ConfigurationException 
+        * @throws IOException 
         */
-       public static void main(String[] args) throws ConfigurationException {
+       public static void main(String[] args) throws ConfigurationException, 
IOException {
                validateArgs(args);
                
                final String RIVER_HOME = args[RIVER_HOME_INDEX];
@@ -46,7 +51,8 @@ public class StartMahaloService {
                log.info("Using RIVER_HOME="+RIVER_HOME);
                log.info("Using HTTP_PORT="+HTTP_PORT);
                
-               ServiceStarter.main(new MahaloServiceConfiguration());
+               Configuration config = TransactionServiceConfiguration.config();
+               ServiceStarter.main(config);
        }
 
        private static void validateArgs(String[] args) {

Added: 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/LookupServiceConfiguration.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/LookupServiceConfiguration.java?rev=1325306&view=auto
==============================================================================
--- 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/LookupServiceConfiguration.java
 (added)
+++ 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/LookupServiceConfiguration.java
 Thu Apr 12 15:05:14 2012
@@ -0,0 +1,107 @@
+package org.apache.river.extra.easystart.config;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationFile;
+
+import org.apache.river.config.builder.VelocityConfigurationBuilder;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+public class LookupServiceConfiguration extends ConfigurationFile {
+
+       private static final Logger LOGGER = 
Logger.getLogger(LookupServiceConfiguration.class.getName());
+       
+       public static LookupServiceConfiguration config() throws IOException, 
ConfigurationException {
+               
+               Options opts = new Options();
+               opts.PACKAGE_NAME.setOverride("com.sun.jini.reggie");
+//             opts.RIVER_HOME;  - no override for this
+               opts.HTTP_PORT.setOverride("8080");
+               opts.JINI_PORT.setOverride("4160");
+//             opts.MEMBER_GROUPS.add("Lester").add("Jeff");
+               opts.MEMBER_GROUPS.add("Chuck").add("Sarah");
+//             opts.LOOKUP_GROUPS.add("Chuck").add("Sarah");
+               
opts.SERVICE_IMPL.setOverride("com.sun.jini.reggie.TransientRegistrarImpl");
+               opts.CODEBASE.add("reggie-dl.jar").add("jsk-dl.jar");
+               
opts.CLASSPATH.add(opts.RIVER_HOME.getOverride()+"/lib/reggie.jar");
+               
opts.CLASSPATH.add(opts.RIVER_HOME.getOverride()+"/lib/jini-ext.jar");
+//             opts.POLICY.setOverride("secure.policy");
+//             opts.SERVER_EXPORTER.asJeriExporter("localhost", 4161);
+               
+               Properties p = new Properties();
+               p.load( 
VelocityConfigurationBuilder.class.getResourceAsStream("velocity.properties") );
+               VelocityEngine ve = new VelocityEngine(p);
+               VelocityContext context = new VelocityContext();
+               
+               StringBuilder options = new StringBuilder();
+               StringBuilder defaults = new StringBuilder();
+               String key = opts.PACKAGE_NAME.getOverride()+'.';
+               for(Setting setting : opts.OPTIONS) {
+                       String format = setting.getFormatter();
+                       if(setting.isServiceDescription()) {
+                       
+                       String name = key + setting.getName();
+                       
+                       options
+                               .append(",\"")
+                               .append(name)
+                               .append('=')
+                               .append(String.format(format, 
setting.getOverride()))
+                               .append("\"\n");
+                       
+                       defaults
+                               .append(setting.getName())
+                               .append('=')
+                               .append(String.format(format, 
setting.getDefault()))
+                               .append(";\n");
+                       } else {
+                       context.put(setting.getName(),
+                               String.format(format, setting.getOverride()));
+                       }
+               }
+               
+        context.put("defaults", defaults.toString());
+        context.put("options", options.toString());
+        
+        Template template = ve.getTemplate( 
Options.class.getResource("start.config").toExternalForm() );
+        
+        StringWriter sw = new StringWriter();
+
+        template.merge(context, sw);
+        
+        String s = sw.toString();
+        
+        LOGGER.warning(s);
+        
+        StringReader sr = new StringReader(s);
+        
+        return new LookupServiceConfiguration(sr, new 
String[0]);//opts.getOptionsArray());
+       }
+       
+       private LookupServiceConfiguration(Reader reader, String[] options) 
throws ConfigurationException {
+               super(reader,options);
+       }
+       
+//     public ConventionalLookupServiceConfiguration(String[] options) throws 
ConfigurationException {
+//             super(fileReader(), options);
+//     }
+
+       @Override
+       public Object getEntry(String component, String name, Class type,
+                       Object defaultValue) throws ConfigurationException {
+               if("initialMemberGroups".equals(name)) {
+//                     return new String[0];
+                       return super.getEntry(component, name, type, 
defaultValue);
+               } else {
+                       return super.getEntry(component, name, type, 
defaultValue);
+               }
+       }
+}

Added: 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/TransactionServiceConfiguration.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/TransactionServiceConfiguration.java?rev=1325306&view=auto
==============================================================================
--- 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/TransactionServiceConfiguration.java
 (added)
+++ 
river/jtsk/skunk/easystart/src-extra/org/apache/river/extra/easystart/config/TransactionServiceConfiguration.java
 Thu Apr 12 15:05:14 2012
@@ -0,0 +1,106 @@
+package org.apache.river.extra.easystart.config;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationFile;
+
+import org.apache.river.config.builder.VelocityConfigurationBuilder;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+public class TransactionServiceConfiguration extends ConfigurationFile {
+
+       private static final Logger LOGGER = 
Logger.getLogger(TransactionServiceConfiguration.class.getName());
+       
+       public static TransactionServiceConfiguration config() throws 
IOException, ConfigurationException {
+               
+               Options opts = new Options();
+               opts.PACKAGE_NAME.setOverride("com.sun.jini.mahalo");
+//             opts.RIVER_HOME;  - no override for this
+               opts.HTTP_PORT.setOverride("8080");
+//             opts.JINI_PORT.setOverride("4160");
+//             opts.MEMBER_GROUPS.add("Lester").add("Jeff");
+               opts.LOOKUP_GROUPS.add("Chuck").add("Sarah");
+               
opts.SERVICE_IMPL.setOverride("com.sun.jini.mahalo.TransientMahaloImpl");
+               opts.CODEBASE.add("mahalo-dl.jar").add("jsk-dl.jar");
+               
opts.CLASSPATH.add(opts.RIVER_HOME.getOverride()+"/lib/mahalo.jar");
+//             
opts.CLASSPATH.add(opts.RIVER_HOME.getOverride()+"/lib/jini-ext.jar");
+//             opts.POLICY.setOverride("secure.policy");
+//             opts.SERVER_EXPORTER.asJeriExporter("localhost", 4161);
+               
+               Properties p = new Properties();
+               p.load( 
VelocityConfigurationBuilder.class.getResourceAsStream("velocity.properties") );
+               VelocityEngine ve = new VelocityEngine(p);
+               VelocityContext context = new VelocityContext();
+               
+               StringBuilder options = new StringBuilder();
+               StringBuilder defaults = new StringBuilder();
+               String key = opts.PACKAGE_NAME.getOverride()+'.';
+               for(Setting setting : opts.OPTIONS) {
+                       String format = setting.getFormatter();
+                       if(setting.isServiceDescription()) {
+                       
+                       String name = key + setting.getName();
+                       
+                       options
+                               .append(",\"")
+                               .append(name)
+                               .append('=')
+                               .append(String.format(format, 
setting.getOverride()))
+                               .append("\"\n");
+                       
+                       defaults
+                               .append(setting.getName())
+                               .append('=')
+                               .append(String.format(format, 
setting.getDefault()))
+                               .append(";\n");
+                       } else {
+                       context.put(setting.getName(),
+                               String.format(format, setting.getOverride()));
+                       }
+               }
+               
+        context.put("defaults", defaults.toString());
+        context.put("options", options.toString());
+        
+        Template template = ve.getTemplate( 
Options.class.getResource("start.config").toExternalForm() );
+        
+        StringWriter sw = new StringWriter();
+
+        template.merge(context, sw);
+        
+        String s = sw.toString();
+        
+        LOGGER.warning(s);
+        
+        StringReader sr = new StringReader(s);
+        
+        return new TransactionServiceConfiguration(sr, new 
String[0]);//opts.getOptionsArray());
+       }
+       
+       private TransactionServiceConfiguration(Reader reader, String[] 
options) throws ConfigurationException {
+               super(reader,options);
+       }
+       
+//     public ConventionalLookupServiceConfiguration(String[] options) throws 
ConfigurationException {
+//             super(fileReader(), options);
+//     }
+
+       @Override
+       public Object getEntry(String component, String name, Class type,
+                       Object defaultValue) throws ConfigurationException {
+               if("initialMemberGroups".equals(name)) {
+//                     return new String[0];
+                       return super.getEntry(component, name, type, 
defaultValue);
+               } else {
+                       return super.getEntry(component, name, type, 
defaultValue);
+               }
+       }
+}


Reply via email to