-
1. Re: Simple interceptor isn't getting activated
nickarls Apr 23, 2008 9:05 AM (in response to ericjava.eric.chiralsoftware.net)Because you forgot the @Interceptor tag?
-
2. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 9:11 AM (in response to ericjava.eric.chiralsoftware.net)Is that required? That's part of Seam but not of EBJ3. Do I need it, and where do I put it?
-
3. Re: Simple interceptor isn't getting activated
nickarls Apr 23, 2008 9:20 AM (in response to ericjava.eric.chiralsoftware.net)Not sure if it's required. I have something like
@Interceptor public class Auditor { @AroundInvoke public Object audit(InvocationContext context) throws Exception {...} }
and
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Interceptors(Auditor.class) public @interface Audited { }
and then have an @Audited tag on my classes
-
4. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 9:39 AM (in response to ericjava.eric.chiralsoftware.net)Ok, I have it intercepting a session bean, so the interceptor is capable of intercepting.
But it seems like I need to do something different to get it to intercept getter and setter methods on my @Entity class. Any ideas on this? If you have gotten it working on an Entity I would be quite interested in which annotations you used.
-
5. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 9:43 AM (in response to ericjava.eric.chiralsoftware.net)Ok, I'm figuring out more.
EJB interceptors are for session beans only. From the Seam docs:
EJB 3.0 introduced a standard interceptor model for session bean components.So, clearly, it's working on a session bean, but is it possible to also intercept getter and setters on Entities? That's what I'm looking at now. I assume it must be because how else would the Hibernate validators work?
-
6. Re: Simple interceptor isn't getting activated
nickarls Apr 23, 2008 9:57 AM (in response to ericjava.eric.chiralsoftware.net)Hmm. Not sure it has to be done with interception, they might just parse the hibernate annotations and convert them to normal JSF validators and hook them on. Or something. Entities don't get injections so I'm not sure they get interceptors either. Just guessing.
-
7. Re: Simple interceptor isn't getting activated
nickarls Apr 23, 2008 10:03 AM (in response to ericjava.eric.chiralsoftware.net)I've never checked at what stage the validation is being called, probably at the normal JSF lifecycle but probably also the Hibernate EntityManager does some checking before doing the operations (doesn't know it's been through JSF).
-
8. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 10:05 AM (in response to ericjava.eric.chiralsoftware.net)Hmm, thanks for the tip on that.
Here's what I'm trying to do: I have a bunch of entities with a lot of String properties, and I want to do some
string cleanup
on all of them, like trim all of them, many of them should be all-lower-cased, etc. I want to apply these transformations to a big set of entities and properties.I was hoping to do that with an interceptor, so I could basically say
@Interceptors(TrimAllStrings.class)
on some class, and that would be it.But that certainly won't work in plain EJB3. Is there a
Seam way
to do it?Thanks
-
9. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 10:14 AM (in response to ericjava.eric.chiralsoftware.net)Just realized, one thing I could do is write a JSF converter. That would be ok, except then I have to use it all over the place in my JSF code, and I would prefer to apply it automatically to every property in an entity, for instance.
Hmmm.
-
10. Re: Simple interceptor isn't getting activated
jacob.orshalick Apr 23, 2008 12:52 PM (in response to ericjava.eric.chiralsoftware.net)If you are going to use it for all Strings, just set your custom converter as the default converter for Strings in your faces-config. If you have exceptional cases, simply override the converter in the JSF page.
Hope that helps.
-
11. Re: Simple interceptor isn't getting activated
ericjava.eric.chiralsoftware.net Apr 23, 2008 8:00 PM (in response to ericjava.eric.chiralsoftware.net)That's a good idea, I'll do that.
It would be cool to be able to have something like an
entity filter
or entity callbacks that can do things to properties. But for now, doing this in faces config will be fine.