FileDocCategorySizeDatePackage
DescriptorFactory.javaAPI DocGlassfish v2 API18092Fri May 04 22:31:38 BST 2007com.sun.enterprise.deployment.node

DescriptorFactory

public class DescriptorFactory extends Object
This class is responsible for instanciating Descriptor classes
author
Jerome Dochez
version

Fields Summary
static Map
descriptorClasses
Constructors Summary
protected DescriptorFactory()
This is a factory object no need for DescriptorFactory instance

    
Methods Summary
public static java.lang.ObjectgetDescriptor(java.lang.String xmlPath)

return
a new instance of a registered descriptor class for the supplied XPath

        
        
        try {
            Class c = getDescriptorClass(xmlPath);
	    if (c!=null) {
                return c.newInstance();
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
        return null;
    
public static java.lang.ClassgetDescriptorClass(java.lang.String xmlPath)

return
the descriptor tag for a particular XPath

        String s = xmlPath;        
        do {
            if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) {            
                DOLUtils.getDefaultLogger().finer("looking for " + xmlPath);
            }
            if (descriptorClasses.containsKey(xmlPath)) {
                return (Class) descriptorClasses.get(xmlPath);            
            }
            if (xmlPath.indexOf('/")!=-1) {
                xmlPath = xmlPath.substring(xmlPath.indexOf('/")+1);
            } else {
                xmlPath=null;
            }            
        } while (xmlPath!=null);
	if(DOLUtils.getDefaultLogger().isLoggable(Level.SEVERE)) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                new Object[] {"No descriptor registered for " + s});
	}
        return null;
    
private static voidinitMapping()

        descriptorClasses = new HashMap();
	
        // common
        register(new XMLElement(TagNames.DEPLOYMENT_EXTENSION), DeploymentExtensionDescriptor.class);
        register(new XMLElement(TagNames.MESSAGE_DESTINATION), MessageDestinationDescriptor.class);
        register(new XMLElement(TagNames.INJECTION_TARGET), InjectionTarget.class);
        
        // Application
        register(new XMLElement(ApplicationTagNames.APPLICATION), Application.class);
        register(new XMLElement(ApplicationTagNames.MODULE), ModuleDescriptor.class);
        
	//EJB
        register(new XMLElement(EjbTagNames.EJB_BUNDLE_TAG), EjbBundleDescriptor.class);
        register(new XMLElement(WebTagNames.WEB_BUNDLE), WebBundleDescriptor.class);
        register(new XMLElement(EjbTagNames.SESSION), EjbSessionDescriptor.class);       
        register(new XMLElement(EjbTagNames.ENTITY), EjbEntityDescriptor.class);     
        register(new XMLElement(EjbTagNames.MESSAGE_DRIVEN), EjbMessageBeanDescriptor.class);        
        register(new XMLElement(EjbTagNames.ACTIVATION_CONFIG), 
                 ActivationConfigDescriptor.class);        
        register(new XMLElement(TagNames.EJB_REFERENCE), EjbReferenceDescriptor.class);       
        register(new XMLElement(TagNames.EJB_LOCAL_REFERENCE), EjbReferenceDescriptor.class);                
        register(new XMLElement(TagNames.ROLE), SecurityRoleDescriptor.class);
        register(new XMLElement(EjbTagNames.EXCLUDE_LIST), MethodPermissionDescriptor.class);        
        register(new XMLElement(EjbTagNames.RESOURCE_REFERENCE), ResourceReferenceDescriptor.class);
        register(new XMLElement(EjbTagNames.CMP_FIELD), FieldDescriptor.class);
        register(new XMLElement(EjbTagNames.METHOD), MethodDescriptor.class);          
        register(new XMLElement(EjbTagNames.METHOD_PERMISSION), MethodPermissionDescriptor.class);
        register(new XMLElement(EjbTagNames.RUNAS_SPECIFIED_IDENTITY), RunAsIdentityDescriptor.class);
        register(new XMLElement(TagNames.ENVIRONMENT_PROPERTY), EnvironmentProperty.class);
        register(new XMLElement(EjbTagNames.ROLE_REFERENCE), RoleReference.class);
        register(new XMLElement(EjbTagNames.QUERY), QueryDescriptor.class);
        register(new XMLElement(EjbTagNames.QUERY_METHOD), MethodDescriptor.class);    
        register(new XMLElement(RuntimeTagNames.JAVA_METHOD), MethodDescriptor.class);
        register(new XMLElement(TagNames.RESOURCE_ENV_REFERENCE), JmsDestinationReferenceDescriptor.class);
        register(new XMLElement(TagNames.MESSAGE_DESTINATION_REFERENCE), MessageDestinationReferenceDescriptor.class);
        register(new XMLElement(EjbTagNames.EJB_RELATION), RelationshipDescriptor.class);
        register(new XMLElement(EjbTagNames.EJB_RELATIONSHIP_ROLE), RelationRoleDescriptor.class);
        register(new XMLElement(EjbTagNames.AROUND_INVOKE_METHOD), LifecycleCallbackDescriptor.class);
       register(new XMLElement(TagNames.POST_CONSTRUCT), LifecycleCallbackDescriptor.class);
       register(new XMLElement(TagNames.PRE_DESTROY), LifecycleCallbackDescriptor.class);
       register(new XMLElement(EjbTagNames.POST_ACTIVATE_METHOD), LifecycleCallbackDescriptor.class);
       register(new XMLElement(EjbTagNames.PRE_PASSIVATE_METHOD), LifecycleCallbackDescriptor.class);
       register(new XMLElement(EjbTagNames.TIMEOUT_METHOD), MethodDescriptor.class);
       register(new XMLElement(EjbTagNames.INIT_BEAN_METHOD), MethodDescriptor.class);
       register(new XMLElement(EjbTagNames.INIT_CREATE_METHOD), MethodDescriptor.class);
       register(new XMLElement(EjbTagNames.INIT_METHOD), EjbInitInfo.class);
       register(new XMLElement(EjbTagNames.REMOVE_METHOD), EjbRemovalInfo.class);
       register(new XMLElement(EjbTagNames.INTERCEPTOR), EjbInterceptor.class);
       register(new XMLElement(EjbTagNames.INTERCEPTOR_BINDING), 
                InterceptorBindingDescriptor.class);
       register(new XMLElement(EjbTagNames.APPLICATION_EXCEPTION), 
                EjbApplicationExceptionInfo.class);

	//connector
	register(new XMLElement(ConnectorTagNames.CONNECTOR), ConnectorDescriptor.class);
	register(new XMLElement(ConnectorTagNames.OUTBOUND_RESOURCE_ADAPTER), OutboundResourceAdapter.class);  
	register(new XMLElement(ConnectorTagNames.INBOUND_RESOURCE_ADAPTER), InboundResourceAdapter.class);
	register(new XMLElement(ConnectorTagNames.RESOURCE_ADAPTER), OutboundResourceAdapter.class);
	register(new XMLElement(ConnectorTagNames.AUTH_MECHANISM), AuthMechanism.class);
	register(new XMLElement(ConnectorTagNames.SECURITY_PERMISSION), SecurityPermission.class);
	register(new XMLElement(ConnectorTagNames.LICENSE), LicenseDescriptor.class);
	register(new XMLElement(ConnectorTagNames.CONFIG_PROPERTY), EnvironmentProperty.class);
	register(new XMLElement(ConnectorTagNames.REQUIRED_CONFIG_PROP), EnvironmentProperty.class);
	register(new XMLElement(ConnectorTagNames.MSG_LISTENER), MessageListener.class);
	register(new XMLElement(ConnectorTagNames.ACTIVATION_SPEC),MessageListener.class);
	register(new XMLElement(ConnectorTagNames.ADMIN_OBJECT), AdminObject.class);
	register(new XMLElement(ConnectorTagNames.CONNECTION_DEFINITION), ConnectionDefDescriptor.class);

	//appclient
	register(new XMLElement(ApplicationClientTagNames.APPLICATION_CLIENT_TAG), ApplicationClientDescriptor.class);

	//web stuff
        register(new XMLElement(WebTagNames.WEB_BUNDLE), WebBundleDescriptor.class);
        register(new XMLElement(WebTagNames.SERVLET), WebComponentDescriptor.class);
        register(new XMLElement(WebTagNames.INIT_PARAM), EnvironmentProperty.class);        
        register(new XMLElement(WebTagNames.MIME_MAPPING), MimeMappingDescriptor.class);
        register(new XMLElement(WebTagNames.CONTEXT_PARAM), EnvironmentProperty.class);                
        register(new XMLElement(WebTagNames.SECURITY_CONSTRAINT), SecurityConstraintImpl.class);
        register(new XMLElement(WebTagNames.USERDATA_CONSTRAINT), UserDataConstraintImpl.class);     
        register(new XMLElement(WebTagNames.AUTH_CONSTRAINT), AuthorizationConstraintImpl.class);
        register(new XMLElement(WebTagNames.WEB_RESOURCE_COLLECTION), WebResourceCollectionImpl.class);
        register(new XMLElement(WebTagNames.LISTENER), AppListenerDescriptorImpl.class);    
        register(new XMLElement(WebTagNames.FILTER), ServletFilterDescriptor.class);            
        register(new XMLElement(WebTagNames.FILTER_MAPPING), ServletFilterMappingDescriptor.class);    
        register(new XMLElement(WebTagNames.ERROR_PAGE), ErrorPageDescriptorImpl.class);            
        register(new XMLElement(WebTagNames.LOGIN_CONFIG), LoginConfigurationImpl.class);
        register(new XMLElement(WebTagNames.TAGLIB), TagLibConfigurationDescriptor.class);            
        register(new XMLElement(WebTagNames.JSPCONFIG), JspConfigDescriptor.class);            
        register(new XMLElement(WebTagNames.JSP_GROUP), JspGroupDescriptor.class);            
        register(new XMLElement(WebTagNames.LOCALE_ENCODING_MAPPING_LIST), LocaleEncodingMappingListDescriptor.class);            
        register(new XMLElement(WebTagNames.LOCALE_ENCODING_MAPPING), LocaleEncodingMappingDescriptor.class);                         

        // JSR 109 integration
        register(new XMLElement(WebServicesTagNames.SERVICE_REF), ServiceReferenceDescriptor.class);
        register(new XMLElement(WebServicesTagNames.WEB_SERVICE), WebService.class);
        register(new XMLElement(WebServicesTagNames.PORT_COMPONENT), com.sun.enterprise.deployment.WebServiceEndpoint.class);
        register(new XMLElement(WebServicesTagNames.HANDLER), 
                 com.sun.enterprise.deployment.WebServiceHandler.class);
        register(new XMLElement(WebServicesTagNames.HANDLER_CHAIN), 
                 com.sun.enterprise.deployment.WebServiceHandlerChain.class);
        register(new XMLElement(WebServicesTagNames.PORT_INFO),
               com.sun.enterprise.deployment.ServiceRefPortInfo.class);
        register(new XMLElement(WebServicesTagNames.STUB_PROPERTY),
                 NameValuePairDescriptor.class);
        register(new XMLElement(WebServicesTagNames.CALL_PROPERTY),
                 NameValuePairDescriptor.class);
		 
        // persistence.xsd related entries (JSR 220)
        // Note we do not register PersistenceUnitsDescriptor, because that
        // is created by PersistenceDeploymentDescriptorFile.getRootXMLNode().
        register(new XMLElement(PersistenceTagNames.PERSISTENCE_UNIT),
                 PersistenceUnitDescriptor.class);
        register(new XMLElement(TagNames.PERSISTENCE_CONTEXT_REF),
                 EntityManagerReferenceDescriptor.class);
        register(new XMLElement(TagNames.PERSISTENCE_UNIT_REF),
                 EntityManagerFactoryReferenceDescriptor.class);
    
public static voidregister(XMLElement xmlPath, java.lang.Class clazz)
register a new descriptor class handling a particular XPATH in the DTD.

param
xmlPath absolute or relative XPath
param
clazz the descriptor class to use

        if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {        
            DOLUtils.getDefaultLogger().fine("Register " + clazz + " to handle " + xmlPath.getQName());
        }
	descriptorClasses.put(xmlPath.getQName(), clazz);