When you contribute a filter, you need to instantiate it.  Generally
it looks something like:

  public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
configuration, ObjectLocator locator)
  {
    configuration.add("MyFilter", locator.autobuild(MyFilter.class));
  }

The ObjectLocator is a resource of the RequestHandler service that can
be injected into contribute methods for the RequestHandler service and
allows access to other services within the IoC Registry; it also
handle instantiation of objects with injection for you.  So MyFilter
doesn't have to be a service but can still be injected.  Contributing
an object instance to a filter does not do any injection, but
autobuild() does.

In the current .16 snapshot, you can use @Inject on fields of MyFilter
in addition to injection through the constructor.  This was added
because people got confused:  in pages and components you use @Inject
on fields, but in service implementation, 5.0.15 requires that
dependencies be passed through the constructor.  Again, 5.0.16 allows
you to code services and other objects more consistently (but with the
runtime overhead of using reflection to update the private fields).

On Fri, Oct 31, 2008 at 2:41 PM, Keith Bottner <[EMAIL PROTECTED]> wrote:
> Is it possible to retrieve ApplicationStateManager from within a Filter?
>
> I tried using an @Inject and it always returns null.
> I tried placing it in the constructor of the filter but when it is accessed
> it is null.
>
> Is there a recommend way of doing this or is it even advisable?
>
> Thanks in advance for your help.
>
> Keith
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to