You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/01/15 23:24:39 UTC
svn commit: r496518 - in /incubator/tuscany/java/sca:
kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/
services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/
services/discovery/jxta/src/main/java/org/a...
Author: meerajk
Date: Mon Jan 15 14:24:38 2007
New Revision: 496518
URL: http://svn.apache.org/viewvc?view=rev&rev=496518
Log:
Refactored discovery service interface
Modified:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java
incubator/tuscany/java/sca/services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/BonjourDiscoveryService.java
incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java?view=diff&rev=496518&r1=496517&r2=496518
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java Mon Jan 15 14:24:38 2007
@@ -18,7 +18,11 @@
*/
package org.apache.tuscany.spi.services.discovery;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.services.domain.DomainModelService;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
/**
* Abstract implementation of the discovery service.
@@ -31,6 +35,9 @@
/** Domain model service. */
private DomainModelService domainModelService;
+ /** Runtime info. */
+ private RuntimeInfo runtimeInfo;
+
/**
* Makes a reference to the domain model service available to the discovery service.
* This is required by the dicovery service to propogate any changes in the domain
@@ -38,16 +45,83 @@
*
* @param domainModelService Domain model service used for callbacks.
*/
+ @Autowire
public final void setDomainModelService(DomainModelService domainModelService) {
this.domainModelService = domainModelService;
}
/**
+ * Sets the runtime info for the runtime using the discovery service.
+ *
+ * @param runtimeInfo Runtime info for the runtime using the discovery service.
+ */
+ @Autowire
+ public final void setRuntimeInfo(RuntimeInfo runtimeInfo) {
+ this.runtimeInfo = runtimeInfo;
+ }
+
+ /**
+ * Starts the discovery service.
+ * @throws Any unexpected JXTA exception to bubble up the call stack.
+ */
+ @Init
+ public final void start() {
+
+ onStart();
+
+ Runnable shutdownHook = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook(new Thread(shutdownHook));
+
+ }
+
+ /**
+ * Stops the discovery service.
+ * @throws Any unexpected JXTA exception to bubble up the call stack.
+ */
+ @Destroy
+ public final void stop() {
+ onStop();
+ }
+
+ /**
* Gets the domain model service used by this discovery service.
+ *
* @return Domain model service used for callbacks.
*/
protected final DomainModelService getDomainModelService() {
return domainModelService;
+ }
+
+ /**
+ * Gets the runtime info for the runtime using the discovery service.
+ *
+ * @return Runtime info for the runtime using the discovery service.
+ */
+ protected final RuntimeInfo getRuntimeInfo() {
+ return runtimeInfo;
+ }
+
+ /**
+ * Required to be overridden by sub-classes.
+ *
+ */
+ protected abstract void onStart();
+
+ /**
+ * Required to be overridden by sub-classes.
+ *
+ */
+ protected abstract void onStop();
+
+ /**
+ * Shutdown hook.
+ */
+ private class ShutdownHook implements Runnable {
+
+ public void run() {
+ stop();
+ }
+
}
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java?view=diff&rev=496518&r1=496517&r2=496518
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java Mon Jan 15 14:24:38 2007
@@ -18,8 +18,7 @@
*/
package org.apache.tuscany.spi.services.discovery;
-import java.net.URI;
-
+import org.apache.tuscany.host.RuntimeInfo;
import org.apache.tuscany.spi.services.domain.DomainModelService;
/**
@@ -43,12 +42,20 @@
void setDomainModelService(DomainModelService domainModelService);
/**
- * Publish the event to indicate that the specified runtime is started.
+ * Sets the runtime info for the runtime using the discovery service.
*
- * @param domain Domain in which the runtime is participating.
- * @param profile Name of the runtime profile.
- * @param admin A flag to indicate this is the admin runtime.
+ * @param runtimeInfo Runtime info for the runtime using the discovery service.
+ */
+ void setRuntimeInfo(RuntimeInfo runtimeInfo);
+
+ /**
+ * Starts the discovery service.
+ */
+ void start();
+
+ /**
+ * Stops the discovery service.
*/
- void runtimeStarted(URI domain, String profile, boolean admin);
+ void stop();
}
Modified: incubator/tuscany/java/sca/services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/BonjourDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/BonjourDiscoveryService.java?view=diff&rev=496518&r1=496517&r2=496518
==============================================================================
--- incubator/tuscany/java/sca/services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/BonjourDiscoveryService.java (original)
+++ incubator/tuscany/java/sca/services/discovery/bonjour/src/main/java/org/apache/tuscany/service/discovery/bonjour/BonjourDiscoveryService.java Mon Jan 15 14:24:38 2007
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.service.discovery.bonjour;
-import java.net.URI;
-
import org.apache.tuscany.spi.services.discovery.AbstractDiscoveryService;
/**
@@ -29,15 +27,20 @@
*
*/
public class BonjourDiscoveryService extends AbstractDiscoveryService {
-
+
+ /**
+ * Starts the discovery service.
+ */
+ @Override
+ public void onStart() {
+ throw new UnsupportedOperationException();
+ }
+
/**
- * Publish the event to indicate that the specified runtime is started.
- *
- * @param domain Domain in which the runtime is participating.
- * @param profile Name of the runtime profile.
- * @param admin A flag to indicate this is the admin runtime.
+ * Stops the discovery service.
*/
- public void runtimeStarted(URI domain, String profile, boolean admin) {
+ @Override
+ public void onStop() {
throw new UnsupportedOperationException();
}
Modified: incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java?view=diff&rev=496518&r1=496517&r2=496518
==============================================================================
--- incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java (original)
+++ incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java Mon Jan 15 14:24:38 2007
@@ -24,10 +24,9 @@
import net.jxta.endpoint.Message;
import net.jxta.exception.PeerGroupException;
+import org.apache.tuscany.host.RuntimeInfo;
import org.apache.tuscany.spi.services.discovery.AbstractDiscoveryService;
import org.apache.tuscany.spi.services.domain.DomainModelService;
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Init;
/**
* Discovery service implemented using Apple bonjour.
@@ -39,24 +38,6 @@
/** Pipe receiver. */
private PipeReceiver pipeReceiver;
-
- /**
- * Publish the event to indicate that the specified runtime is started.
- *
- * @param domain Domain in which the runtime is participating.
- * @param profile Name of the runtime profile.
- * @param admin A flag to indicate this is the admin runtime.
- * @throws Any unexpected JXTA exception to bubble up the call stack.
- */
- public void runtimeStarted(URI domain, String profile, boolean admin) throws JxtaException {
-
- try {
- pipeReceiver.start(domain, profile);
- } catch (IOException ex) {
- throw new JxtaException(ex);
- }
-
- }
/**
* Callback method for message reception.
@@ -72,13 +53,26 @@
* Starts the discovery service.
* @throws Any unexpected JXTA exception to bubble up the call stack.
*/
- @Init
- public void start() throws JxtaException {
+ @Override
+ public void onStart() throws JxtaException {
try {
+
pipeReceiver = PipeReceiver.newInstance(this);
+
+ RuntimeInfo runtimeInfo = getRuntimeInfo();
+ URI domain = runtimeInfo.getDomain();
+ // TODO Move profile from StandaloneRuntimeInfo to RuntimeInfo
+ String profile = null;
+
+ pipeReceiver.start(domain, profile);
+
+ // TODO Use pipe sender to notify coming alive
+
} catch (PeerGroupException ex) {
throw new JxtaException(ex);
+ } catch (IOException ex) {
+ throw new JxtaException(ex);
}
}
@@ -86,8 +80,10 @@
/**
* Stops the discovery service.
*/
- @Destroy
- public void stop() {
+ @Override
+ protected void onStop() {
+
+ // TODO Use pipe sender to notify shutdown
pipeReceiver.stop();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org