You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by si...@apache.org on 2011/01/11 12:12:35 UTC

svn commit: r1057581 - in /incubator/river/jtsk/trunk/src/org/apache/river/configbuilder: ConfigurationBuilder.java Example.java example.config

Author: sijskes
Date: Tue Jan 11 11:12:35 2011
New Revision: 1057581

URL: http://svn.apache.org/viewvc?rev=1057581&view=rev
Log:
template code

Added:
    incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java
    incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java
    incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config

Added: incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java?rev=1057581&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java (added)
+++ incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java Tue Jan 11 11:12:35 2011
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.configbuilder;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationFile;
+
+/**
+ *
+ * @author sim
+ */
+//TODO: abstract?
+public class ConfigurationBuilder
+{
+
+    public ConfigurationBuilder()
+    {
+    }
+
+    public String getConfigurationText() throws IOException
+    {
+        //TODO: create real implementation.
+
+        InputStream is = getClass().getResourceAsStream("example.config");
+        StringBuilder sb = new StringBuilder();
+        while(true) {
+            int c = is.read();
+            if( c < 0 ) {
+                break ;
+            }
+            sb.append((char)c);
+        }
+
+        return sb.toString();
+    }
+
+    public class ConfigurationFile2
+        extends ConfigurationFile
+    {
+
+        public ConfigurationFile2(Reader reader, String[] options, ClassLoader cl) throws ConfigurationException
+        {
+            super(reader, options, cl);
+        }
+
+        public ConfigurationFile2(Reader reader, String[] options) throws ConfigurationException
+        {
+            super(reader, options);
+        }
+
+        @Override
+        protected Object getSpecialEntry(String name) throws ConfigurationException
+        {
+            if( "$configuration".equals(name) ) {
+                return this ;
+            }
+            return super.getSpecialEntry(name);
+        }
+
+        @Override
+        protected Class getSpecialEntryType(String name) throws ConfigurationException
+        {
+            if( "$configuration".equals(name) ) {
+                return this.getClass();
+            }
+            return super.getSpecialEntryType(name);
+        }
+
+    }
+
+    public Configuration createConfiguration() throws ConfigurationException
+    {
+        try {
+            StringReader sr = new StringReader( getConfigurationText() );
+
+            final ConfigurationFile cf = new ConfigurationFile2(sr,null);
+
+            return cf ;
+        } catch( ConfigurationException c ) {
+            throw c ;
+        } catch( Exception e ) {
+            throw new ConfigurationException("",e);
+        }
+    }
+}

Added: incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java?rev=1057581&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java (added)
+++ incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java Tue Jan 11 11:12:35 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.configbuilder;
+
+import com.sun.jini.start.ServiceStarter;
+import java.security.Permission;
+import net.jini.config.ConfigurationException;
+
+/**
+ *
+ * @author sim
+ */
+public class Example {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws ConfigurationException
+    {
+        System.setSecurityManager(new SecurityManager() {
+
+            @Override
+            public void checkPermission(Permission perm)
+            {
+                //super.checkPermission(perm);
+            }
+
+        } );
+
+
+        ConfigurationBuilder cb = new ConfigurationBuilder();
+
+        //TODO: cb.setThisHere(true);
+        //TODO: cb.setThatThere(false);
+
+        ServiceStarter.main(cb.createConfiguration());
+    }
+
+}

Added: incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config?rev=1057581&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config (added)
+++ incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config Tue Jan 11 11:12:35 2011
@@ -0,0 +1,21 @@
+
+import com.sun.jini.start.NonActivatableServiceDescriptor;
+import com.sun.jini.start.ServiceDescriptor;
+
+com.sun.jini.start {
+    private static codebase = "" ; // "http://your_host:http_port/reggie-dl.jar"
+        //+ " http://your_host:http_port/jsk-dl.jar";
+    private static policy = "" ; // "config_dir/jsk-all.policy";
+    private static classpath = "" ; // "install_dir/lib/reggie.jar";
+
+    static serviceDescriptors = new ServiceDescriptor[] {
+        new NonActivatableServiceDescriptor(
+            codebase, policy, classpath,
+            "com.sun.jini.reggie.TransientRegistrarImpl",
+            $configuration, null, null )
+    };
+}
+
+com.sun.jini.reggie {
+    initialMemberGroups = new String[] { "your.group", "nonsecure.hello.example.jini.sun.com" };
+}



Re: svn commit: r1057581 - in /incubator/river/jtsk/trunk/src/org/apache/river/configbuilder: ConfigurationBuilder.java Example.java example.config

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 11-01-11 12:12, sijskes@apache.org wrote:
> Author: sijskes
> Date: Tue Jan 11 11:12:35 2011
> New Revision: 1057581
>
> URL: http://svn.apache.org/viewvc?rev=1057581&view=rev
> Log:
> template code
>
> Added:
>      incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/ConfigurationBuilder.java
>      incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/Example.java
>      incubator/river/jtsk/trunk/src/org/apache/river/configbuilder/example.config

Thats it folks. Time for some really good ideas now.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Den Haag: 28088397