Hello David;

What I am thinking is that 

1- Supress checkings in "AutoConfig" class

    private void processJndiRefs(String moduleId, JndiConsumer jndiConsumer, 
AppResources appResources, ClassLoader loader) throws OpenEJBException {
        // Resource reference
        for (ResourceRef ref : jndiConsumer.getResourceRef()) {
            
            try {
                Class clazz = Class.forName(ref.getType(),true,loader);
                if(clazz.isAnnotationPresent(ManagedBean.class)){
                    continue;
                }
            } catch (ClassNotFoundException e) {
                throw new OpenEJBException("Class not found : " + 
ref.getType(),e);
            }
 ....
}

2- Updating JndiEncBuilder for ResourceReferenceInfo processing. If @Resource 
type is annotated with @ManagedBean, we can directly add "location" info to the 
resource reference info. Because, managed beans are bound to 
java:module/bean_name  and java:app/module/bean_name contexts. Therefore it has 
always been resolved correctly whether or not "lookup" defined on @Resource.

        for (ResourceReferenceInfo referenceInfo : jndiEnc.resourceRefs) {
            Reference reference = null;

            String refType = referenceInfo.referenceType;
            boolean mb = false;
            Class clazz;
            try {
                clazz = Class.forName(refType, true, classLoader);
                mb = clazz.isAnnotationPresent(ManagedBean.class);
            } catch (ClassNotFoundException e) {
                throw new OpenEJBException("Class not found : " + refType,e);
            }
            
            if(mb){
                String location = referenceInfo.location.jndiName;
                if(location == null){
                    ManagedBean managedBean = 
(ManagedBean)clazz.getAnnotation(ManagedBean.class);
                    String name = managedBean.value();
                    if(name == null || name.equals("")){
                        name = clazz.getSimpleName();
                    }
                    referenceInfo.location = new ReferenceLocationInfo();       
 
            

                    referenceInfo.location.jndiName = "module/" + name;
                }
            }


WDYT?

--Gurkan



----- Original Message ----
From: David Blevins <[email protected]>
To: [email protected]
Sent: Sat, September 18, 2010 12:19:50 AM
Subject: Re: Managed Bean Support


On Sep 17, 2010, at 9:28 AM, Gurkan Erdogdu wrote:

> Hi;
> 
> I am looking the ManagedBean implementation. I think that currently it does 
> not 
>
> support the injection of managed beans via @Resource? Is it correct or I am 
> wrong?

I don't think that's in there yet, but referring to them via @EJB does work as 
a 
side affect of us treating @ManagedBean as a kind of session bean.  Up for 
grabs 
if you want to work on it.

Definitely feel encouraged to throw out implementation ideas before digging.  I 
imagine that we'll not want a second copy of "resolve by interface" code and 
will want to somehow leverage the EjbResolver code we have.

We could probably make it so you can refer to any EJB via @Resource to keep 
things consistent.  Maybe we just detect that the @Resource ref is a bean ref 
and internally record it as a org.apache.openejb.jee.EjbLocalRef.


-David


Reply via email to