@AfterReturning(
      pointcut =
          "execution(public String at.ac.tuwien.infosys.jcloudscale.server.JCloudScaleServer.createNewCloudObject(..))",
      returning = "ret")
  public void matchObjectCreated(JoinPoint jp, String ret) throws JCloudScaleException {

    try {
      ObjectCreatedEvent event = new ObjectCreatedEvent();
      initializeBaseEventProperties(event);
      UUID objectId = UUID.fromString(ret);
      event.setObjectId(objectId);
      JCloudScaleServer server = (JCloudScaleServer) jp.getThis();
      // XXX AbstractJCloudScaleServerRunner
      // UUID serverId = JCloudScaleServerRunner.getInstance().getId();
      UUID serverId = AbstractJCloudScaleServerRunner.getInstance().getId();
      event.setHostId(serverId);
      ClassLoader cl = server.getCloudObjectClassLoader(objectId);
      Class<?> theClazz = Class.forName((String) (jp.getArgs()[0]), true, cl);
      event.setObjectType(theClazz);
      getMqHelper().sendEvent(event);
      log.finer("Sent object created for object " + objectId.toString());
    } catch (Exception e) {
      e.printStackTrace();
      log.severe("Error while triggering ObjectCreatedEvent: " + e.getMessage());
    }
  }
  @Around(
      "execution(public void at.ac.tuwien.infosys.jcloudscale.server.JCloudScaleServer.destroyCloudObject(..))")
  public void matchObjectDestroyed(ProceedingJoinPoint pjp) throws Throwable {

    Class<?> cloudObjectType = null;
    JCloudScaleServer server = null;
    UUID cloudObjectId = null;
    try {
      server = (JCloudScaleServer) pjp.getThis();
      cloudObjectId = UUID.fromString((String) (pjp.getArgs()[0]));

      Object cloudObject = server.getCloudObject(cloudObjectId);
      if (cloudObject != null) cloudObjectType = cloudObject.getClass();
    } catch (Exception e) {
      e.printStackTrace();
      log.severe("Error while triggering ObjectDestroyedEvent: " + e.getMessage());
    }

    pjp.proceed();

    try {
      ObjectDestroyedEvent event = new ObjectDestroyedEvent();
      initializeBaseEventProperties(event);
      // XXX AbstractJCloudScaleServerRunner
      // UUID serverId = JCloudScaleServerRunner.getInstance().getId();
      UUID serverId = AbstractJCloudScaleServerRunner.getInstance().getId();
      event.setHostId(serverId);
      event.setObjectId(cloudObjectId);
      event.setObjectType(cloudObjectType);
      getMqHelper().sendEvent(event);
      log.finer("Sent object destroyed for object " + cloudObjectId);
    } catch (Exception e) {
      e.printStackTrace();
      log.severe("Error while triggering ObjectDestroyedEvent: " + e.getMessage());
    }
  }