I'm far enough along to provide some contextualized code useful for problem 
statement elaboration... and maybe someone can think of an outside-the-box 
solution?
 
The basic challenge is the integration of properties with each 'injectable 
plugin'.  The properties are defined at *server start-up 
or outside-container unit testing set-up* where five steps are executed:
 

 **********************************************************************
 * SOAj v. 2.2.6 [Copyright (c) 2012 by GTC at gtcGroup.com]
 **********************************************************************
 * Threads Available: 12
 * Cores Available: 8
 **********************************************************************
 * 
/C:/projects/refapp/SOAj/soaj-core/target/test-classes/soaj-timer-config.xml
 **********************************************************************
 * Activation Sequence Phase 0 - Retrieve Elements [3]
 * Activation Sequence Phase 1 - Injector Bindings [3]
 * Activation Sequence Phase 2 - Instantiate Plugins [3]
 * Activation Sequence Phase 3 - Invoke Verification
 * Activation Sequence Phase 4 - Log Metadata
 **********************************************************************
 
*During Phase 1 the plugin module objects (MO) populate properties using a 
Template Method invoked during the "configure" portion of the module 
lifecycle.  *
 
/**
 * This MODULE OBJECT defines properties programmatically.
 * 
 * <p style="font-family:Verdana; font-size:10px; font-style:italic">
 * Copyright (c) 2006 - 2012 by Global Technology Consulting Group, Inc. at 
<a
 * href="http://gtcGroup.com";>gtcGroup.com </a>.
 * </p>
 * 
 * @author Marvin Toll
 * @since v. 2.3
 */
public class SjcLocalHostTimerMO extends SjcBaseMO {
    /**
     * Constructor
     * 
     * @param pluginElementPO
     */
    public SjcLocalHostTimerMO(final SjcPluginElementPO pluginElementPO) {
        super(pluginElementPO);
        return;
    }
    /**
     * @see SjcBaseMO#putPropertiesTM(Properties)
     */
    @Override
    public void putPropertiesTM(final Properties properties) {
        properties.put(SjcPiTimer.DECLARATIVE_LOGGING_TASK_SCHEDULED, 
"true");
        properties.put(SjcPiTimer.DECLARATIVE_LOGGING_TASK_LAUNCHED, 
"true");
        properties.put(SjcPiTimer.DECLARATIVE_LOGGING_TASK_COMPLETED, 
"true");
        return;
    }
}
 
The properties above are cached using the injectable plugin 'unique name' 
as the key.*  During processing, the injectable plugin instances may need 
access to their properties* (obtainable from the Caching Singleton)*:*
 
    /**
     * This method retrieves cached properties.
     * 
     * @param pluginUniqueName
     * @return SjcPluginPropertyPO
     */
    public static SjcPluginPropertyPO retrievePluginPropertyPO(
            final String pluginUniqueName) {
 
        final SjcPluginPropertyPO pluginPropertyPO = 
ActivatedPluginsCS.activatedProperties
                .get(pluginUniqueName);
 
        return pluginPropertyPO;
    }
 
*So... this got me to the point that an injectable plugin instance needs to 
know its own "unique name".*

 

Having said all that... there may be a better way to integrate properties 
(useable with both web server and outside-container unit testing) with 
their injectable plugin instance... that are processed at server startup.

_Marvin
http://PatternEnabled.com


On Friday, July 20, 2012 3:58:14 PM UTC-4, Craig McClanahan wrote:

> What you are trying to do isn't going to work.
>
> The @Named annotation in question is on the field where the injection took 
> place.  The object that got injected, or its class (SjcPiTimerSI) has no 
> clue *why* it got injected, so no general purpose utility method like you 
> have outlined is going to be able to learn what you're after.
>
> Craig
>
> On Thu, Jul 19, 2012 at 10:03 AM, MarvinToll.com 
> <[email protected]>wrote:
>
>> ** Newbie Alert **
>>
>> A class has the following field injection:
>>
>>     @Inject
>>     @Named(SjcConstant.TIMER_PLUGIN)
>>     private SjcPiTimerSI timerSI;
>>
>> I would like to subsequently find out the instance @Named value.
>>
>> For example, a Utility method similar to:
>>
>> public static String retrieveInstanceNamedName (SjcPiTimerSI 
>> thisInstance) {
>>
>> String instanceName;
>>
>>      *???*
>>
>> return instanceName;
>> }
>>
>> Any thoughts/
>>
>> _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/-/W7xHCPKv6fcJ.
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.

Reply via email to