package org.jfox.ejb.meta;
import org.w3c.dom.Node;
public class ResourceRefDescriptor extends Descriptor {
public static final String APPLICATION_AUTHORIZATION = "Application";
public static final String CONTAINER_AUTHORIZATION = "Container";
private String refName;
private String type;
private String auth;
private String jndiName;
public ResourceRefDescriptor() {
}
public void processXML(Node node) throws EJBDescriptionException {
super.processXML(node);
setRefName(XmlUtil.getChildNodeValueOf(node,"res-ref-name"));
setType(XmlUtil.getChildNodeValueOf(node,"res-type"));
setAuthorization(XmlUtil.getChildNodeValueOf(node,"res-auth"));
}
public boolean equals(Object obj) {
if (obj instanceof ResourceRefDescriptor)
return refName.equals(((ResourceRefDescriptor) obj).refName);
else
return false;
}
public String getAuthorization() {
return auth;
}
public String getJndiName() {
if (jndiName == null)
jndiName = "";
return jndiName;
}
public String getRefName() {
return refName;
}
public String getType() {
return type;
}
public int hashCode() {
return refName.hashCode();
}
public boolean isResolved() {
return jndiName != null && !"".equals(jndiName);
}
public void setAuthorization(String s) {
if (!"Application".equals(s) && !"Container".equals(s)) {
throw new IllegalArgumentException("res-auth must be one of \"Application\" and \"Container\"");
}
else {
auth = s;
return;
}
}
public void setJndiName(String s) {
jndiName = s;
}
public void setRefName(String s) {
refName = s;
}
public void setType(String s) {
type = s;
}
public String toString() {
return "res-ref-name: " + getRefName() + "\n" + "res-type: " + getType() + "\n" + "jndi-name: " + getJndiName() + "\n";
}
public static void main(String[] args) {
}
}