You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2006/02/02 11:30:59 UTC
svn commit: r374342 - in
/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader:
./ search/
Author: rickhall
Date: Thu Feb 2 02:30:51 2006
New Revision: 374342
URL: http://svn.apache.org/viewcvs?rev=374342&view=rev
Log:
Further refactoring of the Module Loader layer to improve the module and
search policy abstractions.
Removed:
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleCallback.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleCallbackImpl.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/search/
Modified:
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IContentLoader.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ILibrary.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModule.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/JarContent.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IContentLoader.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IContentLoader.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IContentLoader.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IContentLoader.java Thu Feb 2 02:30:51 2006
@@ -24,17 +24,15 @@
{
public IContent getContent();
- public void setModuleCallback(IModuleCallback callback);
- public IModuleCallback getModuleCallback();
+ public void setSearchPolicy(ISearchPolicy searchPolicy);
+ public ISearchPolicy getSearchPolicy();
+
+ public void setURLPolicy(IURLPolicy urlPolicy);
+ public IURLPolicy getURLPolicy();
public Class getClass(String name);
public URL getResource(String name);
- // getResourceAsStream() was used instead of getResourceBytes()
- // because the content loader for the system bundle must delegate
- // to "ParentClassLoader.getResourceAsStream()".
public InputStream getResourceAsStream(String name)
throws IOException;
-
- public String findLibrary(String name);
}
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ILibrary.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ILibrary.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ILibrary.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ILibrary.java Thu Feb 2 02:30:51 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 The Apache Software Foundation
+ * Copyright 2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,20 +18,10 @@
/**
* <p>
- * This interface represents a source for obtaining native libraries for a
- * given module via the module's class loader. The main goal of a library
- * source is to map a library name to a path in the file system.
+ * This interface represents a native library for a module
+ * The main purpose of this interface is to provide a mechanism
+ * to map a library name to a path in the file system.
* </p>
- * <p>
- * All library sources are initialized before first usage via a call
- * to the <a href="#open()"><tt>LibrarySource.open()</tt></a> method and
- * are also deinitialized via a call to
- * <a href="#open()"><tt>LibrarySource.close()</tt></a>. Library sources
- * should be implemented such that they can be opened, closed, and then
- * re-opened.
- * </p>
- * @see org.apache.felix.moduleloader.ModuleImpl
- * @see org.apache.felix.moduleloader.ModuleClassLoader
**/
public interface ILibrary
{
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModule.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModule.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModule.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModule.java Thu Feb 2 02:30:51 2006
@@ -21,13 +21,7 @@
public interface IModule
{
public String getId();
- public ISearchPolicy getSearchPolicy();
- public IURLPolicy getURLPolicy();
public IContentLoader getContentLoader();
-
- public Object[][] getAttributes();
- public Object getAttribute(String key, Object defaultValue);
- public void setAttribute(String key, Object value);
public Class getClass(String name);
public URL getResource(String name);
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IModuleFactory.java Thu Feb 2 02:30:51 2006
@@ -18,14 +18,14 @@
public interface IModuleFactory
{
- public ISearchPolicy getSearchPolicy();
-
public IModule[] getModules();
public IModule getModule(String id);
- public IModule createModule(
- String id, IContentLoader contentLoader, Object[][] attrs);
+ public IModule createModule(String id);
public void removeModule(IModule module);
+
+ public void setContentLoader(IModule module, IContentLoader contentLoader);
+
public void addModuleListener(ModuleListener l);
public void removeModuleListener(ModuleListener l);
}
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ISearchPolicy.java Thu Feb 2 02:30:51 2006
@@ -22,13 +22,7 @@
public interface ISearchPolicy
{
- public IModuleFactory getModuleFactory();
- public void setModuleFactory(IModuleFactory factory);
-
- public Class findClass(IModule module, String name)
- throws ClassNotFoundException;
- public URL findResource(IModule module, String name)
- throws ResourceNotFoundException;
-
- public String findLibrary(IModule module, String name);
+ public Class findClass(String name) throws ClassNotFoundException;
+ public URL findResource(String name) throws ResourceNotFoundException;
+ public String findLibrary(String name);
}
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java Thu Feb 2 02:30:51 2006
@@ -1,8 +1,24 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.felix.moduleloader;
import java.net.URL;
public interface IURLPolicy
{
- public URL createURL(IModule m_module, String path);
+ public URL createURL(String path);
}
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/JarContent.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/JarContent.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/JarContent.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/JarContent.java Thu Feb 2 02:30:51 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.felix.moduleloader;
import java.io.*;
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleFactoryImpl.java Thu Feb 2 02:30:51 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.felix.moduleloader;
import java.util.HashMap;
@@ -5,30 +21,18 @@
import org.apache.felix.framework.Logger;
-
-
public class ModuleFactoryImpl implements IModuleFactory
{
private Logger m_logger = null;
- private ISearchPolicy m_searchPolicy = null;
- private IURLPolicy m_urlPolicy = 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, ISearchPolicy searchPolicy, IURLPolicy urlPolicy)
+ public ModuleFactoryImpl(Logger logger)
{
m_logger = logger;
m_listeners = m_noListeners;
- m_searchPolicy = searchPolicy;
- m_searchPolicy.setModuleFactory(this);
- m_urlPolicy = urlPolicy;
- }
-
- public ISearchPolicy getSearchPolicy()
- {
- return m_searchPolicy;
}
public synchronized IModule[] getModules()
@@ -41,8 +45,7 @@
return (IModule) m_moduleMap.get(id);
}
- public IModule createModule(
- String id, IContentLoader contentLoader, Object[][] attrs)
+ public IModule createModule(String id)
{
IModule module = null;
@@ -52,7 +55,7 @@
{
if (m_moduleMap.get(id) == null)
{
- module = new ModuleImpl(m_logger, id, m_searchPolicy, m_urlPolicy, contentLoader, attrs);
+ module = new ModuleImpl(m_logger, id);
m_moduleMap.put(id, module);
}
else
@@ -89,10 +92,18 @@
fireModuleRemoved(module);
}
+ public void setContentLoader(IModule module, IContentLoader contentLoader)
+ {
+ synchronized (this)
+ {
+ ((ModuleImpl) module).setContentLoader(contentLoader);
+ }
+ }
+
/**
* <p>
- * Adds a listener to the <tt>ModuleManager</tt> to listen for
- * module added, reset, and removed events.
+ * 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.
**/
@@ -129,7 +140,7 @@
/**
* <p>
- * Removes a listener from the <tt>ModuleManager</tt>.
+ * Removes a listener from the <tt>IModuleFactory</tt>.
* </p>
* @param l the <tt>ModuleListener</tt> to remove.
**/
@@ -186,7 +197,7 @@
/**
* <p>
* Fires an event indicating that the specified module was added
- * to the <tt>ModuleManager</tt>.
+ * to the <tt>IModuleFactory</tt>.
* </p>
* @param module the module that was added.
**/
@@ -214,7 +225,7 @@
/**
* <p>
* Fires an event indicating that the specified module was removed
- * from the <tt>ModuleManager</tt>.
+ * from the <tt>IModuleFactory</tt>.
* </p>
* @param module the module that was removed.
**/
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java Thu Feb 2 02:30:51 2006
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.felix.moduleloader;
import java.net.URL;
-import java.util.*;
import org.apache.felix.framework.Logger;
@@ -20,23 +35,12 @@
private Logger m_logger = null;
private String m_id = null;
- private ISearchPolicy m_searchPolicy = null;
- private IURLPolicy m_urlPolicy = null;
private IContentLoader m_contentLoader = null;
- private Map m_attrMap = new HashMap();
- ModuleImpl(
- Logger logger,
- String id, ISearchPolicy searchPolicy, IURLPolicy urlPolicy,
- IContentLoader contentLoader, Object[][] attrs)
+ ModuleImpl(Logger logger, String id)
{
m_logger = logger;
m_id = id;
- m_searchPolicy = searchPolicy;
- m_urlPolicy = urlPolicy;
- m_contentLoader = contentLoader;
- m_contentLoader.setModuleCallback(new ModuleCallbackImpl(this));
- initialize(attrs);
}
public String getId()
@@ -44,50 +48,21 @@
return m_id;
}
- public ISearchPolicy getSearchPolicy()
- {
- return m_searchPolicy;
- }
-
- public IURLPolicy getURLPolicy()
- {
- return m_urlPolicy;
- }
-
public IContentLoader getContentLoader()
{
return m_contentLoader;
}
- public synchronized Object[][] getAttributes()
+ protected void setContentLoader(IContentLoader contentLoader)
{
- Set s = m_attrMap.entrySet();
- Object[][] attrs = new Object[s.size()][];
- Iterator iter = s.iterator();
- for (int i = 0; iter.hasNext(); i++)
- {
- Map.Entry entry = (Map.Entry) iter.next();
- attrs[i] = new Object[] { entry.getKey(), entry.getValue() };
- }
- return attrs;
- }
-
- public synchronized Object getAttribute(String key, Object defaultValue)
- {
- Object value = m_attrMap.get(key);
- return (value == null) ? defaultValue : value;
- }
-
- public synchronized void setAttribute(String key, Object value)
- {
- m_attrMap.put(key, value);
+ m_contentLoader = contentLoader;
}
public Class getClass(String name)
{
try
{
- return m_searchPolicy.findClass(this, name);
+ return m_contentLoader.getSearchPolicy().findClass(name);
}
catch (ClassNotFoundException ex)
{
@@ -103,7 +78,7 @@
{
try
{
- return m_searchPolicy.findResource(this, name);
+ return m_contentLoader.getSearchPolicy().findResource(name);
}
catch (ResourceNotFoundException ex)
{
@@ -113,14 +88,6 @@
ex);
}
return null;
- }
-
- private void initialize(Object[][] attrs)
- {
- for (int i = 0; (attrs != null) && (i < attrs.length); i++)
- {
- m_attrMap.put(attrs[i][KEY_IDX], attrs[i][VALUE_IDX]);
- }
}
public String toString()
Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleListener.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleListener.java?rev=374342&r1=374341&r2=374342&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleListener.java (original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/moduleloader/ModuleListener.java Thu Feb 2 02:30:51 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 The Apache Software Foundation
+ * Copyright 2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
* <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>ModuleManager</tt> instance.
+ * to the <tt>IModuleFactory</tt> instance.
* </p>
- * @see org.apache.felix.moduleloader.ModuleFactoryImpl
+ * @see org.apache.felix.moduleloader.IModuleFactory
* @see org.apache.felix.moduleloader.ModuleEvent
**/
public interface ModuleListener extends EventListener
@@ -32,7 +32,7 @@
/**
* <p>
* This method is called after a module is added to the
- * <tt>ModuleManager</tt>.
+ * <tt>IModuleFactory</tt>.
* </p>
* @param event the event object containing the event details.
**/
@@ -41,7 +41,7 @@
/**
* <p>
* This method is called after a module is remove from the
- * <tt>ModuleManager</tt>.
+ * <tt>IModuleFactory</tt>.
* </p>
* @param event the event object containing the event details.
**/