glassfish - Storing and editing configuration for Java EE applications -


update : See my blog post on this topic about one year in this writing:

... in context of the Java EE7 plan discussion on this topic.


I have finished writing a small Java EE6 application, and in the process, by changing the hard-coded preferences with the appropriate dynamic configuration interface.

I'm not sure how - or, more specifically, where - to store settings, something like that should be done in a clear, "standard" way that " Work ", but I am not getting this for my life.

What I want is a simple way to load and store settings, which works in various app servers and OS, does not require any kind of information by the user, and really works properly . Java Preferences API will be ideal - but looks like broken under glassfish 3.1.

Option configuration for the storage will be theoretically involved:

  1. Using context-parameters from the container environment
  2. Using the Java Preferences API
  3. To read / write a property file ... somewhere
  4. To store JPA in a javdib provided by the container
  5. Putting it loaded from classpath into the property file
  6. A Using system properties to set the configuration options, or path of the .properties file

    This appears to be a basic requirement that is well-prepared in such an environment where The container estimates that you need all the major services that you may need - but there are problems in all these approaches.

    A render (1) ineffective, and in any case there is any scope to configure the reference parameter in the webfish user interface, hence you have to use `esdmin 'and To do something less than beautiful command line sync, tax reference parameters can only be accessed through ServletContext - which is not accessible in a consistent way between frameworks such as JSF2, JAX-RS, and raw servlets - take Following at least seam handles service.

    What else appears in the glassfish A library version was opposed between a deployment app and glassfish brake (2). Preferences fails to flush the preferences on the backend disk, so the stored preference data is lost when the application server restarts. Despite being included in Java EE 6 specs, the Java Preferences API is also considered as a J2SE / desktop object.

    (3) Can work - but there is no way to know how to read your app / write an account on file system and see it. You can not make this configuration because it becomes a chicken-egg problem. Different platform-specific estimates can be implemented, but will break into the presence of the security manager.

    (4) will work, but it looks like a fly. It requires that a Javadi service is in progress and forces the user to ensure that the APIs and Junkies in the AP server Is properly configured. It's big and complex for a simple job, and entity modeling is not a beautiful fit for storing preferences anyway, because it will be structured mostly in the key / value.

    (5) will work, but users must know where config files should be placed, where it will be found under various different app servers, to provide any kind of configuration UI Makes it difficult because it can not necessarily find the local path of the config file or it can open specifically to write in the presence of security manager.

    (6) will also work, but forces the user to configure the configuration system before configuring the user. Needless to say, it does not excite me, seeing that the deployment of the app is complicated and already the resources are created for those users who do not already know the glassfish / EE.

    So ... how are you handling configuration and storage options? Have you found a way to help you configure your app to store its configuration, without the user "just do this"?

    The problem with the Priorities API was due to the inclusion of jaxb and stax implementation jar in the war of application drawn by jersey-json. With these exclusions (anyway they are made available by the app server) the preferences APIs are working properly.

    It seems that the Prefs API is the best way with custom UI for setup. / P>

Comments