public void removeSupplier(Injectable injectable) { for (Iterator<Map.Entry<Supplier, Injectable>> iterator = reinjectionMappings.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry<Supplier, Injectable> entry = iterator.next(); if (injectable.equals(entry.getValue())) { iterator.remove(); break; } } }
/** * Finds the mapped Supplier for the injectable. * * @param injectable the injectable * @return the Supplier */ private Supplier<?> findSupplier(Injectable injectable) { Supplier<?> supplier = null; for (Map.Entry<Supplier, Injectable> entry : reinjectionMappings.entrySet()) { if (injectable.equals(entry.getValue())) { supplier = entry.getKey(); break; } } return supplier; }
private InjectionSite findInjectionSite(Injectable attribute) { // try constructor for (int i = 0; i < cdiSources.size(); i++) { Injectable injectable = cdiSources.get(i); if (attribute.equals(injectable)) { return new ConstructorInjectionSite(constructor, i); } } // try postConstruction for (Map.Entry<InjectionSite, Injectable> entry : postConstruction.entrySet()) { if (entry.getValue().equals(attribute)) { return entry.getKey(); } } return null; }
private InjectionSite findInjectionSite(Injectable attribute) { // try constructor for (int i = 0; i < cdiSources.size(); i++) { Injectable injectable = cdiSources.get(i); if (attribute.equals(injectable)) { return new ConstructorInjectionSite(constructor, i); } } // try postConstruction for (Map.Entry<InjectionSite, Injectable> entry : postConstruction.entrySet()) { if (entry.getValue().equals(attribute)) { return entry.getKey(); } } return null; }
/** * Returns the injectable type. * * @param injectable the injectable * @return the type */ private Class<?> getMemberType(Injectable injectable) { for (Map.Entry<Member, Injectable> entry : sites.entrySet()) { if (injectable.equals(entry.getValue())) { Member member = entry.getKey(); if (member instanceof Method) { return ((Method) member).getParameterTypes()[0]; } else if (member instanceof Field) { return ((Field) member).getType(); } else { throw new AssertionError("Unsupported injection site type for singleton components"); } } } return null; }
private void generateContextInjectionMapping(WebComponentType type, Map<String, Map<String, InjectionSite>> mappings) { // OASIS API Map<String, InjectionSite> oasisMapping = mappings.get(OASIS_CONTEXT_ATTRIBUTE); if (oasisMapping == null) { oasisMapping = new HashMap<>(); WebContextInjectionSite site = new WebContextInjectionSite(ComponentContext.class, SESSION_CONTEXT); oasisMapping.put(SESSION_CONTEXT_SITE, site); mappings.put(OASIS_CONTEXT_ATTRIBUTE, oasisMapping); } for (Map.Entry<String, Map<InjectionSite, Injectable>> entry : type.getInjectionSites().entrySet()) { for (Map.Entry<InjectionSite, Injectable> siteMap : entry.getValue().entrySet()) { if (siteMap.getValue().equals(Injectable.OASIS_COMPONENT_CONTEXT)) { oasisMapping.put(entry.getKey(), siteMap.getKey()); } } } }
if (entry.getValue().equals(attribute)) { Member member = entry.getKey(); if (member instanceof Field) {