wiki:GnowsisConfiguration

To configure your services, you have a folder inside the user's path. The folder is called .gnowsis and inside that you either have 'config' or 'data'. Each service has it's own file space where all resources (so called managed resources) reside it needs to run.

How do I populate the service's file space?

Each service can have a 'default' folder in his WEB-INF folder which may contain default files, e.g. initial service settings.

The service runtime supports copying resources from the default folder into the service's file space through the ConfigManager class. Extend AbstractServiceImplementation for your service implementation to have getConfigManager() available.

   final ConfigManager cfgManager = getConfigManager();
   log( "Service default folder:" + cfgManager.getDefaultDir() );
   log( "Service file space for managed resources:" + cfgManager.getManagedResourceDir() );

You can now copy resources from the default folder to your service file space. Resource names are relative paths in your default folder and have to start with either config/ or data/

example for a resource 'config/setting.xml' ('data/setting.xml' respectively) of service 'ExampleService':
 ExampleService/WEB-INF/default/config/setting.xml
is copied to 
.gnowsis/config/ExampleService/setting.xml

and 
ExampleService/WEB-INF/default/data/setting.xml
is copied to 
.gnowsis/data/ExampleService/setting.xml

The ConfigManager provides methods to accomplish this copy operation

        //copy the resource only if it is not already present in the service file space
        cfgManager.copyResourceFromDefaultIfNew( "config/setting.xml" );

        //even copy whole direcories (and subdirectories)
        cfgManager.copyResourceFolderFromDefaultIfNew( "data" );

        //force a copy
        cfgManager.forceCopyOfResource( getDefaultResourceAsFile( "config/setting.xml" ),   // ExampleService/WEB-INF/default/config/setting.xml
                                        getManagedResourceAsFile( "config/setting.xml" ) ); //<home>/.gnowsis/config/ExampleService/setting.xml


        //check whether a resource exists
        boolean b = cfgManager.resourceDoesExist( "config/setting.xml" );   //<home>/.gnowsis/config/ExampleService/setting.xml
Last modified 11 years ago Last modified on 12/13/05 12:16:07