/**
   * {@inheritDoc}
   *
   * @param componentKey
   * @return
   * @see org.picocontainer.MutablePicoContainer#removeComponent(java.lang.Object)
   */
  public ComponentAdapter removeComponent(final Object componentKey) {
    if (logger.isDebugEnabled()) {
      logger.debug("Unregistering component " + componentKey + " from container " + delegate);
    }

    return delegate.removeComponent(componentKey);
  }
Ejemplo n.º 2
0
 public Object remove(final Object o) {
   ComponentAdapter adapter = mutablePicoContainer.removeComponent(o);
   if (adapter != null) {
     // if previously an instance was registered, return it, otherwise return the type
     return adapter instanceof InstanceAdapter
         ? adapter.getComponentInstance(mutablePicoContainer, ComponentAdapter.NOTHING.class)
         : adapter.getComponentImplementation();
   } else {
     return null;
   }
 }
Ejemplo n.º 3
0
  /**
   * Adds the object to Saros' container, and injects dependencies into the annotated fields of the
   * given object. It should only be used for objects that were created by Eclipse, which have the
   * same life cycle as the Saros plug-in, e.g. the popup menu actions.
   */
  public synchronized void reinject(Object toInjectInto) {
    try {
      // Remove the component if an instance of it was already registered
      Class<?> clazz = toInjectInto.getClass();
      ComponentAdapter<?> removed = container.removeComponent(clazz);
      if (removed != null) {
        log.warn(clazz.getName() + " added more than once!", new StackTrace());
      }

      // Add the given instance to the container
      container.addComponent(clazz, toInjectInto);

      /*
       * Ask PicoContainer to inject into the component via fields
       * annotated with @Inject
       */
      reinjector.reinject(clazz, new AnnotatedFieldInjection());
    } catch (PicoCompositionException e) {
      log.error("Internal error in reinjection:", e);
    }
  }
Ejemplo n.º 4
0
 public void clear() {
   Set adapters = keySet();
   for (Object adapter : adapters) {
     mutablePicoContainer.removeComponent(adapter);
   }
 }
Ejemplo n.º 5
0
 public void removeComponent(Object o) {
   container.removeComponent(o);
 }