<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 7 Oct 2010, at 21:23, Israel Lacerra wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I think I really need initialize the command on CommandsFactoryImpl.initializeReplicableCommand. In RemoteCommandsFactory we only initialize the parameters that have been serialized.... right? <br></blockquote>yes. Or use a generic interface that only has an init(ComponentRegistry) call? Then the command can read whatever it needs from the registry. <br><blockquote type="cite"><br>I need a cache local instance... and RemoteCommandsFactory does not have it (at least not yet).<br>
<br><div class="gmail_quote">On Thu, Sep 30, 2010 at 9:58 PM, Israel Lacerra <span dir="ltr"><<a href="mailto:israeldl@gmail.com">israeldl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><br><div class="gmail_quote"><div class="im">On Thu, Sep 30, 2010 at 8:15 PM, Manik Surtani <span dir="ltr"><<a href="mailto:manik@jboss.org" target="_blank">manik@jboss.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><br><div><div><div>On 30 Sep 2010, at 23:48, Israel Lacerra wrote:</div><br><blockquote type="cite"><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 4:06 PM, Manik Surtani <span dir="ltr"><<a href="mailto:manik@jboss.org" target="_blank">manik@jboss.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
So this is an extension to the discussion around a GenericCommand that has been going around. IMO a GenericCommand is a big -1 from me for various reasons - the whole purpose of the command pattern is so we have strongly typed and unit testable commands. This will help the ongoing work by Mircea, Sanne and Israel on various modules that need to define custom commands.<br>
<br>
I proposed the following solution to Mircea earlier today, I'll repeat here for you guys to discuss. Note that this is a *half baked* solution and needs more thought! :-)<br>
<br>
* If a module needs to define custom commands, it should define its own ReplicableCommand implementations in its' own module.<br>
* It should define a sub-interface to Visitor (MyModuleVisitor) with additional methods to handle the new commands<br>
* Interceptors defined in this module should extend CommandInterceptor AND implement MyModuleVisitor<br>
* These new commands can be created directly, or via a new CommandFactory specially for these commands.<br>
<br></blockquote><div>Just to make clear what is my problem... The ReplicableCommand does not need to be necessarily a VisitableCommand, right?</div></div></blockquote><div><br></div></div><div>Yes, if your custom command is not visitable then you won't need to extend Visitor, etc.</div>
<div><br><blockquote type="cite"><div class="gmail_quote"><div> In my case it's a CacheRpcCommand and I have to initialize this on CommandsFactoryImpl.initializeReplicableCommand(ReplicableCommand, boolean):<br>
<br>case ClusteredQueryFacade.COMMAND_ID:<br> ClusteredQueryFacade csc = (ClusteredQueryFacade) c;<br> csc.initialize(cache);<br> break;<br><br>The problem is each ReplicableCommand may have a different way to initialize. Maybe we can create a big initialize method, that receives a lot of arguments, and the command uses just some of them. Or this problem will de solved with the solution that you proposed?<br>
</div></div></blockquote><div><br></div></div><div>This is in the RemoteCommandsFactory right? This is why I suggested RemoteCommandsFactory.fromStream() has a Map which contains IDs mapped to a command creator instance. A command creator could be an interface that looks like:</div>
<div><br></div></div></div></blockquote></div><div><br>No. This is in the CommandsFactoryImpl.initializeReplicableCommand. But maybe it could be on RemoteCommandsFactory. I did not remember if JavaDoc made me put this on CommandsFactoryImpl or if I really tried on RemoteCommandsFactory and did not worked. <br>
<br> </div><div class="im"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div></div><div>interface CommandCreator<C extends ReplicableCommand> {</div>
<div> C createAndInitialize();</div><div>}</div><div><br></div><div>So when you register a new command ID you also create and register a new CommandCreator instance which knows how to create and initialize the command.<br>
</div></div></div></blockquote></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im"><div style="word-wrap: break-word;"><div>
<div><br></div><div>
I'll try and find some time tomorrow to hack up a hypothetical example. Should make it clearer for everyone.</div><div><br></div><div>More comments? Mircea, Sanne? </div></div><div><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;">
<div><br></div><font color="#888888"><div>--</div></font><div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org" target="_blank">manik@jboss.org</a></div></div><div><div>Lead, Infinispan</div>
<div>Lead, JBoss Cache</div><div><a href="http://www.infinispan.org/" target="_blank">http://www.infinispan.org</a></div><div><a href="http://www.jbosscache.org/" target="_blank">http://www.jbosscache.org</a></div><div><br>
</div></div></div></span><br></span><br>
</div>
<br></div><br></div><div class="im">_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br></div></blockquote></div><br>
</blockquote></div><br>
_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/infinispan-dev</blockquote></div><br></body></html>