summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java')
-rw-r--r--sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java b/sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
new file mode 100644
index 0000000000..8b9b1e8dc7
--- /dev/null
+++ b/sca-java-1.x/tags/kernel/2.0-alpha-incubating/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
@@ -0,0 +1,76 @@
+/*
+ * 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.extension;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.deployer.ContributionProcessor;
+import org.apache.tuscany.spi.deployer.ContributionProcessorRegistry;
+
+/**
+ * The base class for ContributionProcessor implementations
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+@Service(ContributionProcessor.class)
+public abstract class ContributionProcessorExtension implements ContributionProcessor {
+ /**
+ * The ContributionProcessorRegistry that this processor should register with; usually set by injection. This
+ * registry may also be used to process other sub-artifacts.
+ */
+ protected ContributionProcessorRegistry registry;
+
+ /**
+ * @param registry the registry to set
+ */
+ @Reference
+ public void setContributionProcessorRegistry(ContributionProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Initialize the processor. It registers itself to the registry by content type it supports.
+ */
+ @Init
+ public void start() {
+ registry.register(this.getContentType(), this);
+ }
+
+ /**
+ * Destroy the processor. It unregisters itself from the registry.
+ */
+ @Destroy
+ public void stop() {
+ registry.unregister(this.getContentType());
+ }
+
+ /**
+ * Returns the content type that this implementation can handle.
+ *
+ * @return the content type that this implementation can handle
+ */
+ public abstract String getContentType();
+
+}