You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hivemind.apache.org by "Nelson, Randy" <ra...@bankofamerica.com> on 2004/06/10 15:15:59 UTC

multiple interfaces for a service-point question

The service-points only allow a service to implement 1 interface.  However,
there are times when it seems like it would be useful to specify that your
service implements more than one inteface as in the description below.
Hivemind hasn't been implemented that way, so I am sure there are keys
reason why not so I was just wondering what was the thought process behind
it?


Example:

interface Add {
  public void add(int arg0, int arg1);
}

interface Startable {
  public void startup() throws Exception;
}

interface Stopable {
  public void shutdown() throws Exception;
}

=====

  <service-point id="Adder" interface="hivemind.examples.Addable">
  	<create-instance class="hivemind.examples.impl.AdderImpl"/>
  </service-point>

...

  <contribution configuration-id="Startup">
    <task title="Adder"  order="100" >
	<invoke-startup service-id="hivemind.examples.Adder" />
    </task>
  </contribution>

  <contribution configuration-id="Startup">
    <task title="Adder"  order="1000" >
	<invoke-shutdown service-id="hivemind.examples.Adder" />
    </task>
  </contribution>

=====

You have an Adder service that implements Addable.  You'd like to be able to
contribute this to a "Startup" service or a "Shutdown".  However, you don't
want to make all Addable services have to implement either/both of the
Startable or Stopable interfaces. (In this case I am expanding "Panorama
Startup" example).  Are there ways to do this without the Adder service
implementing multiple interfaces and without combining all the methods into
1 interface?)

-Randy




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


RE: multiple interfaces for a service-point question

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
This has been occuring to me as well. Of course, you can simulate this by creating a meta-interface
that implements the other interfaces ... it would just be nicer if HiveMind allowed a list of
interfaces.

My vision of HiveMind is lots of simple little interfaces and services: aggregation rather than
inheritance or composition.

In you example, Add/add() is definately part of the service interface.

Startable/start() and Stopable/stop() are not; that's part of the service implementation.  I think a
better approach to this particular situation is to turn Startable and Stopaple into event
interfaces, and use the BuilderFactory to registry your Add service implementation as listeners.

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


> -----Original Message-----
> From: Nelson, Randy [mailto:randy.j.nelson@bankofamerica.com] 
> Sent: Thursday, June 10, 2004 9:16 AM
> To: 'hivemind-dev@jakarta.apache.org'
> Subject: multiple interfaces for a service-point question
> 
> 
> The service-points only allow a service to implement 1 
> interface.  However,
> there are times when it seems like it would be useful to 
> specify that your
> service implements more than one inteface as in the description below.
> Hivemind hasn't been implemented that way, so I am sure there are keys
> reason why not so I was just wondering what was the thought 
> process behind
> it?
> 
> 
> Example:
> 
> interface Add {
>   public void add(int arg0, int arg1);
> }
> 
> interface Startable {
>   public void startup() throws Exception;
> }
> 
> interface Stopable {
>   public void shutdown() throws Exception;
> }
> 
> =====
> 
>   <service-point id="Adder" interface="hivemind.examples.Addable">
>   	<create-instance class="hivemind.examples.impl.AdderImpl"/>
>   </service-point>
> 
> ...
> 
>   <contribution configuration-id="Startup">
>     <task title="Adder"  order="100" >
> 	<invoke-startup service-id="hivemind.examples.Adder" />
>     </task>
>   </contribution>
> 
>   <contribution configuration-id="Startup">
>     <task title="Adder"  order="1000" >
> 	<invoke-shutdown service-id="hivemind.examples.Adder" />
>     </task>
>   </contribution>
> 
> =====
> 
> You have an Adder service that implements Addable.  You'd 
> like to be able to
> contribute this to a "Startup" service or a "Shutdown".  
> However, you don't
> want to make all Addable services have to implement either/both of the
> Startable or Stopable interfaces. (In this case I am 
> expanding "Panorama
> Startup" example).  Are there ways to do this without the 
> Adder service
> implementing multiple interfaces and without combining all 
> the methods into
> 1 interface?)
> 
> -Randy
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-dev-help@jakarta.apache.org
> 


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