public <T> T unmarshal( String containerId, String data, String marshallingFormat, Class<T> unmarshalType) { if (data == null || data.isEmpty()) { return null; } 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); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
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); }