Example #1
0
 /**
  * Receive any contributions.
  *
  * <p>We need to know when to remove the component so we need a map from the factory to the
  * instance so that when the factory is unregistered, we can dispose it.
  *
  * @param factory The DS Component Factory that can make, well, ehh, components.
  */
 @Reference(type = '*', target = "(component.factory=com.vaadin.Component/contribution)")
 protected void setContribution(ComponentFactory factory) {
   ComponentInstance ci = factory.newInstance(null);
   Component c = (Component) ci.getInstance();
   synchronized (this) {
     tabs.addTab(c);
     mapping.put(factory, ci);
   }
 }
Example #2
0
 /**
  * The contribution is unregistered.
  *
  * @param factory The component factory.
  */
 protected void unsetContribution(ComponentFactory factory) {
   ComponentInstance ci;
   Component c;
   synchronized (this) {
     ci = mapping.remove(factory);
     c = (Component) ci.getInstance();
     tabs.removeComponent(c);
   }
   c.detach();
   ci.dispose();
 }