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/21 16:43:06 UTC
svn commit: r498364 -
/incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
Author: meerajk
Date: Sun Jan 21 07:43:05 2007
New Revision: 498364
URL: http://svn.apache.org/viewvc?view=rev&rev=498364
Log:
Added code to configure the platform. The configurator is
ecpected to be defined in the SCDL with the relavant proeprties
and auto-wired to the JXTA discovery service.
Modified:
incubator/tuscany/java/sca/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
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=498364&r1=498363&r2=498364
==============================================================================
--- 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 Sun Jan 21 07:43:05 2007
@@ -18,14 +18,18 @@
*/
package org.apache.tuscany.service.discovery.jxta;
+import java.io.File;
import java.io.IOException;
import java.net.URI;
+import javax.security.cert.CertificateException;
import javax.xml.stream.XMLStreamReader;
import net.jxta.exception.PeerGroupException;
+import net.jxta.platform.NetworkConfigurator;
import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.services.discovery.AbstractDiscoveryService;
/**
@@ -35,35 +39,50 @@
*
*/
public class JxtaDiscoveryService extends AbstractDiscoveryService {
-
+
/** Pipe receiver. */
private PipeReceiver pipeReceiver;
-
+
+ /** Network platform configurator. */
+ private NetworkConfigurator configurator;
+
+ /**
+ * Adds a network configurator for this service.
+ * @param configurator Network configurator.
+ */
+ @Autowire
+ public void setConfigurator(NetworkConfigurator configurator) {
+ this.configurator = configurator;
+ }
+
/**
* Starts the discovery service.
* @throws Any unexpected JXTA exception to bubble up the call stack.
*/
@Override
public void onStart() throws JxtaException {
-
+
try {
+
+ // Configure the platform
+ configure();
pipeReceiver = PipeReceiver.newInstance(this);
-
+
RuntimeInfo runtimeInfo = getRuntimeInfo();
URI domain = runtimeInfo.getDomain();
- String runtimeId = runtimeInfo.getRuntimeId();
-
+ String runtimeId = runtimeInfo.getRuntimeId();
+
pipeReceiver.start(domain, runtimeId);
-
+
} catch (PeerGroupException ex) {
throw new JxtaException(ex);
} catch (IOException ex) {
throw new JxtaException(ex);
}
-
+
}
-
+
/**
* Sends a message to the specified runtime.
*
@@ -73,13 +92,34 @@
public void sendMessage(String runtimeId, XMLStreamReader content) {
throw new UnsupportedOperationException();
}
-
+
/**
* Stops the discovery service.
*/
@Override
protected void onStop() {
pipeReceiver.stop();
+ }
+
+ /**
+ * Configures the platform.
+ *
+ */
+ private void configure() {
+
+ try {
+ if (!configurator.exists()) {
+ configurator.save();
+ } else {
+ File pc = new File(configurator.getHome(), "PlatformConfig");
+ configurator.load(pc.toURI());
+ configurator.save();
+ }
+ } catch (IOException ex) {
+ throw new JxtaException(ex);
+ } catch (CertificateException ex) {
+ throw new JxtaException(ex);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org