el-next@uel.java.net

Re: Reverse-lookup EL names

From: Pete Muir <pmuir_at_redhat.com>
Date: Fri, 9 Apr 2010 11:43:24 +0100

What scenarios do you see this being useful in?

On 1 Apr 2010, at 00:06, Lincoln Baxter, III wrote:

> I'm seeing benefit for a TypeMapper or NameMapper off of the ELContext object.
>
> When working with Bean Containers, each container has a different API for looking up beans and getting information about them. For instance, if I wanted to know what names were associated with a bean of type "com.ocpsoft.MyBean," there's currently no way of doing that through EL. I can go out to the bean containers themselves in order to get that information, but EL hides it.
>
> The use case:
> I've annotated a class, and a method on that class, and want to use that annotation to invoke an operation on that bean:
>
> @ExtensionDefined
> @javax.enterprise.context.Named("something")
> public class MyBean {
>
> @ExecuteThis
> public void action() {}
>
> }
>
> The custom annotations' scanner has access to the Class Type, but without providing direct support for Spring, CDI, Seam, Guice, JSF, etc -- has no idea what that class is named in the EL.
>
> The ELContext has hooks into whatever bean-container backs it (if there even is one -- it could be completely custom) and can provide names for a given type.
>
> So:
>
> @Inject ELContext context; //assume this works for example purposes...
> TypeMapper mapper = context.getTypeMapper();
> Set<String> names = mapper.getNames(Class<?> clazz); // lists all names for which the provided type is registered.
>
> This is a very rough concept, but what do you think? I think the value is there, but specifics need to be worked out.
>
> --
> Lincoln Baxter, III
> http://ocpsoft.com
> http://scrumshark.com
> "Keep it Simple"