The object you get is actually a proxy to the actual service
implementation.  The dynamic proxy only knows that it needs to support
the javax.servlet.Filter interface, so that's all it supports.  You
can't downcast it to the implementation class.  What you can do is
come up with your own service interface which extends
javax.servlet.Filter and your implementation class can implement that.
You'd have to use that interface to "talk to" your service object.

p.s. Alternatively, there is such a thing as bean services (the
service interface is the bean class), but I don't suggest using them.
It's better to front your services with an interface (which is what we
have to fabricate at runtime via Javassist to support bean services).


On 11/11/06, Robin Ericsson <[EMAIL PROTECTED]> wrote:
Hi,

This is really a hivemind question, but it's my tapestry usage that
probably is wrong :)

My service looks like this:
    <service-point id="FormProcessingFilter" interface="javax.servlet.Filter">
        <invoke-factory>
            <construct
class="nu.localhost.bwatch.filters.FormProcessingFilter"
initialize-method="afterPropertiesSet">
                <set property="authenticationFailureUrl"
value="/LoginFailed.html" />
                <set property="defaultTargetUrl" value="/app" />
                <set property="filterProcessesUrl"
value="/j_acegi_security_check" />
            </construct>
        </invoke-factory>
    </service-point>

I inject it in tapestry like this:
        @InjectObject("service:bwatch.FormProcessingFilter")
        public abstract Filter getProcessingFilter();

But when I cast it to my class which I know it is, I get a ClassCastException.
FormProcessingFilter filter = (FormProcessingFilter) getProcessingFilter();

What am I doing wrong and how should I solve it? :)

--
        regards,
        Robin

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



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

Reply via email to