Author: lresende
Date: Wed Jun 4 09:38:51 2008
New Revision: 663299
URL: http://svn.apache.org/viewvc?rev=663299&view=rev
Log:
TUSCANY-2362 - Applying remaining part of Ram's patch
Modified:
incubator/tuscany/java/sca/modules/implementation-resource/src/main/java/org/apache/tuscany/sca/implementation/resource/impl/ResourceImplementationProcessor.java
Modified:
incubator/tuscany/java/sca/modules/implementation-resource/src/main/java/org/apache/tuscany/sca/implementation/resource/impl/ResourceImplementationProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-resource/src/main/java/org/apache/tuscany/sca/implementation/resource/impl/ResourceImplementationProcessor.java?rev=663299&r1=663298&r2=663299&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-resource/src/main/java/org/apache/tuscany/sca/implementation/resource/impl/ResourceImplementationProcessor.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-resource/src/main/java/org/apache/tuscany/sca/implementation/resource/impl/ResourceImplementationProcessor.java
Wed Jun 4 09:38:51 2008
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.implementation.resource.impl;
@@ -53,20 +53,20 @@
public class ResourceImplementationProcessor implements
StAXArtifactProcessor<ResourceImplementation> {
private static final QName IMPLEMENTATION_RESOURCE = new
QName(Constants.SCA10_TUSCANY_NS, "implementation.resource");
private static final String MSG_LOCATION_MISSING = "Reading
implementation.resource - location attribute missing";
-
+
private ContributionFactory contributionFactory;
private ResourceImplementationFactory implementationFactory;
private Monitor monitor;
-
+
public ResourceImplementationProcessor(ModelFactoryExtensionPoint
modelFactories, Monitor monitor) {
contributionFactory =
modelFactories.getFactory(ContributionFactory.class);
implementationFactory =
modelFactories.getFactory(ResourceImplementationFactory.class);
this.monitor = monitor;
}
-
+
/**
* Report a exception.
- *
+ *
* @param problems
* @param message
* @param model
@@ -80,7 +80,7 @@
/**
* Report a error.
- *
+ *
* @param problems
* @param message
* @param model
@@ -90,7 +90,7 @@
Problem problem = new ProblemImpl(this.getClass().getName(),
"impl-resource-validation-messages", Severity.ERROR, model, message,
(Object[])messageParameters);
monitor.problem(problem);
}
- }
+ }
public QName getArtifactType() {
// Returns the QName of the XML element processed by this processor
@@ -103,11 +103,11 @@
}
public ResourceImplementation read(XMLStreamReader reader) throws
ContributionReadException, XMLStreamException {
-
+
// Read an <implementation.resource> element
-
+
// Create and initialize the resource implementation model
- ResourceImplementation implementation = null;
+ ResourceImplementation implementation = null;
// Read the location attribute specifying the location of the resources
String location = reader.getAttributeValue(null, "location");
@@ -127,12 +127,12 @@
break;
}
}
-
+
return implementation;
}
public void resolve(ResourceImplementation implementation, ModelResolver
resolver) throws ContributionResolveException {
-
+
// Resolve the resource directory location
Artifact artifact = contributionFactory.createArtifact();
artifact.setURI(implementation.getLocation());
@@ -146,18 +146,21 @@
error("ContributionResolveException", resolver, ce);
throw ce;
}
+ } else {
+ error("CouldNotResolveLocation", resolver,
implementation.getLocation());
+ throw new ContributionResolveException("Could not resolve
implementation.resource location: " + implementation.getLocation());
}
}
public void write(ResourceImplementation implementation, XMLStreamWriter
writer) throws ContributionWriteException, XMLStreamException {
-
+
// Write <implementation.resource>
writer.writeStartElement(IMPLEMENTATION_RESOURCE.getNamespaceURI(),
IMPLEMENTATION_RESOURCE.getLocalPart());
-
+
if (implementation.getLocation() != null) {
writer.writeAttribute("location", implementation.getLocation());
}
-
+
writer.writeEndElement();
}
}