You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/03/13 15:28:33 UTC
[10/48] polygene-java git commit: New (de)serialization API and SPI &
new implementations
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueDeserializer.java b/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueDeserializer.java
deleted file mode 100644
index 80d282b..0000000
--- a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueDeserializer.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Collection;
-import java.util.Map;
-import java.util.function.Function;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.api.value.ValueSerializationException;
-import org.apache.polygene.spi.value.ValueDeserializerAdapter;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * ValueDeserializer reading Values from XML documents.
- */
-public class StaxValueDeserializer
- extends ValueDeserializerAdapter<XMLEventReader, Node>
-{
-
- private final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
- private final TransformerFactory transformerFactory = TransformerFactory.newInstance();
-
- public StaxValueDeserializer()
- {
- // Input Factory setup
- inputFactory.setProperty( "javax.xml.stream.isValidating", Boolean.FALSE );
- inputFactory.setProperty( "javax.xml.stream.isNamespaceAware", Boolean.FALSE );
- inputFactory.setProperty( "javax.xml.stream.supportDTD", Boolean.FALSE );
- inputFactory.setProperty( "javax.xml.stream.isCoalescing", Boolean.TRUE );
- inputFactory.setProperty( "javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE );
- }
-
- @Override
- protected XMLEventReader adaptInput( ModuleDescriptor module, InputStream input )
- throws Exception
- {
- return inputFactory.createXMLEventReader( input, "UTF-8" );
- }
-
- @Override
- protected Object readPlainValue( ModuleDescriptor module, XMLEventReader input )
- throws Exception
- {
- if( !input.hasNext() )
- {
- return null;
- }
- XMLEvent nextEvent = input.nextEvent();
- if( nextEvent.getEventType() == XMLEvent.START_ELEMENT
- && "null".equals( nextEvent.asStartElement().getName().getLocalPart() ) )
- {
- input.nextTag();
- return null;
- }
- if( nextEvent.getEventType() != XMLEvent.CHARACTERS )
- {
- throw new ValueSerializationException( "Expected characters but got: " + nextEvent );
- }
- String stringValue = nextEvent.asCharacters().getData();
- return detectAndConvertStringValue( stringValue );
- }
-
- @Override
- protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
- XMLEventReader input,
- Function<XMLEventReader, T> deserializer,
- Collection<T> collection
- )
- throws Exception
- {
- if( !input.hasNext() )
- {
- return null;
- }
- XMLEvent nextTag = input.nextTag();
- if( nextTag.isStartElement() && "null".equals( nextTag.asStartElement().getName().getLocalPart() ) )
- {
- input.nextTag();
- return null;
- }
- if( !nextTag.isStartElement() || !"array".equals( nextTag.asStartElement().getName().getLocalPart() ) )
- {
- throw new ValueSerializationException( "Expected an <array/> but got: " + nextTag );
- }
- WHILE:
- while( input.hasNext() )
- {
- XMLEvent currentTag = input.nextTag();
- if( currentTag.isEndElement() )
- {
- String endElementName = currentTag.asEndElement().getName().getLocalPart();
- switch( endElementName )
- {
- case "array":
- break WHILE;
- case "value":
- continue;
- }
- }
- if( !"value".equals( currentTag.asStartElement().getName().getLocalPart() ) )
- {
- throw new ValueSerializationException( "Expected a <value/> but got: " + currentTag );
- }
- T item = deserializer.apply( input );
- collection.add( item );
- }
- return collection;
- }
-
- @Override
- protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
- XMLEventReader input,
- Function<XMLEventReader, K> keyDeserializer,
- Function<XMLEventReader, V> valueDeserializer,
- Map<K, V> map
- )
- throws Exception
- {
- if( !input.hasNext() )
- {
- return null;
- }
- XMLEvent nextTag = input.nextTag();
- if( nextTag.isStartElement() && "null".equals( nextTag.asStartElement().getName().getLocalPart() ) )
- {
- input.nextTag();
- return null;
- }
- if( !nextTag.isStartElement() || !"array".equals( nextTag.asStartElement().getName().getLocalPart() ) )
- {
- throw new ValueSerializationException( "Expected an <array/> but got: " + nextTag );
- }
- XMLEvent currentTag = input.nextTag(); // <object>
- while( !currentTag.isEndElement() || !"array".equals( currentTag.asEndElement().getName().getLocalPart() ) )
- {
- if( !currentTag.isStartElement() || !"object".equals( currentTag.asStartElement()
- .getName()
- .getLocalPart() ) )
- {
- throw new ValueSerializationException( "Expected an <object/> but got: " + nextTag );
- }
- currentTag = input.nextTag(); // <field>
- K key = null;
- V value = null;
- while( !currentTag.isEndElement() || !"object".equals( currentTag.asEndElement()
- .getName()
- .getLocalPart() ) )
- {
- input.nextTag(); // <name>
- String keyOrValue = input.nextEvent().asCharacters().getData();
- input.nextTag(); // </name>
- input.nextTag(); // <value>
- switch( keyOrValue )
- {
- case "key":
- key = keyDeserializer.apply( input );
- break;
- case "value":
- value = valueDeserializer.apply( input );
- break;
- default:
- readObjectTree( module, input );
- break;
- }
- input.nextTag(); // </value>
- input.nextTag(); // </field>
- currentTag = input.nextTag();
- }
- if( key != null )
- {
- map.put( key, value );
- }
- currentTag = input.nextTag();
- }
- return map;
- }
-
- @Override
- protected Node readObjectTree( ModuleDescriptor module, XMLEventReader input )
- throws Exception
- {
- XMLEvent peek = input.peek();
- if( peek.isStartElement() && "null".equals( peek.asStartElement().getName().getLocalPart() ) )
- {
- input.nextTag();// <null>
- input.nextTag();// </null>
- return null;
- }
- String elementBody = readElementBody( input );
- Transformer transformer = transformerFactory.newTransformer();
- DOMResult domResult = new DOMResult();
- transformer.transform( new StreamSource( new StringReader( elementBody ) ), domResult );
- return ( (Document) domResult.getNode() ).getDocumentElement();
- }
-
- private static String readElementBody( XMLEventReader input )
- throws XMLStreamException
- {
- StringWriter buf = new StringWriter( 1024 );
- int depth = 0;
- while( input.hasNext() )
- {
- // peek event
- XMLEvent xmlEvent = input.peek();
- if( xmlEvent.isStartElement() )
- {
- ++depth;
- }
- else if( xmlEvent.isEndElement() )
- {
- --depth;
- // reached END_ELEMENT tag?
- // break loop, leave event in stream
- if( depth < 0 )
- {
- break;
- }
- }
- // consume event
- xmlEvent = input.nextEvent();
- // print out event
- xmlEvent.writeAsEncodedUnicode( buf );
- }
- return buf.getBuffer().toString();
- }
-
- @Override
- protected Object asSimpleValue( ModuleDescriptor module, Node inputNode )
- throws Exception
- {
- if( inputNode == null )
- {
- return null;
- }
- if( inputNode.getNodeType() == Node.ELEMENT_NODE && "null".equals( inputNode.getLocalName() ) )
- {
- return null;
- }
- if( inputNode.getNodeType() != Node.TEXT_NODE && inputNode.getNodeType() != Node.CDATA_SECTION_NODE )
- {
- throw new ValueSerializationException( "Expected a TEXT or CDATA node but got " + inputNode );
- }
- String stringValue = inputNode.getNodeValue();
- return detectAndConvertStringValue( stringValue );
- }
-
- @Override
- @SuppressWarnings( "SimplifiableIfStatement" )
- protected boolean isObjectValue( ModuleDescriptor module, Node inputNode )
- throws Exception
- {
- if( inputNode == null )
- {
- return false;
- }
- if( "object".equals( inputNode.getLocalName() ) )
- {
- return true;
- }
- if( !"value".equals( inputNode.getLocalName() ) )
- {
- return false;
- }
- return getDirectChildNode( inputNode, "object" ) != null;
- }
-
- @Override
- protected boolean objectHasField( ModuleDescriptor module, Node inputNode, String key )
- throws Exception
- {
- if( inputNode == null )
- {
- return false;
- }
- Node objectNode;
- if( "value".equals( inputNode.getLocalName() ) )
- {
- objectNode = getDirectChildNode( inputNode, "object" );
- }
- else
- {
- objectNode = inputNode;
- }
- if( objectNode == null )
- {
- return false;
- }
- if( !"object".equals( objectNode.getLocalName() ) )
- {
- throw new ValueSerializationException( "Expected an object value but got: " + objectNode );
- }
- return getObjectFieldNode( objectNode, key ) != null;
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected <T> T getObjectFieldValue( ModuleDescriptor module,
- Node inputNode,
- String key,
- Function<Node, T> valueDeserializer
- )
- throws Exception
- {
- if( inputNode == null )
- {
- return null;
- }
- Node objectNode;
- if( "value".equals( inputNode.getLocalName() ) )
- {
- objectNode = getDirectChildNode( inputNode, "object" );
- }
- else
- {
- objectNode = inputNode;
- }
- if( objectNode == null )
- {
- return null;
- }
- if( !"object".equals( objectNode.getLocalName() ) )
- {
- throw new ValueSerializationException( "Expected an object value but got: " + objectNode );
- }
- Node fieldNode = getObjectFieldNode( objectNode, key );
- if( fieldNode == null )
- {
- return null;
- }
- Node valueElement = getDirectChildNode( fieldNode, "value" );
- if( valueElement == null )
- {
- return null;
- }
- Node valueNode = valueElement.getFirstChild();
- if( valueNode == null )
- {
- return (T) "";
- }
- if( valueNode.getNodeType() == Node.ELEMENT_NODE && "null".equals( valueNode.getLocalName() ) )
- {
- return null;
- }
- return valueDeserializer.apply( valueNode );
- }
-
- @Override
- protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
- Node inputNode,
- Function<Node, T> deserializer,
- Collection<T> collection
- )
- throws Exception
- {
- if( inputNode == null )
- {
- return;
- }
- if( !( inputNode instanceof Element ) )
- {
- throw new ValueSerializationException( "Expected an Element but got " + inputNode );
- }
- NodeList arrayValues = inputNode.getChildNodes();
- for( int arrayValuesIndex = 0; arrayValuesIndex < arrayValues.getLength(); arrayValuesIndex++ )
- {
- Node arrayValue = arrayValues.item( arrayValuesIndex );
- T value = deserializer.apply( arrayValue.getFirstChild() );
- collection.add( value );
- }
- }
-
- @Override
- protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
- Node inputNode,
- Function<Node, K> keyDeserializer,
- Function<Node, V> valueDeserializer, Map<K, V> map
- )
- throws Exception
- {
- if( inputNode == null )
- {
- return;
- }
- if( !"array".equals( inputNode.getLocalName() ) )
- {
- throw new ValueSerializationException( "Expected an <array/> but got " + inputNode );
- }
- NodeList entriesNodes = inputNode.getChildNodes();
- for( int idx = 0; idx < entriesNodes.getLength(); idx++ )
- {
- Node entryNode = entriesNodes.item( idx );
- K key = getObjectFieldValue( module, entryNode, "key", keyDeserializer );
- V value = getObjectFieldValue( module, entryNode, "value", valueDeserializer );
- if( key != null )
- {
- map.put( key, value );
- }
- }
- }
-
- @Override
- protected <V> void putObjectNodeInMap( ModuleDescriptor module,
- Node inputNode,
- Function<Node, V> valueDeserializer,
- Map<String, V> map
- )
- throws Exception
- {
- if( inputNode == null )
- {
- return;
- }
- if( !"object".equals( inputNode.getLocalName() ) )
- {
- throw new ValueSerializationException( "Expected an <object/> but got " + inputNode );
- }
- NodeList fieldsNodes = inputNode.getChildNodes();
- for( int idx = 0; idx < fieldsNodes.getLength(); idx++ )
- {
- Node fieldNode = fieldsNodes.item( idx );
- Node node = getDirectChildNode( fieldNode, "name" );
- String key = node != null ? node.getTextContent() : null;
- if( key != null && key.length() > 0 )
- {
- V value = getObjectFieldValue( module, inputNode, key, valueDeserializer );
- map.put( key, value );
- }
- }
- }
-
- @SuppressWarnings( "AssignmentToMethodParameter" )
- private Object detectAndConvertStringValue( String stringValue )
- {
- if( stringValue == null || stringValue.length() == 0 )
- {
- return "";
- }
- stringValue = StringEscapeUtils.unescapeXml( stringValue );
- if( stringValue.matches( "[+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+(\\.\\d+)?)?" ) )
- {
- if( stringValue.indexOf( '.' ) != -1 )
- {
- return new BigDecimal( stringValue );
- }
- return new BigInteger( stringValue );
- }
- if( "true".equalsIgnoreCase( stringValue ) || "false".equalsIgnoreCase( stringValue ) )
- {
- return Boolean.parseBoolean( stringValue );
- }
- return stringValue;
- }
-
- private static Node getObjectFieldNode( Node inputNode, String key )
- {
- if( inputNode == null )
- {
- return null;
- }
- if( !( inputNode instanceof Element ) )
- {
- throw new ValueSerializationException( "Excpected an Element but got " + inputNode );
- }
- NodeList fieldNodes = inputNode.getChildNodes();
- for( int idx = 0; idx < fieldNodes.getLength(); idx++ )
- {
- Node fieldNode = fieldNodes.item( idx );
- Node nameNode = getDirectChildNode( fieldNode, "name" );
- if( nameNode != null && key.equals( nameNode.getTextContent() ) )
- {
- return fieldNode;
- }
- }
- return null;
- }
-
- private static Node getDirectChildNode( Node parent, String name )
- {
- for( Node child = parent.getFirstChild(); child != null; child = child.getNextSibling() )
- {
- if( name.equals( child.getNodeName() ) )
- {
- return child;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializationService.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializationService.java b/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializationService.java
deleted file mode 100644
index 11c752b..0000000
--- a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializationService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.value.ValueSerialization;
-
-/**
- * ValueSerialization Service producing and consuming XML documents.
- */
-@Mixins( { StaxValueSerializer.class, StaxValueDeserializer.class } )
-public interface StaxValueSerializationService
- extends ValueSerialization
-{
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializer.java b/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializer.java
deleted file mode 100644
index ef292d1..0000000
--- a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/StaxValueSerializer.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import java.io.OutputStream;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.apache.polygene.spi.value.ValueSerializerAdapter;
-
-/**
- * ValueSerializer producing Values state as XML documents.
- */
-public class StaxValueSerializer
- extends ValueSerializerAdapter<XMLStreamWriter>
-{
-
- private final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-
- public StaxValueSerializer()
- {
- // Output Factory setup
- outputFactory.setProperty( "javax.xml.stream.isRepairingNamespaces", Boolean.FALSE );
- }
-
- @Override
- protected XMLStreamWriter adaptOutput( OutputStream output )
- throws Exception
- {
- XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter( output, "UTF-8" );
- xmlStreamWriter.writeStartDocument( "utf-8", "1.1" );
- return xmlStreamWriter;
- }
-
- @Override
- protected void onSerializationEnd( Object object, XMLStreamWriter output )
- throws Exception
- {
- output.writeEndDocument();
- output.flush();
- output.close();
- }
-
- @Override
- protected void onArrayStart( XMLStreamWriter output )
- throws Exception
- {
- output.writeStartElement( "array" );
- }
-
- @Override
- protected void onArrayEnd( XMLStreamWriter output )
- throws Exception
- {
- output.writeEndElement();
- }
-
- @Override
- protected void onObjectStart( XMLStreamWriter output )
- throws Exception
- {
- output.writeStartElement( "object" );
- }
-
- @Override
- protected void onObjectEnd( XMLStreamWriter output )
- throws Exception
- {
- output.writeEndElement();
- }
-
- @Override
- protected void onFieldStart( XMLStreamWriter output, String key )
- throws Exception
- {
- output.writeStartElement( "field" );
- output.writeStartElement( "name" );
- output.writeCharacters( key );
- output.writeEndElement();
- }
-
- @Override
- protected void onFieldEnd( XMLStreamWriter output )
- throws Exception
- {
- output.writeEndElement();
- }
-
- @Override
- protected void onValueStart( XMLStreamWriter output )
- throws Exception
- {
- output.writeStartElement( "value" );
- }
-
- @Override
- protected void onValue( XMLStreamWriter output, Object value )
- throws Exception
- {
- if( value == null )
- {
- output.writeStartElement( "null" );
- output.writeEndElement();
- }
- else
- {
- output.writeCharacters( StringEscapeUtils.escapeXml( value.toString() ) );
- }
- }
-
- @Override
- protected void onValueEnd( XMLStreamWriter output )
- throws Exception
- {
- output.writeEndElement();
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/assembly/StaxValueSerializationAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/assembly/StaxValueSerializationAssembler.java b/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/assembly/StaxValueSerializationAssembler.java
deleted file mode 100644
index 8eaede4..0000000
--- a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/assembly/StaxValueSerializationAssembler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax.assembly;
-
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.bootstrap.Assemblers;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.valueserialization.stax.StaxValueSerializationService;
-
-/**
- * Assemble a ValueSerialization Service producing and consuming XML documents.
- */
-public class StaxValueSerializationAssembler
- extends Assemblers.Visibility<StaxValueSerializationAssembler>
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.services( StaxValueSerializationService.class )
- .visibleIn( visibility() )
- .taggedWith( ValueSerialization.Formats.XML );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/package.html
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/package.html b/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/package.html
deleted file mode 100644
index a79d1b0..0000000
--- a/extensions/valueserialization-stax/src/main/java/org/apache/polygene/valueserialization/stax/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>XML StAX Value Serializer.</h2>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxCollectionSerializationTest.java b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxCollectionSerializationTest.java
deleted file mode 100644
index 04ed30a..0000000
--- a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxCollectionSerializationTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import org.apache.polygene.valueserialization.stax.assembly.StaxValueSerializationAssembler;
-import org.junit.BeforeClass;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.value.AbstractCollectionSerializationTest;
-
-import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
-
-public class StaxCollectionSerializationTest
- extends AbstractCollectionSerializationTest
-{
-
- @BeforeClass
- public static void beforeClass_IBMJDK()
- {
- assumeNoIbmJdk();
- }
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- super.assemble( module );
- new StaxValueSerializationAssembler().assemble( module );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxConfigurationDeserializationTest.java b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxConfigurationDeserializationTest.java
deleted file mode 100644
index 052072f..0000000
--- a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxConfigurationDeserializationTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.polygene.valueserialization.stax;
-
-import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.valueserialization.stax.assembly.StaxValueSerializationAssembler;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.value.ValueBuilder;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.entity.AbstractConfigurationDeserializationTest;
-
-@Ignore( "Complex configurations are not yet support in Stax ValueSerialization, due to handling arrays with Java serialization.")
-public class StaxConfigurationDeserializationTest
- extends AbstractConfigurationDeserializationTest
-{
- @Service
- private ValueSerialization valueSerialization;
-
- @Override
- public void assemble( final ModuleAssembly module )
- throws AssemblyException
- {
- super.assemble( module );
- new StaxValueSerializationAssembler()
- .assemble( module );
- }
-
- @Test
- public void serializeTest()
- {
- ValueBuilder<ConfigSerializationConfig> builder = valueBuilderFactory.newValueBuilder( ConfigSerializationConfig.class );
- builder.prototype().name().set( "main" );
- builder.prototype().host().set( createHost() );
- builder.prototype().identity().set( new StringIdentity( "configtest" ) );
- ConfigSerializationConfig value = builder.newInstance();
-
- valueSerialization.serialize( value, System.out );
- }
-
- private Host createHost()
- {
- ValueBuilder<Host> builder = valueBuilderFactory.newValueBuilder( Host.class );
- builder.prototype().ip().set( "12.23.34.45" );
- builder.prototype().port().set( 1234 );
- return builder.newInstance();
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
deleted file mode 100644
index 11f1e7d..0000000
--- a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.value.AbstractPlainValueSerializationTest;
-import org.apache.polygene.valueserialization.stax.assembly.StaxValueSerializationAssembler;
-import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
-
-public class StaxPlainValueSerializationTest
- extends AbstractPlainValueSerializationTest
-{
- @BeforeClass
- public static void beforeClass_IBMJDK()
- {
- assumeNoIbmJdk();
- }
-
- // START SNIPPET: assembly
- @Override
- public void assemble( ModuleAssembly module )
- {
- new StaxValueSerializationAssembler().assemble( module );
- }
- // END SNIPPET: assembly
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxValueCompositeSerializationTest.java b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxValueCompositeSerializationTest.java
deleted file mode 100644
index 65d66f6..0000000
--- a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxValueCompositeSerializationTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.valueserialization.stax;
-
-import org.apache.polygene.valueserialization.stax.assembly.StaxValueSerializationAssembler;
-import org.junit.BeforeClass;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.value.AbstractValueCompositeSerializationTest;
-
-import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
-
-public class StaxValueCompositeSerializationTest
- extends AbstractValueCompositeSerializationTest
-{
-
- @BeforeClass
- public static void beforeClass_IBMJDK()
- {
- assumeNoIbmJdk();
- }
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- super.assemble( module );
- new StaxValueSerializationAssembler().assemble( module );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/extensions/valueserialization-stax/src/test/resources/configtest.xml
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/resources/configtest.xml b/extensions/valueserialization-stax/src/test/resources/configtest.xml
deleted file mode 100644
index e8100ad..0000000
--- a/extensions/valueserialization-stax/src/test/resources/configtest.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-
-<object>
- <field>
- <name>name</name>
- <value>main</value>
- </field>
- <field>
- <name>host</name>
- <value>
- <object>
- <field>
- <name>_type</name>
- <value>org.apache.polygene.test.entity.AbstractConfigurationDeserializationTest$Host</value>
- </field>
- <field>
- <name>port</name>
- <value>1234</value>
- </field>
- <field>
- <name>ip</name>
- <value>12.23.34.45</value>
- </field>
- </object>
- </value>
- </field>
- <field>
- <name>identity</name>
- <value>configtest</value>
- </field>
-</object>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/internals/testsupport-internal/build.gradle
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/build.gradle b/internals/testsupport-internal/build.gradle
index fc70ba0..3878ee0 100644
--- a/internals/testsupport-internal/build.gradle
+++ b/internals/testsupport-internal/build.gradle
@@ -19,10 +19,15 @@
apply plugin: 'polygene-internal'
apply plugin: 'polygene-internal-docker'
+description = "Apache Polygene\u2122 Internal Test Support"
+
+jar { manifest { name = "Apache Polygene\u2122 Internals - Test Support" } }
+
dependencies {
api polygene.core.testsupport
implementation libraries.docker_junit
runtimeOnly polygene.core.runtime
+ runtimeOnly libraries.johnzon // TODO Quid?
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java
----------------------------------------------------------------------
diff --git a/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java b/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java
index 4a4ffc2..3c59c82 100644
--- a/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java
+++ b/libraries/appbrowser/src/test/java/org/apache/polygene/library/appbrowser/AppBrowserTest.java
@@ -31,7 +31,6 @@ import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.mixin.Mixins;
import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.value.ValueSerialization;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
@@ -47,7 +46,6 @@ public class AppBrowserTest extends AbstractPolygeneTest
module.entities( Person.class );
module.values( Age.class );
module.services( MemoryEntityStoreService.class );
- module.importedServices( ValueSerialization.class );
}
@Test
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
index a0d6346..2c526b5 100644
--- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
+++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/ConstraintTest.java
@@ -20,14 +20,14 @@
package org.apache.polygene.library.constraints;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Test;
import org.apache.polygene.api.composite.TransientBuilder;
import org.apache.polygene.api.constraint.ConstraintViolationException;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.junit.Test;
import static org.junit.Assert.fail;
@@ -236,8 +236,8 @@ public class ConstraintTest
{
TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().notEmptyString().set( "X" );
- cb.prototype().notEmptyCollection().set( Arrays.asList( "X" ) );
- cb.prototype().notEmptyList().set( Arrays.asList( "X" ) );
+ cb.prototype().notEmptyCollection().set( Collections.singletonList( "X" ) );
+ cb.prototype().notEmptyList().set( Collections.singletonList( "X" ) );
}
@Test( expected = ConstraintViolationException.class )
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rdf/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/rdf/build.gradle b/libraries/rdf/build.gradle
index c3f175c..50babbe 100644
--- a/libraries/rdf/build.gradle
+++ b/libraries/rdf/build.gradle
@@ -34,7 +34,6 @@ dependencies {
runtimeOnly polygene.core.runtime
testImplementation polygene.core.testsupport
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rdf/src/main/java/org/apache/polygene/library/rdf/entity/EntityStateSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/polygene/library/rdf/entity/EntityStateSerializer.java b/libraries/rdf/src/main/java/org/apache/polygene/library/rdf/entity/EntityStateSerializer.java
index 7477179..0bd823b 100644
--- a/libraries/rdf/src/main/java/org/apache/polygene/library/rdf/entity/EntityStateSerializer.java
+++ b/libraries/rdf/src/main/java/org/apache/polygene/library/rdf/entity/EntityStateSerializer.java
@@ -27,17 +27,15 @@ import org.apache.polygene.api.entity.EntityDescriptor;
import org.apache.polygene.api.entity.EntityReference;
import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.property.PropertyDescriptor;
-import org.apache.polygene.api.service.qualifier.Tagged;
+import org.apache.polygene.api.serialization.Serializer;
import org.apache.polygene.api.type.ValueCompositeType;
import org.apache.polygene.api.type.ValueType;
import org.apache.polygene.api.util.Classes;
import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.api.value.ValueSerializer;
-import org.apache.polygene.api.value.ValueSerializer.Options;
import org.apache.polygene.library.rdf.Rdfs;
import org.apache.polygene.spi.entity.EntityState;
import org.apache.polygene.spi.entity.ManyAssociationState;
+import org.apache.polygene.spi.serialization.JsonSerializer;
import org.openrdf.model.BNode;
import org.openrdf.model.Graph;
import org.openrdf.model.Literal;
@@ -52,10 +50,8 @@ import org.openrdf.model.impl.GraphImpl;
*/
public class EntityStateSerializer
{
-
@Service
- @Tagged( ValueSerialization.Formats.JSON )
- private ValueSerializer valueSerializer;
+ private JsonSerializer serializer;
public URI createEntityURI( ValueFactory valueFactory, EntityReference reference )
{
@@ -87,7 +83,8 @@ public class EntityStateSerializer
graph.add( entityUri,
Rdfs.TYPE,
- values.createURI( Classes.toURI( entityState.entityDescriptor().types().findFirst().orElse( null ) ) ) );
+ values.createURI(
+ Classes.toURI( entityState.entityDescriptor().types().findFirst().orElse( null ) ) ) );
serializeProperties( entityState,
graph,
@@ -108,29 +105,26 @@ public class EntityStateSerializer
includeNonQueryable );
}
- private void serializeProperties( final EntityState entityState,
- final Graph graph,
- final Resource subject,
- final EntityDescriptor entityType,
- final boolean includeNonQueryable
- )
+ private void serializeProperties( EntityState entityState,
+ Graph graph, Resource subject,
+ EntityDescriptor entityType,
+ boolean includeNonQueryable )
{
// Properties
- entityType.state().properties().forEach( persistentProperty -> {
- Object property = entityState.propertyValueOf( persistentProperty.qualifiedName() );
- if( property != null )
+ entityType.state().properties().forEach(
+ persistentProperty ->
{
- serializeProperty( persistentProperty, property, subject, graph, includeNonQueryable );
- }
- } );
+ Object property = entityState.propertyValueOf( persistentProperty.qualifiedName() );
+ if( property != null )
+ {
+ serializeProperty( persistentProperty, property, subject, graph, includeNonQueryable );
+ }
+ } );
}
- private void serializeProperty( PropertyDescriptor persistentProperty,
- Object property,
- Resource subject,
- Graph graph,
- boolean includeNonQueryable
- )
+ private void serializeProperty( PropertyDescriptor persistentProperty, Object property,
+ Resource subject, Graph graph,
+ boolean includeNonQueryable )
{
if( !( includeNonQueryable || persistentProperty.queryable() ) )
{
@@ -152,7 +146,7 @@ public class EntityStateSerializer
}
else
{
- String stringProperty = valueSerializer.serialize( new Options().withoutTypeInfo(), property );
+ String stringProperty = serializer.serialize( Serializer.Options.NO_TYPE_INFO, property );
final Literal object = valueFactory.createLiteral( stringProperty );
graph.add( subject, predicate, object );
}
@@ -170,29 +164,44 @@ public class EntityStateSerializer
BNode collection = valueFactory.createBNode();
graph.add( subject, predicate, collection );
- ( (ValueCompositeType) valueType ).properties().forEach( persistentProperty -> {
- Object propertyValue = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF
- .apply( value )
- .state()
- .propertyFor( persistentProperty.accessor() )
- .get();
-
- if( propertyValue != null )
+ ( (ValueCompositeType) valueType ).properties().forEach(
+ persistentProperty ->
{
- ValueType type = persistentProperty.valueType();
- if( type instanceof ValueCompositeType )
- {
- URI pred = valueFactory.createURI( baseUri, persistentProperty.qualifiedName().name() );
- serializeValueComposite( collection, pred, (ValueComposite) propertyValue, type, graph,
- baseUri + persistentProperty.qualifiedName().name() + "/",
- includeNonQueryable );
- }
- else
+ Object propertyValue
+ = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF
+ .apply( value )
+ .state()
+ .propertyFor( persistentProperty.accessor() )
+ .get();
+
+ if( propertyValue != null )
{
- serializeProperty( persistentProperty, propertyValue, collection, graph, includeNonQueryable );
+ ValueType type = persistentProperty
+ .valueType();
+ if( type instanceof ValueCompositeType )
+ {
+ URI pred = valueFactory.createURI( baseUri,
+ persistentProperty
+ .qualifiedName()
+ .name() );
+ serializeValueComposite( collection, pred,
+ (ValueComposite) propertyValue,
+ type, graph,
+ baseUri
+ + persistentProperty
+ .qualifiedName()
+ .name() + "/",
+ includeNonQueryable );
+ }
+ else
+ {
+ serializeProperty( persistentProperty,
+ propertyValue,
+ collection, graph,
+ includeNonQueryable );
+ }
}
- }
- } );
+ } );
}
private void serializeAssociations( final EntityState entityState,
@@ -204,15 +213,30 @@ public class EntityStateSerializer
ValueFactory values = graph.getValueFactory();
// Associations
- associations.filter( type -> includeNonQueryable || type.queryable() ).forEach( associationType -> {
- EntityReference associatedId = entityState.associationValueOf( associationType.qualifiedName() );
- if( associatedId != null )
+ associations.filter( type -> includeNonQueryable || type.queryable() ).forEach(
+ associationType ->
{
- URI assocURI = values.createURI( associationType.qualifiedName().toURI() );
- URI assocEntityURI = values.createURI( associatedId.toURI() );
- graph.add( entityUri, assocURI, assocEntityURI );
- }
- } );
+ EntityReference associatedId
+ = entityState
+ .associationValueOf(
+ associationType
+ .qualifiedName() );
+ if( associatedId != null )
+ {
+ URI assocURI = values
+ .createURI(
+ associationType
+ .qualifiedName()
+ .toURI() );
+ URI assocEntityURI
+ = values.createURI(
+ associatedId
+ .toURI() );
+ graph.add( entityUri,
+ assocURI,
+ assocEntityURI );
+ }
+ } );
}
private void serializeManyAssociations( final EntityState entityState,
@@ -225,17 +249,37 @@ public class EntityStateSerializer
ValueFactory values = graph.getValueFactory();
// Many-Associations
- associations.filter( type -> includeNonQueryable || type.queryable() ).forEach( associationType -> {
- BNode collection = values.createBNode();
- graph.add( entityUri, values.createURI( associationType.qualifiedName().toURI() ), collection );
- graph.add( collection, Rdfs.TYPE, Rdfs.SEQ );
-
- ManyAssociationState associatedIds = entityState.manyAssociationValueOf( associationType.qualifiedName() );
- for( EntityReference associatedId : associatedIds )
+ associations.filter( type -> includeNonQueryable || type.queryable() ).forEach(
+ associationType ->
{
- URI assocEntityURI = values.createURI( associatedId.toURI() );
- graph.add( collection, Rdfs.LIST_ITEM, assocEntityURI );
- }
- } );
+ BNode collection = values
+ .createBNode();
+ graph.add( entityUri, values
+ .createURI(
+ associationType
+ .qualifiedName()
+ .toURI() ),
+ collection );
+ graph.add( collection,
+ Rdfs.TYPE,
+ Rdfs.SEQ );
+
+ ManyAssociationState
+ associatedIds
+ = entityState
+ .manyAssociationValueOf(
+ associationType
+ .qualifiedName() );
+ for( EntityReference associatedId : associatedIds )
+ {
+ URI assocEntityURI
+ = values.createURI(
+ associatedId
+ .toURI() );
+ graph.add( collection,
+ Rdfs.LIST_ITEM,
+ assocEntityURI );
+ }
+ } );
}
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
index 0ef8475..fb5b0c3 100644
--- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
@@ -22,17 +22,12 @@ package org.apache.polygene.library.rdf.entity;
import java.io.PrintWriter;
import java.time.Instant;
-import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.api.time.SystemTime;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.Statement;
-import org.openrdf.rio.RDFHandlerException;
import org.apache.polygene.api.entity.EntityBuilder;
import org.apache.polygene.api.entity.EntityReference;
+import org.apache.polygene.api.identity.StringIdentity;
import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.injection.scope.Uses;
+import org.apache.polygene.api.time.SystemTime;
import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.polygene.api.usecase.Usecase;
@@ -46,8 +41,12 @@ import org.apache.polygene.library.rdf.serializer.RdfXmlSerializer;
import org.apache.polygene.spi.entity.EntityState;
import org.apache.polygene.spi.entitystore.EntityStore;
import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork;
+import org.apache.polygene.test.AbstractPolygeneTest;
import org.apache.polygene.test.EntityTestAssembler;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.Statement;
+import org.openrdf.rio.RDFHandlerException;
/**
* JAVADOC
@@ -64,7 +63,6 @@ public class EntitySerializerTest
throws AssemblyException
{
new EntityTestAssembler().assemble( module );
- new OrgJsonValueSerializationAssembler().assemble( module );
module.entities( TestEntity.class );
module.values( TestValue.class, Test2Value.class );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/rest-client/build.gradle b/libraries/rest-client/build.gradle
index da6455c..2270e41 100644
--- a/libraries/rest-client/build.gradle
+++ b/libraries/rest-client/build.gradle
@@ -33,7 +33,6 @@ dependencies {
testImplementation polygene.core.testsupport
testImplementation polygene.library( 'rest-server' )
- testImplementation polygene.extension( 'valueserialization-orgjson' )
testRuntimeOnly libraries.logback
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/requestwriter/ValueCompositeRequestWriter.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/requestwriter/ValueCompositeRequestWriter.java b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/requestwriter/ValueCompositeRequestWriter.java
index 90ad77a..8a77d40 100644
--- a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/requestwriter/ValueCompositeRequestWriter.java
+++ b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/requestwriter/ValueCompositeRequestWriter.java
@@ -26,11 +26,11 @@ import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.property.StateHolder;
import org.apache.polygene.api.service.qualifier.Tagged;
+import org.apache.polygene.api.serialization.Serialization;
+import org.apache.polygene.api.serialization.SerializationException;
+import org.apache.polygene.api.serialization.Serializer;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.api.value.ValueDescriptor;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.api.value.ValueSerializationException;
-import org.apache.polygene.api.value.ValueSerializer;
import org.apache.polygene.library.rest.client.spi.RequestWriter;
import org.apache.polygene.spi.PolygeneSPI;
import org.restlet.Request;
@@ -38,7 +38,6 @@ import org.restlet.data.CharacterSet;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Reference;
-import org.restlet.engine.io.WriterOutputStream;
import org.restlet.representation.WriterRepresentation;
import org.restlet.resource.ResourceException;
@@ -52,8 +51,8 @@ public class ValueCompositeRequestWriter
private PolygeneSPI spi;
@Service
- @Tagged( ValueSerialization.Formats.JSON )
- private ValueSerializer valueSerializer;
+ @Tagged( Serialization.Formats.JSON )
+ private Serializer serializer;
@Override
public boolean writeRequest(Object requestObject, Request request) throws ResourceException
@@ -80,11 +79,11 @@ public class ValueCompositeRequestWriter
}
else
{
- param = valueSerializer.serialize( value );
+ param = serializer.serialize( value );
}
ref.addQueryParameter( propertyDescriptor.qualifiedName().name(), param );
}
- catch( ValueSerializationException e )
+ catch( SerializationException e )
{
throw new ResourceException( e );
}
@@ -99,7 +98,7 @@ public class ValueCompositeRequestWriter
throws IOException
{
setCharacterSet( CharacterSet.UTF_8 );
- valueSerializer.serialize( valueObject, new WriterOutputStream( writer, CharacterSet.UTF_8 ) );
+ serializer.serialize( writer, valueObject );
}
});
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/DefaultResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/DefaultResponseReader.java b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/DefaultResponseReader.java
index 6d3111b..ff8060b 100644
--- a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/DefaultResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/DefaultResponseReader.java
@@ -20,10 +20,11 @@
package org.apache.polygene.library.rest.client.responsereader;
-import java.io.IOException;
-import org.json.JSONException;
-import org.json.JSONTokener;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.library.rest.client.spi.ResponseReader;
+import org.apache.polygene.spi.serialization.JsonDeserializer;
import org.restlet.Response;
import org.restlet.data.MediaType;
import org.restlet.resource.ResourceException;
@@ -32,34 +33,31 @@ import org.restlet.resource.ResourceException;
* ResponseReader for simple types from JSON
*/
public class DefaultResponseReader
- implements ResponseReader
+ implements ResponseReader
{
+ @Structure
+ private ModuleDescriptor module;
+
+ @Service
+ private JsonDeserializer jsonDeserializer;
+
@Override
- public Object readResponse(Response response, Class<?> resultType) throws ResourceException
- {
- if (MediaType.APPLICATION_JSON.equals(response.getEntity().getMediaType()))
- if (resultType.equals(String.class))
- {
- try
+ public Object readResponse( Response response, Class<?> resultType ) throws ResourceException
+ {
+ if( MediaType.APPLICATION_JSON.equals( response.getEntity().getMediaType() ) )
+ {
+ if( resultType.equals( String.class ) || Number.class.isAssignableFrom( resultType ) )
{
- return response.getEntity().getText();
- } catch (IOException e)
- {
- throw new ResourceException(e);
+ try
+ {
+ return jsonDeserializer.deserialize( module, resultType, response.getEntityAsText() );
+ }
+ catch( Exception e )
+ {
+ throw new ResourceException( e );
+ }
}
- } else if (Number.class.isAssignableFrom(resultType))
- {
- try
- {
- Number value = (Number) new JSONTokener(response.getEntityAsText()).nextValue();
- if (resultType.equals(Integer.class))
- return Integer.valueOf(value.intValue());
- } catch (JSONException e)
- {
- throw new ResourceException(e);
- }
- }
-
- return null;
- }
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/JSONResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/JSONResponseReader.java b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/JSONResponseReader.java
index 7b8d6a0..335c26b 100644
--- a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/JSONResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/JSONResponseReader.java
@@ -20,18 +20,19 @@
package org.apache.polygene.library.rest.client.responsereader;
-import java.util.Iterator;
+import java.io.IOException;
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonString;
+import javax.json.JsonValue;
import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.injection.scope.Structure;
-import org.apache.polygene.api.service.qualifier.Tagged;
import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.api.type.ValueCompositeType;
import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.api.value.ValueDeserializer;
-import org.apache.polygene.api.value.ValueSerialization;
import org.apache.polygene.library.rest.client.spi.ResponseReader;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.apache.polygene.spi.serialization.JsonDeserializer;
import org.restlet.Response;
import org.restlet.data.Form;
import org.restlet.data.MediaType;
@@ -41,47 +42,50 @@ import org.restlet.resource.ResourceException;
* JAVADOC
*/
public class JSONResponseReader
- implements ResponseReader
+ implements ResponseReader
{
- @Structure
- private ModuleDescriptor module;
+ @Structure
+ private ModuleDescriptor module;
- @Service
- @Tagged( ValueSerialization.Formats.JSON )
- private ValueDeserializer valueDeserializer;
+ @Service
+ private JsonDeserializer jsonDeserializer;
@Override
- public Object readResponse( Response response, Class<?> resultType )
- {
- if (response.getEntity().getMediaType().equals( MediaType.APPLICATION_JSON))
- {
- if (ValueComposite.class.isAssignableFrom( resultType ))
- {
- String jsonValue = response.getEntityAsText();
- ValueCompositeType valueType = module.valueDescriptor( resultType.getName() ).valueType();
- return valueDeserializer.deserialize( module, valueType, jsonValue );
- }
- else if (resultType.equals(Form.class))
- {
- try
+ public Object readResponse( Response response, Class<?> resultType )
+ {
+ if( response.getEntity().getMediaType().equals( MediaType.APPLICATION_JSON ) )
+ {
+ if( ValueComposite.class.isAssignableFrom( resultType ) )
{
- String jsonValue = response.getEntityAsText();
- JSONObject jsonObject = new JSONObject(jsonValue);
- Iterator<?> keys = jsonObject.keys();
- Form form = new Form();
- while (keys.hasNext())
- {
- Object key = keys.next();
- form.set(key.toString(), jsonObject.get(key.toString()).toString());
- }
- return form;
- } catch (JSONException e)
- {
- throw new ResourceException(e);
+ String jsonValue = response.getEntityAsText();
+ ValueCompositeType valueType = module.valueDescriptor( resultType.getName() ).valueType();
+ return jsonDeserializer.deserialize( module, valueType, jsonValue );
}
- }
- }
+ else if( resultType.equals( Form.class ) )
+ {
+ try
+ {
+ JsonObject jsonObject = Json.createReader( response.getEntity().getReader() ).readObject();
+ Form form = new Form();
+ jsonObject.entrySet().forEach(
+ entry ->
+ {
- return null;
- }
+ String key = entry.getKey();
+ JsonValue value = entry.getValue();
+ String valueString = value.getValueType() == JsonValue.ValueType.STRING
+ ? ( (JsonString) value ).getString()
+ : value.toString();
+ form.set( key, valueString );
+ } );
+ return form;
+ }
+ catch( IOException | JsonException e )
+ {
+ throw new ResourceException( e );
+ }
+ }
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/TableResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/TableResponseReader.java b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/TableResponseReader.java
index 4c8ac66..55019a3 100644
--- a/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/TableResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/polygene/library/rest/client/responsereader/TableResponseReader.java
@@ -22,15 +22,19 @@ package org.apache.polygene.library.rest.client.responsereader;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
+import java.util.List;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonString;
+import javax.json.JsonValue;
+import org.apache.polygene.api.injection.scope.Service;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.structure.Module;
import org.apache.polygene.library.rest.client.spi.ResponseReader;
import org.apache.polygene.library.rest.common.table.Table;
import org.apache.polygene.library.rest.common.table.TableBuilder;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.apache.polygene.spi.serialization.JsonDeserializer;
import org.restlet.Response;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
@@ -40,74 +44,75 @@ import org.restlet.resource.ResourceException;
* JAVADOC
*/
public class TableResponseReader
- implements ResponseReader
+ implements ResponseReader
{
- @Structure
- Module module;
+ @Structure
+ private Module module;
- @Override
- public Object readResponse( Response response, Class<?> resultType ) throws ResourceException
- {
- if (response.getEntity().getMediaType().equals( MediaType.APPLICATION_JSON) && Table.class.isAssignableFrom( resultType ))
- {
- String jsonValue = response.getEntityAsText();
- try
- {
- JSONObject jsonObject = new JSONObject(jsonValue);
-
- JSONObject table = jsonObject.getJSONObject( "table" );
- TableBuilder builder = new TableBuilder(module);
+ @Service
+ private JsonDeserializer jsonDeserializer;
- JSONArray cols = table.getJSONArray( "cols" );
- for (int i = 0; i < cols.length(); i++)
+ @Override
+ public Object readResponse( Response response, Class<?> resultType ) throws ResourceException
+ {
+ if( response.getEntity().getMediaType().equals( MediaType.APPLICATION_JSON )
+ && Table.class.isAssignableFrom( resultType ) )
+ {
+ try
{
- JSONObject col = cols.getJSONObject( i );
- builder.column( col.optString( "id" ), col.getString( "label" ), col.getString( "type" ));
- }
+ JsonObject jsonObject = Json.createReader( response.getEntity().getReader() ).readObject();
+ JsonObject table = jsonObject.getJsonObject( "table" );
- JSONArray rows = table.getJSONArray( "rows" );
- for (int i = 0; i < rows.length(); i++)
- {
- builder.row();
- JSONObject row = rows.getJSONObject( i );
- JSONArray cells = row.getJSONArray( "c" );
- for (int j = 0; j < cells.length(); j++)
- {
- JSONObject cell = cells.getJSONObject( j );
- Object value = cell.opt( "v" );
- String formatted = cell.optString("f");
+ TableBuilder builder = new TableBuilder( module );
- if (cols.getJSONObject( j ).getString( "type" ).equals("datetime") && value != null)
- value = ZonedDateTime.parse( value.toString() );
- else if (cols.getJSONObject( j ).getString( "type" ).equals("date") && value != null)
- try
- {
- value = DateTimeFormatter.ofPattern( "yyyy-MM-dd").parse( value.toString() );
- } catch (DateTimeParseException e)
- {
- throw new ResourceException(e);
- }
- else if (cols.getJSONObject( j ).getString( "type" ).equals("timeofday") && value != null)
- try
- {
- value = DateTimeFormatter.ofPattern( "HH:mm:ss").parse( value.toString() );
- } catch (DateTimeParseException e)
- {
- throw new ResourceException(e);
- }
+ JsonArray cols = table.getJsonArray( "cols" );
+ cols.getValuesAs( JsonObject.class ).forEach(
+ col -> builder.column( col.getString( "id", null ),
+ col.getString( "label" ),
+ col.getString( "type" ) ) );
- builder.cell( value, formatted );
- }
- builder.endRow();
+ table.getJsonArray( "rows" ).getValuesAs( JsonObject.class ).forEach(
+ row ->
+ {
+ builder.row();
+ List<JsonObject> cells = row.getJsonArray( "c" ).getValuesAs( JsonObject.class );
+ for( int idx = 0; idx < cells.size(); idx++ )
+ {
+ JsonObject cell = cells.get( idx );
+ JsonValue jsonValue = cell.get( "v" );
+ String formatted = cell.getString( "f", null );
+ String type = cols.getJsonObject( idx ).getString( "type" );
+ Object value;
+ switch( type )
+ {
+ case "datetime":
+ value = ZonedDateTime.parse( ( (JsonString) jsonValue ).getString() );
+ break;
+ case "date":
+ value = DateTimeFormatter.ofPattern( "yyyy-MM-dd" )
+ .parse( ( (JsonString) jsonValue ).getString() );
+ break;
+ case "timeofday":
+ value = DateTimeFormatter.ofPattern( "HH:mm:ss" )
+ .parse( ( (JsonString) jsonValue ).getString() );
+ break;
+ default:
+ value = jsonValue.getValueType() == JsonValue.ValueType.STRING
+ ? ( (JsonString) jsonValue ).getString()
+ : jsonValue.toString();
+ }
+ builder.cell( value, formatted );
+ }
+ builder.endRow();
+ }
+ );
+ return builder.newTable();
}
-
- return builder.newTable();
- } catch (JSONException e)
- {
- throw new ResourceException( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY, e);
- }
- }
-
- return null;
- }
+ catch( Exception e )
+ {
+ throw new ResourceException( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY, e );
+ }
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7c2814ee/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java
index 771cbd6..e979d43 100644
--- a/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/polygene/library/rest/client/ContextResourceClientFactoryTest.java
@@ -26,14 +26,12 @@ import org.apache.polygene.api.common.Optional;
import org.apache.polygene.api.common.UseDefaults;
import org.apache.polygene.api.composite.TransientComposite;
import org.apache.polygene.api.constraint.Name;
-import org.apache.polygene.api.entity.EntityComposite;
import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.Uses;
import org.apache.polygene.api.property.Property;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.api.structure.ApplicationDescriptor;
import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.type.HasTypes;
import org.apache.polygene.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.polygene.api.unitofwork.UnitOfWorkCallback;
import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
@@ -72,7 +70,6 @@ import org.apache.polygene.library.rest.server.restlet.NullCommandResult;
import org.apache.polygene.library.rest.server.spi.CommandResult;
import org.apache.polygene.test.AbstractPolygeneTest;
import org.apache.polygene.test.util.FreePortFinder;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.Assert;
@@ -112,7 +109,6 @@ public class ContextResourceClientFactoryTest
throws AssemblyException
{
// General setup of client and server
- new OrgJsonValueSerializationAssembler().assemble( module );
new ClientAssembler().assemble( module );
new ValueAssembler().assemble( module );
new RestServerAssembler().assemble( module );
@@ -568,12 +564,12 @@ public class ContextResourceClientFactoryTest
public TestResult queryWithValue( TestQuery query )
{
- return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'"+query.abc().get()+"'}" );
+ return vbf.newValueFromSerializedState( TestResult.class, "{\"xyz\":\""+query.abc().get()+"\"}" );
}
public TestResult queryWithoutValue()
{
- return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+ return vbf.newValueFromSerializedState( TestResult.class, "{\"xyz\":\"bar\"}" );
}
public String queryWithStringResult( TestQuery query )
@@ -609,7 +605,7 @@ public class ContextResourceClientFactoryTest
public void beforeCompletion()
throws UnitOfWorkCompletionException
{
- throw new ConcurrentEntityModificationException( Collections.<EntityComposite, HasTypes>emptyMap(),
+ throw new ConcurrentEntityModificationException( Collections.emptyMap(),
UsecaseBuilder.newUsecase( "Testing" ) );
}
@@ -642,7 +638,7 @@ public class ContextResourceClientFactoryTest
public TestResult queryWithValue( TestQuery query )
{
- return module.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+ return module.newValueFromSerializedState( TestResult.class, "{\"xyz\":\"bar\"}" );
}
// Test interaction constraints
@@ -650,7 +646,7 @@ public class ContextResourceClientFactoryTest
@Requires( File.class )
public TestResult queryWithRoleRequirement( TestQuery query )
{
- return module.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+ return module.newValueFromSerializedState( TestResult.class, "{\"xyz\":\"bar\"}" );
}
@Requires( File.class )
@@ -697,7 +693,7 @@ public class ContextResourceClientFactoryTest
public TestResult genericQuery( TestQuery query )
{
- return module.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+ return module.newValueFromSerializedState( TestResult.class, "{\"xyz\":\"bar\"}" );
}
}