Archived

This forum has been archived. Please start a new discussion on GitHub.

Is it possible to use custom plugin in IceGrid?

Hi everyone,I wonder if it is possible to use custom plugin in IceGrid? I have tried,but it didn't work.Can anyone tell me what's the problem?Thanks advanced.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Could you be more specific and describe what you tried and the problem you encountered? Please also specify the Ice version and operation system you're using.

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    Could you be more specific and describe what you tried and the problem you encountered? Please also specify the Ice version and operation system you're using.

    Cheers,
    Benoit.
    Hi,Benoit,thanks for your reply.I have written a simple ICE plugin like following:
    using System;
    
    namespace Plugin
    {
        public class MyPlugin : Ice.Plugin
        {
            #region Plugin Members
    
            public void destroy()
            {
                Console.WriteLine("MyPlugin has been destroyed.");
            }
    
            public void initialize()
            {
                Console.WriteLine("MyPlugin has been initialized.");
            }
    
            #endregion
        }
    }
    
    and the plugin factory is like this:
    namespace Plugin
    {
        public class MyPluginFactoryI : Ice.PluginFactory
        {
            #region PluginFactory Members
    
            public Ice.Plugin create(Ice.Communicator communicator, string name, string[] args)
            {
                return new MyPlugin();
            }
    
            #endregion
        }
    }
    
    and then I wrote a simple ICE program to load the plugin:
    using System;
    
    namespace Plugin.Demo
    {
        class Program
        {
            static void Main(string[] args)
            {
                App app = new App();
                app.main(args, "config.server");
    
                Console.Read();
            }
    
            class App : Ice.Application
            {
    
                public override int run(string[] args)
                {
                    //communicator().waitForShutdown();
                    return 0;
                }
            }
        }
    }
    
    with a config.server file:
    #
    # MyPlugin Configuration
    #
    Ice.Plugin.MyPlugin=MyPlugin:Plugin.MyPluginFactoryI
    
    It all works well.The problem is,is it possible to load the plugin in IceGrid,not as a service but as a plugin?
  • benoit
    benoit Rennes, France
    Hi,

    No, you can't directly load the plugin with IceGrid. Ice plugins can only be loaded by an Ice communicator object which is usually instantiated by a server process or an IceBox service. Did you look into using an IceBox service instead? What is the purpose of your Ice plugin?

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    No, you can't directly load the plugin with IceGrid. Ice plugins can only be loaded by an Ice communicator object which is usually instantiated by a server process or an IceBox service. Did you look into using an IceBox service instead? What is the purpose of your Ice plugin?

    Cheers,
    Benoit.

    Hi Benoit,

    I have a group of services which is hosted by IceGrid,and these services all depend on a common base service(CommonService),so I want to implement CommonService as a plugin.Of course it can be implemented as a service.But today I found that the services deployed in IceGrid are all single process,so it means these services can't share the CommonService,because they are not in the same process!

    I have found another solution which uses IceBox.First, deploy the services in IceBox,and then deploy the IceBox in IceGrid.But this solution has some disadvantages,for example,the activate mode.In the past, I could set the activate mode to on-demand for every service,but now I can only set the activate mode to on-demand for the IceBox which hosts a group of services.What's worse,services have to explicitly set the endpoints.Any better suggestions?Forgive my poor English!:-)