cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r690991 [16/20] - in /cxf/sandbox/dosgi: ./ discovery/ discovery/local/ discovery/local/src/ discovery/local/src/main/ discovery/local/src/main/java/ discovery/local/src/main/java/org/ discovery/local/src/main/java/org/apache/ discovery/loc...
Date Mon, 01 Sep 2008 15:08:10 GMT
Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,332 @@
+/*
+ * 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.util.manifestparser;
+
+import org.apache.felix.framework.FilterImpl;
+import org.apache.felix.framework.util.MapToDictionary;
+import org.apache.felix.framework.util.VersionRange;
+import org.apache.felix.moduleloader.ICapability;
+import org.apache.felix.moduleloader.IRequirement;
+import org.osgi.framework.*;
+
+public class Requirement implements IRequirement
+{
+    private String m_namespace = null;
+    private R4Directive[] m_directives = null;
+    private R4Attribute[] m_attributes = null;
+    private boolean m_isOptional = false;
+
+    private String m_pkgName = null;
+    private VersionRange m_pkgVersionRange = null;
+    private Filter m_filter = null;
+
+    public Requirement(String namespace, String filterStr) throws InvalidSyntaxException
+    {
+        m_namespace = namespace;
+        m_filter = new FilterImpl(filterStr);
+    }
+
+    public Requirement(String namespace, String pkgName, R4Directive[] directives, R4Attribute[] attributes)
+    {
+        m_namespace = namespace;
+        m_directives = directives;
+        m_attributes = attributes;
+
+        // Find all import directives: resolution.
+        for (int i = 0; (m_directives != null) && (i < m_directives.length); i++)
+        {
+            if (m_directives[i].getName().equals(Constants.RESOLUTION_DIRECTIVE))
+            {
+                m_isOptional = m_directives[i].getValue().equals(Constants.RESOLUTION_OPTIONAL);
+            }
+        }
+
+        for (int i = 0; i < m_attributes.length; i++)
+        {
+            if (m_attributes[i].getName().equals(ICapability.PACKAGE_PROPERTY))
+            {
+                m_pkgName = (String) m_attributes[i].getValue();
+            }
+            else if (m_namespace.equals(ICapability.PACKAGE_NAMESPACE) &&
+                     m_attributes[i].getName().equals(ICapability.VERSION_PROPERTY))
+            {
+                m_pkgVersionRange = (VersionRange) m_attributes[i].getValue();
+            }
+        }
+
+        if (m_pkgVersionRange == null)
+        {
+            m_pkgVersionRange = VersionRange.infiniteRange;
+        }
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Filter getFilter()
+    {
+        if (m_filter == null)
+        {
+            m_filter = convertToFilter();
+        }
+        return m_filter;
+    }
+
+// TODO: RB - We need to verify that the resolver code does not
+// touch these implementation-specific methods.
+
+    public String getPackageName()
+    {
+        return m_pkgName;
+    }
+
+    public VersionRange getPackageVersionRange()
+    {
+        return m_pkgVersionRange;
+    }
+
+    public R4Directive[] getDirectives()
+    {
+        // TODO: RB - We should return copies of the arrays probably.
+        return m_directives;
+    }
+
+    public R4Attribute[] getAttributes()
+    {
+        // TODO: RB - We should return copies of the arrays probably.
+        return m_attributes;
+    }
+
+    public boolean isMultiple()
+    {
+        return false;
+    }
+
+    public boolean isOptional()
+    {
+        return m_isOptional;
+    }
+
+    public String getComment()
+    {
+        return "Comment for " + toString();
+    }
+
+    public boolean isSatisfied(ICapability capability)
+    {
+        // If the requirement was constructed with a filter, then
+        // we must use that filter for evaluation.
+        if ((m_attributes == null) && (m_filter != null))
+        {
+            return m_namespace.equals(capability.getNamespace()) &&
+                getFilter().match(new MapToDictionary(capability.getProperties()));
+        }
+        // Otherwise, if the requirement was constructed with attributes, then
+        // perform the evaluation manually instead of using the filter for
+        // performance reasons.
+        else if (m_attributes != null)
+        {
+            return capability.getNamespace().equals(getNamespace()) &&
+                doAttributesMatch((Capability) capability);
+        }
+
+        return false;
+    }
+
+    private boolean doAttributesMatch(Capability ec)
+    {
+        // Grab the capability's attributes.
+        R4Attribute[] capAttrs = ec.getAttributes();
+
+        // Cycle through all attributes of this import package
+        // and make sure its values match the attribute values
+        // of the specified export package.
+        for (int reqAttrIdx = 0; reqAttrIdx < m_attributes.length; reqAttrIdx++)
+        {
+            // Get current attribute from this import package.
+            R4Attribute reqAttr = m_attributes[reqAttrIdx];
+
+            // Check if the export package has the same attribute.
+            boolean found = false;
+            for (int capAttrIdx = 0;
+                (!found) && (capAttrIdx < capAttrs.length);
+                capAttrIdx++)
+            {
+                // Get current attribute for the export package.
+                R4Attribute capAttr = capAttrs[capAttrIdx];
+                // Check if the attribute names are equal.
+                if (reqAttr.getName().equals(capAttr.getName()))
+                {
+                    // We only recognize version types. If the value of the
+                    // attribute is a version/version range, then we use the
+                    // "in range" comparison, otherwise we simply use equals().
+                    if (capAttr.getValue() instanceof Version)
+                    {
+                        if (!((VersionRange) reqAttr.getValue()).isInRange((Version) capAttr.getValue()))
+                        {
+                            return false;
+                        }
+                    }
+                    else if (!reqAttr.getValue().equals(capAttr.getValue()))
+                    {
+                        return false;
+                    }
+                    found = true;
+                }
+            }
+            // If the attribute was not found, then return false.
+            if (!found)
+            {
+                return false;
+            }
+        }
+
+        // Now, cycle through all attributes of the export package and verify that
+        // all mandatory attributes are present in this import package.
+        for (int capAttrIdx = 0; capAttrIdx < capAttrs.length; capAttrIdx++)
+        {
+            // Get current attribute for this package.
+            R4Attribute capAttr = capAttrs[capAttrIdx];
+
+            // If the export attribute is mandatory, then make sure
+            // this import package has the attribute.
+            if (capAttr.isMandatory())
+            {
+                boolean found = false;
+                for (int reqAttrIdx = 0;
+                    (!found) && (reqAttrIdx < m_attributes.length);
+                    reqAttrIdx++)
+                {
+                    // Get current attribute from specified package.
+                    R4Attribute reqAttr = m_attributes[reqAttrIdx];
+
+                    // Check if the attribute names are equal
+                    // and set found flag.
+                    if (capAttr.getName().equals(reqAttr.getName()))
+                    {
+                        found = true;
+                    }
+                }
+                // If not found, then return false.
+                if (!found)
+                {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    private Filter convertToFilter()
+    {
+        StringBuffer sb = new StringBuffer();
+        if ((m_attributes != null) && (m_attributes.length > 1))
+        {
+            sb.append("(&");
+        }
+        for (int i = 0; (m_attributes != null) && (i < m_attributes.length); i++)
+        {
+            // If this is a package import, then convert wild-carded
+            // dynamically imported package names to an OR comparison.
+            if (m_namespace.equals(ICapability.PACKAGE_NAMESPACE) &&
+                m_attributes[i].getName().equals(ICapability.PACKAGE_PROPERTY) &&
+                m_attributes[i].getValue().toString().endsWith(".*"))
+            {
+                int idx = m_attributes[i].getValue().toString().indexOf(".*");
+                sb.append("(|(package=");
+                sb.append(m_attributes[i].getValue().toString().substring(0, idx));
+                sb.append(")(package=");
+                sb.append(m_attributes[i].getValue().toString());
+                sb.append("))");
+            }
+            else if (m_attributes[i].getValue() instanceof VersionRange)
+            {
+                VersionRange vr = (VersionRange) m_attributes[i].getValue();
+                if (vr.isLowInclusive())
+                {
+                    sb.append("(");
+                    sb.append(m_attributes[i].getName());
+                    sb.append(">=");
+                    sb.append(vr.getLow().toString());
+                    sb.append(")");
+                }
+                else
+                {
+                    sb.append("(!(");
+                    sb.append(m_attributes[i].getName());
+                    sb.append("<=");
+                    sb.append(vr.getLow().toString());
+                    sb.append("))");
+                }
+
+                if (vr.getHigh() != null)
+                {
+                    if (vr.isHighInclusive())
+                    {
+                        sb.append("(");
+                        sb.append(m_attributes[i].getName());
+                        sb.append("<=");
+                        sb.append(vr.getHigh().toString());
+                        sb.append(")");
+                    }
+                    else
+                    {
+                        sb.append("(!(");
+                        sb.append(m_attributes[i].getName());
+                        sb.append(">=");
+                        sb.append(vr.getHigh().toString());
+                        sb.append("))");
+                    }
+                }
+            }
+            else
+            {
+                sb.append("(");
+                sb.append(m_attributes[i].getName());
+                sb.append("=");
+                sb.append(m_attributes[i].getValue().toString());
+                sb.append(")");
+            }
+        }
+
+        if ((m_attributes != null) && (m_attributes.length > 1))
+        {
+            sb.append(")");
+        }
+
+        try
+        {
+            return new FilterImpl(sb.toString());
+        }
+        catch (InvalidSyntaxException ex)
+        {
+            // This should never happen, so we can safely ignore.
+        }
+
+        return null;
+    }
+
+    public String toString()
+    {
+        return getNamespace() + "; " + getFilter().toString();
+    }
+}

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,33 @@
+/* 
+ * 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.moduleloader;
+
+import java.util.Map;
+
+public interface ICapability
+{
+    public static final String MODULE_NAMESPACE = "module";
+    public static final String PACKAGE_NAMESPACE = "package";
+
+    public static final String PACKAGE_PROPERTY = "package";
+    public static final String VERSION_PROPERTY = "version";
+
+    String getNamespace();
+    Map getProperties();
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,126 @@
+/*
+ * 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.moduleloader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+
+public interface IContent
+{
+
+    /**
+     * <p>
+     * This method must be called before using any other methods on this
+     * interface. If the content is already opened, then subsequent calls
+     * should have no effect. This method is intended to allow the content
+     * to initialize any necessary resources.
+     * </p>
+    **/
+    public void open();
+
+    /**
+     * <p>
+     * This method must be called when the content is no longer needed so
+     * that any resourses being used (e.g., open files) can be closed. Once
+     * this method is called, the content is no longer usable. If the content
+     * is already closed, then calls on this method should have no effect.
+     * </p>
+    **/
+    public void close();
+
+    /**
+     * <p>
+     * This method determines if the specified named entry is contained in
+     * the associated content. The entry name is a relative path with '/'
+     * separators.
+     * </p>
+     * @param name The name of the entry to find.
+     * @return <tt>true</tt> if a corresponding entry was found, <tt>false</tt>
+     *         otherwise.
+    **/
+    public boolean hasEntry(String name);
+
+    /**
+     * <p>
+     * Returns an enumeration of entry names as <tt>String</tt> objects.
+     * An entry name is a path constructed with '/' as path element
+     * separators and is relative to the root of the content. Entry names
+     * for entries that represent directories should end with the '/'
+     * character.
+     * </p>
+     * @returns An enumeration of entry names or <tt>null</tt>.
+    **/
+    public Enumeration getEntries();
+
+    /**
+     * <p>
+     * This method returns the named entry as an array of bytes.
+     * </p>
+     * @param name The name of the entry to retrieve as a byte array.
+     * @return An array of bytes if the corresponding entry was found, <tt>null</tt>
+     *         otherwise.
+    **/
+    public byte[] getEntryAsBytes(String name);
+
+    /**
+     * <p>
+     * This method returns the named entry as an input stream.
+     * </p>
+     * @param name The name of the entry to retrieve as an input stream.
+     * @return An input stream if the corresponding entry was found, <tt>null</tt>
+     *         otherwise.
+     * @throws <tt>java.io.IOException</tt> if any error occurs.
+    **/
+    public InputStream getEntryAsStream(String name)
+        throws IOException;
+
+    /**
+     * <p>
+     * This method returns the named entry as an <tt>IContent</tt> Typically,
+     * this method only makes sense for entries that correspond to some form
+     * of aggregated resource (e.g., an embedded JAR file or directory), but
+     * implementations are free to interpret this however makes sense. This method
+     * should return a new <tt>IContent</tt> instance for every invocation and
+     * the caller is responsible for opening and closing the returned content
+     * object.
+     * </p>
+     * @param name The name of the entry to retrieve as an <tt>IContent</tt>.
+     * @return An <tt>IContent</tt> instance if a corresponding entry was found,
+     *         <tt>null</tt> otherwise.
+    **/
+    public IContent getEntryAsContent(String name);
+
+    /**
+     * <p>
+     * This method returns the named entry as a file in the file system for
+     * use as a native library. It may not be possible for all content
+     * implementations (e.g., memory only) to implement this method, in which
+     * case it is acceptable to return <tt>null</tt>.
+     * </p>
+     * @param name The name of the entry to retrieve as a file.
+     * @return A string corresponding to the absolute path of the file if a
+     *         corresponding entry was found, <tt>null</tt> otherwise.
+    **/
+// TODO: CACHE - This method needs to be rethought once we start allowing
+//               native libs in fragments to support multi-host attachement.
+//               For now, our implementations of this interface will not
+//               return a new file for every invocation.
+    public String getEntryAsNativeLibrary(String name);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,59 @@
+/*
+ * 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.moduleloader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface IContentLoader
+{
+    public void open();
+    public void close();
+
+    public IContent getContent();
+
+    public void setSearchPolicy(ISearchPolicy searchPolicy);
+    public ISearchPolicy getSearchPolicy();
+
+    public void setURLPolicy(IURLPolicy urlPolicy);
+    public IURLPolicy getURLPolicy();
+
+    public void setSecurityContext(Object securityContext);
+    public Object getSecurityContext();
+
+    public Class getClass(String name);
+    public URL getResource(String name);
+    public Enumeration getResources(String name);
+    public URL getResourceFromContent(String name);
+
+    // 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
+    // be readdressed in the future, perhaps by the spec to clearly indicate
+    // how resources on the bundle class path are searched, which is why we
+    // need the index number in the first place -- to differentiate among
+    // resources with the same name on the bundle class path. This was previously
+    // handled as part of the resource path, but that approach is not spec
+    // compliant.
+    public boolean hasInputStream(int index, String urlPath)
+        throws IOException;
+    public InputStream getInputStream(int index, String urlPath)
+        throws IOException;
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.moduleloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface IModule
+{
+    public String getId();
+    public IModuleDefinition getDefinition();
+    public IContentLoader getContentLoader();
+    public IWire[] getWires();
+
+    public boolean isRemovalPending();
+
+    public Class getClass(String name);
+    public URL getResource(String name);
+    public Enumeration getResources(String name);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,29 @@
+/* 
+ * 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.moduleloader;
+
+import org.apache.felix.framework.util.manifestparser.R4Library;
+
+public interface IModuleDefinition
+{
+    public ICapability[] getCapabilities();
+    public IRequirement[] getRequirements();
+    public IRequirement[] getDynamicRequirements();
+    public R4Library[] getLibraries();
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleDefinition.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.moduleloader;
+
+public interface IModuleFactory
+{
+    public IModule[] getModules();
+    public IModule getModule(String id);
+
+    public IModule createModule(String id, IModuleDefinition md);
+    public void removeModule(IModule module);
+
+    public void setContentLoader(IModule module, IContentLoader contentLoader);
+
+    public void addModuleListener(ModuleListener l);
+    public void removeModuleListener(ModuleListener l);
+
+    /**
+     * This is an experimental method that is likely to change or go
+     * away - so don't use it for now.
+     *
+     * Note to self, we need to think about what the implications of
+     * this are and whether we are fine with them.
+     */
+    public void refreshModule(IModule currentModule);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,31 @@
+/* 
+ * 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.moduleloader;
+
+import org.osgi.framework.Filter;
+
+public interface IRequirement
+{
+    String getNamespace();
+    Filter getFilter();
+    boolean isMultiple();
+    boolean isOptional();
+    String getComment();
+    boolean isSatisfied(ICapability capability);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,31 @@
+/* 
+ * 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.moduleloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface ISearchPolicy
+{
+    public Object[] definePackage(String name);
+    public Class findClass(String name) throws ClassNotFoundException;
+    public URL findResource(String name) throws ResourceNotFoundException;
+    public Enumeration findResources(String name) throws ResourceNotFoundException;
+    public String findLibrary(String name);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,34 @@
+/* 
+ * 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.moduleloader;
+
+import java.net.URL;
+
+public interface IURLPolicy
+{
+    // TODO: ML - For expediency, the port argument was added to this method
+    // but it is not clear that it makes sense in the long run. This needs to
+    // be readdressed in the future, perhaps by the spec to clearly indicate
+    // how resources on the bundle class path are searched, which is why we
+    // need the port number in the first place -- to differentiate among
+    // resources with the same name on the bundle class path. This was previously
+    // handled as part of the resource path, but that approach is not spec
+    // compliant.
+    public URL createURL(int port, String path);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,33 @@
+/* 
+ * 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.moduleloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface IWire
+{
+    public IModule getImporter();
+    public IRequirement getRequirement();
+    public IModule getExporter();
+    public ICapability getCapability();
+    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

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/IWire.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,63 @@
+/* 
+ * 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.moduleloader;
+
+import java.util.EventObject;
+
+/**
+ * <p>
+ * This is an event class that is used by the <tt>ModuleManager</tt> to
+ * indicate when modules are added, removed, or reset. To receive these
+ * events, a <tt>ModuleListener</tt> must be added to the <tt>ModuleManager</tt>
+ * instance.
+ * </p>
+ * @see org.apache.felix.moduleloader.ModuleFactoryImpl
+ * @see org.apache.felix.moduleloader.ModuleImpl
+ * @see org.apache.felix.moduleloader.ModuleListener
+**/
+public class ModuleEvent extends EventObject
+{
+    private IModule m_module = null;
+
+    /**
+     * <p>
+     * Constructs a module event with the specified <tt>ModuleManager</tt>
+     * as the event source and the specified module as the subject of
+     * the event.
+     * </p>
+     * @param mgr the source of the event.
+     * @param module the subject of the event.
+    **/
+    public ModuleEvent(IModuleFactory factory, IModule module)
+    {
+        super(factory);
+        m_module = module;
+    }
+
+    /**
+     * <p>
+     * Returns the module that is the subject of the event.
+     * </p>
+     * @return the module that is the subject of the event.
+    **/
+    public IModule getModule()
+    {
+        return m_module;
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleEvent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,314 @@
+/*
+ * 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.moduleloader;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.framework.Logger;
+
+public class ModuleFactoryImpl implements IModuleFactory
+{
+    private Logger m_logger = null;
+    private Map m_moduleMap = new HashMap();
+
+    private ModuleListener[] m_listeners = null;
+    private static final ModuleListener[] m_noListeners = new ModuleListener[0];
+
+    public ModuleFactoryImpl(Logger logger)
+    {
+        m_logger = logger;
+        m_listeners = m_noListeners;
+    }
+
+    public synchronized IModule[] getModules()
+    {
+        return (IModule[]) m_moduleMap.values().toArray(new IModule[m_moduleMap.size()]);
+    }
+
+    public synchronized IModule getModule(String id)
+    {
+        return (IModule) m_moduleMap.get(id);
+    }
+
+    public IModule createModule(String id, IModuleDefinition md)
+    {
+        IModule module = null;
+
+        // Use a synchronized block instead of synchronizing the
+        // method, so we can fire our event outside of the block.
+        synchronized (this)
+        {
+            if (m_moduleMap.get(id) == null)
+            {
+                module = new ModuleImpl(m_logger, id, md);
+                m_moduleMap.put(id, module);
+            }
+            else
+            {
+                throw new IllegalArgumentException("Module ID must be unique.");
+            }
+        }
+
+        // Fire event here instead of inside synchronized block.
+        fireModuleAdded(module);
+
+        return module;
+    }
+
+    /**
+     * This is an experimental method that is likely to change or go
+     * away - so don't use it for now.
+     *
+     * Note to self, we need to think about what the implications of
+     * this are and whether we are fine with them.
+     */
+    public void refreshModule(IModule module)
+    {
+        boolean fire = false;
+
+        synchronized (this)
+        {
+            fire = (m_moduleMap.get(module.getId()) != null);
+        }
+
+        if (fire)
+        {
+            fireModuleRefreshed(module);
+        }
+    }
+
+    public void removeModule(IModule module)
+    {
+        // Use a synchronized block instead of synchronizing the
+        // method, so we can fire our event outside of the block.
+        synchronized (this)
+        {
+            if (m_moduleMap.get(module.getId()) != null)
+            {
+                // Remove from data structures.
+                m_moduleMap.remove(module.getId());
+                // Close the module's content loader to deinitialize it.
+                // TODO: This is not really the best place for this, but at
+                // least it is centralized with the call to IContentLoader.open()
+                // when a module's content loader is set below.
+                ((ModuleImpl) module).getContentLoader().close();
+            }
+            else
+            {
+                // Don't fire event.
+                return;
+            }
+        }
+
+        // Fire event here instead of inside synchronized block.
+        fireModuleRemoved(module);
+    }
+
+    public void setContentLoader(IModule module, IContentLoader contentLoader)
+    {
+        synchronized (this)
+        {
+            ((ModuleImpl) module).setContentLoader(contentLoader);
+            // Open the module's content loader to initialize it.
+            // TODO: This is not really the best place for this, but at
+            // least it is centralized with the call to IContentLoader.close()
+            // when the module is removed above.
+            contentLoader.open();
+        }
+    }
+
+    /**
+     * <p>
+     * Adds a listener to the <tt>IModuleFactory</tt> to listen for
+     * module added and removed events.
+     * </p>
+     * @param l the <tt>ModuleListener</tt> to add.
+    **/
+    public void addModuleListener(ModuleListener l)
+    {
+        // Verify listener.
+        if (l == null)
+        {
+            throw new IllegalArgumentException("Listener is null");
+        }
+
+        // Use the m_noListeners object as a lock.
+        synchronized (m_noListeners)
+        {
+            // If we have no listeners, then just add the new listener.
+            if (m_listeners == m_noListeners)
+            {
+                m_listeners = new ModuleListener[] { l };
+            }
+            // Otherwise, we need to do some array copying.
+            // Notice, the old array is always valid, so if
+            // the dispatch thread is in the middle of a dispatch,
+            // then it has a reference to the old listener array
+            // and is not affected by the new value.
+            else
+            {
+                ModuleListener[] newList = new ModuleListener[m_listeners.length + 1];
+                System.arraycopy(m_listeners, 0, newList, 0, m_listeners.length);
+                newList[m_listeners.length] = l;
+                m_listeners = newList;
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * Removes a listener from the <tt>IModuleFactory</tt>.
+     * </p>
+     * @param l the <tt>ModuleListener</tt> to remove.
+    **/
+    public void removeModuleListener(ModuleListener l)
+    {
+        // Verify listener.
+        if (l == null)
+        {
+            throw new IllegalArgumentException("Listener is null");
+        }
+
+        // Use the m_noListeners object as a lock.
+        synchronized (m_noListeners)
+        {
+            // Try to find the instance in our list.
+            int idx = -1;
+            for (int i = 0; i < m_listeners.length; i++)
+            {
+                if (m_listeners[i].equals(l))
+                {
+                    idx = i;
+                    break;
+                }
+            }
+
+            // If we have the instance, then remove it.
+            if (idx >= 0)
+            {
+                // If this is the last listener, then point to empty list.
+                if (m_listeners.length == 1)
+                {
+                    m_listeners = m_noListeners;
+                }
+                // Otherwise, we need to do some array copying.
+                // Notice, the old array is always valid, so if
+                // the dispatch thread is in the middle of a dispatch,
+                // then it has a reference to the old listener array
+                // and is not affected by the new value.
+                else
+                {
+                    ModuleListener[] newList = new ModuleListener[m_listeners.length - 1];
+                    System.arraycopy(m_listeners, 0, newList, 0, idx);
+                    if (idx < newList.length)
+                    {
+                        System.arraycopy(m_listeners, idx + 1, newList, idx,
+                            newList.length - idx);
+                    }
+                    m_listeners = newList;
+                }
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * Fires an event indicating that the specified module was added
+     * to the <tt>IModuleFactory</tt>.
+     * </p>
+     * @param module the module that was added.
+    **/
+    protected void fireModuleAdded(IModule module)
+    {
+        // Event holder.
+        ModuleEvent event = null;
+
+        // Get a copy of the listener array, which is guaranteed
+        // to not be null.
+        ModuleListener[] listeners = m_listeners;
+
+        // Loop through listeners and fire events.
+        for (int i = 0; i < listeners.length; i++)
+        {
+            // Lazily create event.
+            if (event == null)
+            {
+                event = new ModuleEvent(this, module);
+            }
+            listeners[i].moduleAdded(event);
+        }
+    }
+
+    /**
+     * <p>
+     * Fires an event indicating that the specified module was removed
+     * from the <tt>IModuleFactory</tt>.
+     * </p>
+     * @param module the module that was removed.
+    **/
+    protected void fireModuleRemoved(IModule module)
+    {
+        // Event holder.
+        ModuleEvent event = null;
+
+        // Get a copy of the listener array, which is guaranteed
+        // to not be null.
+        ModuleListener[] listeners = m_listeners;
+
+        // Loop through listeners and fire events.
+        for (int i = 0; i < listeners.length; i++)
+        {
+            // Lazily create event.
+            if (event == null)
+            {
+                event = new ModuleEvent(this, module);
+            }
+            listeners[i].moduleRemoved(event);
+        }
+    }
+
+    /**
+     * This is an experimental method that is likely to change or go
+     * away - so don't use it for now.
+     *
+     * Note to self, we need to think about what the implications of
+     * this are and whether we are fine with them.
+     */
+    protected void fireModuleRefreshed(IModule module)
+    {
+     // Event holder.
+        ModuleEvent event = null;
+
+        // Get a copy of the listener array, which is guaranteed
+        // to not be null.
+        ModuleListener[] listeners = m_listeners;
+
+        // Loop through listeners and fire events.
+        for (int i = 0; i < listeners.length; i++)
+        {
+            // Lazily create event.
+            if (event == null)
+            {
+                event = new ModuleEvent(this, module);
+            }
+            listeners[i].moduleRefreshed(event);
+        }
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,194 @@
+/*
+ * 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.moduleloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.apache.felix.framework.Logger;
+
+public class ModuleImpl implements IModule
+{
+    private Logger m_logger = null;
+    private String m_id = null;
+    private boolean m_removalPending = false;
+    private IModuleDefinition m_md = null;
+    private IContentLoader m_contentLoader = null;
+    private IWire[] m_wires = null;
+    private IModule[] m_dependents = new IModule[0];
+
+    ModuleImpl(Logger logger, String id, IModuleDefinition md)
+    {
+        m_logger = logger;
+        m_id = id;
+        m_md = md;
+    }
+
+    public String getId()
+    {
+        return m_id;
+    }
+
+    public IModuleDefinition getDefinition()
+    {
+        return m_md;
+    }
+
+    public IContentLoader getContentLoader()
+    {
+        return m_contentLoader;
+    }
+
+    protected void setContentLoader(IContentLoader contentLoader)
+    {
+        m_contentLoader = contentLoader;
+    }
+
+    public synchronized IWire[] getWires()
+    {
+        return m_wires;
+    }
+
+    public synchronized void setWires(IWire[] wires)
+    {
+        // Remove module from old wire modules' dependencies.
+        for (int i = 0; (m_wires != null) && (i < m_wires.length); i++)
+        {
+            ((ModuleImpl) m_wires[i].getExporter()).removeDependent(this);
+        }
+        m_wires = wires;
+        // Add module to new wire modules' dependencies.
+        for (int i = 0; (wires != null) && (i < wires.length); i++)
+        {
+            ((ModuleImpl) m_wires[i].getExporter()).addDependent(this);
+        }
+    }
+
+    public synchronized void addDependent(IModule module)
+    {
+        // Make sure the dependent module is not already present.
+        for (int i = 0; i < m_dependents.length; i++)
+        {
+            if (m_dependents[i].equals(module))
+            {
+                return;
+            }
+        }
+        IModule[] tmp = new IModule[m_dependents.length + 1];
+        System.arraycopy(m_dependents, 0, tmp, 0, m_dependents.length);
+        tmp[m_dependents.length] = module;
+        m_dependents = tmp;
+    }
+
+    public synchronized void removeDependent(IModule module)
+    {
+        // Make sure the dependent module is not already present.
+        for (int i = 0; i < m_dependents.length; i++)
+        {
+            if (m_dependents[i].equals(module))
+            {
+                // If this is the module, then point to empty list.
+                if ((m_dependents.length - 1) == 0)
+                {
+                    m_dependents = new IModule[0];
+                }
+                // Otherwise, we need to do some array copying.
+                else
+                {
+                    IModule[] tmp = new IModule[m_dependents.length - 1];
+                    System.arraycopy(m_dependents, 0, tmp, 0, i);
+                    if (i < tmp.length)
+                    {
+                        System.arraycopy(
+                            m_dependents, i + 1, tmp, i, tmp.length - i);
+                    }
+                    m_dependents = tmp;
+                }
+            }
+        }
+    }
+
+    public synchronized IModule[] getDependents()
+    {
+        return m_dependents;
+    }
+
+    public boolean isRemovalPending()
+    {
+        return m_removalPending;
+    }
+
+    public void setRemovalPending(boolean removalPending)
+    {
+        m_removalPending = removalPending;
+    }
+
+    public Class getClass(String name)
+    {
+        try
+        {
+            return m_contentLoader.getSearchPolicy().findClass(name);
+        }
+        catch (ClassNotFoundException ex)
+        {
+            m_logger.log(
+                Logger.LOG_WARNING,
+                ex.getMessage(),
+                ex);
+        }
+        return null;
+    }
+
+    public URL getResource(String name)
+    {
+        try
+        {
+            return m_contentLoader.getSearchPolicy().findResource(name);
+        }
+        catch (ResourceNotFoundException ex)
+        {
+            m_logger.log(
+                Logger.LOG_WARNING,
+                ex.getMessage(),
+                ex);
+        }
+        return null;
+    }
+
+    public Enumeration getResources(String name)
+    {
+        try
+        {
+           return m_contentLoader.getSearchPolicy().findResources(name);
+        }
+        catch (ResourceNotFoundException ex)
+        {
+            m_logger.log(
+                Logger.LOG_WARNING,
+                ex.getMessage(),
+                ex);
+        }
+        return null;
+    }
+
+    public String toString()
+    {
+        return m_id;
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,60 @@
+/*
+ * 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.moduleloader;
+
+import java.util.EventListener;
+
+/**
+ * <p>
+ * This interface is an event listener for <tt>ModuleEvent</tt> events.
+ * To receive events, an implementation of this listener must be added
+ * to the <tt>IModuleFactory</tt> instance.
+ * </p>
+ * @see org.apache.felix.moduleloader.IModuleFactory
+ * @see org.apache.felix.moduleloader.ModuleEvent
+**/
+public interface ModuleListener extends EventListener
+{
+    /**
+     * <p>
+     * This method is called after a module is added to the
+     * <tt>IModuleFactory</tt>.
+     * </p>
+     * @param event the event object containing the event details.
+    **/
+    public void moduleAdded(ModuleEvent event);
+
+    /**
+     * <p>
+     * This method is called after a module is remove from the
+     * <tt>IModuleFactory</tt>.
+     * </p>
+     * @param event the event object containing the event details.
+    **/
+    public void moduleRemoved(ModuleEvent event);
+
+    /**
+     * This is an experimental method that is likely to change or go
+     * away - so don't use it for now.
+     *
+     * Note to self, we need to think about what the implications of
+     * this are and whether we are fine with them.
+     */
+    public void moduleRefreshed(ModuleEvent event);
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,27 @@
+/* 
+ * 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.moduleloader;
+
+public class ResourceNotFoundException extends Exception
+{
+    public ResourceNotFoundException(String msg)
+    {
+        super(msg);
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/moduleloader/ResourceNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,455 @@
+/*
+ * 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.osgi.framework;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.apache.felix.framework.FilterImpl;
+
+/**
+ * <p>
+ * This class is a replacement for the version that ships with the
+ * standard OSGi JAR file.
+ * </p>
+**/
+public final class AdminPermission extends BasicPermission
+{
+    static final long serialVersionUID = 307051004521261705L;
+
+    public static final String CLASS = "class";
+    public static final String EXECUTE = "execute";
+    public static final String EXTENSIONLIFECYCLE = "extensionLifecycle";
+    public static final String LIFECYCLE = "lifecycle";
+    public static final String LISTENER = "listener";
+    public static final String METADATA = "metadata";
+    public static final String RESOLVE = "resolve";
+    public static final String RESOURCE = "resource";
+    public static final String STARTLEVEL = "startlevel";
+
+    private static final int CLASS_MASK = 1;
+    private static final int EXECUTE_MASK = 2;
+    private static final int EXTENSIONLIFECYCLE_MASK = 4;
+    private static final int LIFECYCLE_MASK = 8;
+    private static final int LISTENER_MASK = 16;
+    private static final int METADATA_MASK = 32;
+    private static final int RESOLVE_MASK = 64;
+    private static final int RESOURCE_MASK = 128;
+    private static final int STARTLEVEL_MASK = 256;
+    private static final int ALL_MASK =
+        CLASS_MASK | EXECUTE_MASK | EXTENSIONLIFECYCLE_MASK |
+        LIFECYCLE_MASK | LISTENER_MASK | METADATA_MASK |
+        RESOLVE_MASK | RESOURCE_MASK | STARTLEVEL_MASK;
+
+    private String m_actions = null;
+    int m_actionMask = 0;
+
+    // Cached filter for permissions created with a filter when
+    // granting admin permissions.
+    private FilterImpl m_filterImpl = null;
+
+    // Bundle associated with the permission when checking
+    // admin permissions.
+    private Bundle m_bundle = null;
+    // Cached bundle property dictionary when checking
+    // admin permissions.
+    private Dictionary m_bundleDict = null;
+
+    // This constructor is only used when granting an admin permission.
+	public AdminPermission()
+    {
+		this("*", ALL_MASK);
+    }
+
+    // This constructor is only used when checking a granted admin permission.
+    public AdminPermission(Bundle bundle, String actions)
+    {
+        this(createName(bundle), actions);
+        m_bundle = bundle;
+    }
+
+    // This constructor is only used when granting an admin permission.
+	public AdminPermission(String filter, String actions)
+    {
+		super((filter == null) || (filter.equals("*")) ? "(id=*)" : filter);
+        m_actionMask = parseActions(actions);
+    }
+
+    // This constructor is only used by the admin permission collection
+    // when combining admin permissions or by the default constructor when granting
+    // an admin permission
+    AdminPermission(String filter, int actionMask)
+    {
+        super((filter == null) || (filter.equals("*")) ? "(id=*)" : filter);
+        m_actionMask = actionMask;
+    }
+
+    public boolean equals(Object obj)
+    {
+	if (obj == this)
+        {
+	    return true;
+	}
+
+	if (!(obj instanceof AdminPermission))
+        {
+	    return false;
+	}
+
+	AdminPermission p = (AdminPermission) obj;
+
+	return getName().equals(p.getName()) && (m_actionMask == p.m_actionMask);
+    }
+
+    public int hashCode()
+    {
+	return getName().hashCode() ^ getActions().hashCode();
+    }
+
+    public String getActions()
+    {
+        if (m_actions == null)
+        {
+            m_actions = createActionString(m_actionMask);
+        }
+	return m_actions;
+    }
+
+    public boolean implies(Permission p)
+    {
+	if (!(p instanceof AdminPermission))
+        {
+	    return false;
+	}
+
+        AdminPermission admin = (AdminPermission) p;
+
+        // Make sure that the permission was create with a bundle or a "*".
+        // Otherwise, throw an Exception - as per spec.
+        if ((admin.m_bundle == null) && !(admin.getName().equals("(id=*)")))
+        {
+            throw new RuntimeException(
+                "The specified permission was not constructed with a bundle or *!");
+        }
+
+        // Make sure the action mask is a subset.
+        if ((m_actionMask & admin.m_actionMask) != admin.m_actionMask)
+        {
+            return false;
+        }
+
+        // Special case: if the specified permission was constructed with "*"
+        // filter, then this method returns <code>true</code> if this object's
+        // filter is "*".
+        if (admin.getName().equals("(id=*)"))
+        {
+            return getName().equals("(id=*)");
+        }
+
+        // Next, if this object was create with a "*" we can return true
+        // (This way we avoid creating and matching a filter).
+        if (getName().equals("(id=*)"))
+        {
+            return true;
+        }
+
+        // Otherwise, see if this permission's filter matches the
+        // dictionary of the passed in permission.
+        if (m_filterImpl == null)
+        {
+            try
+            {
+                m_filterImpl = new FilterImpl(getName());
+            }
+            catch (InvalidSyntaxException ex)
+            {
+                return false;
+            }
+        }
+
+        return m_filterImpl.match(admin.getBundleDictionary());
+    }
+
+    public PermissionCollection newPermissionCollection()
+    {
+	return new AdminPermissionCollection();
+    }
+
+    private Dictionary getBundleDictionary()
+    {
+        if (m_bundleDict == null)
+        {
+            // Add bundle properties to dictionary.
+            m_bundleDict = new Hashtable();
+            m_bundleDict.put("id", new Long(m_bundle.getBundleId()));
+
+            String symbolicName = m_bundle.getSymbolicName();
+            if (symbolicName != null)
+            {
+                m_bundleDict.put("name", symbolicName);
+            }
+            // Add location in privileged block since it performs a security check.
+            if (System.getSecurityManager() != null)
+            {
+                AccessController.doPrivileged(new PrivilegedAction()
+                {
+                    public Object run()
+                    {
+                        m_bundleDict.put("location", m_bundle.getLocation());
+
+                        createSigner(m_bundle, m_bundleDict);
+                        return null;
+                    }
+                });
+            }
+            else
+            {
+                m_bundleDict.put("location", m_bundle.getLocation());
+                createSigner(m_bundle, m_bundleDict);
+            }
+        }
+        return m_bundleDict;
+    }
+
+    private static void createSigner(Bundle bundle, Dictionary dict)
+    {
+        try
+        {
+            Method method = bundle.getClass().getDeclaredMethod(
+                "getSignerMatcher", null);
+            method.setAccessible(true);
+
+            Object signer = method.invoke(bundle, null);
+
+            if (signer != null)
+            {
+                dict.put("signer", signer);
+            }
+        }
+        catch (Exception ex)
+        {
+// TODO: log this or something
+            ex.printStackTrace();
+        }
+    }
+
+    private static int parseActions(String actions)
+    {
+        if (actions == null)
+        {
+            return ALL_MASK;
+        }
+
+        int mask = 0;
+
+        StringTokenizer st = new StringTokenizer(actions, ", ");
+        while (st.hasMoreTokens())
+        {
+            String s = st.nextToken();
+            if (s.equals("*"))
+            {
+                mask = ALL_MASK;
+                break;
+            }
+            else if (s.equalsIgnoreCase(CLASS))
+            {
+                mask |= CLASS_MASK;
+            }
+            else if (s.equalsIgnoreCase(EXECUTE))
+            {
+                mask |= EXECUTE_MASK;
+            }
+            else if (s.equalsIgnoreCase(EXTENSIONLIFECYCLE))
+            {
+                mask |= EXTENSIONLIFECYCLE_MASK;
+            }
+            else if (s.equalsIgnoreCase(LIFECYCLE))
+            {
+                mask |= LIFECYCLE_MASK;
+            }
+            else if (s.equalsIgnoreCase(LISTENER))
+            {
+                mask |= LISTENER_MASK;
+            }
+            else if (s.equalsIgnoreCase(METADATA))
+            {
+                mask |= METADATA_MASK;
+            }
+            else if (s.equalsIgnoreCase(RESOLVE))
+            {
+                mask |= RESOLVE_MASK;
+            }
+            else if (s.equalsIgnoreCase(RESOURCE))
+            {
+                mask |= RESOURCE_MASK;
+            }
+            else if (s.equalsIgnoreCase(STARTLEVEL))
+            {
+                mask |= STARTLEVEL_MASK;
+            }
+        }
+
+        return mask;
+    }
+
+    private static String createActionString(int mask)
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ((mask & CLASS_MASK) > 0)
+        {
+            sb.append(CLASS);
+            sb.append(",");
+        }
+
+        if ((mask & EXECUTE_MASK) > 0)
+        {
+            sb.append(EXECUTE);
+            sb.append(",");
+        }
+
+        if ((mask & EXTENSIONLIFECYCLE_MASK) > 0)
+        {
+            sb.append(EXTENSIONLIFECYCLE);
+            sb.append(",");
+        }
+
+        if ((mask & LIFECYCLE_MASK) > 0)
+        {
+            sb.append(LIFECYCLE);
+            sb.append(",");
+        }
+
+        if ((mask & LISTENER_MASK) > 0)
+        {
+            sb.append(LISTENER);
+            sb.append(",");
+        }
+
+        if ((mask & METADATA_MASK) > 0)
+        {
+            sb.append(METADATA);
+            sb.append(",");
+        }
+
+        if ((mask & RESOLVE_MASK) > 0)
+        {
+            sb.append(RESOLVE);
+            sb.append(",");
+        }
+
+        if ((mask & RESOURCE_MASK) > 0)
+        {
+            sb.append(RESOURCE);
+            sb.append(",");
+        }
+
+        if ((mask & STARTLEVEL_MASK) > 0)
+        {
+            sb.append(STARTLEVEL);
+            sb.append(",");
+        }
+
+        // Remove trailing comma.
+        if (sb.length() > 0)
+        {
+            sb.setLength(sb.length() - 1);
+        }
+
+        return sb.toString();
+    }
+
+    private static String createName(Bundle bundle)
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append("(id=");
+        sb.append(bundle.getBundleId());
+        sb.append(")");
+        return sb.toString();
+    }
+}
+
+final class AdminPermissionCollection extends PermissionCollection
+{
+    private static final long serialVersionUID = 3747361397420496672L;
+    private HashMap m_map = new HashMap();
+
+    public void add(Permission permission)
+    {
+        if (!(permission instanceof AdminPermission))
+        {
+            throw new IllegalArgumentException("Invalid permission: " + permission);
+        }
+        else if (isReadOnly())
+        {
+            throw new SecurityException(
+                "Cannot add to read-only permission collection.");
+        }
+
+        AdminPermission admin = (AdminPermission) permission;
+        AdminPermission current = (AdminPermission) m_map.get(admin.getName());
+        if (current != null)
+        {
+            if (admin.m_actionMask != current.m_actionMask)
+            {
+                m_map.put(admin.getName(),
+                    new AdminPermission(admin.getName(),
+                        admin.m_actionMask | current.m_actionMask));
+            }
+        }
+        else
+        {
+            m_map.put(admin.getName(), admin);
+        }
+    }
+
+    public boolean implies(Permission permission)
+    {
+        if (!(permission instanceof AdminPermission))
+        {
+            return false;
+        }
+
+        for (Iterator iter = m_map.values().iterator(); iter.hasNext(); )
+        {
+            if (((AdminPermission) iter.next()).implies(permission))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public Enumeration elements()
+    {
+        return Collections.enumeration(m_map.values());
+    }
+}

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/AdminPermission.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,41 @@
+/* 
+ * 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.osgi.framework;
+
+import org.apache.felix.framework.FilterImpl;
+
+/**
+ * <p>
+ * Framework utility class that currently only provides public access to
+ * <tt>Filter</tt> instance creation. This class is a replacement for the
+ * version that ships with the standard OSGi JAR file.
+ * </p>
+**/
+public class FrameworkUtil
+{
+    private FrameworkUtil()
+    {
+    }
+
+    public static Filter createFilter(String filter)
+        throws InvalidSyntaxException
+    {
+        return new FilterImpl(null, filter);
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/FrameworkUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,19 @@
+package org.osgi.framework;
+
+public class ServiceException extends RuntimeException {
+    
+    private String type; 
+    
+    public ServiceException(String type) {
+        this(type, null);
+    }
+    
+    public ServiceException(String type, Throwable cause) {
+        super(cause);
+        this.type = type;
+    }
+    
+    public String getType() {
+        return type;
+    }
+}

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/ServiceException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,56 @@
+/*
+ * $Date$
+ *
+ * Copyright (c) OSGi Alliance (2004, 2007). All Rights Reserved.
+ *
+ * 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.osgi.framework.hooks.service;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceListener;
+
+public interface ListenerHook {
+    static class Listener {
+        private BundleContext bc;
+        private ServiceListener sl;
+        private String filter;
+        
+        public Listener(BundleContext bc, ServiceListener sl, String filter) {
+            this.bc = bc;
+            this.sl = sl;
+            this.filter = filter;
+        }
+        
+        public BundleContext getBundleContext() {
+            return bc;
+        }
+        
+        public ServiceListener getServiceListener() {
+            return sl;
+        }
+        
+        public String getFilter() {
+            return filter;
+        }
+    }
+    
+    void added(ListenerHook.Listener listener);
+    void initial(ListenerHook.Listener[] listeners);
+    void removed(ListenerHook.Listener listener);
+    
+    void serviceReferencesRequested(BundleContext bc,
+                                    String className,
+                                    String filter,
+                                    boolean allServices);
+}

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/framework/hooks/service/ListenerHook.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message