I've rewritten the problem statement using a "robot legs" semantic:
This is the "robot properties" problem: How to create two robots each
with a unique Properties object, the left one injected with a Propertiesdefined
in LeftModule, and the right one with a
Properties defined in RightModule. That is, two Robot instances uniquely
named, each having a Module defining a Properties instance that has a
shared set of property keys with (potentially) unique property values.
And to bind these in a generic (loosely typed manner) by adding to the
following code executed from BaseModule.config() so that the unique
Properties instances are generically referenceable from a Robot instance:
/**
* This method configures the {@link Binder} subsequently used to
create an
* injector.
*
* @param pluginConcrete
* @param pluginUniqueName
*/
protected void bindPlugin(final Class<Object> pluginConcrete,
final String pluginUniqueName) {
final String Method_Name = "bindPlugin";
// Declare/Initialize
final Class<Object> pluginInterface;
if (this.pluginElementPO.isPluginInterfaceName()) {
try {
pluginInterface = SjcReflectionUtil
.retrieveClass(this.pluginElementPO
.getPluginInterfaceNameOrNull());
} catch (final ClassNotFoundException e) {
throw new SjcReflectionSE(new SjcExceptionPO(
SjcBaseMO.CLASS_NAME, Method_Name),
"The plugin interface ["
+ this.pluginElementPO
.getPluginInterfaceNameOrNull()
+ "] could not be referenced.", e);
}
// ********************************
// * Four Combinations Start Here *
// ********************************
if (this.pluginElementPO.isPluginCacheable()) {
// Yes interface, yes singleton.
bind(pluginInterface)
.annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete).asEagerSingleton();
} else {
// Yes interface, no singleton.
bind(pluginInterface).annotatedWith(
Names.named(pluginUniqueName)).to(pluginConcrete);
}
} else if (this.pluginElementPO.isPluginCacheable()) {
// No interface, yes singleton.
bind(pluginConcrete).annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete).asEagerSingleton();
} else {
// No interface, no singleton.
bind(pluginConcrete).annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete);
}
return;
On Monday, August 6, 2012 6:13:00 AM UTC-4, Dave Elton wrote:
> ***Also a newbie ***
>
> I'm not sure that this is exactly your problem, but the "robot legs"
> solution in the FAQ may use some of the mechanisms that could help you:
> http://code.google.com/p/google-guice/wiki/FrequentlyAskedQuestions
>
>
>
--
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/-/3IONNq3BZ38J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.