@Test void release() throws Exception { final EmbeddableComponentManager ecm = new EmbeddableComponentManager(); final DefaultComponentDescriptor<Role> cd = new DefaultComponentDescriptor<>(); cd.setRoleType(Role.class); cd.setImplementation(RoleImpl.class); Role roleImpl = new RoleImpl(); ecm.registerComponent(cd, roleImpl); final ComponentEventManager cem = mock(ComponentEventManager.class); ecm.setComponentEventManager(cem); ecm.release(roleImpl); verify(cem).notifyComponentUnregistered(cd, ecm); verify(cem).notifyComponentRegistered(cd, ecm); assertNotNull(ecm.getInstance(Role.class)); assertNotSame(roleImpl, ecm.getInstance(Role.class)); }
@Override public void release(Object component) throws ComponentLifecycleException { ComponentEntry<?> componentEntry = null; for (Map<String, ComponentEntry<?>> entries : this.componentEntries.values()) { for (ComponentEntry<?> entry : entries.values()) { if (entry.instance == component) { componentEntry = entry; break; } } } if (componentEntry != null) { releaseInstance(componentEntry); if (this.eventManager != null) { this.eventManager.notifyComponentUnregistered(componentEntry.descriptor, this); this.eventManager.notifyComponentRegistered(componentEntry.descriptor, this); } } }
EmbeddableComponentManager implements NamespacedComponentManager, Disposable { @Override public void release(Object component) throws ComponentLifecycleException { ComponentEntry<?> componentEntry = null; for (Map<String, ComponentEntry<?>> entries : this.componentEntries.values()) { for (ComponentEntry<?> entry : entries.values()) { if (entry.instance == component) { componentEntry = entry; break; } } } if (componentEntry != null) { releaseInstance(componentEntry); if (this.eventManager != null) { this.eventManager.notifyComponentUnregistered(componentEntry.descriptor, this); this.eventManager.notifyComponentRegistered(componentEntry.descriptor, this); } } } }
EmbeddableComponentManager implements NamespacedComponentManager, Disposable { @Override public void release(Object component) throws ComponentLifecycleException { ComponentEntry<?> componentEntry = null; for (Map<String, ComponentEntry<?>> entries : this.componentEntries.values()) { for (ComponentEntry<?> entry : entries.values()) { if (entry.instance == component) { componentEntry = entry; break; } } } if (componentEntry != null) { releaseInstance(componentEntry); if (this.eventManager != null) { this.eventManager.notifyComponentUnregistered(componentEntry.descriptor, this); this.eventManager.notifyComponentRegistered(componentEntry.descriptor, this); } } } EmbeddableComponentManager();  EmbeddableComponentManager(String namespace); }
EmbeddableComponentManager implements NamespacedComponentManager, Disposable { @Override public void release(Object component) throws ComponentLifecycleException { ComponentEntry<?> componentEntry = null; for (Map<String, ComponentEntry<?>> entries : this.componentEntries.values()) { for (ComponentEntry<?> entry : entries.values()) { if (entry.instance == component) { componentEntry = entry; break; } } } if (componentEntry != null) { releaseInstance(componentEntry); if (this.eventManager != null) { this.eventManager.notifyComponentUnregistered(componentEntry.descriptor, this); this.eventManager.notifyComponentRegistered(componentEntry.descriptor, this); } } } EmbeddableComponentManager();  EmbeddableComponentManager(String namespace); @Override String getNamespace(); void initialize(ClassLoader classLoader); @Override boolean hasComponent(Type role); @Override boolean hasComponent(Type roleType, String roleHint); @Override T getInstance(Type roleType); @Override T getInstance(Type roleType, String roleHint); @Override List<T> getInstanceList(Type role); @Override @SuppressWarnings("unchecked") Map<String, T> getInstanceMap(Type roleType); @Override @SuppressWarnings("unchecked") ComponentDescriptor<T> getComponentDescriptor(Type role, String hint); @Override @SuppressWarnings("unchecked") List<ComponentDescriptor<T>> getComponentDescriptorList(Type role); @Override ComponentEventManager getComponentEventManager(); @Override void setComponentEventManager(ComponentEventManager eventManager); @Override ComponentManager getParent(); @Override void setParent(ComponentManager parentComponentManager); @Override void registerComponent(ComponentDescriptor<T> componentDescriptor); @Override void registerComponent(ComponentDescriptor<T> componentDescriptor, T componentInstance); @Override void unregisterComponent(Type role, String hint); @Override void unregisterComponent(ComponentDescriptor<?> componentDescriptor); @Override void release(Object component); @Override void dispose(); @Override @Deprecated List<ComponentDescriptor<T>> getComponentDescriptorList(Class<T> role); }
EmbeddableComponentManager implements NamespacedComponentManager, Disposable { @Override public void release(Object component) throws ComponentLifecycleException { ComponentEntry<?> componentEntry = null; for (Map<String, ComponentEntry<?>> entries : this.componentEntries.values()) { for (ComponentEntry<?> entry : entries.values()) { if (entry.instance == component) { componentEntry = entry; break; } } } if (componentEntry != null) { releaseInstance(componentEntry); if (this.eventManager != null) { this.eventManager.notifyComponentUnregistered(componentEntry.descriptor, this); this.eventManager.notifyComponentRegistered(componentEntry.descriptor, this); } } } EmbeddableComponentManager();  EmbeddableComponentManager(String namespace); @Override String getNamespace(); void initialize(ClassLoader classLoader); @Override boolean hasComponent(Type role); @Override boolean hasComponent(Type roleType, String roleHint); @Override T getInstance(Type roleType); @Override T getInstance(Type roleType, String roleHint); @Override List<T> getInstanceList(Type role); @Override @SuppressWarnings("unchecked") Map<String, T> getInstanceMap(Type roleType); @Override @SuppressWarnings("unchecked") ComponentDescriptor<T> getComponentDescriptor(Type role, String hint); @Override @SuppressWarnings("unchecked") List<ComponentDescriptor<T>> getComponentDescriptorList(Type role); @Override ComponentEventManager getComponentEventManager(); @Override void setComponentEventManager(ComponentEventManager eventManager); @Override ComponentManager getParent(); @Override void setParent(ComponentManager parentComponentManager); @Override void registerComponent(ComponentDescriptor<T> componentDescriptor); @Override void registerComponent(ComponentDescriptor<T> componentDescriptor, T componentInstance); @Override void unregisterComponent(Type role, String hint); @Override void unregisterComponent(ComponentDescriptor<?> componentDescriptor); @Override void release(Object component); @Override void dispose(); @Override @Deprecated List<ComponentDescriptor<T>> getComponentDescriptorList(Class<T> role);  }