Пример #1
0
        /// <summary>
        /// Loads and initializes adapter loaders.
        /// </summary>
        /// <param name="services">is the engine instance services</param>
        private void LoadAdapters(EPServicesContext services)
        {
            var pluginLoaders = _configSnapshot.PluginLoaders;

            if ((pluginLoaders == null) || (pluginLoaders.Count == 0))
            {
                return;
            }
            foreach (var config in pluginLoaders)
            {
                var  className = config.TypeName;
                Type pluginLoaderClass;
                try
                {
                    pluginLoaderClass = services.EngineImportService.GetClassForNameProvider().ClassForName(className);
                }
                catch (TypeLoadException ex)
                {
                    throw new ConfigurationException("Failed to load adapter loader class '" + className + "'", ex);
                }

                Object pluginLoaderObj;
                try
                {
                    pluginLoaderObj = Activator.CreateInstance(pluginLoaderClass);
                }
                catch (TypeLoadException)
                {
                    throw new ConfigurationException("Class '" + pluginLoaderClass + "' cannot be instantiated");
                }
                catch (MissingMethodException e)
                {
                    throw new ConfigurationException(
                              "Error instantiating class - Default constructor was not found", e);
                }
                catch (MethodAccessException e)
                {
                    throw new ConfigurationException(
                              "Error instantiating class - Caller does not have permission to use constructor", e);
                }
                catch (ArgumentException e)
                {
                    throw new ConfigurationException("Error instantiating class - Type is not a RuntimeType", e);
                }

                if (!(pluginLoaderObj is PluginLoader))
                {
                    throw new ConfigurationException(
                              "Failed to cast adapter loader class '" + className + "' to " + typeof(PluginLoader).FullName);
                }

                var pluginLoader = (PluginLoader)pluginLoaderObj;
                var context      = new PluginLoaderInitContext(
                    config.LoaderName, config.ConfigProperties, config.ConfigurationXML, this);
                pluginLoader.Init(context);

                // register adapter loader in JNDI context tree
                services.EngineEnvContext.Bind("plugin-loader/" + config.LoaderName, pluginLoader);
            }
        }
Пример #2
0
 public void Init(PluginLoaderInitContext context)
 {
     if (context.Properties.Get(ENGINE_URI) != null)
     {
         _engineURI = context.Properties.Get(ENGINE_URI);
     }
     else
     {
         _engineURI = context.EpServiceProvider.URI;
     }
 }
Пример #3
0
 public void Init(PluginLoaderInitContext context)
 {
     if (context.Properties.Get(RUNTIME_URI) != null)
     {
         _engineURI = context.Properties.Get(RUNTIME_URI);
     }
     else
     {
         _engineURI = context.Runtime.URI;
     }
 }
Пример #4
0
        /// <summary>
        ///     Loads and initializes adapter loaders.
        /// </summary>
        /// <param name="services">is the runtime instance services</param>
        private void LoadAdapters(EPServicesContext services)
        {
            var pluginLoaders = _configLastProvided.Runtime.PluginLoaders;
            if (pluginLoaders == null || pluginLoaders.Count == 0) {
                return;
            }

            foreach (var config in pluginLoaders) {
                var className = config.ClassName;
                Type pluginLoaderClass;
                try {
                    pluginLoaderClass = services.ClassForNameProvider.ClassForName(className);
                }
                catch (TypeLoadException ex) {
                    throw new ConfigurationException("Failed to load adapter loader class '" + className + "'", ex);
                }

                object pluginLoaderObj;
                try {
                    pluginLoaderObj = TypeHelper.Instantiate(pluginLoaderClass);
                }
                catch (Exception ex) {
                    throw new ConfigurationException("Failed to instantiate adapter loader class '" + className + "' via default constructor", ex);
                }

                if (!(pluginLoaderObj is PluginLoader)) {
                    throw new ConfigurationException("Failed to cast adapter loader class '" + className + "' to " + typeof(PluginLoader).Name);
                }

                var pluginLoader = (PluginLoader) pluginLoaderObj;
                var context = new PluginLoaderInitContext(config.LoaderName, config.ConfigProperties, config.ConfigurationXML, this);
                pluginLoader.Init(context);

                // register adapter loader in JNDI context tree
                try {
                    services.RuntimeEnvContext.Bind("plugin-loader/" + config.LoaderName, pluginLoader);
                }
                catch (Exception e) {
                    throw new EPException("Failed to use context to bind adapter loader", e);
                }
            }
        }
Пример #5
0
 public void Init(PluginLoaderInitContext context)
 {
     Names.Add(context.Name);
     Props.Add(context.Properties);
     _properties = context.Properties;
 }