Why would you want to create a service this way?  Why wouldn’t you just create a HelloImpl class which implements your service interface and use BuilderFactory to instantiate it?

 


From: 张博 [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 15, 2005 12:57 AM
To: [email protected]
Subject: A problem about ServiceImplementationFactory

 

Hello everyone:

I'm new to hivemind. I'm from China.
I want to use ServiceImplementationFactory to produce Service, here is the code:
------------------------------

------------------------------------------------------------------------------------------------------
Interface: Hello.java
package cn.topsmart.test;

public interface Hello {
   
    public void sayHello();

}
---------------------------------------------------------------------------------------------------------------------------------------
HelloFactory.java
package cn.topsmart.test;

import org.apache.hivemind.ServiceImplementationFactory;
import org.apache.hivemind.ServiceImplementationFactoryParameters;

public class HelloFactory implements ServiceImplementationFactory {

    public Object createCoreServiceImplementation(
            ServiceImplementationFactoryParameters factoryParameters) {
        return new Hello(){
            public void sayHello() {
                System.out.println("hello..............");
            }
        };
    }

}
-------------------------------------------------------------------------------------------------------------------------------------------------
hivemodule.xml
<?xml version="1.0"?>

<module id="topsmart" version="0.0.1">
   
    <service-point id="HelloFactory" interface="org.apache.hivemind.ServiceImplementationFactory"/>
    <service-point id="Hello" interface="cn.topsmart.test.Hello"/>
   
    <implementation service-id="HelloFactory">
        <invoke-factory>
            <construct class="cn.topsmart.test.HelloFactory"/>
        </invoke-factory>
    </implementation>
    <implementation service-id="Hello">
        <invoke-factory service-id="HelloFactory"/>
    </implementation>
   
</module>
-------------------------------------------------------------------------------------------------------------------------------------
Test.java
Hello hello = (Hello)registry.getService(Hello.class);
hello.sayHello();
-----------------------------------------------------------------------------------------------------------------------------------
But when I run the test code, the mistake appears:
[EMAIL PROTECTED]:16:58 ERROR (topsmart.Hello)     - Error at file:/E:/projects/topsmart/build/classes/META-INF/hivemodule.xml, line 14, column 46: Parameters to service implementation factory HelloFactory contains no contributions but expects exactly one contribution.
I did not know why this is? Was any place makes a mistake?
Thanks!

Reply via email to