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/30 00:19:15 UTC
svn commit: r501228 - in /incubator/tuscany/java/sca:
kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/
kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/
runtime/services/discovery/jxta/src/main/java/org/apache/tu...
Author: meerajk
Date: Mon Jan 29 15:19:13 2007
New Revision: 501228
URL: http://svn.apache.org/viewvc?view=rev&rev=501228
Log:
added federated deployer
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java (with props)
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/runtime/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java?view=auto&rev=501228
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java Mon Jan 29 15:19:13 2007
@@ -0,0 +1,107 @@
+/*
+ * 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.tuscany.core.deployer.federation;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.component.ComponentException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.services.discovery.DiscoveryService;
+import org.apache.tuscany.spi.services.discovery.RequestListener;
+
+/**
+ * Federated deployer that deploys components in response to asynchronous
+ * messages from the federated domain.
+ *
+ * @version $Revision$ $Date$
+ *
+ */
+public class FederatedDeployer implements RequestListener {
+
+ /** QName of the message. */
+ private static final QName MESSAGE_TYPE = new QName("http://www.osoa.org/xmlns/sca/1.0", "composite");
+
+ /** Deployer. */
+ private Deployer deployer;
+
+ /**
+ * Deploys the SCDL.
+ * @param content SCDL content.
+ * @return Response to the request message.
+ *
+ * TODO Handle response messages.
+ */
+ public XMLStreamReader onRequest(XMLStreamReader content) {
+
+ // TODO get this from the SCDL content
+ final URL applicationScdl = null;
+ // TODO get this from somewhere
+ final ClassLoader applicationClassLoader = null;
+ // TODO get this from somewhere
+ final String name = null;
+ // TODO get this from somewhere
+ final CompositeComponent parent = null;
+
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(applicationScdl);
+ impl.setClassLoader(applicationClassLoader);
+ ComponentDefinition<CompositeImplementation> definition =
+ new ComponentDefinition<CompositeImplementation>(name, impl);
+
+ try {
+ deployer.deploy(parent, definition);
+ } catch (LoaderException ex) {
+ return null;
+ } catch (BuilderException ex) {
+ return null;
+ } catch (ComponentException ex) {
+ return null;
+ }
+
+ return null;
+ }
+
+ /**
+ * Injects the discovery service.
+ * @param discoveryService Discovery service to be injected.
+ */
+ @Autowire
+ public void setDiscoveryService(DiscoveryService discoveryService) {
+ discoveryService.registerRequestListener(MESSAGE_TYPE, this);
+ }
+
+ /**
+ * Injects the deployer.
+ * @param discoveryService Discovery service to be injected.
+ */
+ @Autowire
+ public void setDeployer(Deployer deployer) {
+ this.deployer = deployer;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/federation/FederatedDeployer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=501228&r1=501227&r2=501228
==============================================================================
--- 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 29 15:19:13 2007
@@ -81,7 +81,7 @@
* Starts the discovery service.
*/
@Init
- public final void start() {
+ public final void start() throws DiscoveryException {
onStart();
}
@@ -89,7 +89,7 @@
* Stops the discovery service.
*/
@Destroy
- public final void stop() {
+ public final void stop() throws DiscoveryException {
onStop();
}
@@ -126,12 +126,12 @@
* Required to be overridden by sub-classes.
*
*/
- protected abstract void onStart();
+ protected abstract void onStart() throws DiscoveryException;
/**
* Required to be overridden by sub-classes.
*
*/
- protected abstract void onStop();
+ protected abstract void onStop() throws DiscoveryException;
}
Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java?view=auto&rev=501228
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java Mon Jan 29 15:19:13 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.tuscany.spi.services.discovery;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Checked exception thrown during discovery operations.
+ *
+ * @version $Revision$ $Date$
+ *
+ */
+@SuppressWarnings("serial")
+public class DiscoveryException extends TuscanyException {
+
+ /**
+ * Initialises the exception message.
+ * @param message Message for the exception.
+ */
+ public DiscoveryException(String message) {
+ super(message);
+ }
+
+ /**
+ * Initialises the exception root cause.
+ * @param message Root cause for the exception.
+ */
+ public DiscoveryException(Throwable cause) {
+ super(cause);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=501228&r1=501227&r2=501228
==============================================================================
--- 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 29 15:19:13 2007
@@ -40,8 +40,9 @@
* @param runtimeId Runtime id of recipient.
* @param content Message content.
* @return The message id.
+ * @throws DiscoveryException In case of discovery errors.
*/
- int sendMessage(String runtimeId, XMLStreamReader content);
+ int sendMessage(String runtimeId, XMLStreamReader content) throws DiscoveryException;
/**
* Registers a request listener for async messages. Request listeners handle
Modified: incubator/tuscany/java/sca/runtime/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java?view=diff&rev=501228&r1=501227&r2=501228
==============================================================================
--- incubator/tuscany/java/sca/runtime/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java (original)
+++ incubator/tuscany/java/sca/runtime/services/discovery/jxta/src/main/java/org/apache/tuscany/service/discovery/jxta/JxtaDiscoveryService.java Mon Jan 29 15:19:13 2007
@@ -47,6 +47,7 @@
import org.apache.tuscany.service.discovery.jxta.stax.StaxHelper;
import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.services.discovery.AbstractDiscoveryService;
+import org.apache.tuscany.spi.services.discovery.DiscoveryException;
import org.apache.tuscany.spi.services.work.WorkScheduler;
import org.omg.CORBA.Any;
import org.osoa.sca.annotations.Property;
@@ -118,10 +119,14 @@
* @throws Any unexpected JXTA exception to bubble up the call stack.
*/
@Override
- public void onStart() throws JxtaException {
+ public void onStart() throws DiscoveryException {
workScheduler.scheduleWork(new Runnable() {
public void run() {
- startService();
+ try {
+ startService();
+ } catch(DiscoveryException ex) {
+ throw new JxtaException(ex);
+ }
}
});
}
@@ -129,7 +134,7 @@
/**
* Rusn the discovery service in a different thread.
*/
- private void startService() {
+ private void startService() throws DiscoveryException {
try {
@@ -143,14 +148,11 @@
peerListener.start();
} catch (PeerGroupException ex) {
- ex.printStackTrace();
- throw new JxtaException(ex);
+ throw new DiscoveryException(ex);
} catch (IOException ex) {
- ex.printStackTrace();
- throw new JxtaException(ex);
+ throw new DiscoveryException(ex);
} catch (Exception ex) {
- ex.printStackTrace();
- throw new JxtaException(ex);
+ throw new DiscoveryException(ex);
}
}
@@ -162,8 +164,9 @@
* broadcasted to all runtimes in the domain.
* @param content Message content.
* @return The message id.
+ * @throws DiscoveryException In case of discovery errors.
*/
- public int sendMessage(final String runtimeId, final XMLStreamReader content) {
+ public int sendMessage(final String runtimeId, final XMLStreamReader content) throws DiscoveryException {
if(content == null) {
throw new IllegalArgumentException("Content id is null");
@@ -173,7 +176,7 @@
if(runtimeId != null) {
peerID = peerListener.getPeerId(runtimeId);
if(peerID == null) {
- throw new JxtaException("Unrecognized runtime " + runtimeId);
+ throw new DiscoveryException("Unrecognized runtime " + runtimeId);
}
}
@@ -216,7 +219,7 @@
* Configures the platform.
*
*/
- private void configure() {
+ private void configure() throws DiscoveryException {
try {
@@ -234,9 +237,9 @@
}
} catch (IOException ex) {
- throw new JxtaException(ex);
+ throw new DiscoveryException(ex);
} catch (CertificateException ex) {
- throw new JxtaException(ex);
+ throw new DiscoveryException(ex);
}
}
@@ -261,7 +264,7 @@
if (auth.isReadyForJoin()){
membership.join(auth);
} else {
- throw new JxtaException("Unable to join domain group");
+ throw new DiscoveryException("Unable to join domain group");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org