polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [1/4] zest-java git commit: ZEST-111; First commit to the Restful Library.
Date Sun, 02 Aug 2015 10:39:53 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop a944b2f79 -> f5bf22db8


http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/FormRepresentation.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/FormRepresentation.java
b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/FormRepresentation.java
new file mode 100644
index 0000000..9572c63
--- /dev/null
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/FormRepresentation.java
@@ -0,0 +1,157 @@
+/*
+ * 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.zest.library.restlet.serialization;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.zest.api.association.AssociationStateHolder;
+import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.injection.scope.Uses;
+import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
+import org.apache.zest.api.value.ValueComposite;
+import org.apache.zest.api.value.ValueDescriptor;
+import org.apache.zest.functional.Function;
+import org.apache.zest.spi.ZestSPI;
+import org.restlet.data.Form;
+import org.restlet.data.MediaType;
+import org.restlet.representation.OutputRepresentation;
+import org.restlet.representation.Representation;
+
+/**
+ * Representation based of Zest ValueComposites. It can serialize and deserialize
+ * automatically in JSON only.<br>
+ * <br>
+ */
+public class FormRepresentation<T> extends OutputRepresentation
+{
+    @Structure
+    private ZestSPI spi;
+
+    @Structure
+    private ValueBuilderFactory vbf;
+
+    /**
+     * The (parsed) object to format.
+     */
+    @Optional
+    private volatile T object;
+
+    /**
+     * The object class to instantiate.
+     */
+    @Optional
+    @Uses
+    private volatile Class<T> objectClass;
+
+    /**
+     * The representation to parse.
+     */
+    @Optional
+    @Uses
+    private volatile Representation representation;
+
+    public FormRepresentation()
+    {
+        super( MediaType.APPLICATION_WWW_FORM );
+    }
+
+    private T createObject()
+    {
+        //noinspection MismatchedQueryAndUpdateOfCollection
+        final Form form = new Form( representation );
+        ValueBuilder<T> builder = this.vbf.newValueBuilderWithState(
+            objectClass,
+            new Function<PropertyDescriptor, Object>()
+            {
+                @Override
+                public Object map( PropertyDescriptor descriptor )
+                {
+                    return form.getFirstValue( descriptor.qualifiedName().name() );
+                }
+            },
+            descriptor -> null,
+            descriptor -> null,
+            descriptor -> null
+        );
+        return builder.newInstance();
+    }
+
+    /**
+     * Returns the wrapped object, deserializing the representation with Zest
+     * if necessary.
+     *
+     * @return The wrapped object.
+     *
+     * @throws IOException
+     */
+    public T getObject()
+        throws IOException
+    {
+        if( object == null )
+        {
+            object = createObject();
+        }
+        return object;
+    }
+
+    /**
+     * Returns the object class to instantiate.
+     *
+     * @return The object class to instantiate.
+     */
+    public Class<T> getObjectClass()
+    {
+        return objectClass;
+    }
+
+    @Override
+    public void write( OutputStream outputStream )
+        throws IOException
+    {
+        if( representation != null )
+        {
+            representation.write( outputStream );
+        }
+        else if( object != null )
+        {
+            AssociationStateHolder state = spi.stateOf( (ValueComposite) object );
+            ValueDescriptor descriptor = (ValueDescriptor) spi.modelDescriptorFor( object
);
+            descriptor.state().properties().forEach( property -> {
+                String name = property.qualifiedName().name();
+                String value = state.propertyFor( property.accessor() ).get().toString();
+                try
+                {
+                    outputStream.write( name.getBytes( "UTF-8" ) );
+                    outputStream.write( "=".getBytes( "UTF-8" ) );
+                    outputStream.write( value.getBytes( "UTF-8" ) );
+                    outputStream.write( '\n' );
+                }
+                catch( IOException e )
+                {
+                    // TODO; not sure what could happen here.
+                }
+            } );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
new file mode 100644
index 0000000..ba6e9aa
--- /dev/null
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
@@ -0,0 +1,126 @@
+/*
+ * 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.zest.library.restlet.serialization;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.injection.scope.Uses;
+import org.apache.zest.api.value.ValueSerialization;
+import org.apache.zest.api.value.ValueSerializer;
+import org.apache.zest.spi.ZestSPI;
+import org.restlet.data.MediaType;
+import org.restlet.representation.OutputRepresentation;
+import org.restlet.representation.Representation;
+
+/**
+ * Representation based of Zest ValueComposites. It can serialize and deserialize
+ * automatically in JSON only.<br>
+ * <br>
+ */
+public class JsonRepresentation<T> extends OutputRepresentation
+{
+
+    private static final ValueSerializer.Options OPTIONS_NO_TYPE = new ValueSerializer.Options().withoutTypeInfo().withMapEntriesAsObjects();
+
+    @Structure
+    private ZestSPI spi;
+
+    @Service
+    private ValueSerialization serializer;
+
+    /**
+     * The (parsed) object to format.
+     */
+    @Optional
+    @Uses
+    private volatile T object;
+
+    /**
+     * The object class to instantiate.
+     */
+    @Optional
+    @Uses
+    private volatile Class<T> objectClass;
+
+    /**
+     * The representation to parse.
+     */
+    @Optional
+    @Uses
+    private volatile Representation representation;
+
+    public JsonRepresentation()
+    {
+        super( MediaType.APPLICATION_JSON );
+    }
+
+    /**
+     * Returns the wrapped object, deserializing the representation with Zest
+     * if necessary.
+     *
+     * @return The wrapped object.
+     *
+     * @throws IOException
+     */
+    public T getObject()
+        throws IOException
+    {
+        T result = null;
+
+        if( this.object != null )
+        {
+            result = this.object;
+        }
+        else if( this.representation != null )
+        {
+            result = serializer.deserialize( objectClass, this.representation.getStream()
);
+        }
+        return result;
+    }
+
+    /**
+     * Returns the object class to instantiate.
+     *
+     * @return The object class to instantiate.
+     */
+    public Class<T> getObjectClass()
+    {
+        return objectClass;
+    }
+
+    @Override
+    public void write( OutputStream outputStream )
+        throws IOException
+    {
+        if( representation != null )
+        {
+            representation.write( outputStream );
+        }
+        else if( object != null )
+        {
+            serializer.serialize( OPTIONS_NO_TYPE, object, outputStream );
+            outputStream.write( '\n' );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/ZestConverter.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/ZestConverter.java
b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/ZestConverter.java
new file mode 100644
index 0000000..ae98cac
--- /dev/null
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/ZestConverter.java
@@ -0,0 +1,268 @@
+/*
+ * 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.zest.library.restlet.serialization;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.object.ObjectFactory;
+import org.apache.zest.spi.ZestSPI;
+import org.restlet.data.MediaType;
+import org.restlet.data.Preference;
+import org.restlet.engine.converter.ConverterHelper;
+import org.restlet.engine.resource.VariantInfo;
+import org.restlet.representation.Representation;
+import org.restlet.representation.Variant;
+import org.restlet.resource.Resource;
+
+/**
+ * Converter between Apache Zest and JSON.
+ */
+public class ZestConverter extends ConverterHelper
+{
+    @Structure
+    private ZestSPI spi;
+
+    /**
+     * Variant with media type application/json.
+     */
+    private static final VariantInfo VARIANT_JSON = new VariantInfo( MediaType.APPLICATION_JSON
);
+    private static final VariantInfo VARIANT_WWW_FORM_URLENCODED = new VariantInfo( MediaType.APPLICATION_WWW_FORM
);
+
+    private final ObjectFactory objectFactory;
+
+    public ZestConverter( ObjectFactory objectFactory )
+    {
+        this.objectFactory = objectFactory;
+    }
+
+    /**
+     * Creates the marshaling {@link JsonRepresentation}.
+     *
+     * @param mediaType The target media type.
+     * @param source    The source object to marshal.
+     *
+     * @return The marshaling {@link JsonRepresentation}.
+     */
+    protected <T> Representation create( MediaType mediaType, T source )
+    {
+        //noinspection unchecked
+        return objectFactory.newObject( JsonRepresentation.class, source );
+    }
+
+    /**
+     * Creates the unmarshaling {@link JsonRepresentation}.
+     *
+     * @param source      The source representation to unmarshal.
+     * @param objectClass The object class to instantiate.
+     *
+     * @return The unmarshaling {@link JsonRepresentation}.
+     */
+    protected <T> Representation create( Representation source, Class<T> objectClass
)
+    {
+        if( VARIANT_WWW_FORM_URLENCODED.isCompatible( source ) )
+        {
+            return objectFactory.newObject( FormRepresentation.class, source, objectClass
);
+        }
+        else if( VARIANT_WWW_FORM_URLENCODED.isCompatible( source ) )
+        {
+            //noinspection unchecked
+            return objectFactory.newObject( JsonRepresentation.class, source, objectClass
);
+        }
+        return null;
+    }
+
+    public ObjectFactory getObjectFactory()
+    {
+        return objectFactory;
+    }
+
+    @Override
+    public List<Class<?>> getObjectClasses( Variant source )
+    {
+        List<Class<?>> result = new ArrayList<>();
+
+        if( isCompatible( source ) )
+        {
+            result = addObjectClass( result, Object.class );
+            result = addObjectClass( result, JsonRepresentation.class );
+        }
+
+        return result;
+    }
+
+    @Override
+    public List<VariantInfo> getVariants( Class<?> source )
+    {
+        List<VariantInfo> result = new ArrayList<>();
+
+        if( source != null )
+        {
+            result = addVariant( result, VARIANT_JSON );
+            result = addVariant( result, VARIANT_WWW_FORM_URLENCODED );
+        }
+
+        return result;
+    }
+
+    /**
+     * Indicates if the given variant is compatible with the media types
+     * supported by this converter.
+     *
+     * @param variant The variant.
+     *
+     * @return True if the given variant is compatible with the media types
+     * supported by this converter.
+     */
+    protected boolean isCompatible( Variant variant )
+    {
+        //noinspection SimplifiableIfStatement
+        if( variant == null )
+        {
+            return false;
+        }
+
+        return VARIANT_JSON.isCompatible( variant ) ||
+               VARIANT_WWW_FORM_URLENCODED.isCompatible( variant )
+            ;
+    }
+
+    @Override
+    public float score( Object source, Variant target, Resource resource )
+    {
+        float result;
+
+        if( source instanceof JsonRepresentation<?> )
+        {
+            result = 1.0F;
+        }
+        else
+        {
+            if( target == null )
+            {
+                result = 0.5F;
+            }
+            else if( isCompatible( target ) )
+            {
+                result = 0.8F;
+            }
+            else
+            {
+                result = 0.5F;
+            }
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T> float score( Representation source, Class<T> target,
+                            Resource resource
+    )
+    {
+        float result = -1.0F;
+
+        if( source instanceof JsonRepresentation<?> )
+        {
+            result = 1.0F;
+        }
+        else if( ( target != null )
+                 && JsonRepresentation.class.isAssignableFrom( target ) )
+        {
+            result = 1.0F;
+        }
+        else if( isCompatible( source ) )
+        {
+            result = 0.8F;
+        }
+
+        return result;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public <T> T toObject( Representation source, Class<T> target, Resource resources
)
+        throws IOException
+    {
+        Object result = null;
+
+        Representation representation = null;
+        if( isCompatible( source ) )
+        {
+            representation = create( source, target );
+        }
+
+        if( representation != null )
+        {
+            // Handle the conversion
+            if( ( target != null )
+                && JsonRepresentation.class.isAssignableFrom( target ) )
+            {
+                result = representation;
+            }
+            else
+            {
+                if( representation instanceof JsonRepresentation )
+                {
+                    result = ( (JsonRepresentation) representation ).getObject();
+                }
+                if( representation instanceof FormRepresentation )
+                {
+                    result = ( (FormRepresentation) representation ).getObject();
+                }
+            }
+        }
+
+        return (T) result;
+    }
+
+    @Override
+    public Representation toRepresentation( Object source, Variant target, Resource resource
)
+    {
+        Representation result = null;
+
+        if( source instanceof JsonRepresentation )
+        {
+            result = (JsonRepresentation<?>) source;
+        }
+        else
+        {
+            if( target.getMediaType() == null )
+            {
+                target.setMediaType( MediaType.APPLICATION_JSON );
+            }
+            if( isCompatible( target ) )
+            {
+                result = create( target.getMediaType(), source );
+            }
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T> void updatePreferences( List<Preference<MediaType>> preferences,
+                                       Class<T> entity
+    )
+    {
+        updatePreferences( preferences, MediaType.APPLICATION_JSON, 1.0F );
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/main/resources/META_INF/services/org.restlet.engine.converter.ConverterHelper
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/resources/META_INF/services/org.restlet.engine.converter.ConverterHelper
b/libraries/restlet/src/main/resources/META_INF/services/org.restlet.engine.converter.ConverterHelper
new file mode 100644
index 0000000..fd0253a
--- /dev/null
+++ b/libraries/restlet/src/main/resources/META_INF/services/org.restlet.engine.converter.ConverterHelper
@@ -0,0 +1 @@
+org.apache.zest.library.restlet.Qi4jConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java
b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java
new file mode 100644
index 0000000..f9c6a8a
--- /dev/null
+++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java
@@ -0,0 +1,27 @@
+/*
+ * 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.zest.library.restlet;
+
+import org.apache.zest.api.entity.Identity;
+
+public interface Customer extends Identity
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java
new file mode 100644
index 0000000..5eb8524
--- /dev/null
+++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java
@@ -0,0 +1,27 @@
+/*
+ * 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.zest.library.restlet;
+
+import org.apache.zest.api.entity.Identity;
+
+public interface Order extends Identity
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/test/java/org/apache/zest/library/restlet/OrdersModule.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/OrdersModule.java
b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/OrdersModule.java
new file mode 100644
index 0000000..dcc0b83
--- /dev/null
+++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/OrdersModule.java
@@ -0,0 +1,41 @@
+/*
+ * 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.zest.library.restlet;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.library.restlet.assembly.RestletCrudModuleAssembler;
+
+public class OrdersModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        new RestletCrudModuleAssembler( Order.class ).assemble( module );
+        new RestletCrudModuleAssembler( Customer.class ).assemble( module );
+        new RestletCrudModuleAssembler( Product.class ).assemble( module );
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java
b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java
new file mode 100644
index 0000000..6dec85b
--- /dev/null
+++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java
@@ -0,0 +1,27 @@
+/*
+ * 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.zest.library.restlet;
+
+import org.apache.zest.api.entity.Identity;
+
+public interface Product extends Identity
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/libraries/restlet/src/test/java/org/apache/zest/library/restlet/TestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/TestApplication.java
b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/TestApplication.java
new file mode 100644
index 0000000..6c405a0
--- /dev/null
+++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/TestApplication.java
@@ -0,0 +1,70 @@
+/*
+ * 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.zest.library.restlet;
+
+import org.apache.zest.api.activation.PassivationException;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.library.restlet.assembly.RestApplicationAssembler;
+import org.apache.zest.library.restlet.assembly.configuration.ConfigurationModule;
+import org.apache.zest.library.restlet.assembly.configuration.ConfigurationLayer;
+import org.apache.zest.library.restlet.assembly.connectivity.ConnectivityLayer;
+import org.apache.zest.library.restlet.assembly.domain.DomainLayer;
+import org.apache.zest.library.restlet.assembly.infrastructue.FileStorageModule;
+import org.apache.zest.library.restlet.assembly.infrastructue.InfrastructureLayer;
+import org.apache.zest.library.restlet.assembly.resource.ResourceLayer;
+
+// START SNIPPET: app
+public class TestApplication
+{
+    private static final String NAME = "Test Application";
+    private static final String VERSION = "1.0";
+    private static final Application.Mode MODE = Application.Mode.development;
+
+    // END SNIPPET: app
+
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        RestApplicationAssembler assembler = new RestApplicationAssembler( NAME, VERSION,
MODE,
+            ConfigurationLayer.class,
+            InfrastructureLayer.class,
+            DomainLayer.class,
+            ResourceLayer.class,
+            ConnectivityLayer.class
+        );
+
+        assembler.initialize();
+
+        ModuleAssembly configModule = assembler.layer( ConfigurationLayer.class ).module(
ConfigurationModule.NAME );
+        assembler.layer( InfrastructureLayer.class,
+                         new FileStorageModule( configModule ) );
+
+        assembler.layer( DomainLayer.class,
+                         new OrdersModule()
+        );
+        assembler.start();
+        assembler.addShutdownHook();
+    }
+    // START SNIPPET: app
+}
+// END SNIPPET: app

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9304d008/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index c017e1f..369b3a8 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -47,6 +47,7 @@ include 'core:functional',
         'libraries:rest-client',
         'libraries:rest-common',
         'libraries:rest-server',
+        'libraries:restlet',
         'libraries:scheduler',
         'libraries:scripting',
         'libraries:servlet',


Mime
View raw message