You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2010/04/01 01:26:22 UTC
svn commit: r929746 - in
/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi:
./ Resource.java ResourceConverter.java ResourceProcessor.java
ResourceResolver.java package.html packageinfo
Author: gnodet
Date: Wed Mar 31 23:26:22 2010
New Revision: 929746
URL: http://svn.apache.org/viewvc?rev=929746&view=rev
Log:
[subsystem] add a SPI proposal for subsystems
Added:
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceConverter.java
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceResolver.java
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/package.html
incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/packageinfo
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java Wed Mar 31 23:26:22 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed 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.aries.subsystem.spi;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.osgi.framework.Version;
+
+/**
+ * A resource is the representation of a uniquely identified and typed data.
+ * A bundle is represented as a resource with a type {@link #TYPE_BUNDLE}.
+ */
+public interface Resource {
+
+ /**
+ * Identify resources that are bundles.
+ */
+ public static final String TYPE_BUNDLE = "bundle";
+
+ /**
+ * Symbolic name of the resource
+ *
+ * @return
+ */
+ String getSymbolicName();
+
+ /**
+ * Version of the resource
+ *
+ * @return
+ */
+ Version getVersion();
+
+ /**
+ * Type of the resource
+ *
+ * @return
+ */
+ String getType();
+
+ /**
+ * Location of the resource.
+ * Can be the real url of the resource, but not necesseraly.
+ *
+ * @return
+ */
+ String getLocation();
+
+ /**
+ * Open the resource for reading.
+ *
+ * @return
+ * @throws IOException
+ */
+ InputStream open() throws IOException;
+
+}
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceConverter.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceConverter.java?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceConverter.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceConverter.java Wed Mar 31 23:26:22 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed 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.aries.subsystem.spi;
+
+import org.apache.aries.subsystem.SubsystemException;
+
+/**
+ * ResourceConverters are used to tranform resources into another kind of
+ * resources. For example, convert a blueprint xml configuration file
+ * into a deployable OSGi bundle
+ *
+ * Note that converters do not really *enable* anything. The ease the use
+ * of the subsystem archives, so we could remove those from the SPI.
+ */
+public interface ResourceConverter {
+
+ /**
+ * Check if the converter can convert a resource into the given type
+ * TODO: do we need that or should it be inferred from service properties?
+ *
+ * @param resource
+ * @param targetType
+ * @return
+ */
+ boolean canConvert(Resource resource, String targetType);
+
+ /**
+ * Convert a resource into the given type.
+ *
+ * @param resource
+ * @return <code>null</code> if the conversion is not supported
+ */
+ Resource convert(Resource resource, String targetType) throws SubsystemException;
+
+}
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java Wed Mar 31 23:26:22 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed 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.aries.subsystem.spi;
+
+import org.apache.aries.subsystem.Subsystem;
+import org.apache.aries.subsystem.SubsystemException;
+
+/**
+ * A ResourceProcessor is an object that can manage a given resource type.
+ * Processors must be registered in the OSGi registry.
+ *
+ * The purpose is to actually install a resource. There would be a processor
+ * for OSGi bundles (which may be internal), maybe we can also have a standard
+ * one for configurations for the ConfigAdmin.
+ */
+public interface ResourceProcessor {
+
+ void begin(Subsystem subsystem);
+
+ void process(Resource resource) throws SubsystemException;
+
+ void dropped(Resource resource) throws SubsystemException;
+
+ void prepare() throws SubsystemException;
+
+ void commit();
+
+ void rollback();
+
+}
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceResolver.java?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceResolver.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceResolver.java Wed Mar 31 23:26:22 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed 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.aries.subsystem.spi;
+
+import java.util.List;
+
+import org.apache.aries.subsystem.SubsystemException;
+
+/**
+ * The ResourceResolver object is used by the SubsystemAdmin to locate
+ * resources and resolve a subsystem (i.e. compute its transitive
+ * closure).
+ *
+ * The resolver is an important part, but I'm not sure it actually
+ * belong to the SPI, it may be an interface at the implementation level.
+ * Putting in the SPI allow to explain its role and put a name on this
+ * important actor, but this also mean that people will be allowed
+ * to deploy resolver themselves and expect it to be used.
+ *
+ */
+public interface ResourceResolver {
+
+ /**
+ * Find the given resource.
+ * Usually called with the parsed content of one of the subsystem headers.
+ * For example:
+ * my-bsn;version=1.0;type=subsystem
+ *
+ * @param resource the resource path with its associated metadata
+ * @return
+ */
+ Resource find(String resource) throws SubsystemException;
+
+ /**
+ * Resolve the subsystem by computing the list of resources
+ * that need to be installed in addition to the content resources.
+ *
+ * @param subsystemContent the resources that define the content of the subsystem
+ * @param subsystemResources the resources available from the subsystem archive
+ * @return
+ */
+ List<Resource> resolve(List<Resource> subsystemContent, List<Resource> subsystemResources) throws SubsystemException;
+
+}
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/package.html
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/package.html?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/package.html (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/package.html Wed Mar 31 23:26:22 2010
@@ -0,0 +1,9 @@
+<BODY>
+<p>Subsystem SPI Package Version 1.0.
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.apache.aries.subsystem.spi;version="[1.0,2.0)"
+</pre>
+</BODY>
Added: incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/packageinfo
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/packageinfo?rev=929746&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/packageinfo (added)
+++ incubator/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/packageinfo Wed Mar 31 23:26:22 2010
@@ -0,0 +1 @@
+version 1.0