felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r901786 - /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
Date Thu, 21 Jan 2010 17:30:09 GMT
Author: rickhall
Date: Thu Jan 21 17:30:08 2010
New Revision: 901786

URL: http://svn.apache.org/viewvc?rev=901786&view=rev
Log:
The framework is working again in some capacity.

Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java?rev=901786&r1=901785&r2=901786&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
(original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
Thu Jan 21 17:30:08 2010
@@ -24,6 +24,7 @@
 import org.apache.felix.framework.capabilityset.Module;
 import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.capabilityset.Wire;
+import org.apache.felix.framework.util.Util;
 import org.apache.felix.moduleloader.ResourceNotFoundException;
 
 public class WireImpl implements Wire
@@ -66,23 +67,111 @@
         return m_req + " (" + m_importer + ") -> " + m_cap + " (" + m_exporter + ")";
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.felix.framework.searchpolicy.IWire#getClass(java.lang.String)
+     */
     public boolean hasPackage(String pkgName)
     {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName));
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.felix.framework.searchpolicy.IWire#getClass(java.lang.String)
+     */
     public Class getClass(String name) throws ClassNotFoundException
     {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
+        Class clazz = null;
+
+        // Get the package of the target class.
+        String pkgName = Util.getClassPackage(name);
 
+        // Only check when the package of the target class is
+        // the same as the package for the wire.
+        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        {
+            // Check the include/exclude filters from the target package
+            // to make sure that the class is actually visible. We delegate
+            // to the exporting module, rather than its content, so it can
+            // it can follow any internal wires it may have (e.g., if the
+            // package has multiple sources).
+// TODO: FELIX3 - Implement package filter!
+//            if (m_cap.isIncluded(name))
+            {
+                clazz = m_exporter.getClassByDelegation(name);
+            }
+
+            // If no class was found, then we must throw an exception
+            // since the exporter for this package did not contain the
+            // requested class.
+            if (clazz == null)
+            {
+                throw new ClassNotFoundException(name);
+            }
+        }
+
+        return clazz;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.felix.framework.searchpolicy.IWire#getResource(java.lang.String)
+     */
     public URL getResource(String name) throws ResourceNotFoundException
     {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
+        URL url = null;
+
+        // Get the package of the target class.
+        String pkgName = Util.getResourcePackage(name);
 
+        // Only check when the package of the target resource is
+        // the same as the package for the wire.
+        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        {
+            // 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);
+
+            // If no resource was found, then we must throw an exception
+            // since the exporter for this package did not contain the
+            // requested class.
+            if (url == null)
+            {
+                throw new ResourceNotFoundException(name);
+            }
+        }
+
+        return url;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.felix.framework.searchpolicy.IWire#getResources(java.lang.String)
+     */
     public Enumeration getResources(String name) throws ResourceNotFoundException
     {
-        throw new UnsupportedOperationException("Not supported yet.");
+        Enumeration urls = null;
+
+        // Get the package of the target class.
+        String pkgName = Util.getResourcePackage(name);
+
+        // Only check when the package of the target resource is
+        // the same as the package for the wire.
+        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        {
+            urls = m_exporter.getResourcesByDelegation(name);
+
+            // If no resource was found, then we must throw an exception
+            // since the exporter for this package did not contain the
+            // requested class.
+            if (urls == null)
+            {
+                throw new ResourceNotFoundException(name);
+            }
+        }
+
+        return urls;
     }
 }
\ No newline at end of file



Mime
View raw message