You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by 张博 <li...@gmail.com> on 2005/06/15 06:51:17 UTC

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:
06-15@10: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!

Re: A problem about ServiceImplementationFactory

Posted by Knut Wannheden <kn...@gmail.com>.
Hi,

The problem in your case is that you haven't set the
"parameters-occurs" attribute for your HelloFactory service. The
default value is "1" (see
http://jakarta.apache.org/hivemind/descriptor.html#service-point), but
in your case you want parameters-occurs="none".

Hope that helps,

--knut

On 6/15/05, 张博 <li...@gmail.com> wrote:
> Hello everyone:
>  
>  I'm new to hivemind. I'm from China.
>  I want to use ServiceImplementationFactory to produce Service, here is the
> code:
>