public String marshal(String marshallingFormat, Object entity) {
    MarshallingFormat format = getFormat(marshallingFormat);

    if (format == null) {
      throw new IllegalArgumentException("Unknown marshalling format " + marshallingFormat);
    }

    Marshaller marshaller = serverMarshallers.get(format);
    if (marshaller == null) {
      marshaller = MarshallerFactory.getMarshaller(format, this.getClass().getClassLoader());
      serverMarshallers.put(format, marshaller);
    }

    return marshaller.marshall(entity);
  }
  public String marshal(String containerId, String marshallingFormat, Object entity) {
    MarshallingFormat format = getFormat(marshallingFormat);

    KieContainerInstance containerInstance = registry.getContainer(containerId);

    if (containerInstance == null || format == null) {
      throw new IllegalArgumentException(
          "No container found for id "
              + containerId
              + " or unknown marshalling format "
              + marshallingFormat);
    }

    Marshaller marshaller = containerInstance.getMarshaller(format);
    if (marshaller == null) {
      throw new IllegalArgumentException("No marshaller found for format " + format);
    }

    return marshaller.marshall(entity);
  }