Fields Summary |
---|
protected static final String | CUSTOM_RESOURCE |
protected static final String | JDBC_CONNECTION_POOL |
protected static final String | CONNECTOR_RESOURCE |
protected static final String | ADMIN_OBJECT_RESOURCE |
protected static final String | JDBC_RESOURCE |
protected static final String | RESOURCE_ADAPTER_CONFIG |
protected static final String | MAIL_RESOURCE |
protected static final String | EXTERNAL_JNDI_RESOURCE |
protected static final String | CONNECTOR_CONNECTION_POOL |
protected static final String | PERSISTENCE_MANAGER_FACTORY_RESOURCE |
protected static final String | CONNECTOR_SECURITY_MAP |
private String | resType |
private AttributeList | attrList |
private Properties | props |
private String | sDescription |
Methods Summary |
---|
public boolean | equals(java.lang.Object obj)
if (this == obj) return true;
if ( !(obj instanceof Resource) ) return false;
Resource r = (Resource)obj;
return r.getType().equals(this.getType()) &&
//No need to compare description for equality
//r.getDescription().equals(this.getDescription()) &&
r.getProperties().equals(this.getProperties()) &&
r.getAttributes().equals(this.getAttributes());
|
private javax.management.Attribute | getAttribute(com.sun.enterprise.resource.Resource r, java.lang.String name)Utility method to get an Attribute of the given name
in the specified resource
for (Iterator<Attribute> iter = r.getAttributes().iterator(); iter.hasNext();) {
Attribute elt = iter.next();
if (elt.getName().equals(name)) return elt;
}
return null;
|
public javax.management.AttributeList | getAttributes()
return attrList;
|
public java.lang.String | getDescription()
return sDescription;
|
public java.util.Properties | getProperties()
return props;
|
public java.lang.String | getType()
return resType;
|
private boolean | hasSameIdentity(com.sun.enterprise.resource.Resource r)Checks if the specified resource has the same identity as
this resource.
//For two resources to have the same identity, atleast their types should match
if (r.getType() != this.getType()) {
return false;
}
String rType = r.getType();
//For all resources, their identity is their jndi-name
if (rType.equals(CUSTOM_RESOURCE)|| rType.equals(EXTERNAL_JNDI_RESOURCE)
|| rType.equals(JDBC_RESOURCE)|| rType.equals(PERSISTENCE_MANAGER_FACTORY_RESOURCE)
|| rType.equals(CONNECTOR_RESOURCE)|| rType.equals(ADMIN_OBJECT_RESOURCE) || rType.equals(MAIL_RESOURCE)) {
return isEqualAttribute(r, JNDI_NAME);
}
//For pools the identity is limited to pool name
if (rType.equals(JDBC_CONNECTION_POOL) || rType.equals(CONNECTOR_CONNECTION_POOL)) {
return isEqualAttribute(r, CONNECTION_POOL_NAME);
}
if (rType.equals(RESOURCE_ADAPTER_CONFIG)) {
return isEqualAttribute(r, RES_ADAPTER_CONFIG);
}
return false;
|
public int | hashCode()
return this.getAttributes().hashCode() +
this.getProperties().hashCode() +
this.getType().hashCode();
//description is not used to generate hashcode
//this.getDescription().hashCode();
|
public boolean | isAConflict(com.sun.enterprise.resource.Resource r)
//If the two resource have the same identity
if (hasSameIdentity(r)) {
//If the two resources are not equal, then there is no
//conflict
if (!r.equals(this))
return true;
}
return false;
|
private boolean | isEqualAttribute(com.sun.enterprise.resource.Resource r, java.lang.String name)Compares the attribute with the specified name
in this resource with the passed in resource and checks
if they are equal
return (getAttribute(r, name).equals(getAttribute(this, name)));
|
public void | setAttribute(java.lang.String name, java.lang.String value)
attrList.add(new Attribute(name, value));
|
public void | setAttribute(java.lang.String name, java.lang.String[] value)
attrList.add(new Attribute(name, value));
|
public void | setDescription(java.lang.String sDescription)
this.sDescription = sDescription;
|
public void | setProperty(java.lang.String name, java.lang.String value)
props.setProperty(name, value);
|
public java.lang.String | toString()
String rType = getType();
String identity = "";
if (rType.equals(CUSTOM_RESOURCE)|| rType.equals(EXTERNAL_JNDI_RESOURCE)
|| rType.equals(JDBC_RESOURCE)|| rType.equals(PERSISTENCE_MANAGER_FACTORY_RESOURCE)
|| rType.equals(CONNECTOR_RESOURCE)|| rType.equals(ADMIN_OBJECT_RESOURCE) || rType.equals(MAIL_RESOURCE)) {
identity = (String) getAttribute(this, JNDI_NAME).getValue();
}else if (rType.equals(JDBC_CONNECTION_POOL) || rType.equals(CONNECTOR_CONNECTION_POOL)) {
identity = (String) getAttribute(this, CONNECTION_POOL_NAME).getValue();
}else if (rType.equals(RESOURCE_ADAPTER_CONFIG)) {
identity = (String) getAttribute(this, RES_ADAPTER_CONFIG).getValue();
}
return identity + " of type " + resType;
|