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:29:01 UTC
[38/48] polygene-java git commit: Serialization extensions assembly
naming convention for the generator
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackPlainValueSerializationTest.java b/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackPlainValueSerializationTest.java
new file mode 100644
index 0000000..2a0d1b4
--- /dev/null
+++ b/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackPlainValueSerializationTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.serialization.messagepack;
+
+import java.util.Base64;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.serialization.messagepack.assembly.MessagePackSerializationAssembler;
+import org.apache.polygene.test.serialization.AbstractPlainValueSerializationTest;
+import org.msgpack.core.MessagePack;
+
+public class MessagePackPlainValueSerializationTest extends AbstractPlainValueSerializationTest
+{
+ @Override
+ public void assemble( ModuleAssembly module )
+ {
+ new MessagePackSerializationAssembler().withMessagePackSettings( withTestSettings( new MessagePackSettings() ) )
+ .assemble( module );
+ }
+
+ @Override
+ protected String getSingleStringRawState( String state ) throws Exception
+ {
+ return MessagePack.newDefaultUnpacker( Base64.getDecoder().decode( state ) )
+ .unpackValue().asStringValue().asString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackValueCompositeSerializationTest.java b/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackValueCompositeSerializationTest.java
new file mode 100644
index 0000000..b1491f8
--- /dev/null
+++ b/extensions/serialization-messagepack/src/test/java/org/apache/polygene/serialization/messagepack/MessagePackValueCompositeSerializationTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.serialization.messagepack;
+
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.serialization.messagepack.assembly.MessagePackSerializationAssembler;
+import org.apache.polygene.test.serialization.AbstractValueCompositeSerializationTest;
+
+public class MessagePackValueCompositeSerializationTest extends AbstractValueCompositeSerializationTest
+{
+ // START SNIPPET: assembly
+ @Override
+ public void assemble( ModuleAssembly module )
+ {
+ new MessagePackSerializationAssembler().assemble( module );
+ // END SNIPPET: assembly
+ super.assemble( module );
+ // START SNIPPET: assembly
+ }
+ // END SNIPPET: assembly
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/build.gradle b/extensions/serialization-msgpack/build.gradle
deleted file mode 100644
index 6f51948..0000000
--- a/extensions/serialization-msgpack/build.gradle
+++ /dev/null
@@ -1,36 +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.
- */
-
-apply plugin: 'polygene-extension'
-
-description = "Apache Polygene\u2122 MessagePack Serialization Extension"
-
-jar { manifest { name = "Apache Polygene\u2122 Extension - Serialization - MessagePack" } }
-
-dependencies {
- api polygene.core.bootstrap
- api libraries.msgpack
-
- implementation libraries.commons_lang
-
- runtimeOnly polygene.core.runtime
-
- testImplementation polygene.core.testsupport
-
- testRuntimeOnly libraries.logback
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/dev-status.xml
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/dev-status.xml b/extensions/serialization-msgpack/dev-status.xml
deleted file mode 100644
index 8086fb0..0000000
--- a/extensions/serialization-msgpack/dev-status.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ 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.
- ~
- ~
- -->
-<module xmlns="http://polygene.apache.org/schemas/2008/dev-status/1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://polygene.apache.org/schemas/2008/dev-status/1
- http://polygene.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
- <status>
- <!--none,early,beta,stable,mature-->
- <codebase>early</codebase>
-
- <!-- none, brief, good, complete -->
- <documentation>none</documentation>
-
- <!-- none, some, good, complete -->
- <unittests>some</unittests>
- </status>
- <licenses>
- <license>ALv2</license>
- </licenses>
-</module>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/docs/serialization-msgpack.txt
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/docs/serialization-msgpack.txt b/extensions/serialization-msgpack/src/docs/serialization-msgpack.txt
deleted file mode 100644
index 3ae0fa4..0000000
--- a/extensions/serialization-msgpack/src/docs/serialization-msgpack.txt
+++ /dev/null
@@ -1,43 +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.
-///////////////////////////////////////////////////////////////
-
-[[extension-serialization-msgpack,MessagePack serialization]]
-= MessagePack serialization =
-
-[devstatus]
---------------
-source=extensions/serialization-msgpack/dev-status.xml
---------------
-
-`Serialization` service backed by http://msgpack.org/[MessagePack] that produce and consume binary payloads.
-See <<core-api-serialization>> and <<core-spi-serialization>>.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-// TODO Include sample model and its output from test code & resources
-
-== Assembly ==
-
-Assembly is done using the provided Assembler:
-
-[snippet,java]
-----
-source=extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackValueCompositeSerializationTest.java
-tag=assembly
-----
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapter.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapter.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapter.java
deleted file mode 100644
index 5ca8a60..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapter.java
+++ /dev/null
@@ -1,57 +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.serialization.msgpack;
-
-import java.io.IOException;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.polygene.api.type.ValueType;
-import org.msgpack.value.Value;
-
-/**
- * Adapter for MessagePack (de)serialization.
- *
- * @param <T> the adapted type
- */
-public interface MessagePackAdapter<T>
-{
- /**
- * @return the adapted type
- */
- Class<T> type();
-
- /**
- * Serialize.
- *
- * @param object Object to serialize, never null
- * @param serialize Serialization function for nested structure serialization
- * @return MessagePack Value
- */
- Value serialize( Object object, Function<Object, Value> serialize )
- throws IOException;
-
- /**
- * Deserialize.
- *
- * @param value MessagePack value
- * @param deserialize Deserialization function for nested structure deserialization
- * @return Deserialized object
- */
- T deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapters.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapters.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapters.java
deleted file mode 100644
index f87b9cd..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackAdapters.java
+++ /dev/null
@@ -1,269 +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.serialization.msgpack;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.injection.scope.Uses;
-import org.apache.polygene.api.mixin.Initializable;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.serialization.Converters;
-import org.apache.polygene.api.service.ServiceDescriptor;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.spi.serialization.BuiltInConverters;
-import org.msgpack.value.Value;
-import org.msgpack.value.ValueFactory;
-
-import static org.apache.polygene.api.type.HasTypesCollectors.closestType;
-import static org.apache.polygene.serialization.msgpack.MessagePackSettings.orDefault;
-
-@Mixins( MessagePackAdapters.Mixin.class )
-public interface MessagePackAdapters
-{
- void registerAdapter( ValueType valueType, MessagePackAdapter<?> adapter );
-
- <T> MessagePackAdapter<T> adapterFor( ValueType valueType );
-
- default <T> MessagePackAdapter<T> adapterFor( Class<T> type )
- {
- return adapterFor( ValueType.of( type ) );
- }
-
- class Mixin implements MessagePackAdapters, Initializable
- {
- private Map<ValueType, MessagePackAdapter<?>> adapters = new LinkedHashMap<>();
-
- @Uses
- private ServiceDescriptor descriptor;
-
- @This
- private BuiltInConverters builtInConverters;
-
- @This
- private Converters converters;
-
- @Override
- public void initialize()
- {
- MessagePackSettings settings = orDefault( descriptor.metaInfo( MessagePackSettings.class ) );
- settings.getConverters()
- .forEach( ( type, converter ) -> converters.registerConverter( type, converter ) );
- builtInConverters.registerBuiltInConverters( converters );
- settings.getAdapters().forEach( adapters::put );
- registerBaseMessagePackAdapters();
- }
-
- @Override
- public void registerAdapter( ValueType valueType, MessagePackAdapter<?> adapter )
- {
- adapters.put( valueType, adapter );
- }
-
- @Override
- public <T> MessagePackAdapter<T> adapterFor( final ValueType valueType )
- {
- return castAdapter( adapters.keySet().stream()
- .collect( closestType( valueType ) )
- .map( adapters::get )
- .orElse( null ) );
- }
-
- @SuppressWarnings( "unchecked" )
- private <T> MessagePackAdapter<T> castAdapter( MessagePackAdapter<?> adapter )
- {
- return (MessagePackAdapter<T>) adapter;
- }
-
- private void registerBaseMessagePackAdapters()
- {
- // Primitive Value types
- adapters.put( ValueType.STRING, new StringAdapter() );
- adapters.put( ValueType.CHARACTER, new CharacterAdapter() );
- adapters.put( ValueType.BOOLEAN, new BooleanAdapter() );
- adapters.put( ValueType.INTEGER, new IntegerAdapter() );
- adapters.put( ValueType.LONG, new LongAdapter() );
- adapters.put( ValueType.SHORT, new ShortAdapter() );
- adapters.put( ValueType.BYTE, new ByteAdapter() );
- adapters.put( ValueType.FLOAT, new FloatAdapter() );
- adapters.put( ValueType.DOUBLE, new DoubleAdapter() );
- }
-
- private static abstract class ToStringAdapter<T> implements MessagePackAdapter<T>
- {
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newString( object.toString() );
- }
- }
-
- private static class StringAdapter extends ToStringAdapter<String>
- {
- @Override
- public Class<String> type() { return String.class; }
-
- @Override
- public String deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asStringValue().asString();
- }
- }
-
- private static class CharacterAdapter extends ToStringAdapter<Character>
- {
- @Override
- public Class<Character> type() { return Character.class; }
-
- @Override
- public Character deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- String string = value.asStringValue().asString();
- return string.isEmpty() ? null : string.charAt( 0 );
- }
- }
-
- private static class BooleanAdapter implements MessagePackAdapter<Boolean>
- {
- @Override
- public Class<Boolean> type() { return Boolean.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newBoolean( (Boolean) object );
- }
-
- @Override
- public Boolean deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asBooleanValue().getBoolean();
- }
- }
-
- private static class IntegerAdapter implements MessagePackAdapter<Integer>
- {
- @Override
- public Class<Integer> type() { return Integer.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newInteger( (Integer) object );
- }
-
- @Override
- public Integer deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asIntegerValue().asInt();
- }
- }
-
- private static class LongAdapter implements MessagePackAdapter<Long>
- {
- @Override
- public Class<Long> type() { return Long.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newInteger( (Long) object );
- }
-
- @Override
- public Long deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asIntegerValue().asLong();
- }
- }
-
- private static class ShortAdapter implements MessagePackAdapter<Short>
- {
- @Override
- public Class<Short> type() { return Short.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newInteger( (Short) object );
- }
-
- @Override
- public Short deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asIntegerValue().asShort();
- }
- }
-
- private static class ByteAdapter implements MessagePackAdapter<Byte>
- {
- @Override
- public Class<Byte> type() { return Byte.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newInteger( (Byte) object );
- }
-
- @Override
- public Byte deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asIntegerValue().asByte();
- }
- }
-
- private static class FloatAdapter implements MessagePackAdapter<Float>
- {
- @Override
- public Class<Float> type() { return Float.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newFloat( (Float) object );
- }
-
- @Override
- public Float deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asFloatValue().toFloat();
- }
- }
-
- private static class DoubleAdapter implements MessagePackAdapter<Double>
- {
- @Override
- public Class<Double> type() { return Double.class; }
-
- @Override
- public Value serialize( Object object, Function<Object, Value> serialize )
- {
- return ValueFactory.newFloat( (Double) object );
- }
-
- @Override
- public Double deserialize( Value value, BiFunction<Value, ValueType, Object> deserialize )
- {
- return value.asFloatValue().toDouble();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackDeserializer.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackDeserializer.java
deleted file mode 100644
index 9afe450..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackDeserializer.java
+++ /dev/null
@@ -1,313 +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.serialization.msgpack;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Array;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Stream;
-import org.apache.polygene.api.association.AssociationDescriptor;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.property.PropertyDescriptor;
-import org.apache.polygene.api.serialization.Converter;
-import org.apache.polygene.api.serialization.Converters;
-import org.apache.polygene.api.serialization.Deserializer;
-import org.apache.polygene.api.serialization.SerializationException;
-import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.api.type.ArrayType;
-import org.apache.polygene.api.type.CollectionType;
-import org.apache.polygene.api.type.EnumType;
-import org.apache.polygene.api.type.MapType;
-import org.apache.polygene.api.type.ValueCompositeType;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.api.value.ValueBuilder;
-import org.apache.polygene.api.value.ValueDescriptor;
-import org.apache.polygene.spi.serialization.AbstractBinaryDeserializer;
-import org.msgpack.core.MessagePack;
-import org.msgpack.core.MessageUnpacker;
-import org.msgpack.value.ArrayValue;
-import org.msgpack.value.ImmutableValue;
-import org.msgpack.value.MapValue;
-import org.msgpack.value.Value;
-
-import static java.util.Collections.unmodifiableList;
-import static java.util.Collections.unmodifiableMap;
-import static java.util.Collections.unmodifiableSet;
-import static org.apache.polygene.api.util.Collectors.toMap;
-
-@Mixins( MessagePackDeserializer.Mixin.class )
-public interface MessagePackDeserializer extends Deserializer
-{
- class Mixin extends AbstractBinaryDeserializer
- {
- @This
- private Converters converters;
-
- @This
- private MessagePackAdapters adapters;
-
- @Override
- public <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream state )
- {
- MessageUnpacker unpacker = MessagePack.newDefaultUnpacker( state );
- try
- {
- if( !unpacker.hasNext() )
- {
- return null;
- }
- ImmutableValue value = unpacker.unpackValue();
- return doDeserialize( module, valueType, value );
- }
- catch( IOException e )
- {
- throw new SerializationException( "Unable to deserialize " + valueType );
- }
- }
-
- @SuppressWarnings( "unchecked" )
- private <T> T doDeserialize( ModuleDescriptor module, ValueType valueType, Value value )
- {
- try
- {
- if( value == null || value.isNilValue() )
- {
- return null;
- }
- Converter<Object> converter = converters.converterFor( valueType );
- if( converter != null )
- {
- return (T) converter.fromString( doDeserialize( module, ValueType.STRING, value ).toString() );
- }
- MessagePackAdapter<?> adapter = adapters.adapterFor( valueType );
- if( adapter != null )
- {
- return (T) adapter.deserialize( value, ( val, type ) -> doDeserialize( module, valueType, val ) );
- }
- if( EnumType.class.isAssignableFrom( valueType.getClass() ) )
- {
- return (T) Enum.valueOf( (Class) valueType.primaryType(), value.asStringValue().asString() );
- }
- if( ArrayType.class.isAssignableFrom( valueType.getClass() ) )
- {
- return (T) deserializeArray( module, (ArrayType) valueType, value );
- }
- if( CollectionType.class.isAssignableFrom( valueType.getClass() ) )
- {
- return (T) deserializeCollection( module, (CollectionType) valueType, value.asArrayValue() );
- }
- if( MapType.class.isAssignableFrom( valueType.getClass() ) )
- {
- return (T) deserializeMap( module, (MapType) valueType, value.asMapValue() );
- }
- if( ValueCompositeType.class.isAssignableFrom( valueType.getClass() ) )
- {
- return (T) deserializeValueComposite( module, (ValueCompositeType) valueType, value.asMapValue() );
- }
- return (T) doGuessDeserialize( module, valueType, value );
- }
- catch( IOException | ClassNotFoundException ex )
- {
- throw new SerializationException( "Unable to deserialize " + valueType + " from: " + value );
- }
- }
-
- private Object deserializeArray( ModuleDescriptor module, ArrayType arrayType, Value value ) throws IOException
- {
- if( arrayType.isArrayOfPrimitiveBytes() )
- {
- return value.asBinaryValue().asByteArray();
- }
- CollectionType collectionType = CollectionType.listOf( arrayType.collectedType() );
- List collection = (List) deserializeCollection( module, collectionType, value.asArrayValue() );
- Object array = Array.newInstance( arrayType.collectedType().primaryType(), collection.size() );
- for( int idx = 0; idx < collection.size(); idx++ )
- {
- Array.set( array, idx, collection.get( idx ) );
- }
- return array;
- }
-
- private Collection<?> deserializeCollection( ModuleDescriptor module, CollectionType collectionType,
- ArrayValue value ) throws IOException
- {
- Collection<?> collection = collectionType.isSet() ? new LinkedHashSet( value.size() )
- : new ArrayList( value.size() );
- for( Value element : value.list() )
- {
- collection.add( doDeserialize( module, collectionType.collectedType(), element ) );
- }
- return collection;
- }
-
- private Map<Object, Object> deserializeMap( ModuleDescriptor module, MapType mapType, MapValue value )
- throws IOException
- {
- Map<Object, Object> map = new LinkedHashMap<>( value.size() );
- for( Map.Entry<Value, Value> entry : value.entrySet() )
- {
- Object key = doDeserialize( module, mapType.keyType(), entry.getKey() );
- Object val = doDeserialize( module, mapType.valueType(), entry.getValue() );
- map.put( key, val );
- }
- return map;
- }
-
- private Object deserializeValueComposite( ModuleDescriptor module, ValueCompositeType valueType,
- MapValue value ) throws IOException
- {
- Map<String, Value> namedValues = value.map().entrySet().stream().map(
- entry ->
- {
- String key = doDeserialize( module, ValueType.STRING, entry.getKey() );
- return new AbstractMap.SimpleImmutableEntry<>( key, entry.getValue() );
- }
- ).collect( toMap( HashMap::new ) );
-
- String typeInfo = null;
- if( namedValues.containsKey( "_type" ) )
- {
- typeInfo = doDeserialize( module, ValueType.STRING, namedValues.get( "_type" ) );
- }
- if( typeInfo != null )
- {
- ValueDescriptor descriptor = module.valueDescriptor( typeInfo );
- if( descriptor == null )
- {
- throw new SerializationException(
- "_type: " + typeInfo + " could not be resolved while deserializing " + value );
- }
- valueType = descriptor.valueType();
- }
-
- ValueBuilder builder = module.instance().newValueBuilderWithState(
- valueType.primaryType(),
- propertyFunction( module, namedValues ),
- associationFunction( module, namedValues ),
- manyAssociationFunction( module, namedValues ),
- namedAssociationFunction( module, namedValues ) );
- return builder.newInstance();
- }
-
- private Function<PropertyDescriptor, Object> propertyFunction( ModuleDescriptor module,
- Map<String, Value> namedValues )
- {
- return property ->
- {
- Value value = namedValues.get( property.qualifiedName().name() );
- if( value != null )
- {
- Object propertyValue = doDeserialize( module, property.valueType(), value );
- if( property.isImmutable() )
- {
- if( propertyValue instanceof Set )
- {
- return unmodifiableSet( (Set<?>) propertyValue );
- }
- else if( propertyValue instanceof List )
- {
- return unmodifiableList( (List<?>) propertyValue );
- }
- else if( propertyValue instanceof Map )
- {
- return unmodifiableMap( (Map<?, ?>) propertyValue );
- }
- }
- return propertyValue;
- }
- return property.resolveInitialValue( module );
- };
- }
-
- private Function<AssociationDescriptor, EntityReference> associationFunction( ModuleDescriptor module,
- Map<String, Value> namedValues )
- {
- return association -> doDeserialize( module, ValueType.ENTITY_REFERENCE,
- namedValues.get( association.qualifiedName().name() ) );
- }
-
- private Function<AssociationDescriptor, Stream<EntityReference>> manyAssociationFunction(
- ModuleDescriptor module, Map<String, Value> namedValues )
- {
- return association ->
- {
- List list = doDeserialize( module, ENTITY_REF_LIST_VALUE_TYPE,
- namedValues.get( association.qualifiedName().name() ) );
- return list == null ? Stream.empty() : list.stream();
- };
- }
-
- private Function<AssociationDescriptor, Stream<Map.Entry<String, EntityReference>>> namedAssociationFunction(
- ModuleDescriptor module, Map<String, Value> namedValues )
- {
- return association ->
- {
- Map map = doDeserialize( module, ENTITY_REF_MAP_VALUE_TYPE,
- namedValues.get( association.qualifiedName().name() ) );
- return map == null ? Stream.empty() : map.entrySet().stream();
- };
- }
-
- private Object doGuessDeserialize( ModuleDescriptor module, ValueType valueType, Value value )
- throws IOException, ClassNotFoundException
- {
- switch( value.getValueType() )
- {
- case BINARY:
- return deserializeJava( value.asBinaryValue().asByteArray() );
- case MAP:
- MapValue mapValue = value.asMapValue();
- Optional<String> typeInfo = mapValue
- .entrySet().stream()
- .filter( entry -> entry.getKey().isStringValue() )
- .map( entry ->
- {
- String key = doDeserialize( module, ValueType.STRING, entry.getKey() );
- return new AbstractMap.SimpleImmutableEntry<>( key, entry.getValue() );
- } )
- .filter( entry -> "_type".equals( entry.getKey() ) )
- .findFirst()
- .map( entry -> doDeserialize( module, ValueType.STRING, entry.getValue() ) );
- if( typeInfo.isPresent() )
- {
- ValueDescriptor valueDescriptor = module.valueDescriptor( typeInfo.get() );
- if( valueDescriptor != null )
- {
- return deserializeValueComposite( module, valueDescriptor.valueType(), mapValue );
- }
- }
- default:
- throw new SerializationException( "Don't know how to deserialize " + valueType + " from " + value
- + " (" + value.getValueType() + ")" );
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerialization.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerialization.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerialization.java
deleted file mode 100644
index d24d597..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerialization.java
+++ /dev/null
@@ -1,22 +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.serialization.msgpack;
-
-public interface MessagePackSerialization extends MessagePackSerializer, MessagePackDeserializer
-{
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializationAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializationAssembler.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializationAssembler.java
deleted file mode 100644
index 1a576ce..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializationAssembler.java
+++ /dev/null
@@ -1,52 +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.serialization.msgpack;
-
-import org.apache.polygene.api.serialization.Deserializer;
-import org.apache.polygene.api.serialization.Serialization;
-import org.apache.polygene.api.serialization.Serializer;
-import org.apache.polygene.bootstrap.Assemblers;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.bootstrap.ServiceDeclaration;
-
-public class MessagePackSerializationAssembler extends Assemblers.VisibilityIdentity<MessagePackSerializationAssembler>
-{
- private MessagePackSettings settings;
-
- public MessagePackSerializationAssembler withMessagePackSettings( MessagePackSettings settings )
- {
- this.settings = settings;
- return this;
- }
-
- @Override
- public void assemble( ModuleAssembly module )
- {
- ServiceDeclaration declaration = module.services( MessagePackSerialization.class )
- .withTypes( Serialization.class, Serializer.class, Deserializer.class )
- .visibleIn( visibility() );
- if( hasIdentity() )
- {
- declaration.identifiedBy( identity() );
- }
- if( settings != null )
- {
- declaration.setMetaInfo( settings );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializer.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializer.java
deleted file mode 100644
index cdbbf5a..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSerializer.java
+++ /dev/null
@@ -1,202 +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.serialization.msgpack;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Map;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-import org.apache.polygene.api.PolygeneAPI;
-import org.apache.polygene.api.association.AssociationStateHolder;
-import org.apache.polygene.api.common.Optional;
-import org.apache.polygene.api.composite.CompositeInstance;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.serialization.Converter;
-import org.apache.polygene.api.serialization.Converters;
-import org.apache.polygene.api.serialization.SerializationException;
-import org.apache.polygene.api.serialization.Serializer;
-import org.apache.polygene.api.type.ArrayType;
-import org.apache.polygene.api.type.EnumType;
-import org.apache.polygene.api.type.MapType;
-import org.apache.polygene.api.type.ValueCompositeType;
-import org.apache.polygene.api.util.ArrayIterable;
-import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.api.value.ValueDescriptor;
-import org.apache.polygene.spi.serialization.AbstractBinarySerializer;
-import org.msgpack.core.MessagePack;
-import org.msgpack.core.MessagePacker;
-import org.msgpack.value.ArrayValue;
-import org.msgpack.value.MapValue;
-import org.msgpack.value.Value;
-import org.msgpack.value.ValueFactory;
-
-import static java.util.stream.Collectors.toList;
-import static org.apache.polygene.api.util.Collectors.toMap;
-
-@Mixins( MessagePackSerializer.Mixin.class )
-public interface MessagePackSerializer extends Serializer
-{
- class Mixin extends AbstractBinarySerializer
- {
- @This
- private Converters converters;
-
- @This
- private MessagePackAdapters adapters;
-
- @Override
- public void serialize( Options options, OutputStream output, @Optional Object object )
- {
- MessagePacker packer = MessagePack.newDefaultPacker( output );
- Value value = doSerialize( options, object, true );
- try
- {
- packer.packValue( value );
- packer.flush();
- }
- catch( IOException ex )
- {
- throw new SerializationException( "Unable to serialize " + object, ex );
- }
- }
-
- private Value doSerialize( Options options, Object object, boolean root )
- {
- try
- {
- if( object == null )
- {
- return ValueFactory.newNil();
- }
- Class<?> objectClass = object.getClass();
- Converter<Object> converter = converters.converterFor( objectClass );
- if( converter != null )
- {
- return doSerialize( options, converter.toString( object ), false );
- }
- MessagePackAdapter<?> adapter = adapters.adapterFor( objectClass );
- if( adapter != null )
- {
- return adapter.serialize( object, obj -> doSerialize( options, obj, false ) );
- }
- if( EnumType.isEnum( objectClass ) )
- {
- return ValueFactory.newString( object.toString() );
- }
- if( ValueCompositeType.isValueComposite( objectClass ) )
- {
- return serializeValueComposite( options, object, root );
- }
- if( MapType.isMap( objectClass ) )
- {
- return serializeMap( options, (Map<?, ?>) object );
- }
- if( ArrayType.isArray( objectClass ) )
- {
- return serializeArray( options, object );
- }
- if( Iterable.class.isAssignableFrom( objectClass ) )
- {
- return serializeIterable( options, (Iterable<?>) object );
- }
- if( Stream.class.isAssignableFrom( objectClass ) )
- {
- return serializeStream( options, (Stream<?>) object );
- }
- // Fallback to Java Serialization
- return ValueFactory.newBinary( serializeJava( object ) );
- }
- catch( IOException ex )
- {
- throw new SerializationException( "Unable to serialize " + object, ex );
- }
- }
-
- private MapValue serializeValueComposite( Options options, Object composite, boolean root )
- {
- CompositeInstance instance = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( (ValueComposite) composite );
- ValueDescriptor descriptor = (ValueDescriptor) instance.descriptor();
- AssociationStateHolder state = (AssociationStateHolder) instance.state();
- ValueCompositeType valueType = descriptor.valueType();
-
- ValueFactory.MapBuilder builder = ValueFactory.newMapBuilder();
- valueType.properties().forEach(
- property -> builder.put(
- ValueFactory.newString( property.qualifiedName().name() ),
- doSerialize( options, state.propertyFor( property.accessor() ).get(), false ) ) );
- valueType.associations().forEach(
- association -> builder.put(
- ValueFactory.newString( association.qualifiedName().name() ),
- doSerialize( options, state.associationFor( association.accessor() ).reference(), false ) ) );
- valueType.manyAssociations().forEach(
- association -> builder.put(
- ValueFactory.newString( association.qualifiedName().name() ),
- doSerialize( options,
- state.manyAssociationFor( association.accessor() ).references().collect( toList() ),
- false ) ) );
- valueType.namedAssociations().forEach(
- association -> builder.put(
- ValueFactory.newString( association.qualifiedName().name() ),
- doSerialize( options,
- state.namedAssociationFor( association.accessor() ).references().collect( toMap() ),
- false ) ) );
-
- if( !root && options.includeTypeInfo() )
- {
- builder.put( ValueFactory.newString( "_type" ),
- ValueFactory.newString( valueType.primaryType().getName() ) );
- }
- return builder.build();
- }
-
- private MapValue serializeMap( Options options, Map<?, ?> map )
- {
- ValueFactory.MapBuilder builder = ValueFactory.newMapBuilder();
- map.forEach( ( key, value ) -> builder.put( doSerialize( options, key, false ),
- doSerialize( options, value, false ) ) );
- return builder.build();
- }
-
- private Value serializeArray( Options options, Object object )
- {
- ArrayType valueType = ArrayType.of( object.getClass() );
- if( valueType.isArrayOfPrimitiveBytes() )
- {
- return ValueFactory.newBinary( (byte[]) object );
- }
- if( valueType.isArrayOfPrimitives() )
- {
- return serializeIterable( options, new ArrayIterable( object ) );
- }
- return serializeStream( options, Stream.of( (Object[]) object ) );
- }
-
- private ArrayValue serializeIterable( Options options, Iterable<?> iterable )
- {
- return serializeStream( options, StreamSupport.stream( iterable.spliterator(), false ) );
- }
-
- private ArrayValue serializeStream( Options options, Stream<?> stream )
- {
- return ValueFactory.newArray( stream.map( element -> doSerialize( options, element, false ) )
- .collect( toList() ) );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSettings.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSettings.java b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSettings.java
deleted file mode 100644
index e3fbf26..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/MessagePackSettings.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.serialization.msgpack;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.spi.serialization.SerializationSettings;
-
-public class MessagePackSettings extends SerializationSettings<MessagePackSettings>
-{
- public static final MessagePackSettings DEFAULT = new MessagePackSettings();
-
- public static MessagePackSettings orDefault( MessagePackSettings settings )
- {
- return settings != null ? settings : DEFAULT;
- }
-
- private Map<ValueType, MessagePackAdapter<?>> adapters;
-
- public MessagePackSettings()
- {
- adapters = new LinkedHashMap<>();
- }
-
- public Map<ValueType, MessagePackAdapter<?>> getAdapters()
- {
- return adapters;
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/package.html
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/package.html b/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/package.html
deleted file mode 100644
index 16c905a..0000000
--- a/extensions/serialization-msgpack/src/main/java/org/apache/polygene/serialization/msgpack/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>MessagePack Serialization.</h2>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackCollectionSerializationTest.java b/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackCollectionSerializationTest.java
deleted file mode 100644
index 6ade37f..0000000
--- a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackCollectionSerializationTest.java
+++ /dev/null
@@ -1,31 +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.serialization.msgpack;
-
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.serialization.AbstractCollectionSerializationTest;
-
-public class MessagePackCollectionSerializationTest extends AbstractCollectionSerializationTest
-{
- @Override
- public void assemble( ModuleAssembly module )
- {
- new MessagePackSerializationAssembler().assemble( module );
- super.assemble( module );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackPlainValueSerializationTest.java b/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackPlainValueSerializationTest.java
deleted file mode 100644
index 6714527..0000000
--- a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackPlainValueSerializationTest.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.serialization.msgpack;
-
-import java.util.Base64;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.serialization.AbstractPlainValueSerializationTest;
-import org.msgpack.core.MessagePack;
-
-public class MessagePackPlainValueSerializationTest extends AbstractPlainValueSerializationTest
-{
- @Override
- public void assemble( ModuleAssembly module )
- {
- new MessagePackSerializationAssembler().withMessagePackSettings( withTestSettings( new MessagePackSettings() ) )
- .assemble( module );
- }
-
- @Override
- protected String getSingleStringRawState( String state ) throws Exception
- {
- return MessagePack.newDefaultUnpacker( Base64.getDecoder().decode( state ) )
- .unpackValue().asStringValue().asString();
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackValueCompositeSerializationTest.java b/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackValueCompositeSerializationTest.java
deleted file mode 100644
index dd9291e..0000000
--- a/extensions/serialization-msgpack/src/test/java/org/apache/polygene/serialization/msgpack/MessagePackValueCompositeSerializationTest.java
+++ /dev/null
@@ -1,35 +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.serialization.msgpack;
-
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.test.serialization.AbstractValueCompositeSerializationTest;
-
-public class MessagePackValueCompositeSerializationTest extends AbstractValueCompositeSerializationTest
-{
- // START SNIPPET: assembly
- @Override
- public void assemble( ModuleAssembly module )
- {
- new MessagePackSerializationAssembler().assemble( module );
- // END SNIPPET: assembly
- super.assemble( module );
- // START SNIPPET: assembly
- }
- // END SNIPPET: assembly
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/manual/src/docs/userguide/extensions.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/userguide/extensions.txt b/manual/src/docs/userguide/extensions.txt
index 42f216e..433bd47 100644
--- a/manual/src/docs/userguide/extensions.txt
+++ b/manual/src/docs/userguide/extensions.txt
@@ -53,7 +53,7 @@ include::../../../../extensions/serialization-javaxxml/src/docs/serialization-ja
:leveloffset: 2
-include::../../../../extensions/serialization-msgpack/src/docs/serialization-msgpack.txt[]
+include::../../../../extensions/serialization-messagepack/src/docs/serialization-messagepack.txt[]
:leveloffset: 2
@@ -140,4 +140,3 @@ include::../../../../extensions/migration/src/docs/migration.txt[]
include::../../../../extensions/reindexer/src/docs/reindexer.txt[]
:leveloffset: 2
-
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index e0b6b7d..d63bdb6 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -78,7 +78,7 @@ include 'core:api',
'extensions:reindexer',
'extensions:serialization-javaxjson',
'extensions:serialization-javaxxml',
- 'extensions:serialization-msgpack',
+ 'extensions:serialization-messagepack',
'tools:model-detail',
'tools:envisage',
// 'tools:generator-polygene',
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/tools/generator-polygene/app/index.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js
index a0631e5..158f4e3 100644
--- a/tools/generator-polygene/app/index.js
+++ b/tools/generator-polygene/app/index.js
@@ -152,10 +152,11 @@ module.exports = generators.Base.extend(
name: 'serialization',
choices: [
'JavaxJson',
- 'JavaxXml'
+ 'JavaxXml',
+ 'MessagePack'
],
message: 'Which serialization system do you want to use?',
- default: polygene.serialization ? polygene.serialization : "Jackson"
+ default: polygene.serialization ? polygene.serialization : "JavaxJson"
},
{
type: 'list',
@@ -399,4 +400,4 @@ function assignFunctions(polygene) {
current.imported = imported;
};
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5c429014/tools/generator-polygene/test/generator_test.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/test/generator_test.js b/tools/generator-polygene/test/generator_test.js
index 0d0b938..e9ddd17 100644
--- a/tools/generator-polygene/test/generator_test.js
+++ b/tools/generator-polygene/test/generator_test.js
@@ -39,7 +39,8 @@ var cachings = [
var serializations = [
'JavaxJson',
- 'JavaxXml'
+ 'JavaxXml',
+ 'MessagePack'
];
var metricses = [
@@ -124,4 +125,4 @@ function test(entityStore, indexing, serialization, caching, metrics, features)
function buildAndVerify(dir) {
assert.file(['gradlew', 'settings.gradle', 'build.gradle']);
assert(shell.exec(path.join(dir, 'gradlew') + ' build').code == 0);
-}
\ No newline at end of file
+}