No, @Inject is an IOC annotation and works for services. I've never
tried injecting a static service though...

@Inject
private static PolicyValueProviderSource policyValueProvider;

maybe try deleting the 'static' keyword, oh, and ensure you're using
the Tapestry @Inject and not javax or anyother.

Steve.


On 21 September 2011 16:18, Chris Poulsen <mailingl...@nesluop.dk> wrote:
> Hi,
>
> I thought the @Inject was a part of the web app goodness that only works in
> those special packages and constructor injection is the way to go when using
> the IoC stand-alone?
>
> (This page shows an example using this:
> http://wiki.apache.org/tapestry/Tapestry5HowToIocOnly )
>
> --
> Chris
>
> On Wed, Sep 21, 2011 at 9:37 AM, nquirynen <nat...@pensionarchitects.be>wrote:
>
>> I have made a new project and have now this:
>>
>> *Main.java*
>>
>> public static void main(String[] args) {
>>         RegistryBuilder builder = new RegistryBuilder();
>>        builder.add(AppModule.class);
>>
>>        Registry registry = builder.build();
>>        registry.performRegistryStartup();
>>
>>                DocumentGenerator gen = new DocumentGenerator();
>>
>>        registry.cleanupThread();
>>        registry.shutdown();
>>        }
>>
>> *AppModule.java*
>>
>> public static void bind(ServiceBinder binder)
>>    {
>>        binder.bind(PolicyValueProviderSource.class,
>> PolicyValueProviderSourceImpl.class);
>>     }
>>
>>
>>    public void
>> contributePolicyValueProviderSource(MappedConfiguration&lt;String,
>> PolicyValueProvider&gt; config) {
>>         config.add("name", new PolicyValueProvider(){
>>                @Override
>>                public String getValue(Policy policy) {
>>                        return policy.getHolder().getName();
>>                }
>>        });
>>        config.add("firstname", new PolicyValueProvider(){
>>                @Override
>>                public String getValue(Policy policy) {
>>                        return policy.getHolder().getFirstName();
>>                }
>>        });
>>    }
>>
>> *
>> DocumentGenerator.java*
>>
>> @Inject
>>        private static PolicyValueProviderSource policyValueProvider;
>>
>>        public DocumentGenerator() {
>>                 for(String v : policyValueProvider.getConfiguredFields()) {
>>                        System.out.println(v+" : ");
>>                }
>>        }
>>
>>
>>
>>
>> But now I always get a NullPointerException on *policyValueProvider* in
>> *DocumentGenerator.*
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Console-app-with-Tapestry-IoC-configuration-tp4822836p4825438.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to