river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtra...@apache.org
Subject svn commit: r1657704 - in /river/river-examples/river-examples/trunk/hello-service: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/river/ src/main/java/org/apache/river/examples/ src/main/java/org...
Date Thu, 05 Feb 2015 22:37:17 GMT
Author: gtrasuk
Date: Thu Feb  5 22:37:16 2015
New Revision: 1657704

URL: http://svn.apache.org/r1657704
Log:
Hello example service is complete (but not the client).

Added:
    river/river-examples/river-examples/trunk/hello-service/
    river/river-examples/river-examples/trunk/hello-service/pom.xml
    river/river-examples/river-examples/trunk/hello-service/src/
    river/river-examples/river-examples/trunk/hello-service/src/main/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/
    river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/GreeterService.java
    river/river-examples/river-examples/trunk/hello-service/src/main/resources/
    river/river-examples/river-examples/trunk/hello-service/src/test/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/apache/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/apache/river/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/apache/river/examples/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/apache/river/examples/hello/
    river/river-examples/river-examples/trunk/hello-service/src/test/java/org/apache/river/examples/hello/service/

Added: river/river-examples/river-examples/trunk/hello-service/pom.xml
URL: http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-service/pom.xml?rev=1657704&view=auto
==============================================================================
--- river/river-examples/river-examples/trunk/hello-service/pom.xml (added)
+++ river/river-examples/river-examples/trunk/hello-service/pom.xml Thu Feb  5 22:37:16 2015
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.river.examples</groupId>
+        <artifactId>river-examples</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.river.examples</groupId>
+    <artifactId>hello-service</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>hello-service</name>
+    <url>http://maven.apache.org</url>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <!-- Note that the versions for these are specified in the parent
+        pom's dependency management section. 
+        -->
+        <dependency>
+            <groupId>net.jini</groupId>
+            <artifactId>jsk-platform</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.jini</groupId>
+            <artifactId>jsk-lib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.jini</groupId>
+            <artifactId>jsk-resources</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.river</groupId>
+            <artifactId>start</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.river.examples</groupId>
+            <artifactId>hello-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathLayoutType>custom</classpathLayoutType>
+                            <customClasspathLayout>
+                                ${artifact.artifactId}.${artifact.extension}
+                            </customClasspathLayout>
+                        </manifest>
+                    </archive>
+                </configuration>
+               
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/GreeterService.java
URL: http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/GreeterService.java?rev=1657704&view=auto
==============================================================================
--- river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/GreeterService.java
(added)
+++ river/river-examples/river-examples/trunk/hello-service/src/main/java/org/apache/river/examples/hello/service/GreeterService.java
Thu Feb  5 22:37:16 2015
@@ -0,0 +1,80 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.apache.river.examples.hello.service;
+
+import com.sun.jini.config.Config;
+import com.sun.jini.start.LifeCycle;
+import java.io.IOException;
+import java.rmi.server.ExportException;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationProvider;
+import net.jini.core.entry.Entry;
+import net.jini.core.lookup.ServiceID;
+import net.jini.discovery.DiscoveryManagement;
+import net.jini.export.Exporter;
+import net.jini.lookup.JoinManager;
+import net.jini.lookup.ServiceIDListener;
+import net.jini.security.ProxyPreparer;
+import org.apache.river.examples.hello.api.Greeter;
+
+/**
+ *
+ * @author trasukg
+ */
+public class GreeterService implements Greeter, ServiceIDListener {
+
+    private static final String GREETER = "org.apache.river.examples.hello.greeter";
+
+    Configuration config = null;
+    Greeter myProxy = null;
+    Exporter exporter = null;
+    ProxyPreparer registrarPreparer = null;
+    JoinManager joinManager = null;
+    DiscoveryManagement discoveryManager = null;
+    Entry[] attributes = null;
+
+    public GreeterService(String[] args, final LifeCycle lc)
+            throws ConfigurationException, ExportException, IOException {
+        config = ConfigurationProvider.getInstance(args);
+
+        // Get the exporter and create our proxy.
+        exporter = (Exporter) Config.getNonNullEntry(config, GREETER, "exporter", Exporter.class);
+        myProxy = (Greeter) exporter.export(this);
+
+        /* 
+         The "discovery manager" looks after finding one or more service 
+         registrars for the join manager to use.
+         */
+        discoveryManager
+                = (DiscoveryManagement) config.getEntry(GREETER, "discoveryManager",
+                        DiscoveryManagement.class);
+        attributes = (Entry[]) config.getEntry(GREETER, "attributes", Entry[].class);
+
+        /*
+         Publish it using the join manager.
+         The "join manager" takes care of registering our service with any/all 
+         service registrars that appear in the workgroup.
+        
+         We don't have to do anything with it - just creating it starts the join process.
+         */
+        joinManager = new JoinManager(myProxy, attributes, this, discoveryManager, null,
config);
+        System.out.println("Hello service has been started successfully.");
+    }
+
+    public String sayHello(String name) throws IOException {
+        return "Hi there " + name;
+
+    }
+
+    ServiceID sid = null;
+
+    public void serviceIDNotify(ServiceID sid) {
+        this.sid = sid;
+        System.out.println("Hello service was assigned service id of " + sid);
+    }
+
+}



Mime
View raw message