diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:26:33 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:26:33 +0000 |
commit | a40e527938d76ba71f211da7e327adb50384ba69 (patch) | |
tree | cb8f99f1727122b040a3f0fbb6649292b6a74302 /sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java | |
parent | 968721109881107520d7aefa91d7fcc0519d7739 (diff) |
Moving 1.x tags
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java')
-rw-r--r-- | sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java b/sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java new file mode 100644 index 0000000000..e2f2496091 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-notification/src/main/java/org/apache/tuscany/sca/implementation/notification/NotificationImplementationProcessor.java @@ -0,0 +1,99 @@ +/* + * 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.sca.implementation.notification; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; + +/** + * Loader for handling Notification <implementation.notification> elements. + * + * @version $Rev$ $Date$ + */ +public class NotificationImplementationProcessor implements StAXArtifactProcessor<NotificationImplementationImpl> { + + protected static final QName IMPLEMENTATION_NOTIFICATION = + new QName(Constants.SCA10_TUSCANY_NS, "implementation.notification"); + + private NotificationImplementationFactory implementationFactory; + + public NotificationImplementationProcessor(NotificationImplementationFactory implementationFactory) { + this.implementationFactory = implementationFactory; + } + + public QName getArtifactType() { + return IMPLEMENTATION_NOTIFICATION; + } + + public Class<NotificationImplementationImpl> getModelType() { + return NotificationImplementationImpl.class; + } + + public NotificationImplementationImpl read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + assert IMPLEMENTATION_NOTIFICATION.equals(reader.getName()); + String componentTypeName = reader.getAttributeValue(null, "name"); + String implementationType = reader.getAttributeValue(null, "type"); + + NotificationImplementationImpl implementation = implementationFactory.createNotificationImplementation(); + implementation.setComponentTypeName(componentTypeName); + implementation.setImplementationType(implementationType); + // Skip to end element + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && IMPLEMENTATION_NOTIFICATION.equals(reader.getName())) { + break; + } + } + + ComponentType componentType = new DefaultAssemblyFactory().createComponentType(); + componentType.setURI(componentTypeName + ".componentType"); + componentType.setUnresolved(true); + implementation.setComponentType(componentType); + + return implementation; + } + + public void resolve(NotificationImplementationImpl impl, ModelResolver resolver) throws ContributionResolveException { + ComponentType componentType = resolver.resolveModel(ComponentType.class, impl.getComponentType()); + + if (componentType.isUnresolved()) { + throw new ContributionResolveException("ComponentType still unresolved"); + } + impl.setComponentType(componentType); + impl.setUnresolved(false); + } + + public void write(NotificationImplementationImpl model, XMLStreamWriter outputSource) + throws ContributionWriteException, XMLStreamException { + + //FIXME Implement this method + } +} |