package org.jfox.ejb.meta;

import org.w3c.dom.Node;

/**
 * @author <a href="mailto:yangyong@ufsoft.com.cn">Young Yang</a>
 */

public class EJBReferenceDescriptor extends EJBDescriptorBase {
  private String type;
  private String refName;

  public EJBReferenceDescriptor() {
  }

  public void processXML(Node node) throws EJBDescriptionException {
    super.processXML(node);
    setRefName(XmlUtil.getChildNodeValueOf(node,"ejb-ref-name"));
    setType(XmlUtil.getChildNodeValueOf(node,"ejb-ref-type"));
    setHomeClassName(XmlUtil.getChildNodeValueOf(node,"home"));
    setRemoteClassName(XmlUtil.getChildNodeValueOf(node,"remote"));
    setEjbName(XmlUtil.getChildNodeValueOf(node,"ejb-link"));
  }

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }

  public String getRefName() {
    return refName;
  }

  public void setRefName(String refName) {
    this.refName = refName;
  }

  public boolean isResolved(){
    return !getJndiName().equals("");
  }

  public boolean equals(Object obj) {
    if (obj instanceof EJBReferenceDescriptor)
      return refName.equals(((EJBReferenceDescriptor) obj).refName);
    else
      return false;
  }

  public int hashCode() {
    return refName.hashCode();
  }

  public static void main(String[] args) {

  }
}