incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r996322 - in /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl: ./ config/
Date Sun, 12 Sep 2010 14:42:52 GMT
Author: cziegeler
Date: Sun Sep 12 14:42:51 2010
New Revision: 996322

URL: http://svn.apache.org/viewvc?rev=996322&view=rev
Log:
SLING-1737 : Add state management for resources

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/AbstractConfigTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigurationPid.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=996322&r1=996321&r2=996322&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
Sun Sep 12 14:42:51 2010
@@ -44,12 +44,14 @@ public interface RegisteredResource exte
     /** Attribute key: configuration pid */
     String CONFIG_PID_ATTRIBUTE = "config.pid";
 
+    String getScheme();
+
     /**
-     * Return this data's id. It is opaque for the {@link OsgiInstaller}
+     * Return this data's url. It is opaque for the {@link OsgiInstaller}
      * but should uniquely identify the resource within the namespace of
      * the used installation mechanism.
      */
-    String getId();
+    String getURL();
 
     /**
      * Return the type of this resource.
@@ -89,9 +91,6 @@ public interface RegisteredResource exte
      */
     int getPriority();
     void cleanup();
-	String getURL();
-
-	String getScheme();
 
 	/** Attributes include the bundle symbolic name, bundle version, etc. */
 	Map<String, Object> getAttributes();

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=996322&r1=996321&r2=996322&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
Sun Sep 12 14:42:51 2010
@@ -60,8 +60,8 @@ public class RegisteredResourceImpl
 
     private static final long serialVersionUID = 4L;
 
-    /** The resource id. */
-    private final String id;
+    /** The resource url. */
+    private final String url;
     /** The installer scheme. */
 	private final String urlScheme;
 	/** The digest for the resource. */
@@ -136,7 +136,7 @@ public class RegisteredResourceImpl
 	        final String digest,
 	        final int priority,
 	        final String scheme) throws IOException {
-        this.id = id;
+        this.url = scheme + ':' + id;
         this.urlScheme = scheme;
 		this.resourceType = type;
 		this.priority = priority;
@@ -151,7 +151,7 @@ public class RegisteredResourceImpl
                 final String name = (String)attributes.get(Constants.BUNDLE_SYMBOLICNAME);
                 if (name == null) {
                     // not a bundle
-                    throw new IOException("Bundle resource does not contain a bundle " +
this.urlScheme + ":" + this.id);
+                    throw new IOException("Bundle resource does not contain a bundle " +
this.url);
                 }
                 this.digest = (digest != null && digest.length() > 0 ? digest
: id + ":" + computeDigest(this.dataFile));
                 entity = ENTITY_BUNDLE_PREFIX + name;
@@ -209,7 +209,7 @@ public class RegisteredResourceImpl
 	 * @see org.apache.sling.osgi.installer.impl.RegisteredResource#getURL()
 	 */
 	public String getURL() {
-		return this.getScheme() + ':' + this.getId();
+		return this.url;
 	}
 
 	/**
@@ -272,13 +272,6 @@ public class RegisteredResourceImpl
 	    return result;
 	}
 
-	/**
-	 * @see org.apache.sling.osgi.installer.impl.RegisteredResource#getId()
-	 */
-	public String getId() {
-	    return id;
-	}
-
     /**
      * @see org.apache.sling.osgi.installer.impl.RegisteredResource#getType()
      */

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/AbstractConfigTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/AbstractConfigTask.java?rev=996322&r1=996321&r2=996322&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/AbstractConfigTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/AbstractConfigTask.java
Sun Sep 12 14:42:51 2010
@@ -26,6 +26,7 @@ import java.util.Set;
 
 import org.apache.sling.osgi.installer.impl.OsgiInstallerTask;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
+import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -67,7 +68,15 @@ abstract class AbstractConfigTask extend
         Configuration result = null;
 
         if (cp.getFactoryPid() == null) {
-            result = ca.getConfiguration(cp.getConfigPid(), null);
+            if ( createIfNeeded ) {
+                result = ca.getConfiguration(cp.getConfigPid(), null);
+            } else {
+                String filter = "(" + Constants.SERVICE_PID + "=" + cp.getConfigPid() + ")";
+                Configuration[] configs = ca.listConfigurations( filter );
+                if ( configs != null && configs.length > 0 ) {
+                    result = configs[0];
+                }
+            }
         } else {
             Configuration configs[] = ca.listConfigurations(
                 "(|(" + ConfigurationPid.ALIAS_KEY
@@ -75,7 +84,7 @@ abstract class AbstractConfigTask extend
                 + "))");
 
             if (configs == null || configs.length == 0) {
-                if(createIfNeeded) {
+                if (createIfNeeded) {
                     result = ca.createFactoryConfiguration(cp.getConfigPid(), null);
                 }
             } else {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java?rev=996322&r1=996321&r2=996322&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
Sun Sep 12 14:42:51 2010
@@ -54,10 +54,12 @@ public class ConfigTaskCreator {
      * Create a task to install or uninstall a configuration.
 	 */
 	public OsgiInstallerTask createTask(final RegisteredResource toActivate) {
+	    // if there is no config admin, just return
+	//    if ( this.configAdminServiceTracker.getService() == null ) {
+    //        return null;
+	//    }
 	    final OsgiInstallerTask result;
 		if (toActivate.getState() == RegisteredResource.State.UNINSTALL) {
-		    // None of our resources are installable, remove corresponding config
-		    // (task simply does nothing if config does not exist)
 		    result = new ConfigRemoveTask(toActivate, this.configAdminServiceTracker);
 		} else {
 	        result = new ConfigInstallTask(toActivate, this.configAdminServiceTracker);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigurationPid.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigurationPid.java?rev=996322&r1=996321&r2=996322&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigurationPid.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigurationPid.java
Sun Sep 12 14:42:51 2010
@@ -43,7 +43,7 @@ public class ConfigurationPid implements
             pid = pid.substring(slashPos + 1);
         }
         // remove extension
-        if ( RegisteredResourceImpl.    isConfigExtension(RegisteredResourceImpl.getExtension(pid)))
{
+        if ( RegisteredResourceImpl.isConfigExtension(RegisteredResourceImpl.getExtension(pid)))
{
             final int lastDot = pid.lastIndexOf('.');
             pid = pid.substring(0, lastDot);
         }



Mime
View raw message