/*
  * (non-Javadoc)
  *
  * @see org.opennaas.core.resources.caactivatepability.AbstractCapability#activate()
  */
 @Override
 public void activate() throws CapabilityException {
   registerService(
       Activator.getContext(),
       CAPABILITY_TYPE,
       getResourceType(),
       getResourceName(),
       IOpenflowForwardingCapability.class.getName());
   super.activate();
 }
 @Override
 public void activate() throws CapabilityException {
   registerService(
       Activator.getContext(),
       CAPABILITY_TYPE,
       getResourceType(),
       getResourceName(),
       ITopologyDiscoveryCapability.class.getName());
   super.activate();
 }
  /** tests ConnectionsCapability.getActionSet().getStartupRefreshAction() != null */
  @Test
  public void getStartUpRefreshActionTest() throws Exception {

    ((Resource) mockResource)
        .setResourceDescriptor(ResourceHelper.newResourceDescriptorProteus("roadm"));

    // Test elements not null
    log.info("Checking connections factory");
    Assert.assertNotNull(connectionFactory);
    log.info("Checking capability descriptor");
    Assert.assertNotNull(
        mockResource.getResourceDescriptor().getCapabilityDescriptor("connections"));
    log.info("Creating connection capability");
    connectionsCapability = (AbstractCapability) connectionFactory.create(mockResource);
    Assert.assertNotNull(connectionsCapability);
    connectionsCapability.initialize();

    Assert.assertFalse(connectionsCapability.getActionSet().getRefreshActionName().isEmpty());
    startupActionNames = connectionsCapability.getActionSet().getRefreshActionName();
  }
  @Override
  public void bootstrap(Resource resource) throws ResourceException {
    log.info("Loading bootstrap to start resource...");
    oldModel = resource.getModel();
    resetModel(resource);

    /* start its capabilities */
    for (ICapability capab : resource.getCapabilities()) {
      /* abstract capabilities have to be initialized */
      log.debug("Found a capability in the resource.");
      /* abstract capabilities have to be initialized */
      if (capab instanceof AbstractCapability) {
        log.debug("Executing capabilities startup...");
        ((AbstractCapability) capab).sendRefreshActions();
      }
    }

    IQueueManagerCapability queueCapab =
        (IQueueManagerCapability) resource.getCapabilityByInterface(IQueueManagerCapability.class);
    QueueResponse response;
    try {
      response = queueCapab.execute();
      if (!response.isOk()) {
        // TODO IMPROVE ERROR REPORTING
        throw new ResourceException(
            "Error during capabilities startup. Failed to execute startUp actions.");
      }
    } catch (ProtocolException e) {
      throw new ResourceException(
          "Error during capabilities startup. Failed to execute startUp actions.", e);
    } catch (ActionException e) {
      throw new ResourceException(
          "Error during capabilities startup. Failed to execute startUp actions.", e);
    } catch (CapabilityException e) {
      throw new ResourceException(
          "Error during capabilities startup. Failed to execute startUp actions.", e);
    }

    if (resource.getProfile() != null) {
      log.debug("Executing initModel from profile...");
      resource.getProfile().initModel(resource.getModel());
    }

    if (ModelHelper.getInterfaces(((ComputerSystem) resource.getModel())).isEmpty()) {
      log.warn("Router has no interfaces");
    }

    // FIXME This should be part of refresh action
    initVirtualResources(resource);
  }
 /*
  * (non-Javadoc)
  *
  * @see org.opennaas.core.resources.capability.AbstractCapability#deactivate()
  */
 @Override
 public void deactivate() throws CapabilityException {
   unregisterService();
   super.deactivate();
 }
 @Override
 public void deactivate() throws CapabilityException {
   registration.unregister();
   super.deactivate();
 }