I think that you're looking for Assisted Inject: http://code.google.com/p/google-guice/wiki/AssistedInject
On Thu, Jul 5, 2012 at 9:14 PM, cheez <u.int.3...@gmail.com> wrote: > I have a FTP client which has multiple servers configured by the user at > runtime: > > class FTPConnection > { > FTPConnection(ServerInfo server, UserInfo user)... > } > > I also have a client class which does something with the connection: > > class DoSomethingWithFTP > { > DoSomethingWithFTP(FTPConnection conn)... > } > > For example, one type of DoSomethingWithFTP might be a > DownloadAllTheThings process. What I'd like to do is have a notion of a > "current connection" which is analogous to the "current user". Nevermind > that I probably wouldn't write code like this, all I want to do is figure > out how I would inject the "current" FTP connection! > > So as you can see, a FTP connection requires some server info and user > info. This is where I get stuck. The "current connection" is tied to these > two values and they need to be injected into the FTPConnection. > > If it was a web app, I might scope these values to the session but what if > I wanted to process all of them at once, in multiple threads? > > The pseudo-code I'd like to write is this: > > foreach( pair<UserInfo,ServerInfo> config : whatever() ) > { > makeNewThreadAndProcessThisSite(config); > } > > This is a very simplified view of the whole thing. I probably will not > write code like this but I think it's an approximate proxy for the problem > I am really trying to solve. > > Would you kindly help me tease out a solution? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-guice/-/5lXTdY069zEJ. > To post to this group, send email to google-guice@googlegroups.com. > To unsubscribe from this group, send email to > google-guice+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to google-guice@googlegroups.com. To unsubscribe from this group, send email to google-guice+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.