hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Howard Lewis Ship <hls...@gmail.com>
Subject Re: invoke-factory / create-instance and model
Date Wed, 27 Oct 2004 11:59:28 GMT
Please check the docs.

Primitive will create the service implementation on first reference.

The default, singleton, creates the service implementation on first
method invocation.

There has been discussion about additional models; "prototype" would
do what you are interested in.


On Wed, 27 Oct 2004 12:00:00 +0200, Thierry TEMPLIER
<ttemplier@transiciel.com> wrote:
>  
> 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 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Mime
View raw message