1 23 package com.sun.enterprise.deployment; 24 25 28 29 public class NamedReferencePair { 30 31 public static final int EJB = 1; 33 public static final int EJB_REF = 2; 34 public static final int RESOURCE_REF = 3; 35 public static final int RESOURCE_ENV_REF = 4; 36 37 private Descriptor referant; 38 private NamedDescriptor referee; 39 private int type; 40 41 public static NamedReferencePair createEjbPair 42 (EjbDescriptor referant, EjbDescriptor referee) 43 { 44 return new NamedReferencePair(referant, referee, EJB); 45 } 46 47 public static NamedReferencePair createEjbRefPair 48 (Descriptor referant, EjbReferenceDescriptor referee) 49 { 50 return new NamedReferencePair(referant, referee, EJB_REF); 51 } 52 53 public static NamedReferencePair createResourceRefPair 54 (Descriptor referant, ResourceReferenceDescriptor referee) 55 { 56 return new NamedReferencePair(referant, referee, RESOURCE_REF); 57 } 58 59 public static NamedReferencePair createResourceEnvRefPair 60 (Descriptor referant, JmsDestinationReferenceDescriptor referee) 61 { 62 return new NamedReferencePair(referant, referee, RESOURCE_ENV_REF); 63 } 64 65 67 protected NamedReferencePair(Descriptor referant, NamedDescriptor referee, 68 int type) { 69 this.referant = referant; 70 this.referee = referee; 71 this.type = type; 72 } 73 74 75 public Descriptor getReferant() { 76 return this.referant; 77 } 78 79 80 public NamedDescriptor getReferee() { 81 return this.referee; 82 } 83 84 public String getPairTypeName() { 85 switch(this.type) { 86 case EJB : return "EJB"; 87 case EJB_REF : return "EJB REF"; 88 case RESOURCE_REF : return "RESOURCE REF"; 89 case RESOURCE_ENV_REF : return "RESOURCE ENV REF"; 90 } 91 throw new IllegalStateException ("unknown type = " + type); 92 } 93 94 public int getPairType() { 95 return this.type; 96 } 97 98 99 public void print(StringBuffer toStringBuffer) { 100 toStringBuffer.append("NRP: ").append(referant.getName()).append(" -> ").append(((Descriptor) referee).getName()); 101 } 102 103 } 104 | Popular Tags |