1 22 package org.jboss.deployers.plugins.deployers.helpers; 23 24 import org.jboss.deployers.spi.deployer.DeploymentUnit; 25 import org.jboss.deployers.spi.structure.DeploymentContext; 26 27 34 public class AttachmentLocator 35 { 36 43 static public Object search(DeploymentUnit unit, String name) 44 { 45 Object attachment = null; 46 DeploymentContext ctx = unit.getDeploymentContext(); 47 while( attachment == null && ctx != null ) 48 { 49 attachment = ctx.getDeploymentUnit().getAttachment(name); 50 ctx = ctx.getParent(); 51 } 52 return attachment; 53 } 54 55 64 static public <T> T search(DeploymentUnit unit, String name, Class <T> expectedType) 65 { 66 Object result = search(unit, name); 67 if (result == null) 68 return null; 69 return expectedType.cast(result); 70 } 71 72 80 static public <T> T search(DeploymentUnit unit, Class <T> type) 81 { 82 return search(unit, type.getName(), type); 83 } 84 } 85 | Popular Tags |