FileDocCategorySizeDatePackage
DefaultDOLVisitor.javaAPI DocGlassfish v2 API14033Fri May 04 22:31:58 BST 2007com.sun.enterprise.deployment.util

DefaultDOLVisitor

public class DefaultDOLVisitor extends Object implements EjbBundleVisitor, WebBundleVisitor, ConnectorVisitor, ApplicationVisitor, AppClientVisitor, EjbVisitor
Default implementation of all the DOL visitor interface for convenience
author
Jerome Dochez
version

Fields Summary
protected com.sun.enterprise.deployment.BundleDescriptor
bundleDescriptor
Constructors Summary
public DefaultDOLVisitor()
Creates new TraceVisitor


        
      
    
Methods Summary
public voidaccept(com.sun.enterprise.deployment.WebService webService)
visits a web service definition

param
web service

    
public voidaccept(com.sun.enterprise.deployment.MethodPermission pm, java.util.Iterator methods)
visits a method permission and permitted methods for the last J2EE component visited

param
method permission
param
the methods associated with the above permission

    
public voidaccept(com.sun.enterprise.deployment.RoleReference roleRef)
visits a role reference for the last J2EE component visited

param
role reference

    
public voidaccept(com.sun.enterprise.deployment.MethodDescriptor method, com.sun.enterprise.deployment.ContainerTransaction ct)
visists a method transaction for the last J2EE component visited

param
method descriptor the method
param
container transaction

    
public voidaccept(com.sun.enterprise.deployment.EnvironmentProperty envEntry)
visits an environment property for the last J2EE component visited

param
the environment property

    
public voidaccept(com.sun.enterprise.deployment.ResourceReferenceDescriptor resRef)
visits an resource reference for the last J2EE component visited

param
the resource reference

    
public voidaccept(com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor jmsDestRef)
visits an jms destination reference for the last J2EE component visited

param
the jms destination reference

    
public voidaccept(com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor msgDestRef)
visits an message destination reference for the last J2EE component visited

param
the message destination reference

    
public voidaccept(com.sun.enterprise.deployment.MessageDestinationDescriptor msgDest)
visits an message destination for the last J2EE component visited

param
the message destination

    
public voidaccept(com.sun.enterprise.deployment.ApplicationClientDescriptor appclientdescriptor)
visits a appclient descriptor

param
appclientdescriptor

       bundleDescriptor = appclientdescriptor;
    
public voidaccept(com.sun.enterprise.deployment.Application application)
visit an application object

param
the application descriptor

    
public voidaccept(com.sun.enterprise.deployment.FieldDescriptor fd)
visits a CMP field definition (for CMP entity beans)

param
field descriptor for the CMP field

    
public voidaccept(com.sun.enterprise.deployment.MethodDescriptor method, com.sun.enterprise.deployment.QueryDescriptor qd)
visits a query method

param
method descriptor for the method
param
query descriptor

    
public voidaccept(com.sun.enterprise.deployment.RelationshipDescriptor descriptor)
visits an ejb relationship descriptor

param
the relationship descriptor

    
public voidaccept(com.sun.enterprise.deployment.Descriptor descriptor)
visits a J2EE descriptor

param
the descriptor

    
public voidaccept(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
visit a web bundle descriptor

param
the web bundle descriptor

        this.bundleDescriptor = descriptor;
    
public voidaccept(com.sun.enterprise.deployment.EjbBundleDescriptor bundleDescriptor)
visits an ejb bundle descriptor

param
an ejb bundle descriptor

        this.bundleDescriptor = bundleDescriptor;
    
public voidaccept(com.sun.enterprise.deployment.WebComponentDescriptor descriptor)
visit a web component descriptor

param
the web component

    
public voidaccept(com.sun.enterprise.deployment.EjbDescriptor ejb)
visits an ejb descriptor

param
ejb descriptor

    
public voidaccept(com.sun.enterprise.deployment.ConnectorDescriptor conDesc)
visits a connector descriptor

param
connectordescriptor

    
public voidaccept(com.sun.enterprise.deployment.InjectionCapable injectable)

    
public voidaccept(com.sun.enterprise.deployment.types.EjbReference ejbRef)
visits an ejb reference for the last J2EE component visited

param
the ejb reference

    
public voidaccept(com.sun.enterprise.deployment.types.MessageDestinationReferencer msgDestReferencer)

    
public voidaccept(com.sun.enterprise.deployment.ServiceReferenceDescriptor serviceRef)
visits a web service reference descriptor

param
serviceRef

    
protected voidacceptWithCL(com.sun.enterprise.deployment.InjectionCapable injectable)

        // If parsed from deployment descriptor, we need to determine whether
        // the inject target name refers to an injection field or an
        // injection method for each injection target
        for (InjectionTarget target : injectable.getInjectionTargets()) {
            if( (target.getFieldName() == null) &&
                    (target.getMethodName() == null) ) {

                String injectTargetName = target.getTargetName();
                String targetClassName  = target.getClassName();
                ClassLoader classLoader = getBundleDescriptor().getClassLoader();

                Class targetClazz = null;

                try {

                    targetClazz = classLoader.loadClass(targetClassName);

                } catch(ClassNotFoundException cnfe) {
                    // @@@
                    // Don't treat this as a fatal error for now.  One known issue
                    // is that all .xml, even web.xml, is processed within the
                    // appclient container during startup.  In that case, there
                    // are issues with finding .classes in .wars due to the
                    // structure of the returned client .jar and the way the
                    // classloader is formed.
                    DOLUtils.getDefaultLogger().fine
                            ("Injection class " + targetClassName + " not found for " +
                            injectable);
                    return;
                }

                // Spec requires that we attempt to match on method before field.
                boolean matched = false;

                // The only information we have is method name, so iterate
                // through the methods find a match.  There is no overloading
                // allowed for injection methods, so any match is considered
                // the only possible match.

                String setterMethodName = TypeUtil.
                        propertyNameToSetterMethod(injectTargetName);

                // method can have any access type so use getDeclaredMethods()
                for(Method next : targetClazz.getDeclaredMethods()) {
                    // only when the method name matches and the method
                    // has exactly one parameter, we find a match
                    if( next.getName().equals(setterMethodName) && 
                        next.getParameterTypes().length == 1) {
                        target.setMethodName(next.getName());
                        if( injectable.getInjectResourceType() == null ) {
                            Class[] paramTypes = next.getParameterTypes();
                            if (paramTypes.length == 1) {
                                String resourceType = paramTypes[0].getName();
                                injectable.setInjectResourceType(resourceType);
                            }
                        }
                        matched = true;
                        break;
                    }
                }

               if( !matched ) {

                    // In the case of injection fields, inject target name ==
                    // field name.  Field can have any access type.
                    try {
                        Field f = targetClazz.getDeclaredField(injectTargetName);
                        target.setFieldName(injectTargetName);
                        if( injectable.getInjectResourceType() == null ) {
                            String resourceType = f.getType().getName();
                            injectable.setInjectResourceType(resourceType);
                        }
                        matched = true;
                    } catch(NoSuchFieldException nsfe) {
                        String msg = "No matching injection setter method or " +
                                "injection field found for injection property " +
                                injectTargetName + " on class " + targetClassName +
                                " for component dependency " + injectable;

                        throw new RuntimeException(msg, nsfe);
                    }
                }
            }
        }
    
protected voidacceptWithoutCL(com.sun.enterprise.deployment.InjectionCapable injectable)

    
public AppClientVisitorgetAppClientVisitor()

return
a AppClientVisitor (if app client should be visited)

        return this;
    
protected com.sun.enterprise.deployment.BundleDescriptorgetBundleDescriptor()

return
the bundleDescriptor we are visiting

        return bundleDescriptor;
    
public ConnectorVisitorgetConnectorVisitor()

return
a ConnectorVisitor (if connector should be visited)

        return this;
    
public EjbBundleVisitorgetEjbBundleVisitor()

return
an implementation of the ejbBundleVisitor (if any) to visit ejb bundle descriptors

        return this;
    
public EjbVisitorgetEjbVisitor()

return
a EjbVisitor (if ejbs should be visited)

        return this;
    
public WebBundleVisitorgetWebBundleVisitor()

return
an implementation of the ejbBundleVisitor (if any) to visit ejb bundle descriptors

        return this;