Hi All,
After thinking about how to customize the system bundle cache, with a eye on
not making the base code bigger, it struck me that the simplest thing to do
would be to pass a BundleCache implementation in the configuration map that is
passed to the Felix construction, as is done for system activators.
So for now I have added this code to the FelixConstants class...
public static final String SYSTEMBUNDLE_BUNDLE_CACHE
= "felix.systembundle.bundle.cache";
and I added this code to the Felix.init method...
// Create the bundle cache, if necessary, so that we can reload any installed
bundles.
m_cache= (BundleCache)
m_configMutableMap.get(FelixConstants.SYSTEMBUNDLE_BUNDLE_CACHE);
if (m_cache == null)
{
try
{
m_cache = new BundleCache(m_logger, m_configMap);
}
catch (Exception ex)
{
m_logger.log(Logger.LOG_ERROR, "Error creating bundle cache.", ex);
throw new BundleException("Error creating bundle cache.", ex);
}
}
then in my code I do this....
configMap.put(FelixConstants.SYSTEMBUNDLE_BUNDLE_CACHE, new
Felix4GAEBundleCache());
Felix framework= new Felix(configMap);
I have attached a patch file if you are inclined to apply these changes.
Thanks,
-ted
BTW, I will release felix4gae here, http://code.google.com/p/felix4gae.
I am working on this in the evenings so it will probably take a couple of weeks.
--- On Fri, 5/1/09, Richard S. Hall <[email protected]> wrote:
> From: Richard S. Hall <[email protected]>
> Subject: Re: Custom BundleCache?
> To: [email protected]
> Date: Friday, May 1, 2009, 12:44 PM
> On 5/1/09 8:37 AM, Ted Stockwell wrote:
> >
> > Is the custom BundleCache something that the Felix
> group might be interested in merging back into the Felix
> code? (that's another reason for my asking, it would be
> nice if eventually my custom version of Felix was extending
> Felex in a supported fashion instead of 'hacking'
> Felix with some custom classes).
> >
>
> I would be interested in an improved abstraction for
> Felix' bundle cache, but I wouldn't want anything
> too heavyweight. I am not sure how sophisticated/complicated
> the Apache VFS is, but if it were to add more than just a
> few classes, it would likely be too much for me. And it also
> couldn't introduce any dependencies on Java 5 or beyond.
>
> Is that do-able? If so, we can definitely talk more about
> it.
>
> -> richard
>
### Eclipse Workspace Patch 1.0
#P org.apache.felix.framework
Index: src/main/java/org/apache/felix/framework/util/FelixConstants.java
===================================================================
--- src/main/java/org/apache/felix/framework/util/FelixConstants.java
(revision 771005)
+++ src/main/java/org/apache/felix/framework/util/FelixConstants.java
(working copy)
@@ -46,6 +46,8 @@
public static final String LOG_LOGGER_PROP = "felix.log.logger";
public static final String SYSTEMBUNDLE_ACTIVATORS_PROP
= "felix.systembundle.activators";
+ public static final String SYSTEMBUNDLE_BUNDLE_CACHE
+ = "felix.systembundle.bundle.cache";
public static final String BUNDLE_STARTLEVEL_PROP
= "felix.startlevel.bundle";
public static final String SERVICE_URLHANDLERS_PROP =
"felix.service.urlhandlers";
Index: src/main/java/org/apache/felix/framework/Felix.java
===================================================================
--- src/main/java/org/apache/felix/framework/Felix.java (revision 771005)
+++ src/main/java/org/apache/felix/framework/Felix.java (working copy)
@@ -486,15 +486,19 @@
// Initialize event dispatcher.
m_dispatcher = EventDispatcher.start(m_logger);
- // Create the bundle cache so that we can reload any installed
bundles.
- try
- {
- m_cache = new BundleCache(m_logger, m_configMap);
- }
- catch (Exception ex)
+ // Create the bundle cache, if necessary, so that we can reload
any installed bundles.
+ m_cache= (BundleCache)
m_configMutableMap.get(FelixConstants.SYSTEMBUNDLE_BUNDLE_CACHE);
+ if (m_cache == null)
{
- m_logger.log(Logger.LOG_ERROR, "Error creating bundle cache.",
ex);
- throw new BundleException("Error creating bundle cache.", ex);
+ try
+ {
+ m_cache = new BundleCache(m_logger, m_configMap);
+ }
+ catch (Exception ex)
+ {
+ m_logger.log(Logger.LOG_ERROR, "Error creating bundle
cache.", ex);
+ throw new BundleException("Error creating bundle
cache.", ex);
+ }
}
// If this is the first time init is called, check to see if
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]