Ignacio
I committed this but have a couple comments on the patch if you can
address them:
* rather than catch Exception can you explicitly catch
MalformedURLException
* rather than throw LoaderException, can you throw an
InvalidValueException (with the identifier set to the name)
* you probably should check for a null (missing) attribute value
I would also be good to test for these things in the test case - at
least check that scdlLocation is set in the returned impl.
Thanks
--
Jeremy
On Aug 29, 2006, at 12:26 PM, [EMAIL PROTECTED] wrote:
Author: jboynes
Date: Tue Aug 29 12:26:05 2006
New Revision: 438171
URL: http://svn.apache.org/viewvc?rev=438171&view=rev
Log:
apply patch from Ignacio Silva-Lupe for TUSCANY-673
Modified:
incubator/tuscany/java/sca/core/src/main/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoader.java
incubator/tuscany/java/sca/core/src/test/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoaderTestCase.java
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/
src/main/java/org/apache/tuscany/core/implementation/composite/
ImplementationCompositeLoader.java?
rev=438171&r1=438170&r2=438171&view=diff
======================================================================
========
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoader.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoader.java Tue Aug 29 12:26:05 2006
@@ -18,21 +18,22 @@
*/
package org.apache.tuscany.core.implementation.composite;
+import java.net.URL;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.osoa.sca.Version;
import org.osoa.sca.annotations.Constructor;
-import org.apache.tuscany.spi.extension.LoaderExtension;
-import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
import org.apache.tuscany.spi.loader.LoaderException;
-import org.apache.tuscany.spi.loader.LoaderUtil;
import org.apache.tuscany.spi.loader.LoaderRegistry;
-import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.CompositeImplementation;
/**
* Loader that handles an <implementation.composite> element.
@@ -41,7 +42,7 @@
*/
public class ImplementationCompositeLoader extends
LoaderExtension<CompositeImplementation> {
private static final QName IMPLEMENTATION_COMPOSITE =
- new QName(Version.XML_NAMESPACE_1_0,
"implementation.composite");
+ new QName(Version.XML_NAMESPACE_1_0,
"implementation.composite");
@Constructor({"registry"})
public ImplementationCompositeLoader(@Autowire LoaderRegistry
registry) {
@@ -59,8 +60,17 @@
assert IMPLEMENTATION_COMPOSITE.equals(reader.getName());
String name = reader.getAttributeValue(null, "name");
+ String scdlLocation = reader.getAttributeValue(null,
"scdlLocation");
CompositeImplementation impl = new CompositeImplementation();
impl.setName(name);
+ URL scdlLocationURL;
+ try {
+ scdlLocationURL = new URL
(deploymentContext.getScdlLocation(), scdlLocation);
+ } catch (Exception e) {
+ throw new LoaderException(e);
+ }
+ impl.setScdlLocation(scdlLocationURL);
+ impl.setClassLoader(deploymentContext.getClassLoader());
LoaderUtil.skipToEndElement(reader);
return impl;
}
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/
src/test/java/org/apache/tuscany/core/implementation/composite/
ImplementationCompositeLoaderTestCase.java?
rev=438171&r1=438170&r2=438171&view=diff
======================================================================
========
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoaderTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/
tuscany/core/implementation/composite/
ImplementationCompositeLoaderTestCase.java Tue Aug 29 12:26:05 2006
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.core.implementation.composite;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import javax.xml.namespace.QName;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import javax.xml.stream.XMLStreamException;
@@ -27,6 +30,7 @@
import org.jmock.MockObjectTestCase;
import org.osoa.sca.Version;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
import org.apache.tuscany.spi.loader.LoaderException;
import org.apache.tuscany.spi.model.CompositeImplementation;
@@ -40,14 +44,16 @@
private ImplementationCompositeLoader loader;
private Mock mockReader;
- public void testName() throws LoaderException,
XMLStreamException {
+ public void testName() throws LoaderException,
XMLStreamException, MalformedURLException {
String name = "foo";
mockReader.expects(once()).method("getName").will
(returnValue(IMPLEMENTATION_COMPOSITE));
mockReader.expects(atLeastOnce()).method("getAttributeValue")
.with(ANYTHING, ANYTHING)
.will(returnValue(name));
mockReader.expects(once()).method("next").will(returnValue
(END_ELEMENT));
- CompositeImplementation impl = loader.load(null,
(XMLStreamReader) mockReader.proxy(), null);
+ URL scdlLocation = new URL("http://META-INF/sca/");
+ CompositeImplementation impl = loader.load(null,
(XMLStreamReader) mockReader.proxy(),
+ new RootDeploymentContext(getClass().getClassLoader
(), null, null, scdlLocation));
assertEquals(name, impl.getName());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]