private Iterable<Metadata<Extension>> getExtensions( ClassLoader classLoader, Bootstrap bootstrap) { Set<Metadata<Extension>> result = new HashSet<Metadata<Extension>>(); if (discoveryEnabled) { Iterables.addAll(result, bootstrap.loadExtensions(classLoader)); } if (!extensions.isEmpty()) { result.addAll(extensions); } // Ensure that WeldSEBeanRegistrant is present WeldSEBeanRegistrant weldSEBeanRegistrant = null; for (Metadata<Extension> metadata : result) { if (metadata.getValue().getClass().getName().equals(WeldSEBeanRegistrant.class.getName())) { weldSEBeanRegistrant = (WeldSEBeanRegistrant) metadata.getValue(); break; } } if (weldSEBeanRegistrant == null) { try { weldSEBeanRegistrant = SecurityActions.newInstance(WeldSEBeanRegistrant.class); result.add( new MetadataImpl<Extension>( weldSEBeanRegistrant, SYNTHETIC_LOCATION_PREFIX + WeldSEBeanRegistrant.class.getName())); } catch (Exception e) { throw new RuntimeException(e); } } if (!beanBuilders.isEmpty()) { weldSEBeanRegistrant.setBeanBuilders(beanBuilders); } return result; }
private static <T> Map<T, Metadata<T>> createMetadataMap( List<Metadata<T>> metadata, ValidatorMessage specifiedTwiceMessage) { Map<T, Metadata<T>> result = new HashMap<T, Metadata<T>>(); for (Metadata<T> value : metadata) { if (result.containsKey(value.getValue())) { throw new DeploymentException(specifiedTwiceMessage, metadata); } result.put(value.getValue(), value); } return result; }
private static Iterable adapt(Iterable iterable) { if (weldSL) { List<Object> list = new ArrayList<Object>(); for (Object o : iterable) { Metadata md = (Metadata) o; list.add(md.getValue()); } return list; } else { return iterable; } }
public Metadata<Class<? extends T>> apply(Metadata<String> from) { String location = from.getLocation(); try { return new MetadataImpl<Class<? extends T>>( Reflections.<Class<? extends T>>cast(resourceLoader.classForName(from.getValue())), location); } catch (ResourceLoadingException e) { throw new ResourceLoadingException( e.getMessage() + "; location: " + location, e.getCause()); } catch (Exception e) { throw new ResourceLoadingException(e.getMessage() + "; location: " + location, e); } }