[jboss-user] [JBoss Seam] - Re: A couple of observations

petemuir do-not-reply at jboss.com
Thu Aug 3 16:43:16 EDT 2006


"iradix" wrote : 
  | 1)I haven't found a good way to instantiate multiple, unique Seam  components of the same type.  As a use case say that I have a ProductFinder  SFSB that uses multiple CategoryFilter objects to narrow down a result list.  I can't create a subclass of CategoryFilter for each type of category because the categories are dynamically defined, and I'd like them to be Seam components so that they can take advantage of bijection and all the other Seam goodies.  What I've been doing in this situation is using Component.newInstance(), but besides the fact that Gavin indicated that wasn't a great idea, it doesn't really seam suited to the task anyway.  For one thing, newInstance() will cause an outjection of the created component after it is created, which is not really something I'm interested in for this scenario.  Why clutter up any context when the bean is just used internally by the containing class?  This isn't much of a problem with EJBs since they can be retrieved outside of seam and still be intercepted, but  how about a method like  T Component.newInstance(Class beanClass) to instantiate a CGLIB enhanced bean of any class with a no-arg constructor?  The instantiated bean wouldn't even have to be named since it won't be outjected. Or at least public access to the methods on Component necessary to do something like that would be helpful.

I can see uses for this, but remember you can do bijection etc. through Component and the Context.  Since you're creating a reusable component this might be a better way to do it as it allows you to specify context variable names at runtime rather than compiletime.  Is there anything you can do with Seam annotations that you can't with methods? Off the top of my head: DataBinder stuff perhaps (could be useful), Logger (which I would find useful to be able to access as Logger.getInstance(...) for these situations thus removing a commons-logging dependencies).

anonymous wrote : 2) Wouldn't the ability to define an automatic naming convention be nice?  Something like the type of pattern Log4J gives you to output a portion of a class name?  Generally, I'm naming all of my beans to be the camel case class name with a lowercase first character and this would help with refactoring as well as stupid mistakes like copying a similar object and forgetting to change the name.  Hopefully I'm not the only one who does things like that.  Basically, all you would have to do is give the component a @Name annotation with no value to get the default.  I'd imagine the naming convention could be defined in seam.properties.

Yeah.  Something similar to the Hibernate Naming Strategy I think would be a good idea.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963012#3963012

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963012




More information about the jboss-user mailing list