Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

KKernel Class Reference

Collaboration diagram for KKernel:

Collaboration graph
[legend]
List of all members.

Static Public Methods

Context newConfiguration (Context _context, Class _c)

Static Private Attributes

Container containers = null
ConfigurationFactory configuration_factory = new JConfigurationFactory()

Detailed Description

Bootstrap class of the jonathan configuration mechanism. Provides the runtime configuration file mechanism by using XML decoders and loads the java system properties.

Must be provided in the application's compiled configuration by specifying the bootstrap attribute of the root context in the XML configuration file to be compiled. KKernel is loaded in the java code of the compiled configuration file.

<U>jonathan's example of KKernel use:</U>

Definition at line 74 of file KKernel.java.


Member Function Documentation

Context KKernel::newConfiguration ( Context _context,
Class _c ) [inline, static]
 

The jonathan Kernel's runtime bootstrap mechanism. This method

  • loads its context parameter's /jonathan/KKernel/xml_decoder value; it must be an implementation of File2Configuration
  • loads its context parameter's /jonathan/KKernel/runtime_configuration_file String property and decodes the corresponding runtime configuration file with the previously loaded decoder; the decoded components are imported in a duplicata of the given Context parameter.
  • loads its context parameter's /jonathan/KKernel/properties_decoder (it must be an implementation of Properties2Configuration) and uses it to import the java System properties
Parameters:
_context   the compiled configuration to bootstrap on
_c  
Returns:
the application's complete runtime configuration

Definition at line 101 of file KKernel.java.

00101                                                                      {
00102       ClassLoader $loader = null;
00103       try {
00104          $loader = _c.getClassLoader();
00105       } catch (Exception e) {
00106          e.printStackTrace();
00107       }
00108 
00109       Container $current = containers;
00110       while ($current != null) {
00111          if ($loader == $current.loader && _context == $current.source) {
00112             return $current.returned_context;
00113          } else {
00114             $current = $current.next;
00115          }
00116       }
00117 
00118       ClassPathFinder $class_path_finder = new ClassPathFinderImpl($loader);
00119 
00120       Context $toBeReturned =
00121          configuration_factory.newContext(_context,$class_path_finder);
00122 
00123       Object $xml_file_name = null;
00124       try {
00125          $xml_file_name = System.getProperty("jonathan.KKernel.runtime_configuration_file");
00126       } catch (Exception _) {
00127       }
00128       
00129       if ($xml_file_name == null) {
00130           $xml_file_name =
00131              _context.getValue("/jonathan/KKernel/runtime_configuration_file",'/');
00132       }
00133 
00134       if ($xml_file_name instanceof String) {
00135          Object $component = $toBeReturned.getValue("/jonathan/KKernel/xml_decoder",'/');
00136          if ($component instanceof File2Configuration) {
00137             File2Configuration $xml_decoder = (File2Configuration) $component;
00138             try {
00139                $xml_decoder.importElement($toBeReturned,(String) $xml_file_name,configuration_factory,
00140                                           $class_path_finder);
00141             } catch (JonathanException e) {
00142                Exception actual = e.represents();
00143                if (actual instanceof IOException) {
00144                   System.err.println("Warning : error when trying to import the runtime configuration from " + 
00145                                      $xml_file_name +": " + e);
00146                   $toBeReturned = configuration_factory.newContext(_context,$class_path_finder);
00147                } else {
00148                   System.err.println("Error importing the runtime configuration from " + 
00149                                      $xml_file_name +".");
00150                   e.printStackTrace();
00151                }
00152             }
00153          } else {
00154             System.err.println("Warning: no XML decoder associated with KKernel to read input from " +
00155                                $xml_file_name);
00156          }
00157       }
00158       
00159       Properties system_properties = null;
00160       try {
00161          system_properties = System.getProperties();
00162       } catch (SecurityException ignored) {
00163          ignored.printStackTrace();
00164       }
00165 
00166       if (system_properties != null) {
00167          Object $component = $toBeReturned.getValue("/jonathan/KKernel/properties_decoder",'/');
00168          if ($component instanceof Properties2Configuration) {
00169             Properties2Configuration $properties_decoder = (Properties2Configuration) $component;
00170             try {
00171                $properties_decoder.importProperties($toBeReturned, system_properties, 
00172                                                     new String[] {"java.", "file."}, true);
00173             } catch (JonathanException e) {
00174                System.err.println("Warning : error when trying to import system properties: " + e);
00175             }
00176          } else {
00177             System.err.println("Warning: no properties decoder associated with KKernel to\n" + 
00178                                "         import the system properties.");
00179          }
00180       }
00181       
00182       // -------------------
00183 
00184       containers = new Container(_context,$loader,$toBeReturned,containers);
00185       return $toBeReturned;
00186    }


Member Data Documentation

ConfigurationFactory KKernel::configuration_factory = new JConfigurationFactory() [static, private]
 

Definition at line 77 of file KKernel.java.

Container KKernel::containers = null [static, private]
 

Definition at line 76 of file KKernel.java.


The documentation for this class was generated from the following file:
Generated at Fri May 31 19:24:41 2002 for Jonathan by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001