felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r953419 [2/2] - in /felix/sandbox/rickhall/framework-vb-2/src/main: java/org/apache/felix/framework/ java/org/apache/felix/framework/cache/ java/org/apache/felix/framework/ext/ java/org/apache/felix/framework/resolver/ java/org/apache/felix...
Date Thu, 10 Jun 2010 18:53:24 GMT
Added: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java?rev=953419&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
(added)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
Thu Jun 10 18:53:23 2010
@@ -0,0 +1,116 @@
+/*
+ * 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.felix.framework;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import org.apache.felix.framework.Felix.FelixResolver;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.ext.VBWire;
+import org.apache.felix.framework.ext.VirtualModule;
+import org.apache.felix.framework.resolver.Content;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.resolver.Wire;
+import org.apache.felix.framework.util.SecureAction;
+import org.apache.felix.framework.util.manifestparser.CapabilityImpl;
+import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+public class UnmanagedModuleImpl extends AbstractModuleImpl
+{
+    private final VirtualModule m_vm;
+
+    public UnmanagedModuleImpl(
+        Logger logger, Map configMap,
+        Bundle bundle, String id, Map headerMap, VirtualModule vm)
+        throws BundleException
+    {
+        super(logger, configMap, bundle, id, headerMap);
+        m_vm = vm;
+    }
+
+    public VirtualModule getVirtualModule()
+    {
+        return m_vm;
+    }
+
+    public Content getContent()
+    {
+        return null;
+    }
+
+    @Override
+    public synchronized void resolve(List<VBWire> wires)
+        throws BundleException
+    {
+        m_vm.resolve(wires);
+        super.resolve(wires);
+    }
+
+    public Class loadClass(String name) throws ClassNotFoundException
+    {
+        return m_vm.loadClass(name);
+    }
+
+    public URL getResource(String name)
+    {
+        return m_vm.getResource(name);
+    }
+
+    public Enumeration<URL> getResources(String name)
+    {
+        return m_vm.getResources(name);
+    }
+
+    public URL getEntry(String name)
+    {
+        return m_vm.getEntry(name);
+    }
+
+    public Enumeration<String> getEntryPaths(String path)
+    {
+        return m_vm.getEntryPaths(path);
+    }
+
+    public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
+    {
+        return m_vm.findEntries(path, path, isResolved());
+    }
+
+    public boolean hasInputStream(int index, String urlPath) throws IOException
+    {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public InputStream getInputStream(int index, String urlPath) throws IOException
+    {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
\ No newline at end of file

Copied: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/VirtualModuleContextImpl.java
(from r952665, felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/VirtualModuleContextImpl.java?p2=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/VirtualModuleContextImpl.java&p1=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java&r1=952665&r2=953419&rev=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/VirtualModuleContextImpl.java
Thu Jun 10 18:53:23 2010
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -6,9 +6,9 @@
  * 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
@@ -16,12 +16,28 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.framework.resolver;
+package org.apache.felix.framework;
 
-public class ResourceNotFoundException extends Exception
+import java.io.File;
+import org.apache.felix.framework.ext.VirtualModuleContext;
+import org.osgi.framework.Bundle;
+
+public class VirtualModuleContextImpl implements VirtualModuleContext
 {
-    public ResourceNotFoundException(String msg)
+    private final Bundle m_bundle;
+
+    VirtualModuleContextImpl(Bundle bundle)
+    {
+        m_bundle = bundle;
+    }
+
+    public Bundle getBundle()
+    {
+        return m_bundle;
+    }
+
+    public File getDataFile()
     {
-        super(msg);
+        throw new UnsupportedOperationException("Not supported yet.");
     }
 }
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleArchive.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
Thu Jun 10 18:53:23 2010
@@ -146,6 +146,29 @@ public class BundleArchive
         revise(m_originalLocation, is);
     }
 
+    public BundleArchive(
+        Logger logger, Map configMap, File archiveRootDir,
+        long id, String location, Map headers)
+        throws Exception
+    {
+        m_logger = logger;
+        m_configMap = configMap;
+        m_archiveRootDir = archiveRootDir;
+        m_id = id;
+        if (m_id <= 0)
+        {
+            throw new IllegalArgumentException(
+                "Bundle ID cannot be less than or equal to zero.");
+        }
+        m_originalLocation = location;
+
+        // Save state.
+        initialize();
+
+        // Add a revision for the content.
+        revise(m_originalLocation, headers);
+    }
+
     /**
      * <p>
      * This constructor is called when an archive for a bundle is being
@@ -202,7 +225,7 @@ public class BundleArchive
         // to read the location from the current revision - if that fails we
         // likely have an old bundle cache and read the location the old way.
         // The next revision will update the bundle cache.
-        revise(getRevisionLocation(revisionCount - 1), null);
+        revise(getRevisionLocation(revisionCount - 1), (InputStream) null);
     }
 
     /**
@@ -649,6 +672,32 @@ public class BundleArchive
         }
     }
 
+    public synchronized void revise(String location, Map headers)
+        throws Exception
+    {
+        File revisionRootDir = new File(m_archiveRootDir,
+            REVISION_DIRECTORY + getRefreshCount() + "." + getRevisionCount());
+
+        BundleRevision revision =
+            new VirtualRevision(
+                m_logger, m_configMap, revisionRootDir, location, headers);
+
+        setRevisionLocation(location, (m_revisions == null) ? 0 : m_revisions.length);
+
+        // Add new revision to revision array.
+        if (m_revisions == null)
+        {
+            m_revisions = new BundleRevision[] { revision };
+        }
+        else
+        {
+            BundleRevision[] tmp = new BundleRevision[m_revisions.length + 1];
+            System.arraycopy(m_revisions, 0, tmp, 0, m_revisions.length);
+            tmp[m_revisions.length] = revision;
+            m_revisions = tmp;
+        }
+    }
+
     /**
      * <p>
      * This method undoes the previous revision to the archive; this method will

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleCache.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleCache.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleCache.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/BundleCache.java
Thu Jun 10 18:53:23 2010
@@ -186,6 +186,39 @@ public class BundleCache
         }
     }
 
+    public BundleArchive create(long id, String location, Map headers)
+        throws Exception
+    {
+        File cacheDir = determineCacheDir(m_configMap);
+
+        // Construct archive root directory.
+        File archiveRootDir =
+            new File(cacheDir, BUNDLE_DIR_PREFIX + Long.toString(id));
+
+        try
+        {
+            // Create the archive and add it to the list of archives.
+            BundleArchive ba =
+                new BundleArchive(
+                    m_logger, m_configMap, archiveRootDir, id, location, headers);
+            return ba;
+        }
+        catch (Exception ex)
+        {
+            if (m_secureAction.fileExists(archiveRootDir))
+            {
+                if (!BundleCache.deleteDirectoryTree(archiveRootDir))
+                {
+                    m_logger.log(
+                        Logger.LOG_ERROR,
+                        "Unable to delete the archive directory: "
+                            + archiveRootDir);
+                }
+            }
+            throw ex;
+        }
+    }
+
     /**
      * Provides the system bundle access to its private storage area; this
      * special case is necessary since the system bundle is not really a

Added: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/VirtualRevision.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/VirtualRevision.java?rev=953419&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/VirtualRevision.java
(added)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/cache/VirtualRevision.java
Thu Jun 10 18:53:23 2010
@@ -0,0 +1,112 @@
+/*
+ * 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.felix.framework.cache;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.felix.framework.Logger;
+import org.apache.felix.framework.resolver.Content;
+
+public class VirtualRevision extends BundleRevision
+{
+    private static final String HEADERS_FILE = "headers.map";
+
+    private final Map m_headers;
+
+    public VirtualRevision(
+        Logger logger, Map configMap, File revisionRootDir,
+        String location, Map headers)
+        throws Exception
+    {
+        super(logger, configMap, revisionRootDir, location);
+        m_headers = headers;
+
+        initialize();
+
+        File headerFile = new File(revisionRootDir, HEADERS_FILE);
+        FileWriter fw = null;
+        BufferedWriter bw = null;
+        try
+        {
+            fw = new FileWriter(headerFile);
+            bw = new BufferedWriter(fw);
+            bw.write(headers.toString());
+        }
+        finally
+        {
+            if (fw != null)
+            {
+                try
+                {
+                    fw.close();
+                }
+                catch (IOException ex)
+                {
+                    // Not much we can do.
+                }
+            }
+            if (bw != null)
+            {
+                try
+                {
+                    bw.close();
+                }
+                catch (IOException ex)
+                {
+                    // Not much we can do.
+                }
+            }
+        }
+    }
+
+    @Override
+    public Map getManifestHeader() throws Exception
+    {
+        return m_headers;
+    }
+
+    @Override
+    public Content getContent() throws Exception
+    {
+        return null;
+    }
+
+    @Override
+    protected void close() throws Exception
+    {
+    }
+
+    private void initialize() throws IOException
+    {
+        // If the revision directory does not exist, then create it.
+        if (!BundleCache.getSecureAction().fileExists(getRevisionRootDir()))
+        {
+            if (!BundleCache.getSecureAction().mkdir(getRevisionRootDir()))
+            {
+                getLogger().log(
+                    Logger.LOG_ERROR,
+                    getClass().getName() + ": Unable to create revision directory.");
+                throw new IOException("Unable to create archive directory.");
+            }
+        }
+    }
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
Thu Jun 10 18:53:23 2010
@@ -18,13 +18,15 @@
  */
 package org.apache.felix.framework.ext;
 
+import java.util.Map;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 
 public interface FelixBundleContext extends BundleContext
 {
-    public void addRequirement(String s) throws BundleException;
-    public void removeRequirement() throws BundleException;
-    public void addCapability() throws BundleException;
-    public void removeCapability() throws BundleException;
+    VirtualModuleContext installBundle(String location, Map headers, VirtualModule vm)
+        throws BundleException;
+    VirtualModuleContext reinstallBundle(Bundle bundle, VirtualModule vm)
+        throws BundleException;
 }
\ No newline at end of file

Copied: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/ResourceNotFoundException.java
(from r952665, felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/ResourceNotFoundException.java?p2=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/ResourceNotFoundException.java&p1=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java&r1=952665&r2=953419&rev=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/ResourceNotFoundException.java
Thu Jun 10 18:53:23 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.framework.resolver;
+package org.apache.felix.framework.ext;
 
 public class ResourceNotFoundException extends Exception
 {

Copied: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VBWire.java
(from r952665, felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VBWire.java?p2=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VBWire.java&p1=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java&r1=952665&r2=953419&rev=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VBWire.java
Thu Jun 10 18:53:23 2010
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -6,9 +6,9 @@
  * 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
@@ -16,12 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.framework.resolver;
+package org.apache.felix.framework.ext;
 
-public class ResourceNotFoundException extends Exception
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface VBWire
 {
-    public ResourceNotFoundException(String msg)
-    {
-        super(msg);
-    }
+    public Class getClass(String name) throws ClassNotFoundException;
+    public URL getResource(String name) throws ResourceNotFoundException;
+    public Enumeration getResources(String name) throws ResourceNotFoundException;
 }
\ No newline at end of file

Copied: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
(from r952665, felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModule.java?p2=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModule.java&p1=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java&r1=952665&r2=953419&rev=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/FelixBundleContext.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
Thu Jun 10 18:53:23 2010
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -6,9 +6,9 @@
  * 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
@@ -18,13 +18,23 @@
  */
 package org.apache.felix.framework.ext;
 
-import org.osgi.framework.BundleContext;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import org.apache.felix.framework.resolver.Wire;
+import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleException;
 
-public interface FelixBundleContext extends BundleContext
+public interface VirtualModule
 {
-    public void addRequirement(String s) throws BundleException;
-    public void removeRequirement() throws BundleException;
-    public void addCapability() throws BundleException;
-    public void removeCapability() throws BundleException;
+    // TODO: VB - How to signal a refresh?
+    void resolve(List<VBWire> wires) throws BundleException;
+
+    Class loadClass(String name) throws ClassNotFoundException;
+    URL getResource(String name);
+    Enumeration getResources(String name);
+
+    URL getEntry(String entry);
+    Enumeration<String> getEntryPaths(String path);
+    Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);
 }
\ No newline at end of file

Copied: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModuleContext.java
(from r952665, felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModuleContext.java?p2=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModuleContext.java&p1=felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java&r1=952665&r2=953419&rev=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/ext/VirtualModuleContext.java
Thu Jun 10 18:53:23 2010
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -6,9 +6,9 @@
  * 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
@@ -16,12 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.framework.resolver;
+package org.apache.felix.framework.ext;
 
-public class ResourceNotFoundException extends Exception
+import java.io.File;
+import org.osgi.framework.Bundle;
+
+public interface VirtualModuleContext
 {
-    public ResourceNotFoundException(String msg)
-    {
-        super(msg);
-    }
+    Bundle getBundle();
+    File getDataFile();
 }
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Module.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Module.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Module.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Module.java
Thu Jun 10 18:53:23 2010
@@ -26,11 +26,14 @@ import java.util.List;
 import java.util.Map;
 import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.ext.VBWire;
+import org.apache.felix.framework.ext.VirtualModule;
 import org.apache.felix.framework.util.manifestparser.R4Library;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 import org.osgi.framework.Version;
 
-public interface Module
+public interface Module extends VirtualModule
 {
     final static int EAGER_ACTIVATION = 0;
     final static int LAZY_ACTIVATION = 1;
@@ -49,16 +52,19 @@ public interface Module
     // Run-time data access methods.
     Bundle getBundle();
     String getId();
-    List<Wire> getWires();
+    List<VBWire> getWires();
+    void resolve(List<VBWire> wires) throws BundleException;
     boolean isResolved();
     Object getSecurityContext();
 
     // Content access methods.
     Content getContent();
-    Class getClassByDelegation(String name) throws ClassNotFoundException;
-    URL getResourceByDelegation(String name);
-    Enumeration getResourcesByDelegation(String name);
+    Class loadClass(String name) throws ClassNotFoundException;
+    URL getResource(String name);
+    Enumeration<URL> getResources(String name);
     URL getEntry(String name);
+    Enumeration<String> getEntryPaths(String path);
+    Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);
 
     // TODO: ML - For expediency, the index argument was added to these methods
     // but it is not clear that this makes sense in the long run. This needs to

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Thu Jun 10 18:53:23 2010
@@ -28,13 +28,13 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeSet;
-import org.apache.felix.framework.FelixResolverState;
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.capabilityset.Attribute;
 import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.capabilityset.Directive;
 import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.ext.VBWire;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.RequirementImpl;
 import org.osgi.framework.Constants;
@@ -248,10 +248,10 @@ public class ResolverImpl implements Res
         }
         // If any of our wires have this package, then we cannot
         // attempt to dynamically import it.
-        List<Wire> wires = module.getWires();
+        List<VBWire> wires = module.getWires();
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
-            if (wires.get(i).hasPackage(pkgName))
+            if (((Wire) wires.get(i)).hasPackage(pkgName))
             {
                 return null;
             }
@@ -518,10 +518,10 @@ public class ResolverImpl implements Res
         if (module.isResolved())
         {
             // Use wires to get actual requirements and satisfying capabilities.
-            for (Wire wire : module.getWires())
+            for (VBWire wire : module.getWires())
             {
-                reqs.add(wire.getRequirement());
-                caps.add(wire.getCapability());
+                reqs.add(((Wire) wire).getRequirement());
+                caps.add(((Wire) wire).getCapability());
             }
 
             // Since the module is resolved, it could be dynamically importing,

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Wire.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Wire.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Wire.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/Wire.java
Thu Jun 10 18:53:23 2010
@@ -18,12 +18,14 @@
  */
 package org.apache.felix.framework.resolver;
 
+import org.apache.felix.framework.ext.ResourceNotFoundException;
 import java.net.URL;
 import java.util.Enumeration;
 import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.ext.VBWire;
 
-public interface Wire
+public interface Wire extends VBWire
 {
     /**
      * Returns the importing module.

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireImpl.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
Thu Jun 10 18:53:23 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework.resolver;
 
+import org.apache.felix.framework.ext.ResourceNotFoundException;
 import java.net.URL;
 import java.util.Enumeration;
 import org.apache.felix.framework.capabilityset.Capability;
@@ -96,7 +97,7 @@ public class WireImpl implements Wire
             // package has multiple sources).
             if (((CapabilityImpl) m_cap).isIncluded(name))
             {
-                clazz = m_exporter.getClassByDelegation(name);
+                clazz = m_exporter.loadClass(name);
             }
 
             // If no class was found, then we must throw an exception
@@ -129,7 +130,7 @@ public class WireImpl implements Wire
             // Delegate to the exporting module, rather than its
             // content, so that it can follow any internal wires it may have
             // (e.g., if the package has multiple sources).
-            url = m_exporter.getResourceByDelegation(name);
+            url = m_exporter.getResource(name);
 
             // If no resource was found, then we must throw an exception
             // since the exporter for this package did not contain the
@@ -158,7 +159,7 @@ public class WireImpl implements Wire
         if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
             m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
         {
-            urls = m_exporter.getResourcesByDelegation(name);
+            urls = m_exporter.getResources(name);
 
             // If no resource was found, then we must throw an exception
             // since the exporter for this package did not contain the

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
Thu Jun 10 18:53:23 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework.resolver;
 
+import org.apache.felix.framework.ext.ResourceNotFoundException;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.List;
@@ -94,7 +95,7 @@ public class WireModuleImpl implements W
         {
             try
             {
-                Class clazz = m_exporter.getClassByDelegation(name);
+                Class clazz = m_exporter.loadClass(name);
                 if (clazz != null)
                 {
                     return clazz;
@@ -120,7 +121,7 @@ public class WireModuleImpl implements W
         String pkgName = Util.getResourcePackage(name);
         if (m_packages.contains(pkgName))
         {
-            URL url = m_exporter.getResourceByDelegation(name);
+            URL url = m_exporter.getResource(name);
             if (url != null)
             {
                 return url;
@@ -144,7 +145,7 @@ public class WireModuleImpl implements W
         // See if we have a resolved package for the resource's package.
         if (m_packages.contains(pkgName))
         {
-            Enumeration urls = m_exporter.getResourcesByDelegation(name);
+            Enumeration urls = m_exporter.getResources(name);
             if (urls != null)
             {
                 return urls;

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/util/Util.java?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/util/Util.java
(original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/java/org/apache/felix/framework/util/Util.java
Thu Jun 10 18:53:23 2010
@@ -23,7 +23,6 @@ import java.net.URL;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -33,6 +32,7 @@ import org.apache.felix.framework.capabi
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.ext.VBWire;
 import org.apache.felix.framework.resolver.Wire;
 
 import org.osgi.framework.Bundle;
@@ -318,13 +318,13 @@ public class Util
         return matching;
     }
 
-    public static Wire getWire(Module m, String name)
+    public static VBWire getWire(Module m, String name)
     {
-        List<Wire> wires = m.getWires();
+        List<VBWire> wires = m.getWires();
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
-            if (wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE)
&&
-                wires.get(i).getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue().equals(name))
+            if (((Wire) wires.get(i)).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE)
&&
+                ((Wire) wires.get(i)).getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue().equals(name))
             {
                 return wires.get(i);
             }

Modified: felix/sandbox/rickhall/framework-vb-2/src/main/resources/default.properties
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-vb-2/src/main/resources/default.properties?rev=953419&r1=953418&r2=953419&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-vb-2/src/main/resources/default.properties (original)
+++ felix/sandbox/rickhall/framework-vb-2/src/main/resources/default.properties Thu Jun 10
18:53:23 2010
@@ -26,7 +26,9 @@ ee-1.5=J2SE-1.5,J2SE-1.4,J2SE-1.3
 ee-1.4=J2SE-1.4,J2SE-1.3
 ee-1.3=J2SE-1.3
 
-org.osgi.framework.system.packages=org.osgi.framework; version=1.5.0, \
+org.osgi.framework.system.packages= \
+ org.apache.felix.framework.ext; version=3.1.0.SNAPSHOT, \
+ org.osgi.framework; version=1.5.0, \
  org.osgi.framework.launch; version=1.0.0, \
  org.osgi.framework.hooks.service; version=1.0.0, \
  org.osgi.service.packageadmin; version=1.2.0, \



Mime
View raw message