public void updated(Object instance, String name) { if (instance != null && !reinjectable) { throw new IllegalStateException("Implementation is not reinjectable: " + instance.getClass().getName()); } for (int i = 0; i < injectables.length; i++) { Injectable attribute = injectables[i]; if (attribute.getName().equals(name)) { Injector<Object> injector = injectors[i]; if (instance != null) { updatedInjectors.add(injector); } } } }
public void updated(Object instance, String name) { if (instance != null && !reinjectable) { throw new IllegalStateException("Implementation is not reinjectable: " + instance.getClass().getName()); } for (int i = 0; i < injectables.length; i++) { Injectable attribute = injectables[i]; if (attribute.getName().equals(name)) { Injector<Object> injector = injectors[i]; if (instance != null) { updatedInjectors.add(injector); } } } }
public void removed(Object instance, String name) { if (instance != null && !reinjectable) { throw new IllegalStateException("Implementation is not reinjectable: " + instance.getClass().getName()); } for (int i = 0; i < injectables.length; i++) { Injectable attribute = injectables[i]; if (attribute.getName().equals(name)) { Injector<Object> injector = injectors[i]; injector.clearSupplier(); if (instance != null) { updatedInjectors.add(injector); } } } }
public void removed(Object instance, String name) { if (instance != null && !reinjectable) { throw new IllegalStateException("Implementation is not reinjectable: " + instance.getClass().getName()); } for (int i = 0; i < injectables.length; i++) { Injectable attribute = injectables[i]; if (attribute.getName().equals(name)) { Injector<Object> injector = injectors[i]; injector.clearSupplier(); if (instance != null) { updatedInjectors.add(injector); } } } }
/** * Overrides the target id to be unique for each injection point, e.g. a consumer and producer may have the same name and both need to have separate * connections. * * @return the id */ public String getTargetId() { return getUri() + injectable.getName() + "_target_" + this.getClass().getName()+ "#"+ getTopic(); }
/** * Overrides the target id to be unique for each injection point, e.g. a consumer and producer may have the same name and both need to have separate * connections. * * @return the id */ public String getTargetId() { return getUri() + injectable.getName() + "_target_" + this.getClass().getName()+ "#"+ getTopic(); }
private void generateResourceInjectionMapping(ResourceReference definition, WebComponentType type, Map<String, Map<String, InjectionSite>> mappings) { Map<String, InjectionSite> mapping = mappings.get(definition.getName()); if (mapping == null) { mapping = new HashMap<>(); mappings.put(definition.getName(), mapping); } for (Map.Entry<String, Map<InjectionSite, Injectable>> entry : type.getInjectionSites().entrySet()) { for (Map.Entry<InjectionSite, Injectable> siteMap : entry.getValue().entrySet()) { if (siteMap.getValue().getName().equals(definition.getName())) { mapping.put(entry.getKey(), siteMap.getKey()); } } } ServiceContract contract = definition.getServiceContract(); Class<?> interfaceClass = contract.getInterfaceClass(); // also inject the reference into the servlet context WebContextInjectionSite servletContextSite = new WebContextInjectionSite(interfaceClass, SERVLET_CONTEXT); mapping.put(SERVLET_CONTEXT_SITE, servletContextSite); }
private void generateProducerInjectionMapping(Producer definition, WebComponentType type, Map<String, Map<String, InjectionSite>> mappings) { Map<String, InjectionSite> mapping = mappings.get(definition.getName()); if (mapping == null) { mapping = new HashMap<>(); mappings.put(definition.getName(), mapping); } for (Map.Entry<String, Map<InjectionSite, Injectable>> entry : type.getInjectionSites().entrySet()) { for (Map.Entry<InjectionSite, Injectable> siteMap : entry.getValue().entrySet()) { if (siteMap.getValue().getName().equals(definition.getName())) { mapping.put(entry.getKey(), siteMap.getKey()); } } } ServiceContract contract = definition.getServiceContract(); Class<?> interfaceClass = contract.getInterfaceClass(); // also inject the reference into the servlet context WebContextInjectionSite servletContextSite = new WebContextInjectionSite(interfaceClass, SERVLET_CONTEXT); mapping.put(SERVLET_CONTEXT_SITE, servletContextSite); }
private void generateReferenceInjectionMapping(Reference<ComponentType> definition, WebComponentType type, Map<String, Map<String, InjectionSite>> mappings) { Map<String, InjectionSite> mapping = mappings.get(definition.getName()); if (mapping == null) { mapping = new HashMap<>(); mappings.put(definition.getName(), mapping); } for (Map.Entry<String, Map<InjectionSite, Injectable>> entry : type.getInjectionSites().entrySet()) { for (Map.Entry<InjectionSite, Injectable> siteMap : entry.getValue().entrySet()) { if (siteMap.getValue().getName().equals(definition.getName())) { mapping.put(entry.getKey(), siteMap.getKey()); } } } ServiceContract contract = definition.getServiceContract(); Class<?> interfaceClass = contract.getInterfaceClass(); // inject the reference into the session context WebContextInjectionSite site = new WebContextInjectionSite(interfaceClass, SESSION_CONTEXT); mapping.put(SESSION_CONTEXT_SITE, site); // also inject the reference into the servlet context WebContextInjectionSite servletContextSite = new WebContextInjectionSite(interfaceClass, SERVLET_CONTEXT); mapping.put(SERVLET_CONTEXT_SITE, servletContextSite); }
public void removeSupplier(Injectable injectable) { factory.removeSupplier(injectable); String name = injectable.getName(); List<Object> instances = scopeContainer.getActiveInstances(this); for (Object instance : instances) { getImplementationManager().removed(instance, name); } // Clear the instance factory as it has changed and will need to be re-created. This can happen if reinjection occurs after the first // instance has been created. recreate.set(true); }
public void removeSupplier(Injectable injectable) { factory.removeSupplier(injectable); String name = injectable.getName(); List<Object> instances = scopeContainer.getActiveInstances(this); for (Object instance : instances) { getImplementationManager().removed(instance, name); } // Clear the instance factory as it has changed and will need to be re-created. This can happen if reinjection occurs after the first // instance has been created. recreate.set(true); }
/** * Sets a Supplier. * * @param injectable the injectable identifying the component reference, property or context artifact the Supplier creates instances for * @param supplier the Supplier * @param attributes the injection attributes */ public void setSupplier(Injectable injectable, Supplier<?> supplier, InjectionAttributes attributes) { factory.setSupplier(injectable, supplier, attributes); List<Object> instances = scopeContainer.getActiveInstances(this); String name = injectable.getName(); for (Object instance : instances) { getImplementationManager().updated(instance, name); } // Clear the instance factory as it has changed and will need to be re-created. This can happen if reinjection occurs after the first // instance has been created. recreate.set(true); }
/** * Sets a Supplier. * * @param injectable the injectable identifying the component reference, property or context artifact the Supplier creates instances for * @param supplier the Supplier * @param attributes the injection attributes */ public void setSupplier(Injectable injectable, Supplier<?> supplier, InjectionAttributes attributes) { factory.setSupplier(injectable, supplier, attributes); List<Object> instances = scopeContainer.getActiveInstances(this); String name = injectable.getName(); for (Object instance : instances) { getImplementationManager().updated(instance, name); } // Clear the instance factory as it has changed and will need to be re-created. This can happen if reinjection occurs after the first // instance has been created. recreate.set(true); }