Hi everybody,
I'm new to Hivemind and I try to understand and make work model
in the configuration of <invoke-instance> and <create-instance>.
I put the attribute model in these tags with the value 'primitive'.
I guess that it will create an instance every time I get a service
in order to call a method on it.
Here are my configuration files:
1�) configuration.xml:
<?xml version="1.0"?>
<module id="service" version="1.0.0">
<sub-module descriptor="configuration-interface.xml"/>
<sub-module descriptor="configuration-impl.xml"/>
</module>
2�) configuration-interface.xml:
<?xml version="1.0"?>
<module id="interfaces" version="1.0.0">
<service-point id="MonService" interface="service.IMonService" model="primitive"/>
<service-point id="MonDao" interface="dao.IMonDao"/>
</module>
3�) configuration-impl.xml:
<?xml version="1.0"?>
<module id="implementations" version="1.0.0">
<implementation service-id="interfaces.MonService">
<!-- create-instance class="service.MonService"/ -->
<invoke-factory model="primitive">
<construct class="service.MonService">
<set-service property="dao" service-id="interfaces.MonDao"/>
</construct>
</invoke-factory>
</implementation>
<implementation service-id="interfaces.MonDao">
<create-instance class="dao.MonDao" model="primitive"/>
</implementation>
</module>
Here is my main class:
public class Main {
public static void main(String[] args) {
String path = "/configuration.xml";
RegistryBuilder builder = new RegistryBuilder();
ClassResolver resolver = new DefaultClassResolver();
builder.processModules(resolver);
builder.processModule(resolver, new ClasspathResource(resolver,path));
Registry registry=builder.constructRegistry(Locale.getDefault());
System.out.println("###################################");
IMonService service=(IMonService)registry.getService("interfaces.MonService", IMonService.class);
service.executeService("test");
System.out.println("###################################");
IMonService service1=(IMonService)registry.getService("interfaces.MonService", IMonService.class);
service1.executeService("test1");
}
}
I think that the instances 'service' and 'service1' must be different but they are the same...
Is my configuration wrong?
Thanks a lot for your help.
Thierry
- Re: invoke-factory / create-instance and model Thierry TEMPLIER
- Re: invoke-factory / create-instance and model Howard Lewis Ship
