Search in sources :

Example 1 with ModuleManager

use of org.cristalise.kernel.process.module.ModuleManager in project kernel by cristal-ise.

the class Gateway method init.

/**
 * Initialises the Gateway and all of the client objects it holds, with
 * the exception of the Lookup, which is initialised during connect()
 *
 * @param props - java.util.Properties containing all application properties.
 * If null, the java system properties are used
 * @param res - ResourceLoader for the kernel to use to resolve all class resource requests
 * such as for bootstrap descriptions and version information
 * @throws InvalidDataException - invalid properties caused a failure in initialisation
 */
public static void init(Properties props, ResourceLoader res) throws InvalidDataException {
    // Init properties & resources
    mC2KProps.clear();
    orbDestroyed = false;
    mResource = res;
    if (mResource == null)
        mResource = new Resource();
    // report version info
    Logger.msg("Gateway.init() - Kernel version: " + getKernelVersion());
    // the application to be able to configure castor
    try {
        mMarshaller = new CastorXMLUtility(mResource, props, mResource.getKernelResourceURL("mapFiles/"));
    } catch (MalformedURLException e1) {
        throw new InvalidDataException("Invalid Resource Location");
    }
    Properties allModuleProperties;
    // init module manager
    try {
        mModules = new ModuleManager(AbstractMain.isServer);
        allModuleProperties = mModules.loadModules(mResource.getModuleDefURLs());
    } catch (Exception e) {
        Logger.error(e);
        throw new InvalidDataException("Could not load module definitions.");
    }
    // merge in module props
    for (Enumeration<?> e = allModuleProperties.propertyNames(); e.hasMoreElements(); ) {
        String propName = (String) e.nextElement();
        mC2KProps.put(propName, allModuleProperties.get(propName));
    }
    // Overwrite with argument props
    if (props != null)
        mC2KProps.putAll(props);
    // dump properties
    Logger.msg("Gateway.init() - DONE");
    dumpC2KProps(7);
}
Also used : MalformedURLException(java.net.MalformedURLException) Resource(org.cristalise.kernel.process.resource.Resource) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectProperties(org.cristalise.kernel.utils.ObjectProperties) Properties(java.util.Properties) ModuleManager(org.cristalise.kernel.process.module.ModuleManager) CastorXMLUtility(org.cristalise.kernel.utils.CastorXMLUtility) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) MalformedURLException(java.net.MalformedURLException) PersistencyException(org.cristalise.kernel.common.PersistencyException) CannotManageException(org.cristalise.kernel.common.CannotManageException)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 Properties (java.util.Properties)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 ModuleManager (org.cristalise.kernel.process.module.ModuleManager)1 Resource (org.cristalise.kernel.process.resource.Resource)1 CastorXMLUtility (org.cristalise.kernel.utils.CastorXMLUtility)1 ObjectProperties (org.cristalise.kernel.utils.ObjectProperties)1