1 23 24 package com.sun.enterprise.deployment; 25 26 import java.util.*; 27 import java.lang.reflect.*; 28 import com.sun.enterprise.util.LocalStringManagerImpl; 29 import java.util.logging.*; 30 import com.sun.logging.*; 31 import com.sun.enterprise.deployment.util.LogDomains; 32 33 42 43 public class EjbEntityDescriptor extends EjbDescriptor { 44 45 public static String TYPE = "Entity"; 46 public static String BEAN_PERSISTENCE = "Bean"; 47 public static String CONTAINER_PERSISTENCE = "Container"; 48 public static String TRUE = "true"; 49 public static String FALSE = "false"; 50 51 protected String persistenceType; 53 protected boolean isReentrant = false; 54 protected String primaryKeyClassName; 55 56 private static LocalStringManagerImpl localStrings = 57 new LocalStringManagerImpl(EjbEntityDescriptor.class); 58 59 static Logger _logger = LogDomains.getLogger(LogDomains.DPL_LOGGER); 60 61 62 63 66 public EjbEntityDescriptor() { 67 } 68 69 72 public EjbEntityDescriptor(EjbDescriptor other) { 73 super(other); 74 if (other instanceof EjbEntityDescriptor) { 75 EjbEntityDescriptor entity = (EjbEntityDescriptor) other; 76 this.persistenceType = entity.persistenceType; 77 this.isReentrant = entity.isReentrant; 78 this.primaryKeyClassName = entity.primaryKeyClassName; 79 } 80 } 81 82 87 public void replaceEntityDescriptor(EjbEntityDescriptor oldEntityDesc) 88 { 89 EjbBundleDescriptor bundle = oldEntityDesc.getEjbBundleDescriptor(); 91 bundle.replaceEjb(oldEntityDesc, this); 92 93 Iterator refs = oldEntityDesc.getAllEjbReferencers().iterator(); 95 while ( refs.hasNext() ) { 96 EjbReferenceDescriptor ref = (EjbReferenceDescriptor)refs.next(); 97 ref.setEjbDescriptor(this); 98 } 99 } 100 101 102 106 public String getTransactionType() { 107 return super.transactionType; 108 } 109 110 115 public void setTransactionType(String transactionType) { 116 if (!CONTAINER_TRANSACTION_TYPE.equals(transactionType) 117 && this.isBoundsChecking()) { 118 throw new IllegalArgumentException (localStrings.getLocalString( 119 "enterprise.deployment.exceptionentitybeancanonlyhavecntnrtxtype", 120 "Entity beans can only have Container transaction type. The type was being set to {0}", new Object [] {transactionType})); 121 } 122 super.transactionType = transactionType; 123 } 124 125 126 129 public boolean isReentrant() { 130 return this.isReentrant; 131 } 132 133 public String getReentrant() { 134 if (this.isReentrant()) { 135 return TRUE; 136 } else { 137 return FALSE; 138 } 139 } 140 141 public void setReentrant(String reentrantString) { 142 if (TRUE.equalsIgnoreCase(reentrantString)) { 143 this.setReentrant(true); 144 return; 145 } 146 if (FALSE.equalsIgnoreCase(reentrantString)) { 147 this.setReentrant(false); 148 return; 149 } 150 if (this.isBoundsChecking()) { 151 throw new IllegalArgumentException (localStrings.getLocalString( 152 "enterprise.deployment.exceptionstringnotlegalvalue", 153 "{0} is not a legal value for entity reentrancy", new Object [] {reentrantString})); 154 } 155 } 156 157 160 public void setReentrant(boolean isReentrant) { 161 this.isReentrant = isReentrant; 162 super.changed(); 163 } 164 165 168 public String getPersistenceType() { 169 if (this.persistenceType == null) { 170 this.persistenceType = BEAN_PERSISTENCE; 171 } 172 return this.persistenceType; 173 } 174 175 179 public void setPersistenceType(String persistenceType) { 180 boolean isValidChange = (BEAN_PERSISTENCE.equals(persistenceType) || CONTAINER_PERSISTENCE.equals(persistenceType)); 181 if (isValidChange || !this.isBoundsChecking()) { 182 this.persistenceType = persistenceType; 183 super.changed(); 184 } else { 185 throw new IllegalArgumentException (localStrings.getLocalString( 187 "enterprise.deployment.exceptionpersistenceisnotallowedtype", 188 "{0} is not an allowed persistence type", new Object [] {persistenceType})); 189 } 190 } 191 192 196 public String getPrimaryKeyClassName() { 197 if (this.primaryKeyClassName == null) { 198 this.primaryKeyClassName = Object .class.getName(); 199 } 200 return this.primaryKeyClassName; 201 } 202 203 206 public void setPrimaryKeyClassName(String primaryKeyClassName) { 207 this.primaryKeyClassName = primaryKeyClassName; 208 super.changed(); 209 } 210 211 214 public String getType() { 215 return TYPE; 216 } 217 218 221 public void setType(String type) { 222 throw new IllegalArgumentException (localStrings.getLocalString( 223 "enterprise.deployment.exceptioncannotsettypeonentitybean", 224 "Cannon set type on an entity bean")); 225 } 226 227 230 public void print(StringBuffer toStringBuffer) { 231 super.print(toStringBuffer); 232 toStringBuffer.append("\n Entity descriptor"); 233 toStringBuffer.append("\n isReentrant ").append(isReentrant); 234 toStringBuffer.append("\n primaryKeyClassName ").append(primaryKeyClassName); 235 toStringBuffer.append("\n persistenceType ").append(persistenceType); 236 } 237 } 238 | Popular Tags |