FileDocCategorySizeDatePackage
ResourceReferenceDescriptor.javaAPI DocGlassfish v2 API15973Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment

ResourceReferenceDescriptor

public class ResourceReferenceDescriptor extends EnvironmentProperty implements NamedDescriptor, com.sun.enterprise.deployment.web.ResourceReference
This descriptor represents a dependency on a resource.
author
Danny Coward

Fields Summary
public static final String
APPLICATION_AUTHORIZATION
For database resources, this says the application will log in.
public static final String
CONTAINER_AUTHORIZATION
For database resources this says the container will log in.
public static final String
RESOURCE_SHAREABLE
public static final String
RESOURCE_UNSHAREABLE
private static final String
URL_RESOURCE_TYPE
private static final String
CONNECTOR_RESOURCE_TYPE
private static final String
MAIL_RESOURCE_TYPE
private static final String
JDBC_RESOURCE_TYPE
private static final String
ORB_RESOURCE_TYPE
private static final String
WEBSERVICE_CONTEXT_TYPE
private String
rType
private com.sun.enterprise.deployment.ResourcePrincipal
resourcePrincipal
private MailConfiguration
mailConfiguration
private String
authorization
private DataSource
dataSource
private String
sharingScope
private List
runtimeProps
boolean
createTablesAtDeploy
boolean
dropTablesAtUndeploy
String
databaseVendorName
Properties
schemaGeneratorProperties
private static final com.sun.enterprise.util.LocalStringManagerImpl
localStrings
static final Logger
_logger
Constructors Summary
public ResourceReferenceDescriptor(String name, String description, String type)
Construct a resource reference with the given name, description and type.

param
the name of the reference
param
the description
param
the type of the resource reference.

    // END OF IASRI 4718559    
    
                                     
         
					  
	super(name, "", description);
	rType = type;
        this.sharingScope = RESOURCE_SHAREABLE;
    
public ResourceReferenceDescriptor()
Default constructor.

        this.sharingScope = RESOURCE_SHAREABLE;
    
Methods Summary
public voidaddProperty(NameValuePairDescriptor newProp)
Add a new runtime property to this cmp resource

	 if (runtimeProps==null) {
	     runtimeProps = new ArrayList();
	 }
	 runtimeProps.add(newProp);
     
public voidcheckType()
checks the given class type. throws an IllegalArgumentException if bounds checking if the class of type "type" does not exist

	if (rType != null) {
	    Class typeClass = null;
	    // is it loadable ?
	    try {
	        // Bug fix 4850684: for resource-refs that are user-defined classes,
	        // the classloader used to load them cannot be the one associated 
	        // with the application deployed, since the classloader instance
	        // would have no idea about classes not included in app
	        // for e.g connector module with res-ref that points to the
	        // ConnectionFactory class of a resource adapter
	      
	        typeClass = Class.forName(rType, true,
					  Thread.currentThread().getContextClassLoader());
		
	    } catch (Throwable t) {
	        if (this.isBoundsChecking()) {
		    throw new IllegalArgumentException(localStrings.getLocalString(
		  "enterprise.deployment.exceptiontypenotallowedpropertytype", 
                  "{0} is not an allowed property value type", 
                  new Object[] {rType}));
		} else {
		    return;
		}
	    }
        }
    
public booleanequals(java.lang.Object object)
Equality on name.

	if (object instanceof ResourceReference) {
	    ResourceReference resourceReference = (ResourceReference) object;
	    return resourceReference.getName().equals(this.getName());
	}
	return false;
    
public java.lang.StringgetAuthorization()
Return the authorization type of this resource. The default value is APPLICATION_AUTHORIZATION

return
the authorization type of the resource.

	if (this.authorization == null) {
	    this.authorization = APPLICATION_AUTHORIZATION;
	}
	return this.authorization;
    
public java.lang.StringgetDatabaseVendorName()

return
the database vendor name

        return databaseVendorName;
    
public java.lang.StringgetInjectResourceType()

        return rType;
    
public javax.sql.DataSourcegetJDBCDataSource()
Lookup the datasource from the namespace based on the JNDI name.

return
the data source

	if ( dataSource == null ) {
	    try {
		// Get JDBC DataSource for database 
		javax.naming.Context ctx = new javax.naming.InitialContext();
		// cache the datasource to avoid JNDI lookup overheads
		dataSource = (DataSource)ctx.lookup(getJndiName());
	    } catch ( Exception ex ) { }
	}
	return dataSource;
    
public java.lang.StringgetJndiName()
Return the JNDI name of this resource reference.

return
the JNDI name of the resource reference.

    

                         
       
        String jndiName = super.getValue();
        return (jndiName != null  && ! jndiName.equals("")) ? 
            jndiName : getMappedName();
    
public MailConfigurationgetMailConfiguration()
Return the mail configuration details of thsi resource or null.

return
the mail configuration object.

	return this.mailConfiguration;
    
public java.util.IteratorgetProperties()

return
the runtime properties for this cmp resource

	 if (runtimeProps==null) {
	     return null;
	 }
	 return runtimeProps.iterator();
     
public com.sun.enterprise.deployment.ResourcePrincipalgetResourcePrincipal()
Return the identity used to authorize this resource.

return
the principal.

	return this.resourcePrincipal;
    
public java.util.PropertiesgetSchemaGeneratorProperties()

return
the override properties for the schema generation

        return schemaGeneratorProperties;
    
public java.lang.StringgetSharingScope()
Return the res-sharing-scope of this resource reference.

return
the sharing scope.

	if ( sharingScope == null ) {
	    return "";
	}
	return sharingScope;
    
public java.lang.StringgetType()
Return the type of the resource.

return
the type of the resource.

	return rType;
    
public booleanisContainerAuthorization()
Return true of this resource reference is expecting the container to authorize the resource.

return
true if authorization is container managed.

	return this.getAuthorization().equals(CONTAINER_AUTHORIZATION);
    
public booleanisCreateTablesAtDeploy()

return
true if automatic creation of tables for the CMP Beans is done at deployment time

        return createTablesAtDeploy;
    
public booleanisDropTablesAtUndeploy()

return
true if automatic creation of tables for the CMP Beans is done at deployment time

        return dropTablesAtUndeploy;
    
public booleanisJDBCResource()

return
true if the resource is a jdbc DataSource object.

        return this.getType().equals(JDBC_RESOURCE_TYPE);
    
public booleanisJMSConnectionFactory()
Return true if this resource is a JMS connection factory.

return
true if the resource is a JMS connection factory, false otherwise.

        String myType = this.getType();
        return 
            ( myType.equals("javax.jms.QueueConnectionFactory") ||
              myType.equals("javax.jms.TopicConnectionFactory") );
    
public booleanisMailResource()
Return true if this resource is to a JavaMail session object.

return
true if the resource is a JavaMail session object.

        //START OF IASRI 4650786
//	return (this.getMailConfiguration() != null);
        return this.getType().equals(MAIL_RESOURCE_TYPE);
        //END OF IASRI 4650786
    
public booleanisORB()

    	return this.getType().equals(ORB_RESOURCE_TYPE);
    
public booleanisResolved()
Does this resource references have a JNDI name.

return
true if the resource reference has a JNDI name, false otherwise

	return true;
    
public booleanisResourceConnectionFactory()
Return true if this resource is a CCI connection factory.

return
true if the resource is a CCI connection factory, false otherwise.

        return this.getType().equals(CONNECTOR_RESOURCE_TYPE);
    
public booleanisURLResource()
Return true if this resource is a URL object.

return
true if the resource is a URL object, false otherwise.

        return this.getType().equals(URL_RESOURCE_TYPE);
    
public booleanisWebServiceContext()

        return this.getType().equals(WEBSERVICE_CONTEXT_TYPE);
    
public voidprint(java.lang.StringBuffer toStringBuffer)
Returns a formatted string representing my state.

        StringBuffer sb = toStringBuffer;
        sb.append("Res-Ref-Env-Property: ");
        sb.append(super.getName());
        sb.append("@");
        sb.append(getType());
        sb.append("@");
        sb.append(getDescription());
	if (this.isResolved()) {
	    sb.append(" resolved as: jndi: ");
            sb.append(getJndiName());
            sb.append("@res principal: ");
            sb.append(getResourcePrincipal());
            sb.append("@mail: ");
            sb.append(getMailConfiguration());
	}
        if (runtimeProps!=null) {
            for (Iterator itr = runtimeProps.iterator();itr.hasNext();) {
                sb.append("\nPropery : ");
                sb.append(itr.next());
            }
        } else {
            sb.append("\nNo Runtime properties");
        }
        sb.append("\nDatabase Vendor : " + databaseVendorName);
        sb.append("\nCreate Tables at Deploy : " + createTablesAtDeploy);
        sb.append("\nDelete Tables at Undeploy : " + dropTablesAtUndeploy);
        
        if (schemaGeneratorProperties!=null) {
            sb.append("\nSchema Generator Properties : ");
            sb.append(schemaGeneratorProperties);
        }
                
    
public voidsetAuthorization(java.lang.String authorization)
Sets the authorization type of this resource.

param
the authorization type.

	this.authorization = authorization;
    
public voidsetCreateTablesAtDeploy(boolean createTablesAtDeploy)
Sets whether if automatic creation of tables for the CMP Beans is done at deployment time

        this.createTablesAtDeploy = createTablesAtDeploy;
    
public voidsetDatabaseVendorName(java.lang.String vendorName)
Sets the database vendor name

        this.databaseVendorName = vendorName;
    
public voidsetDropTablesAtUndeploy(boolean dropTablesAtUndeploy)
Sets whether if automatic creation of tables for the CMP Beans is done at deployment time

        this.dropTablesAtUndeploy = dropTablesAtUndeploy;
    
public voidsetInjectResourceType(java.lang.String resourceType)

        rType = resourceType;
    
public voidsetJndiName(java.lang.String jndiName)
Set the JNDI name of this resource reference.

param
the JNDI name of the resource reference.

	super.setValue(jndiName);
    
public voidsetMailConfiguration(MailConfiguration mailConfiguration)
Sets the mail configuration information for this reference.

param
the mail configuration object.

	this.mailConfiguration = mailConfiguration;
    
public voidsetResourcePrincipal(com.sun.enterprise.deployment.ResourcePrincipal resourcePrincipal)
Sets the identity used to authorize this resource.

param
the principal.

	this.resourcePrincipal = resourcePrincipal;
    
public voidsetSchemaGeneratorProperties(java.util.Properties props)
Sets the override properties for the schema generation

        schemaGeneratorProperties = props;
    
public voidsetSharingScope(java.lang.String ss)
Set the res-sharing-scope of this resource reference.

param
the sharing scope.

	sharingScope = ss;
    
public voidsetType(java.lang.String type)
Sets the type of this resource.

param
the type of the resource.

	rType = type;