You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/02/18 09:55:21 UTC

[1/6] polygene-java git commit: Invalid character in column names.

Repository: polygene-java
Updated Branches:
  refs/heads/develop 849c75da9 -> 62f4eeb64


Invalid character in column names.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/a4bfcf10
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/a4bfcf10
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/a4bfcf10

Branch: refs/heads/develop
Commit: a4bfcf10733ff531e85eedee8156822e05706cf4
Parents: 849c75d
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 16:40:18 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 16:40:18 2017 +0800

----------------------------------------------------------------------
 .../entitystore/cassandra/CassandraCluster.java | 43 ++++++++++++++------
 1 file changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a4bfcf10/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index c5bcf72..debd680 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -17,6 +17,25 @@
  *
  *
  */
+/*
+ *  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.entitystore.cassandra;
 
 import com.datastax.driver.core.Cluster;
@@ -34,17 +53,17 @@ public interface CassandraCluster
     String CURRENT_STORAGE_VERSION = "1";
     String DEFAULT_KEYSPACE_NAME = "polygene:entitystore";
     String DEFAULT_TABLE_NAME = "polygene:entitystore:entities";
-    String IDENTITY_COLUMN = "_id";
-    String VERSION_COLUMN = "_version";
-    String USECASE_COLUMN = "_usecase";
-    String LASTMODIFIED_COLUMN = "_modified";
-    String APP_VERSION_COLUMN = "_appversion";
-    String STORE_VERSION_COLUMN = "_storeversion";
-    String TYPE_COLUMN = "_type";
-    String PROPERTIES_COLUMN = "_props";
-    String ASSOCIATIONS_COLUMN = "_assocs";
-    String MANYASSOCIATIONS_COLUMN = "_manyassocs";
-    String NAMEDASSOCIATIONS_COLUMN = "_namedassocs";
+    String IDENTITY_COLUMN = "id";
+    String VERSION_COLUMN = "version";
+    String USECASE_COLUMN = "usecase";
+    String LASTMODIFIED_COLUMN = "modified";
+    String APP_VERSION_COLUMN = "appversion";
+    String STORE_VERSION_COLUMN = "storeversion";
+    String TYPE_COLUMN = "type";
+    String PROPERTIES_COLUMN = "props";
+    String ASSOCIATIONS_COLUMN = "assocs";
+    String MANYASSOCIATIONS_COLUMN = "manyassocs";
+    String NAMEDASSOCIATIONS_COLUMN = "namedassocs";
 
     Session session();
 
@@ -198,7 +217,7 @@ public interface CassandraCluster
         {
             try( Session defaultSession = cluster.connect() )
             {
-                String query = "CREATE KEYSPACE " + keyspaceName + "WITH replication = {'class':'SimpleStrategy', 'replication_factor' : " + replication + "};";
+                String query = "CREATE KEYSPACE " + keyspaceName + " WITH replication = {'class':'SimpleStrategy', 'replication_factor' : " + replication + "};";
                 defaultSession.execute( query );
             }
         }


[5/6] polygene-java git commit: A bit more documentation, and fixes of names.

Posted by ni...@apache.org.
A bit more documentation, and fixes of names.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/2ac3d33c
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/2ac3d33c
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/2ac3d33c

Branch: refs/heads/develop
Commit: 2ac3d33c6ca8719c03b1ecb2cc1152e2255c8014
Parents: 2e228a6
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 17:14:08 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 17:14:08 2017 +0800

----------------------------------------------------------------------
 .../entitystore/cassandra/CassandraCluster.java | 20 +++--
 .../CassandraEntityStoreConfiguration.java      | 80 +++++++++++++++++++-
 .../cassandra/CassandraMapEntityStoreTest.java  |  2 +-
 3 files changed, 93 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac3d33c/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index 147ae83..a8d3d29 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -46,13 +46,14 @@ import org.apache.polygene.api.configuration.Configuration;
 import org.apache.polygene.api.injection.scope.This;
 import org.apache.polygene.api.mixin.Mixins;
 import org.apache.polygene.api.service.ServiceActivation;
+import org.apache.polygene.spi.entitystore.EntityStoreException;
 
 @Mixins( CassandraCluster.Mixin.class )
 public interface CassandraCluster
 {
     String CURRENT_STORAGE_VERSION = "1";
-    String DEFAULT_KEYSPACE_NAME = "polygene:entitystore";
-    String DEFAULT_TABLE_NAME = "polygene:entitystore:entities";
+    String DEFAULT_KEYSPACE_NAME = "polygene";
+    String DEFAULT_TABLE_NAME = "entitystore";
     String IDENTITY_COLUMN = "id";
     String VERSION_COLUMN = "version";
     String USECASE_COLUMN = "usecase";
@@ -123,7 +124,7 @@ public interface CassandraCluster
         public String tableName()
         {
             CassandraEntityStoreConfiguration config = configuration.get();
-            String tableName = config.table().get();
+            String tableName = config.entityTableName().get();
             if( tableName == null )
             {
                 tableName = DEFAULT_TABLE_NAME;
@@ -154,9 +155,16 @@ public interface CassandraCluster
             KeyspaceMetadata keyspace = cluster.getMetadata().getKeyspace( keyspaceName );
             if( keyspace == null )
             {
-                createKeyspace( keyspaceName, config.replicationFactor().get() );
-                session = cluster.connect( keyspaceName );
-                createPolygeneStateTable( tableName );
+                if( config.createIfMissing().get() )
+                {
+                    createKeyspace( keyspaceName, config.replicationFactor().get() );
+                    session = cluster.connect( keyspaceName );
+                    createPolygeneStateTable( tableName );
+                }
+                else
+                {
+                    throw new EntityStoreException( "Keyspace '" + keyspaceName + "' does not exist." );
+                }
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac3d33c/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
index 4a5e512..9fd8c1f 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
@@ -28,23 +28,99 @@ import org.apache.polygene.api.property.Property;
 public interface CassandraEntityStoreConfiguration
     extends ConfigurationComposite
 {
-
+    /**
+     * A comma or space separated list of <code>hostname:port</code> to the Cassandra cluster.
+     * <p>
+     *     A small list of hostnames should be given, as the client is capable to discover the topology by itself
+     *     and only need one host that it can connect to.
+     * </p>
+     * <p>
+     *     Also not that Cassandra refuse to bind to all interfaces on a host, so you need to know which hostname
+     *     corresponds to the interface that Cassandra is bound to. This may not include 'localhost'.
+     * </p>
+     * @return A comma or space separated list of hostnames (and port) to use to connect to the Cassandra cluster.
+     */
     @Optional
     Property<String> hostnames();
 
+    /** The replication factor to be used, if a KEYSPACE is created.
+     *
+     * @return The replication factor to use in the keyspace if a keyspace is created. Default: 3
+     */
     @Optional
     Property<Integer> replicationFactor();
 
+    /**
+     * Username for connecting the client to the Cassandra cluster.
+     * <p>
+     *     The Cassandra client uses the CQL interface.
+     * </p>
+     * @return The Username to use to connect to the Cassandra cluster. If empty, then no user name will be attempted.
+     */
     @UseDefaults
     Property<String> username();
 
+    /**
+     * Password for connecting the client to the Cassandra cluster.
+     * <p>
+     *     The Cassandra client uses the CQL interface.
+     * </p>
+     * @return The password to use to connect to the Cassandra cluster. If empty, then no password will be attempted.
+     */
     @UseDefaults
     Property<String> password();
 
+    /**
+     * The name of the KEYSPACE to be used.
+     *
+     * @return The name of the KEYSPACE to use If null, then the default <code>KEYSPACE polygene</code> will be used.
+     */
     @Optional
     Property<String> keySpace();
 
+    /**
+     * The name of the entity TABLE to be used.
+     * <p>
+     * All entities are stored in the same table, with one entity per row. The required table schema is as follows;
+     * </p>
+     * <pre><code>
+     *     CREATE TABLE entitystore (
+     *         id text,
+     *         version text,
+     *         appversion text,
+     *         storeversion text,
+     *         modified timestamp,
+     *         usecase text,
+     *         props map<text,text>,
+     *         assocs map<text,text>,
+     *         manyassocs map<text,text>,
+     *         namedassocs map<text,text>,
+     *         PRIMARY KEY (id)
+     * );
+     *
+     * </code></pre>
+     *
+     * @return the name of the Entity table. If it returns null the default name of <code>entitystore</code> will be used.
+     */
     @Optional
-    Property<String> table();
+    Property<String> entityTableName();
+
+    /**
+     * Defines whether a KEYSPACE and entity TABLE should be created if not already present in the Cassandra cluster.
+     * <p>
+     * The default keyspace that could be created is defined as follows;
+     * </p>
+     * <pre><code>
+     *     CREATE KEYSPACE sensetif WITH replication = {'class':'SimpleStrategy', 'replication_factor' : $replicationFactor };
+     * </code></pre>
+     * <p>
+     *     The <code>$replicationFactor</code> refers to the {@link CassandraEntityStoreConfiguration#replicationFactor()}
+     *     configuration property above.
+     * </p>
+     *
+     * @return true if the KEYSPACE and TABLE should be created, false if an Exception should be thrown if it is missing.
+     */
+    @UseDefaults
+    Property<Boolean> createIfMissing();
 }
 // END SNIPPET: config
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac3d33c/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
index 3f5cc12..21580f5 100644
--- a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
@@ -65,7 +65,7 @@ public class CassandraMapEntityStoreTest
 
         CassandraEntityStoreConfiguration cassandraConfig = config.forMixin( CassandraEntityStoreConfiguration.class ).declareDefaults();
         cassandraConfig.keySpace().set( "polygene:test" );
-        cassandraConfig.table().set( "polygene:test:entities" );
+        cassandraConfig.entityTableName().set( "polygene:test:entities" );
         cassandraConfig.replicationFactor().set( 1 );
         // START SNIPPET: assembly
     }


[4/6] polygene-java git commit: Need generics for maps it seems.

Posted by ni...@apache.org.
Need generics for maps it seems.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/2e228a6f
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/2e228a6f
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/2e228a6f

Branch: refs/heads/develop
Commit: 2e228a6fdf1ff5c2bfc752a0bed9cf34cdecc17f
Parents: db12d82
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 16:52:27 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 16:52:27 2017 +0800

----------------------------------------------------------------------
 extensions/entitystore-cassandra/dev-status.xml      |  4 ++--
 .../entitystore/cassandra/CassandraCluster.java      | 15 +++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2e228a6f/extensions/entitystore-cassandra/dev-status.xml
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/dev-status.xml b/extensions/entitystore-cassandra/dev-status.xml
index fcc2930..aac41cc 100644
--- a/extensions/entitystore-cassandra/dev-status.xml
+++ b/extensions/entitystore-cassandra/dev-status.xml
@@ -24,13 +24,13 @@
         http://polygene.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
   <status>
         <!--none,early,beta,stable,mature-->
-        <codebase>beta</codebase>
+        <codebase>early</codebase>
 
         <!-- none, brief, good, complete -->
         <documentation>none</documentation>
 
         <!-- none, some, good, complete -->
-        <unittests>good</unittests>
+        <unittests>none</unittests>
     </status>
     <licenses>
         <license>ALv2</license>

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2e228a6f/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index debd680..147ae83 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -70,7 +70,9 @@ public interface CassandraCluster
     String tableName();
 
     PreparedStatement entityRetrieveStatement();
+
     PreparedStatement versionRetrieveStatement();
+
     PreparedStatement entityUpdateStatement();
 
     String keyspaceName();
@@ -118,7 +120,7 @@ public interface CassandraCluster
             return keyspaceName;
         }
 
-        public  String tableName(  )
+        public String tableName()
         {
             CassandraEntityStoreConfiguration config = configuration.get();
             String tableName = config.table().get();
@@ -200,16 +202,17 @@ public interface CassandraCluster
         private void createPolygeneStateTable( String tableName )
         {
             session.execute( "CREATE TABLE " + tableName + "(\n"
-                             + "   " + IDENTITY_COLUMN + " text PRIMARYKEY,\n"
+                             + "   " + IDENTITY_COLUMN + " text,\n"
                              + "   " + VERSION_COLUMN + " text,\n"
                              + "   " + APP_VERSION_COLUMN + " text,\n"
                              + "   " + STORE_VERSION_COLUMN + " text,\n"
                              + "   " + LASTMODIFIED_COLUMN + " timestamp,\n"
                              + "   " + USECASE_COLUMN + " text,\n"
-                             + "   " + PROPERTIES_COLUMN + " map,\n"
-                             + "   " + ASSOCIATIONS_COLUMN + " map,\n"
-                             + "   " + MANYASSOCIATIONS_COLUMN + " map,\n"
-                             + "   " + NAMEDASSOCIATIONS_COLUMN + " map,\n"
+                             + "   " + PROPERTIES_COLUMN + " map<text,text>,\n"
+                             + "   " + ASSOCIATIONS_COLUMN + " map<text,text>,\n"
+                             + "   " + MANYASSOCIATIONS_COLUMN + " map<text,text>,\n"
+                             + "   " + NAMEDASSOCIATIONS_COLUMN + " map<text,text>,\n"
+                             + "   PRIMARY KEY (" + IDENTITY_COLUMN + ")\n"
                              + "   )" );
         }
 


[3/6] polygene-java git commit: Change ZrestApplication, since it is no longer related to Zest

Posted by ni...@apache.org.
Change ZrestApplication, since it is no longer related to Zest


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/db12d829
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/db12d829
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/db12d829

Branch: refs/heads/develop
Commit: db12d829412e40fe48cdaa83616ea89f2eff5fea
Parents: 5e2a6c4
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 16:40:56 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 16:40:56 2017 +0800

----------------------------------------------------------------------
 tools/generator-polygene/app/templates/Heroes/app.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db12d829/tools/generator-polygene/app/templates/Heroes/app.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/Heroes/app.tmpl b/tools/generator-polygene/app/templates/Heroes/app.tmpl
index 4878f81..10fced4 100644
--- a/tools/generator-polygene/app/templates/Heroes/app.tmpl
+++ b/tools/generator-polygene/app/templates/Heroes/app.tmpl
@@ -23,7 +23,7 @@ import java.lang.reflect.UndeclaredThrowableException;
 import org.apache.polygene.api.structure.Application;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
-import org.apache.polygene.library.restlet.ZrestApplication;
+import org.apache.polygene.library.restlet.PolygeneRestApplication;
 import org.restlet.Context;
 import org.restlet.routing.Filter;
 import org.restlet.routing.Router;


[6/6] polygene-java git commit: Missing license headers.

Posted by ni...@apache.org.
Missing license headers.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/62f4eeb6
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/62f4eeb6
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/62f4eeb6

Branch: refs/heads/develop
Commit: 62f4eeb642b6baed98abb5ef9bd2fdf5c959cc81
Parents: 2ac3d33
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 17:55:15 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 17:55:15 2017 +0800

----------------------------------------------------------------------
 .../api/property/InitialValueProvider.java      | 19 +++++++++++++++++++
 .../polygene/test/entity/CanRemoveAll.java      | 20 +++++++++++++++++++-
 .../cassandra/EmptyCassandraTableMixin.java     | 19 +++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/62f4eeb6/core/api/src/main/java/org/apache/polygene/api/property/InitialValueProvider.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/property/InitialValueProvider.java b/core/api/src/main/java/org/apache/polygene/api/property/InitialValueProvider.java
index 7fd6cc3..cd32a3a 100644
--- a/core/api/src/main/java/org/apache/polygene/api/property/InitialValueProvider.java
+++ b/core/api/src/main/java/org/apache/polygene/api/property/InitialValueProvider.java
@@ -1,3 +1,22 @@
+/*
+ *  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.api.property;
 
 import java.util.function.BiFunction;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/62f4eeb6/core/testsupport/src/main/java/org/apache/polygene/test/entity/CanRemoveAll.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/CanRemoveAll.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/CanRemoveAll.java
index 80b0a55..d65c513 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/CanRemoveAll.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/CanRemoveAll.java
@@ -1,6 +1,24 @@
+/*
+ *  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.test.entity;
 
-
 public interface CanRemoveAll
 {
     void removeAll();

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/62f4eeb6/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/EmptyCassandraTableMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/EmptyCassandraTableMixin.java b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/EmptyCassandraTableMixin.java
index a620d32..e25c79a 100644
--- a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/EmptyCassandraTableMixin.java
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/EmptyCassandraTableMixin.java
@@ -1,3 +1,22 @@
+/*
+ *  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.entitystore.cassandra;
 
 import com.datastax.driver.core.querybuilder.Delete;


[2/6] polygene-java git commit: Change ZrestApplication, since it is no longer related to Zest

Posted by ni...@apache.org.
Change ZrestApplication, since it is no longer related to Zest


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/5e2a6c42
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/5e2a6c42
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/5e2a6c42

Branch: refs/heads/develop
Commit: 5e2a6c42fdeb571a1d8db45fe74e3cd891b538bd
Parents: a4bfcf1
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 18 16:40:44 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 18 16:40:44 2017 +0800

----------------------------------------------------------------------
 .../restlet/PolygeneRestApplication.java        | 260 +++++++++++++++++++
 .../library/restlet/ZrestApplication.java       | 260 -------------------
 2 files changed, 260 insertions(+), 260 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5e2a6c42/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
new file mode 100644
index 0000000..291cfba
--- /dev/null
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
@@ -0,0 +1,260 @@
+/*
+ *  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.library.restlet;
+
+import java.util.logging.Level;
+import org.apache.polygene.api.composite.TransientBuilderFactory;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.object.ObjectFactory;
+import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+import org.apache.polygene.library.restlet.crud.EntityListResource;
+import org.apache.polygene.library.restlet.crud.EntityResource;
+import org.apache.polygene.library.restlet.resource.CreationResource;
+import org.apache.polygene.library.restlet.resource.DefaultResourceFactoryImpl;
+import org.apache.polygene.library.restlet.resource.EntryPoint;
+import org.apache.polygene.library.restlet.resource.EntryPointResource;
+import org.apache.polygene.library.restlet.resource.ResourceFactory;
+import org.apache.polygene.library.restlet.resource.ServerResource;
+import org.apache.polygene.library.restlet.serialization.PolygeneConverter;
+import org.restlet.Context;
+import org.restlet.Restlet;
+import org.restlet.data.ChallengeScheme;
+import org.restlet.data.Parameter;
+import org.restlet.engine.Engine;
+import org.restlet.routing.Filter;
+import org.restlet.routing.Router;
+import org.restlet.routing.TemplateRoute;
+import org.restlet.security.ChallengeAuthenticator;
+import org.restlet.security.Enroler;
+import org.restlet.security.Verifier;
+import org.restlet.util.Series;
+
+/**
+ * This class is generic enough to be promoted to Polygene's Restlet Library
+ */
+public abstract class PolygeneRestApplication extends org.restlet.Application
+{
+    protected org.apache.polygene.api.structure.Application polygeneApplication;
+    protected ServiceFinder serviceFinder;
+    protected ObjectFactory objectFactory;
+    protected TransientBuilderFactory transientBuilderFactory;
+    protected UnitOfWorkFactory unitOfWorkFactory;
+    protected ValueBuilderFactory valueBuilderFactory;
+
+    private Router router;
+
+    public PolygeneRestApplication( Context context )
+        throws AssemblyException
+    {
+        super( context );
+    }
+
+    protected void printRoutes()
+    {
+        router.getRoutes().forEach(
+            route -> System.out.println( route.toString() ) );
+    }
+
+    protected abstract LayeredApplicationAssembler createApplicationAssembler( String mode )
+        throws AssemblyException;
+
+    @Override
+    public synchronized void start()
+        throws Exception
+    {
+        Series<Parameter> parameters = getContext().getParameters();
+        String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" );
+        createApplication( mode );
+        polygeneApplication.activate();
+        Module module = polygeneApplication.findModule( getConnectivityLayer(), getConnectivityModule() );
+        serviceFinder = module;
+        objectFactory = module;
+        transientBuilderFactory = module;
+        unitOfWorkFactory = module.unitOfWorkFactory();
+        valueBuilderFactory = module;
+        super.start();
+    }
+
+    private void createApplication( String mode )
+    {
+        try
+        {
+            LayeredApplicationAssembler assembler = createApplicationAssembler(mode);
+            assembler.initialize();
+            polygeneApplication = assembler.application();
+            setName( polygeneApplication.name() );
+        }
+        catch( Throwable e )
+        {
+            e.printStackTrace();
+            getLogger().log( Level.SEVERE, "Unable to start Polygene application.", e );
+            throw new InternalError( "Unable to start Polygene application.", e );
+        }
+        getLogger().info( "RestApplication successfully created." );
+    }
+
+    @Override
+    public synchronized void stop()
+        throws Exception
+    {
+        super.stop();
+        polygeneApplication.passivate();
+    }
+
+    @Override
+    public Restlet createInboundRoot()
+    {
+        Context context = getContext();
+        Engine.getInstance().getRegisteredConverters().add( new PolygeneConverter( objectFactory ) );
+
+        if( polygeneApplication.mode() == Application.Mode.development )
+        {
+            setDebugging( true );
+        }
+        router = new Router( context );
+
+        addRoutes( router );
+        router.attach( "/", newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) );
+
+        ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, "Storm Clouds" );
+
+        Verifier verifier = createVerifier();
+        if( verifier != null )
+        {
+            guard.setVerifier( verifier );
+        }
+
+        Enroler enroler = createEnroler();
+        if( enroler != null )
+        {
+            guard.setEnroler( enroler );
+        }
+
+        // In the future, look into JAAS approach.
+//        Configuration jaasConfig = Configuration.getConfiguration();
+//        JaasVerifier verifier = new JaasVerifier( "BasicJaasAuthenticationApplication");
+//        verifier.setConfiguration( jaasConfig);
+//        verifier.setUserPrincipalClassName("com.sun.security.auth.UserPrincipal");
+//        guard.setVerifier(verifier);
+
+        return createInterceptors( guard );
+    }
+
+    private Restlet createInterceptors( ChallengeAuthenticator guard )
+    {
+        Filter inner = createInnerInterceptor();
+        if( inner != null )
+        {
+            inner.setNext( router );
+            guard.setNext( inner );             // guard -> interceptor -> router
+        }
+        else
+        {
+            guard.setNext( router );            // guard -> router
+        }
+        inner = guard;                      // inner = guard
+
+        Filter outer = createOuterInterceptor();
+        if( outer != null )
+        {
+            outer.setNext( inner );             // outer -> inner
+            return outer;
+        }
+        return inner;
+    }
+
+    protected Filter createOuterInterceptor()
+    {
+        return null;
+    }
+
+    protected Filter createInnerInterceptor()
+    {
+        return null;
+    }
+
+    protected Verifier createVerifier()
+    {
+        return null;
+    }
+
+    protected Enroler createEnroler()
+    {
+        return null;
+    }
+
+    protected abstract String getConnectivityLayer();
+
+    protected abstract String getConnectivityModule();
+
+    protected abstract void addRoutes( Router router );
+
+    protected void addResourcePath( String name,
+                                    Class<? extends HasIdentity> type,
+                                    String basePath
+    )
+    {
+        addResourcePath( name, type, basePath, true, true );
+    }
+
+    protected void addResourcePath( String name,
+                                    Class<? extends HasIdentity> type,
+                                    String basePath,
+                                    boolean createLink,
+                                    boolean rootRoute
+    )
+    {
+        if( createLink )
+        {
+            router.attach( basePath + name + "/create", newPolygeneRestlet( CreationResource.class, type ) );
+        }
+        TemplateRoute route = router.attach( basePath + name + "/", newPolygeneRestlet( EntityListResource.class, type ) );
+        if( rootRoute )
+        {
+            route.setName( name );
+        }
+        router.attach( basePath + name + "/{id}/", newPolygeneRestlet( EntityResource.class, type ) );
+        router.attach( basePath + name + "/{id}/{invoke}", newPolygeneRestlet( EntityResource.class, type ) );
+    }
+
+    private <K extends HasIdentity, T extends ServerResource<K>> Restlet newPolygeneRestlet(Class<T> resourceClass,
+                                                                                        Class<K> entityClass
+    )
+    {
+
+        @SuppressWarnings( "unchecked" )
+        ResourceFactory<K, T> factory = objectFactory.newObject( DefaultResourceFactoryImpl.class,
+                                                                 resourceClass, router
+        );
+        PolygeneConverter converter = new PolygeneConverter( objectFactory );
+        return objectFactory.newObject( PolygeneEntityRestlet.class,
+                                        factory,
+                                        router,
+                                        entityClass,
+                                        converter
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5e2a6c42/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/ZrestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/ZrestApplication.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/ZrestApplication.java
deleted file mode 100644
index 662ef6f..0000000
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/ZrestApplication.java
+++ /dev/null
@@ -1,260 +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.library.restlet;
-
-import java.util.logging.Level;
-import org.apache.polygene.api.composite.TransientBuilderFactory;
-import org.apache.polygene.api.identity.HasIdentity;
-import org.apache.polygene.api.object.ObjectFactory;
-import org.apache.polygene.api.service.ServiceFinder;
-import org.apache.polygene.api.structure.Application;
-import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.value.ValueBuilderFactory;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
-import org.apache.polygene.library.restlet.crud.EntityListResource;
-import org.apache.polygene.library.restlet.crud.EntityResource;
-import org.apache.polygene.library.restlet.resource.CreationResource;
-import org.apache.polygene.library.restlet.resource.DefaultResourceFactoryImpl;
-import org.apache.polygene.library.restlet.resource.EntryPoint;
-import org.apache.polygene.library.restlet.resource.EntryPointResource;
-import org.apache.polygene.library.restlet.resource.ResourceFactory;
-import org.apache.polygene.library.restlet.resource.ServerResource;
-import org.apache.polygene.library.restlet.serialization.PolygeneConverter;
-import org.restlet.Context;
-import org.restlet.Restlet;
-import org.restlet.data.ChallengeScheme;
-import org.restlet.data.Parameter;
-import org.restlet.engine.Engine;
-import org.restlet.routing.Filter;
-import org.restlet.routing.Router;
-import org.restlet.routing.TemplateRoute;
-import org.restlet.security.ChallengeAuthenticator;
-import org.restlet.security.Enroler;
-import org.restlet.security.Verifier;
-import org.restlet.util.Series;
-
-/**
- * This class is generic enough to be promoted to Polygene's Restlet Library
- */
-public abstract class ZrestApplication extends org.restlet.Application
-{
-    protected org.apache.polygene.api.structure.Application polygeneApplication;
-    protected ServiceFinder serviceFinder;
-    protected ObjectFactory objectFactory;
-    protected TransientBuilderFactory transientBuilderFactory;
-    protected UnitOfWorkFactory unitOfWorkFactory;
-    protected ValueBuilderFactory valueBuilderFactory;
-
-    private Router router;
-
-    public ZrestApplication( Context context )
-        throws AssemblyException
-    {
-        super( context );
-    }
-
-    protected void printRoutes()
-    {
-        router.getRoutes().stream().forEach(
-            route -> System.out.println( route.toString() ) );
-    }
-
-    protected abstract LayeredApplicationAssembler createApplicationAssembler( String mode )
-        throws AssemblyException;
-
-    @Override
-    public synchronized void start()
-        throws Exception
-    {
-        Series<Parameter> parameters = getContext().getParameters();
-        String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" );
-        createApplication( mode );
-        polygeneApplication.activate();
-        Module module = polygeneApplication.findModule( getConnectivityLayer(), getConnectivityModule() );
-        serviceFinder = module;
-        objectFactory = module;
-        transientBuilderFactory = module;
-        unitOfWorkFactory = module.unitOfWorkFactory();
-        valueBuilderFactory = module;
-        super.start();
-    }
-
-    private void createApplication( String mode )
-    {
-        try
-        {
-            LayeredApplicationAssembler assembler = createApplicationAssembler(mode);
-            assembler.initialize();
-            polygeneApplication = assembler.application();
-            setName( polygeneApplication.name() );
-        }
-        catch( Throwable e )
-        {
-            e.printStackTrace();
-            getLogger().log( Level.SEVERE, "Unable to start Polygene application.", e );
-            throw new InternalError( "Unable to start Polygene application.", e );
-        }
-        getLogger().info( "RestApplication successfully created." );
-    }
-
-    @Override
-    public synchronized void stop()
-        throws Exception
-    {
-        super.stop();
-        polygeneApplication.passivate();
-    }
-
-    @Override
-    public Restlet createInboundRoot()
-    {
-        Context context = getContext();
-        Engine.getInstance().getRegisteredConverters().add( new PolygeneConverter( objectFactory ) );
-
-        if( polygeneApplication.mode() == Application.Mode.development )
-        {
-            setDebugging( true );
-        }
-        router = new Router( context );
-
-        addRoutes( router );
-        router.attach( "/", newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) );
-
-        ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, "Storm Clouds" );
-
-        Verifier verifier = createVerifier();
-        if( verifier != null )
-        {
-            guard.setVerifier( verifier );
-        }
-
-        Enroler enroler = createEnroler();
-        if( enroler != null )
-        {
-            guard.setEnroler( enroler );
-        }
-
-        // In the future, look into JAAS approach.
-//        Configuration jaasConfig = Configuration.getConfiguration();
-//        JaasVerifier verifier = new JaasVerifier( "BasicJaasAuthenticationApplication");
-//        verifier.setConfiguration( jaasConfig);
-//        verifier.setUserPrincipalClassName("com.sun.security.auth.UserPrincipal");
-//        guard.setVerifier(verifier);
-
-        return createInterceptors( guard );
-    }
-
-    private Restlet createInterceptors( ChallengeAuthenticator guard )
-    {
-        Filter inner = createInnerInterceptor();
-        if( inner != null )
-        {
-            inner.setNext( router );
-            guard.setNext( inner );             // guard -> interceptor -> router
-        }
-        else
-        {
-            guard.setNext( router );            // guard -> router
-        }
-        inner = guard;                      // inner = guard
-
-        Filter outer = createOuterInterceptor();
-        if( outer != null )
-        {
-            outer.setNext( inner );             // outer -> inner
-            return outer;
-        }
-        return inner;
-    }
-
-    protected Filter createOuterInterceptor()
-    {
-        return null;
-    }
-
-    protected Filter createInnerInterceptor()
-    {
-        return null;
-    }
-
-    protected Verifier createVerifier()
-    {
-        return null;
-    }
-
-    protected Enroler createEnroler()
-    {
-        return null;
-    }
-
-    protected abstract String getConnectivityLayer();
-
-    protected abstract String getConnectivityModule();
-
-    protected abstract void addRoutes( Router router );
-
-    protected void addResourcePath( String name,
-                                    Class<? extends HasIdentity> type,
-                                    String basePath
-    )
-    {
-        addResourcePath( name, type, basePath, true, true );
-    }
-
-    protected void addResourcePath( String name,
-                                    Class<? extends HasIdentity> type,
-                                    String basePath,
-                                    boolean createLink,
-                                    boolean rootRoute
-    )
-    {
-        if( createLink )
-        {
-            router.attach( basePath + name + "/create", newPolygeneRestlet( CreationResource.class, type ) );
-        }
-        TemplateRoute route = router.attach( basePath + name + "/", newPolygeneRestlet( EntityListResource.class, type ) );
-        if( rootRoute )
-        {
-            route.setName( name );
-        }
-        router.attach( basePath + name + "/{id}/", newPolygeneRestlet( EntityResource.class, type ) );
-        router.attach( basePath + name + "/{id}/{invoke}", newPolygeneRestlet( EntityResource.class, type ) );
-    }
-
-    private <K extends HasIdentity, T extends ServerResource<K>> Restlet newPolygeneRestlet(Class<T> resourceClass,
-                                                                                        Class<K> entityClass
-    )
-    {
-
-        @SuppressWarnings( "unchecked" )
-        ResourceFactory<K, T> factory = objectFactory.newObject( DefaultResourceFactoryImpl.class,
-                                                                 resourceClass, router
-        );
-        PolygeneConverter converter = new PolygeneConverter( objectFactory );
-        return objectFactory.newObject( PolygeneEntityRestlet.class,
-                                        factory,
-                                        router,
-                                        entityClass,
-                                        converter
-        );
-    }
-}