You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2013/06/20 13:01:43 UTC
[CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command and
the base classes
Hi guys,
I had a look at the command interface and it's base classes yesterday, and
I think there is some work to do :) Here are the points I found:
* JavaDoc of Command says that commands have to be designed in a
thread-safe manner, yet all the base implementations are not thread safe! I
have created CHAIN-96 [1] for this, because this definitely has to be fixed
before 2.0
* The same is true for o.a.c.chain2.Chain and its base implemenation. For
example there is a race condition in o.a.c.chain2.impl.ChainBase.add(CMD).
The method first checks the forzen flag and then acts... Another thread may
already have altered frozen. I have created CHAIN-97 [2] for this.
* The use of Context<K, V> is inconsistent throughout the API. Commands
only need a C extends Map<K, V> for execution but the RemoveCommand
implements Command<K, V, Context<K, V>>. Why do we need the Context
interface anyway? It doesn't add much, the only method is just a generic
wrapper around Map.get(Object).
* Base implementations should return the constants CONTINUE_PROCESSING or
PROCESSING_COMPLETE instead of returning true or false
* It may make sense to introduce an enum instead of working with booleans
as return values for commands.
Thoughts?
Benedikt
[1] https://issues.apache.org/jira/browse/CHAIN-96
[2] https://issues.apache.org/jira/browse/CHAIN-97
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Jonas Sprenger <sp...@gmail.com>.
Hi Elijah,
The ‘Continue’ and ‘Completed’ values look very similar to me, especially
in Unit tests. I suggest naming the two states:
- Continue
- Finished
>With regards to an enum for status, wouldn't it be better to use a class so
>that consumers could subclass it and add their own states if needed?
As far as I know, there is not a decision about the third state 'Aborted'
yet. So the question is, do the 3 states cover the complete set of possible
values? Implementing the exception handling might show the need for more
states.
I would suggest sticking with the enum for now. The refactoring from an
enum to a interface ‘Processing’ is not that big deal.
regards,
Jonas
2013/6/26 Elijah Zupancic <el...@zupancic.name>
> +1 to everything.
>
> With regards to an enum for status, wouldn't it be better to use a class so
> that consumers could subclass it and add their own states if needed?
>
> Thanks,
> -Elijah
>
>
> On Sat, Jun 22, 2013 at 4:30 AM, Benedikt Ritter <beneritter@gmail.com
> >wrote:
>
> >
> > Am 22.06.2013 um 12:57 schrieb Simone Tripodi <simonetripodi@apache.org
> >:
> >
> > > Hi Jonas,
> > >
> > >>
> > >> I will provide a patch for
> > >> CHAIN-98<https://issues.apache.org/jira/browse/CHAIN-98>tomorow. The
> > >> patch will only cover the refactoring of CONTINUE and
> > >> COMPLETED processing results.
> > >>
> > >
> > > nice to read that, looking forward to the patch! :)
> > >
> > >> But, I do not understand how exceptions should be handled in this
> > context.
> > >> A exception listener filters the exceptions and returns ABORTED if
> > >> appropriate?
> > >
> > > let's postpone it and keep CONTINUE and COMPLETED only ATM - Benedikt
> > > is working on an exception listener, let's see how it evolves and
> > > let's evaluate later if/how ABORTED will be introduced.
> >
> > Yeah, well I'm not really working on it. But I'll do as soon as I got the
> > time :)
> >
> > Benedikt
> >
> > >
> > > Thanks in advance, all the best!
> > > -Simo
> > >
> > > http://people.apache.org/~simonetripodi/
> > > http://twitter.com/simonetripodi
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
>
> --
> -Elijah
>
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Elijah Zupancic <el...@zupancic.name>.
+1 to everything.
With regards to an enum for status, wouldn't it be better to use a class so
that consumers could subclass it and add their own states if needed?
Thanks,
-Elijah
On Sat, Jun 22, 2013 at 4:30 AM, Benedikt Ritter <be...@gmail.com>wrote:
>
> Am 22.06.2013 um 12:57 schrieb Simone Tripodi <si...@apache.org>:
>
> > Hi Jonas,
> >
> >>
> >> I will provide a patch for
> >> CHAIN-98<https://issues.apache.org/jira/browse/CHAIN-98>tomorow. The
> >> patch will only cover the refactoring of CONTINUE and
> >> COMPLETED processing results.
> >>
> >
> > nice to read that, looking forward to the patch! :)
> >
> >> But, I do not understand how exceptions should be handled in this
> context.
> >> A exception listener filters the exceptions and returns ABORTED if
> >> appropriate?
> >
> > let's postpone it and keep CONTINUE and COMPLETED only ATM - Benedikt
> > is working on an exception listener, let's see how it evolves and
> > let's evaluate later if/how ABORTED will be introduced.
>
> Yeah, well I'm not really working on it. But I'll do as soon as I got the
> time :)
>
> Benedikt
>
> >
> > Thanks in advance, all the best!
> > -Simo
> >
> > http://people.apache.org/~simonetripodi/
> > http://twitter.com/simonetripodi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
-Elijah
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command and the base classes
Posted by Benedikt Ritter <be...@gmail.com>.
Am 22.06.2013 um 12:57 schrieb Simone Tripodi <si...@apache.org>:
> Hi Jonas,
>
>>
>> I will provide a patch for
>> CHAIN-98<https://issues.apache.org/jira/browse/CHAIN-98>tomorow. The
>> patch will only cover the refactoring of CONTINUE and
>> COMPLETED processing results.
>>
>
> nice to read that, looking forward to the patch! :)
>
>> But, I do not understand how exceptions should be handled in this context.
>> A exception listener filters the exceptions and returns ABORTED if
>> appropriate?
>
> let's postpone it and keep CONTINUE and COMPLETED only ATM - Benedikt
> is working on an exception listener, let's see how it evolves and
> let's evaluate later if/how ABORTED will be introduced.
Yeah, well I'm not really working on it. But I'll do as soon as I got the time :)
Benedikt
>
> Thanks in advance, all the best!
> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://twitter.com/simonetripodi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Simone Tripodi <si...@apache.org>.
Hi Jonas,
>
> I will provide a patch for
> CHAIN-98<https://issues.apache.org/jira/browse/CHAIN-98>tomorow. The
> patch will only cover the refactoring of CONTINUE and
> COMPLETED processing results.
>
nice to read that, looking forward to the patch! :)
> But, I do not understand how exceptions should be handled in this context.
> A exception listener filters the exceptions and returns ABORTED if
> appropriate?
let's postpone it and keep CONTINUE and COMPLETED only ATM - Benedikt
is working on an exception listener, let's see how it evolves and
let's evaluate later if/how ABORTED will be introduced.
Thanks in advance, all the best!
-Simo
http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Jonas Sprenger <sp...@gmail.com>.
Hi Simone,
more meat as I expected, thats for sure.
I will provide a patch for
CHAIN-98<https://issues.apache.org/jira/browse/CHAIN-98>tomorow. The
patch will only cover the refactoring of CONTINUE and
COMPLETED processing results.
But, I do not understand how exceptions should be handled in this context.
A exception listener filters the exceptions and returns ABORTED if
appropriate?
Best regards,
Jonas
2013/6/21 Simone Tripodi <si...@apache.org>
> > I'm not sure if we need ABORTED. What is the difference between COMPLETE
> > and ABORTED from the PoV of the Chain? Chain defines an algorithm for
> > processing and I currently don't see how ABORTED fits in there.
> >
>
> OTOH I see some potential here:
>
> * COMPLETE: all chain commands have completed their execution;
>
> * ABORTED: the process got interrupted in a step of the chain because
> of an error/exception
>
> Exceptions can be handled in the way you proposed some emails ago via
> an exception listener.
>
> Sounds like you have a lot of meat to put on the grill, looking
> forward to see patches/commits about it!!! :)
>
> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://twitter.com/simonetripodi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Simone Tripodi <si...@apache.org>.
> I'm not sure if we need ABORTED. What is the difference between COMPLETE
> and ABORTED from the PoV of the Chain? Chain defines an algorithm for
> processing and I currently don't see how ABORTED fits in there.
>
OTOH I see some potential here:
* COMPLETE: all chain commands have completed their execution;
* ABORTED: the process got interrupted in a step of the chain because
of an error/exception
Exceptions can be handled in the way you proposed some emails ago via
an exception listener.
Sounds like you have a lot of meat to put on the grill, looking
forward to see patches/commits about it!!! :)
-Simo
http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Benedikt Ritter <br...@apache.org>.
2013/6/21 Simone Tripodi <si...@apache.org>
> Thanks Jonas,
>
> would you submit a patch for that? TIA!
>
> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://twitter.com/simonetripodi
>
>
> On Thu, Jun 20, 2013 at 11:09 PM, Jonas Sprenger <sp...@gmail.com>
> wrote:
> > Hi guys,
> >
> > so we talk about an enum 'PROCESSING' providing at least 3 states?
> >
> > - CONTINUE
> > - COMPLETE
> > - ABORTED
>
Hi,
I'm not sure if we need ABORTED. What is the difference between COMPLETE
and ABORTED from the PoV of the Chain? Chain defines an algorithm for
processing and I currently don't see how ABORTED fits in there.
Benedikt
> >
> > Ticket CHAIN-98 <https://issues.apache.org/jira/browse/CHAIN-98> has
> been
> > created to cover this task.
> >
> > regards,
> > Jonas
> >
> > 2013/6/20 Simone Tripodi <si...@apache.org>
> >
> >> Hallo Bene,
> >>
> >> > * JavaDoc of Command says that commands have to be designed in a
> >> > thread-safe manner, yet all the base implementations are not thread
> >> safe! I
> >> > have created CHAIN-96 [1] for this, because this definitely has to be
> >> fixed
> >> > before 2.0
> >>
> >> +1
> >>
> >> > * The same is true for o.a.c.chain2.Chain and its base implemenation.
> For
> >> > example there is a race condition in
> >> o.a.c.chain2.impl.ChainBase.add(CMD).
> >> > The method first checks the forzen flag and then acts... Another
> thread
> >> may
> >> > already have altered frozen. I have created CHAIN-97 [2] for this.
> >>
> >> ok, gut!
> >>
> >> > * The use of Context<K, V> is inconsistent throughout the API.
> Commands
> >> > only need a C extends Map<K, V> for execution but the RemoveCommand
> >> > implements Command<K, V, Context<K, V>>. Why do we need the Context
> >> > interface anyway? It doesn't add much, the only method is just a
> generic
> >> > wrapper around Map.get(Object).
> >>
> >> Context must have disappeared from methods signatures some time ago,
> >> it is maybe a refuse - but at that time we agreed on creating a
> >> commodity interface which contains the <T extends V> T retrieve(K
> >> key); method;
> >>
> >> > * Base implementations should return the constants
> CONTINUE_PROCESSING or
> >> > PROCESSING_COMPLETE instead of returning true or false
> >>
> >> I'd even switch to enumeration to represent states...
> >>
> >> > * It may make sense to introduce an enum instead of working with
> booleans
> >> > as return values for commands.
> >>
> >> hahah nice one, I wrote the sentence above without reading the last
> >> bullet, sounds we have an agreement here... :)
> >>
> >> Thanks & Best,
> >> -Simo
> >>
> >> http://people.apache.org/~simonetripodi/
> >> http://twitter.com/simonetripodi
> >>
> >>
> >> On Thu, Jun 20, 2013 at 1:01 PM, Benedikt Ritter <br...@apache.org>
> >> wrote:
> >> > Hi guys,
> >> >
> >> > I had a look at the command interface and it's base classes yesterday,
> >> and
> >> > I think there is some work to do :) Here are the points I found:
> >> >
> >> > * JavaDoc of Command says that commands have to be designed in a
> >> > thread-safe manner, yet all the base implementations are not thread
> >> safe! I
> >> > have created CHAIN-96 [1] for this, because this definitely has to be
> >> fixed
> >> > before 2.0
> >> > * The same is true for o.a.c.chain2.Chain and its base implemenation.
> For
> >> > example there is a race condition in
> >> o.a.c.chain2.impl.ChainBase.add(CMD).
> >> > The method first checks the forzen flag and then acts... Another
> thread
> >> may
> >> > already have altered frozen. I have created CHAIN-97 [2] for this.
> >> > * The use of Context<K, V> is inconsistent throughout the API.
> Commands
> >> > only need a C extends Map<K, V> for execution but the RemoveCommand
> >> > implements Command<K, V, Context<K, V>>. Why do we need the Context
> >> > interface anyway? It doesn't add much, the only method is just a
> generic
> >> > wrapper around Map.get(Object).
> >> > * Base implementations should return the constants
> CONTINUE_PROCESSING or
> >> > PROCESSING_COMPLETE instead of returning true or false
> >> > * It may make sense to introduce an enum instead of working with
> booleans
> >> > as return values for commands.
> >> >
> >> > Thoughts?
> >> >
> >> > Benedikt
> >> >
> >> > [1] https://issues.apache.org/jira/browse/CHAIN-96
> >> > [2] https://issues.apache.org/jira/browse/CHAIN-97
> >> >
> >> > --
> >> > http://people.apache.org/~britter/
> >> > http://www.systemoutprintln.de/
> >> > http://twitter.com/BenediktRitter
> >> > http://github.com/britter
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: dev-help@commons.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Simone Tripodi <si...@apache.org>.
Thanks Jonas,
would you submit a patch for that? TIA!
-Simo
http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi
On Thu, Jun 20, 2013 at 11:09 PM, Jonas Sprenger <sp...@gmail.com> wrote:
> Hi guys,
>
> so we talk about an enum 'PROCESSING' providing at least 3 states?
>
> - CONTINUE
> - COMPLETE
> - ABORTED
>
> Ticket CHAIN-98 <https://issues.apache.org/jira/browse/CHAIN-98> has been
> created to cover this task.
>
> regards,
> Jonas
>
> 2013/6/20 Simone Tripodi <si...@apache.org>
>
>> Hallo Bene,
>>
>> > * JavaDoc of Command says that commands have to be designed in a
>> > thread-safe manner, yet all the base implementations are not thread
>> safe! I
>> > have created CHAIN-96 [1] for this, because this definitely has to be
>> fixed
>> > before 2.0
>>
>> +1
>>
>> > * The same is true for o.a.c.chain2.Chain and its base implemenation. For
>> > example there is a race condition in
>> o.a.c.chain2.impl.ChainBase.add(CMD).
>> > The method first checks the forzen flag and then acts... Another thread
>> may
>> > already have altered frozen. I have created CHAIN-97 [2] for this.
>>
>> ok, gut!
>>
>> > * The use of Context<K, V> is inconsistent throughout the API. Commands
>> > only need a C extends Map<K, V> for execution but the RemoveCommand
>> > implements Command<K, V, Context<K, V>>. Why do we need the Context
>> > interface anyway? It doesn't add much, the only method is just a generic
>> > wrapper around Map.get(Object).
>>
>> Context must have disappeared from methods signatures some time ago,
>> it is maybe a refuse - but at that time we agreed on creating a
>> commodity interface which contains the <T extends V> T retrieve(K
>> key); method;
>>
>> > * Base implementations should return the constants CONTINUE_PROCESSING or
>> > PROCESSING_COMPLETE instead of returning true or false
>>
>> I'd even switch to enumeration to represent states...
>>
>> > * It may make sense to introduce an enum instead of working with booleans
>> > as return values for commands.
>>
>> hahah nice one, I wrote the sentence above without reading the last
>> bullet, sounds we have an agreement here... :)
>>
>> Thanks & Best,
>> -Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://twitter.com/simonetripodi
>>
>>
>> On Thu, Jun 20, 2013 at 1:01 PM, Benedikt Ritter <br...@apache.org>
>> wrote:
>> > Hi guys,
>> >
>> > I had a look at the command interface and it's base classes yesterday,
>> and
>> > I think there is some work to do :) Here are the points I found:
>> >
>> > * JavaDoc of Command says that commands have to be designed in a
>> > thread-safe manner, yet all the base implementations are not thread
>> safe! I
>> > have created CHAIN-96 [1] for this, because this definitely has to be
>> fixed
>> > before 2.0
>> > * The same is true for o.a.c.chain2.Chain and its base implemenation. For
>> > example there is a race condition in
>> o.a.c.chain2.impl.ChainBase.add(CMD).
>> > The method first checks the forzen flag and then acts... Another thread
>> may
>> > already have altered frozen. I have created CHAIN-97 [2] for this.
>> > * The use of Context<K, V> is inconsistent throughout the API. Commands
>> > only need a C extends Map<K, V> for execution but the RemoveCommand
>> > implements Command<K, V, Context<K, V>>. Why do we need the Context
>> > interface anyway? It doesn't add much, the only method is just a generic
>> > wrapper around Map.get(Object).
>> > * Base implementations should return the constants CONTINUE_PROCESSING or
>> > PROCESSING_COMPLETE instead of returning true or false
>> > * It may make sense to introduce an enum instead of working with booleans
>> > as return values for commands.
>> >
>> > Thoughts?
>> >
>> > Benedikt
>> >
>> > [1] https://issues.apache.org/jira/browse/CHAIN-96
>> > [2] https://issues.apache.org/jira/browse/CHAIN-97
>> >
>> > --
>> > http://people.apache.org/~britter/
>> > http://www.systemoutprintln.de/
>> > http://twitter.com/BenediktRitter
>> > http://github.com/britter
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Jonas Sprenger <sp...@gmail.com>.
Hi guys,
so we talk about an enum 'PROCESSING' providing at least 3 states?
- CONTINUE
- COMPLETE
- ABORTED
Ticket CHAIN-98 <https://issues.apache.org/jira/browse/CHAIN-98> has been
created to cover this task.
regards,
Jonas
2013/6/20 Simone Tripodi <si...@apache.org>
> Hallo Bene,
>
> > * JavaDoc of Command says that commands have to be designed in a
> > thread-safe manner, yet all the base implementations are not thread
> safe! I
> > have created CHAIN-96 [1] for this, because this definitely has to be
> fixed
> > before 2.0
>
> +1
>
> > * The same is true for o.a.c.chain2.Chain and its base implemenation. For
> > example there is a race condition in
> o.a.c.chain2.impl.ChainBase.add(CMD).
> > The method first checks the forzen flag and then acts... Another thread
> may
> > already have altered frozen. I have created CHAIN-97 [2] for this.
>
> ok, gut!
>
> > * The use of Context<K, V> is inconsistent throughout the API. Commands
> > only need a C extends Map<K, V> for execution but the RemoveCommand
> > implements Command<K, V, Context<K, V>>. Why do we need the Context
> > interface anyway? It doesn't add much, the only method is just a generic
> > wrapper around Map.get(Object).
>
> Context must have disappeared from methods signatures some time ago,
> it is maybe a refuse - but at that time we agreed on creating a
> commodity interface which contains the <T extends V> T retrieve(K
> key); method;
>
> > * Base implementations should return the constants CONTINUE_PROCESSING or
> > PROCESSING_COMPLETE instead of returning true or false
>
> I'd even switch to enumeration to represent states...
>
> > * It may make sense to introduce an enum instead of working with booleans
> > as return values for commands.
>
> hahah nice one, I wrote the sentence above without reading the last
> bullet, sounds we have an agreement here... :)
>
> Thanks & Best,
> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://twitter.com/simonetripodi
>
>
> On Thu, Jun 20, 2013 at 1:01 PM, Benedikt Ritter <br...@apache.org>
> wrote:
> > Hi guys,
> >
> > I had a look at the command interface and it's base classes yesterday,
> and
> > I think there is some work to do :) Here are the points I found:
> >
> > * JavaDoc of Command says that commands have to be designed in a
> > thread-safe manner, yet all the base implementations are not thread
> safe! I
> > have created CHAIN-96 [1] for this, because this definitely has to be
> fixed
> > before 2.0
> > * The same is true for o.a.c.chain2.Chain and its base implemenation. For
> > example there is a race condition in
> o.a.c.chain2.impl.ChainBase.add(CMD).
> > The method first checks the forzen flag and then acts... Another thread
> may
> > already have altered frozen. I have created CHAIN-97 [2] for this.
> > * The use of Context<K, V> is inconsistent throughout the API. Commands
> > only need a C extends Map<K, V> for execution but the RemoveCommand
> > implements Command<K, V, Context<K, V>>. Why do we need the Context
> > interface anyway? It doesn't add much, the only method is just a generic
> > wrapper around Map.get(Object).
> > * Base implementations should return the constants CONTINUE_PROCESSING or
> > PROCESSING_COMPLETE instead of returning true or false
> > * It may make sense to introduce an enum instead of working with booleans
> > as return values for commands.
> >
> > Thoughts?
> >
> > Benedikt
> >
> > [1] https://issues.apache.org/jira/browse/CHAIN-96
> > [2] https://issues.apache.org/jira/browse/CHAIN-97
> >
> > --
> > http://people.apache.org/~britter/
> > http://www.systemoutprintln.de/
> > http://twitter.com/BenediktRitter
> > http://github.com/britter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [CHAIN] Thoughts about o.a.c.chain2.Chain, o.a.c.chain2.Command
and the base classes
Posted by Simone Tripodi <si...@apache.org>.
Hallo Bene,
> * JavaDoc of Command says that commands have to be designed in a
> thread-safe manner, yet all the base implementations are not thread safe! I
> have created CHAIN-96 [1] for this, because this definitely has to be fixed
> before 2.0
+1
> * The same is true for o.a.c.chain2.Chain and its base implemenation. For
> example there is a race condition in o.a.c.chain2.impl.ChainBase.add(CMD).
> The method first checks the forzen flag and then acts... Another thread may
> already have altered frozen. I have created CHAIN-97 [2] for this.
ok, gut!
> * The use of Context<K, V> is inconsistent throughout the API. Commands
> only need a C extends Map<K, V> for execution but the RemoveCommand
> implements Command<K, V, Context<K, V>>. Why do we need the Context
> interface anyway? It doesn't add much, the only method is just a generic
> wrapper around Map.get(Object).
Context must have disappeared from methods signatures some time ago,
it is maybe a refuse - but at that time we agreed on creating a
commodity interface which contains the <T extends V> T retrieve(K
key); method;
> * Base implementations should return the constants CONTINUE_PROCESSING or
> PROCESSING_COMPLETE instead of returning true or false
I'd even switch to enumeration to represent states...
> * It may make sense to introduce an enum instead of working with booleans
> as return values for commands.
hahah nice one, I wrote the sentence above without reading the last
bullet, sounds we have an agreement here... :)
Thanks & Best,
-Simo
http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi
On Thu, Jun 20, 2013 at 1:01 PM, Benedikt Ritter <br...@apache.org> wrote:
> Hi guys,
>
> I had a look at the command interface and it's base classes yesterday, and
> I think there is some work to do :) Here are the points I found:
>
> * JavaDoc of Command says that commands have to be designed in a
> thread-safe manner, yet all the base implementations are not thread safe! I
> have created CHAIN-96 [1] for this, because this definitely has to be fixed
> before 2.0
> * The same is true for o.a.c.chain2.Chain and its base implemenation. For
> example there is a race condition in o.a.c.chain2.impl.ChainBase.add(CMD).
> The method first checks the forzen flag and then acts... Another thread may
> already have altered frozen. I have created CHAIN-97 [2] for this.
> * The use of Context<K, V> is inconsistent throughout the API. Commands
> only need a C extends Map<K, V> for execution but the RemoveCommand
> implements Command<K, V, Context<K, V>>. Why do we need the Context
> interface anyway? It doesn't add much, the only method is just a generic
> wrapper around Map.get(Object).
> * Base implementations should return the constants CONTINUE_PROCESSING or
> PROCESSING_COMPLETE instead of returning true or false
> * It may make sense to introduce an enum instead of working with booleans
> as return values for commands.
>
> Thoughts?
>
> Benedikt
>
> [1] https://issues.apache.org/jira/browse/CHAIN-96
> [2] https://issues.apache.org/jira/browse/CHAIN-97
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org