Changes between Version 1 and Version 2 of GnowsisConfiguration


Ignore:
Timestamp:
Dec 13, 2005, 12:16:07 PM (21 years ago)
Author:
Andreas.Lauer@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GnowsisConfiguration

    v1 v2  
    11To configure your services, you have a folder inside the user's path. The folder is called
    2 .gnowsis and inside that you either have config or data.
     2.gnowsis and inside that you either have 'config' or 'data'. Each service
     3has it's own file space where all resources (so called managed resources) reside it needs to run.
     4
     5'''How do I populate the service's file space?'''
     6
     7 Each service can have a 'default' folder in his WEB-INF folder which may contain default
     8 files, e.g. initial service settings.
     9
     10 The service runtime supports copying resources from the default folder into the
     11 service's file space through the ''ConfigManager'' class.
     12 Extend ''AbstractServiceImplementation'' for your service implementation to have ''getConfigManager()'' available.
     13
     14{{{
     15   final ConfigManager cfgManager = getConfigManager();
     16   log( "Service default folder:" + cfgManager.getDefaultDir() );
     17   log( "Service file space for managed resources:" + cfgManager.getManagedResourceDir() );
     18}}}
     19
     20 You can now copy resources from the default folder to your service file space. Resource names
     21 are relative paths in your default folder and have to start with either config/ or data/
     22
     23{{{
     24example for a resource 'config/setting.xml' ('data/setting.xml' respectively) of service 'ExampleService':
     25 ExampleService/WEB-INF/default/config/setting.xml
     26is copied to
     27.gnowsis/config/ExampleService/setting.xml
     28
     29and
     30ExampleService/WEB-INF/default/data/setting.xml
     31is copied to
     32.gnowsis/data/ExampleService/setting.xml
     33}}}
     34
     35 The !ConfigManager provides methods to accomplish this copy operation
     36
     37{{{
     38        //copy the resource only if it is not already present in the service file space
     39        cfgManager.copyResourceFromDefaultIfNew( "config/setting.xml" );
     40
     41        //even copy whole direcories (and subdirectories)
     42        cfgManager.copyResourceFolderFromDefaultIfNew( "data" );
     43
     44        //force a copy
     45        cfgManager.forceCopyOfResource( getDefaultResourceAsFile( "config/setting.xml" ),   // ExampleService/WEB-INF/default/config/setting.xml
     46                                        getManagedResourceAsFile( "config/setting.xml" ) ); //<home>/.gnowsis/config/ExampleService/setting.xml
    347
    448
    5 Suggestion, that is not binding:
    6 each service has his web-inf folder, where you make a 'default' folder. During
    7 your config api init, you get the ServiceContext object, which has a method like
    8 "getServicePath" which returns the folder containing the WEB-INF. ie the
    9 "epos_context" path is returned.
    10 
    11 you then call ConfigBlubManager.checkAndCopy(folderA, folderB) to check and copy
    12 the defaults. the semantic of checkAndCopy is to copy everything that is to copy
    13 everything from A to B that is not in B already. if a file in b already exists,
    14 don't overwrite it.
    15 
    16 {{{
    17 example for such an config dir:
    18 blubservice/WEB-INF/default/config/setting.xml
    19 is copied to
    20 .gnowsis/config/blubservice/setting.xml
    21 
    22 and
    23 blubservice/WEB-INF/default/data/setting.xml
    24 is copied to
    25 .gnowsis/data/blubservice/setting.xml
     49        //check whether a resource exists
     50        boolean b = cfgManager.resourceDoesExist( "config/setting.xml" );   //<home>/.gnowsis/config/ExampleService/setting.xml
    2651}}}