Being a newbie to Guice I'm not yet expressing myself well.
This post has been resolved... sort of... I'm caching the properties
instead of trying to use a @Provides... (see post 'Determine an Injected
Instance "@Named" Value').
The current Module Object base class 'configure' method reads as follows:
@Override
protected void configure() {
final String Method_Name = "configure";
// Declare/Initialize
final String pluginUniqueName = this.pluginElementPO
.getPluginUniqueName();
final Properties pluginProperties = new Properties();
putPropertiesTM(pluginProperties);
final SjcPluginPropertyPO pluginPropertyPO = new
SjcPluginPropertyPO(
pluginUniqueName, pluginProperties);
SjcGeneralStoreUtil.putPluginPropertyPO(pluginPropertyPO);
Class<Object> pluginInterface;
Class<Object> pluginConcrete;
try {
pluginConcrete = SjcReflectionUtil
.retrieveClass(this.pluginElementPO
.getPluginConcreteClassName());
} catch (final ClassNotFoundException e) {
throw new SjcReflectionSE(new
SjcExceptionPO(SjcBaseMO.CLASS_NAME,
Method_Name), "The plugin interface ["
+ this.pluginElementPO.getPluginConcreteClassName()
+ "] could not be referenced.", e);
}
// Determine if singleton and determine if interface.
// That makes for four possible bind combinations.
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);
}
if (this.pluginElementPO.isPluginCacheable()) {
bind(pluginInterface)
.annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete).asEagerSingleton();
} else {
bind(pluginInterface).annotatedWith(
Names.named(pluginUniqueName)).to(pluginConcrete);
}
} else if (this.pluginElementPO.isPluginCacheable()) {
bind(pluginConcrete).annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete).asEagerSingleton();
} else {
bind(pluginConcrete).annotatedWith(Names.named(pluginUniqueName))
.to(pluginConcrete);
}
}
On Wednesday, July 18, 2012 5:13:48 PM UTC-4, MarvinToll.com wrote:
> A task is required to be handled programmtically... here is the
> representative 'bind':
>
> bind(SjcPiTimerSI.class).annotatedWith(
>
> Names.named(SjcConstant.TIMER_PLUGIN)).to(SjcPiTimer.class);
>
> However, an instance containing properties is also required.... here is
> the representative '@Provides':
>
> @Provides
> @Named(SjcConstant.TIMER_PLUGIN)
> SjcPiTimerSI provideTimer() {
>
> final SjcPiTimer timer = new SjcPiTimer();
> final SjcPluginPropertyPO pluginPropertyPO = new
> SjcPluginPropertyPO(
> SjcConstant.TIMER_PLUGIN, getTimerProperties());
> timer.setPluginPropertiesOrNullTM(pluginPropertyPO);
>
> return timer;
> }
>
>
>
> *Question:*
>
> Is there a way accomplish the addition of the Plugin Property PO with a
> semantic similar to the 'bind' above? Said another way, I'd like to be
> able to 'bind' (including properties) without having to use an annotation.
>
> _Marvin
> http://PatternEnabled.com
>
>
--
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/-/M06LfKiH_NkJ.
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.