You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Bill Lear <ra...@zopyra.com> on 2003/09/17 01:09:49 UTC

[HiveMind] Extension to adder example

What I'd like to do is to define a service analogous to the Adder,
Subtracter.

Then, I'd like to define a service, Math that uses the Adder and
Subtracter modules to provide the following interface:

public interface Math {
    int add(int arg0, int arg1);
    int subtract(int arg0, int arg1);
}

with implementation:

package hivemind.examples.impl;

import hivemind.examples.Math;
import hivemind.examples.Adder;
import hivemind.examples.Subtracter;

public class MathImpl implements Math {
    private Adder adder;

    public void setAdder(Adder adder) {
        this.adder = adder;
    }

    private Subtracter subtracter;

    public void setSubtracter(Subtracter subtracter) {
        this.subtracter = subtracter;
    }

    public int add(int arg0, int arg1) {
        return adder.add(arg0, arg1);
    }

    public int subtract(int arg0, int arg1) {
        return subtracter.add(arg0, arg1);
    }
}

and call it from code thus (after appropriate registry construction,
etc.):

        Math math = (Math) registry.getService("hivemind.examples.Math",
                                               Math.class);

        System.out.println("Result of add: " + math.add(arg0, arg1));
        System.out.println("Result of subtract: " + math.subtract(arg0, arg1));

I'm a bit confused as to how to tie all of this together.  Could someone
provide some pointers?

Thanks.


Bill

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


Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.
I would agree with Bill here that there is only so much words can 
convey. I had the same problem until the bootstrapping example was 
published, that's when everything clicked in place. I always like the 
illustration kind of documents (and hence my Illustrating Tapestry!) 
which is always concrete and leaves little room for ambiguity.

As far as the names go, I am still with <service> and <service-point>. 
An interface would tend to imply that this is the definition of the 
interface which it is not and the same applies to implementation.

-Harish

Bill Lear wrote:

>On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard M. Lewis Ship writes:
>  
>
>>...
>>Yep, that's the whole point ... build the two jars and you have Adder
>>and Subtractor ready to go.  HiveMind will locate and parse all the
>>hivemodule.xml's into one consistent registry.  If you get
>>hivemind.examples.Adder it will combine the interface from the first
>>jar with the implementaion contributed by the second jar.
>>
>>So ... obviously I've been failing on getting the message out about
>>what HiveMind does if this is coming as a surprise now.
>>    
>>
>
>I think the issue is very simple: programming in this paradigm
>is a radical departure for us not used to it.  I'm not used to
>gluing things together with such little effort.  Not only are
>the concepts different, but, as one might expect, the language
>one uses to convey the concepts is altogether new.  In such cases,
>it's not so much a question of being clear, as providing concrete
>examples that cover the initial case, and then the initial case
>plus one --- sort of teaching by induction, if you will (prove
>case 1, then prove if case N is true, case N+1 is true, etc.).
>
>So, I don't think you have missed wildly (failing); I think that
>the examples could encompass this (and, critically, I think examples
>need to be *structured*, starting from simple to simple + 1); and,
>finally, I think a tweak to the language, as we have discussed,
>would also help.
>
>By having structured examples, it allows intellectual movement
>from simple cases to those beyond, which is what learning new
>things like this is all about.
>
>[Just a thought: why "service", "service point"?  I realize that
>"service" is a useful term, but why not "interface" and
>"implementation"?  Those terms seem to be broad enough and easy to
>understand...]
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>

Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.

Howard M. Lewis Ship wrote:

><service> --> <interface>
><extend-service> --> <implementation>
>
>I like that, except that <service> is a "super-element" of <implementation> and I want to keep it
>that way, since that's the normal usage.  That is, you can define a service and provide the
>implementation (core service impl plus interceptors) all in one go.  And that loops me back to
><service-point> and <extend-service>.  <contribute-service>?
>
Exactly what I intended to say, you said it better. But why don't you 
like <service> for <extend-service>?

>
>I think many people only give lip-service to OO ... they still think in terms of massive, central
>"brain" objects with a bunch of helpers attached. I tend to think in terms of lots of smaller
>objects, peers, working together ... and HiveMind lets me structure it all that way.
>
>--
>Howard M. Lewis Ship
>Creator, Tapestry: Java Web Components
>http://jakarta.apache.org/tapestry
>http://jakarta.apache.org/commons/sandbox/hivemind/
>http://javatapestry.blogspot.com
>
>  
>
>>-----Original Message-----
>>From: Bill Lear [mailto:rael@zopyra.com] 
>>Sent: Wednesday, September 17, 2003 10:34 AM
>>To: Jakarta Commons Developers List
>>Subject: RE: [HiveMind] Extension to adder example
>>
>>
>>On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard 
>>M. Lewis Ship writes:
>>    
>>
>>>...
>>>Yep, that's the whole point ... build the two jars and you 
>>>      
>>>
>>have Adder 
>>    
>>
>>>and Subtractor ready to go.  HiveMind will locate and parse all the 
>>>hivemodule.xml's into one consistent registry.  If you get 
>>>hivemind.examples.Adder it will combine the interface from the first 
>>>jar with the implementaion contributed by the second jar.
>>>
>>>So ... obviously I've been failing on getting the message out about 
>>>what HiveMind does if this is coming as a surprise now.
>>>      
>>>
>>I think the issue is very simple: programming in this 
>>paradigm is a radical departure for us not used to it.  I'm 
>>not used to gluing things together with such little effort.  
>>Not only are the concepts different, but, as one might 
>>expect, the language one uses to convey the concepts is 
>>altogether new.  In such cases, it's not so much a question 
>>of being clear, as providing concrete examples that cover the 
>>initial case, and then the initial case plus one --- sort of 
>>teaching by induction, if you will (prove case 1, then prove 
>>if case N is true, case N+1 is true, etc.).
>>
>>So, I don't think you have missed wildly (failing); I think 
>>that the examples could encompass this (and, critically, I 
>>think examples need to be *structured*, starting from simple 
>>to simple + 1); and, finally, I think a tweak to the 
>>language, as we have discussed, would also help.
>>
>>By having structured examples, it allows intellectual 
>>movement from simple cases to those beyond, which is what 
>>learning new things like this is all about.
>>
>>[Just a thought: why "service", "service point"?  I realize 
>>that "service" is a useful term, but why not "interface" and 
>>"implementation"?  Those terms seem to be broad enough and 
>>easy to understand...]
>>
>>
>>Bill
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>

RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
<service> --> <interface>
<extend-service> --> <implementation>

I like that, except that <service> is a "super-element" of <implementation> and I want to keep it
that way, since that's the normal usage.  That is, you can define a service and provide the
implementation (core service impl plus interceptors) all in one go.  And that loops me back to
<service-point> and <extend-service>.  <contribute-service>?

I think many people only give lip-service to OO ... they still think in terms of massive, central
"brain" objects with a bunch of helpers attached. I tend to think in terms of lots of smaller
objects, peers, working together ... and HiveMind lets me structure it all that way.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Bill Lear [mailto:rael@zopyra.com] 
> Sent: Wednesday, September 17, 2003 10:34 AM
> To: Jakarta Commons Developers List
> Subject: RE: [HiveMind] Extension to adder example
> 
> 
> On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard 
> M. Lewis Ship writes:
> >...
> >Yep, that's the whole point ... build the two jars and you 
> have Adder 
> >and Subtractor ready to go.  HiveMind will locate and parse all the 
> >hivemodule.xml's into one consistent registry.  If you get 
> >hivemind.examples.Adder it will combine the interface from the first 
> >jar with the implementaion contributed by the second jar.
> >
> >So ... obviously I've been failing on getting the message out about 
> >what HiveMind does if this is coming as a surprise now.
> 
> I think the issue is very simple: programming in this 
> paradigm is a radical departure for us not used to it.  I'm 
> not used to gluing things together with such little effort.  
> Not only are the concepts different, but, as one might 
> expect, the language one uses to convey the concepts is 
> altogether new.  In such cases, it's not so much a question 
> of being clear, as providing concrete examples that cover the 
> initial case, and then the initial case plus one --- sort of 
> teaching by induction, if you will (prove case 1, then prove 
> if case N is true, case N+1 is true, etc.).
> 
> So, I don't think you have missed wildly (failing); I think 
> that the examples could encompass this (and, critically, I 
> think examples need to be *structured*, starting from simple 
> to simple + 1); and, finally, I think a tweak to the 
> language, as we have discussed, would also help.
> 
> By having structured examples, it allows intellectual 
> movement from simple cases to those beyond, which is what 
> learning new things like this is all about.
> 
> [Just a thought: why "service", "service point"?  I realize 
> that "service" is a useful term, but why not "interface" and 
> "implementation"?  Those terms seem to be broad enough and 
> easy to understand...]
> 
> 
> Bill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


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


RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
<service> --> <interface>
<extend-service> --> <implementation>

I like that, except that <service> is a "super-element" of <implementation> and I want to keep it
that way, since that's the normal usage.  That is, you can define a service and provide the
implementation (core service impl plus interceptors) all in one go.  And that loops me back to
<service-point> and <extend-service>.  <contribute-service>?

I think many people only give lip-service to OO ... they still think in terms of massive, central
"brain" objects with a bunch of helpers attached. I tend to think in terms of lots of smaller
objects, peers, working together ... and HiveMind lets me structure it all that way.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Bill Lear [mailto:rael@zopyra.com] 
> Sent: Wednesday, September 17, 2003 10:34 AM
> To: Jakarta Commons Developers List
> Subject: RE: [HiveMind] Extension to adder example
> 
> 
> On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard 
> M. Lewis Ship writes:
> >...
> >Yep, that's the whole point ... build the two jars and you 
> have Adder 
> >and Subtractor ready to go.  HiveMind will locate and parse all the 
> >hivemodule.xml's into one consistent registry.  If you get 
> >hivemind.examples.Adder it will combine the interface from the first 
> >jar with the implementaion contributed by the second jar.
> >
> >So ... obviously I've been failing on getting the message out about 
> >what HiveMind does if this is coming as a surprise now.
> 
> I think the issue is very simple: programming in this 
> paradigm is a radical departure for us not used to it.  I'm 
> not used to gluing things together with such little effort.  
> Not only are the concepts different, but, as one might 
> expect, the language one uses to convey the concepts is 
> altogether new.  In such cases, it's not so much a question 
> of being clear, as providing concrete examples that cover the 
> initial case, and then the initial case plus one --- sort of 
> teaching by induction, if you will (prove case 1, then prove 
> if case N is true, case N+1 is true, etc.).
> 
> So, I don't think you have missed wildly (failing); I think 
> that the examples could encompass this (and, critically, I 
> think examples need to be *structured*, starting from simple 
> to simple + 1); and, finally, I think a tweak to the 
> language, as we have discussed, would also help.
> 
> By having structured examples, it allows intellectual 
> movement from simple cases to those beyond, which is what 
> learning new things like this is all about.
> 
> [Just a thought: why "service", "service point"?  I realize 
> that "service" is a useful term, but why not "interface" and 
> "implementation"?  Those terms seem to be broad enough and 
> easy to understand...]
> 
> 
> Bill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


RE: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard M. Lewis Ship writes:
>...
>Yep, that's the whole point ... build the two jars and you have Adder
>and Subtractor ready to go.  HiveMind will locate and parse all the
>hivemodule.xml's into one consistent registry.  If you get
>hivemind.examples.Adder it will combine the interface from the first
>jar with the implementaion contributed by the second jar.
>
>So ... obviously I've been failing on getting the message out about
>what HiveMind does if this is coming as a surprise now.

I think the issue is very simple: programming in this paradigm
is a radical departure for us not used to it.  I'm not used to
gluing things together with such little effort.  Not only are
the concepts different, but, as one might expect, the language
one uses to convey the concepts is altogether new.  In such cases,
it's not so much a question of being clear, as providing concrete
examples that cover the initial case, and then the initial case
plus one --- sort of teaching by induction, if you will (prove
case 1, then prove if case N is true, case N+1 is true, etc.).

So, I don't think you have missed wildly (failing); I think that
the examples could encompass this (and, critically, I think examples
need to be *structured*, starting from simple to simple + 1); and,
finally, I think a tweak to the language, as we have discussed,
would also help.

By having structured examples, it allows intellectual movement
from simple cases to those beyond, which is what learning new
things like this is all about.

[Just a thought: why "service", "service point"?  I realize that
"service" is a useful term, but why not "interface" and
"implementation"?  Those terms seem to be broad enough and easy to
understand...]


Bill

Re: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Wednesday, September 17, 2003 at 09:08:04 (-0400) Harish Krishnaswamy writes:
>...
>That's it! How slick is that?!

Slick-o-Rama, dude.


Bill

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


Re: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Wednesday, September 17, 2003 at 09:08:04 (-0400) Harish Krishnaswamy writes:
>...
>That's it! How slick is that?!

Slick-o-Rama, dude.


Bill

Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Everything remains the same except now you would split the service jar 
into an Adder jar and a Subtracter jar and the following would be the 
hivemodule.xml descriptors for these services.

Adder service:
<?xml version="1.0"?>

<module id="hivemind.examples.impl.AdderImpl" version="1.0.0">

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

</module>

Subtracter service:
<?xml version="1.0"?>

<module id="hivemind.examples.impl.SubtracterImpl" version="1.0.0">

  <extend-service service-id="hivemind.examples.Subtracter">
      <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
  </extend-service>

</module>

That's it! How slick is that?!

-Harish

Bill Lear wrote:

>On Tuesday, September 16, 2003 at 19:30:45 (-0400) Harish Krishnaswamy writes:
>  
>
>>You wouldn't believe, I had done the very same thing except called it a 
>>Calculator!
>>
>>Here are my modules...
>>    
>>
>
>Excellent, that gets me 89.5% of the way there, I think.  I guess one
>thing I am confused about is reuse of entire modules, as they might
>come packaged in the real world, i.e., in jar files.  That is, I have
>programmer A who writes the Adder module, and programmer B who,
>entirely independently, writes the Subtracter module.  What I get from
>A and B are two jar files, Adder.jar, and Subtracter.jar, that include
>the hivemodule.xml for both modules.
>
>Could you share with me how to build the Adder.jar and Subtracter.jar
>(if indeed there is any difference between the current example), and
>then how to use them?  If all I have to do is build the jars, and put
>them in the classpath, then follow your example, very cool, I'm 100%
>of the way there!
>
>Thanks Harish.
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>

RE: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Wednesday, September 17, 2003 at 10:08:14 (-0400) Howard M. Lewis Ship writes:
>...
>Yep, that's the whole point ... build the two jars and you have Adder
>and Subtractor ready to go.  HiveMind will locate and parse all the
>hivemodule.xml's into one consistent registry.  If you get
>hivemind.examples.Adder it will combine the interface from the first
>jar with the implementaion contributed by the second jar.
>
>So ... obviously I've been failing on getting the message out about
>what HiveMind does if this is coming as a surprise now.

I think the issue is very simple: programming in this paradigm
is a radical departure for us not used to it.  I'm not used to
gluing things together with such little effort.  Not only are
the concepts different, but, as one might expect, the language
one uses to convey the concepts is altogether new.  In such cases,
it's not so much a question of being clear, as providing concrete
examples that cover the initial case, and then the initial case
plus one --- sort of teaching by induction, if you will (prove
case 1, then prove if case N is true, case N+1 is true, etc.).

So, I don't think you have missed wildly (failing); I think that
the examples could encompass this (and, critically, I think examples
need to be *structured*, starting from simple to simple + 1); and,
finally, I think a tweak to the language, as we have discussed,
would also help.

By having structured examples, it allows intellectual movement
from simple cases to those beyond, which is what learning new
things like this is all about.

[Just a thought: why "service", "service point"?  I realize that
"service" is a useful term, but why not "interface" and
"implementation"?  Those terms seem to be broad enough and easy to
understand...]


Bill

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


RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
> Could you share with me how to build the Adder.jar and 
> Subtracter.jar (if indeed there is any difference between the 
> current example), and then how to use them?  If all I have to 
> do is build the jars, and put them in the classpath, then 
> follow your example, very cool, I'm 100% of the way there!
> 
> Thanks Harish.

Yep, that's the whole point ... build the two jars and you have Adder and Subtractor ready to go.
HiveMind will locate and parse
all the hivemodule.xml's into one consistent registry.  If you get hivemind.examples.Adder it will
combine the interface from the first jar with the implementaion contributed by the second jar.

So ... obviously I've been failing on getting the message out about what HiveMind does if this is
coming as a surprise now.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com


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


RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
> Could you share with me how to build the Adder.jar and 
> Subtracter.jar (if indeed there is any difference between the 
> current example), and then how to use them?  If all I have to 
> do is build the jars, and put them in the classpath, then 
> follow your example, very cool, I'm 100% of the way there!
> 
> Thanks Harish.

Yep, that's the whole point ... build the two jars and you have Adder and Subtractor ready to go.
HiveMind will locate and parse
all the hivemodule.xml's into one consistent registry.  If you get hivemind.examples.Adder it will
combine the interface from the first jar with the implementaion contributed by the second jar.

So ... obviously I've been failing on getting the message out about what HiveMind does if this is
coming as a surprise now.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com


Re: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Tuesday, September 16, 2003 at 19:30:45 (-0400) Harish Krishnaswamy writes:
>You wouldn't believe, I had done the very same thing except called it a 
>Calculator!
>
>Here are my modules...

Excellent, that gets me 89.5% of the way there, I think.  I guess one
thing I am confused about is reuse of entire modules, as they might
come packaged in the real world, i.e., in jar files.  That is, I have
programmer A who writes the Adder module, and programmer B who,
entirely independently, writes the Subtracter module.  What I get from
A and B are two jar files, Adder.jar, and Subtracter.jar, that include
the hivemodule.xml for both modules.

Could you share with me how to build the Adder.jar and Subtracter.jar
(if indeed there is any difference between the current example), and
then how to use them?  If all I have to do is build the jars, and put
them in the classpath, then follow your example, very cool, I'm 100%
of the way there!

Thanks Harish.


Bill

Re: [HiveMind] Extension to adder example

Posted by Bill Lear <ra...@zopyra.com>.
On Tuesday, September 16, 2003 at 19:30:45 (-0400) Harish Krishnaswamy writes:
>You wouldn't believe, I had done the very same thing except called it a 
>Calculator!
>
>Here are my modules...

Excellent, that gets me 89.5% of the way there, I think.  I guess one
thing I am confused about is reuse of entire modules, as they might
come packaged in the real world, i.e., in jar files.  That is, I have
programmer A who writes the Adder module, and programmer B who,
entirely independently, writes the Subtracter module.  What I get from
A and B are two jar files, Adder.jar, and Subtracter.jar, that include
the hivemodule.xml for both modules.

Could you share with me how to build the Adder.jar and Subtracter.jar
(if indeed there is any difference between the current example), and
then how to use them?  If all I have to do is build the jars, and put
them in the classpath, then follow your example, very cool, I'm 100%
of the way there!

Thanks Harish.


Bill

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


Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Cool! And I forget to mention, I had them as singletons so I can run 
them through the debugger.

-Harish

Howard M. Lewis Ship wrote:

>Right on the money ... except that I probably would not both defining the service model for Adder
>and Subtractor; the default ("deferred") is less efficient, but less trouble as well. Making those
>services singletons (rather than deferred singletons) is a premature optimization.
>
>--
>Howard M. Lewis Ship
>Creator, Tapestry: Java Web Components
>http://jakarta.apache.org/tapestry
>http://jakarta.apache.org/commons/sandbox/hivemind/
>http://javatapestry.blogspot.com
>
>  
>
>>-----Original Message-----
>>From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
>>Sent: Tuesday, September 16, 2003 7:31 PM
>>To: Jakarta Commons Developers List
>>Subject: Re: [HiveMind] Extension to adder example
>>
>>
>>You wouldn't believe, I had done the very same thing except 
>>called it a 
>>Calculator!
>>
>>Here are my modules...
>>
>>Service point module:
>>
>><?xml version="1.0"?>
>>
>><module id="hivemind.examples" version="1.0.0">
>>
>>  <service id="Adder" interface="hivemind.examples.Adder" 
>>model="singleton"/>
>>
>>  <service id="Subtracter" interface="hivemind.examples.Subtracter" 
>>model="singleton"/>
>> 
>>  <service id="Calculator" interface="hivemind.examples.Calculator" 
>>model="singleton">
>>    <invoke-factory service-id="hivemind.BuilderFactory">
>>        <construct
>>            class="hivemind.examples.impl.CalculatorImpl">
>>           
>>            <set-service property="adder" service-id="Adder"/>
>>            <set-service property="subtracter" 
>>service-id="Subtracter"/>
>>        </construct>
>>    </invoke-factory>
>>  </service>
>>
>></module>
>>
>>Service module:
>><?xml version="1.0"?>
>>
>><module id="hivemind.examples.impl" version="1.0.0">
>>
>>  <extend-service service-id="hivemind.examples.Adder">
>>      <create-instance class="hivemind.examples.impl.AdderImpl"/>
>>  </extend-service>
>>
>>  <extend-service service-id="hivemind.examples.Subtracter">
>>      <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
>>  </extend-service>
>>
>></module>
>>
>>Client module:
>><?xml version="1.0"?>
>>
>><module id="hivemind.examples.log" version="1.0.0">
>>
>>  <extend-service service-id="hivemind.examples.Adder">
>>    <interceptor service-id="hivemind.LoggingInterceptor" order="10"/>
>>  </extend-service>
>>
>></module>
>>
>>And the rest is Hivemind! I am really liking it a lot. I 
>>can't wait for 
>>Tapestry 3.1!
>>
>>-Harish
>>
>>Bill Lear wrote:
>>
>>    
>>
>>>What I'd like to do is to define a service analogous to the Adder, 
>>>Subtracter.
>>>
>>>Then, I'd like to define a service, Math that uses the Adder and 
>>>Subtracter modules to provide the following interface:
>>>
>>>public interface Math {
>>>   int add(int arg0, int arg1);
>>>   int subtract(int arg0, int arg1);
>>>}
>>>
>>>with implementation:
>>>
>>>package hivemind.examples.impl;
>>>
>>>import hivemind.examples.Math;
>>>import hivemind.examples.Adder;
>>>import hivemind.examples.Subtracter;
>>>
>>>public class MathImpl implements Math {
>>>   private Adder adder;
>>>
>>>   public void setAdder(Adder adder) {
>>>       this.adder = adder;
>>>   }
>>>
>>>   private Subtracter subtracter;
>>>
>>>   public void setSubtracter(Subtracter subtracter) {
>>>       this.subtracter = subtracter;
>>>   }
>>>
>>>   public int add(int arg0, int arg1) {
>>>       return adder.add(arg0, arg1);
>>>   }
>>>
>>>   public int subtract(int arg0, int arg1) {
>>>       return subtracter.add(arg0, arg1);
>>>   }
>>>}
>>>
>>>and call it from code thus (after appropriate registry construction,
>>>etc.):
>>>
>>>       Math math = (Math) 
>>>      
>>>
>>registry.getService("hivemind.examples.Math",
>>    
>>
>>>                                              Math.class);
>>>
>>>       System.out.println("Result of add: " + math.add(arg0, arg1));
>>>       System.out.println("Result of subtract: " + 
>>>      
>>>
>>math.subtract(arg0, 
>>    
>>
>>>arg1));
>>>
>>>I'm a bit confused as to how to tie all of this together.  Could 
>>>someone provide some pointers?
>>>
>>>Thanks.
>>>
>>>
>>>Bill
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>>
>>>
>>> 
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>

RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Right on the money ... except that I probably would not both defining the service model for Adder
and Subtractor; the default ("deferred") is less efficient, but less trouble as well. Making those
services singletons (rather than deferred singletons) is a premature optimization.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
> Sent: Tuesday, September 16, 2003 7:31 PM
> To: Jakarta Commons Developers List
> Subject: Re: [HiveMind] Extension to adder example
> 
> 
> You wouldn't believe, I had done the very same thing except 
> called it a 
> Calculator!
> 
> Here are my modules...
> 
> Service point module:
> 
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples" version="1.0.0">
> 
>   <service id="Adder" interface="hivemind.examples.Adder" 
> model="singleton"/>
> 
>   <service id="Subtracter" interface="hivemind.examples.Subtracter" 
> model="singleton"/>
>  
>   <service id="Calculator" interface="hivemind.examples.Calculator" 
> model="singleton">
>     <invoke-factory service-id="hivemind.BuilderFactory">
>         <construct
>             class="hivemind.examples.impl.CalculatorImpl">
>            
>             <set-service property="adder" service-id="Adder"/>
>             <set-service property="subtracter" 
> service-id="Subtracter"/>
>         </construct>
>     </invoke-factory>
>   </service>
> 
> </module>
> 
> Service module:
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples.impl" version="1.0.0">
> 
>   <extend-service service-id="hivemind.examples.Adder">
>       <create-instance class="hivemind.examples.impl.AdderImpl"/>
>   </extend-service>
> 
>   <extend-service service-id="hivemind.examples.Subtracter">
>       <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
>   </extend-service>
> 
> </module>
> 
> Client module:
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples.log" version="1.0.0">
> 
>   <extend-service service-id="hivemind.examples.Adder">
>     <interceptor service-id="hivemind.LoggingInterceptor" order="10"/>
>   </extend-service>
> 
> </module>
> 
> And the rest is Hivemind! I am really liking it a lot. I 
> can't wait for 
> Tapestry 3.1!
> 
> -Harish
> 
> Bill Lear wrote:
> 
> >What I'd like to do is to define a service analogous to the Adder, 
> >Subtracter.
> >
> >Then, I'd like to define a service, Math that uses the Adder and 
> >Subtracter modules to provide the following interface:
> >
> >public interface Math {
> >    int add(int arg0, int arg1);
> >    int subtract(int arg0, int arg1);
> >}
> >
> >with implementation:
> >
> >package hivemind.examples.impl;
> >
> >import hivemind.examples.Math;
> >import hivemind.examples.Adder;
> >import hivemind.examples.Subtracter;
> >
> >public class MathImpl implements Math {
> >    private Adder adder;
> >
> >    public void setAdder(Adder adder) {
> >        this.adder = adder;
> >    }
> >
> >    private Subtracter subtracter;
> >
> >    public void setSubtracter(Subtracter subtracter) {
> >        this.subtracter = subtracter;
> >    }
> >
> >    public int add(int arg0, int arg1) {
> >        return adder.add(arg0, arg1);
> >    }
> >
> >    public int subtract(int arg0, int arg1) {
> >        return subtracter.add(arg0, arg1);
> >    }
> >}
> >
> >and call it from code thus (after appropriate registry construction,
> >etc.):
> >
> >        Math math = (Math) 
> registry.getService("hivemind.examples.Math",
> >                                               Math.class);
> >
> >        System.out.println("Result of add: " + math.add(arg0, arg1));
> >        System.out.println("Result of subtract: " + 
> math.subtract(arg0, 
> > arg1));
> >
> >I'm a bit confused as to how to tie all of this together.  Could 
> >someone provide some pointers?
> >
> >Thanks.
> >
> >
> >Bill
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


RE: [HiveMind] Extension to adder example

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Right on the money ... except that I probably would not both defining the service model for Adder
and Subtractor; the default ("deferred") is less efficient, but less trouble as well. Making those
services singletons (rather than deferred singletons) is a premature optimization.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
> Sent: Tuesday, September 16, 2003 7:31 PM
> To: Jakarta Commons Developers List
> Subject: Re: [HiveMind] Extension to adder example
> 
> 
> You wouldn't believe, I had done the very same thing except 
> called it a 
> Calculator!
> 
> Here are my modules...
> 
> Service point module:
> 
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples" version="1.0.0">
> 
>   <service id="Adder" interface="hivemind.examples.Adder" 
> model="singleton"/>
> 
>   <service id="Subtracter" interface="hivemind.examples.Subtracter" 
> model="singleton"/>
>  
>   <service id="Calculator" interface="hivemind.examples.Calculator" 
> model="singleton">
>     <invoke-factory service-id="hivemind.BuilderFactory">
>         <construct
>             class="hivemind.examples.impl.CalculatorImpl">
>            
>             <set-service property="adder" service-id="Adder"/>
>             <set-service property="subtracter" 
> service-id="Subtracter"/>
>         </construct>
>     </invoke-factory>
>   </service>
> 
> </module>
> 
> Service module:
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples.impl" version="1.0.0">
> 
>   <extend-service service-id="hivemind.examples.Adder">
>       <create-instance class="hivemind.examples.impl.AdderImpl"/>
>   </extend-service>
> 
>   <extend-service service-id="hivemind.examples.Subtracter">
>       <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
>   </extend-service>
> 
> </module>
> 
> Client module:
> <?xml version="1.0"?>
> 
> <module id="hivemind.examples.log" version="1.0.0">
> 
>   <extend-service service-id="hivemind.examples.Adder">
>     <interceptor service-id="hivemind.LoggingInterceptor" order="10"/>
>   </extend-service>
> 
> </module>
> 
> And the rest is Hivemind! I am really liking it a lot. I 
> can't wait for 
> Tapestry 3.1!
> 
> -Harish
> 
> Bill Lear wrote:
> 
> >What I'd like to do is to define a service analogous to the Adder, 
> >Subtracter.
> >
> >Then, I'd like to define a service, Math that uses the Adder and 
> >Subtracter modules to provide the following interface:
> >
> >public interface Math {
> >    int add(int arg0, int arg1);
> >    int subtract(int arg0, int arg1);
> >}
> >
> >with implementation:
> >
> >package hivemind.examples.impl;
> >
> >import hivemind.examples.Math;
> >import hivemind.examples.Adder;
> >import hivemind.examples.Subtracter;
> >
> >public class MathImpl implements Math {
> >    private Adder adder;
> >
> >    public void setAdder(Adder adder) {
> >        this.adder = adder;
> >    }
> >
> >    private Subtracter subtracter;
> >
> >    public void setSubtracter(Subtracter subtracter) {
> >        this.subtracter = subtracter;
> >    }
> >
> >    public int add(int arg0, int arg1) {
> >        return adder.add(arg0, arg1);
> >    }
> >
> >    public int subtract(int arg0, int arg1) {
> >        return subtracter.add(arg0, arg1);
> >    }
> >}
> >
> >and call it from code thus (after appropriate registry construction,
> >etc.):
> >
> >        Math math = (Math) 
> registry.getService("hivemind.examples.Math",
> >                                               Math.class);
> >
> >        System.out.println("Result of add: " + math.add(arg0, arg1));
> >        System.out.println("Result of subtract: " + 
> math.subtract(arg0, 
> > arg1));
> >
> >I'm a bit confused as to how to tie all of this together.  Could 
> >someone provide some pointers?
> >
> >Thanks.
> >
> >
> >Bill
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


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


Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.
You wouldn't believe, I had done the very same thing except called it a 
Calculator!

Here are my modules...

Service point module:

<?xml version="1.0"?>

<module id="hivemind.examples" version="1.0.0">

  <service id="Adder" interface="hivemind.examples.Adder" 
model="singleton"/>

  <service id="Subtracter" interface="hivemind.examples.Subtracter" 
model="singleton"/>
 
  <service id="Calculator" interface="hivemind.examples.Calculator" 
model="singleton">
    <invoke-factory service-id="hivemind.BuilderFactory">
        <construct
            class="hivemind.examples.impl.CalculatorImpl">
           
            <set-service property="adder" service-id="Adder"/>
            <set-service property="subtracter" service-id="Subtracter"/>
        </construct>
    </invoke-factory>
  </service>

</module>

Service module:
<?xml version="1.0"?>

<module id="hivemind.examples.impl" version="1.0.0">

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

  <extend-service service-id="hivemind.examples.Subtracter">
      <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
  </extend-service>

</module>

Client module:
<?xml version="1.0"?>

<module id="hivemind.examples.log" version="1.0.0">

  <extend-service service-id="hivemind.examples.Adder">
    <interceptor service-id="hivemind.LoggingInterceptor" order="10"/>
  </extend-service>

</module>

And the rest is Hivemind! I am really liking it a lot. I can't wait for 
Tapestry 3.1!

-Harish

Bill Lear wrote:

>What I'd like to do is to define a service analogous to the Adder,
>Subtracter.
>
>Then, I'd like to define a service, Math that uses the Adder and
>Subtracter modules to provide the following interface:
>
>public interface Math {
>    int add(int arg0, int arg1);
>    int subtract(int arg0, int arg1);
>}
>
>with implementation:
>
>package hivemind.examples.impl;
>
>import hivemind.examples.Math;
>import hivemind.examples.Adder;
>import hivemind.examples.Subtracter;
>
>public class MathImpl implements Math {
>    private Adder adder;
>
>    public void setAdder(Adder adder) {
>        this.adder = adder;
>    }
>
>    private Subtracter subtracter;
>
>    public void setSubtracter(Subtracter subtracter) {
>        this.subtracter = subtracter;
>    }
>
>    public int add(int arg0, int arg1) {
>        return adder.add(arg0, arg1);
>    }
>
>    public int subtract(int arg0, int arg1) {
>        return subtracter.add(arg0, arg1);
>    }
>}
>
>and call it from code thus (after appropriate registry construction,
>etc.):
>
>        Math math = (Math) registry.getService("hivemind.examples.Math",
>                                               Math.class);
>
>        System.out.println("Result of add: " + math.add(arg0, arg1));
>        System.out.println("Result of subtract: " + math.subtract(arg0, arg1));
>
>I'm a bit confused as to how to tie all of this together.  Could someone
>provide some pointers?
>
>Thanks.
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>


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


Re: [HiveMind] Extension to adder example

Posted by Harish Krishnaswamy <hk...@comcast.net>.
You wouldn't believe, I had done the very same thing except called it a 
Calculator!

Here are my modules...

Service point module:

<?xml version="1.0"?>

<module id="hivemind.examples" version="1.0.0">

  <service id="Adder" interface="hivemind.examples.Adder" 
model="singleton"/>

  <service id="Subtracter" interface="hivemind.examples.Subtracter" 
model="singleton"/>
 
  <service id="Calculator" interface="hivemind.examples.Calculator" 
model="singleton">
    <invoke-factory service-id="hivemind.BuilderFactory">
        <construct
            class="hivemind.examples.impl.CalculatorImpl">
           
            <set-service property="adder" service-id="Adder"/>
            <set-service property="subtracter" service-id="Subtracter"/>
        </construct>
    </invoke-factory>
  </service>

</module>

Service module:
<?xml version="1.0"?>

<module id="hivemind.examples.impl" version="1.0.0">

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

  <extend-service service-id="hivemind.examples.Subtracter">
      <create-instance class="hivemind.examples.impl.SubtracterImpl"/>
  </extend-service>

</module>

Client module:
<?xml version="1.0"?>

<module id="hivemind.examples.log" version="1.0.0">

  <extend-service service-id="hivemind.examples.Adder">
    <interceptor service-id="hivemind.LoggingInterceptor" order="10"/>
  </extend-service>

</module>

And the rest is Hivemind! I am really liking it a lot. I can't wait for 
Tapestry 3.1!

-Harish

Bill Lear wrote:

>What I'd like to do is to define a service analogous to the Adder,
>Subtracter.
>
>Then, I'd like to define a service, Math that uses the Adder and
>Subtracter modules to provide the following interface:
>
>public interface Math {
>    int add(int arg0, int arg1);
>    int subtract(int arg0, int arg1);
>}
>
>with implementation:
>
>package hivemind.examples.impl;
>
>import hivemind.examples.Math;
>import hivemind.examples.Adder;
>import hivemind.examples.Subtracter;
>
>public class MathImpl implements Math {
>    private Adder adder;
>
>    public void setAdder(Adder adder) {
>        this.adder = adder;
>    }
>
>    private Subtracter subtracter;
>
>    public void setSubtracter(Subtracter subtracter) {
>        this.subtracter = subtracter;
>    }
>
>    public int add(int arg0, int arg1) {
>        return adder.add(arg0, arg1);
>    }
>
>    public int subtract(int arg0, int arg1) {
>        return subtracter.add(arg0, arg1);
>    }
>}
>
>and call it from code thus (after appropriate registry construction,
>etc.):
>
>        Math math = (Math) registry.getService("hivemind.examples.Math",
>                                               Math.class);
>
>        System.out.println("Result of add: " + math.add(arg0, arg1));
>        System.out.println("Result of subtract: " + math.subtract(arg0, arg1));
>
>I'm a bit confused as to how to tie all of this together.  Could someone
>provide some pointers?
>
>Thanks.
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>