1 23 package com.sun.enterprise.deployment.annotation.context; 24 25 import java.lang.annotation.ElementType ; 26 import java.lang.reflect.AnnotatedElement ; 27 28 import java.util.Iterator ; 29 import java.util.Set ; 30 31 import com.sun.enterprise.deployment.Descriptor; 32 import com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor; 33 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor; 34 import com.sun.enterprise.deployment.EnvironmentProperty; 35 import com.sun.enterprise.deployment.JndiNameEnvironment; 36 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor; 37 import com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor; 38 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 39 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 40 import com.sun.enterprise.deployment.WritableJndiNameEnvironment; 41 import com.sun.enterprise.deployment.annotation.ProcessingContext; 42 import com.sun.enterprise.deployment.types.EjbReference; 43 import com.sun.enterprise.deployment.types.EjbReferenceContainer; 44 import com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer; 45 import com.sun.enterprise.deployment.types.ResourceReferenceContainer; 46 import com.sun.enterprise.deployment.types.ServiceReferenceContainer; 47 import com.sun.enterprise.deployment.types.HandlerChainContainer; 48 49 54 public class ResourceContainerContextImpl extends AnnotationContext 55 implements ResourceContainerContext, ComponentContext, 56 ServiceReferenceContainerContext, HandlerContext { 57 58 protected Descriptor descriptor = null; 59 protected String componentClassName = null; 60 61 public ResourceContainerContextImpl() { 62 } 63 64 public ResourceContainerContextImpl(Descriptor descriptor) { 65 this.descriptor = descriptor; 66 } 67 68 73 public void addEjbReferenceDescriptor(EjbReference ejbReference) { 74 getEjbReferenceContainer().addEjbReferenceDescriptor(ejbReference); 75 } 76 77 83 public EjbReference getEjbReference(String name) { 84 EjbReference ejbRef = null; 85 try { 86 ejbRef = getEjbReferenceContainer().getEjbReference(name); 87 } catch(IllegalArgumentException e) { 94 } 97 return ejbRef; 98 } 99 100 protected EjbReferenceContainer getEjbReferenceContainer() { 101 return (EjbReferenceContainer)descriptor; 102 } 103 104 public void addResourceReferenceDescriptor(ResourceReferenceDescriptor 105 resReference) { 106 getResourceReferenceContainer().addResourceReferenceDescriptor 107 (resReference); 108 } 109 110 116 public ResourceReferenceDescriptor getResourceReference(String name) { 117 ResourceReferenceDescriptor resourceRef = null; 118 try { 119 resourceRef = getResourceReferenceContainer(). 120 getResourceReferenceByName(name); 121 } catch(IllegalArgumentException e) { 128 } 131 return resourceRef; 132 } 133 134 protected ResourceReferenceContainer getResourceReferenceContainer() { 135 return (ResourceReferenceContainer)descriptor; 136 } 137 138 139 public void addMessageDestinationReferenceDescriptor 140 (MessageDestinationReferenceDescriptor msgDestReference) { 141 getMessageDestinationReferenceContainer( 142 ).addMessageDestinationReferenceDescriptor(msgDestReference); 143 } 144 145 146 public MessageDestinationReferenceDescriptor getMessageDestinationReference 147 (String name) { 148 MessageDestinationReferenceDescriptor msgDestRef = null; 149 try { 150 msgDestRef = getMessageDestinationReferenceContainer(). 151 getMessageDestinationReferenceByName(name); 152 } catch(IllegalArgumentException e) { 159 } 162 return msgDestRef; 163 } 164 165 protected MessageDestinationReferenceContainer 166 getMessageDestinationReferenceContainer() 167 { 168 return (MessageDestinationReferenceContainer)descriptor; 169 } 170 171 public void addJmsDestinationReferenceDescriptor 172 (JmsDestinationReferenceDescriptor jmsDestReference) { 173 getJmsDestinationReferenceContainer( 174 ).addJmsDestinationReferenceDescriptor(jmsDestReference); 175 } 176 177 public JmsDestinationReferenceDescriptor getJmsDestinationReference 178 (String name) { 179 JmsDestinationReferenceDescriptor jmsDestRef = null; 180 try { 181 jmsDestRef = getJmsDestinationReferenceContainer(). 182 getJmsDestinationReferenceByName(name); 183 } catch(IllegalArgumentException e) { 190 } 193 return jmsDestRef; 194 } 195 196 protected WritableJndiNameEnvironment 197 getJmsDestinationReferenceContainer() 198 { 199 return (WritableJndiNameEnvironment)descriptor; 200 } 201 202 public void addEnvEntryDescriptor(EnvironmentProperty envEntry) { 203 204 getEnvEntryContainer().addEnvironmentProperty(envEntry); 205 206 } 207 208 public EnvironmentProperty getEnvEntry(String name) { 209 EnvironmentProperty envEntry = null; 210 try { 211 envEntry = getEnvEntryContainer(). 212 getEnvironmentPropertyByName(name); 213 } catch(IllegalArgumentException e) { 220 } 223 return envEntry; 224 225 } 226 227 protected WritableJndiNameEnvironment getEnvEntryContainer() 228 { 229 return (WritableJndiNameEnvironment)descriptor; 230 } 231 232 public void addEntityManagerFactoryReferenceDescriptor 233 (EntityManagerFactoryReferenceDescriptor emfRefDesc) { 234 235 getEmfRefContainer().addEntityManagerFactoryReferenceDescriptor 236 (emfRefDesc); 237 238 } 239 240 public EntityManagerFactoryReferenceDescriptor 241 getEntityManagerFactoryReference(String name) { 242 243 EntityManagerFactoryReferenceDescriptor emfRefDesc = null; 244 245 try { 246 emfRefDesc = getEmfRefContainer(). 247 getEntityManagerFactoryReferenceByName(name); 248 } catch(IllegalArgumentException e) { 255 } 258 259 return emfRefDesc; 260 261 } 262 263 protected WritableJndiNameEnvironment getEmfRefContainer() 264 { 265 return (WritableJndiNameEnvironment)descriptor; 266 } 267 268 269 public void addEntityManagerReferenceDescriptor 270 (EntityManagerReferenceDescriptor emRefDesc) { 271 272 getEmRefContainer().addEntityManagerReferenceDescriptor 273 (emRefDesc); 274 275 } 276 277 public EntityManagerReferenceDescriptor 278 getEntityManagerReference(String name) { 279 280 EntityManagerReferenceDescriptor emRefDesc = null; 281 282 try { 283 emRefDesc = getEmRefContainer(). 284 getEntityManagerReferenceByName(name); 285 } catch(IllegalArgumentException e) { 292 } 295 296 return emRefDesc; 297 298 } 299 300 protected WritableJndiNameEnvironment getEmRefContainer() 301 { 302 return (WritableJndiNameEnvironment)descriptor; 303 } 304 305 308 public void addPostConstructDescriptor( 309 LifecycleCallbackDescriptor postConstructDesc) { 310 getPostConstructContainer().addPostConstructDescriptor(postConstructDesc); 311 } 312 313 318 public LifecycleCallbackDescriptor getPostConstruct(String className) { 319 LifecycleCallbackDescriptor postConstructDesc = 320 getPostConstructContainer().getPostConstructDescriptorByClass(className); 321 return postConstructDesc; 322 } 323 324 protected WritableJndiNameEnvironment getPostConstructContainer() { 325 return (WritableJndiNameEnvironment)descriptor; 326 } 327 328 331 public void addPreDestroyDescriptor( 332 LifecycleCallbackDescriptor preDestroyDesc) { 333 getPreDestroyContainer().addPreDestroyDescriptor(preDestroyDesc); 334 } 335 336 341 public LifecycleCallbackDescriptor getPreDestroy(String className) { 342 LifecycleCallbackDescriptor preDestroyDesc = 343 getPreDestroyContainer().getPreDestroyDescriptorByClass(className); 344 return preDestroyDesc; 345 } 346 347 protected WritableJndiNameEnvironment getPreDestroyContainer() { 348 return (WritableJndiNameEnvironment)descriptor; 349 } 350 351 public String getComponentClassName() { 352 return componentClassName; 353 } 354 355 public HandlerChainContainer[] 356 getHandlerChainContainers(boolean serviceSideHandlerChain, Class declaringClass) { 357 return null; 359 } 360 361 public ServiceReferenceContainer[] getServiceRefContainers() { 362 ServiceReferenceContainer[] containers = new ServiceReferenceContainer[1]; 364 containers[0] = (ServiceReferenceContainer) descriptor; 365 return containers; 366 } 367 } 368 | Popular Tags |