public <T> T search(DeploymentUnit unit, String name, Class<T> expectedType) { return AttachmentLocator.searchAncestors(unit, name, expectedType); } }
/** * Get an attachment of the given type, search in children * * @param <T> the expected type * @param type the type * @param unit the deployment unit * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or type */ public static <T> T searchChildren(DeploymentUnit unit, Class<T> type) { if (type == null) throw new IllegalArgumentException("Null expected type."); return searchChildren(unit, type.getName(), type); } }
JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class); if (earMetaData != null)
private T getUtil() { if (util == null) { T tmp = AttachmentLocator.searchAncestors(unit, type); if (tmp == null) throw new IllegalArgumentException("No such util: " + type); util = tmp; } return util; }
/** * Get named attachment of a given type, search in children * * @param <T> the expected type * @param unit the deployment unit * @param name the name of the attachment * @param expectedType the expected type * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or expectedType */ public static <T> T searchChildren(DeploymentUnit unit, String name, Class<T> expectedType) { Object result = searchChildren(unit, name); if (result == null) return null; if (expectedType == null) throw new IllegalArgumentException("Null expected type."); return expectedType.cast(result); }
/** * Get a named attachment * * @param unit the deployment unit * @param name the name of the attachment * @return the attachment or null if not present * @throws IllegalArgumentException for a null name */ @Deprecated public static Object search(DeploymentUnit unit, String name) { return searchAncestors(unit, name); }
Object result = searchChildren(component, name); if (result != null) return result; Object result = searchChildren(child, name); if (result != null) return result;
/** * Get named attachment of a given type * * @param <T> the expected type * @param unit the deployment unit * @param name the name of the attachment * @param expectedType the expected type * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or expectedType */ @Deprecated public static <T> T search(DeploymentUnit unit, String name, Class<T> expectedType) { return searchAncestors(unit, name, expectedType); }
/** * Get an attachment of the given type, search ancestors * * @param <T> the expected type * @param type the type * @param unit the deployment unit * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or type */ public static <T> T searchAncestors(DeploymentUnit unit, Class<T> type) { if (type == null) throw new IllegalArgumentException("Null expected type."); return searchAncestors(unit, type.getName(), type); }
/** * Get an attachment of the given type * * @param <T> the expected type * @param type the type * @param unit the deployment unit * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or type */ @Deprecated public static <T> T search(DeploymentUnit unit, Class<T> type) { if (type == null) throw new IllegalArgumentException("Null expected type."); return searchAncestors(unit, type); }
/** * Get named attachment of a given type, search ancestors * * @param <T> the expected type * @param unit the deployment unit * @param name the name of the attachment * @param expectedType the expected type * @return the attachment or null if not present * @throws IllegalArgumentException for a null name or expectedType */ public static <T> T searchAncestors(DeploymentUnit unit, String name, Class<T> expectedType) { Object result = searchAncestors(unit, name); if (result == null) return null; if (expectedType == null) throw new IllegalArgumentException("Null expected type."); return expectedType.cast(result); }
protected void scan(Set<ScanningPlugin> plugins) throws Exception { Module module = AttachmentLocator.searchAncestors(unit, Module.class); if (module == null) throw new IllegalArgumentException("No module found: " + unit); ScanningPlugin[] array = plugins.toArray(new ScanningPlugin[plugins.size()]); FederatedResourceVisitor visitor = new FederatedResourceVisitor(array, array, getRecurseFilters(array)); ResourceFilter filter = visitor.getFilter(); ResourceFilter recurseFilter = visitor.getRecurseFilter(); filter = wrap(ResourceFilter.class.getName() + ".resource", filter); recurseFilter = wrap(ResourceFilter.class.getName() + ".recurse", recurseFilter); // by default we don't use VFS, // since we already expect it to be VFS based URL[] urls; if (isToVFS()) urls = toVFS(getRoots()); else urls = getRoots(); // something in javassist uses TCL ClassLoader tccl = SecurityActions.setContextClassLoader(unit.getClassLoader()); try { module.visit(visitor, filter, recurseFilter, urls); } finally { SecurityActions.resetContextClassLoader(tccl); } }