private void verifyMarshallingRoundTrip( Marshaller marshaller, Object inputObject ) { String rawContent = marshaller.marshall( inputObject ); Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall( rawContent, inputObject.getClass() ); Assertions.assertThat( testObjectAfterMarshallingTurnAround ).isEqualTo( inputObject ); }
public void disposeMarshallers() { synchronized ( marshallers ) { for ( Marshaller marshaller : this.marshallers.values() ) { marshaller.dispose(); } this.marshallers.clear(); } }
@Override public ClassLoader getClassLoader() { return this.marshaller.getClassLoader(); }
protected <T> T deserialize(String content, Class<T> type) { return marshaller.unmarshall( content, type ); } }
protected String serialize(Object object) { if (object == null) { return ""; } try { return marshaller.marshall(object); } catch ( MarshallingException e ) { throw new IllegalStateException( "Error while serializing request data!", e ); } }
private <T> T deserialize(String content, Class<T> type) { if (type == null) { return null; } try { return MarshallerFactory.getMarshaller(MarshallingFormat.JSON, this.getClass().getClassLoader()).unmarshall(content, type); } catch ( MarshallingException e ) { throw new IllegalStateException( "Error while deserializing data received from server!", e ); } }
protected String serialize(Object object) { if (object == null) { return ""; } try { return marshaller.marshall( object ); } catch ( MarshallingException e ) { throw new RuntimeException( "Error while serializing request data!", e ); } }
private void verifyMarshallingRoundTrip(Marshaller marshaller, Object inputObject) { String rawContent = marshaller.marshall(inputObject); Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall(rawContent, inputObject.getClass()); Assertions.assertThat(inputObject).isEqualTo(testObjectAfterMarshallingTurnAround); }
protected <T> T deserialize(String content, Class<T> type) { logger.debug("About to deserialize content: \n '{}' \n into type: '{}'", content, type); if (content == null || content.isEmpty()) { return null; } try { return marshaller.unmarshall(content, type); } catch ( MarshallingException e ) { throw new KieServicesException( "Error while deserializing data received from server!", e ); } }
Marshaller marshaller = org.opensaml.Configuration .getMarshallerFactory().getMarshaller(logoutRequest); org.w3c.dom.Element authDOM = marshaller.marshall(logoutRequest); StringWriter rspWrt = new StringWriter(); XMLHelper.writeNode(authDOM, rspWrt); System.out.println(rspWrt.toString());
public void disposeMarshallers() { synchronized ( marshallers ) { for ( Marshaller marshaller : this.marshallers.values() ) { marshaller.dispose(); } this.marshallers.clear(); } }
@SuppressWarnings("unchecked") private <V> V marshallUnmarshall(V input) { try { String marshall = marshaller.marshall( input ); System.out.println(marshall); V unmarshall = (V) marshaller.unmarshall(marshall, input.getClass()); return unmarshall; } catch (Exception e) { e.printStackTrace(); throw e; } }
private <T> T deserialize(String content, Class<T> type) { try { return marshaller.unmarshall( content, type ); } catch ( MarshallingException e ) { throw new KieServicesException( "Error while deserializing data received from server!", e ); } }
protected String serialize(Object object) { if (object == null) { return ""; } try { return MarshallerFactory.getMarshaller(MarshallingFormat.JSON, this.getClass().getClassLoader()).marshall(object); } catch ( MarshallingException e ) { throw new IllegalStateException( "Error while serializing request data!", e ); } }
private void verifyMarshallingRoundTrip( Marshaller marshaller, Object inputObject ) { String rawContent = marshaller.marshall( inputObject ); logger.info(rawContent); Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall( rawContent, inputObject.getClass() ); Assertions.assertThat( testObjectAfterMarshallingTurnAround ).isEqualTo( inputObject ); }
protected void loadQueryDefinitions(final InputStream qdStream, final Marshaller marshaller) throws IOException { final String qdString = IOUtils.toString(qdStream, Charset.forName("UTF-8")); try { QueryDefinition[] queries = marshaller.unmarshall(qdString, QueryDefinition[].class); LOGGER.info("Found {} query definitions", queries == null ? 0 : queries.length); if (queries == null) { return; } for (QueryDefinition q : queries) { LOGGER.info("Loaded query definition: {}", q); event.fire(new QueryDefinitionLoaded(q)); } } catch (MarshallingException e) { LOGGER.error("Error when unmarshalling query definitions from stream.", e); } } }
protected String serialize(Object object) { if (object == null) { return ""; } try { return marshaller.marshall( object ); } catch ( MarshallingException e ) { throw new KieServicesException( "Error while serializing request data!", e ); } }
private void verifyMarshallingRoundTrip( Marshaller marshaller, Object inputObject ) { String rawContent = marshaller.marshall( inputObject ); logger.info(rawContent); Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall( rawContent, inputObject.getClass() ); Assertions.assertThat( testObjectAfterMarshallingTurnAround ).isEqualTo( inputObject ); }
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(getExtraClasses(registry), 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; }