You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pieter (Created) (JIRA)" <ji...@apache.org> on 2012/03/14 17:58:38 UTC

[jira] [Created] (FELIX-3395) Make preferences persistence location configurable

Make preferences persistence location configurable
--------------------------------------------------

                 Key: FELIX-3395
                 URL: https://issues.apache.org/jira/browse/FELIX-3395
             Project: Felix
          Issue Type: Wish
          Components: Preferences Service
            Reporter: Pieter


I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.

I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
{code:java}
        String configuredRootDir = System.getProperty("felix.prefs.rootdir");
        this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
        this.rootDirectory.mkdirs();
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229670#comment-13229670 ] 

Pieter commented on FELIX-3395:
-------------------------------

I forgot one thing; DataFileBackingStoreImpl is in a package private, so I cannot extend it. Can that be "fixed" too?
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229667#comment-13229667 ] 

Pieter commented on FELIX-3395:
-------------------------------

Indeed, that's a better solution. Could this version be released? It would save some hassle to get a snapshot in my production environment.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229640#comment-13229640 ] 

Pieter commented on FELIX-3395:
-------------------------------

Actually, thas was my first attempt to fix this. Since what I wanted was just a small extension to DataFileBackingStoreImpl, I started by subclassing that store and registering it as a service. Only change needed was setting the protected rootdirectory property. However, since rootdirectory is final, I could not do that, so I ended up copying DataFileBackingStoreImpl and adding a line. If you would make that property not final, that would help too.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Richard S. Hall (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229474#comment-13229474 ] 

Richard S. Hall commented on FELIX-3395:
----------------------------------------

Yep, as I said, it is certainly do-able. The only downside is there is no cross-bundle solution for this. So, I'm not arguing against it in Preferences, just pointing out you run the risk of swimming against the tide if you use the OSGi framework in a way that it wasn't intended.

Regarding your "update" issue with Pax Runner...if they really only support clean cache provisioning, I'd recommend looking into a different solution. 
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Richard S. Hall (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229429#comment-13229429 ] 

Richard S. Hall commented on FELIX-3395:
----------------------------------------

You could probably do that, but technically the Preferences impl is doing the right thing, since it should store data in its private data area. It seems like you should configure Pax Runner to not delete the cache for each run otherwise you'll run into this issue with every bundle that "correctly" saves data to is private data area.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229464#comment-13229464 ] 

Pieter commented on FELIX-3395:
-------------------------------

I can easily configure Pax Runner not the delete the cache, but that introduced another problem for me, see http://groups.google.com/group/ops4j/browse_thread/thread/eca643395acbd529. You are right that this might be a problem for every bundle that saves it's data to the private area, but luckily for me I don't use other bundles doing so.

Storing the data in the bundle's private area is a good approach, I wouldn't argue that. However, the Preferences javadoc (http://www.osgi.org/javadoc/r4v41/org/osgi/service/prefs/Preferences.html) states that "This data is stored persistently in an implementation-dependent backing store. Typical implementations include flat files, OS-specific registries, directory servers and SQL databases.", which led me to the idea that a configurable location might be a good idea. 
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229493#comment-13229493 ] 

Pieter commented on FELIX-3395:
-------------------------------

I might agree with you last remark. I like Pax Runner as a way to provision using a Maven repository, but dumping the cache is not an elegant thing to do. I'll see which solution I can find in that area, but that's another issue. Still I would love to have this feature, because it solves (works around) my problem. As a final argument to sell it I would say it offers more freedom. For people who don't use it, it doesn't harm. But maybe there are more people like me, who for some reason would like to persist this data on a specific location.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Marcel Offermans (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229612#comment-13229612 ] 

Marcel Offermans commented on FELIX-3395:
-----------------------------------------

Instead of trying to support such features in the default implementation, why don't you write your own BackingStore? The preferences bundle was designed to allow you to plug in different storage back-ends.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FELIX-3395) Make preferences persistence location configurable

Posted by "Pieter (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pieter updated FELIX-3395:
--------------------------

    Description: 
I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.

I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:

        String configuredRootDir = System.getProperty("felix.prefs.rootdir");
        this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
        this.rootDirectory.mkdirs();


  was:
I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.

I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
{code:java}
        String configuredRootDir = System.getProperty("felix.prefs.rootdir");
        this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
        this.rootDirectory.mkdirs();
{code}

    
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3395) Make preferences persistence location configurable

Posted by "Marcel Offermans (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13229654#comment-13229654 ] 

Marcel Offermans commented on FELIX-3395:
-----------------------------------------

Instead of making it non-final, I just committed a small patch that adds a new constructor that allows you to explicitly set the root directory. Once set, I think it makes sense that this property is final.
                
> Make preferences persistence location configurable
> --------------------------------------------------
>
>                 Key: FELIX-3395
>                 URL: https://issues.apache.org/jira/browse/FELIX-3395
>             Project: Felix
>          Issue Type: Wish
>          Components: Preferences Service
>            Reporter: Pieter
>
> I want Preference Service to persist stored preferences and have them survive system restarts. Preference Service stores its stuff in the OSGi frameworks' cache region, which get cleared on restart (by Pax Runner, which is what I use). Trying to get around this was problematic, so I figured it would be nice to be able have the preferences database outside the cache directory. A system property like "felix.prefs.rootdir" could be used to set the location.
> I patched the Preference Service from trunk to get this feature and the changes are minimal, I just added the following lines to the DataFileBackingStoreImpl constructor:
>         String configuredRootDir = System.getProperty("felix.prefs.rootdir");
>         this.rootDirectory = configuredRootDir == null ? context.getDataFile("") : new File(configuredRootDir);
>         this.rootDirectory.mkdirs();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira