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 <T> T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); Marshaller marshaller = serverMarshallers.get(format); if (marshaller == null) { marshaller = MarshallerFactory.getMarshaller(format, this.getClass().getClassLoader()); serverMarshallers.put(format, marshaller); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }