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 2016/04/14 08:13:07 UTC
[01/34] zest-java git commit: Testcase use the old style composition
with explicit Entities. Not necessary anymore.
Repository: zest-java
Updated Branches:
refs/heads/develop 2ae805e40 -> ffb8ad294
Testcase use the old style composition with explicit Entities. Not necessary anymore.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/d845ea70
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/d845ea70
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/d845ea70
Branch: refs/heads/develop
Commit: d845ea705b05b3d8182086ba82979fa8332bde78
Parents: 4dabe57
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Mon Dec 14 18:21:49 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Mon Dec 14 18:21:49 2015 +0800
----------------------------------------------------------------------
.../test/indexing/AbstractAnyQueryTest.java | 24 +++++++--------
.../org/apache/zest/test/indexing/TestData.java | 11 +++----
.../indexing/model/entities/AccountEntity.java | 29 ------------------
.../test/indexing/model/entities/CatEntity.java | 31 --------------------
.../indexing/model/entities/CityEntity.java | 29 ------------------
.../test/indexing/model/entities/DogEntity.java | 29 ------------------
.../indexing/model/entities/DomainEntity.java | 29 ------------------
.../indexing/model/entities/FemaleEntity.java | 29 ------------------
.../indexing/model/entities/MaleEntity.java | 29 ------------------
.../indexing/model/entities/PersonEntity.java | 29 ------------------
.../test/indexing/model/entities/PetEntity.java | 29 ------------------
.../test/indexing/model/entities/package.html | 21 -------------
12 files changed, 16 insertions(+), 303 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
index 9c34fb8..de7676e 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
@@ -23,19 +23,19 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
import org.apache.zest.test.EntityTestAssembler;
+import org.apache.zest.test.indexing.model.Account;
import org.apache.zest.test.indexing.model.Address;
+import org.apache.zest.test.indexing.model.Cat;
+import org.apache.zest.test.indexing.model.City;
+import org.apache.zest.test.indexing.model.Domain;
+import org.apache.zest.test.indexing.model.Female;
import org.apache.zest.test.indexing.model.File;
import org.apache.zest.test.indexing.model.Host;
+import org.apache.zest.test.indexing.model.Male;
import org.apache.zest.test.indexing.model.Port;
import org.apache.zest.test.indexing.model.Protocol;
import org.apache.zest.test.indexing.model.QueryParam;
import org.apache.zest.test.indexing.model.URL;
-import org.apache.zest.test.indexing.model.entities.AccountEntity;
-import org.apache.zest.test.indexing.model.entities.CatEntity;
-import org.apache.zest.test.indexing.model.entities.CityEntity;
-import org.apache.zest.test.indexing.model.entities.DomainEntity;
-import org.apache.zest.test.indexing.model.entities.FemaleEntity;
-import org.apache.zest.test.indexing.model.entities.MaleEntity;
/**
* Abstract satisfiedBy with tests for any queries against Index/Query engines.
@@ -56,12 +56,12 @@ public class AbstractAnyQueryTest
protected void assembleEntities( ModuleAssembly module, Visibility visibility )
{
- module.entities( MaleEntity.class,
- FemaleEntity.class,
- CityEntity.class,
- DomainEntity.class,
- AccountEntity.class,
- CatEntity.class ). visibleIn( visibility );
+ module.entities( Male.class,
+ Female.class,
+ City.class,
+ Domain.class,
+ Account.class,
+ Cat.class ). visibleIn( visibility );
}
protected void assembleValues( ModuleAssembly module, Visibility visibility )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index d9988d0..e83b71b 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -41,9 +41,6 @@ import org.apache.zest.test.indexing.model.Person;
import org.apache.zest.test.indexing.model.Protocol;
import org.apache.zest.test.indexing.model.QueryParam;
import org.apache.zest.test.indexing.model.URL;
-import org.apache.zest.test.indexing.model.entities.CatEntity;
-import org.apache.zest.test.indexing.model.entities.FemaleEntity;
-import org.apache.zest.test.indexing.model.entities.MaleEntity;
import static org.joda.time.DateTimeZone.UTC;
@@ -144,7 +141,7 @@ class TestData
Female annDoe;
{
- EntityBuilder<FemaleEntity> femaleBuilder = unitOfWork.newEntityBuilder( FemaleEntity.class, "anndoe" );
+ EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, "anndoe" );
annDoe = femaleBuilder.instance();
annDoe.name().set( "Ann Doe" );
annDoe.title().set( Person.Title.MRS );
@@ -161,7 +158,7 @@ class TestData
}
{
- EntityBuilder<MaleEntity> maleBuilder = unitOfWork.newEntityBuilder( MaleEntity.class );
+ EntityBuilder<Male> maleBuilder = unitOfWork.newEntityBuilder( Male.class );
Male joeDoe = maleBuilder.instance();
joeDoe.name().set( "Joe Doe" );
joeDoe.title().set( Person.Title.MR );
@@ -186,7 +183,7 @@ class TestData
}
{
- EntityBuilder<MaleEntity> maleBuilder = unitOfWork.newEntityBuilder( MaleEntity.class );
+ EntityBuilder<Male> maleBuilder = unitOfWork.newEntityBuilder( Male.class );
Male jackDoe = maleBuilder.instance();
jackDoe.name().set( "Jack Doe" );
jackDoe.title().set( Person.Title.DR );
@@ -237,7 +234,7 @@ class TestData
}
{
- EntityBuilder<CatEntity> catBuilder = unitOfWork.newEntityBuilder( CatEntity.class );
+ EntityBuilder<Cat> catBuilder = unitOfWork.newEntityBuilder( Cat.class );
Cat felix = catBuilder.instance();
felix.name().set( "Felix" );
catBuilder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/AccountEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/AccountEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/AccountEntity.java
deleted file mode 100644
index 0c2ac1d..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/AccountEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Account;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface AccountEntity
- extends Account, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CatEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CatEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CatEntity.java
deleted file mode 100644
index 39cf47e..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CatEntity.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.test.indexing.model.Cat;
-
-/**
- * JAVADOC Add JavaDoc
- */
-@Queryable( false )
-public interface CatEntity
- extends Cat, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CityEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CityEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CityEntity.java
deleted file mode 100644
index 16a49dc..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/CityEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.City;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface CityEntity
- extends City, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DogEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DogEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DogEntity.java
deleted file mode 100644
index 900b537..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DogEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Dog;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface DogEntity
- extends Dog, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DomainEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DomainEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DomainEntity.java
deleted file mode 100644
index 06482ec..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/DomainEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Domain;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface DomainEntity
- extends Domain, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/FemaleEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/FemaleEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/FemaleEntity.java
deleted file mode 100644
index 24b5e4b..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/FemaleEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Female;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface FemaleEntity
- extends Female, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/MaleEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/MaleEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/MaleEntity.java
deleted file mode 100644
index 0b6675e..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/MaleEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Male;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface MaleEntity
- extends Male, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PersonEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PersonEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PersonEntity.java
deleted file mode 100644
index 02da77e..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PersonEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Person;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface PersonEntity
- extends Person, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PetEntity.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PetEntity.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PetEntity.java
deleted file mode 100644
index cc6f921..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/PetEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2008 Alin Dreghiciu.
- *
- * Licensed 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.test.indexing.model.entities;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.test.indexing.model.Pet;
-
-/**
- * JAVADOC Add JavaDoc
- */
-public interface PetEntity
- extends Pet, EntityComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d845ea70/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/package.html
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/package.html b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/package.html
deleted file mode 100644
index b19cc59..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/entities/package.html
+++ /dev/null
@@ -1,21 +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>Index/Query SPI Test Support - Entities.</h2>
- </body>
-</html>
[19/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index 5d67aa2..02448d3 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -33,14 +33,9 @@ import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
-import java.util.function.BiFunction;
import java.util.function.Function;
import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.EnumType;
import org.apache.zest.api.type.MapType;
@@ -105,10 +100,6 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
private static final String UTF_8 = "UTF-8";
private final Map<Class<?>, Function<Object, Object>> deserializers = new HashMap<>( 16 );
private final Map<Class<?>, ComplexDeserializer<Object, InputType, InputNodeType>> complexDeserializers = new HashMap<>( 2 );
- private final Application application;
- private final Module module;
- private Function<Application, Module> valuesModuleFinder;
- private Module valuesModule;
/**
* Register a Plain Value type deserialization Function.
@@ -131,24 +122,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
complexDeserializers.put( type, (ComplexDeserializer<Object, InputType, InputNodeType>) deserializer );
}
- @SuppressWarnings( "unchecked" )
- public ValueDeserializerAdapter( @Structure Application application,
- @Structure Module module,
- @Service ServiceReference<ValueDeserializer> serviceRef
- )
+ protected ValueDeserializerAdapter()
{
- this( application, module, serviceRef.metaInfo( Function.class ) );
- }
-
- protected ValueDeserializerAdapter( Application application,
- Module module,
- Function<Application, Module> valuesModuleFinder
- )
- {
-
- this.application = application;
- this.module = module;
- setValuesModuleFinder( valuesModuleFinder );
// Primitive Value types
registerDeserializer( String.class, Object::toString );
@@ -189,84 +164,58 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
registerDeserializer( EntityReference.class, input -> EntityReference.parseEntityReference( input.toString() ) );
}
- private void setValuesModuleFinder( Function<Application, Module> valuesModuleFinder )
- {
- this.valuesModuleFinder = valuesModuleFinder;
- this.valuesModule = null;
- }
-
- private Module valuesModule()
- {
- if( valuesModule == null )
- {
- if( valuesModuleFinder == null )
- {
- valuesModule = module;
- }
- else
- {
- valuesModule = valuesModuleFinder.apply( application );
- if( valuesModule == null )
- {
- throw new ValueSerializationException( "Values Module provided by the finder Function was null." );
- }
- }
- }
- return valuesModule;
- }
-
@Override
- public <T> Function<String, T> deserialize( Class<T> type )
+ public <T> Function<String, T> deserialize( ModuleDescriptor module, Class<T> type )
{
if( CollectionType.isCollection( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new CollectionType( type, objectValueType ) );
+ return deserialize( module, new CollectionType( type, objectValueType ) );
}
if( MapType.isMap( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new MapType( type, objectValueType, objectValueType ) );
+ return deserialize( module, new MapType( type, objectValueType, objectValueType ) );
}
- return deserialize( new ValueType( type ) );
+ return deserialize( module, new ValueType( type ) );
}
@Override
- public final <T> Function<String, T> deserialize( final ValueType valueType )
+ public final <T> Function<String, T> deserialize( ModuleDescriptor module, ValueType valueType )
{
- return input -> deserialize( valueType, input );
+ return input -> deserialize( module, valueType, input );
}
- @Override
- public final <T> BiFunction<ValueType, String, T> deserialize()
- {
- return this::deserialize;
- }
+// @Override
+// public final <T> BiFunction<ValueType, String, T> deserialize()
+// {
+// return this::deserialize;
+// }
@Override
- public final <T> T deserialize( Class<?> type, String input )
+ public final <T> T deserialize( ModuleDescriptor module, Class<?> type, String input )
throws ValueSerializationException
{
if( CollectionType.isCollection( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new CollectionType( type, objectValueType ), input );
+ return deserialize( module, new CollectionType( type, objectValueType ), input );
}
if( MapType.isMap( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new MapType( type, objectValueType, objectValueType ), input );
+ return deserialize( module, new MapType( type, objectValueType, objectValueType ), input );
}
- return deserialize( new ValueType( type ), input );
+ return deserialize( module, new ValueType( type ), input );
}
@Override
- public final <T> T deserialize( ValueType valueType, String input )
+ public final <T> T deserialize( ModuleDescriptor module, ValueType valueType, String input )
throws ValueSerializationException
{
try
{
- return deserializeRoot( valueType, new ByteArrayInputStream( input.getBytes( UTF_8 ) ) );
+ return deserializeRoot( module, valueType, new ByteArrayInputStream( input.getBytes( UTF_8 ) ) );
}
catch( ValueSerializationException ex )
{
@@ -279,29 +228,29 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
@Override
- public final <T> T deserialize( Class<?> type, InputStream input )
+ public final <T> T deserialize( ModuleDescriptor module, Class<?> type, InputStream input )
throws ValueSerializationException
{
if( CollectionType.isCollection( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new CollectionType( type, objectValueType ), input );
+ return deserialize( module, new CollectionType( type, objectValueType ), input );
}
if( MapType.isMap( type ) )
{
ValueType objectValueType = new ValueType( Object.class );
- return deserialize( new MapType( type, objectValueType, objectValueType ), input );
+ return deserialize( module, new MapType( type, objectValueType, objectValueType ), input );
}
- return deserialize( new ValueType( type ), input );
+ return deserialize( module, new ValueType( type ), input );
}
@Override
- public final <T> T deserialize( ValueType valueType, InputStream input )
+ public final <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream input )
throws ValueSerializationException
{
try
{
- return deserializeRoot( valueType, input );
+ return deserializeRoot( module, valueType, input );
}
catch( ValueSerializationException ex )
{
@@ -314,7 +263,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeRoot( ValueType valueType, InputStream input )
+ private <T> T deserializeRoot( ModuleDescriptor module, ValueType valueType, InputStream input )
throws Exception
{
final Class<?> type = valueType.types().findFirst().orElse( null );
@@ -338,27 +287,27 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
return null;
}
String string = scanner.next();
- return (T) deserializeBase64Serialized( string );
+ return (T) deserializeBase64Serialized( module, string );
}
else // Complex ValueType
{
- InputType adaptedInput = adaptInput( input );
- onDeserializationStart( valueType, adaptedInput );
- T deserialized = doDeserialize( valueType, adaptedInput );
- onDeserializationEnd( valueType, adaptedInput );
+ InputType adaptedInput = adaptInput( module, input );
+ onDeserializationStart( module, valueType, adaptedInput );
+ T deserialized = doDeserialize( module, valueType, adaptedInput );
+ onDeserializationEnd( module, valueType, adaptedInput );
return deserialized;
}
}
@SuppressWarnings( "unchecked" )
- private <T> T doDeserialize( ValueType valueType, InputType input )
+ private <T> T doDeserialize( ModuleDescriptor module, ValueType valueType, InputType input )
throws Exception
{
final Class<?> type = valueType.types().findFirst().orElse( null );
// Registered deserializers
if( deserializers.get( type ) != null )
{
- Object value = readPlainValue( input );
+ Object value = readPlainValue( module, input );
if( value == null )
{
return null;
@@ -372,38 +321,38 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
else // Explicit ValueComposite
if( ValueCompositeType.class.isAssignableFrom( valueType.getClass() ) )
{
- return (T) deserializeValueComposite( valueType, input );
+ return (T) deserializeValueComposite( module, valueType, input );
}
else // Explicit Collections
if( CollectionType.class.isAssignableFrom( valueType.getClass() ) )
{
- return (T) deserializeCollection( (CollectionType) valueType, input );
+ return (T) deserializeCollection( module, (CollectionType) valueType, input );
}
else // Explicit Map
if( MapType.class.isAssignableFrom( valueType.getClass() ) )
{
- return (T) deserializeMap( (MapType) valueType, input );
+ return (T) deserializeMap( module, (MapType) valueType, input );
}
else // Enum
if( EnumType.class.isAssignableFrom( valueType.getClass() ) || type.isEnum() )
{
- return (T) Enum.valueOf( (Class) type, readPlainValue( input ).toString() );
+ return (T) Enum.valueOf( (Class) type, readPlainValue( module, input ).toString() );
}
else // Array
if( type.isArray() )
{
- return (T) deserializeBase64Serialized( readPlainValue( input ).toString() );
+ return (T) deserializeBase64Serialized( module, readPlainValue( module, input ).toString() );
}
// Guessed Deserialization
- return (T) deserializeGuessed( valueType, input );
+ return (T) deserializeGuessed( module, valueType, input );
}
- private <T> Function<InputType, T> buildDeserializeInputFunction( final ValueType valueType )
+ private <T> Function<InputType, T> buildDeserializeInputFunction( ModuleDescriptor module, ValueType valueType )
{
return input -> {
try
{
- return doDeserialize( valueType, input );
+ return doDeserialize( module, valueType, input );
}
catch( ValueSerializationException ex )
{
@@ -416,7 +365,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
};
}
- private <T> Collection<T> deserializeCollection( CollectionType collectionType, InputType input )
+ private <T> Collection<T> deserializeCollection( ModuleDescriptor module, CollectionType collectionType, InputType input )
throws Exception
{
Collection<T> collection;
@@ -429,43 +378,46 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
{
collection = new ArrayList<>();
}
- return readArrayInCollection( input,
- this.<T>buildDeserializeInputFunction( collectionType.collectedType() ),
+ return readArrayInCollection( module,
+ input,
+ this.<T>buildDeserializeInputFunction( module, collectionType.collectedType() ),
collection );
}
- private <K, V> Map<K, V> deserializeMap( MapType mapType, InputType input )
+ private <K, V> Map<K, V> deserializeMap( ModuleDescriptor module, MapType mapType, InputType input )
throws Exception
{
- return readMapInMap( input,
- this.<K>buildDeserializeInputFunction( mapType.keyType() ),
- this.<V>buildDeserializeInputFunction( mapType.valueType() ),
+ return readMapInMap( module,
+ input,
+ this.<K>buildDeserializeInputFunction( module, mapType.keyType() ),
+ this.<V>buildDeserializeInputFunction( module, mapType.valueType() ),
new HashMap<>() );
}
- private <T> T deserializeValueComposite( ValueType valueType, InputType input )
+ private <T> T deserializeValueComposite( ModuleDescriptor module, ValueType valueType, InputType input )
throws Exception
{
- InputNodeType inputNode = readObjectTree( input );
+ InputNodeType inputNode = readObjectTree( module, input );
if( inputNode == null )
{
return null;
}
- return deserializeNodeValueComposite( valueType, inputNode );
+ return deserializeNodeValueComposite( module, valueType, inputNode );
}
- private <T> T deserializeNodeValueComposite( ValueType valueType, InputNodeType inputNode )
+ private <T> T deserializeNodeValueComposite( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
throws Exception
{
ValueCompositeType valueCompositeType = (ValueCompositeType) valueType;
Class<?> valueBuilderType = valueCompositeType.types().findFirst().orElse( null );
String typeInfo = this.getObjectFieldValue(
+ module,
inputNode,
"_type",
- this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
+ this.<String>buildDeserializeInputNodeFunction( module, new ValueType( String.class ) ) );
if( typeInfo != null )
{
- ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( typeInfo );
+ ValueDescriptor valueDescriptor = module.valueDescriptor( typeInfo );
if( valueDescriptor == null )
{
throw new ValueSerializationException( "Specified value type could not be resolved: " + typeInfo );
@@ -473,11 +425,12 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
valueCompositeType = valueDescriptor.valueType();
valueBuilderType = Class.forName( typeInfo );
}
- return deserializeValueComposite( valueCompositeType, valueBuilderType, inputNode );
+ return deserializeValueComposite( module, valueCompositeType, valueBuilderType, inputNode );
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeValueComposite( ValueCompositeType valueCompositeType,
+ private <T> T deserializeValueComposite( ModuleDescriptor module,
+ ValueCompositeType valueCompositeType,
Class<?> valueBuilderType,
InputNodeType inputNode
)
@@ -492,12 +445,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
try
{
propertyName = property.qualifiedName().name();
- if( objectHasField( inputNode, propertyName ) )
+ if( objectHasField( module, inputNode, propertyName ) )
{
value = getObjectFieldValue(
+ module,
inputNode,
propertyName,
- buildDeserializeInputNodeFunction( property.valueType() ) );
+ buildDeserializeInputNodeFunction( module, property.valueType() ) );
if( property.isImmutable() )
{
if( value instanceof Set )
@@ -517,7 +471,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
else
{
// Serialized object does not contain the field, try to default it
- value = property.initialValue( valuesModule() );
+ value = property.initialValue( module );
}
}
catch( Exception e )
@@ -532,12 +486,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
try
{
String associationName = association.qualifiedName().name();
- if( objectHasField( inputNode, associationName ) )
+ if( objectHasField( module, inputNode, associationName ) )
{
Object value = getObjectFieldValue(
+ module,
inputNode,
associationName,
- buildDeserializeInputNodeFunction( new ValueType( EntityReference.class ) ) );
+ buildDeserializeInputNodeFunction( module, new ValueType( EntityReference.class ) ) );
stateMap.put( associationName, value );
}
}
@@ -552,14 +507,17 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
try
{
String manyAssociationName = manyAssociation.qualifiedName().name();
- if( objectHasField( inputNode, manyAssociationName ) )
+ if( objectHasField( module, inputNode, manyAssociationName ) )
{
Object value = getObjectFieldValue(
+ module,
inputNode,
manyAssociationName,
- buildDeserializeInputNodeFunction( new CollectionType(
- Collection.class,
- new ValueType( EntityReference.class ) ) ) );
+ buildDeserializeInputNodeFunction(
+ module,
+ new CollectionType(
+ Collection.class,
+ new ValueType( EntityReference.class ) ) ) );
stateMap.put( manyAssociationName, value );
}
}
@@ -574,12 +532,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
try
{
String namedAssociationName = namedAssociation.qualifiedName().name();
- if( objectHasField( inputNode, namedAssociationName ) )
+ if( objectHasField( module, inputNode, namedAssociationName ) )
{
Object value = getObjectFieldValue(
+ module,
inputNode,
namedAssociationName,
- buildDeserializeInputNodeFunction( MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
+ buildDeserializeInputNodeFunction( module, MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
stateMap.put( namedAssociationName, value );
}
}
@@ -589,16 +548,16 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
} );
- ValueBuilder<?> valueBuilder = buildNewValueBuilderWithState( valueBuilderType, stateMap );
+ ValueBuilder<?> valueBuilder = buildNewValueBuilderWithState( module, valueBuilderType, stateMap );
return (T) valueBuilder.newInstance(); // Unchecked cast because the builder could use a type != T
}
- private <T> Function<InputNodeType, T> buildDeserializeInputNodeFunction( final ValueType valueType )
+ private <T> Function<InputNodeType, T> buildDeserializeInputNodeFunction( ModuleDescriptor module, final ValueType valueType )
{
return inputNode -> {
try
{
- return doDeserializeInputNodeValue( valueType, inputNode );
+ return doDeserializeInputNodeValue( module, valueType, inputNode );
}
catch( ValueSerializationException ex )
{
@@ -612,7 +571,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
@SuppressWarnings( "unchecked" )
- private <T> T doDeserializeInputNodeValue( ValueType valueType, InputNodeType inputNode )
+ private <T> T doDeserializeInputNodeValue( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
throws Exception
{
if( inputNode == null )
@@ -623,7 +582,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
// Registered deserializers
if( deserializers.get( type ) != null )
{
- Object value = asSimpleValue( inputNode );
+ Object value = asSimpleValue( module, inputNode );
if( value == null )
{
return null;
@@ -637,12 +596,12 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
else // Explicit ValueComposite
if( ValueCompositeType.class.isAssignableFrom( valueType.getClass() ) )
{
- return (T) deserializeNodeValueComposite( valueType, inputNode );
+ return (T) deserializeNodeValueComposite( module, valueType, inputNode );
}
else // Explicit Collections
if( CollectionType.class.isAssignableFrom( valueType.getClass() ) )
{
- return (T) deserializeNodeCollection( (CollectionType) valueType, inputNode );
+ return (T) deserializeNodeCollection( module, (CollectionType) valueType, inputNode );
}
else // Explicit Map
if( MapType.class.isAssignableFrom( valueType.getClass() ) )
@@ -650,17 +609,17 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
MapType mapType = (MapType) valueType;
if( mapType.variant().equals( Serialization.Variant.entry ) )
{
- return (T) deserializeNodeEntryMap( (MapType) valueType, inputNode );
+ return (T) deserializeNodeEntryMap( module, (MapType) valueType, inputNode );
}
else
{
- return (T) deserializeNodeObjectMap( (MapType) valueType, inputNode );
+ return (T) deserializeNodeObjectMap( module, (MapType) valueType, inputNode );
}
}
else // Enum
if( EnumType.class.isAssignableFrom( valueType.getClass() ) || type.isEnum() )
{
- Object value = asSimpleValue( inputNode );
+ Object value = asSimpleValue( module, inputNode );
if( value == null )
{
return null;
@@ -668,12 +627,15 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
return (T) Enum.valueOf( (Class) type, value.toString() );
}
// Guessed deserialization
- return (T) deserializeNodeGuessed( valueType, inputNode );
+ return (T) deserializeNodeGuessed( module, valueType, inputNode );
}
- private ValueBuilder<?> buildNewValueBuilderWithState( Class<?> type, final Map<String, Object> stateMap )
+ private ValueBuilder<?> buildNewValueBuilderWithState( ModuleDescriptor module,
+ Class<?> type,
+ final Map<String, Object> stateMap
+ )
{
- return valuesModule().newValueBuilderWithState(
+ return module.instance().newValueBuilderWithState(
type,
property -> stateMap.get( property.qualifiedName().name() ),
association -> {
@@ -705,18 +667,21 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeGuessed( ValueType valueType, InputType input )
+ private <T> T deserializeGuessed( ModuleDescriptor module, ValueType valueType, InputType input )
throws Exception
{
- InputNodeType inputNode = readObjectTree( input );
+ InputNodeType inputNode = readObjectTree( module, input );
if( inputNode == null )
{
return null;
}
- return deserializeNodeGuessed( valueType, inputNode );
+ return deserializeNodeGuessed( module, valueType, inputNode );
}
- private <T> Collection<T> deserializeNodeCollection( CollectionType collectionType, InputNodeType inputNode )
+ private <T> Collection<T> deserializeNodeCollection( ModuleDescriptor module,
+ CollectionType collectionType,
+ InputNodeType inputNode
+ )
throws Exception
{
Collection<T> collection;
@@ -729,48 +694,52 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
{
collection = new ArrayList<>();
}
- putArrayNodeInCollection( inputNode,
- this.<T>buildDeserializeInputNodeFunction( collectionType.collectedType() ),
+ putArrayNodeInCollection( module,
+ inputNode,
+ this.<T>buildDeserializeInputNodeFunction( module, collectionType.collectedType() ),
collection );
return collection;
}
- private <K, V> Map<K, V> deserializeNodeEntryMap( MapType mapType, InputNodeType inputNode )
+ private <K, V> Map<K, V> deserializeNodeEntryMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
throws Exception
{
Map<K, V> map = new HashMap<>();
- putArrayNodeInMap( inputNode,
- this.<K>buildDeserializeInputNodeFunction( mapType.keyType() ),
- this.<V>buildDeserializeInputNodeFunction( mapType.valueType() ),
+ putArrayNodeInMap( module,
+ inputNode,
+ this.<K>buildDeserializeInputNodeFunction( module, mapType.keyType() ),
+ this.<V>buildDeserializeInputNodeFunction( module, mapType.valueType() ),
map );
return map;
}
- private <V> Map<String, V> deserializeNodeObjectMap( MapType mapType, InputNodeType inputNode )
+ private <V> Map<String, V> deserializeNodeObjectMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
throws Exception
{
Map<String, V> map = new HashMap<>();
- putObjectNodeInMap( inputNode,
- this.<V>buildDeserializeInputNodeFunction( mapType.valueType() ),
+ putObjectNodeInMap( module,
+ inputNode,
+ this.<V>buildDeserializeInputNodeFunction( module, mapType.valueType() ),
map );
return map;
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeNodeGuessed( ValueType valueType, InputNodeType inputNode )
+ private <T> T deserializeNodeGuessed( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
throws Exception
{
- if( isObjectValue( inputNode ) )
+ if( isObjectValue( module, inputNode ) )
{
// Attempt ValueComposite deserialization
ValueCompositeType valueCompositeType;
- if( objectHasField( inputNode, "_type" ) ) // with _type info
+ if( objectHasField( module, inputNode, "_type" ) ) // with _type info
{
String typeInfo = this.getObjectFieldValue(
+ module,
inputNode,
"_type",
- this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
- ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( typeInfo );
+ this.<String>buildDeserializeInputNodeFunction( module, new ValueType( String.class ) ) );
+ ValueDescriptor valueDescriptor = module.valueDescriptor( typeInfo );
if( valueDescriptor == null )
{
throw new ValueSerializationException( "Specified value type could not be resolved: " + typeInfo );
@@ -779,10 +748,10 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
}
else // without _type info
{
- ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( valueType.types()
- .findFirst()
- .get()
- .getName() );
+ ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.types()
+ .findFirst()
+ .get()
+ .getName() );
if( valueDescriptor == null )
{
throw new ValueSerializationException( "Don't know how to deserialize " + inputNode );
@@ -790,27 +759,27 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
valueCompositeType = valueDescriptor.valueType();
}
Class<?> valueBuilderType = valueCompositeType.types().findFirst().orElse( null );
- return deserializeValueComposite( valueCompositeType, valueBuilderType, inputNode );
+ return deserializeValueComposite( module, valueCompositeType, valueBuilderType, inputNode );
}
// Last resort : base64 java deserialization
- return (T) deserializeBase64Serialized( inputNode );
+ return (T) deserializeBase64Serialized( module, inputNode );
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeBase64Serialized( InputNodeType inputNode )
+ private <T> T deserializeBase64Serialized( ModuleDescriptor module, InputNodeType inputNode )
throws Exception
{
- Object value = asSimpleValue( inputNode );
+ Object value = asSimpleValue( module, inputNode );
if( value == null )
{
return null;
}
String base64 = value.toString();
- return deserializeBase64Serialized( base64 );
+ return deserializeBase64Serialized( module, base64 );
}
@SuppressWarnings( "unchecked" )
- private <T> T deserializeBase64Serialized( String inputString )
+ private <T> T deserializeBase64Serialized( ModuleDescriptor module, String inputString )
throws Exception
{
byte[] bytes = inputString.getBytes( UTF_8 );
@@ -828,7 +797,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
//
/**
- * Called by the adapter on deserialization start, after {@link #adaptInput(java.io.InputStream)}.
+ * Called by the adapter on deserialization start, after {@link #adaptInput(ModuleDescriptor, java.io.InputStream)}.
*
* @param valueType ValueType
* @param input Input
@@ -836,7 +805,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
@SuppressWarnings( "UnusedParameters" )
- protected void onDeserializationStart( ValueType valueType, InputType input )
+ protected void onDeserializationStart( ModuleDescriptor module, ValueType valueType, InputType input )
throws Exception
{
// NOOP
@@ -850,7 +819,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected void onDeserializationEnd( ValueType valueType, InputType input )
+ protected void onDeserializationEnd( ModuleDescriptor module, ValueType valueType, InputType input )
throws Exception
{
// NOOP
@@ -869,7 +838,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract InputType adaptInput( InputStream input )
+ protected abstract InputType adaptInput( ModuleDescriptor module, InputStream input )
throws Exception;
/**
@@ -879,7 +848,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract Object readPlainValue( InputType input )
+ protected abstract Object readPlainValue( ModuleDescriptor module, InputType input )
throws Exception;
/**
@@ -892,7 +861,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract <T> Collection<T> readArrayInCollection( InputType input,
+ protected abstract <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+ InputType input,
Function<InputType, T> deserializer,
Collection<T> collection
)
@@ -926,7 +896,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract <K, V> Map<K, V> readMapInMap( InputType input,
+ protected abstract <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+ InputType input,
Function<InputType, K> keyDeserializer,
Function<InputType, V> valueDeserializer,
Map<K, V> map
@@ -940,19 +911,19 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract InputNodeType readObjectTree( InputType input )
+ protected abstract InputNodeType readObjectTree( ModuleDescriptor module, InputType input )
throws Exception;
//
// Tree Parsing Deserialization
//
- protected abstract Object asSimpleValue( InputNodeType inputNode )
+ protected abstract Object asSimpleValue( ModuleDescriptor module, InputNodeType inputNode )
throws Exception;
- protected abstract boolean isObjectValue( InputNodeType inputNode )
+ protected abstract boolean isObjectValue( ModuleDescriptor module, InputNodeType inputNode )
throws Exception;
- protected abstract boolean objectHasField( InputNodeType inputNode, String key )
+ protected abstract boolean objectHasField( ModuleDescriptor module, InputNodeType inputNode, String key )
throws Exception;
/**
@@ -967,26 +938,30 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
*
* @throws Exception that will be wrapped in a {@link ValueSerializationException}
*/
- protected abstract <T> T getObjectFieldValue( InputNodeType inputNode,
+ protected abstract <T> T getObjectFieldValue( ModuleDescriptor module,
+ InputNodeType inputNode,
String key,
Function<InputNodeType, T> valueDeserializer
)
throws Exception;
- protected abstract <T> void putArrayNodeInCollection( InputNodeType inputNode,
+ protected abstract <T> void putArrayNodeInCollection( ModuleDescriptor module,
+ InputNodeType inputNode,
Function<InputNodeType, T> deserializer,
Collection<T> collection
)
throws Exception;
- protected abstract <K, V> void putArrayNodeInMap( InputNodeType inputNode,
+ protected abstract <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+ InputNodeType inputNode,
Function<InputNodeType, K> keyDeserializer,
Function<InputNodeType, V> valueDeserializer,
Map<K, V> map
)
throws Exception;
- protected abstract <V> void putObjectNodeInMap( InputNodeType inputNode,
+ protected abstract <V> void putObjectNodeInMap( ModuleDescriptor module,
+ InputNodeType inputNode,
Function<InputNodeType, V> valueDeserializer,
Map<String, V> map
)
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
index 6dd152e..f74c5f4 100644
--- a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
+++ b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
@@ -23,17 +23,12 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Function;
+import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.value.ValueSerializationException;
+import org.apache.zest.spi.value.ValueDeserializerAdapter;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueDeserializer;
-import org.apache.zest.api.value.ValueSerializationException;
-import org.apache.zest.spi.value.ValueDeserializerAdapter;
/**
* ValueDeserializer reading Values from JSON documents using org.json.
@@ -42,31 +37,15 @@ public class OrgJsonValueDeserializer
extends ValueDeserializerAdapter<JSONTokener, Object>
{
- public OrgJsonValueDeserializer(
- @Structure Application application,
- @Structure Module module,
- @Service ServiceReference<ValueDeserializer> serviceRef )
- {
- super( application, module, serviceRef );
- }
-
- /* package */ OrgJsonValueDeserializer(
- Application application,
- Module module,
- Function<Application, Module> valuesModuleFinder )
- {
- super( application, module, valuesModuleFinder );
- }
-
@Override
- protected JSONTokener adaptInput( InputStream input )
+ protected JSONTokener adaptInput( ModuleDescriptor module, InputStream input )
throws Exception
{
return new JSONTokener( new InputStreamReader( input, "UTF-8" ) );
}
@Override
- protected Object readPlainValue( JSONTokener input )
+ protected Object readPlainValue( ModuleDescriptor module, JSONTokener input )
throws Exception
{
Object nextValue = input.nextValue();
@@ -75,18 +54,20 @@ public class OrgJsonValueDeserializer
return null;
}
else // Object or Array
- if( JSONObject.class.isAssignableFrom( nextValue.getClass() )
- || JSONArray.class.isAssignableFrom( nextValue.getClass() ) )
- {
- throw new ValueSerializationException( "Asked for a Value but found an Object or an Array." );
- }
+ if( JSONObject.class.isAssignableFrom( nextValue.getClass() )
+ || JSONArray.class.isAssignableFrom( nextValue.getClass() ) )
+ {
+ throw new ValueSerializationException( "Asked for a Value but found an Object or an Array." );
+ }
return nextValue;
}
@Override
- protected <T> Collection<T> readArrayInCollection( JSONTokener input,
+ protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+ JSONTokener input,
Function<JSONTokener, T> deserializer,
- Collection<T> collection )
+ Collection<T> collection
+ )
throws Exception
{
char c = input.nextClean();
@@ -129,7 +110,7 @@ public class OrgJsonValueDeserializer
return collection;
}
input.back();
- for( ;; )
+ for(; ; )
{
if( input.nextClean() == ',' )
{
@@ -144,32 +125,34 @@ public class OrgJsonValueDeserializer
c = input.nextClean();
switch( c )
{
- case ';':
- case ',':
- if( input.nextClean() == ']' )
- {
- return collection;
- }
- input.back();
- break;
- case ']':
- case ')':
- if( q != c )
- {
- throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
- }
+ case ';':
+ case ',':
+ if( input.nextClean() == ']' )
+ {
return collection;
- default:
- throw input.syntaxError( "Expected a ',' or ']'" );
+ }
+ input.back();
+ break;
+ case ']':
+ case ')':
+ if( q != c )
+ {
+ throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
+ }
+ return collection;
+ default:
+ throw input.syntaxError( "Expected a ',' or ']'" );
}
}
}
@Override
- protected <K, V> Map<K, V> readMapInMap( JSONTokener input,
+ protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+ JSONTokener input,
Function<JSONTokener, K> keyDeserializer,
Function<JSONTokener, V> valueDeserializer,
- Map<K, V> map )
+ Map<K, V> map
+ )
throws Exception
{
char c = input.nextClean();
@@ -213,7 +196,7 @@ public class OrgJsonValueDeserializer
}
input.back();
- for( ;; )
+ for(; ; )
{
if( input.nextClean() == ',' )
{
@@ -238,14 +221,14 @@ public class OrgJsonValueDeserializer
c = input.nextClean();
switch( c )
{
- case 0:
- throw input.syntaxError( "A JSONObject text must end with '}'" );
- case '}':
- breakIteration = true;
- continue;
- default:
- input.back();
- objectKey = input.nextValue().toString();
+ case 0:
+ throw input.syntaxError( "A JSONObject text must end with '}'" );
+ case '}':
+ breakIteration = true;
+ continue;
+ default:
+ input.back();
+ objectKey = input.nextValue().toString();
}
/*
@@ -282,20 +265,20 @@ public class OrgJsonValueDeserializer
*/
switch( input.nextClean() )
{
- case ';':
- case ',':
- if( input.nextClean() == '}' )
- {
- breakIteration = true;
- continue;
- }
- input.back();
- continue;
- case '}':
+ case ';':
+ case ',':
+ if( input.nextClean() == '}' )
+ {
breakIteration = true;
continue;
- default:
- throw input.syntaxError( "Expected a ',' or '}'" );
+ }
+ input.back();
+ continue;
+ case '}':
+ breakIteration = true;
+ continue;
+ default:
+ throw input.syntaxError( "Expected a ',' or '}'" );
}
}
if( key != null )
@@ -306,23 +289,23 @@ public class OrgJsonValueDeserializer
c = input.nextClean();
switch( c )
{
- case ';':
- case ',':
- if( input.nextClean() == ']' )
- {
- return map;
- }
- input.back();
- break;
- case ']':
- case ')':
- if( q != c )
- {
- throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
- }
+ case ';':
+ case ',':
+ if( input.nextClean() == ']' )
+ {
return map;
- default:
- throw input.syntaxError( "Expected a ',' or ']'" );
+ }
+ input.back();
+ break;
+ case ']':
+ case ')':
+ if( q != c )
+ {
+ throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
+ }
+ return map;
+ default:
+ throw input.syntaxError( "Expected a ',' or ']'" );
}
}
}
@@ -331,7 +314,9 @@ public class OrgJsonValueDeserializer
// Deserialization - Tree parsing
//
@Override
- protected JSONObject readObjectTree( JSONTokener input )
+ protected JSONObject readObjectTree( ModuleDescriptor module,
+ JSONTokener input
+ )
throws Exception
{
Object objectTree = input.nextValue();
@@ -343,7 +328,7 @@ public class OrgJsonValueDeserializer
}
@Override
- protected Object asSimpleValue( Object inputNode )
+ protected Object asSimpleValue( ModuleDescriptor module, Object inputNode )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
@@ -358,7 +343,7 @@ public class OrgJsonValueDeserializer
}
@Override
- protected boolean isObjectValue( Object inputNode )
+ protected boolean isObjectValue( ModuleDescriptor module, Object inputNode )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
@@ -369,7 +354,7 @@ public class OrgJsonValueDeserializer
}
@Override
- protected boolean objectHasField( Object inputNode, String key )
+ protected boolean objectHasField( ModuleDescriptor module, Object inputNode, String key )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
@@ -385,7 +370,11 @@ public class OrgJsonValueDeserializer
}
@Override
- protected <T> T getObjectFieldValue( Object inputNode, String key, Function<Object, T> valueDeserializer )
+ protected <T> T getObjectFieldValue( ModuleDescriptor module,
+ Object inputNode,
+ String key,
+ Function<Object, T> valueDeserializer
+ )
throws Exception
{
JSONObject json = (JSONObject) inputNode;
@@ -399,7 +388,11 @@ public class OrgJsonValueDeserializer
}
@Override
- protected <T> void putArrayNodeInCollection( Object inputNode, Function<Object, T> deserializer, Collection<T> collection )
+ protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+ Object inputNode,
+ Function<Object, T> deserializer,
+ Collection<T> collection
+ )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
@@ -420,7 +413,12 @@ public class OrgJsonValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( Object inputNode, Function<Object, K> keyDeserializer, Function<Object, V> valueDeserializer, Map<K, V> map )
+ protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+ Object inputNode,
+ Function<Object, K> keyDeserializer,
+ Function<Object, V> valueDeserializer,
+ Map<K, V> map
+ )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
@@ -452,7 +450,11 @@ public class OrgJsonValueDeserializer
}
@Override
- protected <V> void putObjectNodeInMap( Object inputNode, Function<Object, V> valueDeserializer, Map<String, V> map )
+ protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+ Object inputNode,
+ Function<Object, V> valueDeserializer,
+ Map<String, V> map
+ )
throws Exception
{
if( JSONObject.NULL.equals( inputNode ) )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
deleted file mode 100644
index 9ce1892..0000000
--- a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin. All Rights Reserved.
- *
- * Licensed 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.valueserialization.orgjson;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.api.value.ValueSerializationException;
-
-/**
- * ValueSerialization producing and consuming JSON documents using org.json.
- *
- * <p>
- * This class is used internally by the Zest Runtime to provide default ValueSerialization when no
- * ValueSerialization Service is available.
- * </p>
- * <p>
- * In application code, prefer the use of {@link OrgJsonValueSerializationService}.
- * </p>
- */
-public class OrgJsonValueSerialization
- implements ValueSerialization
-{
-
- private final OrgJsonValueSerializer serializer;
- private final OrgJsonValueDeserializer deserializer;
-
- public OrgJsonValueSerialization( Application application, Module module, final Module valuesModule )
- {
- this.serializer = new OrgJsonValueSerializer();
- this.deserializer = new OrgJsonValueDeserializer( application, module, from -> valuesModule );
- }
-
- @Override
- public <T> Function<T, String> serialize()
- {
- return serializer.serialize();
- }
-
- @Override
- public <T> Function<T, String> serialize( Options options )
- {
- return serializer.serialize( options );
- }
-
- @Override
- @Deprecated
- public <T> Function<T, String> serialize( boolean includeTypeInfo )
- {
- return serializer.serialize( includeTypeInfo );
- }
-
- @Override
- public String serialize( Object object )
- throws ValueSerializationException
- {
- return serializer.serialize( object );
- }
-
- @Override
- public String serialize( Options options, Object object )
- throws ValueSerializationException
- {
- return serializer.serialize( options, object );
- }
-
- @Override
- @Deprecated
- public String serialize( Object object, boolean includeTypeInfo )
- throws ValueSerializationException
- {
- return serializer.serialize( object, includeTypeInfo );
- }
-
- @Override
- public void serialize( Object object, OutputStream output )
- throws ValueSerializationException
- {
- serializer.serialize( object, output );
- }
-
- @Override
- public void serialize( Options options, Object object, OutputStream output )
- throws ValueSerializationException
- {
- serializer.serialize( options, object, output );
- }
-
- @Override
- @Deprecated
- public void serialize( Object object, OutputStream output, boolean includeTypeInfo )
- throws ValueSerializationException
- {
- serializer.serialize( object, output, includeTypeInfo );
- }
-
- @Override
- public <T> Function<String, T> deserialize( Class<T> type )
- {
- return deserializer.deserialize( type );
- }
-
- @Override
- public <T> Function<String, T> deserialize( ValueType valueType )
- {
- return deserializer.deserialize( valueType );
- }
-
- @Override
- public <T> BiFunction<ValueType, String, T> deserialize()
- {
- return deserializer.deserialize();
- }
-
- @Override
- public <T> T deserialize( Class<?> type, String input )
- throws ValueSerializationException
- {
- return deserializer.deserialize( type, input );
- }
-
- @Override
- public <T> T deserialize( ValueType type, String input )
- throws ValueSerializationException
- {
- return deserializer.deserialize( type, input );
- }
-
- @Override
- public <T> T deserialize( Class<?> type, InputStream input )
- throws ValueSerializationException
- {
- return deserializer.deserialize( new ValueType( type ), input );
- }
-
- @Override
- public <T> T deserialize( ValueType type, InputStream input )
- throws ValueSerializationException
- {
- return deserializer.deserialize( type, input );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
index 4d7dec3..1cbce1d 100644
--- a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
+++ b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
@@ -45,6 +45,7 @@ public class JSONManyAssociationStateTest
state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
state.put( JSONKeys.NAMED_ASSOCIATIONS, new JSONObject() );
JSONEntityState entityState = new JSONEntityState( null,
+ null,
"0",
System.currentTimeMillis(),
EntityReference.parseEntityReference( "123" ),
@@ -70,6 +71,7 @@ public class JSONManyAssociationStateTest
state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
state.put( JSONKeys.NAMED_ASSOCIATIONS, new JSONObject() );
JSONEntityState entityState = new JSONEntityState( null,
+ null,
"0",
System.currentTimeMillis(),
EntityReference.parseEntityReference( "123" ),
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
index 29c27aa..6254de9 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
@@ -14,18 +14,24 @@
package org.apache.zest.test;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.zest.api.object.ObjectFactory;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.service.ServiceFinder;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.bootstrap.ApplicationAssembly;
import org.apache.zest.bootstrap.Assembler;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.junit.After;
+import org.junit.Before;
/**
* Base class for Composite tests.
@@ -36,7 +42,23 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
@Structure
protected UnitOfWorkFactory uowf;
- protected ModuleSpi module;
+ @Structure
+ protected TransientBuilderFactory transientBuilderFactory;
+
+ @Structure
+ protected ValueBuilderFactory valueBuilderFactory;
+
+ @Structure
+ protected ServiceFinder serviceFinder;
+
+ @Structure
+ protected ObjectFactory objectFactory;
+
+ @Structure
+ protected QueryBuilderFactory queryBuilderFactory;
+
+ @Structure
+ protected ModuleDescriptor module;
@Before
@Override
@@ -48,7 +70,7 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
{
return; // failure in Assembly.
}
- module = (ModuleSpi) application.findModule( "Layer 1", "Module 1" );
+ Module module = application.findModule( "Layer 1", "Module 1" );
module.injectTo( this );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
index e697375..ebacb42 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
@@ -45,7 +45,7 @@ public abstract class AbstractCachePoolTest
throws Exception
{
super.setUp();
- cachePool = module.findService( CachePool.class ).get();
+ cachePool = module.instance().findService( CachePool.class ).get();
cache = cachePool.fetchCache( "1", String.class );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
index 8712911..a6fff82 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
@@ -45,6 +45,7 @@ public abstract class AbstractConfigurationDeserializationTest extends AbstractZ
throws AssemblyException
{
// ModuleAssembly storageModule = module.layer().module( "storage" );
+ @SuppressWarnings( "UnnecessaryLocalVariable" )
ModuleAssembly storageModule = module; // Disable the more complex set up. The entire value serialization has gotten the deserialization type lookup problem wrong.
module.configurations( ConfigSerializationConfig.class );
module.values( Host.class );
@@ -57,7 +58,7 @@ public abstract class AbstractConfigurationDeserializationTest extends AbstractZ
@Test
public void givenServiceWhenInitializingExpectCorrectDeserialization()
{
- ServiceReference<MyService> ref = module.findService( MyService.class );
+ ServiceReference<MyService> ref = module.instance().findService( MyService.class );
assertThat( ref, notNullValue() );
assertThat( ref.isAvailable(), equalTo( true ) );
MyService myService = ref.get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index de6956d..ad7a116 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -25,11 +25,12 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
@@ -69,6 +70,9 @@ public abstract class AbstractEntityStoreTest
@Service
private EntityStore store;
+ @Structure
+ private Module moduleInstance;
+
@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
@@ -79,12 +83,6 @@ public abstract class AbstractEntityStoreTest
module.objects( getClass() );
}
- @Before
- public void init()
- {
- module.injectTo( this );
- }
-
@Override
@After
public void tearDown()
@@ -115,23 +113,23 @@ public abstract class AbstractEntityStoreTest
instance.localDateValue().set( new LocalDate( "2020-03-04" ) );
instance.association().set( instance );
- ValueBuilder<Tjabba> valueBuilder4 = module.newValueBuilder( Tjabba.class );
+ ValueBuilder<Tjabba> valueBuilder4 = moduleInstance.newValueBuilder( Tjabba.class );
final Tjabba prototype4 = valueBuilder4.prototype();
prototype4.bling().set( "BlinkLjus" );
// Set value
- ValueBuilder<TestValue2> valueBuilder2 = module.newValueBuilder( TestValue2.class );
+ ValueBuilder<TestValue2> valueBuilder2 = moduleInstance.newValueBuilder( TestValue2.class );
TestValue2 prototype2 = valueBuilder2.prototype();
prototype2.stringValue().set( "Bar" );
Tjabba newValue = valueBuilder4.newInstance();
prototype2.anotherValue().set( newValue );
prototype2.anotherValue().set( newValue );
- ValueBuilder<Tjabba> valueBuilder3 = module.newValueBuilder( Tjabba.class );
+ ValueBuilder<Tjabba> valueBuilder3 = moduleInstance.newValueBuilder( Tjabba.class );
final Tjabba prototype3 = valueBuilder3.prototype();
prototype3.bling().set( "Brakfis" );
- ValueBuilder<TestValue> valueBuilder1 = module.newValueBuilder( TestValue.class );
+ ValueBuilder<TestValue> valueBuilder1 = moduleInstance.newValueBuilder( TestValue.class );
TestValue prototype = valueBuilder1.prototype();
prototype.enumProperty().set( TestEnum.VALUE3 );
prototype.listProperty().get().add( "Foo" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
index e9c18b5..527b4bf 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
@@ -80,9 +80,9 @@ public class AbstractAnyQueryTest
throws Exception
{
super.setUp();
- TestData.populate( module );
+ TestData.populate( module.instance() );
- this.unitOfWork = this.module.unitOfWorkFactory().newUnitOfWork();
+ this.unitOfWork = this.module.instance().unitOfWorkFactory().newUnitOfWork();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
index 4698753..d9704ce 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
@@ -22,6 +22,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
import org.junit.Test;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.query.Query;
@@ -52,24 +54,28 @@ public abstract class AbstractComplexQueryTest
private static final String JOE = "Joe Doe";
private static final String JACK = "Jack Doe";
+ @Structure
+ Module moduleInstance;
+
+
@Test
public void showNetwork()
throws IOException
{
- IndexExporter indexerExporter = module.findService( IndexExporter.class ).get();
+ IndexExporter indexerExporter = moduleInstance.findService( IndexExporter.class ).get();
indexerExporter.exportReadableToStream( System.out );
}
@Test
public void script01()
{
- ValueBuilder<Address> addressBuilder = this.module.newValueBuilder( Address.class );
+ ValueBuilder<Address> addressBuilder = this.moduleInstance.newValueBuilder( Address.class );
Address address = addressBuilder.prototype();
address.line1().set( "Qi Street 4j" );
address.line2().set( "Off main Java Street" );
address.zipcode().set( "12345" );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Address> addressProp = templateFor( Person.class ).address();
qb = qb.where( eq( addressProp, addressBuilder.newInstance() ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -81,13 +87,13 @@ public abstract class AbstractComplexQueryTest
@Test
public void script02()
{
- ValueBuilder<Address> addressBuilder = this.module.newValueBuilder( Address.class );
+ ValueBuilder<Address> addressBuilder = this.moduleInstance.newValueBuilder( Address.class );
Address address = addressBuilder.prototype();
address.line1().set( "Qi Street 4j" );
address.line2().set( "Off main Java Street" );
address.zipcode().set( "12345" );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Address> addressProp = templateFor( Person.class ).address();
qb = qb.where( not( eq( addressProp, addressBuilder.newInstance() ) ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -99,20 +105,20 @@ public abstract class AbstractComplexQueryTest
@Test
public void script03()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
List<QueryParam> queryParams = new ArrayList<>( 2 );
QueryParam param = queryParamBuilder.prototype();
param.name().set( "user" );
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
queryParams.add( queryParamBuilder.newInstance() );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( eq( paramsProp, queryParams ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -124,7 +130,7 @@ public abstract class AbstractComplexQueryTest
@Test
public void script04()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
List<QueryParam> queryParams = new ArrayList<>( 2 );
QueryParam param = queryParamBuilder.prototype();
// Different order
@@ -132,13 +138,13 @@ public abstract class AbstractComplexQueryTest
param.value().set( "somepassword" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "user" );
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( eq( paramsProp, queryParams ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -150,20 +156,20 @@ public abstract class AbstractComplexQueryTest
@Test
public void script05()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
List<QueryParam> queryParams = new ArrayList<>( 2 );
QueryParam param = queryParamBuilder.prototype();
param.name().set( "user" );
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
queryParams.add( queryParamBuilder.newInstance() );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( not( eq( paramsProp, queryParams ) ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -175,9 +181,9 @@ public abstract class AbstractComplexQueryTest
@Test
public void script06()
{
- ValueBuilder<URL> urlBuilder = this.module.newValueBuilder( URL.class );
- ValueBuilder<Protocol> protocolBuilder = this.module.newValueBuilder( Protocol.class );
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<URL> urlBuilder = this.moduleInstance.newValueBuilder( URL.class );
+ ValueBuilder<Protocol> protocolBuilder = this.moduleInstance.newValueBuilder( Protocol.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
Protocol protocol = protocolBuilder.prototype();
protocol.value().set( "http" );
@@ -188,7 +194,7 @@ public abstract class AbstractComplexQueryTest
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
@@ -198,7 +204,7 @@ public abstract class AbstractComplexQueryTest
url.protocol().set( protocolBuilder.newInstance() );
url.queryParams().set( queryParams );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<URL> websiteProp = templateFor( Person.class ).personalWebsite();
qb = qb.where( eq( websiteProp, urlBuilder.newInstance() ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -210,9 +216,9 @@ public abstract class AbstractComplexQueryTest
@Test
public void script07()
{
- ValueBuilder<URL> urlBuilder = this.module.newValueBuilder( URL.class );
- ValueBuilder<Protocol> protocolBuilder = this.module.newValueBuilder( Protocol.class );
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<URL> urlBuilder = this.moduleInstance.newValueBuilder( URL.class );
+ ValueBuilder<Protocol> protocolBuilder = this.moduleInstance.newValueBuilder( Protocol.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
Protocol protocol = protocolBuilder.prototype();
protocol.value().set( "http" );
@@ -223,7 +229,7 @@ public abstract class AbstractComplexQueryTest
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
@@ -233,7 +239,7 @@ public abstract class AbstractComplexQueryTest
url.protocol().set( protocolBuilder.newInstance() );
url.queryParams().set( queryParams );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<URL> websiteProp = templateFor( Person.class ).personalWebsite();
qb = qb.where( not( eq( websiteProp, urlBuilder.newInstance() ) ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -245,12 +251,12 @@ public abstract class AbstractComplexQueryTest
@Test
public void script08()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
QueryParam param = queryParamBuilder.prototype();
param.name().set( "user" );
param.value().set( "jackdoe" );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( contains( paramsProp, queryParamBuilder.newInstance() ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -261,13 +267,13 @@ public abstract class AbstractComplexQueryTest
@Test
public void script09()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
QueryParam param = queryParamBuilder.prototype();
param.name().set( "user" );
param.value().set( "jackdoe" );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( not( contains( paramsProp, queryParamBuilder.newInstance() ) ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -278,7 +284,7 @@ public abstract class AbstractComplexQueryTest
@Test
public void script10()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
List<QueryParam> queryParams = new ArrayList<>( 2 );
QueryParam param = queryParamBuilder.prototype();
@@ -286,13 +292,13 @@ public abstract class AbstractComplexQueryTest
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
queryParams.add( queryParamBuilder.newInstance() );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( containsAll( paramsProp, queryParams ) );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -303,7 +309,7 @@ public abstract class AbstractComplexQueryTest
@Test
public void script11()
{
- ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
List<QueryParam> queryParams = new ArrayList<>( 2 );
QueryParam param = queryParamBuilder.prototype();
@@ -311,13 +317,13 @@ public abstract class AbstractComplexQueryTest
param.value().set( "jackdoe" );
queryParams.add( queryParamBuilder.newInstance() );
- queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+ queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
param = queryParamBuilder.prototype();
param.name().set( "password" );
param.value().set( "somepassword" );
queryParams.add( queryParamBuilder.newInstance() );
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
qb = qb.where( not( containsAll( paramsProp, queryParams ) ) );
Query<Person> query = unitOfWork.newQuery( qb );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
index f02c0f9..1c5a4c0 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
@@ -27,6 +27,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.composite.Composite;
@@ -81,6 +83,10 @@ public abstract class AbstractEntityFinderTest
private static final String ANN = "Ann Doe";
+ @Structure
+ Module moduleInstance;
+
+
private EntityFinder entityFinder;
@Before
@@ -89,14 +95,14 @@ public abstract class AbstractEntityFinderTest
throws Exception
{
super.setUp();
- entityFinder = this.module.findService( EntityFinder.class ).get();
+ entityFinder = this.moduleInstance.findService( EntityFinder.class ).get();
}
@Test
public void showNetwork()
throws IOException
{
- final ServiceReference<IndexExporter> indexerService = this.module.findService( IndexExporter.class );
+ final ServiceReference<IndexExporter> indexerService = this.moduleInstance.findService( IndexExporter.class );
final IndexExporter exporter = indexerService.get();
exporter.exportReadableToStream( System.out );
// todo asserts
[33/34] zest-java git commit: Fixed testcases that seems to have
always been wrong... Should be double checked by someone else.
Posted by ni...@apache.org.
Fixed testcases that seems to have always been wrong... Should be double checked by someone else.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/612f952a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/612f952a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/612f952a
Branch: refs/heads/develop
Commit: 612f952a338ef93e305b90321de04b5ccc9c7930
Parents: 962badc
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Apr 14 09:37:50 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Apr 14 09:37:50 2016 +0800
----------------------------------------------------------------------
.../bootstrap/layered/LayeredLayerAssembler.java | 12 ++++++------
.../test/indexing/AbstractNamedQueryTest.java | 18 ++++++++++--------
.../zest/test/indexing/AbstractQueryTest.java | 8 ++++----
.../apache/zest/test/indexing/NameableAssert.java | 4 +++-
.../org/apache/zest/test/indexing/TestData.java | 1 +
5 files changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/612f952a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
index ccec8d2..46a3a83 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
@@ -28,15 +28,15 @@ public abstract class LayeredLayerAssembler
{
private HashMap<Class<? extends ModuleAssembler>, ModuleAssembler> assemblers = new HashMap<>();
- protected ModuleAssembly createModule( LayerAssembly layer, Class<? extends ModuleAssembler> modulerAssemblerClass )
+ protected ModuleAssembly createModule( LayerAssembly layer, Class<? extends ModuleAssembler> moduleAssemblerClass )
{
try
{
- ModuleAssembler moduleAssembler = instantiateAssembler( layer, modulerAssemblerClass );
- String moduleName = createModuleName( modulerAssemblerClass );
- LayeredApplicationAssembler.setNameIfPresent( modulerAssemblerClass, moduleName );
+ ModuleAssembler moduleAssembler = instantiateAssembler( layer, moduleAssemblerClass );
+ String moduleName = createModuleName( moduleAssemblerClass );
+ LayeredApplicationAssembler.setNameIfPresent( moduleAssemblerClass, moduleName );
ModuleAssembly module = layer.module( moduleName );
- assemblers.put( modulerAssemblerClass, moduleAssembler );
+ assemblers.put( moduleAssemblerClass, moduleAssembler );
ModuleAssembly assembly = moduleAssembler.assemble( layer, module );
if( assembly == null )
{
@@ -46,7 +46,7 @@ public abstract class LayeredLayerAssembler
}
catch( Exception e )
{
- throw new IllegalArgumentException( "Unable to instantiate module with " + modulerAssemblerClass.getSimpleName(), e );
+ throw new IllegalArgumentException( "Unable to instantiate module with " + moduleAssemblerClass.getSimpleName(), e );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/612f952a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
index cac1c7e..ecfbc2a 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
@@ -112,8 +112,8 @@ public abstract class AbstractNamedQueryTest
.newQueryBuilder( Nameable.class )
.where( queries.get( "script03" ) ) );
System.out.println( "*** script03: " + query );
- verifyUnorderedResults( query, "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
- "Programming", "Cars" );
+ verifyUnorderedResults( query, "Joe Doe", "Felix", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking",
+ "Gaming", "Programming", "Cars" );
}
@Test
@@ -267,14 +267,15 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
+ Predicate<Composite> predicate = queries.get( "script17" );
final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
- .where( queries.get( "script17" ) ) );
+ .where( predicate ) );
query.orderBy( orderBy( nameable.name() ) );
query.firstResult( 3 );
query.maxResults( 3 );
System.out.println( "*** script17: " + query );
- verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe" );
+ verifyOrderedResults( query, "Felix", "Gaming", "Jack Doe" );
}
@Test
@@ -282,13 +283,14 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
+ Predicate<Composite> predicate = queries.get( "script18" );
final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
- .where( queries.get( "script18" ) ) );
+ .where( predicate ) );
query.orderBy( orderBy( nameable.name() ) );
System.out.println( "*** script18: " + query );
- verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur",
- "Penang", "Programming" );
+ verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Felix", "Gaming", "Jack Doe", "Joe Doe",
+ "Kuala Lumpur", "Penang", "Programming" );
}
@Test
@@ -301,7 +303,7 @@ public abstract class AbstractNamedQueryTest
.where( queries.get( "script19" ) ) );
query.orderBy( orderBy( nameable.name() ) );
System.out.println( "*** script19: " + query );
- verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" );
+ verifyOrderedResults( query, "Felix", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" );
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/612f952a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
index 852094a..b442434 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
@@ -117,7 +117,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
System.out.println( "*** script03: " + query );
- verifyUnorderedResults( query, "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
+ verifyUnorderedResults( query, "Felix", "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
"Programming", "Cars" );
}
@@ -314,7 +314,7 @@ public abstract class AbstractQueryTest
query.firstResult( 3 );
query.maxResults( 2 );
System.out.println( "*** script17: " + query );
- verifyOrderedResults( query, "Gaming", "Jack Doe" );
+ verifyOrderedResults( query, "Felix", "Gaming" );
}
@Test
@@ -327,7 +327,7 @@ public abstract class AbstractQueryTest
Query<Nameable> query = unitOfWork.newQuery( qb );
query.orderBy( orderBy( nameable.name() ) );
System.out.println( "*** script18: " + query );
- verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur",
+ verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Felix", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur",
"Penang", "Programming" );
}
@@ -341,7 +341,7 @@ public abstract class AbstractQueryTest
Query<Nameable> query = unitOfWork.newQuery( qb.where( gt( nameable.name(), "D" ) ) );
query.orderBy( orderBy( nameable.name() ) );
System.out.println( "*** script19: " + query );
- verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" );
+ verifyOrderedResults( query, "Felix", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" );
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/612f952a/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
index e6f8c52..32ee9db 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
@@ -19,6 +19,7 @@ package org.apache.zest.test.indexing;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -97,7 +98,8 @@ public class NameableAssert
public static String[] allNames()
{
- return world.values().toArray( new String[ world.size() ] );
+ Collection<String> values = world.values();
+ return values.toArray( new String[ world.size() ] );
}
public static void verifyUnorderedResults( final Iterable<? extends Nameable> results, final String... names )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/612f952a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index 48cd6b5..e765eb0 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -238,6 +238,7 @@ public class TestData
Cat felix = catBuilder.instance();
felix.name().set( "Felix" );
catBuilder.newInstance();
+ NameableAssert.trace( felix );
}
unitOfWork.complete();
}
[29/34] zest-java git commit: Fixed compile errors that has snuck in.
Posted by ni...@apache.org.
Fixed compile errors that has snuck in.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/be492ed6
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/be492ed6
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/be492ed6
Branch: refs/heads/develop
Commit: be492ed63de48807389ae0e69073774476771262
Parents: 15f156d
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 22:42:52 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 22:42:52 2016 +0800
----------------------------------------------------------------------
.../apache/zest/library/groovy/GroovyMixinTest.java | 4 ++--
.../zest/library/groovy/HelloSpeakerTest.java | 2 +-
.../apache/zest/library/scala/ScalaTraitMixin.java | 16 ++++++++++++----
3 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/be492ed6/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/GroovyMixinTest.java
----------------------------------------------------------------------
diff --git a/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/GroovyMixinTest.java b/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/GroovyMixinTest.java
index f5f6e9d..6f42453 100644
--- a/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/GroovyMixinTest.java
+++ b/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/GroovyMixinTest.java
@@ -29,8 +29,8 @@ public class GroovyMixinTest extends AbstractZestTest
@Test
public void testInvoke()
{
- GroovyComposite domain1 = module.newTransient( GroovyComposite.class );
- GroovyComposite domain2 = module.newTransient( GroovyComposite.class );
+ GroovyComposite domain1 = transientBuilderFactory.newTransient( GroovyComposite.class );
+ GroovyComposite domain2 = transientBuilderFactory.newTransient( GroovyComposite.class );
Assert.assertEquals( "do1() in Groovy:1", domain1.do1() );
Assert.assertEquals( "do1() in Groovy:2", domain1.do1() );
Assert.assertEquals( "do1() in Groovy:3", domain1.do1() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/be492ed6/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/HelloSpeakerTest.java
----------------------------------------------------------------------
diff --git a/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/HelloSpeakerTest.java b/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/HelloSpeakerTest.java
index ac36ec7..3f3e384 100644
--- a/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/HelloSpeakerTest.java
+++ b/libraries/lang-groovy/src/test/groovy/org/apache/zest/library/groovy/HelloSpeakerTest.java
@@ -35,7 +35,7 @@ public class HelloSpeakerTest extends AbstractZestTest
@Test
public void testHello()
{
- HelloSpeaker speaker = module.newTransient( HelloSpeaker.class );
+ HelloSpeaker speaker = transientBuilderFactory.newTransient( HelloSpeaker.class );
Assert.assertEquals( "Hello World!", speaker.sayHello( "World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/be492ed6/libraries/lang-scala/src/main/java/org/apache/zest/library/scala/ScalaTraitMixin.java
----------------------------------------------------------------------
diff --git a/libraries/lang-scala/src/main/java/org/apache/zest/library/scala/ScalaTraitMixin.java b/libraries/lang-scala/src/main/java/org/apache/zest/library/scala/ScalaTraitMixin.java
index 95dbc5c..493b6f9 100644
--- a/libraries/lang-scala/src/main/java/org/apache/zest/library/scala/ScalaTraitMixin.java
+++ b/libraries/lang-scala/src/main/java/org/apache/zest/library/scala/ScalaTraitMixin.java
@@ -30,9 +30,12 @@ import org.apache.zest.api.common.AppliesToFilter;
import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.Classes;
+import org.apache.zest.spi.ZestSPI;
import static org.apache.zest.api.util.Classes.interfacesOf;
@@ -45,6 +48,9 @@ public class ScalaTraitMixin
{
private static Map<Class<?>, Map<Method, InvocationHandler>> methods = new HashMap<>();
+ @Structure
+ private ZestSPI spi;
+
private Class<?> compositeType;
public ScalaTraitMixin( @This Composite composite )
@@ -79,8 +85,9 @@ public class ScalaTraitMixin
public Object invoke( Object composite, Method method, Object[] objects )
throws Throwable
{
- return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) ).module()
- .findService( method.getReturnType() );
+ CompositeInstance compositeInstance = (CompositeInstance) Proxy.getInvocationHandler( composite );
+ ModuleDescriptor moduleDescriptor = compositeInstance.module();
+ return moduleDescriptor.instance().findService( method.getReturnType() );
}
};
getHandlers( compositeType ).put( method, handler );
@@ -93,8 +100,9 @@ public class ScalaTraitMixin
public Object invoke( Object composite, Method method, Object[] objects )
throws Throwable
{
- return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) ).module()
- .findService( method.getReturnType() ).get();
+ CompositeInstance compositeInstance = (CompositeInstance) Proxy.getInvocationHandler( composite );
+ ModuleDescriptor moduleDescriptor = compositeInstance.module();
+ return moduleDescriptor.instance().findService( method.getReturnType() ).get();
}
};
getHandlers( compositeType ).put( method, handler );
[13/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
ZEST-132, ZEST-97
UnitOfWorkFactory as a customizable Service
UnitOfWork as a customizable Transient
Class can be a Transient directly, with itself as both the Composite Type and the Mixin.
SideEffects declarations on methods.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/a5be013f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/a5be013f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/a5be013f
Branch: refs/heads/develop
Commit: a5be013f39cba9642114e01486cdff0c355569f2
Parents: 6138c30
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Dec 16 14:17:22 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Dec 16 14:17:27 2015 +0800
----------------------------------------------------------------------
.../zest/api/configuration/Configuration.java | 7 +-
.../zest/api/entity/EntityBuilderTemplate.java | 2 +-
.../org/apache/zest/api/structure/Module.java | 15 +-
.../java/org/apache/zest/api/type/HasTypes.java | 6 +
.../org/apache/zest/api/type/ValueType.java | 1 +
.../apache/zest/api/unitofwork/UnitOfWork.java | 7 +-
.../zest/api/unitofwork/UnitOfWorkTemplate.java | 2 +-
.../unitofwork/concern/UnitOfWorkConcern.java | 20 +-
.../java/org/apache/zest/api/OperatorsTest.java | 8 +-
.../api/injection/scope/StateFieldTest.java | 4 +-
.../zest/api/property/PropertyErrorTest.java | 2 +-
.../apache/zest/api/unitofwork/RemovalTest.java | 4 +-
.../zest/api/value/DocumentationSupport.java | 67 +-
.../zest/api/value/ValueCompositeTest.java | 6 +-
.../apache/zest/bootstrap/ModuleAssembly.java | 36 +-
.../unitofwork/DefaultUnitOfWorkAssembler.java | 55 ++
.../apache/zest/bootstrap/ClassScannerTest.java | 2 +
.../apache/zest/runtime/ZestRuntimeImpl.java | 2 +-
.../association/ManyAssociationModel.java | 5 +-
.../association/ManyAssociationsModel.java | 2 +-
.../association/NamedAssociationModel.java | 5 +-
.../association/NamedAssociationsModel.java | 2 +-
.../bootstrap/CompositeAssemblyImpl.java | 141 +++-
.../runtime/bootstrap/ModuleAssemblyImpl.java | 12 +-
.../zest/runtime/composite/CompositeModel.java | 5 +-
.../composite/TransientBuilderInstance.java | 2 +-
.../runtime/composite/TransientClassLoader.java | 3 +-
.../zest/runtime/entity/EntityInstance.java | 5 +-
.../apache/zest/runtime/entity/EntityModel.java | 2 +-
.../runtime/entity/EntityStateInstance.java | 9 +-
.../runtime/injection/InjectedFieldsModel.java | 23 +-
.../StructureInjectionProviderFactory.java | 2 +-
.../zest/runtime/service/ServicesModel.java | 12 +
.../zest/runtime/structure/LayerInstance.java | 3 +-
.../zest/runtime/structure/ModuleInstance.java | 136 +---
.../runtime/structure/ModuleUnitOfWork.java | 769 ------------------
.../zest/runtime/structure/TypeLookup.java | 526 -------------
.../zest/runtime/structure/TypeLookupImpl.java | 538 +++++++++++++
.../runtime/structure/UsedLayersInstance.java | 3 +-
.../unitofwork/EntityBuilderInstance.java | 3 +-
.../zest/runtime/unitofwork/EntityFunction.java | 46 ++
.../runtime/unitofwork/ModuleUnitOfWork.java | 777 +++++++++++++++++++
.../unitofwork/UnitOfWorkFactoryMixin.java | 100 +++
.../runtime/unitofwork/UnitOfWorkInstance.java | 40 +-
.../runtime/value/ValueBuilderInstance.java | 2 +-
.../value/ValueBuilderWithPrototype.java | 2 +-
.../runtime/value/ValueBuilderWithState.java | 2 +-
.../zest/runtime/value/ValueStateInstance.java | 11 +-
.../apache/zest/api/common/OptionalTest.java | 6 +-
.../zest/api/common/PropertyErrorTest.java | 2 +-
.../zest/api/common/PropertyTypeTest.java | 2 +-
.../org/apache/zest/api/common/RemovalTest.java | 4 +-
.../zest/api/common/ValueCompositeTest.java | 2 +-
...faceCollisionWithRelatedReturnTypesTest.java | 18 +-
.../qi377/SetAssociationInSideEffectTest.java | 2 +-
.../apache/zest/regression/qi382/Qi382Test.java | 10 +-
.../apache/zest/regression/qi383/Qi383Test.java | 2 +-
.../apache/zest/regression/qi59/IssueTest.java | 4 +-
.../apache/zest/regression/qi94/IssueTest.java | 2 +-
.../org/apache/zest/runtime/ZestAPITest.java | 2 +-
.../org/apache/zest/runtime/ZestSPITest.java | 4 +-
.../AppliesToOrConditionQI241Test.java | 6 +-
.../association/AssociationAssignmentTest.java | 4 +-
.../association/AssociationEqualityTest.java | 18 +-
.../runtime/composite/TransientAsClassTest.java | 22 +-
.../composite/TransientClassLoaderTest.java | 30 +
.../runtime/concerns/GenericConcernTest.java | 2 +-
.../zest/runtime/entity/AggregatedTest.java | 10 +-
.../entity/EntityBuilderWithStateTest.java | 68 +-
.../entity/EntityCompositeEqualityTest.java | 2 +-
.../zest/runtime/entity/EntityCreationTest.java | 4 +-
.../zest/runtime/entity/EntityTypeTest.java | 2 +-
.../runtime/entity/EntityVisibilityTest.java | 58 +-
.../zest/runtime/entity/LifecycleTest.java | 4 +-
.../entity/associations/AssociationTest.java | 2 +-
.../associations/ImmutableAssociationTest.java | 8 +-
.../ConstructorInjectionOfThisTest.java | 2 +
.../injection/UnitOfWorkInjectionTest.java | 10 +-
.../TransientInstantiationTests.java | 1 -
.../zest/runtime/mixin/AssemblyMixinTest.java | 4 +-
.../zest/runtime/mixin/AssemblyRoleTest.java | 6 +-
.../runtime/objects/ObjectVisibilityTest.java | 35 +-
.../runtime/property/ImmutablePropertyTest.java | 2 +-
.../runtime/query/IterableQuerySourceTest.java | 6 +-
.../zest/runtime/query/NonQueryableTest.java | 4 +-
.../runtime/service/AvailableServiceTest.java | 4 +
.../zest/runtime/service/ConfigurationTest.java | 6 +-
.../runtime/service/ServiceVisibilityTest.java | 33 +-
.../structure/TypeToCompositeLookupTest.java | 26 +-
.../transients/TransientVisibilityTest.java | 44 +-
.../unitofwork/AutoCloseableUoWTest.java | 6 +-
.../unitofwork/PrivateEntityUnitOfWorkTest.java | 51 +-
.../zest/runtime/unitofwork/RemovalTest.java | 20 +-
.../unitofwork/UnitOfWorkFactoryTest.java | 2 +-
.../zest/runtime/value/ValueComposite2Test.java | 2 +
.../ValueInjectionDeserializationTest.java | 4 +-
.../zest/runtime/value/ValueVisibilityTest.java | 35 +-
.../runtime/value/ValueWithAssociationTest.java | 12 +-
.../visibility/VisibilityInUnitOfWorkTest.java | 55 +-
.../helpers/JSONMapEntityStoreMixin.java | 2 +-
.../helpers/MapEntityStoreMixin.java | 2 +-
.../org/apache/zest/spi/module/ModelModule.java | 107 ---
.../org/apache/zest/spi/module/ModuleSpi.java | 7 +
.../apache/zest/spi/structure/ModelModule.java | 107 +++
.../apache/zest/spi/structure/TypeLookup.java | 125 +++
.../zest/test/AbstractZestScenarioTest.java | 25 +-
.../org/apache/zest/test/AbstractZestTest.java | 13 +-
.../zest/test/cache/AbstractCachePoolTest.java | 1 -
.../test/entity/AbstractEntityStoreTest.java | 42 +-
.../test/indexing/AbstractAnyQueryTest.java | 2 +-
.../org/apache/zest/test/indexing/TestData.java | 15 +-
.../layered/assembly/AccountModule.java | 1 +
.../indexing/layered/assembly/ConfigModule.java | 1 +
.../indexing/layered/assembly/FamilyModule.java | 1 +
.../layered/assembly/PersistenceModule.java | 1 +
.../layered/assembly/TestExecutionModule.java | 1 +
.../layered/assembly/TestSuite1Module.java | 1 +
.../layered/assembly/TestSuite2Module.java | 1 +
.../layered/assembly/TestSuite3Module.java | 1 +
...AbstractValueCompositeSerializationTest.java | 4 +-
.../prefs/PreferencesEntityStoreMixin.java | 2 +-
.../entitystore/sql/SQLEntityStoreMixin.java | 2 +-
.../sql/DerbySQLEntityStoreTest.java | 2 +-
.../entitystore/sql/MySQLEntityStoreTest.java | 2 +-
.../sql/PostgreSQLEntityStoreTest.java | 2 +-
.../ElasticSearchQueryMultimoduleTest.java | 2 +
.../index/elasticsearch/ElasticSearchTest.java | 4 +-
.../index/elasticsearch/ImmenseTermTest.java | 6 +-
.../apache/zest/index/rdf/ContainsAllTest.java | 12 +-
.../org/apache/zest/index/rdf/ContainsTest.java | 12 +-
.../apache/zest/index/rdf/MultiLayeredTest.java | 3 +-
.../zest/index/rdf/RDFPerformanceTest.java | 16 +-
.../index/rdf/RdfNamedQueryMultimoduleTest.java | 3 +
.../zest/index/rdf/RdfQueryMultimoduleTest.java | 4 +
.../org/apache/zest/index/rdf/RdfQueryTest.java | 2 +
.../zest/index/rdf/qi173/Qi173IssueTest.java | 6 +-
.../zest/index/rdf/qi64/AbstractIssueTest.java | 2 +-
.../withPropagationMandatory/IssueTest.java | 8 +-
.../qi64/withPropagationRequired/IssueTest.java | 10 +-
.../withPropagationRequiresNew/IssueTest.java | 10 +-
.../zest/index/rdf/qi66/Qi66IssueTest.java | 4 +-
.../zest/index/rdf/qi95/Qi95IssueTest.java | 13 +-
.../zest/index/solr/SolrQueryServiceTest.java | 4 +-
.../support/skeletons/AbstractSQLQuerying.java | 8 +-
.../postgresql/PostgreSQLDBIntegrityTest.java | 10 +-
.../metrics/yammer/NoMetricsInstalledTest.java | 4 +-
.../apache/zest/metrics/yammer/YammerTest.java | 4 +-
.../apache/zest/migration/MigrationTest.java | 10 +-
.../zest/index/reindexer/ReindexerTest.java | 4 +-
.../zest/library/alarm/AlarmPointFactory.java | 29 +-
.../apache/zest/library/alarm/AlarmProxy.java | 20 +-
.../library/alarm/AlarmHistoryImplTest.java | 6 +-
.../zest/library/alarm/AlarmPointImplTest.java | 6 +-
.../zest/library/alarm/AlarmProxyTest.java | 2 +-
.../zest/library/alarm/AlarmServiceTest.java | 6 +-
.../library/alarm/ExtendedAlarmModelTest.java | 8 +-
.../library/alarm/SimpleAlarmModelTest.java | 8 +-
.../library/alarm/StandardAlarmModelTest.java | 8 +-
.../conversion/values/ValueToEntityMixin.java | 22 +-
.../conversion/values/EntityToValueTest.java | 10 +-
.../values/NestedValuesConversionTest.java | 2 +-
.../conversion/values/ValueToEntityTest.java | 26 +-
.../source/jdbm/JdbmEventStoreServiceTest.java | 4 +-
.../server/DomainEventSourceResourceSample.java | 2 +-
.../application/ApplicationEventTest.java | 6 +-
.../eventsourcing/domain/DomainEventTest.java | 2 +-
.../source/helper/DomainEventTrackerTest.java | 2 +-
.../domain/source/helper/EventRouterTest.java | 2 +
.../domain/source/helper/EventsTest.java | 2 +
.../source/helper/UnitOfWorkRouterTest.java | 2 +
.../library/scala/HelloWorldCompositeTest.java | 6 +-
.../zest/library/logging/DebuggingTest.java | 2 +-
.../zest/library/logging/TracingTest.java | 8 +-
.../rdf/entity/EntitySerializerTest.java | 2 +-
.../rdf/entity/EntityTypeSerializerTest.java | 2 +-
.../ContextResourceClientFactoryTest.java | 15 +-
.../rest/client/ContinuousIntegrationTest.java | 3 +-
.../rest/server/api/ContextResource.java | 24 +-
.../library/rest/server/api/ContextRestlet.java | 21 +-
.../requestreader/DefaultRequestReader.java | 74 +-
.../library/rest/admin/RestApplication.java | 23 +-
.../zest/library/rest/admin/RestTest.java | 56 +-
.../zest/library/scheduler/Scheduler.java | 3 -
.../library/scheduler/SchedulesHandler.java | 19 +-
.../defaults/DefaultScheduleFactoryMixin.java | 16 +-
.../library/scheduler/internal/Execution.java | 14 +-
.../scheduler/internal/SchedulerMixin.java | 8 +-
.../library/scheduler/internal/TaskRunner.java | 12 +-
.../library/scheduler/CronScheduleTest.java | 2 +-
.../zest/library/scheduler/SchedulerTest.java | 14 +-
.../domain/passwords/PasswordRealmMixin.java | 67 +-
.../library/shiro/domain/permissions/Role.java | 6 +-
.../shiro/domain/permissions/RoleFactory.java | 6 +-
.../zest/library/shiro/PasswordDomainTest.java | 9 +-
.../library/shiro/PermissionsDomainTest.java | 9 +-
.../sql/liquibase/LiquibaseServiceTest.java | 3 +
.../AbstractDataSourceServiceImporterMixin.java | 12 +-
.../DataSourceConfigurationManagerService.java | 7 +-
...taSourceConfigurationManagerServiceTest.java | 9 +-
.../uowfile/internal/UoWFileFactory.java | 5 +-
.../zest/library/uowfile/HasUoWFileTest.java | 30 +-
.../zest/library/uowfile/HasUoWFilesTest.java | 29 +-
.../zest/manual/recipes/assemble/Docs.java | 3 +-
.../createEntity/CarEntityFactoryMixin.java | 19 +-
.../bootstrap/sampledata/BaseDataService.java | 6 +-
.../infrastructure/model/EntityModel.java | 4 +-
.../bootstrap/test/TestApplication.java | 18 +-
.../sample_a/bootstrap/test/TestAssembler.java | 175 +++--
.../shipping/booking/BookNewCargoTest.java | 20 +-
.../booking/BuildDeliverySnapshotTest.java | 31 +-
.../shipping/handling/InspectCargoTest.java | 11 +-
.../handling/RegisterHandlingEventTest.java | 2 +-
.../sample_b/bootstrap/sampledata/BaseData.java | 26 +-
.../bootstrap/sampledata/BaseDataService.java | 26 +-
.../bootstrap/sampledata/SampleDataService.java | 48 +-
.../infrastructure/WicketZestApplication.java | 25 +-
.../sample_b/infrastructure/dci/Context.java | 17 +-
.../infrastructure/model/EntityModel.java | 4 +-
.../infrastructure/model/JSONModel.java | 4 +-
.../infrastructure/model/ReadOnlyModel.java | 11 +-
.../bootstrap/test/TestApplication.java | 31 +-
.../sample_b/bootstrap/test/TestAssembler.java | 18 +-
.../context/test/booking/BookNewCargoTest.java | 12 +-
.../booking/routing/AssignCargoToRouteTest.java | 2 +-
.../routing/RegisterNewDestinationTest.java | 2 +-
.../DeriveUpdatedRouteSpecTest.java | 2 +-
.../event/InspectArrivedCargoTest.java | 2 +-
.../event/InspectCargoInCustomsTest.java | 2 +-
.../event/InspectClaimedCargoTest.java | 2 +-
.../event/InspectLoadedCargoTest.java | 2 +-
.../event/InspectReceivedCargoTest.java | 2 +-
.../event/InspectUnhandledCargoTest.java | 2 +-
.../event/InspectUnloadedCargoTest.java | 2 +-
.../parsing/ParseHandlingEventDataTest.java | 4 +-
.../registration/RegisterHandlingEventTest.java | 18 +-
.../moneytransfer/test/TransferMoneyTest.java | 18 +-
.../moneytransfer/test/TransferMoneyTest2.java | 16 +-
.../sample/forum/context/EventsService.java | 15 +-
.../administration/ForumAdministration.java | 13 +-
.../administration/ForumsAdministration.java | 6 +-
.../zest/sample/forum/context/login/Login.java | 18 +-
.../sample/forum/context/view/ViewBoard.java | 10 +-
.../sample/forum/context/view/ViewPost.java | 8 +-
.../zest/sample/forum/data/entity/Forums.java | 12 +-
.../zest/sample/forum/data/entity/Users.java | 18 +-
.../sample/forum/domainevent/DomainEvent.java | 14 +-
.../zest/sample/forum/rest/ForumRestlet.java | 2 +-
.../sample/forum/service/BootstrapData.java | 16 +-
.../org/apache/zest/sample/sqlsupport/Main.java | 8 +-
.../AbstractEntityStorePerformanceTest.java | 285 +++----
.../sql/DerbySQLEntityStorePerformanceTest.java | 6 +-
.../PostgreSQLEntityStorePerformanceTest.java | 2 +-
.../indexing/rdf/QueryPerformanceTest.java | 29 +-
.../tree/TreeModelCellRenderer.properties | 2 +-
.../zest/envisage/sample/EnvisageSample.java | 6 +-
.../zest/tools/model/VisitableDetailTest.java | 24 +-
.../apache/zest/tutorials/hello/HelloTest4.java | 4 +-
.../demo/thirtyminutes/ThirtyMinutesDocs.java | 19 +-
258 files changed, 3560 insertions(+), 2970 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java b/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
index 6521c8b..9f6acc0 100644
--- a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
+++ b/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
@@ -36,6 +36,7 @@ import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueSerialization;
@@ -163,7 +164,7 @@ public interface Configuration<T>
private ServiceComposite me;
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Service
private Iterable<ServiceReference<ValueSerialization>> valueSerialization;
@@ -178,7 +179,7 @@ public interface Configuration<T>
if( configuration == null )
{
Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
- uow = module.newUnitOfWork( usecase );
+ uow = uowf.newUnitOfWork( usecase );
try
{
configuration = this.findConfigurationInstanceFor( me, uow );
@@ -253,7 +254,7 @@ public interface Configuration<T>
{
Module module = api.moduleOf( serviceComposite );
Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
- UnitOfWork buildUow = module.newUnitOfWork( usecase );
+ UnitOfWork buildUow = module.unitOfWorkFactory().newUnitOfWork( usecase );
Class<?> type = api.serviceDescriptorFor( serviceComposite ).types().findFirst().orElse( null );
Class<V> configType = serviceModel.configurationType();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
index 56afa2c..850f54a 100644
--- a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
+++ b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java
@@ -36,7 +36,7 @@ public abstract class EntityBuilderTemplate<T>
public T newInstance( Module module )
{
- EntityBuilder<T> builder = module.currentUnitOfWork().newEntityBuilder( type );
+ EntityBuilder<T> builder = module.unitOfWorkFactory().currentUnitOfWork().newEntityBuilder( type );
build( builder.instance() );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/structure/Module.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Module.java b/core/api/src/main/java/org/apache/zest/api/structure/Module.java
index e5a0aa6..38d8803 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/Module.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/Module.java
@@ -16,11 +16,8 @@ package org.apache.zest.api.structure;
import java.util.stream.Stream;
import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.composite.TransientBuilderFactory;
-import org.apache.zest.api.composite.TransientComposite;
import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.object.ObjectDescriptor;
@@ -44,7 +41,6 @@ public interface Module
ObjectFactory,
TransientBuilderFactory,
ValueBuilderFactory,
- UnitOfWorkFactory,
QueryBuilderFactory,
ServiceFinder
{
@@ -61,32 +57,43 @@ public interface Module
/**
* @param typeName name of a transient composite type
+ *
* @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
*/
TransientDescriptor transientDescriptor( String typeName );
/**
* @param typeName name of an entity composite type
+ *
* @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
*/
EntityDescriptor entityDescriptor( String typeName );
/**
* @param typeName name of an object type
+ *
* @return the descriptor for an object or null if the class could not be found or the object is not visible
*/
ObjectDescriptor objectDescriptor( String typeName );
/**
* @param typeName name of a value composite type
+ *
* @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
*/
ValueDescriptor valueDescriptor( String typeName );
Stream<? extends TransientDescriptor> transientComposites();
+
Stream<? extends ValueDescriptor> valueComposites();
+
Stream<? extends ServiceDescriptor> serviceComposites();
+
Stream<? extends EntityDescriptor> entityComposites();
+
Stream<? extends ImportedServiceDescriptor> importedServices();
+
Stream<? extends ObjectDescriptor> objects();
+
+ UnitOfWorkFactory unitOfWorkFactory();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java b/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
index 0bc0a35..0c3a0ac 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.api.type;
+import java.lang.reflect.Type;
import java.util.stream.Stream;
/**
@@ -26,4 +27,9 @@ import java.util.stream.Stream;
public interface HasTypes
{
Stream<Class<?>> types();
+
+ default boolean hasType( Type type )
+ {
+ return types().anyMatch( type::equals );
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/ValueType.java b/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
index dc28f10..80a2a81 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/ValueType.java
@@ -14,6 +14,7 @@
*/
package org.apache.zest.api.type;
+import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
index d735afa..b218e6d 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
@@ -18,6 +18,7 @@ package org.apache.zest.api.unitofwork;
import java.util.Map;
import java.util.function.Function;
import org.apache.zest.api.association.AssociationDescriptor;
+import org.apache.zest.api.common.Optional;
import org.apache.zest.api.composite.AmbiguousTypeException;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityReference;
@@ -147,7 +148,7 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
* @throws AmbiguousTypeException If several mixins implement the given type
* @throws LifecycleException if the entity cannot be created
*/
- <T> T newEntity( Class<T> type, String identity )
+ <T> T newEntity( Class<T> type, @Optional String identity )
throws EntityTypeNotFoundException, AmbiguousTypeException, LifecycleException;
/**
@@ -180,7 +181,7 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
* @throws EntityTypeNotFoundException if no EntityComposite type of the given mixin type has been registered
* @throws AmbiguousTypeException If several mixins implement the given type
*/
- <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
+ <T> EntityBuilder<T> newEntityBuilder( Class<T> type, @Optional String identity )
throws EntityTypeNotFoundException, AmbiguousTypeException;
/**
@@ -229,7 +230,7 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
* @throws EntityTypeNotFoundException If no mixins implements the given type
* @throws AmbiguousTypeException If several mixins implement the given type
*/
- <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type, String identity,
+ <T> EntityBuilder<T> newEntityBuilderWithState( Class<T> type, @Optional String identity,
Function<PropertyDescriptor, Object> propertyFunction,
Function<AssociationDescriptor, EntityReference> associationFunction,
Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
index cd91cb9..2d5be61 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplate.java
@@ -58,7 +58,7 @@ public abstract class UnitOfWorkTemplate<RESULT, ThrowableType extends Throwable
ThrowableType ex = null;
do
{
- UnitOfWork uow = module.newUnitOfWork( usecase );
+ UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( usecase );
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
index c79db85..ec6d54d 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/concern/UnitOfWorkConcern.java
@@ -23,9 +23,9 @@ import org.apache.zest.api.common.AppliesTo;
import org.apache.zest.api.concern.GenericConcern;
import org.apache.zest.api.injection.scope.Invocation;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
@@ -42,10 +42,10 @@ public class UnitOfWorkConcern
private static final Class<?>[] DEFAULT_DISCARD_CLASSES = new Class[]{ Throwable.class };
@Structure
- Module module;
+ private UnitOfWorkFactory uowf;
@Invocation
- UnitOfWorkPropagation propagation;
+ private UnitOfWorkPropagation propagation;
/**
* Handles method with {@code UnitOfWorkPropagation} annotation.
@@ -65,7 +65,7 @@ public class UnitOfWorkConcern
UnitOfWorkPropagation.Propagation propagationPolicy = propagation.value();
if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRED )
{
- if( module.isUnitOfWorkActive() )
+ if( uowf.isUnitOfWorkActive() )
{
//noinspection ConstantConditions
return next.invoke( proxy, method, args );
@@ -73,12 +73,12 @@ public class UnitOfWorkConcern
else
{
Usecase usecase = usecase();
- return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
+ return invokeWithCommit( proxy, method, args, uowf.newUnitOfWork( usecase ) );
}
}
else if( propagationPolicy == UnitOfWorkPropagation.Propagation.MANDATORY )
{
- if( !module.isUnitOfWorkActive() )
+ if( !uowf.isUnitOfWorkActive() )
{
throw new IllegalStateException( "UnitOfWork was required but there is no available unit of work." );
}
@@ -86,7 +86,7 @@ public class UnitOfWorkConcern
else if( propagationPolicy == UnitOfWorkPropagation.Propagation.REQUIRES_NEW )
{
Usecase usecase = usecase();
- return invokeWithCommit( proxy, method, args, module.newUnitOfWork( usecase ) );
+ return invokeWithCommit( proxy, method, args, uowf.newUnitOfWork( usecase ) );
}
//noinspection ConstantConditions
return next.invoke( proxy, method, args );
@@ -132,7 +132,7 @@ public class UnitOfWorkConcern
currentUnitOfWork.complete();
return result;
}
- catch( UndeclaredThrowableException e)
+ catch( UndeclaredThrowableException e )
{
Throwable undeclared = e.getUndeclaredThrowable();
if( undeclared instanceof ConcurrentEntityModificationException )
@@ -173,9 +173,9 @@ public class UnitOfWorkConcern
{
throw e;
}
- module.currentUnitOfWork().discard();
+ uowf.currentUnitOfWork().discard();
Thread.sleep( initialDelay + retry * delayFactor );
- return module.newUnitOfWork( usecase() );
+ return uowf.newUnitOfWork( usecase() );
}
/**
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java b/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
index 0f917d6..2214433 100644
--- a/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/OperatorsTest.java
@@ -19,6 +19,8 @@
package org.apache.zest.api;
import java.util.function.Predicate;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Assert;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -58,10 +60,12 @@ public class OperatorsTest
module.values( TestValue.class );
module.forMixin( TestEntity.class ).declareDefaults().foo().set( "Bar" );
module.forMixin( TestValue.class ).declareDefaults().bar().set( "Xyz" );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
- UnitOfWork uow = assembler.module().newUnitOfWork();
+ UnitOfWorkFactory uowf = assembler.module().unitOfWorkFactory();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
@@ -70,7 +74,7 @@ public class OperatorsTest
TestEntity testEntity = entityBuilder.newInstance();
uow.complete();
- uow = assembler.module().newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Iterable<TestEntity> entities = Iterables.iterable( testEntity = uow.get( testEntity ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java b/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
index 02fc6ae..a1c80de 100644
--- a/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/injection/scope/StateFieldTest.java
@@ -46,7 +46,7 @@ public class StateFieldTest
public void givenEntityWithFieldPropertiesWhenUpdatedThenReturnCorrect()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
PersonEntity charles = unitOfWork.newEntity( PersonEntity.class );
@@ -67,7 +67,7 @@ public class StateFieldTest
unitOfWork.complete();
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
charles = unitOfWork.get( charles );
daniel = unitOfWork.get( daniel );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java b/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
index 22488fa..b4969a1 100644
--- a/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/property/PropertyErrorTest.java
@@ -40,7 +40,7 @@ public class PropertyErrorTest
public void givenEntityWithNonOptionPropertyWhenInstantiatedThenException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
PersonEntity person = unitOfWork.newEntity( PersonEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
index 9f80c4f..745cfb2 100644
--- a/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/unitofwork/RemovalTest.java
@@ -43,7 +43,7 @@ public class RemovalTest
public void givenEntityIsCreatedAndUnitOfWorkIsNotCompletedWhenEntityIsRemoveThenSuccessfulRemoval()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, "123" );
@@ -62,7 +62,7 @@ public class RemovalTest
public void givenStandardPidRegulatorWhenNoChangeInInputExpectOutputToGoTowardsMinimum()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
PidRegulator regulator = null;
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
index 43acbc2..e85e2fc 100644
--- a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
+++ b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
@@ -28,25 +28,23 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
import org.apache.zest.bootstrap.Assembler;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.io.Inputs;
import org.apache.zest.io.Outputs;
import org.apache.zest.io.Transforms;
import org.apache.zest.test.AbstractZestTest;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+import org.junit.Before;
+import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@@ -82,6 +80,7 @@ public class DocumentationSupport
module.values( SomeValue.class ); // (2)
// END SNIPPET: default
new OrgJsonValueSerializationAssembler().assemble( module ); // (3)
+ new DefaultUnitOfWorkAssembler().assemble( module );
// START SNIPPET: default
}
// END SNIPPET: default
@@ -101,6 +100,7 @@ public class DocumentationSupport
// START SNIPPET: default
}
+
// END SNIPPET: default
// START SNIPPET: service
@Service
@@ -217,56 +217,39 @@ public class DocumentationSupport
public void assembledWithValuesModuleSerialization()
throws Exception
{
- Application app = new Energy4Java().newApplication( new ApplicationAssembler()
- {
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
- {
- Assembler[][][] pancakes = new Assembler[][][]
+ Application app = new Energy4Java().newApplication( applicationFactory -> {
+ Assembler[][][] pancakes = new Assembler[][][]
{
{
{
- new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly valuesModule )
- throws AssemblyException
- {
- valuesModule.layer().setName( "SINGLE-Layer" );
- valuesModule.setName( "VALUES-Module" );
+ valuesModule -> {
+ valuesModule.layer().setName( "SINGLE-Layer" );
+ valuesModule.setName( "VALUES-Module" );
- valuesModule.values( SomeValue.class );
- }
+ valuesModule.values( SomeValue.class );
+ new DefaultUnitOfWorkAssembler().assemble( valuesModule );
}
},
{
- new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly servicesModule )
- throws AssemblyException
- {
- servicesModule.setName( "SERVICES-Module" );
+ servicesModule -> {
+ servicesModule.setName( "SERVICES-Module" );
- Function<Application, Module> valuesModuleFinder = new Function<Application, Module>()
+ Function<Application, Module> valuesModuleFinder = new Function<Application, Module>()
+ {
+ @Override
+ public Module apply( Application app1 )
{
- @Override
- public Module apply( Application app )
- {
- return app.findModule( "SINGLE-Layer", "VALUES-Module" );
- }
- };
- new OrgJsonValueSerializationAssembler().
- withValuesModuleFinder( valuesModuleFinder ).
- assemble( servicesModule );
- }
+ return app1.findModule( "SINGLE-Layer", "VALUES-Module" );
+ }
+ };
+ new OrgJsonValueSerializationAssembler().
+ withValuesModuleFinder( valuesModuleFinder ).
+ assemble( servicesModule );
}
}
}
};
- return applicationFactory.newApplicationAssembly( pancakes );
- }
+ return applicationFactory.newApplicationAssembly( pancakes );
} );
app.activate();
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
index 89f75df..b5499c4 100644
--- a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
@@ -184,7 +184,7 @@ public class ValueCompositeTest
builder.prototype().number().set( 42L );
SomeValue some = builder.newInstance();
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
@@ -213,7 +213,7 @@ public class ValueCompositeTest
builder.prototype().number().set( 42L );
SomeValue some = builder.newInstance();
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
AssociationValue associationValue;
try
{
@@ -229,7 +229,7 @@ public class ValueCompositeTest
unitOfWork.complete();
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
AssociationValue newAssociationValue = module.newValueFromSerializedState( AssociationValue.class, json );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
index f99c506..bdd8828 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
@@ -23,6 +23,7 @@ import java.util.function.Predicate;
import org.apache.zest.api.activation.Activator;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.type.HasTypes;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
/**
* The ModuleAssembly is used to register any information about * what the module should contain, such as composites,
@@ -77,10 +78,42 @@ public interface ModuleAssembly
*
* @return the assembly
*/
- @SuppressWarnings({ "unchecked", "varargs" })
+ @SuppressWarnings( { "unchecked", "varargs" } )
ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators );
/**
+ * Adds the default UnitOfWorkFactory to this Module.
+ * <p>
+ * In versions <3.0, UnitOfWork was built into the Core Runtime, and couldn't be custom made. In 3.0, the
+ * UnitOfWorkFactory is a regular Service that the Module instance will look up on demand.
+ * </p>
+ * <p>
+ * Typically, this method should be called, and it should be called first in the Assembler, so that
+ * it is possible to add Concerns and SideEffects to the default implementation of either the
+ * {@link org.apache.zest.api.unitofwork.UnitOfWorkFactory} or the
+ * {@link org.apache.zest.api.unitofwork.UnitOfWork}.
+ * </p>
+ * <p>
+ * Internally, this method is the equivalent of;
+ * </p>
+ * <pre><code>
+ * new DefaultUnitOfWorkAssembler().assemble( module );
+ * </code>
+ * </pre>
+ * <p>
+ * and the {@link DefaultUnitOfWorkAssembler} does the equivalent of
+ * </p>
+ * <pre><code>
+ * module.services( UnitOfWorkFactory.class ).withMixins( UnitOfWorkFactoryMixin.class );
+ * module.transients( UnitOfWork.class ).withMixins( ModuleUnitOfWork.class );
+ * </code></pre>
+ * albeit those Mixins are in the Core Runtime and since Core Runtime is not a direct dependency of any
+ * other module, the classes are loaded with reflection. This may change in the future.
+ */
+ ModuleAssembly withDefaultUnitOfWorkFactory()
+ throws AssemblyException;
+
+ /**
* Declare a list of TransientComposites for this Module. Use the TransientDeclaration that is returned to
* declare further settings. Note that the TransientDeclaration works on all of the types specified.
*
@@ -160,7 +193,6 @@ public interface ModuleAssembly
*/
ConfigurationDeclaration configurations( Predicate<HasTypes> specification );
-
/**
* Declare a list of object classes for this Module. Use the ObjectDeclaration that is returned to
* declare further settings. Note that the ObjectDeclaration works on all of the types specified.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
new file mode 100644
index 0000000..14171cd
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
@@ -0,0 +1,55 @@
+/*
+ * 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.bootstrap.unitofwork;
+
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.Assembler;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+
+public class DefaultUnitOfWorkAssembler
+ implements Assembler
+{
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ Class factoryMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.UnitOfWorkFactoryMixin" );
+ module.services( UnitOfWorkFactory.class ).withMixins( factoryMixin );
+
+ Class uowMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.ModuleUnitOfWork" );
+ module.transients( UnitOfWork.class ).withMixins( uowMixin );
+ }
+
+ private Class<?> loadMixinClass( String name )
+ throws AssemblyException
+ {
+ try
+ {
+ return getClass().getClassLoader().loadClass( name );
+ }
+ catch( ClassNotFoundException e )
+ {
+ throw new AssemblyException( "Default UnitOfWorkFactory mixin is not present in the system." );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
index fc7147b..90b6d5a 100644
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
+++ b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.bootstrap;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Assert;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -48,6 +49,7 @@ public class ClassScannerTest
for( Class aClass : filter( matches( ".*Value" ), findClasses( TestValue.class ) ) )
{
module.values( aClass );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
index ac931fa..ce9a239 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
@@ -62,7 +62,7 @@ import org.apache.zest.runtime.property.PropertyInstance;
import org.apache.zest.runtime.service.ImportedServiceReferenceInstance;
import org.apache.zest.runtime.service.ServiceInstance;
import org.apache.zest.runtime.service.ServiceReferenceInstance;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.runtime.value.ValueInstance;
import org.apache.zest.spi.ZestSPI;
import org.apache.zest.spi.entity.EntityState;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
index 57c6790..cdc3198 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationModel.java
@@ -44,13 +44,10 @@ import org.apache.zest.functional.Visitor;
import org.apache.zest.runtime.composite.ValueConstraintsInstance;
import org.apache.zest.runtime.model.Binder;
import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.runtime.unitofwork.BuilderEntityState;
import org.apache.zest.spi.entity.EntityState;
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
/**
* Model for a ManyAssociation.
*
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
index 11d188d..0df3b35 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/association/ManyAssociationsModel.java
@@ -27,7 +27,7 @@ import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.common.QualifiedName;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.runtime.value.ValueStateInstance;
import org.apache.zest.spi.entity.EntityState;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
index 0b0f340..a930f48 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationModel.java
@@ -45,13 +45,10 @@ import org.apache.zest.functional.Visitor;
import org.apache.zest.runtime.composite.ValueConstraintsInstance;
import org.apache.zest.runtime.model.Binder;
import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.runtime.unitofwork.BuilderEntityState;
import org.apache.zest.spi.entity.EntityState;
-import static org.apache.zest.functional.Iterables.empty;
-import static org.apache.zest.functional.Iterables.first;
-
/**
* Model for a NamedAssociation.
*
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
index ad536d1..6c1783b 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
@@ -28,7 +28,7 @@ import org.apache.zest.api.association.NamedAssociation;
import org.apache.zest.api.common.QualifiedName;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.runtime.value.ValueStateInstance;
import org.apache.zest.spi.entity.EntityState;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
index 9190d67f..c7308f7 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
@@ -18,9 +18,31 @@
*/
package org.apache.zest.runtime.bootstrap;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Consumer;
import java.util.function.Function;
-import org.apache.zest.api.common.*;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.common.QualifiedName;
+import org.apache.zest.api.common.UseDefaults;
+import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.InvalidCompositeException;
import org.apache.zest.api.concern.Concerns;
import org.apache.zest.api.constraint.Constraint;
@@ -42,24 +64,40 @@ import org.apache.zest.api.util.Classes;
import org.apache.zest.api.util.Fields;
import org.apache.zest.bootstrap.StateDeclarations;
import org.apache.zest.functional.HierarchicalVisitorAdapter;
-import org.apache.zest.runtime.composite.*;
+import org.apache.zest.runtime.composite.AbstractConstraintModel;
+import org.apache.zest.runtime.composite.CompositeConstraintModel;
+import org.apache.zest.runtime.composite.CompositeMethodModel;
+import org.apache.zest.runtime.composite.CompositeMethodsModel;
+import org.apache.zest.runtime.composite.ConcernModel;
+import org.apache.zest.runtime.composite.ConcernsModel;
+import org.apache.zest.runtime.composite.ConstraintModel;
+import org.apache.zest.runtime.composite.ConstraintsModel;
+import org.apache.zest.runtime.composite.Genericpredicate;
+import org.apache.zest.runtime.composite.MixinModel;
+import org.apache.zest.runtime.composite.MixinsModel;
+import org.apache.zest.runtime.composite.SideEffectModel;
+import org.apache.zest.runtime.composite.SideEffectsModel;
+import org.apache.zest.runtime.composite.StateModel;
+import org.apache.zest.runtime.composite.ValueConstraintsInstance;
+import org.apache.zest.runtime.composite.ValueConstraintsModel;
import org.apache.zest.runtime.injection.Dependencies;
import org.apache.zest.runtime.injection.DependencyModel;
import org.apache.zest.runtime.property.PropertiesModel;
import org.apache.zest.runtime.property.PropertyModel;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
import static java.util.stream.Stream.concat;
-import static org.apache.zest.api.util.Annotations.*;
-import static org.apache.zest.api.util.Classes.*;
-import static org.apache.zest.functional.Iterables.*;
+import static org.apache.zest.api.util.Annotations.hasAnnotation;
+import static org.apache.zest.api.util.Annotations.isType;
+import static org.apache.zest.api.util.Annotations.type;
+import static org.apache.zest.api.util.Classes.classHierarchy;
+import static org.apache.zest.api.util.Classes.interfacesOf;
+import static org.apache.zest.api.util.Classes.isAssignableFrom;
+import static org.apache.zest.api.util.Classes.typeOf;
+import static org.apache.zest.api.util.Classes.typesOf;
+import static org.apache.zest.api.util.Classes.wrapperClass;
+import static org.apache.zest.functional.Iterables.filter;
+import static org.apache.zest.functional.Iterables.first;
+import static org.apache.zest.functional.Iterables.iterable;
import static org.apache.zest.runtime.legacy.Specifications.translate;
/**
@@ -211,8 +249,9 @@ public abstract class CompositeAssemblyImpl
interfacesOf( mixinModel.mixinClass() )
.map( Classes.RAW_CLASS )
- .filter( clazz -> Stream.of( Initializable.class, Lifecycle.class, InvocationHandler.class ).noneMatch( c -> c
- .equals( clazz ) ) )
+ .filter( clazz -> Stream.of( Initializable.class, Lifecycle.class, InvocationHandler.class )
+ .noneMatch( c -> c
+ .equals( clazz ) ) )
.forEach( thisDependencies::add );
// // Implement @This references
@@ -220,7 +259,6 @@ public abstract class CompositeAssemblyImpl
// filter( new DependencyModel.ScopeSpecification( This.class ),
// methodComposite.dependencies() ) );
-
// Iterable<Class<?>> map1 = map( new DependencyModel.InjectionTypeFunction(),
// filter( new DependencyModel.ScopeSpecification( This.class ),
// mixinModel.dependencies() ) );
@@ -257,10 +295,10 @@ public abstract class CompositeAssemblyImpl
mixinDeclarations( thisDependency ) );
List<? extends Class<?>> singleton = Collections.singletonList( thisDependency );
implementMixinType( singleton,
- toList(typeConstraintClasses),
- toList(typeConcernClasses),
- toList(typeSideEffectClasses),
- toList(typeMixinClasses)
+ toList( typeConstraintClasses ),
+ toList( typeConcernClasses ),
+ toList( typeSideEffectClasses ),
+ toList( typeMixinClasses )
);
} );
}
@@ -393,15 +431,15 @@ public abstract class CompositeAssemblyImpl
List<Class<?>> constraintClasses
)
{
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
- boolean optional = annotations.stream().anyMatch(isType(Optional.class));
+ List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
+ boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
ValueConstraintsModel valueConstraintsModel = constraintsFor(
- annotations.stream(),
- GenericPropertyInfo.propertyTypeOf(accessor),
- ((Member) accessor).getName(),
- optional,
- constraintClasses,
- accessor);
+ annotations.stream(),
+ GenericPropertyInfo.propertyTypeOf( accessor ),
+ ( (Member) accessor ).getName(),
+ optional,
+ constraintClasses,
+ accessor );
ValueConstraintsInstance valueConstraintsInstance = null;
if( valueConstraintsModel.isConstrained() )
{
@@ -552,7 +590,7 @@ public abstract class CompositeAssemblyImpl
concernClasses.forEach( concern -> {
if( helper.appliesTo( concern, method, types, mixinClass ) )
{
- concernsFor.add( helper.getConcernModel( concern ) );
+ addConcernIfNotExists( concernsFor, helper.getConcernModel( concern ) );
}
else
{
@@ -564,7 +602,7 @@ public abstract class CompositeAssemblyImpl
Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
{
- concernsFor.add( helper.getConcernModel( concern ) );
+ addConcernIfNotExists( concernsFor, helper.getConcernModel( concern ) );
}
}
catch( NoSuchMethodException e )
@@ -586,7 +624,8 @@ public abstract class CompositeAssemblyImpl
{
if( helper.appliesTo( concern, method, types, mixinClass ) )
{
- concernsFor.add( helper.getConcernModel( concern ) );
+ ConcernModel concernModel = helper.getConcernModel( concern );
+ addConcernIfNotExists( concernsFor, concernModel );
}
}
}
@@ -602,6 +641,14 @@ public abstract class CompositeAssemblyImpl
}
}
+ private void addConcernIfNotExists( List<ConcernModel> concernsFor, ConcernModel concernModel )
+ {
+ if( !concernsFor.contains( concernModel ) )
+ {
+ concernsFor.add( concernModel );
+ }
+ }
+
private SideEffectsModel sideEffectsFor( Method method,
Class<?> mixinClass,
Stream<Class<?>> sideEffectClasses
@@ -609,9 +656,10 @@ public abstract class CompositeAssemblyImpl
{
List<SideEffectModel> sideEffectsFor = new ArrayList<>();
sideEffectClasses.forEach( sideEffect -> {
+ SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
{
- sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
+ addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
}
else
{
@@ -623,7 +671,7 @@ public abstract class CompositeAssemblyImpl
Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass ) )
{
- sideEffectsFor.add( helper.getSideEffectModel( sideEffect ) );
+ addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
}
}
catch( NoSuchMethodException e )
@@ -634,6 +682,25 @@ public abstract class CompositeAssemblyImpl
}
} );
+ // Check annotations on method that have @Concerns annotations themselves
+ for( Annotation annotation : method.getAnnotations() )
+ {
+ @SuppressWarnings( "raw" )
+ SideEffects sideEffects = annotation.annotationType().getAnnotation( SideEffects.class );
+ if( sideEffects != null )
+ {
+ for( Class<?> sideEffect : sideEffects.value() )
+ {
+ if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
+ {
+ SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
+ addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+ }
+ }
+ }
+ }
+
+
if( sideEffectsFor.isEmpty() )
{
return SideEffectsModel.EMPTY_SIDEEFFECTS;
@@ -644,6 +711,14 @@ public abstract class CompositeAssemblyImpl
}
}
+ private void addSideEffectIfNotExists( List<SideEffectModel> sideEffectsFor, SideEffectModel sideEffectModel )
+ {
+ if( !sideEffectsFor.contains( sideEffectModel ) )
+ {
+ sideEffectsFor.add( sideEffectModel );
+ }
+ }
+
@SuppressWarnings( "unchecked" )
private Stream<Class<?>> constraintDeclarations( Class<?> type )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
index b1d60d6..c06a811 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -57,6 +57,7 @@ import org.apache.zest.bootstrap.TransientAssembly;
import org.apache.zest.bootstrap.TransientDeclaration;
import org.apache.zest.bootstrap.ValueAssembly;
import org.apache.zest.bootstrap.ValueDeclaration;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.functional.Iterables;
import org.apache.zest.runtime.activation.ActivatorsModel;
import org.apache.zest.runtime.composite.TransientModel;
@@ -145,6 +146,14 @@ public final class ModuleAssemblyImpl
}
@Override
+ public ModuleAssembly withDefaultUnitOfWorkFactory()
+ throws AssemblyException
+ {
+ new DefaultUnitOfWorkAssembler().assemble( this );
+ return this;
+ }
+
+ @Override
@SuppressWarnings( { "raw", "unchecked" } )
public ValueDeclaration values( Class<?>... valueTypes )
{
@@ -603,7 +612,8 @@ public final class ModuleAssemblyImpl
private String generateId( Stream<Class<?>> serviceTypes )
{
// Find service identity that is not yet used
- Class<?> serviceType = serviceTypes.findFirst().orElse( null ); // Use the first, which *SHOULD* be the main serviceType
+ Class<?> serviceType = serviceTypes.findFirst()
+ .orElse( null ); // Use the first, which *SHOULD* be the main serviceType
int idx = 0;
String id = serviceType.getSimpleName();
boolean invalid;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
index e7f477e..7bd02ef 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
@@ -145,8 +145,8 @@ public abstract class CompositeModel
@Override
public Stream<DependencyModel> dependencies()
{
- return Stream.of( mixinsModel, compositeMethodsModel ).flatMap( Dependencies::dependencies );
-// return Iterables.flatten( mixinsModel.dependencies(), compositeMethodsModel.dependencies() );
+ Stream<Dependencies> models = Stream.of( this.mixinsModel, compositeMethodsModel );
+ return models.flatMap( Dependencies::dependencies );
}
@Override
@@ -219,7 +219,6 @@ public abstract class CompositeModel
Class<?> mainType = first( types );
if( mainType.isInterface() )
{
-
try
{
return Composite.class.cast( proxyConstructor.newInstance( invocationHandler ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
index 78be044..2b0570c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
@@ -19,7 +19,7 @@ import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.composite.TransientBuilder;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
/**
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
index 384f4fc..53f0a6b 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientClassLoader.java
@@ -19,6 +19,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
+import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.entity.Lifecycle;
import org.apache.zest.api.mixin.Initializable;
import org.apache.zest.api.util.Methods;
@@ -160,7 +161,7 @@ import static org.objectweb.asm.Type.getInternalName;
AnnotationVisitor av0;
// Class definition start
- cw.visit( JDK_VERSION, ACC_PUBLIC + ACC_SUPER, classSlash, null, baseClassSlash, null );
+ cw.visit( JDK_VERSION, ACC_PUBLIC + ACC_SUPER, classSlash, null, baseClassSlash, new String[] { "org/apache/zest/api/composite/Composite" } );
// Composite reference
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
index 3f55ba5..15c8524 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
@@ -35,7 +35,6 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkException;
import org.apache.zest.runtime.composite.CompositeMethodInstance;
import org.apache.zest.runtime.composite.MixinsInstance;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entity.EntityStatus;
import org.apache.zest.spi.module.ModuleSpi;
@@ -54,7 +53,7 @@ public final class EntityInstance
}
private final EntityComposite proxy;
- private final ModuleUnitOfWork uow;
+ private final UnitOfWork uow;
private final ModuleSpi moduleInstance;
private final EntityModel entityModel;
private final EntityReference identity;
@@ -63,7 +62,7 @@ public final class EntityInstance
private Object[] mixins;
private EntityStateInstance state;
- public EntityInstance( ModuleUnitOfWork uow,
+ public EntityInstance( UnitOfWork uow,
ModuleSpi moduleInstance,
EntityModel entityModel,
EntityState entityState
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
index 42b33b6..bac3936 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
@@ -31,7 +31,7 @@ import org.apache.zest.api.unitofwork.EntityCompositeAlreadyExistsException;
import org.apache.zest.api.util.Annotations;
import org.apache.zest.runtime.composite.CompositeMethodsModel;
import org.apache.zest.runtime.composite.CompositeModel;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entitystore.EntityAlreadyExistsException;
import org.apache.zest.spi.entitystore.EntityStoreException;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
index 0028c5a..c0a5cba 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityStateInstance.java
@@ -62,14 +62,7 @@ public final class EntityStateInstance
this.stateModel = stateModel;
this.entityState = entityState;
- entityFunction = new BiFunction<EntityReference, Type, Object>()
- {
- @Override
- public Object apply( EntityReference entityReference, Type type )
- {
- return uow.get( Classes.RAW_CLASS.apply( type ), entityReference.identity() );
- }
- };
+ entityFunction = ( entityReference, type ) -> uow.get( Classes.RAW_CLASS.apply( type ), entityReference.identity() );
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
index 18126eb..ba9ac8d 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectedFieldsModel.java
@@ -57,23 +57,24 @@ public final class InjectedFieldsModel
Type genericType = field.getGenericType();
if( genericType instanceof ParameterizedType )
{
- genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
- .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );
+ Type[] actualTypeArguments = ( (ParameterizedType) genericType ).getActualTypeArguments();
+ Type rawType = ( (ParameterizedType) genericType ).getRawType();
+ Type ownerType = ( (ParameterizedType) genericType ).getOwnerType();
+ genericType = new ParameterizedTypeInstance( actualTypeArguments, rawType, ownerType );
- for( int i = 0; i < ( (ParameterizedType) genericType ).getActualTypeArguments().length; i++ )
+ for( int i = 0; i < actualTypeArguments.length; i++ )
{
- Type type = ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ];
+ Type type = actualTypeArguments[ i ];
if( type instanceof TypeVariable )
{
type = Classes.resolveTypeVariable( (TypeVariable) type, field.getDeclaringClass(), fragmentClass );
- ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ] = type;
+ actualTypeArguments[ i ] = type;
}
}
}
boolean optional = DependencyModel.isOptional( injectionAnnotation, field.getAnnotations() );
- DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional, field
- .getAnnotations() );
+ DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional, field.getAnnotations() );
InjectedFieldModel injectedFieldModel = new InjectedFieldModel( field, dependencyModel );
this.fields.add( injectedFieldModel );
}
@@ -82,14 +83,6 @@ public final class InjectedFieldsModel
public Stream<DependencyModel> dependencies()
{
return fields.stream().flatMap( Dependencies::dependencies );
-// return Iterables.map( new Function<InjectedFieldModel, DependencyModel>()
-// {
-// @Override
-// public DependencyModel apply( InjectedFieldModel injectedFieldModel )
-// {
-// return injectedFieldModel.dependency();
-// }
-// }, fields );
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
index ad05b64..1fbb3a3 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
@@ -81,7 +81,7 @@ public final class StructureInjectionProviderFactory
}
else if( clazz.equals( UnitOfWorkFactory.class ) )
{
- return context.module();
+ return context.module().unitOfWorkFactory();
}
else if( clazz.equals( QueryBuilderFactory.class ) )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
index 2fbfb32..4635d42 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
@@ -68,4 +68,16 @@ public class ServicesModel
{
return serviceModels.stream();
}
+
+ public boolean contains( Class<?> type )
+ {
+ for( ServiceModel model : serviceModels )
+ {
+ if( model.hasType( type ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
index 338f8cf..dec81c1 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
@@ -21,7 +21,6 @@ import org.apache.zest.api.activation.ActivationEventListener;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.PassivationException;
import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.object.ObjectDescriptor;
@@ -30,7 +29,7 @@ import org.apache.zest.api.structure.Layer;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
/**
* Instance of a Zest application layer. Contains a list of modules which are managed by this layer.
[04/34] zest-java git commit: Multi Layer abstract test framework for
indexing in multi-layered applications, as it should work.
Posted by ni...@apache.org.
Multi Layer abstract test framework for indexing in multi-layered applications, as it should work.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/6138c305
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/6138c305
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/6138c305
Branch: refs/heads/develop
Commit: 6138c3057cb6a8546ca4d026fd30f26efa7bcfc0
Parents: 5d2a62b
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Tue Dec 15 12:17:55 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Tue Dec 15 12:17:55 2015 +0800
----------------------------------------------------------------------
.../layered/LayeredLayerAssembler.java | 2 +-
.../AbstractMultiLayeredIndexingTest.java | 86 ++++++++++++++------
.../zest/test/indexing/layered/AccessLayer.java | 39 ---------
.../test/indexing/layered/AccountModule.java | 52 ------------
.../indexing/layered/ApplicationAssembler.java | 52 ------------
.../zest/test/indexing/layered/ConfigLayer.java | 37 ---------
.../test/indexing/layered/ConfigModule.java | 41 ----------
.../zest/test/indexing/layered/DomainLayer.java | 38 ---------
.../test/indexing/layered/FamilyModule.java | 54 ------------
.../test/indexing/layered/IndexingLayer.java | 37 ---------
.../test/indexing/layered/PersistenceLayer.java | 37 ---------
.../indexing/layered/PersistenceModule.java | 44 ----------
.../zest/test/indexing/layered/Suite1Case1.java | 76 +++++++++++++++++
.../zest/test/indexing/layered/Suite1Case2.java | 76 +++++++++++++++++
.../zest/test/indexing/layered/TestCase.java | 2 +-
.../zest/test/indexing/layered/TestCase1.java | 76 -----------------
.../zest/test/indexing/layered/TestCase2.java | 76 -----------------
.../test/indexing/layered/TestSuite1Module.java | 40 ---------
.../test/indexing/layered/TestSuite2Module.java | 38 ---------
.../test/indexing/layered/TestSuite3Module.java | 38 ---------
.../indexing/layered/assembly/AccessLayer.java | 65 +++++++++++++++
.../layered/assembly/AccountModule.java | 52 ++++++++++++
.../layered/assembly/ApplicationAssembler.java | 71 ++++++++++++++++
.../indexing/layered/assembly/ConfigLayer.java | 37 +++++++++
.../indexing/layered/assembly/ConfigModule.java | 41 ++++++++++
.../indexing/layered/assembly/DomainLayer.java | 38 +++++++++
.../indexing/layered/assembly/FamilyModule.java | 54 ++++++++++++
.../layered/assembly/IndexingLayer.java | 38 +++++++++
.../layered/assembly/PersistenceLayer.java | 37 +++++++++
.../layered/assembly/PersistenceModule.java | 44 ++++++++++
.../layered/assembly/TestExecutionModule.java | 46 +++++++++++
.../layered/assembly/TestSuite1Module.java | 53 ++++++++++++
.../layered/assembly/TestSuite2Module.java | 38 +++++++++
.../layered/assembly/TestSuite3Module.java | 38 +++++++++
34 files changed, 867 insertions(+), 726 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
index 898591e..ccec8d2 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
@@ -60,7 +60,7 @@ public abstract class LayeredLayerAssembler
return moduleName;
}
- private ModuleAssembler instantiateAssembler( LayerAssembly layer,
+ protected ModuleAssembler instantiateAssembler( LayerAssembly layer,
Class<? extends ModuleAssembler> modulerAssemblerClass
)
throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
index 7a55fe0..a4f6790 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
@@ -21,23 +21,51 @@
package org.apache.zest.test.indexing.layered;
import org.apache.zest.api.activation.ActivationException;
+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.service.ServiceReference;
+import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.layered.ModuleAssembler;
import org.apache.zest.test.indexing.TestData;
+import org.apache.zest.test.indexing.layered.assembly.ApplicationAssembler;
import org.junit.Before;
import org.junit.Test;
public abstract class AbstractMultiLayeredIndexingTest
{
- static Class<? extends ModuleAssembler> indexingAssembler;
+ public static Class<? extends ModuleAssembler> indexingAssembler;
protected Application application;
- private Iterable<ServiceReference<TestCase>> suite1;
- private Iterable<ServiceReference<TestCase>> suite2;
- private Iterable<ServiceReference<TestCase>> suite3;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Optional
+ @Service
+ @Tagged( "Suite1Case1" )
+ private ServiceReference<TestCase> suite1Case1;
+
+ @Optional
+ @Service
+ @Tagged( "Suite1Case2" )
+ private ServiceReference<TestCase> suite1Case2;
+
+ @Optional
+ @Service
+ @Tagged( "Suite2Case1" )
+ private ServiceReference<TestCase> suite2Case1;
+
+ @Optional
+ @Service
+ @Tagged( "Suite3Case1" )
+ private ServiceReference<TestCase> suite3Case1;
public AbstractMultiLayeredIndexingTest( Class<? extends ModuleAssembler> indexingAssembler )
{
@@ -49,53 +77,61 @@ public abstract class AbstractMultiLayeredIndexingTest
throws AssemblyException, ActivationException
{
ApplicationAssembler assembler =
- new ApplicationAssembler( "Multi Layered Indexing Test", "1.0", Application.Mode.development );
+ new ApplicationAssembler( "Multi Layered Indexing Test", "1.0", Application.Mode.development, getClass() );
assembler.initialize();
assembler.start();
application = assembler.application();
Module familyModule = application.findModule( "Domain Layer", "Family Module" );
TestData.populate( familyModule );
- Module suite1Module = application.findModule( "Access Layer", "TestSuite1 Module" );
- suite1 = suite1Module.findServices( TestCase.class );
-
- Module suite2Module = application.findModule( "Access Layer", "TestSuite2 Module" );
- suite2 = suite2Module.findServices( TestCase.class );
+ Module executionModule = application.findModule( "Access Layer", "TestExecution Module" );
+ executionModule.injectTo( this );
+ }
- Module suite3Module = application.findModule( "Access Layer", "TestSuite3 Module" );
- suite3 = suite3Module.findServices( TestCase.class );
+ @Test
+ public void suite1Case1()
+ throws Exception
+ {
+ runTest( suite1Case1, "suite1Case1" );
}
@Test
- public void suite1Tests()
+ public void suite1Case2()
throws Exception
{
- Iterable<ServiceReference<TestCase>> suite = this.suite1;
- runTest( suite );
+ runTest( suite1Case2, "suite1Case2" );
}
@Test
- public void suite2Tests()
+ public void suite2Case1()
throws Exception
{
- runTest( suite2 );
+ runTest( suite2Case1, "suite2Case1" );
}
@Test
- public void suite3Tests()
+ public void suite3Case1()
throws Exception
{
- runTest( suite3 );
+ runTest( suite3Case1, "suite3Case1" );
}
- private void runTest( Iterable<ServiceReference<TestCase>> suite )
+ private void runTest( ServiceReference<TestCase> testCaseRef, String testName )
throws Exception
{
- for( ServiceReference<TestCase> ref : suite )
+ if( testCaseRef == null )
+ {
+ System.err.println( "TestCase is not defined." );
+ }
+ else
{
- TestCase testCase = ref.get();
- testCase.when();
- testCase.given();
- testCase.expect();
+ TestCase testCase = testCaseRef.get();
+ try(UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( testName ) ))
+ {
+ testCase.given();
+ testCase.when();
+ testCase.expect();
+ uow.complete();
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
deleted file mode 100644
index 6b1b4e7..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
+++ /dev/null
@@ -1,39 +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.zest.test.indexing.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-class AccessLayer extends LayeredLayerAssembler
-{
-
- @Override
- public LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException
- {
- createModule( layer, TestSuite1Module.class );
- createModule( layer, TestSuite2Module.class );
- createModule( layer, TestSuite3Module.class );
- return layer;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java
deleted file mode 100644
index 0df4aee..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.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.zest.test.indexing.layered;
-
-import org.apache.zest.api.common.Visibility;
-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.spi.uuid.UuidIdentityGeneratorService;
-import org.apache.zest.test.indexing.model.Account;
-import org.apache.zest.test.indexing.model.Domain;
-import org.apache.zest.test.indexing.model.File;
-import org.apache.zest.test.indexing.model.Host;
-import org.apache.zest.test.indexing.model.Port;
-import org.apache.zest.test.indexing.model.Protocol;
-import org.apache.zest.test.indexing.model.QueryParam;
-import org.apache.zest.test.indexing.model.URL;
-
-class AccountModule
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer );
- module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class )
- .visibleIn( Visibility.layer );
- module.services( UuidIdentityGeneratorService.class );
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java
deleted file mode 100644
index 1b11738..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.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.zest.test.indexing.layered;
-
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
-
-class ApplicationAssembler extends LayeredApplicationAssembler
-{
-
- public ApplicationAssembler( String name, String version, Application.Mode mode )
- throws AssemblyException
- {
- super( name, version, mode );
- }
-
- @Override
- protected void assembleLayers( ApplicationAssembly assembly )
- throws AssemblyException
- {
- LayerAssembly accessLayer = createLayer( AccessLayer.class );
- LayerAssembly domainLayer = createLayer( DomainLayer.class );
- LayerAssembly persistenceLayer = createLayer( PersistenceLayer.class );
- LayerAssembly indexingLayer = createLayer( IndexingLayer.class );
- LayerAssembly configLayer = createLayer( ConfigLayer.class );
- accessLayer.uses( domainLayer );
- domainLayer.uses( persistenceLayer, indexingLayer );
- persistenceLayer.uses( configLayer );
- indexingLayer.uses( configLayer );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
deleted file mode 100644
index 0b4fada..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
+++ /dev/null
@@ -1,37 +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.zest.test.indexing.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-class ConfigLayer extends LayeredLayerAssembler
-{
-
- @Override
- public LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException
- {
- createModule( layer, ConfigModule.class );
- return layer;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java
deleted file mode 100644
index 00265f6..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java
+++ /dev/null
@@ -1,41 +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.zest.test.indexing.layered;
-
-import org.apache.zest.api.common.Visibility;
-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.entitystore.memory.MemoryEntityStoreService;
-
-class ConfigModule
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
deleted file mode 100644
index 5704d48..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
+++ /dev/null
@@ -1,38 +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.zest.test.indexing.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-class DomainLayer extends LayeredLayerAssembler
-{
-
- @Override
- public LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException
- {
- createModule( layer, FamilyModule.class );
- createModule( layer, AccountModule.class );
- return layer;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
deleted file mode 100644
index 56a4939..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
+++ /dev/null
@@ -1,54 +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.zest.test.indexing.layered;
-
-import org.apache.zest.api.common.Visibility;
-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.spi.uuid.UuidIdentityGeneratorService;
-import org.apache.zest.test.indexing.model.Address;
-import org.apache.zest.test.indexing.model.Cat;
-import org.apache.zest.test.indexing.model.City;
-import org.apache.zest.test.indexing.model.Dog;
-import org.apache.zest.test.indexing.model.Female;
-import org.apache.zest.test.indexing.model.Male;
-
-class FamilyModule
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( Male.class,
- Female.class,
- City.class,
- Cat.class,
- Dog.class ).visibleIn( Visibility.application );
-
- module.values( Address.class ).visibleIn( Visibility.application );
- module.services( UuidIdentityGeneratorService.class );
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
deleted file mode 100644
index 489092d..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
+++ /dev/null
@@ -1,37 +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.zest.test.indexing.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-class IndexingLayer extends LayeredLayerAssembler
-{
-
- @Override
- public LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException
- {
- createModule( layer, AbstractMultiLayeredIndexingTest.indexingAssembler );
- return layer;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
deleted file mode 100644
index cc22513..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
+++ /dev/null
@@ -1,37 +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.zest.test.indexing.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
-
-class PersistenceLayer extends LayeredLayerAssembler
-{
-
- @Override
- public LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException
- {
- createModule( layer, PersistenceModule.class );
- return layer;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
deleted file mode 100644
index 0b92f56..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
+++ /dev/null
@@ -1,44 +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.zest.test.indexing.layered;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.value.ValueSerialization;
-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.entitystore.memory.MemoryEntityStoreService;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-
-class PersistenceModule
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
- module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case1.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case1.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case1.java
new file mode 100644
index 0000000..366533d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case1.java
@@ -0,0 +1,76 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.query.QueryExpressions;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+import org.apache.zest.test.indexing.model.Male;
+import org.apache.zest.test.indexing.model.Person;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class Suite1Case1
+ implements TestCase
+{
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private QueryBuilderFactory qbf;
+
+ private QueryBuilder<Male> builder;
+
+ private Query<Male> query;
+
+ @Override
+ public void given()
+ throws Exception
+ {
+ QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
+ Male prototype = QueryExpressions.templateFor( Male.class );
+ builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
+ }
+
+ @Override
+ public void when()
+ throws Exception
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ query = uow.newQuery( builder );
+ }
+
+ @Override
+ public void expect()
+ throws Exception
+ {
+ assertThat( query.count(), equalTo(1) );
+ Male male = query.find();
+ assertThat( male.title().get(), equalTo( Person.Title.MR ));
+ assertThat( male.name().get(), equalTo( "Joe Doe" ));
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case2.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case2.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case2.java
new file mode 100644
index 0000000..cdc4dc2
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/Suite1Case2.java
@@ -0,0 +1,76 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.query.QueryExpressions;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+import org.apache.zest.test.indexing.model.Male;
+import org.apache.zest.test.indexing.model.Person;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class Suite1Case2
+ implements TestCase
+{
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private QueryBuilderFactory qbf;
+
+ private QueryBuilder<Male> builder;
+
+ private Query<Male> query;
+
+ @Override
+ public void given()
+ throws Exception
+ {
+ QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
+ Male prototype = QueryExpressions.templateFor( Male.class );
+ builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
+ }
+
+ @Override
+ @UnitOfWorkPropagation
+ public void when()
+ throws Exception
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ query = uow.newQuery( builder );
+ }
+
+ @Override
+ public void expect()
+ throws Exception
+ {
+ assertThat( query.count(), equalTo(1) );
+ Male male = query.find();
+ assertThat( male.title().get(), equalTo( Person.Title.MR ));
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
index 5dd2e71..b5e0bc4 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
@@ -20,7 +20,7 @@
package org.apache.zest.test.indexing.layered;
-interface TestCase
+public interface TestCase
{
void given()
throws Exception;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
deleted file mode 100644
index e2dd860..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
+++ /dev/null
@@ -1,76 +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.zest.test.indexing.layered;
-
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.test.indexing.model.Male;
-import org.apache.zest.test.indexing.model.Person;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class TestCase1
- implements TestCase
-{
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Structure
- private QueryBuilderFactory qbf;
-
- private QueryBuilder<Male> builder;
-
- private Query<Male> query;
-
- @Override
- public void given()
- throws Exception
- {
- QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
- Male prototype = QueryExpressions.templateFor( Male.class );
- builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
- }
-
- @Override
- @UnitOfWorkPropagation
- public void when()
- throws Exception
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- query = uow.newQuery( builder );
- }
-
- @Override
- public void expect()
- throws Exception
- {
- assertThat( query.count(), equalTo(1) );
- Male male = query.find();
- assertThat( male.title().get(), equalTo( Person.Title.MR ));
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
deleted file mode 100644
index dcd448a..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
+++ /dev/null
@@ -1,76 +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.zest.test.indexing.layered;
-
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.test.indexing.model.Male;
-import org.apache.zest.test.indexing.model.Person;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class TestCase2
- implements TestCase
-{
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Structure
- private QueryBuilderFactory qbf;
-
- private QueryBuilder<Male> builder;
-
- private Query<Male> query;
-
- @Override
- public void given()
- throws Exception
- {
- QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
- Male prototype = QueryExpressions.templateFor( Male.class );
- builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
- }
-
- @Override
- @UnitOfWorkPropagation
- public void when()
- throws Exception
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- query = uow.newQuery( builder );
- }
-
- @Override
- public void expect()
- throws Exception
- {
- assertThat( query.count(), equalTo(1) );
- Male male = query.find();
- assertThat( male.title().get(), equalTo( Person.Title.MR ));
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
deleted file mode 100644
index 01011db..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
+++ /dev/null
@@ -1,40 +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.zest.test.indexing.layered;
-
-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;
-
-class TestSuite1Module
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- module.services( TestCase.class ).withMixins( TestCase1.class );
- module.services( TestCase.class ).withMixins( TestCase2.class );
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
deleted file mode 100644
index 3d8a9e6..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
+++ /dev/null
@@ -1,38 +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.zest.test.indexing.layered;
-
-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;
-
-class TestSuite2Module
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
deleted file mode 100644
index 2c41329..0000000
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
+++ /dev/null
@@ -1,38 +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.zest.test.indexing.layered;
-
-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;
-
-class TestSuite3Module
- implements ModuleAssembler
-{
-
- @Override
- public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException
- {
- return module;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccessLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccessLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccessLayer.java
new file mode 100644
index 0000000..0d349ff
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccessLayer.java
@@ -0,0 +1,65 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import java.lang.reflect.InvocationTargetException;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+
+class AccessLayer extends LayeredLayerAssembler
+{
+
+ private final Class<?> testClass;
+
+ AccessLayer( Class<?> testClass )
+ {
+ this.testClass = testClass;
+ }
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, TestExecutionModule.class );
+ createModule( layer, TestSuite1Module.class );
+ createModule( layer, TestSuite2Module.class );
+ createModule( layer, TestSuite3Module.class );
+ return layer;
+ }
+
+ @Override
+ protected ModuleAssembler instantiateAssembler( LayerAssembly layer,
+ Class<? extends ModuleAssembler> moduleAssemblerClass
+ )
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
+ {
+ if( moduleAssemblerClass.equals(TestExecutionModule.class))
+ {
+ return new TestExecutionModule( testClass );
+ }
+ else
+ {
+ return super.instantiateAssembler( layer, moduleAssemblerClass );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
new file mode 100644
index 0000000..d398e6f
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
@@ -0,0 +1,52 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+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.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.test.indexing.model.Account;
+import org.apache.zest.test.indexing.model.Domain;
+import org.apache.zest.test.indexing.model.File;
+import org.apache.zest.test.indexing.model.Host;
+import org.apache.zest.test.indexing.model.Port;
+import org.apache.zest.test.indexing.model.Protocol;
+import org.apache.zest.test.indexing.model.QueryParam;
+import org.apache.zest.test.indexing.model.URL;
+
+class AccountModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer );
+ module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class )
+ .visibleIn( Visibility.layer );
+ module.services( UuidIdentityGeneratorService.class );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ApplicationAssembler.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ApplicationAssembler.java
new file mode 100644
index 0000000..399cc9b
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ApplicationAssembler.java
@@ -0,0 +1,71 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import java.lang.reflect.InvocationTargetException;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.bootstrap.ApplicationAssembly;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.IllegalLayerAssemblerException;
+import org.apache.zest.bootstrap.layered.LayerAssembler;
+import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
+
+public class ApplicationAssembler extends LayeredApplicationAssembler
+{
+
+ private final Class<?> testClass;
+
+ public ApplicationAssembler( String name, String version, Application.Mode mode, Class<?> testClass )
+ throws AssemblyException
+ {
+ super( name, version, mode );
+ this.testClass = testClass;
+ }
+
+ @Override
+ protected void assembleLayers( ApplicationAssembly assembly )
+ throws AssemblyException
+ {
+ LayerAssembly accessLayer = createLayer( AccessLayer.class );
+ LayerAssembly domainLayer = createLayer( DomainLayer.class );
+ LayerAssembly persistenceLayer = createLayer( PersistenceLayer.class );
+ LayerAssembly indexingLayer = createLayer( IndexingLayer.class );
+ LayerAssembly configLayer = createLayer( ConfigLayer.class );
+ accessLayer.uses( domainLayer );
+ domainLayer.uses( persistenceLayer, indexingLayer );
+ persistenceLayer.uses( configLayer );
+ indexingLayer.uses( configLayer );
+ }
+
+ @Override
+ protected <T extends LayerAssembler> LayerAssembler instantiateLayerAssembler( Class<T> layerAssemblerClass,
+ LayerAssembly layer
+ )
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, IllegalLayerAssemblerException
+ {
+ if( layerAssemblerClass.equals( AccessLayer.class ))
+ {
+ return new AccessLayer( testClass );
+ }
+ return super.instantiateLayerAssembler( layerAssemblerClass, layer );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigLayer.java
new file mode 100644
index 0000000..04c732c
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigLayer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class ConfigLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, ConfigModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
new file mode 100644
index 0000000..ecd4939
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+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.entitystore.memory.MemoryEntityStoreService;
+
+class ConfigModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/DomainLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/DomainLayer.java
new file mode 100644
index 0000000..e5ca391
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/DomainLayer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class DomainLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, FamilyModule.class );
+ createModule( layer, AccountModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
new file mode 100644
index 0000000..9e24b3f
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
@@ -0,0 +1,54 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+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.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.test.indexing.model.Address;
+import org.apache.zest.test.indexing.model.Cat;
+import org.apache.zest.test.indexing.model.City;
+import org.apache.zest.test.indexing.model.Dog;
+import org.apache.zest.test.indexing.model.Female;
+import org.apache.zest.test.indexing.model.Male;
+
+class FamilyModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( Male.class,
+ Female.class,
+ City.class,
+ Cat.class,
+ Dog.class ).visibleIn( Visibility.application );
+
+ module.values( Address.class ).visibleIn( Visibility.application );
+ module.services( UuidIdentityGeneratorService.class );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/IndexingLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/IndexingLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/IndexingLayer.java
new file mode 100644
index 0000000..63933ea
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/IndexingLayer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+import org.apache.zest.test.indexing.layered.AbstractMultiLayeredIndexingTest;
+
+class IndexingLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, AbstractMultiLayeredIndexingTest.indexingAssembler );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceLayer.java
new file mode 100644
index 0000000..fe0cd25
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceLayer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class PersistenceLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, PersistenceModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
new file mode 100644
index 0000000..b6ae1e7
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.value.ValueSerialization;
+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.entitystore.memory.MemoryEntityStoreService;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+
+class PersistenceModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
+ module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
new file mode 100644
index 0000000..bf3fe2b
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
@@ -0,0 +1,46 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+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;
+
+public class TestExecutionModule
+ implements ModuleAssembler
+{
+ private final Class<?> testClass;
+
+ public TestExecutionModule( Class<?> testClass)
+ {
+ this.testClass = testClass;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.objects( testClass ).visibleIn( Visibility.layer );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
new file mode 100644
index 0000000..efcb64b
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
@@ -0,0 +1,53 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+import org.apache.zest.api.common.Visibility;
+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.test.indexing.layered.Suite1Case1;
+import org.apache.zest.test.indexing.layered.Suite1Case2;
+import org.apache.zest.test.indexing.layered.TestCase;
+
+class TestSuite1Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ declareTestCase( module, Suite1Case1.class );
+ declareTestCase( module, Suite1Case2.class );
+ return module;
+ }
+
+ private void declareTestCase( ModuleAssembly module, Class<?> testcaseMixin )
+ {
+ module.services( TestCase.class )
+ .withMixins( testcaseMixin )
+ .visibleIn( Visibility.layer )
+ .taggedWith( testcaseMixin.getSimpleName() );
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
new file mode 100644
index 0000000..ac3f655
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+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;
+
+class TestSuite2Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/6138c305/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
new file mode 100644
index 0000000..f93ddf7
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered.assembly;
+
+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;
+
+class TestSuite3Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
[25/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
ZEST-136 - Massive changes to the Runtime, refactoring the Model and Instance relationship.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/dedb068e
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/dedb068e
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/dedb068e
Branch: refs/heads/develop
Commit: dedb068e4b56fce8d6c21f5938396eb84da63f7c
Parents: 81561b0
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Dec 17 20:40:00 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Dec 17 20:40:08 2015 +0800
----------------------------------------------------------------------
.../main/java/org/apache/zest/api/ZestAPI.java | 4 +-
.../zest/api/composite/CompositeContext.java | 8 +-
.../zest/api/composite/CompositeInstance.java | 4 +-
.../zest/api/composite/ModelDescriptor.java | 7 +
.../zest/api/composite/PropertyMapper.java | 2 +-
.../zest/api/configuration/Configuration.java | 4 +-
.../zest/api/property/PropertyDescriptor.java | 3 +-
.../org/apache/zest/api/structure/Layer.java | 4 +
.../zest/api/structure/LayerDescriptor.java | 20 +
.../org/apache/zest/api/structure/Module.java | 42 +-
.../zest/api/structure/ModuleDescriptor.java | 92 +++-
.../apache/zest/api/structure/TypeLookup.java | 175 ++++++
.../api/structure/UsedLayersDescriptor.java | 4 +-
.../java/org/apache/zest/api/type/HasTypes.java | 4 +-
.../unitofwork/EntityTypeNotFoundException.java | 19 +-
.../apache/zest/api/unitofwork/UnitOfWork.java | 15 +-
.../zest/api/value/ValueBuilderTemplate.java | 5 +-
.../zest/api/value/ValueDeserializer.java | 104 ++--
.../api/configuration/ConfigurationTest.java | 2 +-
.../DeclareConfigurationDefaultsTest.java | 2 +-
.../dataset/iterable/IterableDataSetTest.java | 2 +-
.../decoratorMixin/DecoratorMixinTest.java | 4 +-
.../zest/api/object/ObjectBuilderTest.java | 2 +-
.../api/unitofwork/UnitOfWorkTemplateTest.java | 4 +-
.../zest/api/value/DocumentationSupport.java | 26 +-
.../zest/api/value/ValueCompositeTest.java | 44 +-
.../apache/zest/runtime/ZestRuntimeImpl.java | 4 +-
.../runtime/activation/ActivatorsModel.java | 5 +-
.../bootstrap/ApplicationModelFactoryImpl.java | 2 +-
.../runtime/bootstrap/EntityAssemblyImpl.java | 4 +-
.../runtime/bootstrap/ModuleAssemblyImpl.java | 39 +-
.../runtime/bootstrap/ObjectAssemblyImpl.java | 5 +-
.../runtime/bootstrap/ServiceAssemblyImpl.java | 5 +-
.../bootstrap/TransientAssemblyImpl.java | 12 +-
.../runtime/bootstrap/ValueAssemblyImpl.java | 39 +-
.../composite/AbstractModifierModel.java | 7 +-
.../runtime/composite/CompositeMethodModel.java | 15 +-
.../composite/CompositeMethodsModel.java | 6 +-
.../zest/runtime/composite/CompositeModel.java | 18 +-
.../zest/runtime/composite/ConcernsModel.java | 5 +-
.../runtime/composite/SideEffectsModel.java | 7 +-
.../composite/TransientBuilderInstance.java | 15 +-
.../runtime/composite/TransientInstance.java | 23 +-
.../zest/runtime/composite/TransientModel.java | 11 +-
.../zest/runtime/entity/EntityInstance.java | 13 +-
.../apache/zest/runtime/entity/EntityModel.java | 10 +-
.../runtime/injection/InjectionContext.java | 25 +-
.../ServiceInjectionProviderFactory.java | 8 +-
.../StructureInjectionProviderFactory.java | 37 +-
.../provider/UsesInjectionProviderFactory.java | 2 +-
.../apache/zest/runtime/object/ObjectModel.java | 12 +-
.../zest/runtime/object/ObjectsModel.java | 2 +-
.../zest/runtime/property/PropertyModel.java | 5 +-
.../runtime/service/ImportedServiceModel.java | 14 +-
.../ImportedServiceReferenceInstance.java | 30 +-
.../service/ImportedServicesInstance.java | 4 +-
.../runtime/service/ImportedServicesModel.java | 7 +-
.../zest/runtime/service/ServiceInstance.java | 4 +-
.../zest/runtime/service/ServiceModel.java | 14 +-
.../service/ServiceReferenceInstance.java | 11 +-
.../zest/runtime/service/ServicesInstance.java | 13 +-
.../zest/runtime/service/ServicesModel.java | 7 +-
.../runtime/structure/ApplicationInstance.java | 2 +-
.../runtime/structure/ApplicationModel.java | 43 +-
.../zest/runtime/structure/LayerInstance.java | 65 +--
.../zest/runtime/structure/LayerModel.java | 55 +-
.../runtime/structure/ModuleClassLoader.java | 182 +++++++
.../zest/runtime/structure/ModuleInstance.java | 533 ++++---------------
.../zest/runtime/structure/ModuleModel.java | 274 +++++++++-
.../zest/runtime/structure/TypeLookupImpl.java | 341 ++++++------
.../runtime/structure/UsedLayersInstance.java | 17 +-
.../zest/runtime/structure/UsedLayersModel.java | 8 +-
.../zest/runtime/types/ValueTypeFactory.java | 4 +-
.../unitofwork/EntityBuilderInstance.java | 15 +-
.../runtime/unitofwork/ModuleUnitOfWork.java | 75 ++-
.../unitofwork/UnitOfWorkFactoryMixin.java | 4 +-
.../runtime/unitofwork/UnitOfWorkInstance.java | 24 +-
.../runtime/value/ValueBuilderInstance.java | 11 +-
.../value/ValueBuilderWithPrototype.java | 6 +-
.../runtime/value/ValueBuilderWithState.java | 10 +-
.../zest/runtime/value/ValueInstance.java | 3 +-
.../apache/zest/runtime/value/ValueModel.java | 13 +-
.../zest/runtime/value/ValueStateInstance.java | 5 +-
.../apache/zest/api/common/OptionalTest.java | 12 +-
.../zest/api/common/PropertyTypeTest.java | 2 +-
.../zest/api/common/ValueCompositeTest.java | 38 +-
.../zest/bootstrap/ServiceAssemblyTest.java | 2 +-
.../constraints/PropertyConstraintTest.java | 2 +-
.../zest/regression/qi230/Qi230IssueTest.java | 4 +-
.../apache/zest/regression/qi377/IssueTest.java | 2 +-
...alueCollisionWithRelatedReturnTypesTest.java | 26 +-
.../apache/zest/regression/qi53/IssueTest.java | 2 +-
.../apache/zest/regression/qi55/IssueTest.java | 4 +-
.../apache/zest/regression/qi65/IssueTest.java | 2 +-
.../apache/zest/regression/qi74/IssueTest.java | 2 +-
.../apache/zest/regression/qi78/IssueTest.java | 11 +-
.../org/apache/zest/runtime/ZestAPITest.java | 6 +-
.../runtime/appliesto/AppliesToFilterTest.java | 2 +-
.../AppliesToOrConditionQI241Test.java | 6 +-
.../zest/runtime/appliesto/AppliesToTest.java | 6 +-
.../appliesto/FragmentAppliesToTest.java | 2 +-
.../association/AssociationEqualityTest.java | 4 +-
.../DereferenceForBootstrappedConcernsTest.java | 4 +-
.../runtime/composite/AbstractMixinTest.java | 2 +-
.../composite/CompositeFactoryImplTest.java | 4 +-
.../runtime/composite/FunctionalListTest.java | 2 +-
.../zest/runtime/composite/MapOverrideTest.java | 14 +-
.../zest/runtime/composite/QI247Test1.java | 14 +-
.../zest/runtime/composite/QI247Test2.java | 14 +-
.../zest/runtime/composite/QI256Test.java | 66 +--
.../runtime/composite/TransientAsClassTest.java | 2 +-
.../runtime/concerns/GenericConcernTest.java | 2 +-
.../runtime/concerns/ModuleConcernTest.java | 2 +-
.../runtime/constraints/ConstraintsTest.java | 8 +-
.../zest/runtime/defaults/UseDefaultsTest.java | 2 +-
.../injection/ActivatorInjectionTest.java | 4 +-
.../runtime/injection/ServiceInjectionTest.java | 8 +-
.../runtime/injection/StateInjectionTest.java | 2 +-
.../injection/StateParameterInjectionTest.java | 2 +-
.../injection/StructureInjectionTest.java | 14 +-
.../runtime/injection/ThisInjectionTest.java | 2 +-
.../runtime/injection/UsesGenericClassTest.java | 2 +-
.../runtime/injection/UsesGenericListTest.java | 2 +-
.../zest/runtime/injection/UsesGraphTest.java | 4 +-
.../runtime/injection/UsesInjectionTest.java | 8 +-
.../ServiceInstantiationTests.java | 2 +-
.../TransientInstantiationTests.java | 2 +-
.../instantiation/ValueInstantiationTests.java | 10 +-
.../zest/runtime/mixin/AssemblyMixinTest.java | 2 +-
.../zest/runtime/mixin/AssemblyRoleTest.java | 4 +-
.../zest/runtime/mixin/InitializableTest.java | 4 +-
.../apache/zest/runtime/mixin/JDKMixinTest.java | 4 +-
.../mixin/MethodInterceptionMixinTest.java | 2 +-
.../zest/runtime/mixin/MixinPrecedenceTest.java | 6 +-
.../mixin/MixinsOnThisInjectionTest.java | 2 +-
.../zest/runtime/mixin/PrivateMixinTest.java | 2 +-
.../apache/zest/runtime/mixin/Qi228Test.java | 2 +-
.../runtime/property/ImmutablePropertyTest.java | 4 +-
.../runtime/property/PropertyEqualityTest.java | 73 +--
.../property/PropertyStringArrayTest.java | 2 +-
.../zest/runtime/property/PropertyTest.java | 2 +-
.../property/ValueNestedBuilderTest.java | 12 +-
.../zest/runtime/query/NonQueryableTest.java | 4 +-
.../query/QueryBuilderFactoryImplTest.java | 18 +-
.../runtime/service/ComplexActivatableTest.java | 2 +-
.../zest/runtime/service/ConfigurationTest.java | 6 -
.../zest/runtime/service/ServiceFinderTest.java | 4 +-
.../sideeffects/GenericSideEffectTest.java | 2 +-
.../sideeffects/ModuleSideEffectTest.java | 2 +-
.../sideeffects/SpecificSideEffectTest.java | 2 +-
.../structure/CompositeDescriptorTest.java | 2 +-
.../zest/runtime/structure/ModuleTest.java | 2 +-
.../runtime/threaded/ContextCompositeTest.java | 4 +-
.../runtime/value/NestedValueBuilderTest.java | 12 +-
.../runtime/value/ValueCompositeBasicsTest.java | 6 +-
.../zest/runtime/value/ValueEqualityTest.java | 44 +-
.../ValueInjectionDeserializationTest.java | 2 +-
.../value/ValueSerializationRegressionTest.java | 2 +-
.../runtime/value/ValueWithAssociationTest.java | 6 +-
.../service/importer/InstanceImporterTest.java | 2 +-
.../service/importer/NewObjectImporterTest.java | 2 -
.../importer/ServiceInstanceImporterTest.java | 2 -
.../test/composite/CleanStackTraceTest.java | 2 +-
.../ConcurrentModificationCheckConcern.java | 14 +-
.../DefaultEntityStoreUnitOfWork.java | 16 +-
.../spi/entitystore/EntityStateVersions.java | 4 +-
.../zest/spi/entitystore/EntityStore.java | 6 +-
.../zest/spi/entitystore/EntityStoreSPI.java | 7 +-
.../spi/entitystore/EntityStoreUnitOfWork.java | 8 +-
.../entitystore/helpers/JSONEntityState.java | 28 +-
.../helpers/JSONMapEntityStoreMixin.java | 38 +-
.../helpers/MapEntityStoreMixin.java | 36 +-
.../org/apache/zest/spi/module/ModuleSpi.java | 16 +-
.../apache/zest/spi/structure/ModelModule.java | 107 ----
.../apache/zest/spi/structure/TypeLookup.java | 125 -----
.../spi/value/ValueDeserializerAdapter.java | 323 ++++++-----
.../orgjson/OrgJsonValueDeserializer.java | 196 +++----
.../orgjson/OrgJsonValueSerialization.java | 160 ------
.../helpers/JSONManyAssociationStateTest.java | 2 +
.../org/apache/zest/test/AbstractZestTest.java | 36 +-
.../zest/test/cache/AbstractCachePoolTest.java | 2 +-
...bstractConfigurationDeserializationTest.java | 3 +-
.../test/entity/AbstractEntityStoreTest.java | 20 +-
.../test/indexing/AbstractAnyQueryTest.java | 4 +-
.../test/indexing/AbstractComplexQueryTest.java | 74 +--
.../test/indexing/AbstractEntityFinderTest.java | 10 +-
.../test/indexing/AbstractNamedQueryTest.java | 52 +-
.../zest/test/indexing/AbstractQueryTest.java | 133 ++---
.../AbstractCollectionSerializationTest.java | 84 ++-
.../test/value/AbstractJsonDateFormatTest.java | 12 +-
.../AbstractPlainValueSerializationTest.java | 48 +-
...AbstractValueCompositeSerializationTest.java | 30 +-
.../entitystore/jdbm/JdbmEntityStoreTest.java | 2 +-
.../jdbm/JdbmEntityStoreWithCacheTest.java | 2 +-
.../mongodb/MongoMapEntityStoreTest.java | 2 +-
.../MongoMapEntityStoreWithCacheTest.java | 2 +-
.../prefs/PreferencesEntityStoreMixin.java | 172 +++---
.../redis/RedisMapEntityStoreTest.java | 2 +-
.../redis/RedisMapEntityStoreWithCacheTest.java | 2 +-
.../riak/RiakHttpMapEntityStoreTest.java | 2 +-
.../riak/RiakMapEntityStoreWithCacheTest.java | 2 +-
.../riak/RiakProtobufMapEntityStoreTest.java | 2 +-
.../entitystore/sql/SQLEntityStoreMixin.java | 45 +-
.../sql/DerbySQLEntityStoreTest.java | 2 +-
.../entitystore/sql/MySQLEntityStoreTest.java | 2 +-
.../sql/PostgreSQLEntityStoreTest.java | 2 +-
.../elasticsearch/ElasticSearchIndexer.java | 13 +-
.../index/elasticsearch/ElasticSearchTest.java | 16 +-
.../index/elasticsearch/ImmenseTermTest.java | 2 +-
.../apache/zest/index/rdf/ContainsAllTest.java | 12 +-
.../org/apache/zest/index/rdf/ContainsTest.java | 12 +-
.../zest/index/rdf/RDFPerformanceTest.java | 8 +-
.../zest/index/rdf/qi173/Qi173IssueTest.java | 2 +-
.../withPropagationMandatory/IssueTest.java | 2 +-
.../qi64/withPropagationRequired/IssueTest.java | 2 +-
.../withPropagationRequiresNew/IssueTest.java | 2 +-
.../zest/index/solr/SolrQueryServiceTest.java | 4 +-
.../skeletons/SQLCompatEntityStateWrapper.java | 7 +
.../postgresql/PostgreSQLComplexQueryTest.java | 2 +-
.../postgresql/PostgreSQLDBIntegrityTest.java | 4 +-
.../postgresql/PostgreSQLEntityFinderTest.java | 2 +-
.../sql/postgresql/PostgreSQLQueryTest.java | 2 +-
.../index/sql/postgresql/SQLTestHelper.java | 5 +-
.../reindexer/internal/ReindexerMixin.java | 4 +-
.../zest/index/reindexer/ReindexerTest.java | 4 +-
.../jackson/JacksonValueDeserializer.java | 65 +--
.../stax/StaxValueDeserializer.java | 112 ++--
.../StaxConfigurationDeserializationTest.java | 4 +-
.../library/alarm/AlarmHistoryImplTest.java | 4 +-
.../zest/library/alarm/AlarmPointImplTest.java | 4 +-
.../zest/library/alarm/AlarmServiceTest.java | 8 +-
.../library/alarm/ExtendedAlarmModelTest.java | 38 +-
.../library/alarm/SimpleAlarmModelTest.java | 16 +-
.../library/alarm/StandardAlarmModelTest.java | 20 +-
.../BreaksCircuitOnThrowableTest.java | 4 +-
.../library/constraints/ConstraintTest.java | 54 +-
.../library/constraints/qi70/IssueTest.java | 2 +-
.../conversion/values/EntityToValue.java | 2 +-
.../conversion/values/ValueToEntityMixin.java | 11 +-
.../conversion/values/EntityToValueTest.java | 10 +-
.../values/NestedValuesConversionTest.java | 4 +-
.../conversion/values/ValueToEntityTest.java | 32 +-
.../source/jdbm/JdbmEventStoreService.java | 4 +-
.../source/jdbm/JdbmEventStoreServiceTest.java | 2 +-
.../AbstractApplicationEventStoreMixin.java | 3 +-
.../domain/replay/DomainEventPlayerService.java | 2 +-
.../domain/source/AbstractEventStoreMixin.java | 3 +-
.../application/ApplicationEventTest.java | 2 +-
.../eventsourcing/domain/DomainEventTest.java | 2 +-
.../zest/library/http/JettyServiceTest.java | 2 +-
.../library/jmx/ApplicationManagerService.java | 10 +-
.../jmx/ConfigurationManagerService.java | 3 +-
.../library/javascript/JavaScriptMixinTest.java | 2 +-
.../zest/library/locking/LockingTest.java | 2 +-
.../zest/library/logging/DebuggingTest.java | 4 +-
.../zest/library/logging/TracingTest.java | 16 +-
.../zest/library/metrics/MetricsTest.java | 6 +-
.../zest/library/osgi/OSGiServiceTest.java | 2 +-
.../zest/library/rdf/ApplicationXmlTest.java | 2 +-
.../rdf/entity/EntitySerializerTest.java | 11 +-
.../rdf/entity/EntityTypeSerializerTest.java | 9 +-
.../rdf/repository/MemoryRepositoryTest.java | 5 -
.../rdf/repository/NativeRepositoryTest.java | 7 +-
.../rest/client/RequestWriterDelegator.java | 2 +-
.../rest/client/ResponseReaderDelegator.java | 2 +-
.../responsereader/JSONResponseReader.java | 10 +-
.../ContextResourceClientFactoryTest.java | 6 +-
.../rest/client/ContinuousIntegrationTest.java | 6 +-
.../zest/library/rest/client/RssReaderTest.java | 2 +-
.../library/rest/common/table/TableQuery.java | 2 +-
.../rest/server/api/ContextResource.java | 5 +-
.../server/restlet/RequestReaderDelegator.java | 2 +-
.../server/restlet/ResponseWriterDelegator.java | 2 +-
.../requestreader/DefaultRequestReader.java | 6 +-
.../ValueDescriptorResponseWriter.java | 8 +-
.../zest/library/rest/admin/EntityResource.java | 12 +-
.../zest/library/rest/admin/RestTest.java | 8 +-
.../serialization/JsonRepresentation.java | 6 +-
.../zest/library/scheduler/SchedulerTest.java | 6 +-
.../zest/library/shiro/PasswordDomainTest.java | 2 +-
.../library/shiro/PermissionsDomainTest.java | 4 +-
.../internal/service/ServiceLocator.java | 2 -
.../DataSourceConfigurationManagerService.java | 4 +-
.../sql/datasource/ExternalDataSourceTest.java | 2 +-
.../uid/sequence/PersistingSequencingTest.java | 6 +-
.../uid/sequence/TransientSequencingTest.java | 6 +-
.../zest/library/uid/uuid/UuidServiceTest.java | 4 +-
.../zest/library/uowfile/HasUoWFileTest.java | 2 +-
.../zest/library/uowfile/HasUoWFilesTest.java | 2 +-
.../conversion/EntityToDTOService.java | 4 +-
.../conversion/EntityToDTOService.java | 25 +-
.../zest/sample/rental/web/QuikitServlet.java | 5 +-
.../composite/InvocationPerformanceTest.java | 6 +-
.../PropertyMixinInvocationPerformanceTest.java | 4 +-
.../niclas2/ConcernsOnPropertyTest.java | 3 +-
.../ApplicationDetailDescriptorBuilder.java | 16 +-
.../ImportedServiceCompositeDescriptor.java | 8 +-
.../tutorials/cargo/step2/Step2TestCase.java | 6 +-
.../apache/zest/tutorials/hello/HelloTest.java | 2 +-
.../apache/zest/tutorials/hello/HelloTest2.java | 2 +-
.../apache/zest/tutorials/hello/HelloTest3.java | 2 +-
.../tutorials/services/step2/LibraryTest.java | 2 +-
.../tutorials/services/step3/LibraryTest.java | 2 +-
.../tutorials/services/step4/LibraryTest.java | 2 +-
.../tutorials/services/step5/LibraryTest.java | 2 +-
.../tutorials/services/step6/LibraryTest.java | 2 +-
306 files changed, 2977 insertions(+), 2978 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/ZestAPI.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/ZestAPI.java b/core/api/src/main/java/org/apache/zest/api/ZestAPI.java
index 22eda4c..fca07c3 100644
--- a/core/api/src/main/java/org/apache/zest/api/ZestAPI.java
+++ b/core/api/src/main/java/org/apache/zest/api/ZestAPI.java
@@ -29,7 +29,7 @@ import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.value.ValueDescriptor;
/**
@@ -57,7 +57,7 @@ public interface ZestAPI
*
* @return The Module instance where the Composite or UnitOfWork belongs to.
*/
- Module moduleOf( Object compositeOrUow );
+ ModuleDescriptor moduleOf( Object compositeOrUow );
/**
* Returns the ModelDescriptor of the Composite.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
index e0fffd2..cfb15d6 100644
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
+++ b/core/api/src/main/java/org/apache/zest/api/composite/CompositeContext.java
@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.stream.Stream;
import org.apache.zest.api.ZestAPI;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
/**
* Thread-associated composites. This is basically a ThreadLocal which maintains a reference
@@ -30,10 +30,10 @@ import org.apache.zest.api.structure.Module;
public class CompositeContext<T extends TransientComposite>
extends ThreadLocal<T>
{
- private Module module;
+ private ModuleDescriptor module;
private Class<T> type;
- public CompositeContext( Module module, Class<T> type )
+ public CompositeContext( ModuleDescriptor module, Class<T> type )
{
this.module = module;
this.type = type;
@@ -42,7 +42,7 @@ public class CompositeContext<T extends TransientComposite>
@Override
protected T initialValue()
{
- return module.newTransient( type );
+ return module.instance().newTransient( type );
}
@SuppressWarnings( "unchecked" )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java b/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
index 63aa10d..986bedd 100644
--- a/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
+++ b/core/api/src/main/java/org/apache/zest/api/composite/CompositeInstance.java
@@ -17,7 +17,7 @@ package org.apache.zest.api.composite;
import java.lang.reflect.InvocationHandler;
import org.apache.zest.api.property.StateHolder;
import org.apache.zest.api.structure.MetaInfoHolder;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.HasTypes;
/**
@@ -31,7 +31,7 @@ public interface CompositeInstance
<T> T newProxy( Class<T> mixinType )
throws IllegalArgumentException;
- Module module();
+ ModuleDescriptor module();
CompositeDescriptor descriptor();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java b/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
index a1bef87..e1d79c8 100644
--- a/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
+++ b/core/api/src/main/java/org/apache/zest/api/composite/ModelDescriptor.java
@@ -20,6 +20,7 @@ package org.apache.zest.api.composite;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.structure.MetaInfoHolder;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.HasTypes;
/**
@@ -29,5 +30,11 @@ public interface ModelDescriptor extends HasTypes, MetaInfoHolder
{
Visibility visibility();
+ /** The Module that the Model is declared in.
+ *
+ * @return The Module that this Model was declared in.
+ */
+ ModuleDescriptor module();
+
boolean isAssignableTo( Class<?> type );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java b/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
index 5303094..6fc111a 100644
--- a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
+++ b/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
@@ -462,7 +462,7 @@ public final class PropertyMapper
@SuppressWarnings( "unchecked" )
public Object map( Composite composite, Type type, String value )
{
- return ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( composite ).module().newValueFromSerializedState( (Class<Object>) type, value );
+ return ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( composite ).module().instance().newValueFromSerializedState( (Class<Object>) type, value );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java b/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
index 9f6acc0..cdcf0f3 100644
--- a/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
+++ b/core/api/src/main/java/org/apache/zest/api/configuration/Configuration.java
@@ -252,7 +252,7 @@ public interface Configuration<T>
)
throws InstantiationException
{
- Module module = api.moduleOf( serviceComposite );
+ Module module = api.moduleOf( serviceComposite ).instance();
Usecase usecase = UsecaseBuilder.newUsecase( "Configuration:" + me.identity().get() );
UnitOfWork buildUow = module.unitOfWorkFactory().newUnitOfWork( usecase );
@@ -384,7 +384,7 @@ public interface Configuration<T>
InputStream asStream = getResource( compositeType, resourceName );
if( asStream != null )
{
- V configObject = serializerRef.get().deserialize( configType, asStream );
+ V configObject = serializerRef.get().deserialize( uow.module(), configType, asStream );
return uow.toEntity( configType, configObject );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java b/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
index 649b1fc..e0ad5d6 100644
--- a/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
+++ b/core/api/src/main/java/org/apache/zest/api/property/PropertyDescriptor.java
@@ -19,6 +19,7 @@ import java.lang.reflect.Type;
import org.apache.zest.api.common.QualifiedName;
import org.apache.zest.api.structure.MetaInfoHolder;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
/**
@@ -48,7 +49,7 @@ public interface PropertyDescriptor extends MetaInfoHolder
AccessibleObject accessor();
- Object initialValue( Module module );
+ Object initialValue( ModuleDescriptor module );
ValueType valueType();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Layer.java b/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
index cf4db21..3df1b82 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/Layer.java
@@ -30,5 +30,9 @@ public interface Layer
*/
String name();
+ Application application();
+
Stream<? extends Module> modules();
+
+ LayerDescriptor descriptor();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
index 812b13f..53b552d 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/LayerDescriptor.java
@@ -13,6 +13,14 @@
*/
package org.apache.zest.api.structure;
+import java.util.stream.Stream;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.value.ValueDescriptor;
+
/**
* Layer Descriptor.
*/
@@ -24,8 +32,20 @@ public interface LayerDescriptor
*/
String name();
+ Layer instance();
+
/**
* @return Layers used by this Layer
*/
UsedLayersDescriptor usedLayers();
+
+ Stream<? extends ObjectDescriptor> visibleObjects( Visibility visibility );
+
+ Stream<? extends TransientDescriptor> visibleTransients( Visibility visibility );
+
+ Stream<? extends EntityDescriptor> visibleEntities( Visibility visibility );
+
+ Stream<? extends ValueDescriptor> visibleValues( Visibility visibility );
+
+ Stream<? extends ModelDescriptor> visibleServices( Visibility visibility );
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/Module.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/Module.java b/core/api/src/main/java/org/apache/zest/api/structure/Module.java
index 38d8803..d60f1db 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/Module.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/Module.java
@@ -50,50 +50,14 @@ public interface Module
*/
String name();
- /**
- * @return the Module's ClassLoader
- */
- ClassLoader classLoader();
-
- /**
- * @param typeName name of a transient composite type
- *
- * @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
- */
- TransientDescriptor transientDescriptor( String typeName );
-
- /**
- * @param typeName name of an entity composite type
- *
- * @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
- */
- EntityDescriptor entityDescriptor( String typeName );
+ ModuleDescriptor descriptor();
/**
- * @param typeName name of an object type
*
- * @return the descriptor for an object or null if the class could not be found or the object is not visible
+ * @return the Layer that the Module is declared in.
*/
- ObjectDescriptor objectDescriptor( String typeName );
-
- /**
- * @param typeName name of a value composite type
- *
- * @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
- */
- ValueDescriptor valueDescriptor( String typeName );
-
- Stream<? extends TransientDescriptor> transientComposites();
-
- Stream<? extends ValueDescriptor> valueComposites();
-
- Stream<? extends ServiceDescriptor> serviceComposites();
-
- Stream<? extends EntityDescriptor> entityComposites();
-
- Stream<? extends ImportedServiceDescriptor> importedServices();
+ LayerDescriptor layer();
- Stream<? extends ObjectDescriptor> objects();
UnitOfWorkFactory unitOfWorkFactory();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
index 045a639..06b2169 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/ModuleDescriptor.java
@@ -1,23 +1,97 @@
/*
- * Copyright (c) 2008, Rickard Öberg. All Rights Reserved.
+ * 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
*
- * Licensed 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.
+ * 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.api.structure;
+import java.util.stream.Stream;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.service.ImportedServiceDescriptor;
+import org.apache.zest.api.service.ServiceDescriptor;
+import org.apache.zest.api.value.ValueDescriptor;
+
/**
* Module Descriptor.
*/
public interface ModuleDescriptor
{
String name();
+
+ LayerDescriptor layer();
+
+ /**
+ * @return the Module's ClassLoader
+ */
+ ClassLoader classLoader();
+
+ /**
+ * @param typeName name of a transient composite type
+ *
+ * @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
+ */
+ TransientDescriptor transientDescriptor( String typeName );
+
+ /**
+ * @param typeName name of an entity composite type
+ *
+ * @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
+ */
+ EntityDescriptor entityDescriptor( String typeName );
+
+ /**
+ * @param typeName name of an object type
+ *
+ * @return the descriptor for an object or null if the class could not be found or the object is not visible
+ */
+ ObjectDescriptor objectDescriptor( String typeName );
+
+ /**
+ * @param typeName name of a value composite type
+ *
+ * @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
+ */
+ ValueDescriptor valueDescriptor( String typeName );
+
+ Stream<? extends TransientDescriptor> findVisibleTransientTypes();
+
+ Stream<? extends ValueDescriptor> findVisibleValueTypes();
+
+ Stream<? extends EntityDescriptor> findVisibleEntityTypes();
+
+ Stream<? extends ObjectDescriptor> findVisibleObjectTypes();
+
+ Stream<? extends TransientDescriptor> transientComposites();
+
+ Stream<? extends ValueDescriptor> valueComposites();
+
+ Stream<? extends EntityDescriptor> entityComposites();
+
+ Stream<? extends ObjectDescriptor> objects();
+
+ Stream<? extends ImportedServiceDescriptor> importedServices();
+
+ Stream<? extends ServiceDescriptor> serviceComposites();
+
+ Module instance();
+
+ TypeLookup typeLookup();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java b/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java
new file mode 100644
index 0000000..e1c1905
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java
@@ -0,0 +1,175 @@
+/*
+ * 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.api.structure;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.stream.Stream;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.value.ValueDescriptor;
+
+public interface TypeLookup
+{
+ /**
+ * Lookup first Object Model matching the given Type.
+ *
+ * <p>First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Object Model
+ */
+ ObjectDescriptor lookupObjectModel( Class<?> type );
+
+ /**
+ * Lookup first Transient Model matching the given Type.
+ *
+ * <p>First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Transient Model
+ */
+ TransientDescriptor lookupTransientModel( Class<?> type );
+
+ /**
+ * Lookup first Value Model matching the given Type.
+ *
+ * <p>First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Value Model
+ */
+ ValueDescriptor lookupValueModel( Class<?> type );
+
+ /**
+ * Lookup first Entity Model matching the given Type.
+ *
+ * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
+ * {@link #lookupEntityModels(Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Entity Model
+ */
+ EntityDescriptor lookupEntityModel( Class<?> type );
+
+ /**
+ * Lookup all Entity Models matching the given Type.
+ *
+ * <p>Returned Iterable contains, in order, Entity Models that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
+ * {@link #lookupEntityModel(Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return All matching Entity Models
+ */
+ Iterable<? extends EntityDescriptor> lookupEntityModels( Class<?> type );
+
+ /**
+ * Lookup first ServiceDescriptor/ImportedServiceDescriptor matching the given Type.
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p>See {@link #lookupServiceModels(Type)}.</p>
+ *
+ * @param serviceType Looked up Type
+ *
+ * @return First matching Service
+ */
+ ModelDescriptor lookupServiceModel( Type serviceType );
+
+ /**
+ * Lookup all ServiceDescriptors matching the given Type.
+ *
+ * <p>Returned List contains, in order, ServiceReferences that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
+ * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return All matching ServiceReferences
+ */
+ List<? extends ModelDescriptor> lookupServiceModels( Type type );
+
+ Stream<? extends ObjectDescriptor> allObjects();
+
+ Stream<? extends TransientDescriptor> allTransients();
+
+ Stream<? extends ValueDescriptor> allValues();
+
+ Stream<? extends EntityDescriptor> allEntities();
+
+ Stream<? extends ModelDescriptor> allServices();
+
+ Stream<Class<?>> allVisibleObjects();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java b/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
index 98e70d5..08c5aed 100644
--- a/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
+++ b/core/api/src/main/java/org/apache/zest/api/structure/UsedLayersDescriptor.java
@@ -14,10 +14,12 @@
package org.apache.zest.api.structure;
+import java.util.stream.Stream;
+
/**
* Used Layers Descriptor.
*/
public interface UsedLayersDescriptor
{
- Iterable<? extends LayerDescriptor> layers();
+ Stream<? extends LayerDescriptor> layers();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java b/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
index 0c3a0ac..73bc25e 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/HasTypes.java
@@ -20,6 +20,7 @@ package org.apache.zest.api.type;
import java.lang.reflect.Type;
import java.util.stream.Stream;
+import org.apache.zest.api.util.Classes;
/**
* Has types.
@@ -30,6 +31,7 @@ public interface HasTypes
default boolean hasType( Type type )
{
- return types().anyMatch( type::equals );
+ Class<?> rawType = Classes.RAW_CLASS.apply( type );
+ return types().map( Classes.RAW_CLASS ).anyMatch( rawType::isAssignableFrom );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
index b51bc8c..e35d1b3 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/EntityTypeNotFoundException.java
@@ -17,8 +17,8 @@ package org.apache.zest.api.unitofwork;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
-import static java.util.stream.StreamSupport.stream;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
/**
* Zest exception to be thrown in case that an entity composite
@@ -29,7 +29,7 @@ public class EntityTypeNotFoundException
{
private final String compositeType;
- public EntityTypeNotFoundException( String entityType, String moduleName, Stream<String> visibility )
+ private EntityTypeNotFoundException( String entityType, String moduleName, Stream<String> visibility )
{
super( "Could not find an EntityComposite of type " + entityType + " in module [" + moduleName + "].\n" +
"\tThe following entity types are visible:\n" + visibility.collect( Collectors.joining( "\n" ) ) );
@@ -40,4 +40,17 @@ public class EntityTypeNotFoundException
{
return compositeType;
}
+
+ public static EntityTypeNotFoundException create( String type, ModuleDescriptor module )
+ {
+ return new EntityTypeNotFoundException( type,
+ module.name(),
+ module.findVisibleEntityTypes()
+ .map( item -> item.types()
+ .iterator()
+ .next()
+ .getName() + "[" + item.module()
+ .name() + "]" )
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
index b218e6d..2a66379 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
@@ -28,6 +28,7 @@ import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.structure.MetaInfoHolder;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
/**
@@ -207,7 +208,8 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
Function<PropertyDescriptor, Object> propertyFunction,
Function<AssociationDescriptor, EntityReference> associationFunction,
Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
+ )
throws EntityTypeNotFoundException, AmbiguousTypeException;
/**
@@ -234,7 +236,8 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
Function<PropertyDescriptor, Object> propertyFunction,
Function<AssociationDescriptor, EntityReference> associationFunction,
Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction )
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
+ )
throws EntityTypeNotFoundException, AmbiguousTypeException;
/**
@@ -431,4 +434,12 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
* @return The new or updated Entity
*/
<T extends Identity> T toEntity( Class<T> primaryType, T valueComposite );
+
+ /**
+ * The Module of the UnitOfWork is defined as the Module the UnitOfWorkFactory belonged to from where the
+ * UnitOfWork was created.
+ *
+ * @return the Module where this UnitOfWork was initialized.
+ */
+ ModuleDescriptor module();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java b/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
index 5860f4b..033db11 100644
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
+++ b/core/api/src/main/java/org/apache/zest/api/value/ValueBuilderTemplate.java
@@ -19,6 +19,7 @@
package org.apache.zest.api.value;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
/**
* Builder template for Values.
@@ -34,9 +35,9 @@ public abstract class ValueBuilderTemplate<T>
protected abstract void build( T prototype );
- public T newInstance( Module module )
+ public T newInstance( ModuleDescriptor module )
{
- ValueBuilder<T> builder = module.newValueBuilder( type );
+ ValueBuilder<T> builder = module.instance().newValueBuilder( type );
build( builder.prototype() );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java b/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
index cae79d6..f28af3f 100644
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
+++ b/core/api/src/main/java/org/apache/zest/api/value/ValueDeserializer.java
@@ -16,55 +16,55 @@
package org.apache.zest.api.value;
import java.io.InputStream;
-import java.util.function.BiFunction;
import java.util.function.Function;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
/**
* Use a ValueDeserializer to create new values instances from serialized state.
*
* <p>
- * Serialized state must be one of:
+ * Serialized state must be one of:
* </p>
* <ul>
- * <li>a ValueComposite,</li>
- * <li>an EntityReference,</li>
- * <li>a Collection,</li>
- * <li>a Map,</li>
- * <li>a Plain Value.</li>
+ * <li>a ValueComposite,</li>
+ * <li>an EntityReference,</li>
+ * <li>a Collection,</li>
+ * <li>a Map,</li>
+ * <li>a Plain Value.</li>
* </ul>
* <p>
- * Nested plain values, EntityReferences, Collections, Maps, ValueComposites are supported.
- * EntityReferences are deserialized as their identity string.
+ * Nested plain values, EntityReferences, Collections, Maps, ValueComposites are supported.
+ * EntityReferences are deserialized as their identity string.
* </p>
* <p>
- * Plain values can be one of:
+ * Plain values can be one of:
* </p>
* <ul>
- * <li>String,</li>
- * <li>Character or char,</li>
- * <li>Boolean or boolean,</li>
- * <li>Integer or int,</li>
- * <li>Long or long,</li>
- * <li>Short or short,</li>
- * <li>Byte or byte,</li>
- * <li>Float or float,</li>
- * <li>Double or double,</li>
- * <li>BigInteger,</li>
- * <li>BigDecimal,</li>
- * <li>Date,</li>
- * <li>DateTime (JodaTime),</li>
- * <li>LocalDateTime (JodaTime),</li>
- * <li>LocalDate (JodaTime).</li>
+ * <li>String,</li>
+ * <li>Character or char,</li>
+ * <li>Boolean or boolean,</li>
+ * <li>Integer or int,</li>
+ * <li>Long or long,</li>
+ * <li>Short or short,</li>
+ * <li>Byte or byte,</li>
+ * <li>Float or float,</li>
+ * <li>Double or double,</li>
+ * <li>BigInteger,</li>
+ * <li>BigDecimal,</li>
+ * <li>Date,</li>
+ * <li>DateTime (JodaTime),</li>
+ * <li>LocalDateTime (JodaTime),</li>
+ * <li>LocalDate (JodaTime).</li>
* </ul>
* <p>
- * Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are deserialized
- * from base64 encoded bytes using pure Java serialization. If it happens that the input is invalid, a
- * ValueSerializationException is thrown.
+ * Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are deserialized
+ * from base64 encoded bytes using pure Java serialization. If it happens that the input is invalid, a
+ * ValueSerializationException is thrown.
* </p>
* <p>
- * Having type information in the serialized payload allows to keep actual ValueComposite types and by so
- * circumvent {@link org.apache.zest.api.composite.AmbiguousTypeException} when deserializing.
+ * Having type information in the serialized payload allows to keep actual ValueComposite types and by so
+ * circumvent {@link org.apache.zest.api.composite.AmbiguousTypeException} when deserializing.
* </p>
*/
public interface ValueDeserializer
@@ -76,10 +76,11 @@ public interface ValueDeserializer
* <p>The returned Function may throw {@link ValueSerializationException}.</p>
*
* @param type the value type
- * @param <T> the parametrized function return type
+ * @param <T> the parametrized function return type
+ *
* @return a deserialization function
*/
- <T> Function<String, T> deserialize( Class<T> type );
+ <T> Function<String, T> deserialize( ModuleDescriptor module, Class<T> type );
/**
* Factory method for a typed deserialize function.
@@ -87,10 +88,11 @@ public interface ValueDeserializer
* <p>The returned Function may throw {@link ValueSerializationException}.</p>
*
* @param valueType the value type
- * @param <T> the parametrized function return type
+ * @param <T> the parametrized function return type
+ *
* @return a deserialization function
*/
- <T> Function<String, T> deserialize( ValueType valueType );
+ <T> Function<String, T> deserialize( ModuleDescriptor module, ValueType valueType );
/**
* Factory method for an untyped deserialize function.
@@ -100,53 +102,61 @@ public interface ValueDeserializer
* @param <T> the parametrized function return type
* @return a deserialization function
*/
- <T> BiFunction<ValueType, String, T> deserialize();
+// <T> BiFunction<ValueType, String, T> deserialize();
/**
* Deserialize a value from a state.
*
- * @param <T> the parametrized returned type
- * @param type the value type
+ * @param <T> the parametrized returned type
+ * @param type the value type
* @param input the state
+ *
* @return the value
+ *
* @throws ValueSerializationException if the deserialization failed
*/
- <T> T deserialize( Class<?> type, String input )
+ <T> T deserialize( ModuleDescriptor module, Class<?> type, String input )
throws ValueSerializationException;
/**
* Deserialize a value from a state.
*
- * @param <T> the parametrized returned type
+ * @param <T> the parametrized returned type
* @param valueType the value type
- * @param input the state
+ * @param input the state
+ *
* @return the value
+ *
* @throws ValueSerializationException if the deserialization failed
*/
- <T> T deserialize( ValueType valueType, String input )
+ <T> T deserialize( ModuleDescriptor module, ValueType valueType, String input )
throws ValueSerializationException;
/**
* Deserialize a value from a state.
*
- * @param <T> the parametrized returned type
- * @param type the value type
+ * @param <T> the parametrized returned type
+ * @param type the value type
* @param input the state stream
+ *
* @return the value
+ *
* @throws ValueSerializationException if the deserialization failed
*/
- <T> T deserialize( Class<?> type, InputStream input )
+ <T> T deserialize( ModuleDescriptor module, Class<?> type, InputStream input )
throws ValueSerializationException;
/**
* Deserialize a value from a state.
*
- * @param <T> the parametrized returned type
+ * @param <T> the parametrized returned type
* @param valueType the value type
- * @param input the state stream
+ * @param input the state stream
+ *
* @return the value
+ *
* @throws ValueSerializationException if the deserialization failed
*/
- <T> T deserialize( ValueType valueType, InputStream input )
+ <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream input )
throws ValueSerializationException;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java b/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
index 71cbb0f..69ba438 100644
--- a/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/configuration/ConfigurationTest.java
@@ -49,7 +49,7 @@ public class ConfigurationTest extends AbstractZestTest
public void testConfiguration()
throws Exception
{
- MyService service = module.findService( MyService.class ).get();
+ MyService service = serviceFinder.findService( MyService.class ).get();
PersonDetails details = service.details();
assertThat(details.name().get(), equalTo( "Niclas" ) );
assertThat(details.address().get().street1().get(), equalTo( "Henan Lu 555" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java b/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
index bbf81e2..1e00a4a 100644
--- a/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/configuration/DeclareConfigurationDefaultsTest.java
@@ -76,7 +76,7 @@ public class DeclareConfigurationDefaultsTest
@Test
public void testConfigurationDefaults()
{
- FooServiceComposite fooService = module.findService( FooServiceComposite.class ).get();
+ FooServiceComposite fooService = serviceFinder.findService( FooServiceComposite.class ).get();
Assert.assertEquals( "bar", fooService.configuredFoo() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java b/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
index 675a05e..2c2328a 100644
--- a/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/dataset/iterable/IterableDataSetTest.java
@@ -51,7 +51,7 @@ public class IterableDataSetTest
private TestValue newTestValue( String name )
{
- return module.newValueFromSerializedState( TestValue.class, "{name:'" + name + "'}" );
+ return valueBuilderFactory.newValueFromSerializedState( TestValue.class, "{name:'" + name + "'}" );
}
interface TestValue
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
index 38e7a84..7160348 100644
--- a/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/mixin/decoratorMixin/DecoratorMixinTest.java
@@ -76,7 +76,7 @@ public class DecoratorMixinTest extends AbstractZestTest
// START SNIPPET: create
public View1 createView1( FooModel model )
{
- TransientBuilder<View1> builder = module.newTransientBuilder( View1.class );
+ TransientBuilder<View1> builder = transientBuilderFactory.newTransientBuilder( View1.class );
builder.use( model );
return builder.newInstance();
}
@@ -84,7 +84,7 @@ public class DecoratorMixinTest extends AbstractZestTest
public View2 createView2( FooModel model )
{
- TransientBuilder<View2> builder = module.newTransientBuilder( View2.class );
+ TransientBuilder<View2> builder = transientBuilderFactory.newTransientBuilder( View2.class );
builder.use( model );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java b/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
index bd6a8b0..4331261 100644
--- a/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/object/ObjectBuilderTest.java
@@ -37,7 +37,7 @@ public class ObjectBuilderTest
@Test
public void testNotProvidedUses()
{
- A a = module.newObject( A.class );
+ A a = objectFactory.newObject( A.class );
assertNotNull( a );
assertNotNull( a.b );
assertNotNull( a.b.c );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java b/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
index 9f64100..ff356d4 100644
--- a/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/unitofwork/UnitOfWorkTemplateTest.java
@@ -58,11 +58,11 @@ public class UnitOfWorkTemplateTest
{
prototype.name().set( "Rickard" );
}
- }.newInstance( module );
+ }.newInstance( module.instance() );
return null;
}
- }.withModule( module );
+ }.withModule( module.instance() );
}
interface TestEntity
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
index e85e2fc..9406eb1 100644
--- a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
+++ b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
@@ -59,12 +59,6 @@ public class DocumentationSupport
extends AbstractZestTest
{
- @Before
- public void injectToThis()
- {
- module.injectTo( this );
- }
-
// START SNIPPET: default
// START SNIPPET: service
public interface SomeValue // (1)
@@ -90,9 +84,9 @@ public class DocumentationSupport
// START SNIPPET: default
public void defaultValueSerialization()
{
- SomeValue someValue = someNewValueInstance( module ); // (3)
+ SomeValue someValue = someNewValueInstance(); // (3)
String json = someValue.toString(); // (4)
- SomeValue someNewValue = module.newValueFromSerializedState( SomeValue.class, json ); // (5)
+ SomeValue someNewValue = valueBuilderFactory.newValueFromSerializedState( SomeValue.class, json ); // (5)
// END SNIPPET: default
assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
@@ -113,9 +107,9 @@ public class DocumentationSupport
// START SNIPPET: service
public void assembledDefaultServiceSerialization()
{
- SomeValue someValue = someNewValueInstance( module ); // (5)
+ SomeValue someValue = someNewValueInstance(); // (5)
String json = valueSerializer.serialize( someValue ); // (6)
- SomeValue someNewValue = valueDeserializer.deserialize( SomeValue.class, json ); // (7)
+ SomeValue someNewValue = valueDeserializer.deserialize( module, SomeValue.class, json ); // (7)
// END SNIPPET: service
assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
@@ -157,7 +151,7 @@ public class DocumentationSupport
InputStream input = sourceStream; // Eg. reading incoming JSON
// (4)
- List<AcmeValue> values = valueDeserializer.deserialize( CollectionType.listOf( AcmeValue.class ), input );
+ List<AcmeValue> values = valueDeserializer.deserialize( module, CollectionType.listOf( AcmeValue.class ), input );
// END SNIPPET: stream
assertThat( values, equalTo( dataSource ) );
@@ -197,7 +191,7 @@ public class DocumentationSupport
List<AcmeValue> values = new ArrayList<AcmeValue>();
// (5)
- Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( AcmeValue.class );
+ Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( module, AcmeValue.class );
// Deserialization of a collection of AcmeValue from a String.
// One serialized AcmeValue per line.
@@ -255,7 +249,7 @@ public class DocumentationSupport
try
{
Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" );
- SomeValue someValue = someNewValueInstance( valuesModule );
+ SomeValue someValue = someNewValueInstance();
Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" );
ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get();
@@ -263,7 +257,7 @@ public class DocumentationSupport
String json = valueSerialization.serialize( someValue );
assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
- SomeValue someNewValue = valueSerialization.deserialize( SomeValue.class, json );
+ SomeValue someNewValue = valueSerialization.deserialize( module, SomeValue.class, json );
assertThat( someNewValue, equalTo( someValue ) );
}
finally
@@ -272,9 +266,9 @@ public class DocumentationSupport
}
}
- private SomeValue someNewValueInstance( Module module )
+ private SomeValue someNewValueInstance( )
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
builder.prototype().foo().set( "bar" );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
index b5499c4..8d0bb14 100644
--- a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
+++ b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java
@@ -57,7 +57,7 @@ public class ValueCompositeTest
@Test( expected = IllegalStateException.class )
public void testImmutabilityOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue some = builder.prototype();
some.other().set( "test" );
some = builder.newInstance();
@@ -67,7 +67,7 @@ public class ValueCompositeTest
@Test
public void testCreationOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue some = builder.prototype();
some.other().set( "test" );
builder.newInstance();
@@ -79,7 +79,7 @@ public class ValueCompositeTest
@Test
public void testEqualityOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue instance = builder.newInstance();
@@ -91,7 +91,7 @@ public class ValueCompositeTest
@Test
public void testHashcodeOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue instance = builder.newInstance();
@@ -103,11 +103,11 @@ public class ValueCompositeTest
@Test
public void testModifyValue()
{
- ValueBuilder<AnotherValue> anotherBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<AnotherValue> anotherBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class );
anotherBuilder.prototype().val1().set( "Val1" );
AnotherValue anotherValue = anotherBuilder.newInstance();
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.some().set( "foo" );
prototype.other().set( "test" );
@@ -118,7 +118,7 @@ public class ValueCompositeTest
assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
// Modify value
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().some().set( "bar" );
instance = builder.newInstance();
@@ -127,7 +127,7 @@ public class ValueCompositeTest
assertThat( "AnotherValue.val1 has value Val1", instance.another().get().val1().get(), equalTo( "Val1" ) );
// Modify value again using method 2
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().other().set( "test2" );
instance = builder.newInstance();
@@ -138,25 +138,25 @@ public class ValueCompositeTest
@Test( expected = ConstraintViolationException.class )
public void givenValueWhenModifyToIncorrectValueThenThrowConstraintException()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.some().set( "foo" );
SomeValue instance = builder.newInstance();
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().some().set( "123456" );
}
@Test
public void givenValueWithListOfValueWhenPrototypeThenListedValuesAreEditable()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
SomeValue some = builder.newInstance();
- builder = module.newValueBuilderWithPrototype( some );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( some );
builder.prototype().anotherList().get().get( 0 ).val1().set( "Foo" );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
some = builder.newInstance();
assertThat( "Val1 has been set", some.anotherList().get().get( 0 ).val1().get(), equalTo( "Foo" ) );
@@ -176,9 +176,9 @@ public class ValueCompositeTest
public void givenEntityWhenUpdateValueThenValueIsSet()
throws UnitOfWorkCompletionException
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
- ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
+ ValueBuilder<AnotherValue> valueBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class );
valueBuilder.prototype().val1().set( "Foo" );
builder.prototype().another().set( valueBuilder.newInstance() );
builder.prototype().number().set( 42L );
@@ -205,9 +205,9 @@ public class ValueCompositeTest
public void givenValueWithAssociationsWhenNewUoWThenCanRead()
throws UnitOfWorkCompletionException
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
- ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
+ ValueBuilder<AnotherValue> valueBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class );
valueBuilder.prototype().val1().set( "Foo" );
builder.prototype().another().set( valueBuilder.newInstance() );
builder.prototype().number().set( 42L );
@@ -221,7 +221,7 @@ public class ValueCompositeTest
entityBuilder.instance().someValue().set( some );
SomeEntity entity = entityBuilder.newInstance();
- ValueBuilder<AssociationValue> associationBuilder = module.newValueBuilder( AssociationValue.class );
+ ValueBuilder<AssociationValue> associationBuilder = valueBuilderFactory.newValueBuilder( AssociationValue.class );
associationBuilder.prototype().some().set( entity );
associationValue = associationBuilder.newInstance();
@@ -231,7 +231,7 @@ public class ValueCompositeTest
unitOfWork = uowf.newUnitOfWork();
- AssociationValue newAssociationValue = module.newValueFromSerializedState( AssociationValue.class, json );
+ AssociationValue newAssociationValue = valueBuilderFactory.newValueFromSerializedState( AssociationValue.class, json );
Assert.assertEquals( associationValue.some().get(), newAssociationValue.some().get() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
index ce9a239..458e415 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/ZestRuntimeImpl.java
@@ -42,7 +42,7 @@ import org.apache.zest.api.property.StateHolder;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDescriptor;
@@ -128,7 +128,7 @@ public final class ZestRuntimeImpl
}
@Override
- public Module moduleOf( Object compositeOrServiceReferenceOrUow )
+ public ModuleDescriptor moduleOf( Object compositeOrServiceReferenceOrUow )
{
if( compositeOrServiceReferenceOrUow instanceof TransientComposite )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
index 2483461..545dfd1 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivatorsModel.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.Activator;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.composite.UsesInstance;
@@ -82,13 +83,13 @@ public class ActivatorsModel<ActivateeType>
return activators;
}
- public Iterable<Activator<ActivateeType>> newInstances( Module module )
+ public Iterable<Activator<ActivateeType>> newInstances( ModuleDescriptor module )
throws ActivationException
{
List<Activator<ActivateeType>> activators = new ArrayList<>();
for( ActivatorModel<ActivateeType> activatorModel : activatorModels )
{
- InjectionContext injectionContext = new InjectionContext( (ModuleInstance) module, UsesInstance.EMPTY_USES );
+ InjectionContext injectionContext = new InjectionContext( module, UsesInstance.EMPTY_USES );
activators.add( activatorModel.newInstance( injectionContext ) );
}
return activators;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
index d1eb738..6da472e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
@@ -83,7 +83,7 @@ public final class ApplicationModelFactoryImpl
for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() )
{
- moduleModels.add( moduleAssembly.assembleModule( helper ) );
+ moduleModels.add( moduleAssembly.assembleModule( layerModel, helper ) );
}
mapAssemblyModel.put( layerAssembly, layerModel );
layerModels.add( layerModel );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
index a9e92fa..8e7942a 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
@@ -27,6 +27,7 @@ import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.property.GenericPropertyInfo;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.Annotations;
import org.apache.zest.api.util.Classes;
import org.apache.zest.bootstrap.*;
@@ -85,6 +86,7 @@ public final class EntityAssemblyImpl
}
EntityModel newEntityModel(
+ ModuleDescriptor module,
StateDeclarations stateDeclarations,
AssociationDeclarations associationDecs,
ManyAssociationDeclarations manyAssociationDecs,
@@ -102,7 +104,7 @@ public final class EntityAssemblyImpl
namedAssociationsModel = new NamedAssociationsModel();
buildComposite( helper, stateDeclarations );
- return new EntityModel( types, visibility, metaInfo,
+ return new EntityModel( module, types, visibility, metaInfo,
(EntityMixinsModel) mixinsModel,
(EntityStateModel) stateModel, compositeMethodsModel );
}
[20/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
index aaa8662..3a1b6f4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
@@ -61,10 +61,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfTheSameTypeWhenTestingValueDescriptorEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue(valueBuilderFactory);
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
- Some other = buildSomeValue( module );
+ Some other = buildSomeValue( valueBuilderFactory );
ValueDescriptor otherDescriptor = zest.api().valueDescriptorFor( other );
assertThat( "ValueDescriptors equal",
@@ -78,10 +78,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfCommonTypesWhenTestingValueDescriptorEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
- PrimitivesValue primitive = buildPrimitivesValue( module );
+ PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory );
ValueDescriptor primitiveDescriptor = zest.api().valueDescriptorFor( primitive );
assertThat( "ValueDescriptors not equal",
@@ -95,10 +95,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfDifferentTypesWhenTestingValueDescriptorEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
- Other other = buildOtherValue( module );
+ Other other = buildOtherValue( valueBuilderFactory );
ValueDescriptor otherDescriptor = zest.api().valueDescriptorFor( other );
assertThat( "ValueDescriptors not equal",
@@ -115,10 +115,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfSameTypesAndSameStateWhenTestingValueStateEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
AssociationStateHolder someState = zest.spi().stateOf( (ValueComposite) some );
- Some some2 = buildSomeValue( module );
+ Some some2 = buildSomeValue( valueBuilderFactory );
AssociationStateHolder some2State = zest.spi().stateOf( (ValueComposite) some2 );
assertThat( "ValueStates equal",
@@ -132,10 +132,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfSameTypesAndDifferentStateWhenTestingValueStateEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
AssociationStateHolder someState = zest.spi().stateOf( (ValueComposite) some );
- Some some2 = buildSomeValueWithDifferentState( module );
+ Some some2 = buildSomeValueWithDifferentState( valueBuilderFactory );
AssociationStateHolder some2State = zest.spi().stateOf( (ValueComposite) some2 );
assertThat( "ValueStates not equal",
@@ -149,10 +149,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingValueStateEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
AssociationStateHolder someState = zest.spi().stateOf( (ValueComposite) some );
- AnotherSome anotherSome = buildAnotherSomeValue( module );
+ AnotherSome anotherSome = buildAnotherSomeValue( valueBuilderFactory );
AssociationStateHolder anotherSomeState = zest.spi().stateOf( (ValueComposite) anotherSome );
assertThat( "ValueStates equal",
@@ -166,10 +166,10 @@ public class ValueEqualityTest
@Test
public void givenValuesOfDifferentTypesAndDifferentStateWhenTestingValueStateEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
AssociationStateHolder someState = zest.spi().stateOf( (ValueComposite) some );
- AnotherSome anotherSome = buildAnotherSomeValueWithDifferentState( module );
+ AnotherSome anotherSome = buildAnotherSomeValueWithDifferentState( valueBuilderFactory );
AssociationStateHolder anotherSomeState = zest.spi().stateOf( (ValueComposite) anotherSome );
assertThat( "ValueStates not equal",
@@ -186,8 +186,8 @@ public class ValueEqualityTest
@Test
public void givenValuesOfSameTypesAndSameStateWhenTestingValueEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
- Some some2 = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some some2 = buildSomeValue( valueBuilderFactory );
assertThat( "Values equal",
some,
equalTo( some2 ) );
@@ -199,8 +199,8 @@ public class ValueEqualityTest
@Test
public void givenValuesOfTheSameTypeWithDifferentStateWhenTestingValueEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Some some2 = buildSomeValueWithDifferentState( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some some2 = buildSomeValueWithDifferentState( valueBuilderFactory );
assertThat( "Values not equals",
some,
not( equalTo( some2 ) ) );
@@ -212,8 +212,8 @@ public class ValueEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingValueEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Some anotherSome = buildAnotherSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some anotherSome = buildAnotherSomeValue( valueBuilderFactory );
assertThat( "Values not equal",
some,
@@ -226,8 +226,8 @@ public class ValueEqualityTest
@Test
public void givenValuesOfDifferentTypesAndDifferentStateWhenTestingValueEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Some anotherSome = buildAnotherSomeValueWithDifferentState( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some anotherSome = buildAnotherSomeValueWithDifferentState( valueBuilderFactory );
assertThat( "Values not equal",
some,
not( equalTo( anotherSome ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
index ceb8c7a..a562cd2 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
@@ -56,7 +56,7 @@ public class ValueInjectionDeserializationTest
UnitOfWork uow = null;
try
{
- ValueBuilder<Some> builder = module.newValueBuilder( Some.class );
+ ValueBuilder<Some> builder = valueBuilderFactory.newValueBuilder( Some.class );
builder.prototype().data().set( "Niclas" );
Some value = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java
index c62423b..13a3e14 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java
@@ -52,7 +52,7 @@ public class ValueSerializationRegressionTest extends AbstractZestTest
public void givenNewValueWhenConvertingToEntityExpectNewEntityInStore()
throws UnitOfWorkCompletionException
{
- ValueBuilder<DualFaced> builder = module.newValueBuilder( DualFaced.class );
+ ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
builder.prototype().identity().set( "1234" );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
index c16af32..c2eba27 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
@@ -113,7 +113,7 @@ public class ValueWithAssociationTest extends AbstractZestTest
public void givenNewValueWhenConvertingToEntityExpectNewEntityInStore()
throws UnitOfWorkCompletionException
{
- ValueBuilder<DualFaced> builder = module.newValueBuilder( DualFaced.class );
+ ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
builder.prototype().identity().set( "1234" );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
@@ -156,12 +156,12 @@ public class ValueWithAssociationTest extends AbstractZestTest
identity2 = faced.identity().get();
uow.complete();
}
- ValueBuilder<SimpleName> vb1 = module.newValueBuilder( SimpleName.class );
+ ValueBuilder<SimpleName> vb1 = valueBuilderFactory.newValueBuilder( SimpleName.class );
vb1.prototype().identity().set( identity1 );
vb1.prototype().name().set( "Paul" );
SimpleName simpleValue = vb1.newInstance();
- ValueBuilder<DualFaced> vb2 = module.newValueBuilder( DualFaced.class );
+ ValueBuilder<DualFaced> vb2 = valueBuilderFactory.newValueBuilder( DualFaced.class );
vb2.prototype().identity().set( identity2 );
vb2.prototype().name().set( "Merlin" );
vb2.prototype().simple().set( simpleValue );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
index f8dd02c..045e89e 100644
--- a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
@@ -46,7 +46,7 @@ public class InstanceImporterTest
@Test
public void givenSingletonServiceObjectWhenServicesAreInjectedThenSingletonIsFound()
{
- module.injectTo( this );
+ module.instance().injectTo( this );
assertThat( "service is injected properly", service.helloWorld(), equalTo( "Hello World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/spi/service/importer/NewObjectImporterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/NewObjectImporterTest.java b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/NewObjectImporterTest.java
index e382ba2..007ef61 100644
--- a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/NewObjectImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/NewObjectImporterTest.java
@@ -45,8 +45,6 @@ public class NewObjectImporterTest
@Test
public void testImportServiceFromService()
{
- module.injectTo( this );
-
Assert.assertThat( service.helloWorld(), CoreMatchers.equalTo( "Hello World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java
index fb3afc9..49a1b3e 100644
--- a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java
@@ -52,8 +52,6 @@ public class ServiceInstanceImporterTest
@Test
public void testImportServiceFromService()
{
- module.injectTo( this );
-
Assert.assertThat( service.helloWorld(), CoreMatchers.equalTo( "Hello World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/test/composite/CleanStackTraceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/test/composite/CleanStackTraceTest.java b/core/runtime/src/test/java/org/apache/zest/test/composite/CleanStackTraceTest.java
index da247ff..3fc6339 100644
--- a/core/runtime/src/test/java/org/apache/zest/test/composite/CleanStackTraceTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/test/composite/CleanStackTraceTest.java
@@ -67,7 +67,7 @@ public class CleanStackTraceTest
{
return;
}
- TestComposite composite = module.newTransient( TestComposite.class );
+ TestComposite composite = transientBuilderFactory.newTransient( TestComposite.class );
try
{
composite.doStuff();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
index 9e85c83..09ffd58 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
@@ -22,9 +22,9 @@ import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* Concern that helps EntityStores do concurrent modification checks.
@@ -47,9 +47,9 @@ public abstract class ConcurrentModificationCheckConcern
private ZestAPI api;
@Override
- public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+ public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
{
- final EntityStoreUnitOfWork uow = next.newUnitOfWork( usecase, currentTime );
+ final EntityStoreUnitOfWork uow = next.newUnitOfWork( module, usecase, currentTime );
return new ConcurrentCheckingEntityStoreUnitOfWork( uow, api.dereference( versions ), currentTime );
}
@@ -163,9 +163,15 @@ public abstract class ConcurrentModificationCheckConcern
return uow.usecase();
}
+ @Override
+ public ModuleDescriptor module()
+ {
+ return uow.module();
+ }
+
@SuppressWarnings( "DuplicateThrows" )
@Override
- public EntityState entityStateOf( ModuleSpi module, EntityReference anIdentity )
+ public EntityState entityStateOf( ModuleDescriptor module, EntityReference anIdentity )
throws EntityStoreException, EntityNotFoundException
{
lock.readLock().lock();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
index f6e48f1..7e1c332 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
@@ -17,9 +17,9 @@ package org.apache.zest.spi.entitystore;
import java.util.HashMap;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* Default EntityStore UnitOfWork.
@@ -27,18 +27,21 @@ import org.apache.zest.spi.module.ModuleSpi;
public final class DefaultEntityStoreUnitOfWork
implements EntityStoreUnitOfWork
{
+ private final ModuleDescriptor module;
private EntityStoreSPI entityStoreSPI;
private String identity;
private HashMap<EntityReference, EntityState> states = new HashMap<>();
private Usecase usecase;
private long currentTime;
- public DefaultEntityStoreUnitOfWork( EntityStoreSPI entityStoreSPI,
+ public DefaultEntityStoreUnitOfWork( ModuleDescriptor module,
+ EntityStoreSPI entityStoreSPI,
String identity,
Usecase usecase,
long currentTime
)
{
+ this.module = module;
this.entityStoreSPI = entityStoreSPI;
this.identity = identity;
this.usecase = usecase;
@@ -62,7 +65,12 @@ public final class DefaultEntityStoreUnitOfWork
return usecase;
}
- // EntityStore
+ @Override
+ public ModuleDescriptor module()
+ {
+ return module;
+ }
+// EntityStore
@Override
public EntityState newEntityState( EntityReference anIdentity, EntityDescriptor descriptor )
@@ -79,7 +87,7 @@ public final class DefaultEntityStoreUnitOfWork
}
@Override
- public EntityState entityStateOf( ModuleSpi module, EntityReference anIdentity )
+ public EntityState entityStateOf( ModuleDescriptor module, EntityReference anIdentity )
throws EntityNotFoundException
{
EntityState entityState = states.get( anIdentity );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
index 57a7119..be57097 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
@@ -21,9 +21,11 @@ import java.util.WeakHashMap;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entity.EntityStatus;
+import org.apache.zest.spi.module.ModuleSpi;
/**
* Entity versions state.
@@ -81,7 +83,7 @@ public interface EntityStateVersions
String storeVersion = versions.get( entityState.identity() );
if( storeVersion == null )
{
- EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( Usecase.DEFAULT, currentTime );
+ EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( entityState.entityDescriptor().module(), Usecase.DEFAULT, currentTime );
storeVersion = unitOfWork.versionOf( entityState.identity() );
unitOfWork.discard();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
index 0a3d3e3..d172815 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
@@ -16,17 +16,17 @@
*/
package org.apache.zest.spi.entitystore;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.io.Input;
import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* Interface that must be implemented by store for persistent state of EntityComposites.
*/
public interface EntityStore
{
- EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime );
+ EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime );
- Input<EntityState, EntityStoreException> entityStates( ModuleSpi module );
+ Input<EntityState, EntityStoreException> entityStates( ModuleDescriptor module );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
index fc125a7..6fccb64 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
@@ -16,8 +16,8 @@ package org.apache.zest.spi.entitystore;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* EntityStore SPI.
@@ -28,10 +28,9 @@ public interface EntityStoreSPI
EntityReference identity, EntityDescriptor entityDescriptor
);
- EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference identity );
+ EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor module, EntityReference identity );
String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity );
- StateCommitter applyChanges( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> state
- );
+ StateCommitter applyChanges( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> state );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
index e5d569c..b35854e 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
@@ -16,9 +16,9 @@ package org.apache.zest.spi.entitystore;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* EntityStore UnitOfWork.
@@ -49,6 +49,8 @@ public interface EntityStoreUnitOfWork
* Get the EntityState for a given identity. Throws {@link EntityNotFoundException}
* if the entity with given {@code anIdentity} is not found.
*
+ *
+ * @param module
* @param anIdentity The entity identity. This argument must not be {@code null}.
*
* @return Entity state given the composite descriptor and identity.
@@ -56,7 +58,7 @@ public interface EntityStoreUnitOfWork
* @throws EntityStoreException thrown if retrieval failed.
* @throws EntityNotFoundException if requested entity does not exist
*/
- EntityState entityStateOf( ModuleSpi module, EntityReference anIdentity )
+ EntityState entityStateOf( ModuleDescriptor module, EntityReference anIdentity )
throws EntityStoreException, EntityNotFoundException;
String versionOf( EntityReference anIdentity ) throws EntityStoreException;
@@ -67,4 +69,6 @@ public interface EntityStoreUnitOfWork
void discard();
Usecase usecase();
+
+ ModuleDescriptor module();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
index 1b2a1df..09ce715 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
@@ -19,13 +19,11 @@
*/
package org.apache.zest.spi.entitystore.helpers;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.apache.zest.api.common.QualifiedName;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.api.value.ValueSerializationException;
@@ -34,6 +32,9 @@ import org.apache.zest.spi.entity.EntityStatus;
import org.apache.zest.spi.entity.ManyAssociationState;
import org.apache.zest.spi.entity.NamedAssociationState;
import org.apache.zest.spi.entitystore.EntityStoreException;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
/**
* Standard JSON implementation of EntityState.
@@ -51,6 +52,7 @@ public final class JSONEntityState
JSONKeys.MODIFIED
};
+ private final ModuleDescriptor module;
private final ValueSerialization valueSerialization;
private final String version;
private final EntityReference identity;
@@ -60,23 +62,8 @@ public final class JSONEntityState
private long lastModified;
private JSONObject state;
- /* package */ JSONEntityState( long time,
+ /* package */ JSONEntityState( ModuleDescriptor module,
ValueSerialization valueSerialization,
- EntityReference identity,
- EntityDescriptor entityDescriptor,
- JSONObject initialState
- )
- {
- this( valueSerialization,
- "",
- time,
- identity,
- EntityStatus.NEW,
- entityDescriptor,
- initialState );
- }
-
- /* package */ JSONEntityState( ValueSerialization valueSerialization,
String version,
long lastModified,
EntityReference identity,
@@ -85,6 +72,7 @@ public final class JSONEntityState
JSONObject state
)
{
+ this.module = module;
this.valueSerialization = valueSerialization;
this.version = version;
this.lastModified = lastModified;
@@ -130,7 +118,7 @@ public final class JSONEntityState
{
return null;
}
- return valueSerialization.deserialize( descriptor.valueType(), json.toString() );
+ return valueSerialization.deserialize( module, descriptor.valueType(), json.toString() );
}
}
catch( ValueSerializationException | JSONException e )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index 8dedcfd..a963118 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -39,6 +39,7 @@ import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.value.ValueSerialization;
@@ -58,8 +59,6 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
@@ -139,9 +138,9 @@ public class JSONMapEntityStoreMixin
// EntityStore
@Override
- public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, long currentTime )
+ public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, long currentTime )
{
- return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
+ return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
}
// EntityStoreSPI
@@ -164,8 +163,14 @@ public class JSONMapEntityStoreMixin
state.put( JSONKeys.ASSOCIATIONS, new JSONObject() );
state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
state.put( JSONKeys.NAMED_ASSOCIATIONS, new JSONObject() );
- return new JSONEntityState( unitOfWork.currentTime(), valueSerialization,
- identity, entityDescriptor, state );
+ return new JSONEntityState( entityDescriptor.module(),
+ valueSerialization,
+ "",
+ unitOfWork.currentTime(),
+ identity,
+ EntityStatus.NEW,
+ entityDescriptor,
+ state );
}
catch( JSONException e )
{
@@ -175,7 +180,7 @@ public class JSONMapEntityStoreMixin
@Override
public synchronized EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
- ModuleSpi module,
+ ModuleDescriptor module,
EntityReference identity
)
{
@@ -196,7 +201,7 @@ public class JSONMapEntityStoreMixin
@Override
public synchronized String versionOf( EntityStoreUnitOfWork unitOfWork,
- EntityReference identity
+ EntityReference identity
)
{
CacheState cacheState = cache.get( identity.identity() );
@@ -298,7 +303,7 @@ public class JSONMapEntityStoreMixin
}
@Override
- public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+ public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
{
return new Input<EntityState, EntityStoreException>()
{
@@ -417,7 +422,7 @@ public class JSONMapEntityStoreMixin
}
}
- protected JSONEntityState readEntityState( ModuleSpi module, Reader entityState )
+ protected JSONEntityState readEntityState( ModuleDescriptor module, Reader entityState )
throws EntityStoreException
{
try
@@ -457,14 +462,11 @@ public class JSONMapEntityStoreMixin
EntityDescriptor entityDescriptor = module.entityDescriptor( type );
if( entityDescriptor == null )
{
- throw new EntityTypeNotFoundException( type,
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type, module );
}
- return new JSONEntityState( valueSerialization,
+ return new JSONEntityState( module,
+ valueSerialization,
version,
modified,
EntityReference.parseEntityReference( identity ),
@@ -493,7 +495,7 @@ public class JSONMapEntityStoreMixin
}
}
- private EntityState fetchCachedState( EntityReference identity, ModuleSpi module, long currentTime )
+ private EntityState fetchCachedState( EntityReference identity, ModuleDescriptor module, long currentTime )
{
CacheState cacheState = cache.get( identity.identity() );
if( cacheState != null )
@@ -503,7 +505,7 @@ public class JSONMapEntityStoreMixin
{
String type = data.getString( JSONKeys.TYPE );
EntityDescriptor entityDescriptor = module.entityDescriptor( type );
- return new JSONEntityState( valueSerialization, data.getString( JSONKeys.VERSION ), data.getLong( JSONKeys.MODIFIED ), identity, EntityStatus.LOADED, entityDescriptor, data );
+ return new JSONEntityState( module, valueSerialization, data.getString( JSONKeys.VERSION ), data.getLong( JSONKeys.MODIFIED ), identity, EntityStatus.LOADED, entityDescriptor, data );
}
catch( JSONException e )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
index d553437..55830d8 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -37,6 +37,7 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.usecase.Usecase;
@@ -55,8 +56,6 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -109,9 +108,9 @@ public class MapEntityStoreMixin
// EntityStore
@Override
- public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, long currentTime )
+ public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, long currentTime )
{
- return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
+ return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
}
// EntityStoreSPI
@@ -126,7 +125,7 @@ public class MapEntityStoreMixin
@Override
public synchronized EntityState entityStateOf( EntityStoreUnitOfWork unitofwork,
- ModuleSpi module,
+ ModuleDescriptor module,
EntityReference identity
)
{
@@ -136,7 +135,7 @@ public class MapEntityStoreMixin
@Override
public synchronized String versionOf( EntityStoreUnitOfWork unitofwork,
- EntityReference identity
+ EntityReference identity
)
{
Reader in = mapEntityStore.get( identity );
@@ -202,7 +201,7 @@ public class MapEntityStoreMixin
}
@Override
- public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+ public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
{
return new Input<EntityState, EntityStoreException>()
{
@@ -379,13 +378,13 @@ public class MapEntityStoreMixin
}
}
- protected EntityState readEntityState( ModuleSpi module, Reader entityState )
+ protected EntityState readEntityState( ModuleDescriptor module, Reader entityState )
throws EntityStoreException
{
try
{
JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
- final EntityStatus[] status = {EntityStatus.LOADED};
+ final EntityStatus[] status = { EntityStatus.LOADED };
String version = jsonObject.getString( JSONKeys.VERSION );
long modified = jsonObject.getLong( JSONKeys.MODIFIED );
@@ -405,7 +404,7 @@ public class MapEntityStoreMixin
jsonObject.put( JSONKeys.APPLICATION_VERSION, application.version() );
}
// State changed
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
String type = jsonObject.getString( JSONKeys.TYPE );
@@ -413,11 +412,7 @@ public class MapEntityStoreMixin
EntityDescriptor entityDescriptor = module.entityDescriptor( type );
if( entityDescriptor == null )
{
- throw new EntityTypeNotFoundException( type,
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type, module );
}
Map<QualifiedName, Object> properties = new HashMap<>();
@@ -433,7 +428,8 @@ public class MapEntityStoreMixin
}
else
{
- Object value = valueSerialization.deserialize( propertyDescriptor.valueType(), jsonValue.toString() );
+ Object value = valueSerialization.deserialize( module, propertyDescriptor.valueType(), jsonValue
+ .toString() );
properties.put( propertyDescriptor.qualifiedName(), value );
}
}
@@ -442,7 +438,7 @@ public class MapEntityStoreMixin
// Value not found, default it
Object initialValue = propertyDescriptor.initialValue( module );
properties.put( propertyDescriptor.qualifiedName(), initialValue );
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
} );
@@ -461,7 +457,7 @@ public class MapEntityStoreMixin
{
// Association not found, default it to null
associations.put( associationType.qualifiedName(), null );
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
} );
@@ -516,12 +512,12 @@ public class MapEntityStoreMixin
// NamedAssociation not found, default to empty one
namedAssociations.put( namedAssociationType.qualifiedName(), references );
}
- } );
+ } );
return new DefaultEntityState( version,
modified,
EntityReference.parseEntityReference( identity ),
- status[0],
+ status[ 0 ],
entityDescriptor,
properties,
associations,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
index cb5208c..9192478 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
@@ -16,14 +16,10 @@
*/
package org.apache.zest.spi.module;
-import java.util.stream.Stream;
-import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.entity.IdentityGenerator;
import org.apache.zest.api.metrics.MetricsProvider;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.spi.structure.TypeLookup;
-import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.TypeLookup;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.spi.entitystore.EntityStore;
@@ -35,16 +31,6 @@ public interface ModuleSpi extends Module
ValueSerialization valueSerialization();
- Stream<ModelModule<? extends ModelDescriptor>> findVisibleEntityTypes();
-
- Stream<ModelModule<? extends ModelDescriptor>> findVisibleValueTypes();
-
- Stream<ModelModule<? extends ModelDescriptor>> findVisibleTransientTypes();
-
- Stream<ModelModule<? extends ModelDescriptor>> findVisibleObjectTypes();
-
- Stream<ServiceReference<?>> findVisibleServiceTypes();
-
TypeLookup typeLookup();
MetricsProvider metricsProvider();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java b/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
deleted file mode 100644
index 6b584ae..0000000
--- a/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
+++ /dev/null
@@ -1,107 +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.zest.spi.structure;
-
-import java.util.function.Function;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.spi.module.ModuleSpi;
-
-/**
- * TODO
- */
-public class ModelModule<T extends ModelDescriptor>
-{
-
- public static Function<ModelModule<?>, String> toStringFunction = item -> item.model()
- .types()
- .iterator()
- .next()
- .getName() + "[" + item.module()
- .name() + "]";
-
- public static <T extends ModelDescriptor> Function<T, ModelModule<T>> modelModuleFunction( final ModuleSpi module )
- {
- return model1 -> new ModelModule<>( module, model1 );
- }
-
- public static Function<ModelModule<? extends ModelDescriptor>, ModelDescriptor> modelFunction()
- {
- return modelModule -> {
- return modelModule.model();
- };
- }
-
- private final ModuleSpi module;
- private final T model;
-
- public ModelModule( ModuleSpi module, T model )
- {
- this.module = module;
- this.model = model;
- }
-
- public ModuleSpi module()
- {
- return module;
- }
-
- public T model()
- {
- return model;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if( this == o )
- {
- return true;
- }
- if( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- ModelModule that = (ModelModule) o;
-
- //noinspection SimplifiableIfStatement
- if( model != null ? !model.equals( that.model ) : that.model != null )
- {
- return false;
- }
-
- return !( module != null ? !module.equals( that.module ) : that.module != null );
- }
-
- @Override
- public int hashCode()
- {
- int result = module != null ? module.hashCode() : 0;
- result = 31 * result + ( model != null ? model.hashCode() : 0 );
- return result;
- }
-
- @Override
- public String toString()
- {
- return module.name() + ":" + model;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java b/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
deleted file mode 100644
index 94e0473..0000000
--- a/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
+++ /dev/null
@@ -1,125 +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.zest.spi.structure;
-
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.stream.Stream;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.value.ValueDescriptor;
-
-public interface TypeLookup
-{
- /**
- * Lookup first Entity Model matching the given Type.
- *
- * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
- * {@link #lookupEntityModels(Class)}.</p>
- *
- * @param type Looked up Type
- *
- * @return First matching Entity Model
- */
- ModelModule<EntityDescriptor> lookupEntityModel( Class type );
-
- /**
- * Lookup all Entity Models matching the given Type.
- *
- * <p>Returned Iterable contains, in order, Entity Models that: </p>
- *
- * <ul>
- * <li>exactly match the given type, in Visibility then Assembly order ;</li>
- * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
- * </ul>
- *
- * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
- * {@link #lookupEntityModel(Class)}.</p>
- *
- * @param type Looked up Type
- *
- * @return All matching Entity Models
- */
- Iterable<ModelModule<EntityDescriptor>> lookupEntityModels( Class type );
-
- /**
- * Lookup first ServiceReference matching the given Type.
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p>See {@link #lookupServiceReferences(Type)}.</p>
- *
- * @param <T> Service Type
- * @param serviceType Looked up Type
- *
- * @return First matching ServiceReference
- */
- <T> ServiceReference<T> lookupServiceReference( Type serviceType );
-
- /**
- * Lookup all ServiceReferences matching the given Type.
- *
- * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
- *
- * <ul>
- * <li>exactly match the given type, in Visibility then Assembly order ;</li>
- * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
- * </ul>
- *
- * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
- * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param <T> Service Type
- * @param type Looked up Type
- *
- * @return All matching ServiceReferences
- */
- <T> List<ServiceReference<T>> lookupServiceReferences( Type type );
-
- Stream<Class<?>> allVisibleObjects();
-
- Stream<ModelModule<ObjectDescriptor>> allObjects();
-
- Stream<ModelModule<TransientDescriptor>> allTransients();
-
- Stream<ModelModule<ValueDescriptor>> allValues();
-
- Stream<ModelModule<EntityDescriptor>> allEntities();
-
- Stream<ServiceReference<?>> allServices();
-}
[21/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI256Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI256Test.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI256Test.java
index b99b4e1..2eb3bf4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI256Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI256Test.java
@@ -14,12 +14,12 @@
package org.apache.zest.runtime.composite;
-import org.junit.Test;
import org.apache.zest.api.composite.TransientComposite;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.Test;
/**
* JAVADOC
@@ -38,40 +38,40 @@ public class QI256Test
}
@Mixins( { TestTransient.TestTransientMixin.class } )
- public static interface TestTransient
+ public interface TestTransient
extends TransientComposite
{
- public void declaredMethodThatThrowsCustomException();
+ void declaredMethodThatThrowsCustomException();
- public void invokeDeclaredPublicMethodThatThrowsCustomException();
+ void invokeDeclaredPublicMethodThatThrowsCustomException();
- public void invokePrivateMethodThatThrowsCustomException();
+ void invokePrivateMethodThatThrowsCustomException();
- public void invokeProtectedMethodThatThrowsCustomException();
+ void invokeProtectedMethodThatThrowsCustomException();
- public void invokeUndeclaredPublicMethodThatThrowsCustomException();
+ void invokeUndeclaredPublicMethodThatThrowsCustomException();
- public void declaredMethodThatThrowsBuiltinInheritedException();
+ void declaredMethodThatThrowsBuiltinInheritedException();
- public void invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException();
+ void invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException();
- public void invokePrivateMethodThatThrowsBuiltinInheritedException();
+ void invokePrivateMethodThatThrowsBuiltinInheritedException();
- public void invokeProtectedMethodThatThrowsBuiltinInheritedException();
+ void invokeProtectedMethodThatThrowsBuiltinInheritedException();
- public void invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException();
+ void invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException();
- public void declaredMethodThatThrowsBuiltinException();
+ void declaredMethodThatThrowsBuiltinException();
- public void invokeDeclaredPublicMethodThatThrowsBuiltinException();
+ void invokeDeclaredPublicMethodThatThrowsBuiltinException();
- public void invokePrivateMethodThatThrowsBuiltinException();
+ void invokePrivateMethodThatThrowsBuiltinException();
- public void invokeProtectedMethodThatThrowsBuiltinException();
+ void invokeProtectedMethodThatThrowsBuiltinException();
- public void invokeUndeclaredPublicMethodThatThrowsBuiltinException();
+ void invokeUndeclaredPublicMethodThatThrowsBuiltinException();
- public abstract class TestTransientMixin
+ abstract class TestTransientMixin
implements TestTransient
{
public void declaredMethodThatThrowsCustomException()
@@ -209,14 +209,14 @@ public class QI256Test
public void invokeCustomExceptionThrowingMethod()
throws Throwable
{
- this.module.newTransient( TestTransient.class ).declaredMethodThatThrowsCustomException();
+ this.transientBuilderFactory.newTransient( TestTransient.class ).declaredMethodThatThrowsCustomException();
}
@Test( expected = TestException.class )
public void invokeDeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeDeclaredPublicMethodThatThrowsCustomException();
}
@@ -225,7 +225,7 @@ public class QI256Test
public void invokeUndeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeUndeclaredPublicMethodThatThrowsCustomException();
}
@@ -234,14 +234,14 @@ public class QI256Test
public void invokePrivateMethodWhichInvokesCustomExceptionThrowingMethod()
throws Throwable
{
- this.module.newTransient( TestTransient.class ).invokePrivateMethodThatThrowsCustomException();
+ this.transientBuilderFactory.newTransient( TestTransient.class ).invokePrivateMethodThatThrowsCustomException();
}
@Test( expected = TestException.class )
public void invokeProtectedMethodWhichInvokesCustomExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeProtectedMethodThatThrowsCustomException();
}
@@ -250,7 +250,7 @@ public class QI256Test
public void invokeBuiltinInheritedExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.declaredMethodThatThrowsBuiltinInheritedException();
}
@@ -259,7 +259,7 @@ public class QI256Test
public void invokeDeclaredPublicMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException();
}
@@ -268,7 +268,7 @@ public class QI256Test
public void invokeUndeclaredPublicMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException();
}
@@ -277,7 +277,7 @@ public class QI256Test
public void invokePrivateMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokePrivateMethodThatThrowsBuiltinInheritedException();
}
@@ -286,7 +286,7 @@ public class QI256Test
public void invokeProtectedMethodWhichInvokesBuiltinInheritedExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeProtectedMethodThatThrowsBuiltinInheritedException();
}
@@ -295,7 +295,7 @@ public class QI256Test
public void invokeBuiltinExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.declaredMethodThatThrowsBuiltinInheritedException();
}
@@ -304,7 +304,7 @@ public class QI256Test
public void invokeDeclaredPublicMethodWhichInvokesBuiltinExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeDeclaredPublicMethodThatThrowsBuiltinInheritedException();
}
@@ -313,7 +313,7 @@ public class QI256Test
public void invokeUndeclaredPublicMethodWhichInvokesBuiltinExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeUndeclaredPublicMethodThatThrowsBuiltinInheritedException();
}
@@ -322,7 +322,7 @@ public class QI256Test
public void invokePrivateMethodWhichInvokesBuiltinExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokePrivateMethodThatThrowsBuiltinInheritedException();
}
@@ -331,7 +331,7 @@ public class QI256Test
public void invokeProtectedMethodWhichInvokesBuiltinExceptionThrowingMethod()
throws Throwable
{
- this.module
+ this.transientBuilderFactory
.newTransient( TestTransient.class )
.invokeProtectedMethodThatThrowsBuiltinInheritedException();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
index 5d7839b..7c145ef 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
@@ -68,7 +68,7 @@ public class TransientAsClassTest
@Test
public void test()
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
assertThat( underTest.foo(), equalTo( "foo bar" ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
index d243c64..b65ee90 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
@@ -43,7 +43,7 @@ public class GenericConcernTest
public void testNestedUnitOfWork()
{
UnitOfWork uow = uowf.newUnitOfWork();
- Some some = module.newTransient( Some.class );
+ Some some = transientBuilderFactory.newTransient( Some.class );
some.doStuff();
uow.discard();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/concerns/ModuleConcernTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/ModuleConcernTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/ModuleConcernTest.java
index 97fa16d..b17596d 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/ModuleConcernTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/ModuleConcernTest.java
@@ -57,7 +57,7 @@ public class ModuleConcernTest
@Test
public void testModuleConcerns()
{
- module.newTransient( Foo.class ).test( "Foo", 42 );
+ transientBuilderFactory.newTransient( Foo.class ).test( "Foo", 42 );
assertThat( "Concern has executed", ok, equalTo( true ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/constraints/ConstraintsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/constraints/ConstraintsTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/constraints/ConstraintsTest.java
index 3aeeb95..83eace3 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/constraints/ConstraintsTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/constraints/ConstraintsTest.java
@@ -53,7 +53,7 @@ public class ConstraintsTest
public void givenCompositeWithConstraintsWhenInstantiatedThenUseDeclarationOnComposite()
throws Throwable
{
- MyOne my = module.newTransient( MyOneComposite.class );
+ MyOne my = transientBuilderFactory.newTransient( MyOneComposite.class );
ArrayList<String> list = new ArrayList<String>();
list.add( "zout" );
my.doSomething( "habba", list );
@@ -74,7 +74,7 @@ public class ConstraintsTest
public void givenCompositeWithoutConstraintsWhenInstantiatedThenUseDeclarationOnConstraint()
throws Throwable
{
- MyOne my = module.newTransient( MyOneComposite2.class );
+ MyOne my = transientBuilderFactory.newTransient( MyOneComposite2.class );
ArrayList<String> list = new ArrayList<String>();
list.add( "zout" );
my.doSomething( "habba", list );
@@ -94,7 +94,7 @@ public class ConstraintsTest
@Test
public void givenConstrainedGenericWildcardParameterWhenInvokedThenUseConstraint()
{
- MyOne myOne = module.newTransient( MyOneComposite.class );
+ MyOne myOne = transientBuilderFactory.newTransient( MyOneComposite.class );
ArrayList<String> list = new ArrayList<String>();
list.add( "Foo" );
myOne.doSomething2( list );
@@ -103,7 +103,7 @@ public class ConstraintsTest
@Test
public void givenCompositeConstraintWhenInvokedThenUseAllConstraints()
{
- MyOne myOne = module.newTransient( MyOneComposite.class );
+ MyOne myOne = transientBuilderFactory.newTransient( MyOneComposite.class );
ArrayList<String> list = new ArrayList<String>();
list.add( "Foo" );
myOne.doSomething3( list );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/defaults/UseDefaultsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/defaults/UseDefaultsTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/defaults/UseDefaultsTest.java
index 2bce838..affc53d 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/defaults/UseDefaultsTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/defaults/UseDefaultsTest.java
@@ -44,7 +44,7 @@ public class UseDefaultsTest
@Test
public void givenPropertyWithUseDefaultsWhenInstantiatedThenPropertiesAreDefaulted()
{
- TransientBuilder<TestComposite> builder = module.newTransientBuilder( TestComposite.class );
+ TransientBuilder<TestComposite> builder = transientBuilderFactory.newTransientBuilder( TestComposite.class );
TestComposite testComposite = builder.newInstance();
assertThat( "nullInt is null", testComposite.nullInt().get(), nullValue() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/ActivatorInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ActivatorInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ActivatorInjectionTest.java
index 9af6dd1..9ed6f08 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ActivatorInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ActivatorInjectionTest.java
@@ -163,8 +163,8 @@ public class ActivatorInjectionTest
@Test
public void test()
{
- assertThat( module.findService( ServiceA.class ).get().what(), equalTo( "A" ) );
- assertThat( module.findService( ServiceB.class ).get().what(), equalTo( "B" ) );
+ assertThat( serviceFinder.findService( ServiceA.class ).get().what(), equalTo( "A" ) );
+ assertThat( serviceFinder.findService( ServiceB.class ).get().what(), equalTo( "B" ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
index fbf691e..76c47f4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
@@ -77,12 +77,12 @@ public class ServiceInjectionTest
assertEquals( "X", user.testSingle() );
assertEquals( "Foo", user.testIdentity() );
- assertEquals( "XX", user.testIterable() );
assertEquals( "FooX", user.testServiceReference() );
- assertEquals( "FooXBarX", user.testIterableServiceReferences() );
assertEquals( "Bar", user.testQualifier() );
assertEquals( "A", user.testStringIterable() );
assertEquals( new Long( 1L ), user.testLongIterable() );
+ assertEquals( "FooXBarX", user.testIterableServiceReferences() );
+ assertEquals( "XX", user.testIterable() );
}
@Test
@@ -192,12 +192,16 @@ public class ServiceInjectionTest
{
@Service
MyService service;
+
@Service
MyServiceComposite serviceComposite;
+
@Service
Iterable<MyService> services;
+
@Service
ServiceReference<MyService> serviceRef;
+
@Service
Iterable<ServiceReference<MyService>> serviceRefs;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateInjectionTest.java
index 2c654d7..30a3e10 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateInjectionTest.java
@@ -52,7 +52,7 @@ public class StateInjectionTest
throws Exception
{
TransientBuilder<PropertyFieldInjectionComposite> pficBuilder =
- module.newTransientBuilder( StateInjectionTest.PropertyFieldInjectionComposite.class );
+ transientBuilderFactory.newTransientBuilder( StateInjectionTest.PropertyFieldInjectionComposite.class );
pficBuilder.prototype().testField().set( "X" );
PropertyFieldInjectionComposite pfic = pficBuilder.newInstance();
assertThat( "Test field", pfic.testField().get(), is( equalTo( "X" ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateParameterInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateParameterInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateParameterInjectionTest.java
index b69b313..36afbf8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateParameterInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StateParameterInjectionTest.java
@@ -50,7 +50,7 @@ public class StateParameterInjectionTest
throws Exception
{
TransientBuilder<PropertyParameterInjectionComposite> pficBuilder =
- module.newTransientBuilder( PropertyParameterInjectionComposite.class );
+ transientBuilderFactory.newTransientBuilder( PropertyParameterInjectionComposite.class );
pficBuilder.prototype().testField().set( "X" );
pficBuilder.prototype().namedField().set( "Y" );
PropertyParameterInjectionComposite pfic = pficBuilder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/StructureInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StructureInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StructureInjectionTest.java
index 80cc85e..475818e 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/StructureInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/StructureInjectionTest.java
@@ -51,7 +51,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForCompositeBuilderFactory()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected CompositeBuilderFactory", sic.getCompositeBuilderFactory(), is( notNullValue() ) );
}
@@ -61,7 +61,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForObjectBuilderFactory()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected ObjectBuilderFactory", sic.getObjectFactory(), is( notNullValue() ) );
}
@@ -71,7 +71,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForUnitOfWorkFactory()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected UnitOfWorkFactory", sic.getUnitOfWorkFactory(), is( notNullValue() ) );
}
@@ -81,7 +81,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForServiceLocator()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected ServiceLocator", sic.getServiceLocator(), is( notNullValue() ) );
}
@@ -91,7 +91,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForModuleBinding()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected Module", sic.getModule(), is( notNullValue() ) );
}
@@ -101,7 +101,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForZest()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected Zest", sic.getZest(), is( notNullValue() ) );
}
@@ -111,7 +111,7 @@ public class StructureInjectionTest
@Test
public void injectedStructureForZestSpi()
{
- StructureInjectionComposite sic = module.newTransient( StructureInjectionComposite.class );
+ StructureInjectionComposite sic = transientBuilderFactory.newTransient( StructureInjectionComposite.class );
assertThat( "Injected ZestSPI", sic.getZestSpi(), is( notNullValue() ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/ThisInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ThisInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ThisInjectionTest.java
index 7d071fd..6638de5 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ThisInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ThisInjectionTest.java
@@ -54,7 +54,7 @@ public class ThisInjectionTest
public void givenCompositeWithThisInjectionsWhenInstantiatedThenCompositeIsInjected()
throws Exception
{
- TestComposite testComposite = module.newTransient( TestComposite.class );
+ TestComposite testComposite = transientBuilderFactory.newTransient( TestComposite.class );
assertThat( "Injection worked", testComposite.isInjected() && sideEffectInjected, is( equalTo( true ) ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericClassTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericClassTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericClassTest.java
index fe37567..0fdb0e9 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericClassTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericClassTest.java
@@ -40,7 +40,7 @@ public class UsesGenericClassTest
@Test
public void givenMixinUsesGenericClassWhenUseClassThenInjectWorks()
{
- TransientBuilder<TestCase> builder = module.newTransientBuilder( TestCase.class );
+ TransientBuilder<TestCase> builder = transientBuilderFactory.newTransientBuilder( TestCase.class );
builder.use( UsesGenericClassTest.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericListTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericListTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericListTest.java
index bf69ba0..364bb62 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericListTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGenericListTest.java
@@ -44,7 +44,7 @@ public class UsesGenericListTest
@Test
public void givenMixinUsesGenericListWhenUseListThenInjectWorks()
{
- TransientBuilder<TestCase> builder = module.newTransientBuilder( TestCase.class );
+ TransientBuilder<TestCase> builder = transientBuilderFactory.newTransientBuilder( TestCase.class );
ArrayList<String> list = new ArrayList<String>();
list.add( "Hello" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGraphTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGraphTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGraphTest.java
index 129f399..d354f6a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGraphTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesGraphTest.java
@@ -40,7 +40,7 @@ public class UsesGraphTest
public void givenGraphDependenciesWhenInstantiateAThenGetSameReferences()
{
D d = new D();
- A a = module.newObject( A.class, module.newObject( C.class, d ), d );
+ A a = objectFactory.newObject( A.class, objectFactory.newObject( C.class, d ), d );
Assert.assertThat( "Same reference expected", a.c, equalTo( a.b.c ) );
Assert.assertThat( "Same reference expected", a.d, equalTo( a.b.c.d ) );
@@ -49,7 +49,7 @@ public class UsesGraphTest
@Test
public void givenGraphDependenciesWhenInstantiateUsingBuildersThenDontGetSameReferences()
{
- A a = module.newObject( A.class );
+ A a = objectFactory.newObject( A.class );
Assert.assertThat( "Same reference not expected", a.c, not( equalTo( a.b.c ) ) );
Assert.assertThat( "Same reference not expected", a.d, not( equalTo( a.b.c.d ) ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesInjectionTest.java
index 19666b5..30837ed 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UsesInjectionTest.java
@@ -42,9 +42,9 @@ public class UsesInjectionTest
throws Exception
{
ToBeInjected toBeInjected = new ToBeInjected();
- assertThat( "Injected object", module.newObject( InjectionTarget.class, toBeInjected, true )
+ assertThat( "Injected object", objectFactory.newObject( InjectionTarget.class, toBeInjected, true )
.getUsedObject(), is( equalTo( toBeInjected ) ) );
- assertThat( "Injected boolean", module.newObject( InjectionTarget.class, toBeInjected, true )
+ assertThat( "Injected boolean", objectFactory.newObject( InjectionTarget.class, toBeInjected, true )
.isUsedBoolean(), is( equalTo( true ) ) );
}
@@ -52,14 +52,14 @@ public class UsesInjectionTest
public void givenUsedObjectBuilderWhenUseWithBuilderThenInjectNewInstance()
throws Exception
{
- assertThat( "Injected object", module.newObject( InjectionTarget.class, module.newObject( ToBeInjected.class ), true ), is( notNullValue() ) );
+ assertThat( "Injected object", objectFactory.newObject( InjectionTarget.class, objectFactory.newObject( ToBeInjected.class ), true ), is( notNullValue() ) );
}
@Test
public void givenNoUsesWhenBuilderNewInstanceThenInjectNewInstance()
throws Exception
{
- assertThat( "Injected object", module.newObject( InjectionTarget.class, true ), is( notNullValue() ) );
+ assertThat( "Injected object", objectFactory.newObject( InjectionTarget.class, true ), is( notNullValue() ) );
}
public static class InjectionTarget
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ServiceInstantiationTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ServiceInstantiationTests.java b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ServiceInstantiationTests.java
index c34e1cd..bed3111 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ServiceInstantiationTests.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ServiceInstantiationTests.java
@@ -46,7 +46,7 @@ public class ServiceInstantiationTests
public void whenCreatingServiceCompositeGivenAServiceCompositeThenSucceed()
throws Exception
{
- ServiceReference<My> service = module.findService( My.class );
+ ServiceReference<My> service = serviceFinder.findService( My.class );
Assert.assertEquals( "HabbaZout", service.get().doSomething() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
index bea66f9..7941baa 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
@@ -39,7 +39,7 @@ public class TransientInstantiationTests
public void whenCreatingServiceCompositeGivenAServiceCompositeThenSucceed()
throws Exception
{
- TransientBuilder<My> builder = module.newTransientBuilder( My.class );
+ TransientBuilder<My> builder = transientBuilderFactory.newTransientBuilder( My.class );
My my = builder.newInstance();
Assert.assertEquals( "Niclas", my.doSomething() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ValueInstantiationTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ValueInstantiationTests.java b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ValueInstantiationTests.java
index e2387b5..dc115a0 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ValueInstantiationTests.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/ValueInstantiationTests.java
@@ -46,7 +46,7 @@ public class ValueInstantiationTests
// valueBuilderFactory.newValueBuilder()
try
{
- module.newValueBuilder( null );
+ valueBuilderFactory.newValueBuilder( null );
fail( "NullArgumentException was expected." );
}
catch( NullArgumentException e )
@@ -57,7 +57,7 @@ public class ValueInstantiationTests
// valueBuilderFactory.newValue();
try
{
- module.newValue( null );
+ valueBuilderFactory.newValue( null );
fail( "NullArgumentException was expected." );
}
catch( NullArgumentException e )
@@ -68,8 +68,8 @@ public class ValueInstantiationTests
//module.newValueFromSerializedState();
try
{
- module.newValueFromSerializedState( null, "abc:123" );
- ValueBuilder<My> builder = module.newValueBuilder( null );
+ valueBuilderFactory.newValueFromSerializedState( null, "abc:123" );
+ ValueBuilder<My> builder = valueBuilderFactory.newValueBuilder( null );
fail( "NullArgumentException was expected." );
}
catch( NullArgumentException e )
@@ -82,7 +82,7 @@ public class ValueInstantiationTests
public void whenCreatingServiceCompositeGivenAServiceCompositeThenSucceed()
throws Exception
{
- ValueBuilder<My> builder = module.newValueBuilder( My.class );
+ ValueBuilder<My> builder = valueBuilderFactory.newValueBuilder( My.class );
My my = builder.newInstance();
Assert.assertEquals( "Niclas", my.doSomething() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
index d3ec351..f63d0b8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
@@ -46,7 +46,7 @@ public class AssemblyMixinTest
@Test
public void testAssemblyMixins()
{
- assertThat( "Custom mixin has executed", module.newTransient( Foo.class )
+ assertThat( "Custom mixin has executed", transientBuilderFactory.newTransient( Foo.class )
.test( "Foo", 42 ), equalTo( "Foo/42" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
index 80efede..1d3e2bb 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
@@ -48,14 +48,14 @@ public class AssemblyRoleTest
@Test
public void testAssemblyTypesCustomMixin()
{
- FooComposite2 composite2 = module.newTransient( FooComposite2.class );
+ FooComposite2 composite2 = transientBuilderFactory.newTransient( FooComposite2.class );
assertThat( "Custom mixin has executed", ( (Foo) composite2 ).test( "Foo", 42 ), equalTo( "Foo/42" ) );
}
@Test
public void testAssemblyTypesDefaultMixin()
{
- FooComposite composite = module.newTransient( FooComposite.class );
+ FooComposite composite = transientBuilderFactory.newTransient( FooComposite.class );
assertThat( "Default mixin has executed", ( (Foo) composite ).test( "Foo", 42 ), equalTo( "Foo 42" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/InitializableTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/InitializableTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/InitializableTest.java
index df58cfe..36ed443 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/InitializableTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/InitializableTest.java
@@ -43,14 +43,14 @@ public class InitializableTest
@Test
public void givenCompositeWithInitializableMixinWhenInstantiatedThenInvokeInitialize()
{
- TestComposite instance = module.newTransient( TestComposite.class );
+ TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class );
assertThat( "mixin has been initialized", instance.ok(), equalTo( true ) );
}
@Test
public void givenObjectImplementingInitializableWhenInstantiatedThenInvokeInitialize()
{
- TestObject instance = module.newObject( TestObject.class );
+ TestObject instance = objectFactory.newObject( TestObject.class );
assertThat( "object has been initialized", instance.ok(), equalTo( true ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
index 66888eb..4808f8a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
@@ -134,7 +134,7 @@ public class JDKMixinTest
{
List<ServiceReference<JSONSerializableMap>> services = toList(
filter( EXTENDS_IDENTITY_SPEC,
- module.findServices( JSONSerializableMap.class ) ) );
+ serviceFinder.findServices( JSONSerializableMap.class ) ) );
assertThat( services.size(), equalTo( 1 ) );
assertThat( services.get( 0 ).identity(), equalTo( EXTENDS_IDENTITY ) );
@@ -154,7 +154,7 @@ public class JDKMixinTest
{
List<ServiceReference<JSONSerializableMap>> services = toList(
filter( COMPOSE_IDENTITY_SPEC,
- module.findServices( JSONSerializableMap.class ) ) );
+ serviceFinder.findServices( JSONSerializableMap.class ) ) );
assertThat( services.size(), equalTo( 1 ) );
assertThat( services.get( 0 ).identity(), equalTo( COMPOSE_IDENTITY ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MethodInterceptionMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MethodInterceptionMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MethodInterceptionMixinTest.java
index 63aad6e..86f50f9 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MethodInterceptionMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MethodInterceptionMixinTest.java
@@ -46,7 +46,7 @@ public class MethodInterceptionMixinTest
@Test
public void whenMixinCallsPublicMethodExpectInvocationStackToBeCalled()
{
- ServiceReference<SomeService> service = module.findService( SomeService.class );
+ ServiceReference<SomeService> service = serviceFinder.findService( SomeService.class );
Collection<String> result1 = service.get().result();
assertEquals( "Concern should have been called.", 1, result1.size() );
assertEquals( "Concern should have been called.", "Concern1", result1.iterator().next() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinPrecedenceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinPrecedenceTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinPrecedenceTest.java
index 609e14a..ef8157b 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinPrecedenceTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinPrecedenceTest.java
@@ -45,21 +45,21 @@ public class MixinPrecedenceTest
@Test
public void whenMultipleTypedMixinsPrecedence()
{
- TestComposite1 instance = module.newTransient( TestComposite1.class );
+ TestComposite1 instance = transientBuilderFactory.newTransient( TestComposite1.class );
assertThat( "Mixin precedence", instance.AMethod(), equalTo( "A1" ) );
}
@Test
public void whenGenericAndTypedMixinPrecedence()
{
- TestComposite2 instance = module.newTransient( TestComposite2.class );
+ TestComposite2 instance = transientBuilderFactory.newTransient( TestComposite2.class );
assertThat( "Typed mixin is chosen over generic mixin", instance.AMethod(), equalTo( "A1" ) );
}
@Test
public void whenMultipleGenericMixinsPrecedence()
{
- TestComposite3 instance = module.newTransient( TestComposite3.class );
+ TestComposite3 instance = transientBuilderFactory.newTransient( TestComposite3.class );
assertEquals( "GM1", instance.AMethod() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinsOnThisInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinsOnThisInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinsOnThisInjectionTest.java
index 8a77bca..5070f47 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinsOnThisInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/MixinsOnThisInjectionTest.java
@@ -39,7 +39,7 @@ public class MixinsOnThisInjectionTest
@Test
public void givenCompositeWithThisInjectionAndNoMixinDeclarationWhenBindingCompositeThenUseInterfaceDeclaredMixin()
{
- TestCase TestCase = module.newTransient( TestCase.class );
+ TestCase TestCase = transientBuilderFactory.newTransient( TestCase.class );
assertThat( "Composite can be instantiated", TestCase.sayHello(), equalTo( "Hello" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/PrivateMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/PrivateMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/PrivateMixinTest.java
index 98a24d5..b1b25a4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/PrivateMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/PrivateMixinTest.java
@@ -45,7 +45,7 @@ public class PrivateMixinTest
@Test
public void privateMixinFieldAndConstructorInjection()
{
- SpeakComposite test = module.newTransient( SpeakComposite.class );
+ SpeakComposite test = transientBuilderFactory.newTransient( SpeakComposite.class );
assertThat( "Speak", test.speak(), is( equalTo( "I say it works!" ) ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/mixin/Qi228Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/Qi228Test.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/Qi228Test.java
index 00fd3fc..7493f1a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/Qi228Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/Qi228Test.java
@@ -41,7 +41,7 @@ public class Qi228Test
public void test1()
throws Exception
{
- SomeLogic service = module.findService( SomeLogic.class ).get();
+ SomeLogic service = serviceFinder.findService( SomeLogic.class ).get();
try
{
service.getNumbers();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
index 1ec9207..bc88bd1 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
@@ -47,7 +47,7 @@ public final class ImmutablePropertyTest
private Location createLocation( String locationName )
{
- TransientBuilder<Location> locationBuilder = module.newTransientBuilder( Location.class );
+ TransientBuilder<Location> locationBuilder = transientBuilderFactory.newTransientBuilder( Location.class );
Location locState = locationBuilder.prototypeFor( Location.class );
locState.name().set( locationName );
return locationBuilder.newInstance();
@@ -62,7 +62,7 @@ public final class ImmutablePropertyTest
@Test
public final void testCreationWithStateOfComposite()
{
- TransientBuilder<Location> locationBuilder = module.newTransientBuilder( Location.class );
+ TransientBuilder<Location> locationBuilder = transientBuilderFactory.newTransientBuilder( Location.class );
Location locState = locationBuilder.prototype();
locState.name().set( KUALA_LUMPUR );
Location location = locationBuilder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
index 0daf7b8..6910ce1 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
@@ -19,6 +19,7 @@ package org.apache.zest.runtime.property;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
@@ -123,11 +124,11 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfTheSameTypeWhenTestingPropertyDescriptorEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue(valueBuilderFactory);
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" );
- Some other = buildSomeValue( module );
+ Some other = buildSomeValue( valueBuilderFactory );
ValueDescriptor otherDescriptor = zest.api().valueDescriptorFor( other );
PropertyDescriptor otherCharPropDesc = otherDescriptor.state().findPropertyModelByName( "characterProperty" );
@@ -142,11 +143,11 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfCommonTypesWhenTestingPropertyDescriptorEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" );
- PrimitivesValue primitive = buildPrimitivesValue( module );
+ PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory );
ValueDescriptor primitiveDescriptor = zest.api().valueDescriptorFor( primitive );
PropertyDescriptor primitiveCharPropDesc = primitiveDescriptor.state().findPropertyModelByName( "characterProperty" );
@@ -161,11 +162,11 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfDifferentTypesWhenTestingPropertyDescriptorEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" );
- Other other = buildOtherValue( module );
+ Other other = buildOtherValue( valueBuilderFactory );
ValueDescriptor otherDescriptor = zest.api().valueDescriptorFor( other );
PropertyDescriptor otherCharPropDesc = otherDescriptor.state().findPropertyModelByName( "characterProperty" );
@@ -183,10 +184,10 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingPropertyStateEqualityExpectEquals()
{
- PrimitivesValue primitives = buildPrimitivesValue( module );
- Some some = buildSomeValue( module );
- Some some2 = buildSomeValue( module );
- Other other = buildOtherValue( module );
+ PrimitivesValue primitives = buildPrimitivesValue( valueBuilderFactory );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some some2 = buildSomeValue( valueBuilderFactory );
+ Other other = buildOtherValue( valueBuilderFactory );
assertThat( "Property state equal",
'q',
allOf( equalTo( primitives.characterProperty().get() ),
@@ -207,8 +208,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfTheSameTypeAndSameStateWhenTestingPropertyEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
- Some some2 = buildSomeValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some some2 = buildSomeValue( valueBuilderFactory );
assertThat( "Property equals",
some.characterProperty(),
equalTo( some2.characterProperty() ) );
@@ -220,8 +221,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfTheSameTypeWithDifferentStateWhenTestingPropertyEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Some some2 = buildSomeValueWithDifferentState( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Some some2 = buildSomeValueWithDifferentState( valueBuilderFactory );
assertThat( "Property not equals",
some.characterProperty(),
not( equalTo( some2.characterProperty() ) ) );
@@ -233,8 +234,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfCommonTypesAndSameStateWhenTestingPropertyEqualityExpectEquals()
{
- Some some = buildSomeValue( module );
- PrimitivesValue primitive = buildPrimitivesValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory );
assertThat( "Property equal",
some.characterProperty(),
equalTo( primitive.characterProperty() ) );
@@ -243,8 +244,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfCommonTypesWithDifferentStateWhenTestingPropertyEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- PrimitivesValue primitive = buildPrimitivesValueWithDifferentState( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ PrimitivesValue primitive = buildPrimitivesValueWithDifferentState( valueBuilderFactory );
assertThat( "Property not equal",
some.characterProperty(),
not( equalTo( primitive.characterProperty() ) ) );
@@ -253,8 +254,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingPropertyEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Other other = buildOtherValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Other other = buildOtherValue( valueBuilderFactory );
assertThat( "Property not equal",
some.characterProperty(),
not( equalTo( other.characterProperty() ) ) );
@@ -263,8 +264,8 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfDifferentTypesWithDifferentStateWhenTestingPropertyEqualityExpectNotEquals()
{
- Some some = buildSomeValue( module );
- Other other = buildOtherValue( module );
+ Some some = buildSomeValue( valueBuilderFactory );
+ Other other = buildOtherValue( valueBuilderFactory );
assertThat( "Property not equal",
some.characterProperty(),
not( equalTo( other.characterProperty() ) ) );
@@ -273,11 +274,11 @@ public class PropertyEqualityTest
//
// -----------------------------------:: Values factory methods ::--------------------------------------------------
//
- public static PrimitivesValue buildPrimitivesValue( Module module )
+ public static PrimitivesValue buildPrimitivesValue( ValueBuilderFactory vbf )
{
PrimitivesValue primitive;
{
- ValueBuilder<PrimitivesValue> builder = module.newValueBuilder( PrimitivesValue.class );
+ ValueBuilder<PrimitivesValue> builder = vbf.newValueBuilder( PrimitivesValue.class );
builder.prototype().characterProperty().set( 'q' );
builder.prototype().stringProperty().set( "foo" );
builder.prototype().booleanProperty().set( true );
@@ -293,11 +294,11 @@ public class PropertyEqualityTest
return primitive;
}
- public static PrimitivesValue buildPrimitivesValueWithDifferentState( Module module )
+ public static PrimitivesValue buildPrimitivesValueWithDifferentState( ValueBuilderFactory vbf )
{
PrimitivesValue primitive;
{
- ValueBuilder<PrimitivesValue> builder = module.newValueBuilder( PrimitivesValue.class );
+ ValueBuilder<PrimitivesValue> builder = vbf.newValueBuilder( PrimitivesValue.class );
builder.prototype().characterProperty().set( 'i' );
builder.prototype().stringProperty().set( "bar" );
builder.prototype().booleanProperty().set( false );
@@ -313,11 +314,11 @@ public class PropertyEqualityTest
return primitive;
}
- public static Some buildSomeValue( Module module )
+ public static Some buildSomeValue(ValueBuilderFactory vbf)
{
Some some;
{
- ValueBuilder<Some> builder = module.newValueBuilder( Some.class );
+ ValueBuilder<Some> builder = vbf.newValueBuilder( Some.class );
builder.prototype().characterProperty().set( 'q' );
builder.prototype().stringProperty().set( "foo" );
builder.prototype().booleanProperty().set( true );
@@ -339,11 +340,11 @@ public class PropertyEqualityTest
return some;
}
- public static Some buildSomeValueWithDifferentState( Module module )
+ public static Some buildSomeValueWithDifferentState( ValueBuilderFactory vbf )
{
Some some;
{
- ValueBuilder<Some> builder = module.newValueBuilder( Some.class );
+ ValueBuilder<Some> builder = vbf.newValueBuilder( Some.class );
builder.prototype().characterProperty().set( 'i' );
builder.prototype().stringProperty().set( "bar" );
builder.prototype().booleanProperty().set( false );
@@ -365,11 +366,11 @@ public class PropertyEqualityTest
return some;
}
- public static AnotherSome buildAnotherSomeValue( Module module )
+ public static AnotherSome buildAnotherSomeValue( ValueBuilderFactory vbf )
{
AnotherSome anotherSome;
{
- ValueBuilder<AnotherSome> builder = module.newValueBuilder( AnotherSome.class );
+ ValueBuilder<AnotherSome> builder = vbf.newValueBuilder( AnotherSome.class );
builder.prototype().characterProperty().set( 'q' );
builder.prototype().stringProperty().set( "foo" );
builder.prototype().booleanProperty().set( true );
@@ -391,11 +392,11 @@ public class PropertyEqualityTest
return anotherSome;
}
- public static AnotherSome buildAnotherSomeValueWithDifferentState( Module module )
+ public static AnotherSome buildAnotherSomeValueWithDifferentState( ValueBuilderFactory vbf )
{
AnotherSome anotherSome;
{
- ValueBuilder<AnotherSome> builder = module.newValueBuilder( AnotherSome.class );
+ ValueBuilder<AnotherSome> builder = vbf.newValueBuilder( AnotherSome.class );
builder.prototype().characterProperty().set( 'i' );
builder.prototype().stringProperty().set( "bar" );
builder.prototype().booleanProperty().set( false );
@@ -417,11 +418,11 @@ public class PropertyEqualityTest
return anotherSome;
}
- public static Other buildOtherValue( Module module )
+ public static Other buildOtherValue( ValueBuilderFactory vbf )
{
Other other;
{
- ValueBuilder<Other> builder = module.newValueBuilder( Other.class );
+ ValueBuilder<Other> builder = vbf.newValueBuilder( Other.class );
builder.prototype().characterProperty().set( 'q' );
other = builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyStringArrayTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyStringArrayTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyStringArrayTest.java
index a2c65d0..6410311 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyStringArrayTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyStringArrayTest.java
@@ -43,7 +43,7 @@ public class PropertyStringArrayTest
{
TestComposite instance;
{
- TransientBuilder<TestComposite> builder = module.newTransientBuilder( TestComposite.class );
+ TransientBuilder<TestComposite> builder = transientBuilderFactory.newTransientBuilder( TestComposite.class );
builder.prototype().array().set( new String[]{ "Foo", "Bar" } );
instance = builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyTest.java
index 13ac188..be80bf4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyTest.java
@@ -59,7 +59,7 @@ public class PropertyTest
{
Company company;
{
- TransientBuilder<Company> builder = module.newTransientBuilder( Company.class );
+ TransientBuilder<Company> builder = transientBuilderFactory.newTransientBuilder( Company.class );
builder.prototype().name().set( "JayWay" );
company = builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
index 1f51610..e23af89 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
@@ -79,7 +79,7 @@ public class ValueNestedBuilderTest
@Test
public void testInner()
{
- ValueBuilder<InnerValue> innerBuilder = module.newValueBuilder( InnerValue.class );
+ ValueBuilder<InnerValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerValue.class );
InnerValue inner = innerBuilder.prototype();
inner.listProp().set( new ArrayList<String>() );
inner.mapProp().set( new HashMap<String, String>() );
@@ -90,12 +90,12 @@ public class ValueNestedBuilderTest
@Test
public void testOuter()
{
- ValueBuilder<InnerValue> innerBuilder = module.newValueBuilder( InnerValue.class );
+ ValueBuilder<InnerValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerValue.class );
InnerValue inner = innerBuilder.prototype();
inner.listProp().set( new ArrayList<String>() );
inner.mapProp().set( new HashMap<String, String>() );
inner = innerBuilder.newInstance();
- ValueBuilder<OuterValue> outerBuilder = module.newValueBuilder( OuterValue.class );
+ ValueBuilder<OuterValue> outerBuilder = valueBuilderFactory.newValueBuilder( OuterValue.class );
OuterValue outer = outerBuilder.prototype();
List<InnerValue> inners = new ArrayList<InnerValue>();
inners.add( inner );
@@ -108,7 +108,7 @@ public class ValueNestedBuilderTest
@Test
public void testDefaultedInner()
{
- ValueBuilder<InnerDefaultedValue> innerBuilder = module.newValueBuilder( InnerDefaultedValue.class );
+ ValueBuilder<InnerDefaultedValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerDefaultedValue.class );
InnerDefaultedValue inner = innerBuilder.newInstance();
// If we reach this point, value creation went well
}
@@ -116,9 +116,9 @@ public class ValueNestedBuilderTest
@Test
public void testDefaultedOuter()
{
- ValueBuilder<InnerDefaultedValue> innerBuilder = module.newValueBuilder( InnerDefaultedValue.class );
+ ValueBuilder<InnerDefaultedValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerDefaultedValue.class );
InnerDefaultedValue inner = innerBuilder.newInstance();
- ValueBuilder<OuterDefaultedValue> outerBuilder = module.newValueBuilder( OuterDefaultedValue.class );
+ ValueBuilder<OuterDefaultedValue> outerBuilder = valueBuilderFactory.newValueBuilder( OuterDefaultedValue.class );
OuterDefaultedValue outer = outerBuilder.prototype();
List<InnerDefaultedValue> inners = new ArrayList<InnerDefaultedValue>();
inners.add( inner );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
index 2e3b67b..e8fc34b 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
@@ -45,7 +45,7 @@ public class NonQueryableTest
UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
- QueryBuilder<Abc> builder = module.newQueryBuilder( Abc.class );
+ QueryBuilder<Abc> builder = queryBuilderFactory.newQueryBuilder( Abc.class );
Abc proto = templateFor( Abc.class );
builder.where( eq( proto.isValid(), Boolean.TRUE ) );
Assert.fail( "Exception was expected." );
@@ -66,7 +66,7 @@ public class NonQueryableTest
UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
- module.newQueryBuilder( Abc2.class );
+ queryBuilderFactory.newQueryBuilder( Abc2.class );
Assert.fail( "Exception was expected." );
}
catch( QueryException e )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/query/QueryBuilderFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/QueryBuilderFactoryImplTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/QueryBuilderFactoryImplTest.java
index f91b424..0a46ae9 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/QueryBuilderFactoryImplTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/QueryBuilderFactoryImplTest.java
@@ -56,7 +56,7 @@ public class QueryBuilderFactoryImplTest
throws Exception
{
super.setUp();
- composites = new ArrayList<TestComposite>();
+ composites = new ArrayList<>();
composites.add( newInstance( "A", 6 ) );
composites.add( newInstance( "B", 2 ) );
composites.add( newInstance( "C", 3 ) );
@@ -68,7 +68,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenFindEntityExpectFirstEntityReturned()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
assertEquals( "A", query.find().a().get() );
assertEquals( 6, query.count() );
}
@@ -76,7 +76,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenOrderByFirstPropertyExpectOrderedResult()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
TestComposite template = templateFor( TestComposite.class );
query.orderBy( orderBy( template.a() ) );
verifyOrder( query, "612345" );
@@ -85,7 +85,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenOrderBySecondPropertyExpectOrderedResult()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
TestComposite template = templateFor( TestComposite.class );
query.orderBy( orderBy( template.b() ) );
verifyOrder( query, "123456" );
@@ -94,7 +94,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenOrderByTwoPropertiesExpectOrderedResult()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
TestComposite template = templateFor( TestComposite.class );
query.orderBy( orderBy( template.a() ), orderBy( template.b() ) );
verifyOrder( query, "162345" );
@@ -103,7 +103,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenMaxedResultExpectLimitedResult()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
query.maxResults( 5 );
verifyOrder( query, "62345" );
}
@@ -111,7 +111,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenPlainQueryWhenFirstResultIsBeyondFirstElementExpectLimitedResult()
{
- Query<TestComposite> query = module.newQueryBuilder( TestComposite.class ).newQuery( composites );
+ Query<TestComposite> query = queryBuilderFactory.newQueryBuilder( TestComposite.class ).newQuery( composites );
query.firstResult( 2 );
verifyOrder( query, "3451" );
}
@@ -119,7 +119,7 @@ public class QueryBuilderFactoryImplTest
@Test
public void givenWhereQueryWhenWhereClauseLimitsToRangeExpectLimitedResult()
{
- final QueryBuilder<TestComposite> qb = module.newQueryBuilder( TestComposite.class );
+ final QueryBuilder<TestComposite> qb = queryBuilderFactory.newQueryBuilder( TestComposite.class );
TestComposite template = templateFor( TestComposite.class );
Query<TestComposite> query = qb.where(
and(
@@ -145,7 +145,7 @@ public class QueryBuilderFactoryImplTest
private TestComposite newInstance( String a, int b )
{
TransientBuilder<TestComposite> builder =
- module.newTransientBuilder( TestComposite.class );
+ transientBuilderFactory.newTransientBuilder( TestComposite.class );
TestComposite instance = builder.prototype();
instance.a().set( a );
instance.b().set( b );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/service/ComplexActivatableTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ComplexActivatableTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ComplexActivatableTest.java
index 3e9eb97..1ff3ee8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ComplexActivatableTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ComplexActivatableTest.java
@@ -43,7 +43,7 @@ public class ComplexActivatableTest
@Test
public void validateThatApplicationGotAssembled()
{
- ServiceReference<SuperType> reference = module.findService( SuperType.class );
+ ServiceReference<SuperType> reference = serviceFinder.findService( SuperType.class );
assertEquals( "Hello, World", reference.get().sayHello() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
index 577dc80..97780f6 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
@@ -56,8 +56,6 @@ public class ConfigurationTest
public void whenConfiguredThenSayHelloWorks()
throws Exception
{
- module.injectTo( this );
-
UnitOfWork unit = uowf.newUnitOfWork();
EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service
.identity() );
@@ -74,8 +72,6 @@ public class ConfigurationTest
public void whenUnconfiguredThenSayHelloGivesDefaults()
throws Exception
{
- module.injectTo( this );
-
assertThat( "result is correct", service.get().sayHello(), equalTo( "Hello World" ) );
}
@@ -83,8 +79,6 @@ public class ConfigurationTest
public void givenConfiguredServiceWhenReconfiguredAndRefreshedThenNewConfigurationIsUsed()
throws Exception
{
- module.injectTo( this );
-
HelloWorldConfiguration config;
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceFinderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceFinderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceFinderTest.java
index 55998b0..4f56ae4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceFinderTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceFinderTest.java
@@ -43,7 +43,7 @@ public class ServiceFinderTest extends AbstractZestTest
@Test
public void givenServiceCompileTimeWeavingWhenFindingServiceBySuperTypeExceptServiceToBeFound()
{
- ServiceReference<MyCompileTimeService> service = module.findService( MyCompileTimeService.class );
+ ServiceReference<MyCompileTimeService> service = serviceFinder.findService( MyCompileTimeService.class );
assertThat( service, notNullValue() );
assertThat( service.get(), notNullValue() );
assertThat( service.get().doSomething(), equalTo( "Niclas" ) );
@@ -52,7 +52,7 @@ public class ServiceFinderTest extends AbstractZestTest
@Test
public void givenServiceRuntimeWeavingWhenFindingServiceBySuperTypeExceptServiceToBeFound()
{
- ServiceReference<MyRuntimeService> service = module.findService( MyRuntimeService.class );
+ ServiceReference<MyRuntimeService> service = serviceFinder.findService( MyRuntimeService.class );
assertThat( service, notNullValue() );
assertThat( service.get(), notNullValue() );
assertThat( service.get().doSomething(), equalTo( "Niclas" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/GenericSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/GenericSideEffectTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/GenericSideEffectTest.java
index 2a8e97a..87d7c69 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/GenericSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/GenericSideEffectTest.java
@@ -49,7 +49,7 @@ public class GenericSideEffectTest
@Test
public void testGenericSideEffect()
{
- SomeComposite some = module.newTransient( SomeComposite.class );
+ SomeComposite some = transientBuilderFactory.newTransient( SomeComposite.class );
Property<Integer> count = some.count();
assertThat( "count is zero", count.get(), equalTo( 0 ) );
some.doStuff();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/ModuleSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/ModuleSideEffectTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/ModuleSideEffectTest.java
index e2246db..b97fd30 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/ModuleSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/ModuleSideEffectTest.java
@@ -43,7 +43,7 @@ public class ModuleSideEffectTest
@Test
public void testModuleSideEffect()
{
- module.newTransient( Foo.class ).test( "Foo", 42 );
+ transientBuilderFactory.newTransient( Foo.class ).test( "Foo", 42 );
Assert.assertThat( "SideEffect has been called", ok, CoreMatchers.equalTo( true ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/SpecificSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/SpecificSideEffectTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/SpecificSideEffectTest.java
index 6c909f3..7b021be 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/SpecificSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/sideeffects/SpecificSideEffectTest.java
@@ -46,7 +46,7 @@ public class SpecificSideEffectTest
@Test
public void specificSideEffect()
{
- SomeComposite some = module.newTransient( SomeComposite.class );
+ SomeComposite some = transientBuilderFactory.newTransient( SomeComposite.class );
Property<Integer> count = some.count();
assertThat( "count is zero", count.get(), equalTo( 0 ) );
some.doStuff();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/structure/CompositeDescriptorTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/structure/CompositeDescriptorTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/structure/CompositeDescriptorTest.java
index 4cc78cc..5e6e528 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/structure/CompositeDescriptorTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/structure/CompositeDescriptorTest.java
@@ -36,7 +36,7 @@ public class CompositeDescriptorTest
throws Throwable
{
// Test with Standard composite
- AddressComposite address = module.newTransient( AddressComposite.class );
+ AddressComposite address = transientBuilderFactory.newTransient( AddressComposite.class );
TransientDescriptor addressDescriptor = spi.transientDescriptorFor( address );
assertNotNull( addressDescriptor );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/structure/ModuleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/structure/ModuleTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/structure/ModuleTest.java
index 353f9b9..0a78e0f 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/structure/ModuleTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/structure/ModuleTest.java
@@ -104,7 +104,7 @@ public class ModuleTest
Application app = givenFixture1();
Module module = app.findModule( "Layer 1", "Module 1" ).newTransient( TestComposite1.class ).getModule();
- module.classLoader().loadClass( TestComposite2.class.getName() );
+ module.descriptor().classLoader().loadClass( TestComposite2.class.getName() );
}
@Mixins( TestMixin1.class )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/threaded/ContextCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/threaded/ContextCompositeTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/threaded/ContextCompositeTest.java
index 2869f45..fd2fed8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/threaded/ContextCompositeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/threaded/ContextCompositeTest.java
@@ -39,9 +39,9 @@ public class ContextCompositeTest
{
for( int i = 0; i < 5; i++ )
{
- TransientBuilder<MyCompositeContext> builder = module.newTransientBuilder( MyCompositeContext.class );
+ TransientBuilder<MyCompositeContext> builder = transientBuilderFactory.newTransientBuilder( MyCompositeContext.class );
builder.prototypeFor( MyData.class ).data().set( 0 );
- MyCompositeContext context = new CompositeContext<MyCompositeContext>( module, MyCompositeContext.class ).proxy();
+ MyCompositeContext context = new CompositeContext<>( module, MyCompositeContext.class ).proxy();
Worker w1;
Worker w2;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
index dfcab7c..a0c2715 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
@@ -77,7 +77,7 @@ public class NestedValueBuilderTest
@Test
public void testInner()
{
- ValueBuilder<InnerValue> innerBuilder = module.newValueBuilder( InnerValue.class );
+ ValueBuilder<InnerValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerValue.class );
InnerValue inner = innerBuilder.prototype();
inner.listProp().set( new ArrayList<String>() );
inner.mapProp().set( new HashMap<String, String>() );
@@ -106,12 +106,12 @@ public class NestedValueBuilderTest
@Test
public void testOuter()
{
- ValueBuilder<InnerValue> innerBuilder = module.newValueBuilder( InnerValue.class );
+ ValueBuilder<InnerValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerValue.class );
InnerValue innerPrototype = innerBuilder.prototype();
innerPrototype.listProp().set( new ArrayList<String>() );
innerPrototype.mapProp().set( new HashMap<String, String>() );
InnerValue innerInstance = innerBuilder.newInstance();
- ValueBuilder<OuterValue> outerBuilder = module.newValueBuilder( OuterValue.class );
+ ValueBuilder<OuterValue> outerBuilder = valueBuilderFactory.newValueBuilder( OuterValue.class );
OuterValue outerPrototype = outerBuilder.prototype();
List<InnerValue> inners = new ArrayList<InnerValue>();
inners.add( innerInstance );
@@ -133,7 +133,7 @@ public class NestedValueBuilderTest
@Test
public void testDefaultedInner()
{
- ValueBuilder<InnerDefaultedValue> innerBuilder = module.newValueBuilder( InnerDefaultedValue.class );
+ ValueBuilder<InnerDefaultedValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerDefaultedValue.class );
InnerDefaultedValue inner = innerBuilder.newInstance();
// If we reach this point, value creation went well
try
@@ -159,9 +159,9 @@ public class NestedValueBuilderTest
@Test
public void testDefaultedOuter()
{
- ValueBuilder<InnerDefaultedValue> innerBuilder = module.newValueBuilder( InnerDefaultedValue.class );
+ ValueBuilder<InnerDefaultedValue> innerBuilder = valueBuilderFactory.newValueBuilder( InnerDefaultedValue.class );
InnerDefaultedValue innerInstance = innerBuilder.newInstance();
- ValueBuilder<OuterDefaultedValue> outerBuilder = module.newValueBuilder( OuterDefaultedValue.class );
+ ValueBuilder<OuterDefaultedValue> outerBuilder = valueBuilderFactory.newValueBuilder( OuterDefaultedValue.class );
OuterDefaultedValue outerPrototype = outerBuilder.prototype();
List<InnerDefaultedValue> inners = new ArrayList<InnerDefaultedValue>();
inners.add( innerInstance );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
index 97de116..9174699 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
@@ -43,7 +43,7 @@ public class ValueCompositeBasicsTest
@Test
public void testEqualsForValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
builder.prototypeFor( SomeInternalState.class ).name().set( "Niclas" );
assertEquals("Niclas", builder.prototype().name());
SomeValue value1 = builder.newInstance();
@@ -57,7 +57,7 @@ public class ValueCompositeBasicsTest
@Test
public void testToStringForValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
builder.prototypeFor( SomeInternalState.class ).name().set( "Niclas" );
SomeValue underTest = builder.newInstance();
assertEquals( "{\"name\":\"Niclas\"}", underTest.toString() );
@@ -66,7 +66,7 @@ public class ValueCompositeBasicsTest
@Test
public void testToJSonForValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
builder.prototypeFor( SomeInternalState.class ).name().set( "Niclas" );
SomeValue underTest = builder.newInstance();
assertEquals( "{\"name\":\"Niclas\"}", underTest.toString() );
[14/34] zest-java git commit: Kent suggested that if multiple
Concerns/SideEffects of same type are found,
then remove the previous one and add the new one at the end.
Posted by ni...@apache.org.
Kent suggested that if multiple Concerns/SideEffects of same type are found, then remove the previous one and add the new one at the end.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/81561b09
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/81561b09
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/81561b09
Branch: refs/heads/develop
Commit: 81561b096a354b5b96b47f77e2d7e2f582a36dfe
Parents: a5be013
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Dec 16 15:22:36 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Dec 16 15:22:36 2015 +0800
----------------------------------------------------------------------
.../bootstrap/CompositeAssemblyImpl.java | 31 +++++++++-----------
1 file changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/81561b09/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
index c7308f7..f1842b1 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
@@ -590,7 +590,7 @@ public abstract class CompositeAssemblyImpl
concernClasses.forEach( concern -> {
if( helper.appliesTo( concern, method, types, mixinClass ) )
{
- addConcernIfNotExists( concernsFor, helper.getConcernModel( concern ) );
+ addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel( concern ) );
}
else
{
@@ -602,7 +602,7 @@ public abstract class CompositeAssemblyImpl
Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
{
- addConcernIfNotExists( concernsFor, helper.getConcernModel( concern ) );
+ addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel( concern ) );
}
}
catch( NoSuchMethodException e )
@@ -625,7 +625,7 @@ public abstract class CompositeAssemblyImpl
if( helper.appliesTo( concern, method, types, mixinClass ) )
{
ConcernModel concernModel = helper.getConcernModel( concern );
- addConcernIfNotExists( concernsFor, concernModel );
+ addConcernOrRepositionIfExists( concernsFor, concernModel );
}
}
}
@@ -641,12 +641,11 @@ public abstract class CompositeAssemblyImpl
}
}
- private void addConcernIfNotExists( List<ConcernModel> concernsFor, ConcernModel concernModel )
+ private void addConcernOrRepositionIfExists( List<ConcernModel> concernsFor, ConcernModel concernModel )
{
- if( !concernsFor.contains( concernModel ) )
- {
- concernsFor.add( concernModel );
- }
+ // This remove/add is to allow re-ordering of the concerns
+ concernsFor.remove( concernModel );
+ concernsFor.add( concernModel );
}
private SideEffectsModel sideEffectsFor( Method method,
@@ -659,7 +658,7 @@ public abstract class CompositeAssemblyImpl
SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
{
- addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+ addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
}
else
{
@@ -671,7 +670,7 @@ public abstract class CompositeAssemblyImpl
Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass ) )
{
- addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+ addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
}
}
catch( NoSuchMethodException e )
@@ -694,13 +693,12 @@ public abstract class CompositeAssemblyImpl
if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
{
SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
- addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+ addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
}
}
}
}
-
if( sideEffectsFor.isEmpty() )
{
return SideEffectsModel.EMPTY_SIDEEFFECTS;
@@ -711,12 +709,11 @@ public abstract class CompositeAssemblyImpl
}
}
- private void addSideEffectIfNotExists( List<SideEffectModel> sideEffectsFor, SideEffectModel sideEffectModel )
+ private void addSideEffectOrRepositionIfExists( List<SideEffectModel> sideEffectsFor, SideEffectModel sideEffectModel )
{
- if( !sideEffectsFor.contains( sideEffectModel ) )
- {
- sideEffectsFor.add( sideEffectModel );
- }
+ // This add/remove is to allow reording of SideEffects.
+ sideEffectsFor.remove( sideEffectModel );
+ sideEffectsFor.add( sideEffectModel );
}
@SuppressWarnings( "unchecked" )
[34/34] zest-java git commit: Disable a test for now. It was never
present in 'develop' before.
Posted by ni...@apache.org.
Disable a test for now. It was never present in 'develop' before.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/ffb8ad29
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/ffb8ad29
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/ffb8ad29
Branch: refs/heads/develop
Commit: ffb8ad294c92c39c9145ddea65f880a2e6bf4c49
Parents: 612f952
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Apr 14 13:04:22 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Apr 14 13:04:22 2016 +0800
----------------------------------------------------------------------
.../test/java/org/apache/zest/index/rdf/MultiLayeredTest.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/ffb8ad29/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
index cd8aeae..00ed4b5 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
@@ -26,8 +26,12 @@ import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.bootstrap.layered.ModuleAssembler;
import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
+import org.apache.zest.index.rdf.query.RdfQueryService;
+import org.apache.zest.spi.query.EntityFinder;
import org.apache.zest.test.indexing.layered.AbstractMultiLayeredIndexingTest;
+import org.junit.Ignore;
+@Ignore("Disabled until the new Query sturcture is in place, properly supporting multilayered applications.")
public class MultiLayeredTest extends AbstractMultiLayeredIndexingTest
{
public MultiLayeredTest()
[28/34] zest-java git commit: Fixed the Type resolution so that a
Foo field will not get a Foo as the injected type.
Posted by ni...@apache.org.
Fixed the Type resolution so that a Foo<Bar> field will not get a Foo<Blip> as the injected type.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/15f156d5
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/15f156d5
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/15f156d5
Branch: refs/heads/develop
Commit: 15f156d50f52a9f334ffdc81f045d93b241522f1
Parents: 9a5c94c
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 19:32:32 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 19:32:32 2016 +0800
----------------------------------------------------------------------
.../zest/api/service/ServiceReference.java | 7 ++++
.../runtime/activation/ActivationDelegate.java | 7 ++++
.../ImportedServiceReferenceInstance.java | 7 ++++
.../service/ServiceReferenceInstance.java | 8 ++++-
.../zest/runtime/structure/ModuleInstance.java | 35 ++++++++++----------
.../zest/runtime/structure/TypeLookupImpl.java | 24 ++++++--------
.../property/ValueNestedBuilderTest.java | 30 ++++++++---------
.../runtime/value/NestedValueBuilderTest.java | 2 ++
.../runtime/value/ValueCompositeBasicsTest.java | 2 ++
9 files changed, 73 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
index dd17618..3ed1cfd 100644
--- a/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
+++ b/core/api/src/main/java/org/apache/zest/api/service/ServiceReference.java
@@ -15,6 +15,7 @@
package org.apache.zest.api.service;
import org.apache.zest.api.activation.ActivationEventListenerRegistration;
+import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.structure.MetaInfoHolder;
import org.apache.zest.api.type.HasTypes;
@@ -44,4 +45,10 @@ public interface ServiceReference<T>
* @return TRUE if the service is available, otherwise return FALSE
*/
boolean isAvailable();
+
+ /** Returns the ServiceModel of the service referenced by this ServiceReference.
+ *
+ * @return
+ */
+ ModelDescriptor model();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
index b69d9a7..8363e18 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/activation/ActivationDelegate.java
@@ -24,6 +24,7 @@ import org.apache.zest.api.activation.ActivationEvent;
import org.apache.zest.api.activation.ActivationEventListener;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.PassivationException;
+import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.service.ServiceReference;
import static org.apache.zest.api.activation.ActivationEvent.EventType.ACTIVATED;
@@ -334,6 +335,12 @@ public final class ActivationDelegate
}
@Override
+ public ModelDescriptor model()
+ {
+ return reference.model();
+ }
+
+ @Override
public Stream<Class<?>> types()
{
return reference.types();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
index b77370a..a2da20c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
@@ -24,6 +24,7 @@ import org.apache.zest.api.activation.Activation;
import org.apache.zest.api.activation.ActivationEventListener;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.PassivationException;
+import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.service.ServiceImporterException;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.service.ServiceUnavailableException;
@@ -133,6 +134,12 @@ public final class ImportedServiceReferenceInstance<T>
}
}
+ @Override
+ public ModelDescriptor model()
+ {
+ return serviceModel;
+ }
+
public ModuleDescriptor module()
{
return module;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
index 97928c5..1abe3d5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
@@ -58,7 +58,7 @@ public final class ServiceReferenceInstance<T>
private final ActivationDelegate activation = new ActivationDelegate( this );
private boolean active = false;
- public ServiceReferenceInstance( ServiceModel serviceModel, ModuleDescriptor module )
+ ServiceReferenceInstance( ServiceModel serviceModel, ModuleDescriptor module )
{
this.module = module;
this.serviceModel = serviceModel;
@@ -102,6 +102,12 @@ public final class ServiceReferenceInstance<T>
return getInstance().isAvailable();
}
+ @Override
+ public ModelDescriptor model()
+ {
+ return serviceModel;
+ }
+
public ModuleDescriptor module()
{
return module;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
index a24e768..ce458c9 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.zest.api.activation.Activation;
@@ -370,20 +371,7 @@ public class ModuleInstance
{
throw new NoSuchServiceException( serviceType.getTypeName(), name() );
}
- ModuleInstance serviceLocation = (ModuleInstance) serviceModel.module().instance();
- try
- {
- //noinspection unchecked
- return serviceLocation.services
- .references()
- .filter( ref -> ref.hasType( serviceType ) )
- .map( ref -> (ServiceReference<T>) ref )
- .findAny().get();
- }
- catch( NoSuchElementException e )
- {
- throw new NoSuchServiceException( serviceType.getTypeName(), name() );
- }
+ return findServiceReferenceInstance( serviceModel );
}
@Override
@@ -402,14 +390,27 @@ public class ModuleInstance
}
//noinspection unchecked
return serviceModels.stream()
- .flatMap(
- model -> ( (ModuleInstance) model.module().instance() ).services.references()
- )
+ .map( this::findServiceReferenceInstance )
+ .filter( ref -> ref != null )
.filter( ref -> ref.hasType( serviceType ) )
.map( ref -> (ServiceReference<T>) ref )
.collect( Collectors.toList() );
}
+ private <T> ServiceReference<T> findServiceReferenceInstance( ModelDescriptor model )
+ {
+ ModuleInstance moduleInstanceOfModel = (ModuleInstance) model.module().instance();
+ Optional<ServiceReference<?>> candidate = moduleInstanceOfModel.services.references()
+ .filter( ref -> ref.model().equals( model ) )
+ .findAny();
+ if( candidate.isPresent() )
+ {
+ ServiceReference<?> serviceReference = candidate.get();
+ return (ServiceReference<T>) serviceReference;
+ }
+ return null;
+ }
+
// Implementation of Activation
@Override
@SuppressWarnings( "unchecked" )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
index 0d3c740..aba9b22 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
@@ -47,7 +47,7 @@ import static org.apache.zest.functional.Iterables.first;
/**
* Central place for Composite Type lookups.
*/
-public class TypeLookupImpl
+class TypeLookupImpl
implements TypeLookup
{
@@ -250,19 +250,15 @@ public class TypeLookupImpl
{
return servicesReferences.computeIfAbsent( type1, type ->
{
- List<ModelDescriptor> models =
- allServices().filter(
- new ExactTypeMatching<>( type ).or( new AssignableFromTypeMatching<>( type ) )
- )
- .distinct()
- .collect( Collectors.toList() );
-
- // TODO: Needed??
-// List<T> result = new ArrayList<>();
-// //noinspection unchecked
-// serviceRefs.forEach( descriptor -> result.add( (T) descriptor ) );
-
- return models;
+ // There is a requirement that "exact match" services must be returned before "assignable match"
+ // services, hence the dual streams instead of a OR filter.
+ return Stream.concat(
+ allServices()
+ .filter( new ExactTypeMatching<>( type ) ),
+ allServices()
+ .filter( new AssignableFromTypeMatching<>( type ) ) )
+ .distinct()
+ .collect( Collectors.toList() );
} );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
index e23af89..69dfe02 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/ValueNestedBuilderTest.java
@@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueBuilder;
@@ -25,23 +24,23 @@ import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+import org.junit.Test;
public class ValueNestedBuilderTest
- extends AbstractZestTest
+ extends AbstractZestTest
{
- static interface InnerValue
- extends ValueComposite
+ private interface InnerValue
+ extends ValueComposite
{
-
Property<List<String>> listProp();
Property<Map<String, String>> mapProp();
-
}
- static interface InnerDefaultedValue
- extends ValueComposite
+ private interface InnerDefaultedValue
+ extends ValueComposite
{
@UseDefaults
@@ -49,30 +48,28 @@ public class ValueNestedBuilderTest
@UseDefaults
Property<Map<String, String>> mapPropDefault();
-
}
- static interface OuterValue
- extends ValueComposite
+ private interface OuterValue
+ extends ValueComposite
{
Property<List<InnerValue>> innerListProp();
-
}
- static interface OuterDefaultedValue
- extends ValueComposite
+ private interface OuterDefaultedValue
+ extends ValueComposite
{
@UseDefaults
Property<List<InnerDefaultedValue>> innerListPropDefault();
-
}
@Override
public void assemble( ModuleAssembly module )
- throws AssemblyException
+ throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( InnerValue.class, InnerDefaultedValue.class, OuterValue.class, OuterDefaultedValue.class );
}
@@ -127,5 +124,4 @@ public class ValueNestedBuilderTest
System.out.println( outer.toString() );
// If we reach this point, value creation went well
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
index a0c2715..f20fa6e 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/NestedValueBuilderTest.java
@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.junit.Test;
import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.property.Property;
@@ -71,6 +72,7 @@ public class NestedValueBuilderTest
public void assemble( ModuleAssembly module )
throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( InnerValue.class, InnerDefaultedValue.class, OuterValue.class, OuterDefaultedValue.class );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/15f156d5/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
index 9174699..f5dabb5 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueCompositeBasicsTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.runtime.value;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.junit.Test;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
@@ -37,6 +38,7 @@ public class ValueCompositeBasicsTest
public void assemble( ModuleAssembly module )
throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( SomeValue.class );
}
[10/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
index 77baf16..0d0e6f1 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
@@ -16,6 +16,8 @@
package org.apache.zest.runtime.entity;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +45,7 @@ public class EntityVisibilityTest
private Energy4Java zest;
private Module module;
private Application app;
+ private UnitOfWorkFactory uowf;
@Before
public void setup()
@@ -76,6 +79,7 @@ public class EntityVisibilityTest
} );
app.activate();
module = app.findModule( "From Layer", "From" );
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -172,7 +176,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -190,7 +194,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -208,7 +212,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleModuleVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -226,7 +230,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -244,7 +248,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -262,7 +266,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -280,7 +284,7 @@ public class EntityVisibilityTest
@Test
public void givenFromEntityWhenAccessingBelowApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -298,7 +302,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -316,7 +320,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -334,7 +338,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -352,7 +356,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -370,7 +374,7 @@ public class EntityVisibilityTest
@Test( expected = EntityTypeNotFoundException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -655,6 +659,7 @@ public class EntityVisibilityTest
module.entities( ModuleApplicationVisible.class ).visibleIn( Visibility.application );
module.entities( ModuleLayerVisible.class ).visibleIn( Visibility.layer );
module.entities( ModuleModuleVisible.class ).visibleIn( Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -672,6 +677,7 @@ public class EntityVisibilityTest
module.entities( BelowModuleVisible.class ).visibleIn( Visibility.module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -687,6 +693,7 @@ public class EntityVisibilityTest
module.entities( AboveApplicationVisible.class ).visibleIn( Visibility.application );
module.entities( AboveLayerVisible.class ).visibleIn( Visibility.layer );
module.entities( AboveModuleVisible.class ).visibleIn( Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -701,6 +708,7 @@ public class EntityVisibilityTest
module.entities( BesideApplicationVisible.class ).visibleIn( Visibility.application );
module.entities( BesideLayerVisible.class ).visibleIn( Visibility.layer );
module.entities( BesideModuleVisible.class ).visibleIn( Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -756,12 +764,12 @@ public class EntityVisibilityTest
implements From
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void moduleApplicationVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
ModuleApplicationVisible entity = uow.newEntity( ModuleApplicationVisible.class );
@@ -778,7 +786,7 @@ public class EntityVisibilityTest
@Override
public void moduleLayerVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
ModuleLayerVisible entity = uow.newEntity( ModuleLayerVisible.class );
@@ -795,7 +803,7 @@ public class EntityVisibilityTest
@Override
public void moduleModuleVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
ModuleModuleVisible entity = uow.newEntity( ModuleModuleVisible.class );
@@ -812,7 +820,7 @@ public class EntityVisibilityTest
@Override
public void besideApplicationVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BesideApplicationVisible entity = uow.newEntity( BesideApplicationVisible.class );
@@ -829,7 +837,7 @@ public class EntityVisibilityTest
@Override
public void besideLayerVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BesideLayerVisible entity = uow.newEntity( BesideLayerVisible.class );
@@ -846,7 +854,7 @@ public class EntityVisibilityTest
@Override
public void besideModuleVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BesideModuleVisible entity = uow.newEntity( BesideModuleVisible.class );
@@ -863,7 +871,7 @@ public class EntityVisibilityTest
@Override
public void belowApplicationVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BelowApplicationVisible entity = uow.newEntity( BelowApplicationVisible.class );
@@ -880,7 +888,7 @@ public class EntityVisibilityTest
@Override
public void belowLayerVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BelowLayerVisible entity = uow.newEntity( BelowLayerVisible.class );
@@ -897,7 +905,7 @@ public class EntityVisibilityTest
@Override
public void belowModuleVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
BelowModuleVisible entity = uow.newEntity( BelowModuleVisible.class );
@@ -914,7 +922,7 @@ public class EntityVisibilityTest
@Override
public void aboveApplicationVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AboveApplicationVisible entity = uow.newEntity( AboveApplicationVisible.class );
@@ -931,7 +939,7 @@ public class EntityVisibilityTest
@Override
public void aboveLayerVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AboveLayerVisible entity = uow.newEntity( AboveLayerVisible.class );
@@ -948,7 +956,7 @@ public class EntityVisibilityTest
@Override
public void aboveModuleVisible()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AboveModuleVisible entity = uow.newEntity( AboveModuleVisible.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/LifecycleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/LifecycleTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/LifecycleTest.java
index 495bff8..e2b132c 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/LifecycleTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/LifecycleTest.java
@@ -51,7 +51,7 @@ public class LifecycleTest
public void whenEntityHasLifecycleWhenInstantiatedThenInvokeCreate()
throws UnitOfWorkCompletionException
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
@@ -70,7 +70,7 @@ public class LifecycleTest
public void whenEntityHasLifecycleWhenRemovedThenInvokeRemove()
throws UnitOfWorkCompletionException
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/AssociationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/AssociationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/AssociationTest.java
index a1627d7..8261004 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/AssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/AssociationTest.java
@@ -52,7 +52,7 @@ public class AssociationTest
@Test
public void testAssociation()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/ImmutableAssociationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/ImmutableAssociationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/ImmutableAssociationTest.java
index 3dd855b..ad64912 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/ImmutableAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/associations/ImmutableAssociationTest.java
@@ -44,7 +44,7 @@ public class ImmutableAssociationTest
public void givenEntityWithImmutableAssociationWhenBuildingThenNoException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
PersonEntity father = unitOfWork.newEntity( PersonEntity.class );
@@ -64,7 +64,7 @@ public class ImmutableAssociationTest
public void givenEntityWithImmutableAssociationWhenChangingValueThenThrowException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder( PersonEntity.class );
@@ -89,7 +89,7 @@ public class ImmutableAssociationTest
public void givenEntityWithImmutableManyAssociationWhenBuildingThenNoException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder( PersonEntity.class );
@@ -111,7 +111,7 @@ public class ImmutableAssociationTest
public void givenEntityWithImmutableManyAssociationWhenChangingValueThenThrowException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder( PersonEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
index 43ae9cb..be703e6 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
@@ -15,6 +15,7 @@
*/
package org.apache.zest.runtime.injection;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.common.UseDefaults;
@@ -49,6 +50,7 @@ public class ConstructorInjectionOfThisTest
throws AssemblyException
{
module.values( Does.class ).withMixins( DoesMixin.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
Module module = singletonAssembler.application().findModule( "Layer 1", "Module 1" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
index 7c3d2f0..93ba516 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
@@ -47,15 +47,15 @@ public class UnitOfWorkInjectionTest
throws Exception
{
Usecase usecase = UsecaseBuilder.newUsecase( "usecase1" );
- UnitOfWork uow = module.newUnitOfWork( usecase );
+ UnitOfWork uow = uowf.newUnitOfWork( usecase );
try
{
Trial trial = uow.newEntity( Trial.class, "123" );
trial.doSomething();
uow.complete();
- uow = module.newUnitOfWork( usecase );
+ uow = uowf.newUnitOfWork( usecase );
usecase = UsecaseBuilder.newUsecase( "usecase2" );
- UnitOfWork uow2 = module.newUnitOfWork( usecase );
+ UnitOfWork uow2 = uowf.newUnitOfWork( usecase );
trial = uow.get( trial );
trial.doSomething();
assertEquals( "123", ( (EntityComposite) trial ).identity().get() );
@@ -70,9 +70,9 @@ public class UnitOfWorkInjectionTest
{
try
{
- while( module.isUnitOfWorkActive() )
+ while( uowf.isUnitOfWorkActive() )
{
- uow = module.currentUnitOfWork();
+ uow = uowf.currentUnitOfWork();
uow.discard();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
index bbb0197..bea66f9 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/instantiation/TransientInstantiationTests.java
@@ -58,7 +58,6 @@ public class TransientInstantiationTests
public static class MyMixin
implements My
{
-
public String doSomething()
{
return "Niclas";
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
index d00f655..d3ec351 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
@@ -54,11 +54,11 @@ public class AssemblyMixinTest
public void testAssemblyMixinsEntity()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
FooEntity entity = uow.newEntity( FooEntity.class, "123" );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Foo foo = uow.get( Foo.class, "123" );
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
index f8fb6a2..80efede 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
@@ -63,11 +63,11 @@ public class AssemblyRoleTest
public void testAssemblyMixinsEntity()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
- FooEntity entity = uow.newEntity( FooEntity.class, "123" );
+ UnitOfWork uow = uowf.newUnitOfWork();
+ uow.newEntity( FooEntity.class, "123" );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Foo foo = uow.get( Foo.class, "123" );
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
index 22a733b..dcaa0c8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
@@ -16,6 +16,8 @@
package org.apache.zest.runtime.objects;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -42,6 +44,7 @@ public class ObjectVisibilityTest
private Energy4Java zest;
private Module module;
+ private UnitOfWorkFactory uowf;
private Application app;
@Before
@@ -76,6 +79,7 @@ public class ObjectVisibilityTest
} );
app.activate();
module = app.findModule( "From Layer", "From" );
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -172,7 +176,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -190,7 +194,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -208,7 +212,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleModuleVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -226,7 +230,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -244,7 +248,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -262,7 +266,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -280,7 +284,7 @@ public class ObjectVisibilityTest
@Test
public void givenFromEntityWhenAccessingBelowApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -298,7 +302,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -316,7 +320,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -334,7 +338,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -352,7 +356,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -370,7 +374,7 @@ public class ObjectVisibilityTest
@Test( expected = NoSuchObjectException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -655,6 +659,8 @@ public class ObjectVisibilityTest
module.objects( ModuleApplicationVisible.class ).visibleIn( Visibility.application );
module.objects( ModuleLayerVisible.class ).visibleIn( Visibility.layer );
module.objects( ModuleModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -672,6 +678,7 @@ public class ObjectVisibilityTest
module.objects( BelowModuleVisible.class ).visibleIn( Visibility.module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -687,6 +694,8 @@ public class ObjectVisibilityTest
module.objects( AboveApplicationVisible.class ).visibleIn( Visibility.application );
module.objects( AboveLayerVisible.class ).visibleIn( Visibility.layer );
module.objects( AboveModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -701,6 +710,8 @@ public class ObjectVisibilityTest
module.objects( BesideApplicationVisible.class ).visibleIn( Visibility.application );
module.objects( BesideLayerVisible.class ).visibleIn( Visibility.layer );
module.objects( BesideModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
index caed693..1ec9207 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/ImmutablePropertyTest.java
@@ -83,7 +83,7 @@ public final class ImmutablePropertyTest
@Test
public final void testImmutableEntityProperty()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<LocationEntity> builder = uow.newEntityBuilder( LocationEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
index f8737cc..726c14a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
@@ -20,6 +20,7 @@ package org.apache.zest.runtime.query;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -89,12 +90,13 @@ public class IterableQuerySourceTest
module.values( ContactsValue.class, ContactValue.class );
new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
- uow = assembler.module().newUnitOfWork();
+ uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
Network.populate( uow, assembler.module() );
uow.complete();
- uow = assembler.module().newUnitOfWork();
+ uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
Network.refresh( uow );
qbf = assembler.module();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
index b876242..2e3b67b 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/NonQueryableTest.java
@@ -42,7 +42,7 @@ public class NonQueryableTest
@Test
public void whenQuerableIsFalseOnPropertyThenExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
QueryBuilder<Abc> builder = module.newQueryBuilder( Abc.class );
@@ -63,7 +63,7 @@ public class NonQueryableTest
@Test
public void testQueryIterable()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
module.newQueryBuilder( Abc2.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/service/AvailableServiceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/AvailableServiceTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/AvailableServiceTest.java
index 47d4e0f..0e14d4a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/AvailableServiceTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/AvailableServiceTest.java
@@ -14,6 +14,7 @@
package org.apache.zest.runtime.service;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.common.Optional;
@@ -50,6 +51,7 @@ public class AvailableServiceTest
throws AssemblyException
{
module.services( TestServiceComposite1.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
@@ -72,6 +74,7 @@ public class AvailableServiceTest
module.entities( TestServiceConfiguration.class );
new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
@@ -100,6 +103,7 @@ public class AvailableServiceTest
module.entities( TestServiceConfiguration.class );
new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
index e5b947b..577dc80 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java
@@ -58,7 +58,7 @@ public class ConfigurationTest
{
module.injectTo( this );
- UnitOfWork unit = module.newUnitOfWork();
+ UnitOfWork unit = uowf.newUnitOfWork();
EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service
.identity() );
HelloWorldConfiguration config = entityBuilder.instance();
@@ -88,7 +88,7 @@ public class ConfigurationTest
HelloWorldConfiguration config;
{
- UnitOfWork unit = module.newUnitOfWork();
+ UnitOfWork unit = uowf.newUnitOfWork();
EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service
.identity() );
config = entityBuilder.instance();
@@ -101,7 +101,7 @@ public class ConfigurationTest
assertThat( "result is correct", service.get().sayHello(), equalTo( "Hello World" ) );
{
- UnitOfWork unit = module.newUnitOfWork();
+ UnitOfWork unit = uowf.newUnitOfWork();
config = unit.get( config );
config.phrase().set( "Hey" );
config.name().set( "Universe" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java
index e1d9ae6..92edd73 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java
@@ -16,6 +16,8 @@
package org.apache.zest.runtime.service;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -42,6 +44,7 @@ public class ServiceVisibilityTest
private Energy4Java zest;
private Module module;
private Application app;
+ private UnitOfWorkFactory uowf;
@Before
public void setup()
@@ -75,6 +78,7 @@ public class ServiceVisibilityTest
} );
app.activate();
module = app.findModule( "From Layer", "From" );
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -171,7 +175,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -189,7 +193,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -207,7 +211,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleModuleVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -225,7 +229,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -243,7 +247,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -261,7 +265,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -279,7 +283,7 @@ public class ServiceVisibilityTest
@Test
public void givenFromEntityWhenAccessingBelowApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -297,7 +301,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -315,7 +319,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -333,7 +337,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -351,7 +355,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -369,7 +373,7 @@ public class ServiceVisibilityTest
@Test( expected = NoSuchServiceException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -654,6 +658,8 @@ public class ServiceVisibilityTest
module.services( ModuleApplicationVisible.class ).visibleIn( Visibility.application );
module.services( ModuleLayerVisible.class ).visibleIn( Visibility.layer );
module.services( ModuleModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -671,6 +677,7 @@ public class ServiceVisibilityTest
module.services( BelowModuleVisible.class ).visibleIn( Visibility.module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -686,6 +693,7 @@ public class ServiceVisibilityTest
module.services( AboveApplicationVisible.class ).visibleIn( Visibility.application );
module.services( AboveLayerVisible.class ).visibleIn( Visibility.layer );
module.services( AboveModuleVisible.class ).visibleIn( Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -700,6 +708,7 @@ public class ServiceVisibilityTest
module.services( BesideApplicationVisible.class ).visibleIn( Visibility.application );
module.services( BesideLayerVisible.class ).visibleIn( Visibility.layer );
module.services( BesideModuleVisible.class ).visibleIn( Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java
index 520b528..d516ede 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java
@@ -14,6 +14,8 @@
package org.apache.zest.runtime.structure;
import java.util.Iterator;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.composite.AmbiguousTypeException;
@@ -96,6 +98,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.objects( SomeOtherFooImpl.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -117,6 +120,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.objects( SomeOtherFooImpl.class, BasicFooImpl.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -146,6 +150,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.transients( SomeOtherFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -167,6 +172,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.transients( SomeOtherFoo.class, BasicFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -196,6 +202,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.values( SomeOtherFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -217,6 +224,7 @@ public class TypeToCompositeLookupTest
throws AssemblyException
{
module.values( SomeOtherFoo.class, BasicFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}.module();
@@ -238,7 +246,7 @@ public class TypeToCompositeLookupTest
public void entities()
throws UnitOfWorkCompletionException, ActivationException, AssemblyException
{
- Module module = new SingletonAssembler()
+ UnitOfWorkFactory uowf = new SingletonAssembler()
{
@Override
@@ -247,11 +255,12 @@ public class TypeToCompositeLookupTest
{
new EntityTestAssembler().assemble( module );
module.entities( SomeOtherFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
- }.module();
+ }.module().unitOfWorkFactory();
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
SomeOtherFoo someOtherFoo = uow.newEntityBuilder( SomeOtherFoo.class ).newInstance();
BasicFoo basicFoo = uow.newEntityBuilder( BasicFoo.class ).newInstance();
@@ -267,7 +276,7 @@ public class TypeToCompositeLookupTest
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
uow.get( SomeOtherFoo.class, someOtherFooIdentity );
uow.get( BasicFoo.class, basicFooIdentity );
@@ -280,7 +289,7 @@ public class TypeToCompositeLookupTest
public void entitiesAmbiguousDeclaration()
throws UnitOfWorkCompletionException, ActivationException, AssemblyException
{
- Module module = new SingletonAssembler()
+ UnitOfWorkFactory uowf = new SingletonAssembler()
{
@Override
@@ -289,11 +298,12 @@ public class TypeToCompositeLookupTest
{
new EntityTestAssembler().assemble( module );
module.entities( SomeOtherFoo.class, BasicFoo.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
- }.module();
+ }.module().unitOfWorkFactory();
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
SomeOtherFoo someOtherFoo = uow.newEntityBuilder( SomeOtherFoo.class ).newInstance();
BasicFoo basicFoo = uow.newEntityBuilder( BasicFoo.class ).newInstance();
@@ -317,7 +327,7 @@ public class TypeToCompositeLookupTest
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
assertEquals( CATHEDRAL, uow.get( SomeOtherFoo.class, someOtherFooIdentity ).bar() );
assertEquals( BAZAR, uow.get( BasicFoo.class, basicFooIdentity ).bar() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java
index 798830c..ad27219 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java
@@ -16,9 +16,6 @@
package org.apache.zest.runtime.transients;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.NoSuchTransientException;
import org.apache.zest.api.composite.TransientBuilder;
@@ -30,19 +27,25 @@ import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.bootstrap.ApplicationAssemblerAdapter;
import org.apache.zest.bootstrap.Assembler;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.test.EntityTestAssembler;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class TransientVisibilityTest
{
private Energy4Java zest;
private Module module;
private Application app;
+ private UnitOfWorkFactory uowf;
@Before
public void setup()
@@ -60,7 +63,7 @@ public class TransientVisibilityTest
{ // Layer From
{ // From Module
new FromAssembler(),
- },
+ },
{ // Beside Module
new BesideAssembler()
}
@@ -76,6 +79,7 @@ public class TransientVisibilityTest
} );
app.activate();
module = app.findModule( "From Layer", "From" );
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -172,7 +176,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -190,7 +194,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -208,7 +212,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleModuleVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -226,7 +230,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -244,7 +248,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -262,7 +266,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -280,7 +284,7 @@ public class TransientVisibilityTest
@Test
public void givenFromEntityWhenAccessingBelowApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -298,7 +302,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -316,7 +320,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -334,7 +338,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -352,7 +356,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -370,7 +374,7 @@ public class TransientVisibilityTest
@Test( expected = NoSuchTransientException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -655,6 +659,8 @@ public class TransientVisibilityTest
module.transients( ModuleApplicationVisible.class ).visibleIn( Visibility.application );
module.transients( ModuleLayerVisible.class ).visibleIn( Visibility.layer );
module.transients( ModuleModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -672,6 +678,8 @@ public class TransientVisibilityTest
module.transients( BelowModuleVisible.class ).visibleIn( Visibility.module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -687,6 +695,8 @@ public class TransientVisibilityTest
module.transients( AboveApplicationVisible.class ).visibleIn( Visibility.application );
module.transients( AboveLayerVisible.class ).visibleIn( Visibility.layer );
module.transients( AboveModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -701,6 +711,8 @@ public class TransientVisibilityTest
module.transients( BesideApplicationVisible.class ).visibleIn( Visibility.application );
module.transients( BesideLayerVisible.class ).visibleIn( Visibility.layer );
module.transients( BesideModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/AutoCloseableUoWTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/AutoCloseableUoWTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/AutoCloseableUoWTest.java
index 82439f3..a489767 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/AutoCloseableUoWTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/AutoCloseableUoWTest.java
@@ -54,7 +54,7 @@ public class AutoCloseableUoWTest
public void givenGoodAutoCloseableUoWWhenTryWithResourceExpectSuccess()
throws UnitOfWorkCompletionException
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class );
builder.instance().mandatory().set( "Mandatory property" );
@@ -67,7 +67,7 @@ public class AutoCloseableUoWTest
public void givenWrongAutoCloseableUoWWhenTryWithResourceExpectSuccess()
throws UnitOfWorkCompletionException
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
uow.newEntity( TestEntity.class );
uow.complete();
@@ -77,7 +77,7 @@ public class AutoCloseableUoWTest
@After
public void afterEachTest()
{
- assertThat( module.isUnitOfWorkActive(), is( false ) );
+ assertThat( uowf.isUnitOfWorkActive(), is( false ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
index 86e2fba..1d81f68 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
@@ -14,7 +14,6 @@
package org.apache.zest.runtime.unitofwork;
-import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.entity.EntityBuilder;
@@ -31,17 +30,14 @@ import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
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.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.test.EntityTestAssembler;
+import org.junit.Test;
-import static org.junit.Assert.fail;
import static org.apache.zest.api.common.Visibility.application;
+import static org.junit.Assert.fail;
/**
* JAVADOC
@@ -58,42 +54,29 @@ public class PrivateEntityUnitOfWorkTest
System.setProperty( "zest.compacttrace", "off" );
Energy4Java is = new Energy4Java();
- Application app = is.newApplication( new ApplicationAssembler()
- {
- public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
- {
- return applicationFactory.newApplicationAssembly( new Assembler[][][]{
+ Application app = is.newApplication(
+ applicationFactory ->
+ applicationFactory.newApplicationAssembly( new Assembler[][][]{
{
{
- new Assembler()
- {
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.objects( PrivateEntityUnitOfWorkTest.class );
- }
+ module -> {
+ module.objects( PrivateEntityUnitOfWorkTest.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
},
{
{
- new Assembler()
- {
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( ProductEntity.class );
- module.entities( ProductCatalogEntity.class ).visibleIn( application );
- module.values( ProductInfo.class );
- new EntityTestAssembler().assemble( module );
- }
+ module -> {
+ module.entities( ProductEntity.class );
+ module.entities( ProductCatalogEntity.class ).visibleIn( application );
+ module.values( ProductInfo.class );
+ new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
}
- } );
- }
- } );
+ } ) );
app.activate();
Module module = app.findModule( "Layer 1", "Module 1" );
@@ -126,7 +109,7 @@ public class PrivateEntityUnitOfWorkTest
unitOfWork.discard();
}
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
try
{
ProductCatalog catalog = unitOfWork.get( ProductCatalog.class, "1" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java
index d80267c..2cfaabc 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java
@@ -46,14 +46,14 @@ public class RemovalTest
public void givenUnitOfWorkHasBeenCreateWhenCreatingNewEntityThenFindNewEntityWithGet()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" );
builder.instance().name().set( "Niclas" );
builder.newInstance();
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Abc abc = uow.get( Abc.class, "123" );
assertEquals( "Niclas", abc.name().get() );
}
@@ -67,19 +67,19 @@ public class RemovalTest
public void givenEntityCreatedWhenRemovingEntityThenFindNewEntityShouldNotExist()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" );
builder.instance().name().set( "Niclas" );
builder.newInstance();
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Abc abc = uow.get( Abc.class, "123" );
assertEquals( "Niclas", abc.name().get() );
uow.remove( abc );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
uow.get( Abc.class, "123" );
fail( "This '123' entity should not exist." );
}
@@ -97,18 +97,18 @@ public class RemovalTest
public void givenDetachedEntityWhenRemovingEntityThenFindNewEntityShouldNotExist()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" );
builder.instance().name().set( "Niclas" );
Abc abc = builder.newInstance();
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
abc = uow.get( abc ); // Attach the detached entity to 'uow' session.
uow.remove( abc );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
uow.get( Abc.class, "123" );
fail( "This '123' entity should not exist." );
}
@@ -126,7 +126,7 @@ public class RemovalTest
public void givenEntityCreatedWhenRemovingEntityBeforeCompletingUowThenFindNewEntityShouldNotExist()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" );
@@ -134,7 +134,7 @@ public class RemovalTest
Abc abc = builder.newInstance();
uow.remove( abc );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
uow.get( Abc.class, "123" );
fail( "This '123' entity should not exist." );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryTest.java
index e084471..efd32bb 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryTest.java
@@ -50,7 +50,7 @@ public class UnitOfWorkFactoryTest
public void testUnitOfWork()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
// Create product
EntityBuilder<ProductEntity> cb = unitOfWork.newEntityBuilder( ProductEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueComposite2Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueComposite2Test.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueComposite2Test.java
index 70c28d4..79f8151 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueComposite2Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueComposite2Test.java
@@ -18,6 +18,7 @@
package org.apache.zest.runtime.value;
import java.security.Guard;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Assert;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -47,6 +48,7 @@ public class ValueComposite2Test
{
module.values( SomeValue.class );
module.services( DummyService.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
ValueBuilder<Some> builder = app.module().newValueBuilder( Some.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
index fb98815..ceb8c7a 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java
@@ -60,14 +60,14 @@ public class ValueInjectionDeserializationTest
builder.prototype().data().set( "Niclas" );
Some value = builder.newInstance();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
EntityBuilder<Niclas> eb = uow.newEntityBuilder( Niclas.class );
eb.instance().value().set( value );
Niclas niclas1 = eb.newInstance();
String id = niclas1.identity().get();
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Niclas niclas2 = uow.get( Niclas.class, id );
Some someValue = niclas2.value().get();
Assert.assertEquals( someValue.data().get(), "Niclas" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java
index 4c4cdba..aa14297 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java
@@ -16,6 +16,8 @@
package org.apache.zest.runtime.value;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -44,6 +46,7 @@ public class ValueVisibilityTest
private Energy4Java zest;
private Module module;
private Application app;
+ private UnitOfWorkFactory uowf;
@Before
public void setup()
@@ -77,6 +80,7 @@ public class ValueVisibilityTest
} );
app.activate();
module = app.findModule( "From Layer", "From" );
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -173,7 +177,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -191,7 +195,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -209,7 +213,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingModuleModuleVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -227,7 +231,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -245,7 +249,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingBesideLayerVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -263,7 +267,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingBesideModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -281,7 +285,7 @@ public class ValueVisibilityTest
@Test
public void givenFromEntityWhenAccessingBelowApplicationVisibleExpectSuccess()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -299,7 +303,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingBelowLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -317,7 +321,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingBelowModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -335,7 +339,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingAboveApplicationVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -353,7 +357,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingAboveLayerVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -371,7 +375,7 @@ public class ValueVisibilityTest
@Test( expected = NoSuchValueException.class )
public void givenFromEntityWhenAccessingAboveModuleVisibleExpectException()
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
@@ -656,6 +660,8 @@ public class ValueVisibilityTest
module.values( ModuleApplicationVisible.class ).visibleIn( Visibility.application );
module.values( ModuleLayerVisible.class ).visibleIn( Visibility.layer );
module.values( ModuleModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -673,6 +679,7 @@ public class ValueVisibilityTest
module.values( BelowModuleVisible.class ).visibleIn( Visibility.module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -688,6 +695,8 @@ public class ValueVisibilityTest
module.values( AboveApplicationVisible.class ).visibleIn( Visibility.application );
module.values( AboveLayerVisible.class ).visibleIn( Visibility.layer );
module.values( AboveModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
@@ -702,6 +711,8 @@ public class ValueVisibilityTest
module.values( BesideApplicationVisible.class ).visibleIn( Visibility.application );
module.values( BesideLayerVisible.class ).visibleIn( Visibility.layer );
module.values( BesideModuleVisible.class ).visibleIn( Visibility.module );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
index 4afb9ce..c16af32 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java
@@ -65,7 +65,7 @@ public class ValueWithAssociationTest extends AbstractZestTest
String identity1;
String identity2;
DualFaced value;
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
EntityBuilder<SimpleName> builder1 = uow.newEntityBuilder( SimpleName.class );
builder1.instance().name().set( "Niclas" );
@@ -85,7 +85,7 @@ public class ValueWithAssociationTest extends AbstractZestTest
uow.complete();
}
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
DualFaced entity = uow.get( DualFaced.class, identity2 );
AssociationStateHolder holder = spi.stateOf( (EntityComposite) entity );
@@ -118,13 +118,13 @@ public class ValueWithAssociationTest extends AbstractZestTest
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
uow.toEntity( DualFaced.class, value );
uow.complete();
}
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
DualFaced entity = uow.get( DualFaced.class, "1234" );
assertThat( entity.identity().get(), equalTo( "1234" ) );
@@ -139,7 +139,7 @@ public class ValueWithAssociationTest extends AbstractZestTest
{
String identity1;
String identity2;
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
EntityBuilder<SimpleName> builder1 = uow.newEntityBuilder( SimpleName.class );
builder1.instance().name().set( "Niclas" );
@@ -169,7 +169,7 @@ public class ValueWithAssociationTest extends AbstractZestTest
vb2.prototype().namedSimples().put( "paul", simpleValue );
DualFaced dualValue = vb2.newInstance();
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
DualFaced dualEntity = uow.toEntity( DualFaced.class, dualValue );
// The root entity is expected to have changed value,
[23/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
index dec81c1..b515e38 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerInstance.java
@@ -20,16 +20,11 @@ import java.util.stream.Stream;
import org.apache.zest.api.activation.ActivationEventListener;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Layer;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.spi.structure.ModelModule;
/**
* Instance of a Zest application layer. Contains a list of modules which are managed by this layer.
@@ -41,20 +36,18 @@ public class LayerInstance
// Constructor parameters
private final LayerModel layerModel;
private final ApplicationInstance applicationInstance;
- private final UsedLayersInstance usedLayersInstance;
+
// Eager instance objects
private final ActivationDelegate activation;
private final List<ModuleInstance> moduleInstances;
public LayerInstance( LayerModel model,
- ApplicationInstance applicationInstance,
- UsedLayersInstance usedLayersInstance
+ ApplicationInstance applicationInstance
)
{
// Constructor parameters
this.layerModel = model;
this.applicationInstance = applicationInstance;
- this.usedLayersInstance = usedLayersInstance;
// Eager instance objects
activation = new ActivationDelegate( this );
@@ -74,6 +67,12 @@ public class LayerInstance
return layerModel.name();
}
+ @Override
+ public Application application()
+ {
+ return applicationInstance;
+ }
+
// Implementation of MetaInfoHolder
@Override
public <T> T metaInfo( Class<T> infoType )
@@ -114,51 +113,21 @@ public class LayerInstance
return moduleInstances.stream();
}
- // Other methods
- /* package */ void addModule( ModuleInstance module )
- {
- module.registerActivationEventListener( activation );
- moduleInstances.add( module );
- }
-
- /* package */ LayerModel model()
+ @Override
+ public LayerDescriptor descriptor()
{
return layerModel;
}
- public ApplicationInstance applicationInstance()
- {
- return applicationInstance;
- }
-
- /* package */ UsedLayersInstance usedLayersInstance()
+ void addModule( ModuleInstance module )
{
- return usedLayersInstance;
- }
-
- /* package */ Stream<ModelModule<ObjectDescriptor>> visibleObjects( final Visibility visibility )
- {
- return moduleInstances.stream().flatMap( module -> module.visibleObjects( visibility ) );
- }
-
- /* package */ Stream<ModelModule<TransientDescriptor>> visibleTransients( final Visibility visibility )
- {
- return moduleInstances.stream().flatMap( module -> module.visibleTransients( visibility ) );
- }
-
- /* package */ Stream<ModelModule<EntityDescriptor>> visibleEntities( final Visibility visibility )
- {
- return moduleInstances.stream().flatMap( module -> module.visibleEntities( visibility ) );
- }
-
- /* package */ Stream<ModelModule<ValueDescriptor>> visibleValues( final Visibility visibility )
- {
- return moduleInstances.stream().flatMap( module -> module.visibleValues( visibility ) );
+ module.registerActivationEventListener( activation );
+ moduleInstances.add( module );
}
- /* package */ Stream<ServiceReference<?>> visibleServices( final Visibility visibility )
+ public LayerModel model()
{
- return moduleInstances.stream().flatMap( module -> module.visibleServices( visibility ) );
+ return layerModel;
}
/* package */ ModuleInstance findModule( String moduleName )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
index 8592122..d883bfe 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/LayerModel.java
@@ -16,10 +16,17 @@
package org.apache.zest.runtime.structure;
import java.util.List;
+import java.util.stream.Stream;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.common.MetaInfo;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
import org.apache.zest.api.structure.Layer;
import org.apache.zest.api.structure.LayerDescriptor;
+import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.activation.ActivatorsInstance;
@@ -37,6 +44,7 @@ public final class LayerModel
private final UsedLayersModel usedLayersModel;
private final ActivatorsModel<Layer> activatorsModel;
private final List<ModuleModel> modules;
+ private LayerInstance layerInstance;
public LayerModel( String name,
MetaInfo metaInfo,
@@ -100,20 +108,57 @@ public final class LayerModel
return modelVisitor.visitLeave( this );
}
- // Context
- public LayerInstance newInstance( ApplicationInstance applicationInstance, UsedLayersInstance usedLayerInstance )
+ @Override
+ public Layer instance()
{
- LayerInstance layerInstance = new LayerInstance( this, applicationInstance, usedLayerInstance );
+ return layerInstance;
+ }
+
+ public LayerInstance newInstance( ApplicationInstance applicationInstance )
+ {
+ layerInstance = new LayerInstance( this, applicationInstance );
for( ModuleModel module : modules )
{
- ModuleInstance moduleInstance = module.newInstance( layerInstance );
+ ModuleInstance moduleInstance = module.newInstance( this );
layerInstance.addModule( moduleInstance );
}
-
return layerInstance;
}
@Override
+ public Stream<? extends ObjectDescriptor> visibleObjects( final Visibility visibility )
+ {
+ return modules.stream().flatMap( module -> module.visibleObjects( visibility ) );
+ }
+
+ @Override
+ public Stream<? extends TransientDescriptor> visibleTransients( final Visibility visibility )
+ {
+ return modules.stream().flatMap( module -> module.visibleTransients( visibility ) );
+ }
+
+ @Override
+ public Stream<? extends EntityDescriptor> visibleEntities( final Visibility visibility )
+ {
+ return modules.stream().flatMap( module -> module.visibleEntities( visibility ) );
+ }
+
+ /* package */
+ @Override
+ public Stream<? extends ValueDescriptor> visibleValues( final Visibility visibility )
+ {
+ return modules.stream().flatMap( module -> module.visibleValues( visibility ) );
+ }
+
+ /* package */
+ @Override
+ public Stream<? extends ModelDescriptor> visibleServices( final Visibility visibility )
+ {
+ return modules.stream().flatMap( module -> module.visibleServices( visibility ) );
+ }
+
+
+ @Override
public String toString()
{
return name;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleClassLoader.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleClassLoader.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleClassLoader.java
new file mode 100644
index 0000000..341dc79
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleClassLoader.java
@@ -0,0 +1,182 @@
+/*
+ * 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.runtime.structure;
+
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.AmbiguousTypeException;
+import org.apache.zest.api.composite.ModelDescriptor;
+
+import static java.util.stream.Stream.concat;
+import static org.apache.zest.api.common.Visibility.application;
+import static org.apache.zest.api.common.Visibility.module;
+import static org.apache.zest.api.util.Classes.modelTypeSpecification;
+
+// Module ClassLoader
+class ModuleClassLoader
+ extends ClassLoader
+{
+
+ private final ModuleModel moduleModel;
+ private final ConcurrentHashMap<String, Class<?>> classes = new ConcurrentHashMap<>();
+
+ ModuleClassLoader( ModuleModel moduleModel, ClassLoader classLoader )
+ {
+ super( classLoader );
+ this.moduleModel = moduleModel;
+ }
+
+ @Override
+ protected Class<?> findClass( String className )
+ throws ClassNotFoundException
+ {
+ try
+ {
+ Class<?> resultingClass = classes.computeIfAbsent( className, name ->
+ {
+ Predicate<ModelDescriptor> modelTypeSpecification = modelTypeSpecification( name );
+ Stream<? extends ModelDescriptor> moduleModels = concat(
+ moduleModel.visibleObjects( Visibility.module ),
+ concat(
+ moduleModel.visibleEntities( Visibility.module ),
+ concat(
+ moduleModel.visibleTransients( Visibility.module ),
+ moduleModel.visibleValues( Visibility.module )
+ )
+ )
+ ).filter( modelTypeSpecification );
+
+ Class<?> clazz = null;
+ Iterator<? extends ModelDescriptor> iterator = moduleModels.iterator();
+ if( iterator.hasNext() )
+ {
+ clazz = iterator.next().types().findFirst().orElse( null );
+
+ if( iterator.hasNext() )
+ {
+ // Ambiguous exception
+ new AmbiguousTypeException(
+ "More than one model matches the classname " + name + ":" + iterator.next()
+ );
+ }
+ }
+
+ // Check layer
+ if( clazz == null )
+ {
+ Stream<? extends ModelDescriptor> modelsInLayer1 = concat(
+ moduleModel.layer().visibleObjects( Visibility.layer ),
+ concat(
+ moduleModel.layer().visibleEntities( Visibility.layer ),
+ concat(
+ moduleModel.layer().visibleTransients( Visibility.layer ),
+ moduleModel.layer().visibleValues( Visibility.layer )
+ )
+ )
+ );
+ // TODO: What does this actually represents?? Shouldn't 'application' visible models already be handed back from lasyerInstance().visibleXyz() ??
+ Stream<? extends ModelDescriptor> modelsInLayer2 = concat(
+ moduleModel.layer().visibleObjects( Visibility.application ),
+ concat(
+ moduleModel.layer().visibleEntities( Visibility.application ),
+ concat(
+ moduleModel.layer().visibleTransients( Visibility.application ),
+ moduleModel.layer().visibleValues( Visibility.application )
+ )
+ )
+ );
+ Stream<? extends ModelDescriptor> layerModels = concat(
+ modelsInLayer1,
+ modelsInLayer2
+ ).filter( modelTypeSpecification );
+
+ Iterator<? extends ModelDescriptor> layerModelsIter = layerModels.iterator();
+ if( layerModelsIter.hasNext() )
+ {
+ clazz = layerModelsIter.next().types().findFirst().orElse( null );
+
+ if( layerModelsIter.hasNext() )
+ {
+ // Ambiguous exception
+ new AmbiguousTypeException(
+ "More than one model matches the classname " + name + ":" + layerModelsIter.next()
+ );
+ }
+ }
+ }
+
+ // Check used layers
+ if( clazz == null )
+ {
+ Stream<? extends ModelDescriptor> usedLayersModels = concat(
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleObjects( module ) ),
+ concat(
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleEntities( Visibility.layer ) ),
+ concat(
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleTransients( application ) ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleValues( application ) )
+ )
+ )
+ ).filter( modelTypeSpecification );
+
+ Iterator<? extends ModelDescriptor> usedLayersModelsIter = usedLayersModels.iterator();
+ if( usedLayersModelsIter.hasNext() )
+ {
+ clazz = usedLayersModelsIter.next().types().findFirst().orElse( null );
+
+ if( usedLayersModelsIter.hasNext() )
+ {
+ // Ambiguous exception
+ new AmbiguousTypeException(
+ "More than one model matches the classname " + name + ":" + usedLayersModelsIter.next()
+ );
+ }
+ }
+ }
+ return clazz;
+ } );
+ if( resultingClass == null )
+ {
+ throw new ClassNotFoundException();
+ }
+ return resultingClass;
+ }
+ catch( AmbiguousTypeException e )
+ {
+ throw new ClassNotFoundException( className, e );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
index 4bf431f..a24e768 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
@@ -19,28 +19,24 @@ package org.apache.zest.runtime.structure;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.NoSuchElementException;
import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.Collectors;
import org.apache.zest.api.activation.Activation;
import org.apache.zest.api.activation.ActivationEventListener;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.activation.PassivationException;
import org.apache.zest.api.association.AssociationDescriptor;
import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.AmbiguousTypeException;
import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.NoSuchTransientException;
import org.apache.zest.api.composite.TransientBuilder;
import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.entity.IdentityGenerator;
import org.apache.zest.api.metrics.MetricsProvider;
@@ -50,11 +46,12 @@ import org.apache.zest.api.property.Property;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.structure.TypeLookup;
import org.apache.zest.api.unitofwork.UnitOfWorkException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.util.NullArgumentException;
@@ -69,12 +66,9 @@ import org.apache.zest.runtime.composite.FunctionStateResolver;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.composite.TransientBuilderInstance;
import org.apache.zest.runtime.composite.TransientStateInstance;
-import org.apache.zest.runtime.composite.TransientsModel;
import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.entity.EntitiesModel;
import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.runtime.object.ObjectModel;
-import org.apache.zest.runtime.object.ObjectsModel;
import org.apache.zest.runtime.property.PropertyInstance;
import org.apache.zest.runtime.property.PropertyModel;
import org.apache.zest.runtime.query.QueryBuilderFactoryImpl;
@@ -86,17 +80,11 @@ import org.apache.zest.runtime.value.ValueBuilderInstance;
import org.apache.zest.runtime.value.ValueBuilderWithPrototype;
import org.apache.zest.runtime.value.ValueBuilderWithState;
import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.runtime.value.ValuesModel;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.metrics.MetricsProviderAdapter;
import org.apache.zest.spi.module.ModuleSpi;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerialization;
-import static java.util.stream.Stream.concat;
-import static org.apache.zest.api.util.Classes.modelTypeSpecification;
import static org.apache.zest.functional.Iterables.iterable;
-import static org.apache.zest.runtime.legacy.Specifications.translate;
/**
* Instance of a Zest Module. Contains the various composites for this Module.
@@ -106,18 +94,13 @@ public class ModuleInstance
{
// Constructor parameters
private final ModuleModel model;
- private final LayerInstance layer;
- private final TransientsModel transients;
- private final ValuesModel values;
- private final ObjectsModel objects;
- private final EntitiesModel entities;
+ private final LayerDescriptor layer;
+ private final TypeLookup typeLookup;
private final ServicesInstance services;
private final ImportedServicesInstance importedServices;
// Eager instance objects
private final ActivationDelegate activation;
- private final TypeLookupImpl typeLookup;
private final QueryBuilderFactory queryBuilderFactory;
- private final ClassLoader classLoader;
// Lazy assigned on accessors
private EntityStore store;
private IdentityGenerator generator;
@@ -126,26 +109,20 @@ public class ModuleInstance
private UnitOfWorkFactory uowf;
@SuppressWarnings( "LeakingThisInConstructor" )
- public ModuleInstance( ModuleModel moduleModel, LayerInstance layerInstance, TransientsModel transientsModel,
- EntitiesModel entitiesModel, ObjectsModel objectsModel, ValuesModel valuesModel,
+ public ModuleInstance( ModuleModel moduleModel, LayerDescriptor layer, TypeLookup typeLookup,
ServicesModel servicesModel, ImportedServicesModel importedServicesModel
)
{
// Constructor parameters
model = moduleModel;
- layer = layerInstance;
- transients = transientsModel;
- values = valuesModel;
- entities = entitiesModel;
- services = servicesModel.newInstance( this );
- objects = objectsModel;
- importedServices = importedServicesModel.newInstance( this );
+ this.layer = layer;
+ this.typeLookup = typeLookup;
+ services = servicesModel.newInstance( moduleModel );
+ importedServices = importedServicesModel.newInstance( moduleModel );
// Eager instance objects
activation = new ActivationDelegate( this );
- typeLookup = new TypeLookupImpl( this );
queryBuilderFactory = new QueryBuilderFactoryImpl( this );
- classLoader = new ModuleClassLoader( this, Thread.currentThread().getContextClassLoader() );
// Activation
services.registerActivationEventListener( activation );
@@ -158,129 +135,17 @@ public class ModuleInstance
return model.toString();
}
- // Implementation of Module
- @Override
- public String name()
- {
- return model.name();
- }
-
- @Override
- public ClassLoader classLoader()
- {
- return classLoader;
- }
-
- @Override
- public EntityDescriptor entityDescriptor( String name )
- {
- try
- {
- Class<?> type = classLoader().loadClass( name );
- ModelModule<EntityDescriptor> entityModel = typeLookup.lookupEntityModel( type );
- if( entityModel == null )
- {
- return null;
- }
- return entityModel.model();
- }
- catch( ClassNotFoundException e )
- {
- return null;
- }
- }
-
- @Override
- public ObjectDescriptor objectDescriptor( String typeName )
- {
- try
- {
- Class<?> type = classLoader().loadClass( typeName );
- ModelModule<ObjectDescriptor> objectModel = typeLookup.lookupObjectModel( type );
- if( objectModel == null )
- {
- return null;
- }
- return objectModel.model();
- }
- catch( ClassNotFoundException e )
- {
- return null;
- }
- }
-
- @Override
- public TransientDescriptor transientDescriptor( String name )
- {
- try
- {
- Class<?> type = classLoader().loadClass( name );
- ModelModule<TransientDescriptor> transientModel = typeLookup.lookupTransientModel( type );
- if( transientModel == null )
- {
- return null;
- }
- return transientModel.model();
- }
- catch( ClassNotFoundException e )
- {
- return null;
- }
- }
-
@Override
- public ValueDescriptor valueDescriptor( String name )
+ public ModuleDescriptor descriptor()
{
- try
- {
- Class<?> type = classLoader().loadClass( name );
- ModelModule<ValueDescriptor> valueModel = typeLookup.lookupValueModel( type );
- if( valueModel == null )
- {
- return null;
- }
- return valueModel.model();
- }
- catch( ClassNotFoundException e )
- {
- return null;
- }
- }
-
- @Override
- public Stream<? extends TransientDescriptor> transientComposites()
- {
- return transients.stream();
- }
-
- @Override
- public Stream<? extends ValueDescriptor> valueComposites()
- {
- return values.stream();
- }
-
- @Override
- public Stream<? extends ServiceDescriptor> serviceComposites()
- {
- return services.stream();
- }
-
- @Override
- public Stream<? extends EntityDescriptor> entityComposites()
- {
- return entities.stream();
- }
-
- @Override
- public Stream<? extends ImportedServiceDescriptor> importedServices()
- {
- return importedServices.stream();
+ return model;
}
+ // Implementation of Module
@Override
- public Stream<? extends ObjectDescriptor> objects()
+ public String name()
{
- return objects.stream();
+ return model.name();
}
// Implementation of MetaInfoHolder
@@ -296,15 +161,15 @@ public class ModuleInstance
throws NoSuchObjectException
{
NullArgumentException.validateNotNull( "mixinType", mixinType );
- ModelModule<ObjectDescriptor> modelModule = typeLookup.lookupObjectModel( mixinType );
+ ObjectDescriptor model = typeLookup.lookupObjectModel( mixinType );
- if( modelModule == null )
+ if( model == null )
{
throw new NoSuchObjectException( mixinType.getName(), name(), typeLookup.allVisibleObjects() );
}
- InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
- return mixinType.cast( ( (ObjectModel) modelModule.model() ).newInstance( injectionContext ) );
+ InjectionContext injectionContext = new InjectionContext( model.module(), UsesInstance.EMPTY_USES.use( uses ) );
+ return mixinType.cast( ( (ObjectModel) model ).newInstance( injectionContext ) );
}
@Override
@@ -312,15 +177,15 @@ public class ModuleInstance
throws ConstructionException
{
NullArgumentException.validateNotNull( "instance", instance );
- ModelModule<ObjectDescriptor> modelModule = typeLookup.lookupObjectModel( instance.getClass() );
+ ObjectDescriptor model = typeLookup.lookupObjectModel( instance.getClass() );
- if( modelModule == null )
+ if( model == null )
{
throw new NoSuchObjectException( instance.getClass().getName(), name(), typeLookup.allVisibleObjects() );
}
- InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
- ( (ObjectModel) modelModule.model() ).inject( injectionContext, instance );
+ InjectionContext injectionContext = new InjectionContext( model.module(), UsesInstance.EMPTY_USES.use( uses ) );
+ ( (ObjectModel) model ).inject( injectionContext, instance );
}
// Implementation of TransientBuilderFactory
@@ -329,25 +194,25 @@ public class ModuleInstance
throws NoSuchTransientException
{
NullArgumentException.validateNotNull( "mixinType", mixinType );
- ModelModule<TransientDescriptor> modelModule = typeLookup.lookupTransientModel( mixinType );
+ TransientDescriptor model = typeLookup.lookupTransientModel( mixinType );
- if( modelModule == null )
+ if( model == null )
{
throw new NoSuchTransientException( mixinType.getName(), name() );
}
Map<AccessibleObject, Property<?>> properties = new HashMap<>();
- modelModule.model().state().properties().forEach(
+ model.state().properties().forEach(
propertyModel ->
{
Property<?> property = new PropertyInstance<>( ( (PropertyModel) propertyModel ).getBuilderInfo(),
- propertyModel.initialValue( modelModule.module() ) );
+ propertyModel.initialValue( model.module() ) );
properties.put( propertyModel.accessor(), property );
} );
TransientStateInstance state = new TransientStateInstance( properties );
- return new TransientBuilderInstance<>( modelModule, state, UsesInstance.EMPTY_USES );
+ return new TransientBuilderInstance<>( model, state, UsesInstance.EMPTY_USES );
}
@Override
@@ -370,7 +235,7 @@ public class ModuleInstance
throws NoSuchValueException
{
NullArgumentException.validateNotNull( "mixinType", mixinType );
- ModelModule<ValueDescriptor> compositeModelModule = typeLookup.lookupValueModel( mixinType );
+ ValueDescriptor compositeModelModule = typeLookup.lookupValueModel( mixinType );
if( compositeModelModule == null )
{
@@ -394,7 +259,7 @@ public class ModuleInstance
NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
- ModelModule<ValueDescriptor> compositeModelModule = typeLookup.lookupValueModel( mixinType );
+ ValueDescriptor compositeModelModule = typeLookup.lookupValueModel( mixinType );
if( compositeModelModule == null )
{
@@ -410,9 +275,9 @@ public class ModuleInstance
private static class InitialStateResolver
implements StateResolver
{
- private final Module module;
+ private final ModuleDescriptor module;
- private InitialStateResolver( Module module )
+ private InitialStateResolver( ModuleDescriptor module )
{
this.module = module;
}
@@ -451,14 +316,14 @@ public class ModuleInstance
ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) prototype );
Class<Composite> valueType = (Class<Composite>) valueInstance.types().findFirst().orElse( null );
- ModelModule<ValueDescriptor> modelModule = typeLookup.lookupValueModel( valueType );
+ ValueDescriptor model = typeLookup.lookupValueModel( valueType );
- if( modelModule == null )
+ if( model == null )
{
throw new NoSuchValueException( valueType.getName(), name() );
}
- return new ValueBuilderWithPrototype<>( modelModule, this, prototype );
+ return new ValueBuilderWithPrototype<>( model, this, prototype );
}
@Override
@@ -466,16 +331,16 @@ public class ModuleInstance
throws NoSuchValueException, ConstructionException
{
NullArgumentException.validateNotNull( "mixinType", mixinType );
- ModelModule<ValueDescriptor> modelModule = typeLookup.lookupValueModel( mixinType );
+ ValueDescriptor model = typeLookup.lookupValueModel( mixinType );
- if( modelModule == null )
+ if( model == null )
{
throw new NoSuchValueException( mixinType.getName(), name() );
}
try
{
- return valueSerialization().deserialize( modelModule.model().valueType(), serializedState );
+ return valueSerialization().deserialize( model.module(), model.valueType(), serializedState );
}
catch( ValueSerializationException ex )
{
@@ -490,29 +355,59 @@ public class ModuleInstance
return queryBuilderFactory.newQueryBuilder( resultType );
}
- // Implementation of ServiceFinder
@Override
public <T> ServiceReference<T> findService( Class<T> serviceType )
+ throws NoSuchServiceException
{
- return typeLookup.lookupServiceReference( serviceType );
+ return findService( (Type) serviceType );
}
@Override
public <T> ServiceReference<T> findService( Type serviceType )
{
- return typeLookup.lookupServiceReference( serviceType );
+ ModelDescriptor serviceModel = typeLookup.lookupServiceModel( serviceType );
+ if( serviceModel == null )
+ {
+ throw new NoSuchServiceException( serviceType.getTypeName(), name() );
+ }
+ ModuleInstance serviceLocation = (ModuleInstance) serviceModel.module().instance();
+ try
+ {
+ //noinspection unchecked
+ return serviceLocation.services
+ .references()
+ .filter( ref -> ref.hasType( serviceType ) )
+ .map( ref -> (ServiceReference<T>) ref )
+ .findAny().get();
+ }
+ catch( NoSuchElementException e )
+ {
+ throw new NoSuchServiceException( serviceType.getTypeName(), name() );
+ }
}
@Override
public <T> Iterable<ServiceReference<T>> findServices( Class<T> serviceType )
{
- return typeLookup.lookupServiceReferences( serviceType );
+ return findServices( (Type) serviceType );
}
@Override
public <T> Iterable<ServiceReference<T>> findServices( Type serviceType )
{
- return typeLookup.lookupServiceReferences( serviceType );
+ List<? extends ModelDescriptor> serviceModels = typeLookup.lookupServiceModels( serviceType );
+ if( serviceModels == null )
+ {
+ return Collections.emptyList();
+ }
+ //noinspection unchecked
+ return serviceModels.stream()
+ .flatMap(
+ model -> ( (ModuleInstance) model.module().instance() ).services.references()
+ )
+ .filter( ref -> ref.hasType( serviceType ) )
+ .map( ref -> (ServiceReference<T>) ref )
+ .collect( Collectors.toList() );
}
// Implementation of Activation
@@ -544,18 +439,18 @@ public class ModuleInstance
}
// Other methods
- /* package */ ModuleModel model()
+ ModuleModel model()
{
return model;
}
- public LayerInstance layerInstance()
+ public LayerDescriptor layer()
{
return layer;
}
@Override
- public TypeLookupImpl typeLookup()
+ public TypeLookup typeLookup()
{
return typeLookup;
}
@@ -566,16 +461,15 @@ public class ModuleInstance
{
if( store == null )
{
- ServiceReference<EntityStore> service = null;
try
{
- service = findService( EntityStore.class );
+ ServiceReference<EntityStore> service = findService( EntityStore.class );
+ store = service.get();
}
catch( NoSuchServiceException e )
{
throw new UnitOfWorkException( "No EntityStore service available in module " + name() );
}
- store = service.get();
}
}
return store;
@@ -587,16 +481,15 @@ public class ModuleInstance
{
if( uowf == null )
{
- ServiceReference<UnitOfWorkFactory> service = null;
try
{
- service = findService( UnitOfWorkFactory.class );
+ ServiceReference<UnitOfWorkFactory> service = findService( UnitOfWorkFactory.class );
+ uowf = service.get();
}
catch( NoSuchServiceException e )
{
throw new UnitOfWorkException( "No UnitOfWorkFactory service available in module " + name() );
}
- uowf = service.get();
}
}
return uowf;
@@ -628,7 +521,7 @@ public class ModuleInstance
}
catch( NoSuchServiceException e )
{
- valueSerialization = new OrgJsonValueSerialization( layer.applicationInstance(), this, this );
+ throw new ValueSerializationException( "No ValueSeriaservice available in module " + name() );
}
}
}
@@ -655,242 +548,24 @@ public class ModuleInstance
return metrics;
}
- public Stream<ModelModule<ObjectDescriptor>> visibleObjects( Visibility visibility )
- {
- return objects.stream()
- .filter( new Visibilitypredicate( visibility ) )
- .map( ModelModule.<ObjectDescriptor>modelModuleFunction( this ) );
- }
-
- public Stream<ModelModule<TransientDescriptor>> visibleTransients( Visibility visibility )
- {
- return transients.models()
- .filter( new Visibilitypredicate( visibility ) )
- .map( ModelModule.<TransientDescriptor>modelModuleFunction( this ) );
- }
-
- public Stream<ModelModule<EntityDescriptor>> visibleEntities( Visibility visibility )
- {
- return entities.models()
- .filter( new Visibilitypredicate( visibility ) )
- .map( ModelModule.<EntityDescriptor>modelModuleFunction( this ) );
- }
-
- public Stream<ModelModule<ValueDescriptor>> visibleValues( Visibility visibility )
- {
- return values.models()
- .filter( new Visibilitypredicate( visibility ) )
- .map( ModelModule.<ValueDescriptor>modelModuleFunction( this ) );
- }
-
- public Stream<ServiceReference<?>> visibleServices( Visibility visibility )
- {
- return concat( services.visibleServices( visibility ),
- importedServices.visibleServices( visibility ) );
- }
-
- // Module ClassLoader
- private static class ModuleClassLoader
- extends ClassLoader
- {
-
- private final ModuleInstance moduleInstance;
- private final Map<String, Class<?>> classes = new ConcurrentHashMap<>();
-
- private ModuleClassLoader( ModuleInstance moduleInstance, ClassLoader classLoader )
- {
- super( classLoader );
- this.moduleInstance = moduleInstance;
- }
-
- @Override
- protected Class<?> findClass( String name )
- throws ClassNotFoundException
- {
- Class<?> clazz = classes.get( name );
- if( clazz == null )
- {
- Predicate<ModelDescriptor> modelTypeSpecification = modelTypeSpecification( name );
- Predicate<ModelModule<? extends ModelDescriptor>> translation = translate( ModelModule.modelFunction(), modelTypeSpecification );
- Stream<ModelModule<? extends ModelDescriptor>> moduleModels = concat(
- moduleInstance.visibleObjects( Visibility.module ),
- concat(
- moduleInstance.visibleEntities( Visibility.module ),
- concat(
- moduleInstance.visibleTransients( Visibility.module ),
- moduleInstance.visibleValues( Visibility.module )
- )
- )
- ).filter( translation );
-
- Iterator<ModelModule<? extends ModelDescriptor>> moduleModelsIter = moduleModels.iterator();
- if( moduleModelsIter.hasNext() )
- {
- clazz = moduleModelsIter.next().model().types().findFirst().orElse( null );
-
- if( moduleModelsIter.hasNext() )
- {
- // Ambiguous exception
- throw new ClassNotFoundException(
- name,
- new AmbiguousTypeException(
- "More than one model matches the classname " + name + ":" + moduleModelsIter.next()
- )
- );
- }
- }
-
- // Check layer
- if( clazz == null )
- {
- Stream<ModelModule<? extends ModelDescriptor>> modelsInLayer1 = concat(
- moduleInstance.layerInstance().visibleObjects( Visibility.layer ),
- concat(
- moduleInstance.layerInstance().visibleEntities( Visibility.layer ),
- concat(
- moduleInstance.layerInstance().visibleTransients( Visibility.layer ),
- moduleInstance.layerInstance().visibleValues( Visibility.layer )
- )
- )
- );
- // TODO: What does this actually represents?? Shouldn't 'application' visible models already be handed back from lasyerInstance().visibleXyz() ??
- Stream<ModelModule<? extends ModelDescriptor>> modelsInLayer2 = concat(
- moduleInstance.layerInstance().visibleObjects( Visibility.application ),
- concat(
- moduleInstance.layerInstance().visibleEntities( Visibility.application ),
- concat(
- moduleInstance.layerInstance().visibleTransients( Visibility.application ),
- moduleInstance.layerInstance().visibleValues( Visibility.application )
- )
- )
- );
- Stream<ModelModule<? extends ModelDescriptor>> layerModels = concat(
- modelsInLayer1,
- modelsInLayer2
- ).filter( translation );
-
- Iterator<ModelModule<? extends ModelDescriptor>> layerModelsIter = layerModels.iterator();
- if( layerModelsIter.hasNext() )
- {
- clazz = layerModelsIter.next().model().types().findFirst().orElse( null );
-
- if( layerModelsIter.hasNext() )
- {
- // Ambiguous exception
- throw new ClassNotFoundException(
- name,
- new AmbiguousTypeException(
- "More than one model matches the classname " + name + ":" + layerModelsIter.next() )
- );
- }
- }
- }
-
- // Check used layers
- if( clazz == null )
- {
- Stream<ModelModule<? extends ModelDescriptor>> usedLayersModels = concat(
- moduleInstance.layerInstance().usedLayersInstance().visibleObjects(),
- concat(
- moduleInstance.layerInstance().usedLayersInstance().visibleEntities(),
- concat(
- moduleInstance.layerInstance().usedLayersInstance().visibleTransients(),
- moduleInstance.layerInstance().usedLayersInstance().visibleValues()
- )
- )
- ).filter( translation );
-
- Iterator<ModelModule<? extends ModelDescriptor>> usedLayersModelsIter = usedLayersModels.iterator();
- if( usedLayersModelsIter.hasNext() )
- {
- clazz = usedLayersModelsIter.next().model().types().findFirst().orElse( null );
-
- if( usedLayersModelsIter.hasNext() )
- {
- // Ambiguous exception
- throw new ClassNotFoundException(
- name,
- new AmbiguousTypeException(
- "More than one model matches the classname " + name + ":" + usedLayersModelsIter.next()
- )
- );
- }
- }
- }
-
- if( clazz == null )
- {
- throw new ClassNotFoundException( name );
- }
- classes.put( name, clazz );
- }
-
- return clazz;
- }
- }
-
- public Stream<ModelModule<? extends ModelDescriptor>> findVisibleValueTypes()
- {
- return concat( visibleValues( Visibility.module ),
- concat(
- layerInstance().visibleValues( Visibility.layer ),
- concat(
- layerInstance().visibleValues( Visibility.application ),
- layerInstance().usedLayersInstance().visibleValues()
- )
- )
- );
- }
-
- public Stream<ModelModule<? extends ModelDescriptor>> findVisibleEntityTypes()
- {
- return concat( visibleEntities( Visibility.module ),
- concat(
- layerInstance().visibleEntities( Visibility.layer ),
- concat(
- layerInstance().visibleEntities( Visibility.application ),
- layerInstance().usedLayersInstance().visibleEntities()
- )
- )
- );
- }
-
- public Stream<ModelModule<? extends ModelDescriptor>> findVisibleTransientTypes()
- {
- return concat( visibleTransients( Visibility.module ),
- concat(
- layerInstance().visibleTransients( Visibility.layer ),
- concat(
- layerInstance().visibleTransients( Visibility.application ),
- layerInstance().usedLayersInstance().visibleTransients()
- )
- )
- );
- }
-
- public Stream<ServiceReference<?>> findVisibleServiceTypes()
- {
- return concat( visibleServices( Visibility.module ),
- concat(
- layerInstance().visibleServices( Visibility.layer ),
- concat(
- layerInstance().visibleServices( Visibility.application ),
- layerInstance().usedLayersInstance().visibleServices()
- )
- )
- );
- }
-
- public Stream<ModelModule<? extends ModelDescriptor>> findVisibleObjectTypes()
- {
- return concat( visibleObjects( Visibility.module ),
- concat(
- layerInstance().visibleObjects( Visibility.layer ),
- concat(
- layerInstance().visibleObjects( Visibility.application ),
- layerInstance().usedLayersInstance().visibleObjects()
- )
- )
- );
- }
+// public Stream<ServiceReference<?>> visibleServices( Visibility visibility )
+// {
+// return concat( services.visibleServices( visibility ),
+// importedServices.visibleServices( visibility ) );
+// }
+//
+//
+//
+// public Stream<ServiceReference<?>> findVisibleServiceTypes()
+// {
+// return concat( visibleServices( Visibility.module ),
+// concat(
+// layer().visibleServices( Visibility.layer ),
+// concat(
+// layer().visibleServices( Visibility.application ),
+// layer().usedLayers().layers().flatMap( layer -> layer.visibleServices(Visibility.application) )
+// )
+// )
+// );
+// }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
index 49e3670..85fceec 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleModel.java
@@ -15,10 +15,21 @@
*/
package org.apache.zest.runtime.structure;
+import java.util.stream.Stream;
import org.apache.zest.api.activation.ActivationException;
import org.apache.zest.api.common.MetaInfo;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.service.ImportedServiceDescriptor;
+import org.apache.zest.api.service.ServiceDescriptor;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.structure.TypeLookup;
+import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.activation.ActivatorsInstance;
@@ -30,12 +41,18 @@ import org.apache.zest.runtime.service.ImportedServicesModel;
import org.apache.zest.runtime.service.ServicesModel;
import org.apache.zest.runtime.value.ValuesModel;
+import static java.util.stream.Stream.concat;
+import static org.apache.zest.api.common.Visibility.application;
+import static org.apache.zest.api.common.Visibility.layer;
+import static org.apache.zest.api.common.Visibility.module;
+
/**
* JAVADOC
*/
public class ModuleModel
implements ModuleDescriptor, VisitableHierarchy<Object, Object>
{
+ private final LayerDescriptor layerModel;
private final ActivatorsModel<Module> activatorsModel;
private final TransientsModel transientsModel;
private final EntitiesModel entitiesModel;
@@ -43,12 +60,16 @@ public class ModuleModel
private final ValuesModel valuesModel;
private final ServicesModel servicesModel;
private final ImportedServicesModel importedServicesModel;
+ private final TypeLookupImpl typeLookup;
+ private final ClassLoader classLoader;
private final String name;
private final MetaInfo metaInfo;
+ private ModuleInstance moduleInstance;
public ModuleModel( String name,
MetaInfo metaInfo,
+ LayerDescriptor layerModel,
ActivatorsModel<Module> activatorsModel,
TransientsModel transientsModel,
EntitiesModel entitiesModel,
@@ -60,6 +81,7 @@ public class ModuleModel
{
this.name = name;
this.metaInfo = metaInfo;
+ this.layerModel = layerModel;
this.activatorsModel = activatorsModel;
this.transientsModel = transientsModel;
this.entitiesModel = entitiesModel;
@@ -67,6 +89,8 @@ public class ModuleModel
this.valuesModel = valuesModel;
this.servicesModel = servicesModel;
this.importedServicesModel = importedServicesModel;
+ typeLookup = new TypeLookupImpl( this );
+ classLoader = new ModuleClassLoader( this, Thread.currentThread().getContextClassLoader() );
}
@Override
@@ -80,6 +104,18 @@ public class ModuleModel
return metaInfo.get( infoType );
}
+ @Override
+ public LayerDescriptor layer()
+ {
+ return layerModel;
+ }
+
+ @Override
+ public ClassLoader classLoader()
+ {
+ return classLoader;
+ }
+
public ActivatorsInstance<Module> newActivatorsInstance()
throws ActivationException
{
@@ -87,6 +123,237 @@ public class ModuleModel
}
@Override
+ public EntityDescriptor entityDescriptor( String name )
+ {
+ try
+ {
+ Class<?> type = classLoader().loadClass( name );
+ EntityDescriptor entityModel = typeLookup.lookupEntityModel( type );
+ if( entityModel == null )
+ {
+ return null;
+ }
+ return entityModel;
+ }
+ catch( ClassNotFoundException e )
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public ObjectDescriptor objectDescriptor( String typeName )
+ {
+ try
+ {
+ Class<?> type = classLoader().loadClass( typeName );
+ ObjectDescriptor objectModel = typeLookup.lookupObjectModel( type );
+ if( objectModel == null )
+ {
+ return null;
+ }
+ return objectModel;
+ }
+ catch( ClassNotFoundException e )
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public TransientDescriptor transientDescriptor( String name )
+ {
+ try
+ {
+ Class<?> type = classLoader().loadClass( name );
+ TransientDescriptor transientModel = typeLookup.lookupTransientModel( type );
+ if( transientModel == null )
+ {
+ return null;
+ }
+ return transientModel;
+ }
+ catch( ClassNotFoundException e )
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public ValueDescriptor valueDescriptor( String name )
+ {
+ try
+ {
+ Class<?> type = classLoader().loadClass( name );
+ ValueDescriptor valueModel = typeLookup.lookupValueModel( type );
+ if( valueModel == null )
+ {
+ return null;
+ }
+ return valueModel;
+ }
+ catch( ClassNotFoundException e )
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public Module instance()
+ {
+ return moduleInstance;
+ }
+
+ @Override
+ public TypeLookup typeLookup()
+ {
+ return typeLookup;
+ }
+
+ public ModuleInstance newInstance( LayerDescriptor layerInstance )
+ {
+ moduleInstance = new ModuleInstance( this, layerInstance, typeLookup, servicesModel, importedServicesModel );
+ return moduleInstance;
+ }
+
+ @Override
+ public Stream<? extends TransientDescriptor> transientComposites()
+ {
+ return transientsModel.stream();
+ }
+
+ @Override
+ public Stream<? extends ValueDescriptor> valueComposites()
+ {
+ return valuesModel.stream();
+ }
+
+ @Override
+ public Stream<? extends ServiceDescriptor> serviceComposites()
+ {
+ return servicesModel.models();
+ }
+
+ @Override
+ public Stream<? extends EntityDescriptor> entityComposites()
+ {
+ return entitiesModel.stream();
+ }
+
+ @Override
+ public Stream<? extends ImportedServiceDescriptor> importedServices()
+ {
+ return importedServicesModel.models();
+ }
+
+ @Override
+ public Stream<? extends ObjectDescriptor> objects()
+ {
+ return objectsModel.models();
+ }
+
+ public Stream<? extends ValueDescriptor> findVisibleValueTypes()
+ {
+ return concat( visibleValues( module ),
+ concat(
+ layer().visibleValues( layer ),
+ concat(
+ layer().visibleValues( application ),
+ layer().usedLayers().layers().flatMap( layer1 -> layer1.visibleValues( application ) )
+ )
+ )
+ );
+ }
+
+ public Stream<? extends EntityDescriptor> findVisibleEntityTypes()
+ {
+ return concat( visibleEntities( module ),
+ concat(
+ layer().visibleEntities( layer ),
+ concat(
+ layer().visibleEntities( application ),
+ layer().usedLayers().layers().flatMap( layer1 -> layer1.visibleEntities( application ) )
+ )
+ )
+ );
+ }
+
+ public Stream<? extends TransientDescriptor> findVisibleTransientTypes()
+ {
+ return concat( visibleTransients( module ),
+ concat(
+ layer().visibleTransients( layer ),
+ concat(
+ layer().visibleTransients( application ),
+ layer().usedLayers()
+ .layers()
+ .flatMap( layer1 -> layer1.visibleTransients( application ) )
+ )
+ )
+ );
+ }
+
+ public Stream<? extends ModelDescriptor> findVisibleServiceTypes()
+ {
+ return concat( visibleServices( module ),
+ concat(
+ layer().visibleServices( layer ),
+ concat(
+ layer().visibleServices( application ),
+ layer().usedLayers().layers().flatMap( layer1 -> layer1.visibleServices( application ) )
+ )
+ )
+ );
+ }
+
+ public Stream<? extends ObjectDescriptor> findVisibleObjectTypes()
+ {
+ return concat( visibleObjects( module ),
+ concat(
+ layer().visibleObjects( layer ),
+ concat(
+ layer().visibleObjects( application ),
+ layer().usedLayers().layers().flatMap( layer -> layer.visibleObjects( application ) )
+ )
+ )
+ );
+ }
+
+ public Stream<? extends ObjectDescriptor> visibleObjects( Visibility visibility )
+ {
+ return objectsModel.models()
+ .filter( new Visibilitypredicate( visibility ) );
+ }
+
+ public Stream<? extends TransientDescriptor> visibleTransients( Visibility visibility )
+ {
+ return transientsModel.models()
+ .filter( new Visibilitypredicate( visibility ) );
+ }
+
+ public Stream<? extends EntityDescriptor> visibleEntities( Visibility visibility )
+ {
+ return entitiesModel.models()
+ .filter( new Visibilitypredicate( visibility ) );
+ }
+
+ public Stream<? extends ValueDescriptor> visibleValues( Visibility visibility )
+ {
+ return valuesModel.models()
+ .filter( new Visibilitypredicate( visibility ) );
+ }
+
+ public Stream<? extends ModelDescriptor> visibleServices( Visibility visibility )
+ {
+ return concat(
+ servicesModel.models()
+ .filter( new Visibilitypredicate( visibility ) ),
+ importedServicesModel.models()
+ .filter( new Visibilitypredicate( visibility ) )
+ );
+ }
+
+ @Override
public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super Object, ? super Object, ThrowableType> modelVisitor )
throws ThrowableType
{
@@ -115,13 +382,6 @@ public class ModuleModel
return modelVisitor.visitLeave( this );
}
- // Context
-
- public ModuleInstance newInstance( LayerInstance layerInstance )
- {
- return new ModuleInstance( this, layerInstance, transientsModel, entitiesModel, objectsModel, valuesModel, servicesModel, importedServicesModel );
- }
-
@Override
public String toString()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
index 7835aaa..0d3c740 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
@@ -22,9 +22,7 @@ package org.apache.zest.runtime.structure;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -35,18 +33,14 @@ import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.structure.TypeLookup;
import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.structure.TypeLookup;
import static java.util.stream.Stream.concat;
import static org.apache.zest.api.common.Visibility.application;
import static org.apache.zest.api.common.Visibility.layer;
-import static org.apache.zest.api.common.Visibility.module;
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
import static org.apache.zest.api.util.Classes.interfacesOf;
import static org.apache.zest.functional.Iterables.first;
@@ -58,25 +52,26 @@ public class TypeLookupImpl
{
// Constructor parameters
- private final ModuleInstance moduleInstance;
+ private final ModuleDescriptor moduleModel;
+
// Eager instance objects
- private final Map<Class<?>, ModelModule<ObjectDescriptor>> objectModels;
- private final Map<Class<?>, ModelModule<TransientDescriptor>> transientModels;
- private final Map<Class<?>, ModelModule<ValueDescriptor>> valueModels;
- private final Map<Class<?>, List<ModelModule<EntityDescriptor>>> allEntityModels;
- private final Map<Class<?>, ModelModule<EntityDescriptor>> unambiguousEntityModels;
- private final Map<Type, ServiceReference<?>> serviceReferences;
- private final Map<Type, List<ServiceReference<?>>> servicesReferences;
+ private final ConcurrentHashMap<Class<?>, ObjectDescriptor> objectModels;
+ private final ConcurrentHashMap<Class<?>, TransientDescriptor> transientModels;
+ private final ConcurrentHashMap<Class<?>, ValueDescriptor> valueModels;
+ private final ConcurrentHashMap<Class<?>, List<? extends EntityDescriptor>> allEntityModels;
+ private final ConcurrentHashMap<Class<?>, EntityDescriptor> unambiguousEntityModels;
+ private final ConcurrentHashMap<Type, ModelDescriptor> serviceModels;
+ private final ConcurrentHashMap<Type, List<ModelDescriptor>> servicesReferences;
/**
- * Create a new TypeLookup bound to the given ModuleInstance.
+ * Create a new TypeLookup bound to the given moduleModel.
*
- * @param moduleInstance ModuleInstance bound to this TypeLookup
+ * @param module ModuleModel bound to this TypeLookup
*/
- TypeLookupImpl( ModuleInstance moduleInstance )
+ TypeLookupImpl( ModuleModel module )
{
// Constructor parameters
- this.moduleInstance = moduleInstance;
+ this.moduleModel = module;
// Eager instance objects
objectModels = new ConcurrentHashMap<>();
@@ -84,7 +79,7 @@ public class TypeLookupImpl
valueModels = new ConcurrentHashMap<>();
allEntityModels = new ConcurrentHashMap<>();
unambiguousEntityModels = new ConcurrentHashMap<>();
- serviceReferences = new ConcurrentHashMap<>();
+ serviceModels = new ConcurrentHashMap<>();
servicesReferences = new ConcurrentHashMap<>();
}
@@ -103,23 +98,19 @@ public class TypeLookupImpl
*
* @return First matching Object Model
*/
- ModelModule<ObjectDescriptor> lookupObjectModel( final Class type )
+ @Override
+ public ObjectDescriptor lookupObjectModel( final Class<?> type )
{
- ModelModule<ObjectDescriptor> model = objectModels.get( type );
- if( model == null )
+ return objectModels.computeIfAbsent( type, key ->
{
- List<ModelModule<ObjectDescriptor>> allModels = allObjects().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ List<ObjectDescriptor> allModels = allObjects().collect( Collectors.toList() );
+ ObjectDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
if( model == null )
{
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- objectModels.put( type, model );
+ model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
}
- }
- return model;
+ return model;
+ } );
}
/**
@@ -137,23 +128,19 @@ public class TypeLookupImpl
*
* @return First matching Transient Model
*/
- ModelModule<TransientDescriptor> lookupTransientModel( final Class type )
+ @Override
+ public TransientDescriptor lookupTransientModel( final Class<?> type )
{
- ModelModule<TransientDescriptor> model = transientModels.get( type );
- if( model == null )
+ return transientModels.computeIfAbsent( type, key ->
{
- List<ModelModule<TransientDescriptor>> allModels = allTransients().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ List<TransientDescriptor> allModels = allTransients().collect( Collectors.toList() );
+ TransientDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
if( model == null )
{
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- transientModels.put( type, model );
+ model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
}
- }
- return model;
+ return model;
+ } );
}
/**
@@ -171,23 +158,19 @@ public class TypeLookupImpl
*
* @return First matching Value Model
*/
- public ModelModule<ValueDescriptor> lookupValueModel( final Class type )
+ @Override
+ public ValueDescriptor lookupValueModel( final Class<?> type )
{
- ModelModule<ValueDescriptor> model = valueModels.get( type );
- if( model == null )
+ return valueModels.computeIfAbsent( type, key ->
{
- List<ModelModule<ValueDescriptor>> allModels = allValues().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ List<ValueDescriptor> allModels = allValues().collect( Collectors.toList() );
+ ValueDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
if( model == null )
{
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- valueModels.put( type, model );
+ model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
}
- }
- return model;
+ return model;
+ } );
}
/**
@@ -209,24 +192,18 @@ public class TypeLookupImpl
* @return First matching Entity Model
*/
@Override
- public ModelModule<EntityDescriptor> lookupEntityModel( final Class type )
+ public EntityDescriptor lookupEntityModel( final Class<?> type )
{
- ModelModule<EntityDescriptor> model = unambiguousEntityModels.get( type );
-
- if( model == null )
+ return unambiguousEntityModels.computeIfAbsent( type, key ->
{
- List<ModelModule<EntityDescriptor>> allModels = allEntities().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ List<EntityDescriptor> allModels = allEntities().collect( Collectors.toList() );
+ EntityDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
if( model == null )
{
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- unambiguousEntityModels.put( type, model );
+ model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
}
- }
- return model;
+ return model;
+ } );
}
/**
@@ -252,179 +229,161 @@ public class TypeLookupImpl
* @return All matching Entity Models
*/
@Override
- public Iterable<ModelModule<EntityDescriptor>> lookupEntityModels( final Class type )
+ public Iterable<? extends EntityDescriptor> lookupEntityModels( final Class type )
{
- List<ModelModule<EntityDescriptor>> result = allEntityModels.get( type );
- if( result == null )
- {
- result = concat(
- allEntities().filter( ref -> new ExactTypeMatching<>( type ).test( ref.model() ) ),
- allEntities().filter( ref -> new AssignableFromTypeMatching<>( type ).test( ref.model() ) )
- ).distinct().collect( Collectors.toList() );
- allEntityModels.put( type, result );
- }
- return result;
+ return allEntityModels.computeIfAbsent( type, key ->
+ concat(
+ allEntities().filter( ref -> new ExactTypeMatching<>( key ).test( ref ) ),
+ allEntities().filter( ref -> new AssignableFromTypeMatching<>( key ).test( ref ) )
+ ).distinct().collect( Collectors.toList() )
+ );
}
- /**
- * Lookup first ServiceReference matching the given Type.
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p>See {@link #lookupServiceReferences(Type)}.</p>
- *
- * @param <T> Service Type
- * @param serviceType Looked up Type
- *
- * @return First matching ServiceReference
- */
@Override
- public <T> ServiceReference<T> lookupServiceReference( Type serviceType )
+ public ModelDescriptor lookupServiceModel( Type serviceType1 )
{
- @SuppressWarnings( "unchecked" )
- ServiceReference<T> serviceReference = (ServiceReference<T>) serviceReferences.get( serviceType );
- if( serviceReference == null )
- {
- // Lazily resolve ServiceReference
- serviceReference = first( lookupServiceReferences( serviceType ) );
- if( serviceReference != null )
- {
- serviceReferences.put( serviceType, serviceReference );
- }
- }
-
- if( serviceReference == null )
- {
- throw new NoSuchServiceException( RAW_CLASS.apply( serviceType ).getName(), moduleInstance.name() );
- }
- return serviceReference;
+ return serviceModels.computeIfAbsent( serviceType1, key -> first( lookupServiceModels( key ) ) );
}
- /**
- * Lookup all ServiceReferences matching the given Type.
- *
- * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
- *
- * <ul>
- * <li>exactly match the given type, in Visibility then Assembly order ;</li>
- * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
- * </ul>
- *
- * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
- * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param <T> Service Type
- * @param type Looked up Type
- *
- * @return All matching ServiceReferences
- */
@Override
- public <T> List<ServiceReference<T>> lookupServiceReferences( final Type type )
+ public List<? extends ModelDescriptor> lookupServiceModels( Type type1 )
{
- List<ServiceReference<?>> serviceRefs = servicesReferences.get( type );
- if( serviceRefs == null )
+ return servicesReferences.computeIfAbsent( type1, type ->
{
- serviceRefs = concat(
- allServices()
- .filter( new ExactTypeMatching<>( type ) ),
- allServices()
- .filter( new AssignableFromTypeMatching<>( type )
- )
- ).distinct().collect( Collectors.toList() );
- servicesReferences.put( type, serviceRefs );
- }
- List<ServiceReference<T>> result = new ArrayList<>();
- //noinspection unchecked
- serviceRefs.forEach( ref -> result.add( (ServiceReference<T>) ref ) );
- return result;
+ List<ModelDescriptor> models =
+ allServices().filter(
+ new ExactTypeMatching<>( type ).or( new AssignableFromTypeMatching<>( type ) )
+ )
+ .distinct()
+ .collect( Collectors.toList() );
+
+ // TODO: Needed??
+// List<T> result = new ArrayList<>();
+// //noinspection unchecked
+// serviceRefs.forEach( descriptor -> result.add( (T) descriptor ) );
+
+ return models;
+ } );
}
@Override
public Stream<Class<?>> allVisibleObjects()
{
- return allObjects().flatMap( model -> model.model().types() );
+ return allObjects().flatMap( HasTypes::types );
}
@Override
- public Stream<ModelModule<ObjectDescriptor>> allObjects()
+ public Stream<? extends ObjectDescriptor> allObjects()
{
- return concat( moduleInstance.visibleObjects( module ),
+ return concat( moduleModel.objects(),
concat(
- moduleInstance.layerInstance().visibleObjects( layer ),
concat(
- moduleInstance.layerInstance().visibleObjects( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleObjects()
- )
+ moduleModel.layer().visibleObjects( layer ),
+ moduleModel.layer().visibleObjects( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleObjects( application ) )
)
);
}
@Override
- public Stream<ModelModule<TransientDescriptor>> allTransients()
+ public Stream<? extends TransientDescriptor> allTransients()
{
- return concat( moduleInstance.visibleTransients( module ),
+ return concat( moduleModel.transientComposites(),
concat(
- moduleInstance.layerInstance().visibleTransients( layer ),
concat(
- moduleInstance.layerInstance().visibleTransients( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleTransients()
- )
+ moduleModel.layer().visibleTransients( layer ),
+ moduleModel.layer().visibleTransients( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleTransients( application ) )
)
);
}
@Override
- public Stream<ModelModule<ValueDescriptor>> allValues()
+ public Stream<? extends ValueDescriptor> allValues()
{
- return concat( moduleInstance.visibleValues( module ),
+
+ return concat( moduleModel.valueComposites(),
concat(
- moduleInstance.layerInstance().visibleValues( layer ),
- concat(
- moduleInstance.layerInstance().visibleValues( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleValues()
- )
+ concat( moduleModel.layer().visibleValues( layer ),
+ moduleModel.layer().visibleValues( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer1 -> layer1.visibleValues( application ) )
)
);
}
@Override
- public Stream<ModelModule<EntityDescriptor>> allEntities()
+ public Stream<? extends EntityDescriptor> allEntities()
{
- return concat( moduleInstance.visibleEntities( module ),
+ return concat( moduleModel.entityComposites(),
concat(
- moduleInstance.layerInstance().visibleEntities( layer ),
concat(
- moduleInstance.layerInstance().visibleEntities( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleEntities()
- )
+ moduleModel.layer().visibleEntities( layer ),
+ moduleModel.layer().visibleEntities( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleEntities( application ) )
)
);
}
@Override
- public Stream<ServiceReference<?>> allServices()
+ public Stream<? extends ModelDescriptor> allServices()
{
- return concat( moduleInstance.visibleServices( module ),
- concat(
- moduleInstance.layerInstance().visibleServices( layer ),
- concat(
- moduleInstance.layerInstance().visibleServices( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleServices()
- )
- )
- );
+ Stream<? extends ModelDescriptor> managedServices =
+ concat( moduleModel.serviceComposites(),
+ concat(
+ concat(
+ moduleModel.layer()
+ .visibleServices( layer ),
+ moduleModel.layer()
+ .visibleServices( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleServices( application ) )
+ )
+ );
+ Stream<? extends ModelDescriptor> importedServices =
+ concat( moduleModel.serviceComposites(),
+ concat(
+ concat(
+ moduleModel.layer()
+ .visibleServices( layer ),
+ moduleModel.layer()
+ .visibleServices( application )
+ ),
+ moduleModel.layer()
+ .usedLayers()
+ .layers()
+ .flatMap( layer -> layer.visibleServices( application ) )
+ )
+ );
+ return concat( managedServices, importedServices );
}
- private <T extends ModelDescriptor> ModelModule<T> ambiguityMatching(
+ private <T extends ModelDescriptor> T ambiguityMatching(
Class type,
- List<ModelModule<T>> modelModules,
+ List<T> modelModules,
TypeMatching<T> matching
)
{
- List<ModelModule<T>> models = modelModules.stream()
- .filter( ref -> matching.test( ref.model() ) )
+ List<T> models = modelModules.stream()
+ .filter( matching )
.filter( new SameVisibility<>() )
.distinct()
.collect( Collectors.toList() );
@@ -520,19 +479,19 @@ public class TypeLookupImpl
* This Predicate will filter out all Models that doesn't have the same visisbility as the first one.
*/
private class SameVisibility<T extends ModelDescriptor>
- implements Predicate<ModelModule<T>>
+ implements Predicate<T>
{
private Visibility current = null;
@Override
- public boolean test( ModelModule<T> model )
+ public boolean test( T model )
{
if( current == null )
{
- current = model.model().visibility();
+ current = model.visibility();
return true;
}
- return current == model.model().visibility();
+ return current == model.visibility();
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
index ebf4b9c..7d1df94 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
@@ -17,50 +17,51 @@ package org.apache.zest.runtime.structure;
import java.util.List;
import java.util.stream.Stream;
import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.object.ObjectDescriptor;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.spi.structure.ModelModule;
/**
* JAVADOC
*/
public final class UsedLayersInstance
{
- private final List<LayerInstance> usedLayerInstances;
+ private final List<LayerDescriptor> usedLayerInstances;
- public UsedLayersInstance( List<LayerInstance> usedLayerInstances )
+ public UsedLayersInstance( List<LayerDescriptor> usedLayerInstances )
{
this.usedLayerInstances = usedLayerInstances;
}
- /* package */ Stream<ModelModule<ObjectDescriptor>> visibleObjects()
+ Stream<? extends ObjectDescriptor> visibleObjects()
{
return usedLayerInstances.stream()
.flatMap( layerInstance -> layerInstance.visibleObjects( Visibility.application ) );
}
- /* package */ Stream<ModelModule<TransientDescriptor>> visibleTransients()
+ Stream<? extends TransientDescriptor> visibleTransients()
{
return usedLayerInstances.stream()
.flatMap( layerInstance -> layerInstance.visibleTransients( Visibility.application ) );
}
- /* package */ Stream<ModelModule<EntityDescriptor>> visibleEntities()
+ Stream<? extends EntityDescriptor> visibleEntities()
{
return usedLayerInstances.stream()
.flatMap( layerInstance -> layerInstance.visibleEntities( Visibility.application ) );
}
- /* package */ Stream<ModelModule<ValueDescriptor>> visibleValues()
+ Stream<? extends ValueDescriptor> visibleValues()
{
return usedLayerInstances.stream()
.flatMap( layerInstance -> layerInstance.visibleValues( Visibility.application ) );
}
- /* package */ Stream<ServiceReference<?>> visibleServices()
+ Stream<? extends ModelDescriptor> visibleServices()
{
return usedLayerInstances.stream()
.flatMap( layerInstance -> layerInstance.visibleServices( Visibility.application ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
index 1f098a9..a00c53e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersModel.java
@@ -15,6 +15,8 @@
package org.apache.zest.runtime.structure;
import java.util.List;
+import java.util.stream.Stream;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.UsedLayersDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
@@ -33,9 +35,9 @@ public final class UsedLayersModel
}
@Override
- public Iterable<LayerModel> layers()
+ public Stream<? extends LayerDescriptor> layers()
{
- return usedLayers;
+ return usedLayers.stream();
}
@Override
@@ -56,7 +58,7 @@ public final class UsedLayersModel
return visitor.visitLeave( this );
}
- public UsedLayersInstance newInstance( List<LayerInstance> usedLayerInstances )
+ public UsedLayersInstance newInstance( List<LayerDescriptor> usedLayerInstances )
{
return new UsedLayersInstance( usedLayerInstances );
}
[07/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index 6174483..fed3812 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -32,9 +32,10 @@ import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.qualifier.Tagged;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.util.Dates;
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.ValueDeserializer;
import org.apache.zest.api.value.ValueSerialization;
@@ -72,7 +73,10 @@ public class DefaultRequestReader
{
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultRequestReader.class );
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private ValueBuilderFactory vbf;
@Service
@Tagged( ValueSerialization.Formats.JSON )
@@ -187,7 +191,7 @@ public class DefaultRequestReader
"Bug in Restlet encountered; notify developers!" );
}
- Object command = module.newValueFromSerializedState( commandType, json );
+ Object command = vbf.newValueFromSerializedState( commandType, json );
args[0] = command;
return args;
}
@@ -209,8 +213,7 @@ public class DefaultRequestReader
Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
Form entityAsForm;
- if( representation != null
- && !EmptyRepresentation.class.isInstance( representation )
+ if( !EmptyRepresentation.class.isInstance( representation )
&& representation.isAvailable() )
{
entityAsForm = new Form( representation );
@@ -234,8 +237,7 @@ public class DefaultRequestReader
{
Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
Form entityAsForm;
- if( representation != null
- && !EmptyRepresentation.class.isInstance( representation )
+ if( !EmptyRepresentation.class.isInstance( representation )
&& representation.isAvailable() )
{
entityAsForm = new Form( representation );
@@ -245,8 +247,8 @@ public class DefaultRequestReader
entityAsForm = new Form();
}
- args[0] = module.currentUnitOfWork().get( method.getParameterTypes()[0],
- getValue( "entity", queryAsForm, entityAsForm ) );
+ args[0] = uowf.currentUnitOfWork().get( method.getParameterTypes()[0],
+ getValue( "entity", queryAsForm, entityAsForm ) );
return args;
}
@@ -254,8 +256,7 @@ public class DefaultRequestReader
{
Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
Form entityAsForm;
- if( representation != null
- && !EmptyRepresentation.class.isInstance( representation )
+ if( !EmptyRepresentation.class.isInstance( representation )
&& representation.isAvailable() )
{
entityAsForm = new Form( representation );
@@ -278,13 +279,9 @@ public class DefaultRequestReader
final Form entityAsForm
)
{
- ValueBuilder<? extends ValueComposite> builder = module.newValueBuilderWithState(
+ ValueBuilder<? extends ValueComposite> builder = vbf.newValueBuilderWithState(
valueType,
- new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor propertyDescriptor )
- {
+ (Function<PropertyDescriptor, Object>) propertyDescriptor -> {
Parameter param = queryAsForm.getFirst( propertyDescriptor.qualifiedName().name() );
if( param == null )
@@ -309,39 +306,28 @@ public class DefaultRequestReader
}
return null;
- }
},
- new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() );
+ (Function<AssociationDescriptor, EntityReference>) associationDescriptor -> {
+ Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() );
- if( param == null )
- {
- param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() );
- }
+ if( param == null )
+ {
+ param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() );
+ }
- if( param != null )
- {
- return EntityReference.parseEntityReference( param.getValue() );
- }
- else
- {
- return null;
- }
+ if( param != null )
+ {
+ return EntityReference.parseEntityReference( param.getValue() );
}
- },
- new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
+ else
{
- // TODO
- return Iterables.empty();
+ return null;
}
},
+ (Function<AssociationDescriptor, Iterable<EntityReference>>) associationDescriptor -> {
+ // TODO
+ return Iterables.empty();
+ },
new Function<AssociationDescriptor, Map<String, EntityReference>>()
{
@Override
@@ -470,7 +456,7 @@ public class DefaultRequestReader
}
else if( parameterType.isInterface() )
{
- arg = module.currentUnitOfWork().get( parameterType, argString );
+ arg = uowf.currentUnitOfWork().get( parameterType, argString );
}
else
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
index aa28069..206c71f 100644
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
@@ -19,9 +19,17 @@ package org.apache.zest.library.rest.admin;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.*;
-import org.restlet.*;
+import org.apache.zest.api.object.ObjectFactory;
+import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.restlet.Application;
+import org.restlet.Context;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.Restlet;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.restlet.resource.Finder;
@@ -34,7 +42,10 @@ public class RestApplication
public static final MediaType APPLICATION_SPARQL_JSON = new MediaType( "application/sparql-results+json", "SPARQL JSON" );
@Structure
- private Module module;
+ private ObjectFactory objectFactory;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
public RestApplication( @Uses Context parentContext )
{
@@ -48,7 +59,7 @@ public class RestApplication
@Override
public void handle( Request request, Response response )
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
super.handle( request, response );
@@ -96,7 +107,7 @@ public class RestApplication
private Finder newFinder( Class<? extends ServerResource> resource )
{
- Finder finder = module.newObject( Finder.class );
+ Finder finder = objectFactory.newObject( Finder.class );
finder.setTargetClass( resource );
return finder;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
index 543ecf3..bb75c84 100644
--- a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
@@ -27,8 +27,6 @@ import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.entity.EntityBuilder;
@@ -42,14 +40,19 @@ import org.apache.zest.bootstrap.ApplicationAssemblerAdapter;
import org.apache.zest.bootstrap.Assembler;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.Before;
+import org.junit.Test;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
public class RestTest
extends AbstractZestTest
@@ -59,18 +62,20 @@ public class RestTest
protected ApplicationDescriptor newApplication()
throws AssemblyException
{
- return zest.newApplicationModel( new ApplicationAssemblerAdapter( new Assembler[][][]
- {
+ return zest.newApplicationModel( new ApplicationAssemblerAdapter(
+ new Assembler[][][]
{
{
- RestTest.this,
- new RestAssembler(),
- new RdfMemoryStoreAssembler()
+ {
+ RestTest.this,
+ new RestAssembler(),
+ new RdfMemoryStoreAssembler(),
+ new DefaultUnitOfWorkAssembler()
+ }
}
- }
- } )
- {
- } );
+ } )
+ {} // subclassing ApplicationAssemblerAdapter
+ );
}
@Override
@@ -90,7 +95,7 @@ public class RestTest
throws Exception
{
super.setUp();
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, "P2" );
@@ -141,7 +146,7 @@ public class RestTest
properties.put( "firstname", "Jack" );
properties.put( "lastname", "Doe" );
restTester.putEntity( "P1", properties );
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
try
{
PersonEntity entity = work.get( PersonEntity.class, "P1" );
@@ -161,7 +166,7 @@ public class RestTest
{
RestTester restTester = module.newObject( RestTester.class );
restTester.deleteEntity( "P1" );
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
try
{
PersonEntity entity = null;
@@ -191,10 +196,10 @@ public class RestTest
assertThat(
"Returned RDF", result,
anyOf(
- equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
- equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
- equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ),
- equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ) ) );
+ equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
+ equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
+ equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ),
+ equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ) ) );
}
public static class RestTester
@@ -214,7 +219,8 @@ public class RestTest
int status = client.executeMethod( method );
if( status != 200 )
{
- throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+ throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+ .getStatusText() + "'" );
}
InputStream input = method.getResponseBodyAsStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -241,7 +247,8 @@ public class RestTest
int status = client.executeMethod( method );
if( status != 205 )
{
- throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+ throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+ .getStatusText() + "'" );
}
}
finally
@@ -260,7 +267,8 @@ public class RestTest
int status = client.executeMethod( method );
if( status != 204 )
{
- throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+ throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+ .getStatusText() + "'" );
}
}
finally
@@ -280,7 +288,8 @@ public class RestTest
int status = client.executeMethod( method );
if( status != 200 )
{
- throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+ throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+ .getStatusText() + "'" );
}
InputStream input = method.getResponseBodyAsStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -320,5 +329,4 @@ public class RestTest
@Optional
Association<Person> mother();
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
index 8510645..87e0963 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
@@ -48,9 +48,6 @@ import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propa
* any ordinary {@link org.apache.zest.api.entity.EntityComposite}. There is also a {@link Schedules}
* entity composite that has Associations to all active, completed and cancelled schedules.
* </p>
- * <p>
- *
- * </p>
*/
@Concerns( UnitOfWorkConcern.class )
public interface Scheduler
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
index b4a2b4d..4708239 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
@@ -24,19 +24,19 @@ import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
import org.apache.zest.library.scheduler.internal.Schedules;
-@Mixins(SchedulesHandler.SchedulesHandlerMixin.class)
+@Mixins( SchedulesHandler.SchedulesHandlerMixin.class )
public interface SchedulesHandler
{
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY)
+ @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
Schedules getActiveSchedules();
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY)
+ @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
Schedules getCancelledSchedules();
class SchedulesHandlerMixin implements SchedulesHandler
@@ -45,18 +45,18 @@ public interface SchedulesHandler
private Identity me;
@Structure
- private Module module;
+ private UnitOfWorkFactory module;
@Override
public Schedules getActiveSchedules()
{
- return getOrCreateSchedules(getActiveSchedulesIdentity());
+ return getOrCreateSchedules( getActiveSchedulesIdentity() );
}
@Override
public Schedules getCancelledSchedules()
{
- return getOrCreateSchedules(getCancelledSchedulesIdentity());
+ return getOrCreateSchedules( getCancelledSchedulesIdentity() );
}
public String getActiveSchedulesIdentity()
@@ -69,7 +69,8 @@ public interface SchedulesHandler
return "Schedules-Cancelled:" + me.identity().get();
}
- private Schedules getOrCreateSchedules( String identity ){
+ private Schedules getOrCreateSchedules( String identity )
+ {
UnitOfWork uow = module.currentUnitOfWork();
Schedules schedules;
try
@@ -82,8 +83,6 @@ public interface SchedulesHandler
schedules = uow.newEntity( Schedules.class, identity );
}
return schedules;
-
}
-
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
index 27c7125..3eb93b4 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
@@ -23,14 +23,14 @@ package org.apache.zest.library.scheduler.defaults;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.scheduler.CronSchedule;
import org.apache.zest.library.scheduler.OnceSchedule;
+import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.ScheduleFactory;
+import org.apache.zest.library.scheduler.SchedulerService;
+import org.apache.zest.library.scheduler.Task;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.joda.time.DateTime;
import org.slf4j.Logger;
@@ -42,7 +42,7 @@ public class DefaultScheduleFactoryMixin
private static final Logger logger = LoggerFactory.getLogger( ScheduleFactory.class );
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Service
private SchedulerService scheduler;
@@ -64,7 +64,7 @@ public class DefaultScheduleFactoryMixin
private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
CronSchedule instance = builder.instance();
instance.task().set( task );
@@ -78,7 +78,7 @@ public class DefaultScheduleFactoryMixin
private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );
OnceSchedule builderInstance = builder.instance();
builderInstance.task().set( task );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index 1925ac6..e3b9312 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@ -27,15 +27,14 @@ import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.apache.zest.api.concern.Concerns;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.configuration.Configuration;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.scheduler.Schedule;
import org.apache.zest.library.scheduler.Scheduler;
import org.apache.zest.library.scheduler.SchedulerConfiguration;
@@ -66,7 +65,10 @@ public interface Execution
private final Object lock = new Object();
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private TransientBuilderFactory tbf;
@This
private Scheduler scheduler;
@@ -164,7 +166,7 @@ public interface Execution
{
long now = System.currentTimeMillis();
- try (UnitOfWork uow = module.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
+ try (UnitOfWork uow = uowf.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
{
submitTaskForExecution( oldScheduleTime );
Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
@@ -196,7 +198,7 @@ public interface Execution
private void submitTaskForExecution( ScheduleTime scheduleTime )
{
- Runnable taskRunner = module.newTransient( Runnable.class, scheduleTime );
+ Runnable taskRunner = tbf.newTransient( Runnable.class, scheduleTime );
this.taskExecutor.submit( taskRunner );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
index 4f2272b..75212fe 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
@@ -24,10 +24,10 @@ import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.library.scheduler.Scheduler;
import org.apache.zest.library.scheduler.SchedulerConfiguration;
@@ -50,7 +50,7 @@ public class SchedulerMixin
private ScheduleFactory scheduleFactory;
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@This
private SchedulerService me;
@@ -120,7 +120,7 @@ public class SchedulerMixin
@Override
public void cancelSchedule( String scheduleId )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Schedule schedule;
try
{
@@ -153,7 +153,7 @@ public class SchedulerMixin
private void loadSchedules()
throws UnitOfWorkCompletionException
{
- try (UnitOfWork ignored = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Initialize Schedules" ) ))
+ try (UnitOfWork ignored = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Initialize Schedules" ) ))
{
Schedules schedules = schedulesHandler.getActiveSchedules();
for( Schedule schedule : schedules.schedules() )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
index fa52d73..fd88d9a 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
@@ -24,11 +24,11 @@ import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.library.scheduler.Task;
import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.Task;
public class TaskRunner
implements Runnable
@@ -36,7 +36,7 @@ public class TaskRunner
private static ReentrantLock lock = new ReentrantLock();
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Uses
private ScheduleTime schedule;
@@ -45,7 +45,7 @@ public class TaskRunner
public void run()
{
// TODO: (niclas) I am NOT happy with this implementation, requiring 3 UnitOfWorks to be created. 15-20 milliseconds on my MacBook. If there is a better way to detect overrun, two of those might not be needed.
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner initialize" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner initialize" ) );
try
{
lock.lock();
@@ -58,14 +58,14 @@ public class TaskRunner
schedule.running().set( true );
uow.complete(); // This completion is needed to detect overrun
- uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner" ) );
+ uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner" ) );
schedule = uow.get( schedule ); // re-attach the entity to the new UnitOfWork
Task task = schedule.task().get();
lock.unlock();
task.run();
lock.lock();
uow.complete();
- uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner conclude" ) );
+ uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner conclude" ) );
schedule = uow.get( schedule ); // re-attach the entity to the new UnitOfWork
schedule.running().set( false );
schedule.taskCompletedSuccessfully();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
index ed999fd..8b7dff9 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
@@ -48,7 +48,7 @@ public class CronScheduleTest extends AbstractZestTest
throws Exception
{
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
EntityBuilder<Task> builder1 = work.newEntityBuilder( Task.class );
builder1.instance().name().set( "abc" );
Task task = builder1.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index 15a356c..f2c8fc6 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -73,14 +73,14 @@ public class SchedulerTest
{
Usecase usecase = UsecaseBuilder.newUsecase( "testTask" );
String taskId;
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
FooTask task = createFooTask( uow, "TestTask", BAZAR );
taskId = task.identity().get();
task.run();
uow.complete();
}
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
FooTask task = uow.get( FooTask.class, taskId );
assertThat( task.runCounter().get(), equalTo( 1 ) );
@@ -96,7 +96,7 @@ public class SchedulerTest
DateTime start = new DateTime();
String taskIdentity;
long sleepMillis;
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
Scheduler scheduler = module.findService( Scheduler.class ).get();
@@ -117,7 +117,7 @@ public class SchedulerTest
.until( taskOutput( taskIdentity ), equalTo( 1 ) );
//noinspection unused
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
Timeline timeline = module.findService( Timeline.class ).get();
DateTime now = new DateTime();
@@ -153,7 +153,7 @@ public class SchedulerTest
Schedule schedule2;
Schedule schedule3;
Schedule schedule4;
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
FooTask task = createFooTask( uow, usecase.name(), BAZAR );
taskIdentity = task.identity().get();
@@ -169,7 +169,7 @@ public class SchedulerTest
.atMost( 6, SECONDS )
.until( taskOutput( taskIdentity ), equalTo( 4 ) );
- try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
schedule1 = uow.get( schedule1 );
schedule2 = uow.get( schedule2 );
@@ -193,7 +193,7 @@ public class SchedulerTest
private Callable<Integer> taskOutput( final String taskIdentity )
{
return () -> {
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
FooTask task = uow.get( FooTask.class, taskIdentity );
Integer count = task.runCounter().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
index 2b26353..6e52b7d 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
@@ -33,9 +33,10 @@ import org.apache.zest.api.configuration.Configuration;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.shiro.Shiro;
import org.apache.zest.library.shiro.domain.permissions.RoleAssignee;
import org.slf4j.Logger;
@@ -45,14 +46,17 @@ import static org.apache.zest.api.query.QueryExpressions.eq;
import static org.apache.zest.api.query.QueryExpressions.templateFor;
public class PasswordRealmMixin
- extends AuthorizingRealm
- implements Realm, Authorizer, PasswordService, ServiceActivation
+ extends AuthorizingRealm
+ implements Realm, Authorizer, PasswordService, ServiceActivation
{
private static final Logger LOG = LoggerFactory.getLogger( Shiro.LOGGER_NAME );
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private QueryBuilderFactory qbf;
@This
private Configuration<PasswordRealmConfiguration> configuration;
@@ -70,18 +74,21 @@ public class PasswordRealmMixin
@Override
public void activateService()
- throws Exception
+ throws Exception
{
configuration.refresh();
PasswordRealmConfiguration config = configuration.get();
String algorithm = config.hashAlgorithmName().get();
Integer iterations = config.hashIterationsCount().get();
- if ( algorithm != null || iterations != null ) {
- DefaultHashService hashService = ( DefaultHashService ) passwordService.getHashService();
- if ( algorithm != null ) {
+ if( algorithm != null || iterations != null )
+ {
+ DefaultHashService hashService = (DefaultHashService) passwordService.getHashService();
+ if( algorithm != null )
+ {
hashService.setHashAlgorithmName( algorithm );
}
- if ( iterations != null ) {
+ if( iterations != null )
+ {
hashService.setHashIterations( iterations );
}
}
@@ -89,13 +96,13 @@ public class PasswordRealmMixin
@Override
public void passivateService()
- throws Exception
+ throws Exception
{
}
@Override
public String encryptPassword( Object plaintextPassword )
- throws IllegalArgumentException
+ throws IllegalArgumentException
{
return passwordService.encryptPassword( plaintextPassword );
}
@@ -108,21 +115,25 @@ public class PasswordRealmMixin
@Override
protected AuthenticationInfo doGetAuthenticationInfo( AuthenticationToken token )
- throws AuthenticationException
+ throws AuthenticationException
{
- UnitOfWork uow = module.newUnitOfWork();
- try {
+ UnitOfWork uow = uowf.newUnitOfWork();
+ try
+ {
- String username = ( ( UsernamePasswordToken ) token ).getUsername();
+ String username = ( (UsernamePasswordToken) token ).getUsername();
PasswordSecurable account = findPasswordSecurable( uow, username );
- if ( account == null ) {
+ if( account == null )
+ {
LOG.debug( "Unknown subject identifier: {}" + username );
return null;
}
LOG.debug( "Found account for {}: {}", username, account );
- return new SimpleAuthenticationInfo( account.subjectIdentifier().get(), account.password().get(), getName() );
-
- } finally {
+ return new SimpleAuthenticationInfo( account.subjectIdentifier().get(), account.password()
+ .get(), getName() );
+ }
+ finally
+ {
uow.discard();
}
}
@@ -130,12 +141,14 @@ public class PasswordRealmMixin
@Override
protected AuthorizationInfo doGetAuthorizationInfo( PrincipalCollection principals )
{
- UnitOfWork uow = module.newUnitOfWork();
- try {
+ UnitOfWork uow = uowf.newUnitOfWork();
+ try
+ {
String username = getAvailablePrincipal( principals ).toString();
RoleAssignee roleAssignee = findRoleAssignee( uow, username );
- if ( roleAssignee == null ) {
+ if( roleAssignee == null )
+ {
LOG.debug( "No authorization info for {}", username );
return null;
}
@@ -147,24 +160,24 @@ public class PasswordRealmMixin
SimpleAuthorizationInfo atzInfo = new SimpleAuthorizationInfo( roleNames );
atzInfo.setStringPermissions( permissionStrings );
return atzInfo;
-
- } finally {
+ }
+ finally
+ {
uow.discard();
}
}
private PasswordSecurable findPasswordSecurable( UnitOfWork uow, String username )
{
- QueryBuilder<PasswordSecurable> builder = module.newQueryBuilder( PasswordSecurable.class );
+ QueryBuilder<PasswordSecurable> builder = qbf.newQueryBuilder( PasswordSecurable.class );
builder = builder.where( eq( templateFor( PasswordSecurable.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
private RoleAssignee findRoleAssignee( UnitOfWork uow, String username )
{
- QueryBuilder<RoleAssignee> builder = module.newQueryBuilder( RoleAssignee.class );
+ QueryBuilder<RoleAssignee> builder = qbf.newQueryBuilder( RoleAssignee.class );
builder = builder.where( eq( templateFor( RoleAssignee.class ).subjectIdentifier(), username ) );
return uow.newQuery( builder ).find();
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
index f8fc925..e4c0282 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
@@ -21,8 +21,8 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Property;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
@Mixins( Role.Mixin.class )
public interface Role
@@ -41,7 +41,7 @@ public interface Role
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@This
private Role role;
@@ -49,7 +49,7 @@ public interface Role
@Override
public RoleAssignment assignTo( RoleAssignee assignee )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<RoleAssignment> builder = uow.newEntityBuilder( RoleAssignment.class );
RoleAssignment assignment = builder.instance();
assignment.assignee().set( assignee );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
index 87f6b68..4b5b555 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
@@ -23,8 +23,8 @@ import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.functional.Iterables;
@Mixins( RoleFactory.Mixin.class )
@@ -41,7 +41,7 @@ public interface RoleFactory
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public Role create( String name, String... permissions )
@@ -52,7 +52,7 @@ public interface RoleFactory
@Override
public Role create( String name, Iterable<String> permissions )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Role> roleBuilder = uow.newEntityBuilder( Role.class );
Role role = roleBuilder.instance();
role.name().set( name );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
index 90f9d87..35a9ceb 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
@@ -17,6 +17,7 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.PasswordService;
import org.apache.shiro.subject.Subject;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Test;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.entity.EntityBuilder;
@@ -65,7 +66,7 @@ public class PasswordDomainTest
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Service
private PasswordService passwordService;
@@ -73,7 +74,7 @@ public class PasswordDomainTest
@Override
public User createNewUser( String username, String password )
{
- EntityBuilder<User> userBuilder = module.currentUnitOfWork().newEntityBuilder( User.class );
+ EntityBuilder<User> userBuilder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
User user = userBuilder.instance();
user.subjectIdentifier().set( username );
user.password().set( passwordService.encryptPassword( password ) );
@@ -116,7 +117,7 @@ public class PasswordDomainTest
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
UserFactory userFactory = module.findService( UserFactory.class ).get();
// START SNIPPET: usage
@@ -125,7 +126,7 @@ public class PasswordDomainTest
// END SNIPPET: usage
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
// START SNIPPET: usage
Subject currentUser = SecurityUtils.getSubject();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
index 8fcb885..a436896 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
@@ -17,6 +17,7 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.PasswordService;
import org.apache.shiro.subject.Subject;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.common.Visibility;
@@ -69,7 +70,7 @@ public class PermissionsDomainTest
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Service
private PasswordService passwordService;
@@ -77,7 +78,7 @@ public class PermissionsDomainTest
@Override
public User createNewUser( String username, String password )
{
- EntityBuilder<User> userBuilder = module.currentUnitOfWork().newEntityBuilder( User.class );
+ EntityBuilder<User> userBuilder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
User user = userBuilder.instance();
user.subjectIdentifier().set( username );
user.password().set( passwordService.encryptPassword( password ) );
@@ -129,7 +130,7 @@ public class PermissionsDomainTest
throws UnitOfWorkCompletionException
{
// START SNIPPET: usage
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
User user = userFactory.createNewUser( "foo", "bar" );
Role role = roleFactory.create( "role-one", "permission-one", "permission-two" );
@@ -139,7 +140,7 @@ public class PermissionsDomainTest
// END SNIPPET: usage
// START SNIPPET: usage
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Subject currentUser = SecurityUtils.getSubject();
currentUser.login( new UsernamePasswordToken( "foo", "bar" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
index e3202de..8555f14 100644
--- a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
+++ b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import javax.sql.DataSource;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationEvent;
import org.apache.zest.api.activation.ActivationEventListener;
@@ -86,6 +87,8 @@ public class LiquibaseServiceTest
// END SNIPPET: assembly
module.forMixin( LiquibaseConfiguration.class ).declareDefaults().enabled().set( true );
module.forMixin( LiquibaseConfiguration.class ).declareDefaults().changeLog().set( "changelog.xml" );
+
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
index 5774fd4..93fa811 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
@@ -27,10 +27,10 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.service.ImportedServiceDescriptor;
import org.apache.zest.api.service.ServiceImporter;
import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.library.circuitbreaker.CircuitBreaker;
import org.apache.zest.library.conversion.values.EntityToValue;
@@ -43,14 +43,14 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
protected static final Logger LOGGER = LoggerFactory.getLogger( AbstractDataSourceServiceImporterMixin.class );
- private final Map<String, DataSourceConfigurationValue> configs = new HashMap<String, DataSourceConfigurationValue>();
+ private final Map<String, DataSourceConfigurationValue> configs = new HashMap<>();
- private final Map<String, PooledDataSourceType> pools = new HashMap<String, PooledDataSourceType>();
+ private final Map<String, PooledDataSourceType> pools = new HashMap<>();
- private final Map<DataSource, CircuitBreaker> circuitBreakers = new HashMap<DataSource, CircuitBreaker>();
+ private final Map<DataSource, CircuitBreaker> circuitBreakers = new HashMap<>();
@Structure
- protected Module module;
+ protected UnitOfWorkFactory uowf;
@Service
private EntityToValue entityToValue;
@@ -126,7 +126,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
{
DataSourceConfigurationValue config = configs.get( identity );
if ( config == null ) {
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Create DataSource pool configuration" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Create DataSource pool configuration" ) );
try {
DataSourceConfiguration configEntity = uow.get( DataSourceConfiguration.class, identity );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
index 11e5ce5..03c04ce 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
@@ -54,6 +54,7 @@ import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.sql.datasource.DataSourceConfiguration;
import org.apache.zest.spi.ZestSPI;
@@ -98,7 +99,7 @@ public interface DataSourceConfigurationManagerService
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
@Service
MBeanServer server;
@@ -177,7 +178,7 @@ public interface DataSourceConfigurationManagerService
public Object getAttribute( String name )
throws AttributeNotFoundException, MBeanException, ReflectionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try {
EntityComposite configuration = uow.get( EntityComposite.class, identity );
AssociationStateHolder state = spi.stateOf( configuration );
@@ -195,7 +196,7 @@ public interface DataSourceConfigurationManagerService
public void setAttribute( Attribute attribute )
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try {
EntityComposite configuration = uow.get( EntityComposite.class, identity );
AssociationStateHolder state = spi.stateOf( configuration );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
index 7af957c..e7a6f36 100644
--- a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
+++ b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
@@ -18,6 +18,7 @@ import java.beans.PropertyVetoException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Assert;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -68,7 +69,7 @@ public class DataSourceConfigurationManagerServiceTest
public void testDataSources()
throws ActivationException, AssemblyException
{
- SingletonAssembler assembler = new SingletonAssembler()
+ new SingletonAssembler()
{
@Override
public void assemble( ModuleAssembly module )
@@ -79,11 +80,13 @@ public class DataSourceConfigurationManagerServiceTest
// Create in-memory store for configurations
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
+
// Set up DataSource service that will manage the connection pools
new DBCPDataSourceServiceAssembler().identifiedBy( "datasource-service" ).visibleIn( Visibility.layer ).assemble( module );
{
- ModuleAssembly testModule = module.layer().module( "TestDS" );
+ ModuleAssembly testModule = module.layer().module( "TestDS" ).withDefaultUnitOfWorkFactory();
// Create a specific DataSource that uses the "datasource" service to do the main work
new DataSourceAssembler().
@@ -101,7 +104,7 @@ public class DataSourceConfigurationManagerServiceTest
}
{
- ModuleAssembly testModule2 = module.layer().module( "TestDS2" );
+ ModuleAssembly testModule2 = module.layer().module( "TestDS2" ).withDefaultUnitOfWorkFactory();
// Create another specific DataSource that uses the "datasource" service to do the main work
// Use DataSourceAssembler to assemble the DataSource.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
index 3dcb80a..8cdc5de 100644
--- a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
+++ b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
@@ -30,10 +30,10 @@ import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceActivation;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.fileconfig.FileConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public interface UoWFileFactory
private Application app;
@Structure
- private Module module;
+ private UnitOfWorkFactory module;
@This
private ServiceComposite me;
@@ -181,5 +181,4 @@ public interface UoWFileFactory
return uowMeta;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
index 81a57f9..58e4703 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.concern.Concerns;
@@ -31,7 +32,6 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Property;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
@@ -105,7 +105,7 @@ public class HasUoWFileTest
implements TestService
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void modifyFile( String entityId )
@@ -148,7 +148,7 @@ public class HasUoWFileTest
private void modifyFileImmediatly( String entityId )
throws IOException
{
- TestedEntity entity = module.currentUnitOfWork().get( TestedEntity.class, entityId );
+ TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId );
// START SNIPPET: api
File attachedFile = entity.attachedFile();
File managedFile = entity.managedFile();
@@ -190,7 +190,7 @@ public class HasUoWFileTest
File attachedFile;
// Test discarded creation
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Creation Rollback" );
attachedFile = entity.attachedFile();
@@ -198,7 +198,7 @@ public class HasUoWFileTest
assertFalse( "File still exists after discarded creation UoW", attachedFile.exists() );
// Test completed creation
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Creation" );
attachedFile = entity.attachedFile();
@@ -216,7 +216,7 @@ public class HasUoWFileTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Modification" );
entityId = entity.identity().get();
@@ -225,14 +225,14 @@ public class HasUoWFileTest
}
// Testing discarded modification
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testService.modifyFile( entityId );
}
assertTrue( "File content after discarded modification was not the good one", isFileFirstLineEqualsTo( attachedFile, "Creation" ) );
// Testing completed modification
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testService.modifyFile( entityId );
uow.complete();
@@ -249,7 +249,7 @@ public class HasUoWFileTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Deletion" );
entityId = entity.identity().get();
@@ -258,7 +258,7 @@ public class HasUoWFileTest
}
// Testing discarded deletion
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = uow.get( TestedEntity.class, entityId );
uow.remove( entity );
@@ -266,7 +266,7 @@ public class HasUoWFileTest
assertTrue( "File do not exists after discarded deletion", attachedFile.exists() );
// Testing completed deletion
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = uow.get( TestedEntity.class, entityId );
uow.remove( entity );
@@ -283,7 +283,7 @@ public class HasUoWFileTest
final String entityId;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Concurrent Modification" );
entityId = entity.identity().get();
@@ -294,11 +294,11 @@ public class HasUoWFileTest
UnitOfWork uow, uow2;
TestedEntity entity;
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
entity = uow.get( TestedEntity.class, entityId );
Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile() ) );
- uow2 = module.newUnitOfWork();
+ uow2 = uowf.newUnitOfWork();
entity = uow2.get( TestedEntity.class, entityId );
Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile() ) );
@@ -323,7 +323,7 @@ public class HasUoWFileTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedEntity( uow, "Testing Concurrent Modification" );
entityId = entity.identity().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
index 782db07..7c0418c 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.concern.Concerns;
@@ -121,7 +122,7 @@ public class HasUoWFilesTest
implements TestService
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void modifyFile( String entityId )
@@ -164,7 +165,7 @@ public class HasUoWFilesTest
private void modifyFileImmediatly( String entityId )
throws IOException
{
- TestedEntity entity = module.currentUnitOfWork().get( TestedEntity.class, entityId );
+ TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId );
// START SNIPPET: api
File attachedFileTwo = entity.attachedFile( MyEnum.fileTwo );
File managedFileOne = entity.managedFile( MyEnum.fileOne );
@@ -205,7 +206,7 @@ public class HasUoWFilesTest
File attachedFile;
// Test discarded creation
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Creation Rollback" );
attachedFile = entity.attachedFile( MyEnum.fileOne );
@@ -213,7 +214,7 @@ public class HasUoWFilesTest
assertFalse( "File still exists after discarded creation UoW", attachedFile.exists() );
// Test completed creation
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Creation" );
attachedFile = entity.attachedFile( MyEnum.fileOne );
@@ -231,7 +232,7 @@ public class HasUoWFilesTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Modification" );
entityId = entity.identity().get();
@@ -240,14 +241,14 @@ public class HasUoWFilesTest
}
// Testing discarded modification
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testService.modifyFile( entityId );
}
assertTrue( "File content after discarded modification was not the good one", isFileFirstLineEqualsTo( attachedFile, "Creation" ) );
// Testing completed modification
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testService.modifyFile( entityId );
uow.complete();
@@ -264,7 +265,7 @@ public class HasUoWFilesTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Deletion" );
entityId = entity.identity().get();
@@ -273,7 +274,7 @@ public class HasUoWFilesTest
}
// Testing discarded deletion
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = uow.get( TestedEntity.class, entityId );
uow.remove( entity );
@@ -281,7 +282,7 @@ public class HasUoWFilesTest
assertTrue( "File do not exists after discarded deletion", attachedFile.exists() );
// Testing completed deletion
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = uow.get( TestedEntity.class, entityId );
uow.remove( entity );
@@ -298,7 +299,7 @@ public class HasUoWFilesTest
final String entityId;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Concurrent Modification" );
entityId = entity.identity().get();
@@ -309,11 +310,11 @@ public class HasUoWFilesTest
UnitOfWork uow, uow2;
TestedEntity entity;
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
entity = uow.get( TestedEntity.class, entityId );
Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile( MyEnum.fileOne ) ) );
- uow2 = module.newUnitOfWork();
+ uow2 = uowf.newUnitOfWork();
entity = uow2.get( TestedEntity.class, entityId );
Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile( MyEnum.fileOne ) ) );
@@ -338,7 +339,7 @@ public class HasUoWFilesTest
File attachedFile;
// Create new
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Concurrent Modification" );
entityId = entity.identity().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java b/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
index 74de20d..03d9d5c 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
@@ -21,12 +21,13 @@ package org.apache.zest.manual.recipes.assemble;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueComposite;
public class Docs
{
@This
- Module module;
+ UnitOfWorkFactory module;
public void showUsage()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
index a6fff15..1abf6c7 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
@@ -20,29 +20,30 @@ package org.apache.zest.manual.recipes.createEntity;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
// START SNIPPET: carFactoryMixin2
// START SNIPPET: carFactoryMixin1
public class CarEntityFactoryMixin
- implements CarEntityFactory
+ implements CarEntityFactory
{
-// END SNIPPET: carFactoryMixin1
+ // END SNIPPET: carFactoryMixin1
@Structure
- Module module;
-// END SNIPPET: carFactoryMixin2
+ UnitOfWorkFactory unitOfWorkFactory;
+
+ // END SNIPPET: carFactoryMixin2
// START SNIPPET: carFactoryMixin3
- public CarEntityFactoryMixin( @Structure Module module )
+ public CarEntityFactoryMixin( @Structure UnitOfWorkFactory unitOfWorkFactory )
{
}
-// END SNIPPET: carFactoryMixin3
+ // END SNIPPET: carFactoryMixin3
// START SNIPPET: createCar
- public Car create(Manufacturer manufacturer, String model)
+ public Car create( Manufacturer manufacturer, String model )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
EntityBuilder<Car> builder = uow.newEntityBuilder( Car.class );
Car prototype = builder.instance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
index 11f76d5..7bb8a31 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
@@ -79,7 +79,7 @@ public interface BaseDataService
throws Exception
{
logger.debug( "CREATING BASIC DATA..." );
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "Open uow for " ) );
+ UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( newUsecase( "Open uow for " ) );
try
{
// UnLocode value objects
@@ -154,7 +154,7 @@ public interface BaseDataService
private Location location( UnLocode unlocode, String locationStr )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
EntityBuilder<Location> location = uow.newEntityBuilder( Location.class, unlocode.code().get() );
location.instance().unLocode().set( unlocode );
location.instance().name().set( locationStr );
@@ -163,7 +163,7 @@ public interface BaseDataService
private Voyage voyage( String voyageNumberStr, Schedule schedule )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
EntityBuilder<Voyage> voyage = uow.newEntityBuilder( Voyage.class, voyageNumberStr );
// VoyageNumber
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
index e10124f..3ac14f5 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
@@ -67,10 +67,10 @@ public class EntityModel<T extends DTO, U extends EntityComposite>
private U loadEntity()
{
- U entity = module.currentUnitOfWork().get( entityClass, identity );
+ U entity = module.unitOfWorkFactory().currentUnitOfWork().get( entityClass, identity );
if( entity == null )
{
- Usecase usecase = module.currentUnitOfWork().usecase();
+ Usecase usecase = module.unitOfWorkFactory().currentUnitOfWork().usecase();
throw new NoSuchEntityException( EntityReference.parseEntityReference( identity ), entityClass, usecase );
}
return entity;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
index 675a164..b22fd46 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
@@ -17,6 +17,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.bootstrap.test;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -58,7 +59,7 @@ public class TestApplication extends BaseData
public TestApplication()
{
super(app.findModule( "BOOTSTRAP", "BOOTSTRAP-Bootstrap" ));
- Context.prepareContextBaseClass( module );
+ Context.prepareContextBaseClass( module.unitOfWorkFactory() );
}
// Printing current test method name to console
@@ -71,20 +72,25 @@ public class TestApplication extends BaseData
{
logger.info( name.getMethodName() );
Usecase usecase = UsecaseBuilder.newUsecase( "Usecase: " + name );
- module.newUnitOfWork(usecase);
+ module.unitOfWorkFactory().newUnitOfWork(usecase);
}
@After
public void concludeTest()
{
- UnitOfWork uow = module.currentUnitOfWork();
+ if( module == null )
+ {
+ return;
+ }
+ UnitOfWorkFactory uowf = module.unitOfWorkFactory();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow != null && uow.isOpen() )
uow.discard();
- if( module != null && module.isUnitOfWorkActive() )
+ if( uowf.isUnitOfWorkActive() )
{
- while( module.isUnitOfWorkActive() )
+ while( uowf.isUnitOfWorkActive() )
{
- uow = module.currentUnitOfWork();
+ uow = uowf.currentUnitOfWork();
if( uow.isOpen() )
{
System.err.println( "UnitOfWork not cleaned up:" + uow.usecase().name() );
[31/34] zest-java git commit: Fixed tests that didn't include
ValueSerialization service.
Posted by ni...@apache.org.
Fixed tests that didn't include ValueSerialization service.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/5c1a4009
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/5c1a4009
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/5c1a4009
Branch: refs/heads/develop
Commit: 5c1a4009018bf8cf4ec428eecc3ac15e756b3936
Parents: e5c57f9
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 23:45:45 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 23:45:45 2016 +0800
----------------------------------------------------------------------
.../eventsourcing/domain/source/helper/EventRouterTest.java | 2 ++
.../library/eventsourcing/domain/source/helper/EventsTest.java | 2 ++
.../eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java | 2 ++
3 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5c1a4009/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
index b8785ee..53b6087 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
@@ -49,6 +50,7 @@ public class EventRouterTest
@Override
public void assemble( ModuleAssembly module ) throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
new DefaultUnitOfWorkAssembler().assemble( module );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5c1a4009/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
index 0402c4f..2c2b9cb 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
@@ -19,6 +19,7 @@
package org.apache.zest.library.eventsourcing.domain.source.helper;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -55,6 +56,7 @@ public class EventsTest
@Override
public void assemble( ModuleAssembly module ) throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
new DefaultUnitOfWorkAssembler().assemble( module );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5c1a4009/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
index 94b1d56..654393c 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
@@ -19,6 +19,7 @@
package org.apache.zest.library.eventsourcing.domain.source.helper;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
@@ -53,6 +54,7 @@ public class UnitOfWorkRouterTest
@Override
public void assemble( ModuleAssembly module ) throws AssemblyException
{
+ module.services( OrgJsonValueSerializationService.class );
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
new DefaultUnitOfWorkAssembler().assemble( module );
}
[17/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
index f34fdd4..5ee9f81 100755
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -42,6 +42,7 @@ import org.apache.zest.api.service.ServiceActivation;
import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.EnumType;
import org.apache.zest.api.type.MapType;
@@ -67,8 +68,6 @@ import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -169,13 +168,13 @@ public class PreferencesEntityStoreMixin
}
@Override
- public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+ public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
{
- return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecase, currentTime );
+ return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecase, currentTime );
}
@Override
- public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+ public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
{
return new Input<EntityState, EntityStoreException>()
{
@@ -192,7 +191,7 @@ public class PreferencesEntityStoreMixin
UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit" );
Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
final EntityStoreUnitOfWork uow =
- newUnitOfWork( visitUsecase, System.currentTimeMillis() );
+ newUnitOfWork( module, visitUsecase, System.currentTimeMillis() );
try
{
@@ -224,7 +223,10 @@ public class PreferencesEntityStoreMixin
}
@Override
- public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference identity )
+ public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
+ ModuleDescriptor module,
+ EntityReference identity
+ )
{
try
{
@@ -241,51 +243,74 @@ public class PreferencesEntityStoreMixin
EntityDescriptor entityDescriptor = module.entityDescriptor( type );
if( entityDescriptor == null )
{
- throw new EntityTypeNotFoundException( type,
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type, module );
}
Map<QualifiedName, Object> properties = new HashMap<>();
final Preferences propsPrefs = entityPrefs.node( "properties" );
- entityDescriptor.state().properties().forEach( persistentPropertyDescriptor ->
- {
- if( persistentPropertyDescriptor.qualifiedName().name().equals( "identity" ) )
+ entityDescriptor.state().properties().forEach(
+ persistentPropertyDescriptor ->
{
- // Fake identity property
- properties.put( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
- }
- else
- {
- ValueType propertyType = persistentPropertyDescriptor.valueType();
- Class<?> mainType = propertyType.mainType();
- if( Number.class.isAssignableFrom( mainType ) )
+ if( persistentPropertyDescriptor.qualifiedName().name().equals( "identity" ) )
{
- if( mainType.equals( Long.class ) )
- {
- properties.put( persistentPropertyDescriptor.qualifiedName(),
- this.getNumber( propsPrefs, persistentPropertyDescriptor, LONG_PARSER ) );
- }
- else if( mainType.equals( Integer.class ) )
- {
- properties.put( persistentPropertyDescriptor.qualifiedName(),
- this.getNumber( propsPrefs, persistentPropertyDescriptor, INT_PARSER ) );
- }
- else if( mainType.equals( Double.class ) )
+ // Fake identity property
+ properties.put( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
+ }
+ else
+ {
+ ValueType propertyType = persistentPropertyDescriptor.valueType();
+ Class<?> mainType = propertyType.mainType();
+ if( Number.class.isAssignableFrom( mainType ) )
{
- properties.put( persistentPropertyDescriptor.qualifiedName(),
- this.getNumber( propsPrefs, persistentPropertyDescriptor, DOUBLE_PARSER ) );
+ if( mainType.equals( Long.class ) )
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(),
+ this.getNumber( propsPrefs, persistentPropertyDescriptor, LONG_PARSER ) );
+ }
+ else if( mainType.equals( Integer.class ) )
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(),
+ this.getNumber( propsPrefs, persistentPropertyDescriptor, INT_PARSER ) );
+ }
+ else if( mainType.equals( Double.class ) )
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(),
+ this.getNumber( propsPrefs, persistentPropertyDescriptor, DOUBLE_PARSER ) );
+ }
+ else if( mainType.equals( Float.class ) )
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(),
+ this.getNumber( propsPrefs, persistentPropertyDescriptor, FLOAT_PARSER ) );
+ }
+ else
+ {
+ // Load as string even though it's a number
+ String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName()
+ .name(), null );
+ Object value;
+ if( json == null )
+ {
+ value = null;
+ }
+ else
+ {
+ value = valueSerialization.deserialize( module, persistentPropertyDescriptor.valueType(), json );
+ }
+ properties.put( persistentPropertyDescriptor.qualifiedName(), value );
+ }
}
- else if( mainType.equals( Float.class ) )
+ else if( mainType.equals( Boolean.class ) )
{
+ Boolean initialValue = (Boolean) persistentPropertyDescriptor.initialValue( module );
properties.put( persistentPropertyDescriptor.qualifiedName(),
- this.getNumber( propsPrefs, persistentPropertyDescriptor, FLOAT_PARSER ) );
+ propsPrefs.getBoolean( persistentPropertyDescriptor.qualifiedName().name(),
+ initialValue == null ? false : initialValue ) );
}
- else
+ else if( propertyType instanceof ValueCompositeType
+ || propertyType instanceof MapType
+ || propertyType instanceof CollectionType
+ || propertyType instanceof EnumType )
{
- // Load as string even though it's a number
String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
Object value;
if( json == null )
@@ -294,58 +319,33 @@ public class PreferencesEntityStoreMixin
}
else
{
- value = valueSerialization.deserialize( persistentPropertyDescriptor.valueType(), json );
+ value = valueSerialization.deserialize( module, persistentPropertyDescriptor.valueType(), json );
}
properties.put( persistentPropertyDescriptor.qualifiedName(), value );
}
- }
- else if( mainType.equals( Boolean.class ) )
- {
- Boolean initialValue = (Boolean) persistentPropertyDescriptor.initialValue( module );
- properties.put( persistentPropertyDescriptor.qualifiedName(),
- propsPrefs.getBoolean( persistentPropertyDescriptor.qualifiedName().name(),
- initialValue == null ? false : initialValue ) );
- }
- else if( propertyType instanceof ValueCompositeType
- || propertyType instanceof MapType
- || propertyType instanceof CollectionType
- || propertyType instanceof EnumType )
- {
- String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
- Object value;
- if( json == null )
- {
- value = null;
- }
else
{
- value = valueSerialization.deserialize( persistentPropertyDescriptor.valueType(), json );
- }
- properties.put( persistentPropertyDescriptor.qualifiedName(), value );
- }
- else
- {
- String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
- if( json == null )
- {
- if( persistentPropertyDescriptor.initialValue( module ) != null )
+ String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
+ if( json == null )
{
- properties.put( persistentPropertyDescriptor.qualifiedName(), persistentPropertyDescriptor
- .initialValue( module ) );
+ if( persistentPropertyDescriptor.initialValue( module ) != null )
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(), persistentPropertyDescriptor
+ .initialValue( module ) );
+ }
+ else
+ {
+ properties.put( persistentPropertyDescriptor.qualifiedName(), null );
+ }
}
else
{
- properties.put( persistentPropertyDescriptor.qualifiedName(), null );
+ Object value = valueSerialization.deserialize( module, propertyType, json );
+ properties.put( persistentPropertyDescriptor.qualifiedName(), value );
}
}
- else
- {
- Object value = valueSerialization.deserialize( propertyType, json );
- properties.put( persistentPropertyDescriptor.qualifiedName(), value );
- }
}
- }
- } );
+ } );
// Associations
Map<QualifiedName, EntityReference> associations = new HashMap<>();
@@ -441,9 +441,7 @@ public class PreferencesEntityStoreMixin
}
Preferences entityPrefs = root.node( identity.identity() );
-
- String version = entityPrefs.get( "version", "" );
- return version;
+ return entityPrefs.get( "version", "" );
}
catch( BackingStoreException e )
{
@@ -515,7 +513,7 @@ public class PreferencesEntityStoreMixin
// Properties
Preferences propsPrefs = entityPrefs.node( "properties" );
state.entityDescriptor().state().properties()
- .filter(property -> ! property.qualifiedName().name().equals( "identity" ))
+ .filter( property -> !property.qualifiedName().name().equals( "identity" ) )
.forEach( persistentProperty ->
{
Object value = state.properties().get( persistentProperty.qualifiedName() );
@@ -573,9 +571,9 @@ public class PreferencesEntityStoreMixin
{
String jsonString = valueSerialization.serialize( value );
propsPrefs.put( persistentProperty.qualifiedName().name(), jsonString );
- }
- }
- });
+ }
+ }
+ } );
// Associations
if( !state.associations().isEmpty() )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
index bbfeb08..2731293 100644
--- a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
+++ b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
@@ -59,7 +59,7 @@ public class RedisMapEntityStoreTest
throws Exception
{
super.setUp();
- RedisMapEntityStoreService es = module.findService( RedisMapEntityStoreService.class ).get();
+ RedisMapEntityStoreService es = serviceFinder.findService( RedisMapEntityStoreService.class ).get();
jedisPool = es.jedisPool();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
index fccd9b0..167932c 100644
--- a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
@@ -55,7 +55,7 @@ public class RedisMapEntityStoreWithCacheTest
throws Exception
{
super.setUp();
- RedisMapEntityStoreService es = module.findService( RedisMapEntityStoreService.class ).get();
+ RedisMapEntityStoreService es = serviceFinder.findService( RedisMapEntityStoreService.class ).get();
jedisPool = es.jedisPool();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
index e0b36ac..ff6c5e6 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
@@ -60,7 +60,7 @@ public class RiakHttpMapEntityStoreTest
throws Exception
{
super.setUp();
- RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+ RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
riakClient = es.riakClient();
bucketKey = es.bucket();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
index 8bd136e..4c3e391 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
@@ -56,7 +56,7 @@ public class RiakMapEntityStoreWithCacheTest
throws Exception
{
super.setUp();
- RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+ RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
riakClient = es.riakClient();
bucketKey = es.bucket();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
index 4c7ac64..34a78fb 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
@@ -60,7 +60,7 @@ public class RiakProtobufMapEntityStoreTest
throws Exception
{
super.setUp();
- RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+ RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
riakClient = es.riakClient();
bucketKey = es.bucket();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
index 95ce3fe..0442a5c 100755
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -40,6 +40,7 @@ import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.service.ServiceActivation;
import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.usecase.Usecase;
@@ -68,8 +69,6 @@ import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
import org.apache.zest.spi.entitystore.helpers.JSONKeys;
import org.apache.zest.spi.entitystore.helpers.Migration;
import org.apache.zest.spi.entitystore.helpers.StateStore;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -229,7 +228,10 @@ public class SQLEntityStoreMixin
}
@Override
- public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference entityRef )
+ public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
+ ModuleDescriptor module,
+ EntityReference entityRef
+ )
{
EntityValueResult valueResult = getValue( entityRef );
DefaultEntityState state = readEntityState( module, valueResult.getReader() );
@@ -263,13 +265,13 @@ public class SQLEntityStoreMixin
}
@Override
- public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+ public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
{
- return new DefaultEntityStoreUnitOfWork( entityStoreSPI, newUnitOfWorkId(), usecase, currentTime );
+ return new DefaultEntityStoreUnitOfWork( module, entityStoreSPI, newUnitOfWorkId(), usecase, currentTime );
}
@Override
- public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+ public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
{
return new Input<EntityState, EntityStoreException>()
{
@@ -300,7 +302,7 @@ public class SQLEntityStoreMixin
};
}
- private void queryAllEntities( ModuleSpi module, EntityStatesVisitor entityStatesVisitor )
+ private void queryAllEntities( ModuleDescriptor module, EntityStatesVisitor entityStatesVisitor )
{
Connection connection = null;
PreparedStatement ps = null;
@@ -342,13 +344,13 @@ public class SQLEntityStoreMixin
return uuid + Integer.toHexString( count.incrementAndGet() );
}
- protected DefaultEntityState readEntityState( ModuleSpi module, Reader entityState )
+ protected DefaultEntityState readEntityState( ModuleDescriptor module, Reader entityState )
throws EntityStoreException
{
try
{
JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
- final EntityStatus[] status = {EntityStatus.LOADED};
+ final EntityStatus[] status = { EntityStatus.LOADED };
String version = jsonObject.getString( JSONKeys.VERSION );
long modified = jsonObject.getLong( JSONKeys.MODIFIED );
@@ -372,7 +374,7 @@ public class SQLEntityStoreMixin
identity, currentAppVersion, application.version() );
// State changed
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
String type = jsonObject.getString( JSONKeys.TYPE );
@@ -380,11 +382,7 @@ public class SQLEntityStoreMixin
EntityDescriptor entityDescriptor = module.entityDescriptor( type );
if( entityDescriptor == null )
{
- throw new EntityTypeNotFoundException( type,
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type, module );
}
Map<QualifiedName, Object> properties = new HashMap<>();
@@ -400,7 +398,8 @@ public class SQLEntityStoreMixin
}
else
{
- Object value = valueSerialization.deserialize( propertyDescriptor.valueType(), jsonValue.toString() );
+ Object value = valueSerialization.deserialize( module, propertyDescriptor.valueType(), jsonValue
+ .toString() );
properties.put( propertyDescriptor.qualifiedName(), value );
}
}
@@ -409,7 +408,7 @@ public class SQLEntityStoreMixin
// Value not found, default it
Object initialValue = propertyDescriptor.initialValue( module );
properties.put( propertyDescriptor.qualifiedName(), initialValue );
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
} );
@@ -427,7 +426,7 @@ public class SQLEntityStoreMixin
{
// Association not found, default it to null
associations.put( associationType.qualifiedName(), null );
- status[0] = EntityStatus.UPDATED;
+ status[ 0 ] = EntityStatus.UPDATED;
}
} );
@@ -480,10 +479,10 @@ public class SQLEntityStoreMixin
// NamedAssociation not found, default to empty one
namedAssociations.put( namedAssociationType.qualifiedName(), references );
}
- });
+ } );
return new DefaultEntityState( version, modified,
- EntityReference.parseEntityReference( identity ), status[0], entityDescriptor,
+ EntityReference.parseEntityReference( identity ), status[ 0 ], entityDescriptor,
properties, associations, manyAssociations, namedAssociations );
}
catch( JSONException e )
@@ -584,7 +583,8 @@ public class SQLEntityStoreMixin
} );
JSONWriter associations = properties.endObject().key( JSONKeys.ASSOCIATIONS ).object();
- for( Map.Entry<QualifiedName, EntityReference> stateNameEntityReferenceEntry : state.associations().entrySet() )
+ for( Map.Entry<QualifiedName, EntityReference> stateNameEntityReferenceEntry : state.associations()
+ .entrySet() )
{
EntityReference value = stateNameEntityReferenceEntry.getValue();
associations.key( stateNameEntityReferenceEntry.getKey().name() ).
@@ -592,7 +592,8 @@ public class SQLEntityStoreMixin
}
JSONWriter manyAssociations = associations.endObject().key( JSONKeys.MANY_ASSOCIATIONS ).object();
- for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations().entrySet() )
+ for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations()
+ .entrySet() )
{
JSONWriter assocs = manyAssociations.key( stateNameListEntry.getKey().name() ).array();
for( EntityReference entityReference : stateNameListEntry.getValue() )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
index c33ddd0..8ccb56a 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
@@ -81,7 +81,7 @@ public class DerbySQLEntityStoreTest
{
SQLConfiguration config = uow.get( SQLConfiguration.class,
DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
- Connection connection = module.findService( DataSource.class ).get().getConnection();
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
connection.setAutoCommit( false );
String schemaName = config.schemaName().get();
if( schemaName == null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
index cb263ec..80459e8 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
@@ -93,7 +93,7 @@ public class MySQLEntityStoreTest
{
SQLConfiguration config = uow.get( SQLConfiguration.class,
MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
- Connection connection = module.findService( DataSource.class ).get().getConnection();
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
connection.setAutoCommit( false );
String schemaName = config.schemaName().get();
if( schemaName == null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
index 5504e36..8064a7d 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
@@ -119,7 +119,7 @@ public class PostgreSQLEntityStoreTest
{
SQLConfiguration config = uow.get( SQLConfiguration.class,
PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
- Connection connection = module.findService( DataSource.class ).get().getConnection();
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
connection.setAutoCommit( false );
String schemaName = config.schemaName().get();
if( schemaName == null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
index 3d9fdf2..008ecb0 100755
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
@@ -28,6 +28,7 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.qualifier.Tagged;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.util.Classes;
@@ -41,7 +42,6 @@ import org.apache.zest.spi.entity.NamedAssociationState;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateChangeListener;
-import org.apache.zest.spi.module.ModuleSpi;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.json.JSONArray;
@@ -67,7 +67,7 @@ public interface ElasticSearchIndexer
private static final Logger LOGGER = LoggerFactory.getLogger( ElasticSearchIndexer.class );
@Structure
- private ModuleSpi module;
+ private ModuleDescriptor module;
@Service
private EntityStore entityStore;
@@ -98,7 +98,7 @@ public interface ElasticSearchIndexer
}
EntityStoreUnitOfWork uow = entityStore.newUnitOfWork(
- UsecaseBuilder.newUsecase( "Load associations for indexing" ),
+ module, UsecaseBuilder.newUsecase( "Load associations for indexing" ),
System.currentTimeMillis()
);
@@ -190,8 +190,11 @@ public interface ElasticSearchIndexer
try
{
json.put( "_identity", state.identity().identity() );
- json.put( "_types", state.entityDescriptor().mixinTypes().map( Classes.toClassName() ).collect( Collectors
- .toList() ) );
+ json.put( "_types", state.entityDescriptor()
+ .mixinTypes()
+ .map( Classes.toClassName() )
+ .collect( Collectors
+ .toList() ) );
}
catch( JSONException e )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
index 6bf8c83..45e8086 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
@@ -180,7 +180,7 @@ public class ElasticSearchTest
Post post = postBuilder.instance();
post.title().set( title );
post.author().set( author );
- post.tagline().set( module.newValue( Tagline.class ) );
+ post.tagline().set( valueBuilderFactory.newValue( Tagline.class ) );
post.comments().add( comment1 );
post.comments().add( comment2 );
post = postBuilder.newInstance();
@@ -189,7 +189,7 @@ public class ElasticSearchTest
Page page = pageBuilder.instance();
page.title().set( title );
page.author().set( author );
- page.tagline().set( module.newValue( Tagline.class ) );
+ page.tagline().set( valueBuilderFactory.newValue( Tagline.class ) );
page = pageBuilder.newInstance();
System.out.println( "########################################" );
@@ -201,7 +201,7 @@ public class ElasticSearchTest
uow = uowf.newUnitOfWork();
- QueryBuilder<Post> queryBuilder = module.newQueryBuilder( Post.class );
+ QueryBuilder<Post> queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class );
Query<Post> query = uow.newQuery( queryBuilder );
assertEquals( 1, query.count() );
post = query.find();
@@ -209,7 +209,7 @@ public class ElasticSearchTest
assertEquals( title, post.title().get() );
post = templateFor( Post.class );
- queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), title ) );
+ queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.title(), title ) );
query = uow.newQuery( queryBuilder );
assertEquals( 1, query.count() );
post = query.find();
@@ -217,24 +217,24 @@ public class ElasticSearchTest
assertEquals( title, post.title().get() );
post = templateFor( Post.class );
- queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), "Not available" ) );
+ queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.title(), "Not available" ) );
query = uow.newQuery( queryBuilder );
assertEquals( 0, query.count() );
post = templateFor( Post.class );
- queryBuilder = module.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
+ queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
query = uow.newQuery( queryBuilder );
assertEquals( 1, query.count() );
post = templateFor( Post.class );
- queryBuilder = module.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
+ queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
query = uow.newQuery( queryBuilder );
post = query.find();
assertNotNull( post );
assertEquals( title, post.title().get() );
post = templateFor( Post.class );
- queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(), "eskatos" ) );
+ queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(), "eskatos" ) );
query = uow.newQuery( queryBuilder );
assertEquals( 1, query.count() );
post = query.find();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
index b6b41f1..cdfb80c 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
@@ -132,7 +132,7 @@ public class ImmenseTermTest
{
testEntity = uow.get( testEntity );
Query<TestEntity2> query = uow.newQuery(
- module.newQueryBuilder( TestEntity2.class ).where(
+ queryBuilderFactory.newQueryBuilder( TestEntity2.class ).where(
eq( templateFor( TestEntity2.class ).property(), "test" )
)
);
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
index c0092a1..f405dbc 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
@@ -307,7 +307,7 @@ public class ContainsAllTest
private ExampleEntity findEntity( String... strings )
{
- QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder( ExampleEntity.class );
+ QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
builder = builder.where( QueryExpressions.containsAll(
QueryExpressions.templateFor( ExampleEntity.class ).strings(),
@@ -320,10 +320,10 @@ public class ContainsAllTest
Set<ExampleValue> values = new HashSet<ExampleValue>();
for( String value : valueStrings )
{
- ValueBuilder<ExampleValue2> vBuilder = this.module.newValueBuilder( ExampleValue2.class );
+ ValueBuilder<ExampleValue2> vBuilder = this.valueBuilderFactory.newValueBuilder( ExampleValue2.class );
vBuilder.prototype().stringProperty().set( value );
- ValueBuilder<ExampleValue> vBuilder2 = this.module.newValueBuilder( ExampleValue.class );
+ ValueBuilder<ExampleValue> vBuilder2 = this.valueBuilderFactory.newValueBuilder( ExampleValue.class );
vBuilder2.prototype().valueProperty().set( vBuilder.newInstance() );
values.add( vBuilder2.newInstance() );
}
@@ -333,7 +333,7 @@ public class ContainsAllTest
private Query<ExampleEntity> createComplexQuery( Set<ExampleValue> valuez )
{
- QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder( ExampleEntity.class );
+ QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
builder = builder.where( QueryExpressions.containsAll(
QueryExpressions.templateFor( ExampleEntity.class ).complexValue(),
valuez
@@ -348,7 +348,7 @@ public class ContainsAllTest
{
UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
- createEntityWithStrings( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
+ createEntityWithStrings( creatingUOW, this.valueBuilderFactory, entityStrings.toArray( entityStringsArray ) );
creatingUOW.complete();
UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
@@ -369,7 +369,7 @@ public class ContainsAllTest
{
UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
- createEntityWithComplexValues( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
+ createEntityWithComplexValues( creatingUOW, this.valueBuilderFactory, entityStrings.toArray( entityStringsArray ) );
creatingUOW.complete();
UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
index 9fd4e54..84f5406 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
@@ -136,7 +136,7 @@ public class ContainsTest extends AbstractZestTest
private ExampleEntity findEntity(String string)
{
- QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder(ExampleEntity.class);
+ QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder(ExampleEntity.class);
builder = builder.where(QueryExpressions.contains(
QueryExpressions.templateFor(ExampleEntity.class).strings(),
@@ -149,10 +149,10 @@ public class ContainsTest extends AbstractZestTest
private ExampleEntity findEntityBasedOnValueString(String valueString)
{
- ValueBuilder<ExampleValue2> vBuilder = this.module.newValueBuilder(ExampleValue2.class);
+ ValueBuilder<ExampleValue2> vBuilder = this.valueBuilderFactory.newValueBuilder(ExampleValue2.class);
vBuilder.prototype().stringProperty().set(valueString);
- ValueBuilder<ExampleValue> vBuilder2 = this.module.newValueBuilder(ExampleValue.class);
+ ValueBuilder<ExampleValue> vBuilder2 = this.valueBuilderFactory.newValueBuilder(ExampleValue.class);
vBuilder2.prototype().valueProperty().set(vBuilder.newInstance());
return this.createComplexQuery(vBuilder2.newInstance()).find();
@@ -160,7 +160,7 @@ public class ContainsTest extends AbstractZestTest
private Query<ExampleEntity> createComplexQuery(ExampleValue value)
{
- QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder(ExampleEntity.class);
+ QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder(ExampleEntity.class);
builder = builder.where(QueryExpressions.contains(
QueryExpressions.templateFor(ExampleEntity.class).complexValue(),
value
@@ -174,7 +174,7 @@ public class ContainsTest extends AbstractZestTest
{
UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
- ContainsAllTest.createEntityWithStrings(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
+ ContainsAllTest.createEntityWithStrings(creatingUOW, this.valueBuilderFactory, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
@@ -193,7 +193,7 @@ public class ContainsTest extends AbstractZestTest
{
UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
- ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
+ ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.valueBuilderFactory, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
index c005360..6974e90 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
@@ -118,7 +118,7 @@ public class RDFPerformanceTest extends AbstractZestTest
{
List<ExampleEntity> list = new ArrayList<ExampleEntity>();
UnitOfWork uow = this.uowf.newUnitOfWork();
- Iterator<ExampleEntity> iter = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ) ).iterator();
+ Iterator<ExampleEntity> iter = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ) ).iterator();
int found = 0;
while (iter.hasNext())
{
@@ -141,7 +141,7 @@ public class RDFPerformanceTest extends AbstractZestTest
private void doRemove( int howMany )
{
- Iterator<ExampleEntity> iter = this.uowf.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
+ Iterator<ExampleEntity> iter = this.uowf.currentUnitOfWork().newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
Integer removed = 0;
while (iter.hasNext())
{
@@ -175,7 +175,7 @@ public class RDFPerformanceTest extends AbstractZestTest
UnitOfWork uow = this.uowf.newUnitOfWork();
for (int i = 0; i < 1000; i++)
{
- Query<ExampleEntity> query = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ).
+ Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ).
where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), uow.get( ExampleEntity.class, "entity50" ) ) ));
System.out.println(query.count());
}
@@ -219,7 +219,7 @@ public class RDFPerformanceTest extends AbstractZestTest
this.performTest( 200 );
IndexExporter indexerExporter =
- module.findService( IndexExporter.class ).get();
+ serviceFinder.findService( IndexExporter.class ).get();
indexerExporter.exportReadableToStream( System.out );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
index 1d83240..22985e5 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
@@ -74,7 +74,7 @@ public class Qi173IssueTest
}
uow = uowf.newUnitOfWork();
- QueryBuilder<Car> qb = module.newQueryBuilder( Car.class );
+ QueryBuilder<Car> qb = queryBuilderFactory.newQueryBuilder( Car.class );
Car template = QueryExpressions.templateFor( Car.class );
qb = qb.where( QueryExpressions.eq( template.year(), 2007 ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
index ed7c460..be637fd 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
@@ -42,7 +42,7 @@ public final class IssueTest
{
super.setUp();
- accountService = module.findService( AccountService.class ).get();
+ accountService = serviceFinder.findService( AccountService.class ).get();
}
@Test( expected = IllegalStateException.class )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
index 23a1d8b..f3cb7d3 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
@@ -38,7 +38,7 @@ public final class IssueTest
{
super.setUp();
- accountService = module.findService( AccountService.class ).get();
+ accountService = serviceFinder.findService( AccountService.class ).get();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
index 1675973..b354031 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
@@ -38,7 +38,7 @@ public class IssueTest
{
super.setUp();
- accountService = module.findService( AccountService.class ).get();
+ accountService = serviceFinder.findService( AccountService.class ).get();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
index 621b02f..789b122 100644
--- a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
+++ b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
@@ -86,7 +86,7 @@ public class SolrQueryServiceTest
{
// Search for it
UnitOfWork uow = uowf.newUnitOfWork();
- Query<TestEntity> query = uow.newQuery( module.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
+ Query<TestEntity> query = uow.newQuery( queryBuilderFactory.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
TestEntity test = query.find();
Assert.assertThat( test.name().get(), equalTo( "Hello World" ) );
@@ -99,7 +99,7 @@ public class SolrQueryServiceTest
throws UnitOfWorkCompletionException, SolrServerException
{
// Search for it using search interface
- SolrSearch search = (SolrSearch) module.findService( SolrSearch.class ).get();
+ SolrSearch search = serviceFinder.findService( SolrSearch.class ).get();
SolrDocumentList results = search.search( "hello" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
index 1bbae97..5832447 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
@@ -27,6 +27,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
@@ -194,6 +195,12 @@ import org.slf4j.LoggerFactory;
}
@Override
+ public ModuleDescriptor module()
+ {
+ return wrappedEntityDescriptor.module();
+ }
+
+ @Override
public AssociationStateDescriptor state()
{
return new CompatAssociationStateDescriptorWrapper( wrappedEntityDescriptor.state() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
index 1a0f826..d7f9f37 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
@@ -51,7 +51,7 @@ public class PostgreSQLComplexQueryTest
// Let's check if exception was because database was not available
if( this.module != null )
{
- SQLTestHelper.setUpTest( this.module );
+ SQLTestHelper.setUpTest( this.serviceFinder );
}
// If we got this far, the database must have been available, and exception must have
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
index 2e1389d..88d4b54 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
@@ -72,7 +72,7 @@ public class PostgreSQLDBIntegrityTest
super.setUp();
if( this.module != null )
{
- SQLTestHelper.setUpTest( this.module );
+ SQLTestHelper.setUpTest( this.serviceFinder );
}
}
@@ -95,7 +95,7 @@ public class PostgreSQLDBIntegrityTest
uow.remove( entity );
uow.complete();
- Connection connection = this.module.findService( DataSource.class ).get().getConnection();
+ Connection connection = this.serviceFinder.findService( DataSource.class ).get().getConnection();
try
{
GenericDatabaseExplorer.visitDatabaseTables(
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
index 3f07e2b..7ad7bc0 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
@@ -51,7 +51,7 @@ public class PostgreSQLEntityFinderTest
// Let's check if exception was because database was not available
if( this.module != null )
{
- SQLTestHelper.setUpTest( this.module );
+ SQLTestHelper.setUpTest( this.serviceFinder );
}
// If we got this far, the database must have been available, and exception must have
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
index a0945e9..282d05b 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
@@ -59,7 +59,7 @@ public class PostgreSQLQueryTest
// Let's check if exception was because database was not available
if( this.module != null )
{
- SQLTestHelper.setUpTest( this.module );
+ SQLTestHelper.setUpTest( this.serviceFinder );
}
// If we got this far, the database must have been available, and exception must have
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
index e2254dc..7e3cd18 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
@@ -16,6 +16,7 @@ package org.apache.zest.index.sql.postgresql;
import java.sql.Connection;
import javax.sql.DataSource;
+import org.apache.zest.api.service.ServiceFinder;
import org.junit.Assume;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.structure.Module;
@@ -87,13 +88,13 @@ public class SQLTestHelper
visibleIn( Visibility.layer );
}
- public static void setUpTest( Module module )
+ public static void setUpTest( ServiceFinder serviceFinder )
{
Connection connection = null;
try
{
- DataSource ds = module.findService( DataSource.class ).get();
+ DataSource ds = serviceFinder.findService( DataSource.class ).get();
connection = ds.getConnection();
Assume.assumeNotNull( connection );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
index fad2722..e6ff329 100644
--- a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
+++ b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
@@ -26,6 +26,7 @@ import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.index.reindexer.Reindexer;
import org.apache.zest.index.reindexer.ReindexerConfiguration;
import org.apache.zest.io.Output;
@@ -34,7 +35,6 @@ import org.apache.zest.io.Sender;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.entitystore.StateChangeListener;
-import org.apache.zest.spi.module.ModuleSpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,7 +65,7 @@ public class ReindexerMixin
private Iterable<ServiceReference<StateChangeListener>> listeners;
@Structure
- private ModuleSpi module;
+ private ModuleDescriptor module;
private Logger logger = LoggerFactory.getLogger( Reindexer.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
index c95a8bc..b014abd 100644
--- a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
+++ b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
@@ -108,11 +108,11 @@ public class ReindexerTest
// ----> Reindex and assert data
- module.<ReindexerService>findService( ReindexerService.class ).get().reindex(); // Reindex
+ serviceFinder.findService( ReindexerService.class ).get().reindex(); // Reindex
uow = uowf.newUnitOfWork();
- QueryBuilder<MyEntity> qBuilder = module.newQueryBuilder( MyEntity.class );
+ QueryBuilder<MyEntity> qBuilder = queryBuilderFactory.newQueryBuilder( MyEntity.class );
qBuilder = qBuilder.where( eq( templateFor( MyEntity.class ).name(), TEST_NAME ) );
Query<MyEntity> q = uow.newQuery( qBuilder );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index 1ff5cd8..05ca607 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -27,13 +27,8 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Function;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.value.ValueDeserializer;
import org.apache.zest.api.value.ValueSerializationException;
import org.apache.zest.spi.value.ValueDeserializerAdapter;
@@ -46,29 +41,22 @@ public class JacksonValueDeserializer
private final JsonFactory jsonFactory = new MappingJsonFactory();
- public JacksonValueDeserializer( @Structure Application application,
- @Structure Module module,
- @Service ServiceReference<ValueDeserializer> serviceRef )
- {
- super( application, module, serviceRef );
- }
-
@Override
- protected JsonParser adaptInput( InputStream input )
+ protected JsonParser adaptInput( ModuleDescriptor module, InputStream input )
throws Exception
{
return jsonFactory.createParser( input );
}
@Override
- protected void onDeserializationEnd( ValueType valueType, JsonParser input )
+ protected void onDeserializationEnd( ModuleDescriptor module, ValueType valueType, JsonParser input )
throws Exception
{
input.close();
}
@Override
- protected Object readPlainValue( JsonParser input )
+ protected Object readPlainValue( ModuleDescriptor module, JsonParser input )
throws Exception
{
JsonNode jsonNode = input.readValueAsTree();
@@ -101,9 +89,11 @@ public class JacksonValueDeserializer
}
@Override
- protected <T> Collection<T> readArrayInCollection( JsonParser input,
+ protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+ JsonParser input,
Function<JsonParser, T> deserializer,
- Collection<T> collection )
+ Collection<T> collection
+ )
throws Exception
{
JsonToken token = input.getCurrentToken();
@@ -133,10 +123,12 @@ public class JacksonValueDeserializer
}
@Override
- protected <K, V> Map<K, V> readMapInMap( JsonParser input,
+ protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+ JsonParser input,
Function<JsonParser, K> keyDeserializer,
Function<JsonParser, V> valueDeserializer,
- Map<K, V> map )
+ Map<K, V> map
+ )
throws Exception
{
JsonToken token = input.getCurrentToken();
@@ -197,7 +189,7 @@ public class JacksonValueDeserializer
}
@Override
- protected ObjectNode readObjectTree( JsonParser input )
+ protected ObjectNode readObjectTree( ModuleDescriptor module, JsonParser input )
throws Exception
{
JsonToken token = input.getCurrentToken();
@@ -218,7 +210,7 @@ public class JacksonValueDeserializer
}
@Override
- protected Object asSimpleValue( JsonNode inputNode )
+ protected Object asSimpleValue( ModuleDescriptor module, JsonNode inputNode )
throws Exception
{
if( isNullOrMissing( inputNode ) )
@@ -249,7 +241,8 @@ public class JacksonValueDeserializer
}
@Override
- protected boolean isObjectValue( JsonNode inputNode )
+ @SuppressWarnings( "SimplifiableIfStatement" )
+ protected boolean isObjectValue( ModuleDescriptor module, JsonNode inputNode )
throws Exception
{
if( isNullOrMissing( inputNode ) )
@@ -260,7 +253,7 @@ public class JacksonValueDeserializer
}
@Override
- protected boolean objectHasField( JsonNode inputNode, String key )
+ protected boolean objectHasField( ModuleDescriptor module, JsonNode inputNode, String key )
throws Exception
{
if( isNullOrMissing( inputNode ) )
@@ -275,7 +268,11 @@ public class JacksonValueDeserializer
}
@Override
- protected <T> T getObjectFieldValue( JsonNode inputNode, String key, Function<JsonNode, T> valueDeserializer )
+ protected <T> T getObjectFieldValue( ModuleDescriptor module,
+ JsonNode inputNode,
+ String key,
+ Function<JsonNode, T> valueDeserializer
+ )
throws Exception
{
JsonNode valueNode = inputNode.get( key );
@@ -283,14 +280,15 @@ public class JacksonValueDeserializer
{
return null;
}
- T value = valueDeserializer.apply( valueNode );
- return value;
+ return valueDeserializer.apply( valueNode );
}
@Override
- protected <T> void putArrayNodeInCollection( JsonNode inputNode,
+ protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+ JsonNode inputNode,
Function<JsonNode, T> deserializer,
- Collection<T> collection )
+ Collection<T> collection
+ )
throws Exception
{
if( isNullOrMissing( inputNode ) )
@@ -310,10 +308,12 @@ public class JacksonValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( JsonNode inputNode,
+ protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+ JsonNode inputNode,
Function<JsonNode, K> keyDeserializer,
Function<JsonNode, V> valueDeserializer,
- Map<K, V> map )
+ Map<K, V> map
+ )
throws Exception
{
if( isNullOrMissing( inputNode ) )
@@ -343,7 +343,8 @@ public class JacksonValueDeserializer
}
@Override
- protected <V> void putObjectNodeInMap( JsonNode inputNode,
+ protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+ JsonNode inputNode,
Function<JsonNode, V> valueDeserializer,
Map<String, V> map
)
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
index 3f86b64..df859c5 100644
--- a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
+++ b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
@@ -35,12 +35,7 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueDeserializer;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.value.ValueSerializationException;
import org.apache.zest.spi.value.ValueDeserializerAdapter;
import org.w3c.dom.Document;
@@ -58,11 +53,8 @@ public class StaxValueDeserializer
private final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
private final TransformerFactory transformerFactory = TransformerFactory.newInstance();
- public StaxValueDeserializer( @Structure Application application,
- @Structure Module module,
- @Service ServiceReference<ValueDeserializer> serviceRef )
+ public StaxValueDeserializer()
{
- super( application, module, serviceRef );
// Input Factory setup
inputFactory.setProperty( "javax.xml.stream.isValidating", Boolean.FALSE );
inputFactory.setProperty( "javax.xml.stream.isNamespaceAware", Boolean.FALSE );
@@ -72,14 +64,14 @@ public class StaxValueDeserializer
}
@Override
- protected XMLEventReader adaptInput( InputStream input )
+ protected XMLEventReader adaptInput( ModuleDescriptor module, InputStream input )
throws Exception
{
return inputFactory.createXMLEventReader( input, "UTF-8" );
}
@Override
- protected Object readPlainValue( XMLEventReader input )
+ protected Object readPlainValue( ModuleDescriptor module, XMLEventReader input )
throws Exception
{
if( !input.hasNext() )
@@ -102,9 +94,11 @@ public class StaxValueDeserializer
}
@Override
- protected <T> Collection<T> readArrayInCollection( XMLEventReader input,
+ protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+ XMLEventReader input,
Function<XMLEventReader, T> deserializer,
- Collection<T> collection )
+ Collection<T> collection
+ )
throws Exception
{
if( !input.hasNext() )
@@ -130,10 +124,10 @@ public class StaxValueDeserializer
String endElementName = currentTag.asEndElement().getName().getLocalPart();
switch( endElementName )
{
- case "array":
- break WHILE;
- case "value":
- continue;
+ case "array":
+ break WHILE;
+ case "value":
+ continue;
}
}
if( !"value".equals( currentTag.asStartElement().getName().getLocalPart() ) )
@@ -147,10 +141,12 @@ public class StaxValueDeserializer
}
@Override
- protected <K, V> Map<K, V> readMapInMap( XMLEventReader input,
+ protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+ XMLEventReader input,
Function<XMLEventReader, K> keyDeserializer,
Function<XMLEventReader, V> valueDeserializer,
- Map<K, V> map )
+ Map<K, V> map
+ )
throws Exception
{
if( !input.hasNext() )
@@ -170,14 +166,18 @@ public class StaxValueDeserializer
XMLEvent currentTag = input.nextTag(); // <object>
while( !currentTag.isEndElement() || !"array".equals( currentTag.asEndElement().getName().getLocalPart() ) )
{
- if( !currentTag.isStartElement() || !"object".equals( currentTag.asStartElement().getName().getLocalPart() ) )
+ if( !currentTag.isStartElement() || !"object".equals( currentTag.asStartElement()
+ .getName()
+ .getLocalPart() ) )
{
throw new ValueSerializationException( "Expected an <object/> but got: " + nextTag );
}
currentTag = input.nextTag(); // <field>
K key = null;
V value = null;
- while( !currentTag.isEndElement() || !"object".equals( currentTag.asEndElement().getName().getLocalPart() ) )
+ while( !currentTag.isEndElement() || !"object".equals( currentTag.asEndElement()
+ .getName()
+ .getLocalPart() ) )
{
input.nextTag(); // <name>
String keyOrValue = input.nextEvent().asCharacters().getData();
@@ -185,15 +185,15 @@ public class StaxValueDeserializer
input.nextTag(); // <value>
switch( keyOrValue )
{
- case "key":
- key = keyDeserializer.apply( input );
- break;
- case "value":
- value = valueDeserializer.apply( input );
- break;
- default:
- readObjectTree( input );
- break;
+ case "key":
+ key = keyDeserializer.apply( input );
+ break;
+ case "value":
+ value = valueDeserializer.apply( input );
+ break;
+ default:
+ readObjectTree( module, input );
+ break;
}
input.nextTag(); // </value>
input.nextTag(); // </field>
@@ -209,7 +209,7 @@ public class StaxValueDeserializer
}
@Override
- protected Node readObjectTree( XMLEventReader input )
+ protected Node readObjectTree( ModuleDescriptor module, XMLEventReader input )
throws Exception
{
XMLEvent peek = input.peek();
@@ -224,7 +224,6 @@ public class StaxValueDeserializer
DOMResult domResult = new DOMResult();
transformer.transform( new StreamSource( new StringReader( elementBody ) ), domResult );
return ( (Document) domResult.getNode() ).getDocumentElement();
-
}
private static String readElementBody( XMLEventReader input )
@@ -259,7 +258,7 @@ public class StaxValueDeserializer
}
@Override
- protected Object asSimpleValue( Node inputNode )
+ protected Object asSimpleValue( ModuleDescriptor module, Node inputNode )
throws Exception
{
if( inputNode == null )
@@ -279,7 +278,8 @@ public class StaxValueDeserializer
}
@Override
- protected boolean isObjectValue( Node inputNode )
+ @SuppressWarnings( "SimplifiableIfStatement" )
+ protected boolean isObjectValue( ModuleDescriptor module, Node inputNode )
throws Exception
{
if( inputNode == null )
@@ -298,7 +298,7 @@ public class StaxValueDeserializer
}
@Override
- protected boolean objectHasField( Node inputNode, String key )
+ protected boolean objectHasField( ModuleDescriptor module, Node inputNode, String key )
throws Exception
{
if( inputNode == null )
@@ -327,9 +327,11 @@ public class StaxValueDeserializer
@Override
@SuppressWarnings( "unchecked" )
- protected <T> T getObjectFieldValue( Node inputNode,
+ protected <T> T getObjectFieldValue( ModuleDescriptor module,
+ Node inputNode,
String key,
- Function<Node, T> valueDeserializer )
+ Function<Node, T> valueDeserializer
+ )
throws Exception
{
if( inputNode == null )
@@ -359,6 +361,10 @@ public class StaxValueDeserializer
return null;
}
Node valueElement = getDirectChildNode( fieldNode, "value" );
+ if( valueElement == null )
+ {
+ return null;
+ }
Node valueNode = valueElement.getFirstChild();
if( valueNode == null )
{
@@ -368,14 +374,15 @@ public class StaxValueDeserializer
{
return null;
}
- T value = valueDeserializer.apply( valueNode );
- return value;
+ return valueDeserializer.apply( valueNode );
}
@Override
- protected <T> void putArrayNodeInCollection( Node inputNode,
+ protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+ Node inputNode,
Function<Node, T> deserializer,
- Collection<T> collection )
+ Collection<T> collection
+ )
throws Exception
{
if( inputNode == null )
@@ -396,9 +403,11 @@ public class StaxValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( Node inputNode,
+ protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+ Node inputNode,
Function<Node, K> keyDeserializer,
- Function<Node, V> valueDeserializer, Map<K, V> map )
+ Function<Node, V> valueDeserializer, Map<K, V> map
+ )
throws Exception
{
if( inputNode == null )
@@ -413,8 +422,8 @@ public class StaxValueDeserializer
for( int idx = 0; idx < entriesNodes.getLength(); idx++ )
{
Node entryNode = entriesNodes.item( idx );
- K key = getObjectFieldValue( entryNode, "key", keyDeserializer );
- V value = getObjectFieldValue( entryNode, "value", valueDeserializer );
+ K key = getObjectFieldValue( module, entryNode, "key", keyDeserializer );
+ V value = getObjectFieldValue( module, entryNode, "value", valueDeserializer );
if( key != null )
{
map.put( key, value );
@@ -423,9 +432,11 @@ public class StaxValueDeserializer
}
@Override
- protected <V> void putObjectNodeInMap( Node inputNode,
+ protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+ Node inputNode,
Function<Node, V> valueDeserializer,
- Map<String, V> map )
+ Map<String, V> map
+ )
throws Exception
{
if( inputNode == null )
@@ -440,10 +451,11 @@ public class StaxValueDeserializer
for( int idx = 0; idx < fieldsNodes.getLength(); idx++ )
{
Node fieldNode = fieldsNodes.item( idx );
- String key = getDirectChildNode( fieldNode, "name" ).getTextContent();
+ Node node = getDirectChildNode( fieldNode, "name" );
+ String key = node != null ? node.getTextContent() : null;
if( key != null && key.length() > 0 )
{
- V value = getObjectFieldValue( inputNode, key, valueDeserializer );
+ V value = getObjectFieldValue( module, inputNode, key, valueDeserializer );
map.put( key, value );
}
}
[15/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/MemoryRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/MemoryRepositoryTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/MemoryRepositoryTest.java
index 1c696c0..a9d5abe 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/MemoryRepositoryTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/MemoryRepositoryTest.java
@@ -43,13 +43,8 @@ public class MemoryRepositoryTest
@Test
public void testMemoryRepository() throws RepositoryException
{
- module.injectTo( this );
-
-
RepositoryConnection conn = repository.getConnection();
-
Assert.assertThat( "repository is open", conn.isOpen(), CoreMatchers.equalTo( true ) );
-
conn.close();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/NativeRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/NativeRepositoryTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/NativeRepositoryTest.java
index 4f756f2..8b36d06 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/NativeRepositoryTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/repository/NativeRepositoryTest.java
@@ -30,8 +30,7 @@ import org.apache.zest.test.EntityTestAssembler;
/**
* JAVADOC
*/
-public class NativeRepositoryTest
- extends AbstractZestTest
+public class NativeRepositoryTest extends AbstractZestTest
{
@Service
Repository repository;
@@ -48,12 +47,8 @@ public class NativeRepositoryTest
@Test
public void testNativeRepository() throws RepositoryException
{
- module.injectTo(this);
-
RepositoryConnection conn = repository.getConnection();
-
Assert.assertThat("repository is open", conn.isOpen(), CoreMatchers.equalTo(true));
-
conn.close();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/RequestWriterDelegator.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/RequestWriterDelegator.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/RequestWriterDelegator.java
index 6df65f1..e985bb5 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/RequestWriterDelegator.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/RequestWriterDelegator.java
@@ -57,7 +57,7 @@ public class RequestWriterDelegator
{
try
{
- Class writerClass = module.classLoader().loadClass( className.trim() );
+ Class writerClass = module.descriptor().classLoader().loadClass( className.trim() );
RequestWriter requestWriter = (RequestWriter) module.newObject( writerClass );
registerRequestWriter(requestWriter);
} catch (ClassNotFoundException e)
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ResponseReaderDelegator.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ResponseReaderDelegator.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ResponseReaderDelegator.java
index 0eb46f2..29dd0b3 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ResponseReaderDelegator.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ResponseReaderDelegator.java
@@ -54,7 +54,7 @@ public class ResponseReaderDelegator
{
try
{
- Class readerClass = module.classLoader().loadClass( className.trim() );
+ Class readerClass = module.descriptor().classLoader().loadClass( className.trim() );
ResponseReader reader = (ResponseReader) module.newObject( readerClass );
registerResponseReader( reader );
} catch (ClassNotFoundException e)
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/JSONResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/JSONResponseReader.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/JSONResponseReader.java
index 3507347..09ecfb4 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/JSONResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/JSONResponseReader.java
@@ -18,17 +18,17 @@
package org.apache.zest.library.rest.client.responsereader;
import java.util.Iterator;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.service.qualifier.Tagged;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDeserializer;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.library.rest.client.spi.ResponseReader;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.restlet.Response;
import org.restlet.data.Form;
import org.restlet.data.MediaType;
@@ -41,7 +41,7 @@ public class JSONResponseReader
implements ResponseReader
{
@Structure
- private Module module;
+ private ModuleDescriptor module;
@Service
@Tagged( ValueSerialization.Formats.JSON )
@@ -56,7 +56,7 @@ public class JSONResponseReader
{
String jsonValue = response.getEntityAsText();
ValueCompositeType valueType = module.valueDescriptor( resultType.getName() ).valueType();
- return valueDeserializer.deserialize( valueType, jsonValue );
+ return valueDeserializer.deserialize( module, valueType, jsonValue );
}
else if (resultType.equals(Form.class))
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
index c1d0595..b4cc831 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
@@ -141,7 +141,7 @@ public class ContextResourceClientFactoryTest
throws Exception
{
server = new Server( Protocol.HTTP, 8888 );
- ContextRestlet restlet = module.newObject( ContextRestlet.class, new org.restlet.Context() );
+ ContextRestlet restlet = objectFactory.newObject( ContextRestlet.class, new org.restlet.Context() );
ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
MapVerifier mapVerifier = new MapVerifier();
@@ -156,7 +156,7 @@ public class ContextResourceClientFactoryTest
//START SNIPPET: client-create1
Client client = new Client( Protocol.HTTP );
- ContextResourceClientFactory contextResourceClientFactory = module.newObject( ContextResourceClientFactory.class, client );
+ ContextResourceClientFactory contextResourceClientFactory = objectFactory.newObject( ContextResourceClientFactory.class, client );
contextResourceClientFactory.setAcceptedMediaTypes( MediaType.APPLICATION_JSON );
//END SNIPPET: client-create1
@@ -249,7 +249,7 @@ public class ContextResourceClientFactoryTest
@Override
public HandlerCommand handleResult( TestQuery result, ContextResourceClient client )
{
- ValueBuilder<TestQuery> builder = module.newValueBuilderWithPrototype( result );
+ ValueBuilder<TestQuery> builder = valueBuilderFactory.newValueBuilderWithPrototype( result );
builder.prototype().abc().set( "abc" + builder.prototype().abc().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
index da652d1..bfe5c2e 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
@@ -116,7 +116,7 @@ public class ContinuousIntegrationTest
throws Exception
{
server = new Server( Protocol.HTTP, 8888 );
- ContextRestlet restlet = module.newObject( ContextRestlet.class, new org.restlet.Context() );
+ ContextRestlet restlet = objectFactory.newObject( ContextRestlet.class, new org.restlet.Context() );
ChallengeAuthenticator guard = new ChallengeAuthenticator( null, ChallengeScheme.HTTP_BASIC, "testRealm" );
MapVerifier mapVerifier = new MapVerifier();
@@ -131,7 +131,7 @@ public class ContinuousIntegrationTest
//START SNIPPET: client-create1
Client client = new Client( Protocol.HTTP );
- ContextResourceClientFactory contextResourceClientFactory = module.newObject( ContextResourceClientFactory.class, client );
+ ContextResourceClientFactory contextResourceClientFactory = objectFactory.newObject( ContextResourceClientFactory.class, client );
contextResourceClientFactory.setAcceptedMediaTypes( MediaType.APPLICATION_JSON );
//END SNIPPET: client-create1
@@ -225,7 +225,7 @@ public class ContinuousIntegrationTest
@Override
public HandlerCommand handleResult( BuildSpec result, ContextResourceClient client )
{
- ValueBuilder<BuildSpec> builder = module.newValueBuilderWithPrototype( result );
+ ValueBuilder<BuildSpec> builder = valueBuilderFactory.newValueBuilderWithPrototype( result );
builder.prototype().buildNo().set( "#28" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/RssReaderTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/RssReaderTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/RssReaderTest.java
index 21c7eac..816fcb3 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/RssReaderTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/RssReaderTest.java
@@ -84,7 +84,7 @@ public class RssReaderTest
{
Client client = new Client( Protocol.HTTPS );
Reference ref = new Reference( "https://github.com/Qi4j/qi4j-sdk/commits/develop.atom" );
- ContextResourceClientFactory contextResourceClientFactory = module.newObject( ContextResourceClientFactory.class, client );
+ ContextResourceClientFactory contextResourceClientFactory = objectFactory.newObject( ContextResourceClientFactory.class, client );
contextResourceClientFactory.registerResponseReader( new ResponseReader()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableQuery.java
----------------------------------------------------------------------
diff --git a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableQuery.java b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableQuery.java
index 081ab49..cd365a6 100644
--- a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableQuery.java
+++ b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableQuery.java
@@ -157,7 +157,7 @@ public interface TableQuery
public Table applyTo(Table table)
{
ValueBuilder<Table> tableBuilder = ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF
- .apply( table ).module().newValueBuilderWithPrototype( table );
+ .apply( table ).module().instance().newValueBuilderWithPrototype( table );
/* TODO Finish label setting
if (label() != null)
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
index 67c8584..eb99a46 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
@@ -37,6 +37,7 @@ 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.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
@@ -871,13 +872,13 @@ public class ContextResource
Class<?> valueType = interactionMethod.getParameterTypes()[ 0 ];
if( ValueComposite.class.isAssignableFrom( valueType ) )
{
- ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
+ ValueDescriptor valueDescriptor = module.descriptor().valueDescriptor( valueType.getName() );
valueDescriptor.state().properties().forEach( propertyDescriptor -> {
String value = getValue( propertyDescriptor.qualifiedName().name(), queryAsForm, entityAsForm );
if( value == null )
{
- Object initialValue = propertyDescriptor.initialValue( module );
+ Object initialValue = propertyDescriptor.initialValue( module.descriptor() );
if( initialValue != null )
{
value = initialValue.toString();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/RequestReaderDelegator.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/RequestReaderDelegator.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/RequestReaderDelegator.java
index 801dca9..49f998f 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/RequestReaderDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/RequestReaderDelegator.java
@@ -68,7 +68,7 @@ public class RequestReaderDelegator
{
try
{
- Class readerClass = module.classLoader().loadClass( className.trim() );
+ Class readerClass = module.descriptor().classLoader().loadClass( className.trim() );
RequestReader writer = (RequestReader) module.newObject( readerClass );
registerRequestReader( writer );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/ResponseWriterDelegator.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/ResponseWriterDelegator.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/ResponseWriterDelegator.java
index 7d49388..c7cd54a 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/ResponseWriterDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/ResponseWriterDelegator.java
@@ -65,7 +65,7 @@ public class ResponseWriterDelegator
{
try
{
- Class writerClass = module.classLoader().loadClass( className.trim() );
+ Class writerClass = module.descriptor().classLoader().loadClass( className.trim() );
ResponseWriter writer = (ResponseWriter) module.newObject( writerClass );
registerResultWriter( writer );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index fed3812..383e78a 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -32,6 +32,7 @@ import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.qualifier.Tagged;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueBuilder;
@@ -76,6 +77,9 @@ public class DefaultRequestReader
private UnitOfWorkFactory uowf;
@Structure
+ private ModuleDescriptor module;
+
+ @Structure
private ValueBuilderFactory vbf;
@Service
@@ -296,7 +300,7 @@ public class DefaultRequestReader
{
try
{
- return valueDeserializer.deserialize( propertyDescriptor.valueType(), value );
+ return valueDeserializer.deserialize( module, propertyDescriptor.valueType(), value );
}
catch( ValueSerializationException e )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/ValueDescriptorResponseWriter.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/ValueDescriptorResponseWriter.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/ValueDescriptorResponseWriter.java
index 10ba4b7..001a495 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/ValueDescriptorResponseWriter.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/ValueDescriptorResponseWriter.java
@@ -25,12 +25,12 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.value.ValueDescriptor;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.restlet.Response;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
@@ -46,7 +46,7 @@ public class ValueDescriptorResponseWriter extends AbstractResponseWriter
private static final List<MediaType> supportedMediaTypes = Arrays.asList( MediaType.TEXT_HTML, MediaType.APPLICATION_JSON );
@Structure
- private Module module;
+ private ModuleDescriptor module;
@Service
private Configuration cfg;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
index 3390e38..8665ee8 100755
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
@@ -33,6 +33,7 @@ import org.apache.zest.api.entity.EntityReference;
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.structure.ModuleDescriptor;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueSerialization;
@@ -48,7 +49,6 @@ import org.apache.zest.spi.entitystore.EntityNotFoundException;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.helpers.JSONEntityState;
-import org.apache.zest.spi.module.ModuleSpi;
import org.openrdf.model.Statement;
import org.openrdf.rio.RDFHandlerException;
import org.restlet.data.CharacterSet;
@@ -77,7 +77,7 @@ public class EntityResource
private ValueSerialization valueSerialization;
@Structure
- private ModuleSpi module;
+ private ModuleDescriptor module;
@Uses
private EntityStateSerializer entitySerializer;
@@ -108,7 +108,7 @@ public class EntityResource
throws ResourceException
{
Usecase usecase = UsecaseBuilder.newUsecase( "Remove entity" );
- EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, System.currentTimeMillis() );
+ EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( module, usecase, System.currentTimeMillis() );
try
{
EntityReference identityRef = EntityReference.parseEntityReference( identity );
@@ -129,7 +129,7 @@ public class EntityResource
protected Representation get( Variant variant )
throws ResourceException
{
- EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( UsecaseBuilder.newUsecase( "Get entity" ),
+ EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( module, UsecaseBuilder.newUsecase( "Get entity" ),
System.currentTimeMillis() );
try
@@ -349,7 +349,7 @@ public class EntityResource
throws ResourceException
{
Usecase usecase = UsecaseBuilder.newUsecase( "Update entity" );
- EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, System.currentTimeMillis() );
+ EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( module, usecase, System.currentTimeMillis() );
EntityState entity = getEntityState( unitOfWork );
Form form = new Form( entityRepresentation );
@@ -371,7 +371,7 @@ public class EntityResource
{
entity.setPropertyValue(
persistentProperty.qualifiedName(),
- valueSerialization.deserialize( persistentProperty.valueType(), formValue ) );
+ valueSerialization.deserialize( module, persistentProperty.valueType(), formValue ) );
}
}
} );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
index bb75c84..9271501 100644
--- a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
@@ -123,7 +123,7 @@ public class RestTest
public void givenAnIdentityWhenExecutingGetCommandThenExpectTheCorrectRdf()
throws Exception
{
- RestTester restTester = module.newObject( RestTester.class );
+ RestTester restTester = objectFactory.newObject( RestTester.class );
String rdf = restTester.getEntity( "P1" );
// System.out.println( rdf.replaceAll( "\n", "\\\\n" ).replaceAll( "\"", "\\\\\"" ) );
assertThat( "Incorrect RDF produced", rdf, anyOf(
@@ -140,7 +140,7 @@ public class RestTest
public void givenExistingIdentityWhenExecutingPutCommandThenNewValuesInEntity()
throws Throwable
{
- RestTester restTester = module.newObject( RestTester.class );
+ RestTester restTester = objectFactory.newObject( RestTester.class );
Map<String, String> properties = new HashMap<String, String>();
properties.put( "identity", "P1" );
properties.put( "firstname", "Jack" );
@@ -164,7 +164,7 @@ public class RestTest
public void givenExistingIdentityWhenExecutingDeleteCommandThenEntityIsRemoved()
throws Throwable
{
- RestTester restTester = module.newObject( RestTester.class );
+ RestTester restTester = objectFactory.newObject( RestTester.class );
restTester.deleteEntity( "P1" );
UnitOfWork work = uowf.newUnitOfWork();
try
@@ -191,7 +191,7 @@ public class RestTest
public void givenExistingEntitiesWhenExecutingGetCommandThenExpectTheCorrectRdf()
throws Exception
{
- final RestTester restTester = module.newObject( RestTester.class );
+ final RestTester restTester = objectFactory.newObject( RestTester.class );
final String result = restTester.getEntities().replace( "\r", "" );
assertThat(
"Returned RDF", result,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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
index ba6e9aa..f50c926 100644
--- 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
@@ -26,6 +26,7 @@ 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.structure.ModuleDescriptor;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.api.value.ValueSerializer;
import org.apache.zest.spi.ZestSPI;
@@ -49,6 +50,9 @@ public class JsonRepresentation<T> extends OutputRepresentation
@Service
private ValueSerialization serializer;
+ @Structure
+ private ModuleDescriptor module;
+
/**
* The (parsed) object to format.
*/
@@ -94,7 +98,7 @@ public class JsonRepresentation<T> extends OutputRepresentation
}
else if( this.representation != null )
{
- result = serializer.deserialize( objectClass, this.representation.getStream() );
+ result = serializer.deserialize( module, objectClass, this.representation.getStream() );
}
return result;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index f2c8fc6..ad9bf9d 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -98,7 +98,7 @@ public class SchedulerTest
long sleepMillis;
try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
- Scheduler scheduler = module.findService( Scheduler.class ).get();
+ Scheduler scheduler = serviceFinder.findService( Scheduler.class ).get();
FooTask task = createFooTask( uow, usecase.name(), BAZAR );
taskIdentity = task.identity().get();
@@ -119,7 +119,7 @@ public class SchedulerTest
//noinspection unused
try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
{
- Timeline timeline = module.findService( Timeline.class ).get();
+ Timeline timeline = serviceFinder.findService( Timeline.class ).get();
DateTime now = new DateTime();
// Queries returning past records
@@ -147,7 +147,7 @@ public class SchedulerTest
System.setProperty( "zest.entity.print.state", Boolean.TRUE.toString() );
final Usecase usecase = UsecaseBuilder.newUsecase( "TestOnce" );
final String taskIdentity;
- Scheduler scheduler = module.findService( Scheduler.class ).get();
+ Scheduler scheduler = serviceFinder.findService( Scheduler.class ).get();
Schedule schedule1;
Schedule schedule2;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
index 35a9ceb..422b49e 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
@@ -119,7 +119,7 @@ public class PasswordDomainTest
UnitOfWork uow = uowf.newUnitOfWork();
- UserFactory userFactory = module.findService( UserFactory.class ).get();
+ UserFactory userFactory = serviceFinder.findService( UserFactory.class ).get();
// START SNIPPET: usage
User user = userFactory.createNewUser( "foo", "bar" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
index a436896..4c55058 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
@@ -121,8 +121,8 @@ public class PermissionsDomainTest
@Before
public void before_PermissionsDomainTest()
{
- userFactory = module.findService( UserFactory.class ).get();
- roleFactory = module.findService( RoleFactory.class ).get();
+ userFactory = serviceFinder.findService( UserFactory.class ).get();
+ roleFactory = serviceFinder.findService( RoleFactory.class ).get();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
----------------------------------------------------------------------
diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
index 9b2c867..c02a8e1 100644
--- a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
+++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
@@ -27,8 +27,6 @@ import org.apache.zest.api.structure.Module;
import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
-import static org.apache.zest.functional.Iterables.first;
-
final class ServiceLocator
implements HierarchicalVisitor<Object, Object, RuntimeException>
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
index 03c04ce..7bca2be 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
@@ -51,7 +51,7 @@ import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceImporter;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
@@ -124,7 +124,7 @@ public interface DataSourceConfigurationManagerService
{
for ( ServiceReference<DataSource> dataSource : dataSources ) {
String name = dataSource.identity();
- Module module = spi.moduleOf( dataSource );
+ ModuleDescriptor module = spi.moduleOf( dataSource );
EntityDescriptor descriptor = module.entityDescriptor( DataSourceConfiguration.class.getName() );
List<MBeanAttributeInfo> attributes = new ArrayList<>();
Map<String, AccessibleObject> properties = new LinkedHashMap<>();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/sql/src/test/java/org/apache/zest/library/sql/datasource/ExternalDataSourceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/test/java/org/apache/zest/library/sql/datasource/ExternalDataSourceTest.java b/libraries/sql/src/test/java/org/apache/zest/library/sql/datasource/ExternalDataSourceTest.java
index 74eb368..a0d679b 100644
--- a/libraries/sql/src/test/java/org/apache/zest/library/sql/datasource/ExternalDataSourceTest.java
+++ b/libraries/sql/src/test/java/org/apache/zest/library/sql/datasource/ExternalDataSourceTest.java
@@ -49,7 +49,7 @@ public class ExternalDataSourceTest
public void test()
throws SQLException
{
- DataSource dataSource = module.findService( DataSource.class ).get();
+ DataSource dataSource = serviceFinder.findService( DataSource.class ).get();
Connection connection = dataSource.getConnection();
try {
connection.getMetaData();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/PersistingSequencingTest.java
----------------------------------------------------------------------
diff --git a/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/PersistingSequencingTest.java b/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/PersistingSequencingTest.java
index 7cc48b4..138d7e7 100644
--- a/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/PersistingSequencingTest.java
+++ b/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/PersistingSequencingTest.java
@@ -43,7 +43,7 @@ public class PersistingSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenNumbersStartAtZero()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
assertEquals( 0, underTest.currentValue() );
}
@@ -51,7 +51,7 @@ public class PersistingSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenFirstNextValueIsOne()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
assertEquals( 1, underTest.nextValue() );
assertEquals( 1, underTest.currentValue() );
}
@@ -60,7 +60,7 @@ public class PersistingSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenFirst100ValuesAreInSequence()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
for( int i = 1; i <= 100; i++ )
{
assertEquals( i, underTest.nextValue() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/TransientSequencingTest.java
----------------------------------------------------------------------
diff --git a/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/TransientSequencingTest.java b/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/TransientSequencingTest.java
index fe47e0c..c80b0af 100644
--- a/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/TransientSequencingTest.java
+++ b/libraries/uid/src/test/java/org/apache/zest/library/uid/sequence/TransientSequencingTest.java
@@ -41,7 +41,7 @@ public class TransientSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenNumbersStartAtZero()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
assertEquals( 0, underTest.currentValue() );
}
@@ -49,7 +49,7 @@ public class TransientSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenFirstNextValueIsOne()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
assertEquals( 1, underTest.nextValue() );
assertEquals( 1, underTest.currentValue() );
}
@@ -58,7 +58,7 @@ public class TransientSequencingTest extends AbstractZestTest
public void whenTransientSequencingThenFirst100ValuesAreInSequence()
throws Exception
{
- UnderTest underTest = module.newTransient( UnderTest.class );
+ UnderTest underTest = transientBuilderFactory.newTransient( UnderTest.class );
for( int i = 1; i <= 100; i++ )
{
assertEquals( i, underTest.nextValue() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/uid/src/test/java/org/apache/zest/library/uid/uuid/UuidServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/uid/src/test/java/org/apache/zest/library/uid/uuid/UuidServiceTest.java b/libraries/uid/src/test/java/org/apache/zest/library/uid/uuid/UuidServiceTest.java
index b4389fe..15e486c 100644
--- a/libraries/uid/src/test/java/org/apache/zest/library/uid/uuid/UuidServiceTest.java
+++ b/libraries/uid/src/test/java/org/apache/zest/library/uid/uuid/UuidServiceTest.java
@@ -41,7 +41,7 @@ public class UuidServiceTest extends AbstractZestTest
public void whenGeneratingUuidGivenHashLengthLargerThanZeroThenValidateTheSizeAndContent()
throws Exception
{
- UnderTest ut = module.newTransient( UnderTest.class );
+ UnderTest ut = transientBuilderFactory.newTransient( UnderTest.class );
for( int hashLength = 1; hashLength < 50; hashLength++ )
{
String uid = ut.generateUuid( hashLength );
@@ -58,7 +58,7 @@ public class UuidServiceTest extends AbstractZestTest
public void whenGeneratingUuidGivenZeroHashLengthThenValidateFormat()
throws Exception
{
- UnderTest ut = module.newTransient( UnderTest.class );
+ UnderTest ut = transientBuilderFactory.newTransient( UnderTest.class );
String uid = ut.generateUuid( 0 );
int dashCounter = 0;
for( int i = 0; i < uid.length(); i++ )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
index 58e4703..6751994 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
@@ -179,7 +179,7 @@ public class HasUoWFileTest
@Before
public void beforeTest()
{
- testService = module.<TestService>findService( TestService.class ).get();
+ testService = serviceFinder.findService( TestService.class ).get();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
index 7c0418c..74f8998 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
@@ -195,7 +195,7 @@ public class HasUoWFilesTest
@Before
public void beforeTest()
{
- testService = module.<TestService>findService( TestService.class ).get();
+ testService = serviceFinder.findService( TestService.class ).get();
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
index f78fbcf..bc7d3a6 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
@@ -33,7 +33,7 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.value.NoSuchValueException;
import org.apache.zest.api.value.ValueBuilder;
@@ -68,7 +68,7 @@ public interface EntityToDTOService
private ZestSPI spi;
@Structure
- private Module module;
+ private ModuleDescriptor module;
@Override
public <T> T convert( final Class<T> valueType, Object entity )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
index 8747517..98cbbf4 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
@@ -33,7 +33,7 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.value.NoSuchValueException;
import org.apache.zest.api.value.ValueBuilder;
@@ -68,7 +68,7 @@ public interface EntityToDTOService
private ZestSPI spi;
@Structure
- private Module module;
+ private ModuleDescriptor module;
@Override
public <T> T convert( final Class<T> valueType, Object entity )
@@ -111,7 +111,8 @@ public interface EntityToDTOService
{
return null;
}
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
+ Object entity = associationState.associationFor( associationDescriptor.accessor() )
+ .get();
if( entity != null )
{
return ( (Identity) entity ).identity().get();
@@ -122,7 +123,9 @@ public interface EntityToDTOService
}
}
else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType().mainType().equals( String.class ) )
+ && ( (CollectionType) descriptor.valueType() ).collectedType()
+ .mainType()
+ .equals( String.class ) )
{
AssociationDescriptor associationDescriptor;
try
@@ -208,7 +211,8 @@ public interface EntityToDTOService
return null;
}
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
+ Object entity = associationState.associationFor( associationDescriptor.accessor() )
+ .get();
if( entity != null )
{
return ( (Identity) entity ).identity().get();
@@ -216,7 +220,9 @@ public interface EntityToDTOService
return null;
}
else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType().mainType().equals( String.class ) )
+ && ( (CollectionType) descriptor.valueType() ).collectedType()
+ .mainType()
+ .equals( String.class ) )
{
AssociationDescriptor associationDescriptor;
try
@@ -255,7 +261,8 @@ public interface EntityToDTOService
return null;
}
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
+ Object entity = associationState.associationFor( associationDescriptor.accessor() )
+ .get();
if( entity != null )
{
return convert( type, entity );
@@ -282,7 +289,8 @@ public interface EntityToDTOService
}
return EntityReference.entityReferenceFor( associationState
- .associationFor( associationDescriptor.accessor() ).get() );
+ .associationFor( associationDescriptor.accessor() )
+ .get() );
}
}, new Function<AssociationDescriptor, Iterable<EntityReference>>()
{
@@ -321,5 +329,4 @@ public interface EntityToDTOService
return (T) builder.newInstance();
}
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/samples/rental/src/main/java/org/apache/zest/sample/rental/web/QuikitServlet.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/web/QuikitServlet.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/web/QuikitServlet.java
index df063bc..57b4e9a 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/web/QuikitServlet.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/web/QuikitServlet.java
@@ -57,8 +57,6 @@ import org.w3c.dom.Element;
import org.xml.sax.EntityResolver;
import org.xml.sax.SAXException;
-import static org.apache.zest.functional.Iterables.first;
-
public class QuikitServlet
extends HttpServlet
{
@@ -74,7 +72,7 @@ public class QuikitServlet
{
try
{
- mountPoints = new TreeMap<String, Page>();
+ mountPoints = new TreeMap<>();
documentFactory = DocumentBuilderFactory.newInstance();
documentFactory.setNamespaceAware( true );
ClassLoader cl = getClass().getClassLoader();
@@ -194,6 +192,7 @@ public class QuikitServlet
private void renderPage( Page page, String path, PrintWriter output, HttpServletRequest httpRequest )
throws ParserConfigurationException, SAXException, IOException, RenderException, TransformerException
{
+ @SuppressWarnings( "unchecked" )
Class<? extends Composite> pageClass =
(Class<Composite>) ZestAPI.FUNCTION_DESCRIPTOR_FOR.apply( page ).types().findFirst().orElse( null );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/InvocationPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/InvocationPerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/InvocationPerformanceTest.java
index 664607d..21d2d13 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/InvocationPerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/InvocationPerformanceTest.java
@@ -56,7 +56,7 @@ public class InvocationPerformanceTest
public void testInvokeMixin()
{
// Create instance
- TransientBuilder<SimpleComposite> builder = module.newTransientBuilder( SimpleComposite.class );
+ TransientBuilder<SimpleComposite> builder = transientBuilderFactory.newTransientBuilder( SimpleComposite.class );
Simple simple = builder.newInstance();
for( int i = 0; i < 60000; i++ )
@@ -76,7 +76,7 @@ public class InvocationPerformanceTest
public void testInvokeMixinWithTypedConcern()
{
// Create instance
- Simple simple = module.newTransient( SimpleWithTypedConcernComposite.class );
+ Simple simple = transientBuilderFactory.newTransient( SimpleWithTypedConcernComposite.class );
for( int i = 0; i < 60000; i++ )
{
@@ -94,7 +94,7 @@ public class InvocationPerformanceTest
public void testInvokeMixinWithGenericConcern()
{
// Create instance
- Simple simple = module.newTransient( SimpleWithGenericConcernComposite.class );
+ Simple simple = transientBuilderFactory.newTransient( SimpleWithGenericConcernComposite.class );
for( int i = 0; i < 60000; i++ )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/PropertyMixinInvocationPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/PropertyMixinInvocationPerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/PropertyMixinInvocationPerformanceTest.java
index d6bfcc6..a8dabed 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/PropertyMixinInvocationPerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/runtime/composite/PropertyMixinInvocationPerformanceTest.java
@@ -51,7 +51,7 @@ public class PropertyMixinInvocationPerformanceTest
public void testNewInstance()
{
{
- TransientBuilder<SimpleComposite> builder = module.newTransientBuilder( SimpleComposite.class );
+ TransientBuilder<SimpleComposite> builder = transientBuilderFactory.newTransientBuilder( SimpleComposite.class );
SimpleComposite simple = builder.newInstance();
int rounds = 1;
@@ -62,7 +62,7 @@ public class PropertyMixinInvocationPerformanceTest
}
{
- TransientBuilder<SimpleComposite> builder = module.newTransientBuilder( SimpleComposite.class );
+ TransientBuilder<SimpleComposite> builder = transientBuilderFactory.newTransientBuilder( SimpleComposite.class );
SimpleComposite simple = builder.newInstance();
int rounds = 1;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tests/regression/src/main/java/org/apache/zest/test/regression/niclas2/ConcernsOnPropertyTest.java
----------------------------------------------------------------------
diff --git a/tests/regression/src/main/java/org/apache/zest/test/regression/niclas2/ConcernsOnPropertyTest.java b/tests/regression/src/main/java/org/apache/zest/test/regression/niclas2/ConcernsOnPropertyTest.java
index b063291..2c911be 100644
--- a/tests/regression/src/main/java/org/apache/zest/test/regression/niclas2/ConcernsOnPropertyTest.java
+++ b/tests/regression/src/main/java/org/apache/zest/test/regression/niclas2/ConcernsOnPropertyTest.java
@@ -42,11 +42,10 @@ public class ConcernsOnPropertyTest
module.transients( CarComposite.class );
}
-
@Test
public void whenConcernOnPropertyThenConcernIsInvoked()
{
- TransientBuilder<Car> builder = module.newTransientBuilder( Car.class );
+ TransientBuilder<Car> builder = transientBuilderFactory.newTransientBuilder( Car.class );
Car prototype = builder.prototypeFor( Car.class );
prototype.manufacturer().set( "Volvo" );
Car car = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
index e378cf0..2e0e48b 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
@@ -43,7 +43,6 @@ import org.apache.zest.api.sideeffect.SideEffectsDescriptor;
import org.apache.zest.api.structure.ApplicationDescriptor;
import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.structure.UsedLayersDescriptor;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
@@ -130,13 +129,13 @@ public final class ApplicationDetailDescriptorBuilder
currLayerDescriptor = getLayerDetailDescriptor( layerDescriptor );
applicationDescriptor.addLayer( currLayerDescriptor );
- UsedLayersDescriptor usedLayesDescriptor = layerDescriptor.usedLayers();
- Iterable<? extends LayerDescriptor> usedLayers = usedLayesDescriptor.layers();
- for( LayerDescriptor usedLayer : usedLayers )
- {
- LayerDetailDescriptor usedLayerDetailDesc = getLayerDetailDescriptor( usedLayer );
- currLayerDescriptor.addUsedLayer( usedLayerDetailDesc );
- }
+ layerDescriptor.usedLayers().layers().forEach(
+ usedLayer ->
+ {
+ LayerDetailDescriptor usedLayerDetailDesc = getLayerDetailDescriptor( usedLayer );
+ currLayerDescriptor.addUsedLayer( usedLayerDetailDesc );
+ }
+ );
}
else if( visited instanceof ModuleDescriptor )
{
@@ -480,5 +479,4 @@ public final class ApplicationDetailDescriptorBuilder
currMethodSideEffectDescriptor = null;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
index 13c80ed..14db1b0 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceCompositeDescriptor.java
@@ -26,8 +26,8 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.CompositeDescriptor;
import org.apache.zest.api.service.ImportedServiceDescriptor;
import org.apache.zest.api.service.ServiceImporter;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.Iterables;
/**
* XXX Workaround for inconsistency in Zest core-api/spi
@@ -50,6 +50,12 @@ public class ImportedServiceCompositeDescriptor
}
@Override
+ public ModuleDescriptor module()
+ {
+ return importedService.module();
+ }
+
+ @Override
public Stream<Class<?>> mixinTypes()
{
return mixins.stream();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/cargo/src/test/java/org/apache/zest/tutorials/cargo/step2/Step2TestCase.java
----------------------------------------------------------------------
diff --git a/tutorials/cargo/src/test/java/org/apache/zest/tutorials/cargo/step2/Step2TestCase.java b/tutorials/cargo/src/test/java/org/apache/zest/tutorials/cargo/step2/Step2TestCase.java
index 2521680..02fc7ec 100644
--- a/tutorials/cargo/src/test/java/org/apache/zest/tutorials/cargo/step2/Step2TestCase.java
+++ b/tutorials/cargo/src/test/java/org/apache/zest/tutorials/cargo/step2/Step2TestCase.java
@@ -36,13 +36,13 @@ public class Step2TestCase
throws Exception
{
super.setUp();
- TransientBuilder<VoyageComposite> voyageBuilder = module.newTransientBuilder( VoyageComposite.class );
+ TransientBuilder<VoyageComposite> voyageBuilder = transientBuilderFactory.newTransientBuilder( VoyageComposite.class );
voyageBuilder.prototypeFor( Voyage.class ).bookedCargoSize().set( 0.0 );
voyageBuilder.prototypeFor( Voyage.class ).capacity().set( 100.0 );
voyage = voyageBuilder.newInstance();
TransientBuilder<ShippingServiceComposite> shippingBuilder =
- module.newTransientBuilder( ShippingServiceComposite.class );
+ transientBuilderFactory.newTransientBuilder( ShippingServiceComposite.class );
shippingService = shippingBuilder.newInstance();
}
@@ -94,7 +94,7 @@ public class Step2TestCase
private Cargo newCargo( double size )
{
- TransientBuilder<CargoComposite> builder = module.newTransientBuilder( CargoComposite.class );
+ TransientBuilder<CargoComposite> builder = transientBuilderFactory.newTransientBuilder( CargoComposite.class );
builder.prototypeFor( Cargo.class ).size().set( size );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest.java
----------------------------------------------------------------------
diff --git a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest.java b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest.java
index 50007b5..2093dea 100644
--- a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest.java
+++ b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest.java
@@ -40,7 +40,7 @@ public class HelloTest extends AbstractZestTest
@Test
public void givenHelloValueInitializedToHelloWorldWhenCallingSayExpectHelloWorld()
{
- ValueBuilder<Hello> builder = module.newValueBuilder( Hello.class );
+ ValueBuilder<Hello> builder = valueBuilderFactory.newValueBuilder( Hello.class );
builder.prototypeFor( Hello.State.class ).phrase().set( "Hello" );
builder.prototypeFor( Hello.State.class ).name().set( "World" );
Hello underTest = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest2.java
----------------------------------------------------------------------
diff --git a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest2.java b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest2.java
index efaa8c3..a1094f6 100644
--- a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest2.java
+++ b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest2.java
@@ -34,7 +34,7 @@ public class HelloTest2 extends AbstractZestTest
@Test
public void givenHelloValueInitializedToHelloWorldWhenCallingSayExpectHelloWorld()
{
- TransientBuilder<Hello> builder = module.newTransientBuilder( Hello.class );
+ TransientBuilder<Hello> builder = transientBuilderFactory.newTransientBuilder( Hello.class );
builder.prototypeFor( Hello.State.class ).phrase().set( "Hello" );
builder.prototypeFor( Hello.State.class ).name().set( "World" );
Hello underTest = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest3.java
----------------------------------------------------------------------
diff --git a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest3.java b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest3.java
index 173dbfd..513f0a8 100644
--- a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest3.java
+++ b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest3.java
@@ -37,7 +37,7 @@ public class HelloTest3 extends AbstractZestTest
@Test
public void givenHelloValueInitializedToHelloWorldWhenCallingSayExpectHelloWorld()
{
- ServiceReference<Hello> service = module.findService( Hello.class );
+ ServiceReference<Hello> service = serviceFinder.findService( Hello.class );
String result = service.get().say();
assertThat( result, equalTo( "Hello World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step2/LibraryTest.java
----------------------------------------------------------------------
diff --git a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step2/LibraryTest.java b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step2/LibraryTest.java
index 3c00051..4554704 100644
--- a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step2/LibraryTest.java
+++ b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step2/LibraryTest.java
@@ -29,7 +29,7 @@ public class LibraryTest
public void testLibrary()
throws Exception
{
- Consumer consumer = module.newObject( Consumer.class );
+ Consumer consumer = objectFactory.newObject( Consumer.class );
consumer.run();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step3/LibraryTest.java
----------------------------------------------------------------------
diff --git a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step3/LibraryTest.java b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step3/LibraryTest.java
index f0911a5..db31d8f 100644
--- a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step3/LibraryTest.java
+++ b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step3/LibraryTest.java
@@ -29,7 +29,7 @@ public class LibraryTest
public void testLibrary()
throws Exception
{
- Consumer consumer = module.newObject( Consumer.class );
+ Consumer consumer = objectFactory.newObject( Consumer.class );
consumer.run();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step4/LibraryTest.java
----------------------------------------------------------------------
diff --git a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step4/LibraryTest.java b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step4/LibraryTest.java
index 5245481..71823f7 100644
--- a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step4/LibraryTest.java
+++ b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step4/LibraryTest.java
@@ -30,7 +30,7 @@ public class LibraryTest
public void testLibrary()
throws Exception
{
- Consumer consumer = module.newObject( Consumer.class );
+ Consumer consumer = objectFactory.newObject( Consumer.class );
consumer.run();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step5/LibraryTest.java
----------------------------------------------------------------------
diff --git a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step5/LibraryTest.java b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step5/LibraryTest.java
index 4a167c3..8e61154 100644
--- a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step5/LibraryTest.java
+++ b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step5/LibraryTest.java
@@ -30,7 +30,7 @@ public class LibraryTest
public void testLibrary()
throws Exception
{
- Consumer consumer = module.newObject( Consumer.class );
+ Consumer consumer = objectFactory.newObject( Consumer.class );
consumer.run();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step6/LibraryTest.java
----------------------------------------------------------------------
diff --git a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step6/LibraryTest.java b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step6/LibraryTest.java
index 366fb6a..b513dd0 100644
--- a/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step6/LibraryTest.java
+++ b/tutorials/services/src/test/java/org/apache/zest/tutorials/services/step6/LibraryTest.java
@@ -30,7 +30,7 @@ public class LibraryTest
public void testLibrary()
throws Exception
{
- Consumer consumer = module.newObject( Consumer.class );
+ Consumer consumer = objectFactory.newObject( Consumer.class );
consumer.run();
}
[32/34] zest-java git commit: Merged develop branch.
Posted by ni...@apache.org.
Merged develop branch.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/962badce
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/962badce
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/962badce
Branch: refs/heads/develop
Commit: 962badcea188f48da722cba396fb2478375065e7
Parents: 5c1a400 2ae805e
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 23:49:10 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 23:49:10 2016 +0800
----------------------------------------------------------------------
build.gradle | 2 +-
.../src/main/java/org/apache/zest/test/indexing/model/Address.java | 2 +-
gradle/wrapper/gradle-wrapper.properties | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/962badce/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
----------------------------------------------------------------------
diff --cc core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
index 1d5c03a,8de630a..60aa742
mode 100644,100755..100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
@@@ -20,7 -20,8 +20,7 @@@ package org.apache.zest.test.indexing.m
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
--public interface Address
- extends ValueComposite // necessary, @See ZEST-137
++public interface Address extends ValueComposite // necessary, @See ZEST-137
{
Property<String> line1();
[30/34] zest-java git commit: Fixed missing inclusion for finding
importedServices in TypeLookup and findServiceReferences()
Posted by ni...@apache.org.
Fixed missing inclusion for finding importedServices in TypeLookup and findServiceReferences()
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e5c57f95
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e5c57f95
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e5c57f95
Branch: refs/heads/develop
Commit: e5c57f95e199f8a79763debb2e101028f8e8f896
Parents: be492ed
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 23:14:44 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 23:14:44 2016 +0800
----------------------------------------------------------------------
.../zest/runtime/service/ImportedServicesInstance.java | 6 ++++++
.../org/apache/zest/runtime/structure/ModuleInstance.java | 9 +++++----
.../org/apache/zest/runtime/structure/TypeLookupImpl.java | 2 +-
3 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e5c57f95/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
index 4178dc7..6952df7 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
@@ -114,4 +114,10 @@ public class ImportedServicesInstance
{
return servicesModel.models();
}
+
+ public Stream<ServiceReference<?>> references()
+ {
+ return serviceReferences.stream();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e5c57f95/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
index ce458c9..54500e5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -85,6 +84,7 @@ import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.metrics.MetricsProviderAdapter;
import org.apache.zest.spi.module.ModuleSpi;
+import static java.util.stream.Stream.concat;
import static org.apache.zest.functional.Iterables.iterable;
/**
@@ -400,9 +400,10 @@ public class ModuleInstance
private <T> ServiceReference<T> findServiceReferenceInstance( ModelDescriptor model )
{
ModuleInstance moduleInstanceOfModel = (ModuleInstance) model.module().instance();
- Optional<ServiceReference<?>> candidate = moduleInstanceOfModel.services.references()
- .filter( ref -> ref.model().equals( model ) )
- .findAny();
+ Optional<ServiceReference<?>> candidate =
+ concat( moduleInstanceOfModel.services.references(), moduleInstanceOfModel.importedServices.references() )
+ .filter( ref -> ref.model().equals( model ) )
+ .findAny();
if( candidate.isPresent() )
{
ServiceReference<?> serviceReference = candidate.get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e5c57f95/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
index aba9b22..3e04d57 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
@@ -355,7 +355,7 @@ class TypeLookupImpl
)
);
Stream<? extends ModelDescriptor> importedServices =
- concat( moduleModel.serviceComposites(),
+ concat( moduleModel.importedServices(),
concat(
concat(
moduleModel.layer()
[06/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
index 65120c9..90ea8a0 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
@@ -66,10 +66,10 @@ import static org.apache.zest.api.structure.Application.Mode.test;
*/
@SuppressWarnings( "unchecked" )
public class TestAssembler
- implements ApplicationAssembler
+ implements ApplicationAssembler
{
public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
+ throws AssemblyException
{
// Application assembly
ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
@@ -85,17 +85,17 @@ public class TestAssembler
// Layer dependencies
bootstrapLayer.uses(
- contextLayer,
- domainLayer,
- infrastructureLayer );
+ contextLayer,
+ domainLayer,
+ infrastructureLayer );
contextLayer.uses(
- domainLayer,
- infrastructureLayer );
+ domainLayer,
+ infrastructureLayer );
domainLayer.uses(
- contextLayer,
- infrastructureLayer
+ contextLayer,
+ infrastructureLayer
);
// Assemble
@@ -107,120 +107,125 @@ public class TestAssembler
return assembly;
}
- private void assembleBootstrapLayer( LayerAssembly bootstrapLayer ) throws AssemblyException
+ private void assembleBootstrapLayer( LayerAssembly bootstrapLayer )
+ throws AssemblyException
{
- ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" );
+ ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" ).withDefaultUnitOfWorkFactory();
// Load base data on startup
bootstrapModule
- .addServices(
- BaseDataService.class )
- .visibleIn( application )
- .instantiateOnStartup();
+ .addServices(
+ BaseDataService.class )
+ .visibleIn( application )
+ .instantiateOnStartup();
}
- private void assembleContextLayer( LayerAssembly contextLayer ) throws AssemblyException
+ private void assembleContextLayer( LayerAssembly contextLayer )
+ throws AssemblyException
{
// Role-playing entities
- ModuleAssembly entityRoleModule = contextLayer.module( "CONTEXT-EntityRole" );
+ ModuleAssembly entityRoleModule = contextLayer.module( "CONTEXT-EntityRole" ).withDefaultUnitOfWorkFactory();
entityRoleModule
- .entities(
- CargoRoleMap.class,
- CargosRoleMap.class,
- HandlingEventRoleMap.class,
- HandlingEventsRoleMap.class )
- .visibleIn( application );
-
+ .entities(
+ CargoRoleMap.class,
+ CargosRoleMap.class,
+ HandlingEventRoleMap.class,
+ HandlingEventsRoleMap.class )
+ .visibleIn( application );
// Role-playing values
- ModuleAssembly valueRoleModule = contextLayer.module( "CONTEXT-ValueRole" );
+ ModuleAssembly valueRoleModule = contextLayer.module( "CONTEXT-ValueRole" ).withDefaultUnitOfWorkFactory();
valueRoleModule
- .values(
- ItineraryRoleMap.class,
- RouteSpecificationRoleMap.class )
- .visibleIn( application );
-
+ .values(
+ ItineraryRoleMap.class,
+ RouteSpecificationRoleMap.class )
+ .visibleIn( application );
- ModuleAssembly contextSupportModule = contextLayer.module( "CONTEXT-ContextSupport" );
+ ModuleAssembly contextSupportModule = contextLayer.module( "CONTEXT-ContextSupport" )
+ .withDefaultUnitOfWorkFactory();
contextSupportModule
- .addServices(
- RoutingService.class,
- ApplicationEvents.class )
- .visibleIn( application );
+ .addServices(
+ RoutingService.class,
+ ApplicationEvents.class )
+ .visibleIn( application );
contextSupportModule
- .values(
- RegisterHandlingEventAttemptDTO.class )
- .visibleIn( application );
+ .values(
+ RegisterHandlingEventAttemptDTO.class )
+ .visibleIn( application );
}
- private void assembleDomainLayer( LayerAssembly domainLayer ) throws AssemblyException
+ private void assembleDomainLayer( LayerAssembly domainLayer )
+ throws AssemblyException
{
// Non-role-playing entities
- ModuleAssembly entityModule = domainLayer.module( "DOMAIN-Entity" );
+ ModuleAssembly entityModule = domainLayer.module( "DOMAIN-Entity" ).withDefaultUnitOfWorkFactory();
entityModule
- .entities(
- LocationEntity.class,
- VoyageEntity.class )
- .visibleIn( application );
-
+ .entities(
+ LocationEntity.class,
+ VoyageEntity.class )
+ .visibleIn( application );
// Non-role-playing values
- ModuleAssembly dataModule = domainLayer.module( "DOMAIN-Data" );
+ ModuleAssembly dataModule = domainLayer.module( "DOMAIN-Data" ).withDefaultUnitOfWorkFactory();
dataModule
- .values(
- TrackingId.class,
- Delivery.class,
- ExpectedHandlingEvent.class,
- UnLocode.class,
- Leg.class,
- CarrierMovement.class,
- Schedule.class,
- VoyageNumber.class )
- .visibleIn( application );
+ .values(
+ TrackingId.class,
+ Delivery.class,
+ ExpectedHandlingEvent.class,
+ UnLocode.class,
+ Leg.class,
+ CarrierMovement.class,
+ Schedule.class,
+ VoyageNumber.class )
+ .visibleIn( application );
}
- private void assembleInfrastructureLayer( LayerAssembly infrastructureLayer ) throws AssemblyException
+ private void assembleInfrastructureLayer( LayerAssembly infrastructureLayer )
+ throws AssemblyException
{
- ModuleAssembly serializationModule = infrastructureLayer.module( "INFRASTRUCTURE-Serialization" );
+ ModuleAssembly serializationModule = infrastructureLayer.module( "INFRASTRUCTURE-Serialization" )
+ .withDefaultUnitOfWorkFactory();
serializationModule
.services( OrgJsonValueSerializationService.class )
.taggedWith( ValueSerialization.Formats.JSON )
.setMetaInfo( new Function<Application, Module>()
- {
- @Override
- public Module apply( Application application )
{
- return application.findModule( "CONTEXT", "CONTEXT-ContextSupport" );
- }
- } )
- .visibleIn( application );
-
- ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" );
+ @Override
+ public Module apply( Application application )
+ {
+ return application.findModule( "CONTEXT", "CONTEXT-ContextSupport" );
+ }
+ } )
+ .visibleIn( application );
+
+ ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" )
+ .withDefaultUnitOfWorkFactory();
indexingModule
- .objects(
- EntityStateSerializer.class,
- EntityTypeSerializer.class );
+ .objects(
+ EntityStateSerializer.class,
+ EntityTypeSerializer.class );
indexingModule
- .addServices(
- MemoryRepositoryService.class,
- RdfIndexingEngineService.class )
- .visibleIn( application );
-
+ .addServices(
+ MemoryRepositoryService.class,
+ RdfIndexingEngineService.class )
+ .visibleIn( application );
- ModuleAssembly entityStoreModule = infrastructureLayer.module( "INFRASTRUCTURE-EntityStore" );
+ ModuleAssembly entityStoreModule = infrastructureLayer.module( "INFRASTRUCTURE-EntityStore" )
+ .withDefaultUnitOfWorkFactory();
entityStoreModule
- .addServices(
- MemoryEntityStoreService.class,
- UuidIdentityGeneratorService.class )
- .visibleIn( application );
+ .addServices(
+ MemoryEntityStoreService.class,
+ UuidIdentityGeneratorService.class )
+ .visibleIn( application );
- ModuleAssembly externalServiceModule = infrastructureLayer.module( "INFRASTRUCTURE-ExternalService" );
+ ModuleAssembly externalServiceModule = infrastructureLayer.module( "INFRASTRUCTURE-ExternalService" )
+ .withDefaultUnitOfWorkFactory();
externalServiceModule
- .importedServices(
- GraphTraversalService.class )
- .setMetaInfo( new GraphTraversalServiceImpl( new GraphDAO() ) )
- .visibleIn( application );
+ .importedServices(
+ GraphTraversalService.class )
+ .setMetaInfo( new GraphTraversalServiceImpl( new GraphDAO() ) )
+ .visibleIn( application );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
index 66974bf..236f48d 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
@@ -19,6 +19,7 @@ package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
import java.util.Date;
import java.util.List;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -52,19 +53,20 @@ public class BookNewCargoTest
{
private static final Date TODAY = new Date();
+ private UnitOfWorkFactory uowf;
@Before
public void prepareTest()
throws Exception
{
super.prepareTest();
-
+ uowf = module.unitOfWorkFactory();
}
@Test( expected = RouteException.class )
public void deviation2a_OriginAndDestinationSame() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
new BookNewCargo( CARGOS, HONGKONG, HONGKONG, day( 17 ) ).book();
@@ -73,7 +75,7 @@ public class BookNewCargoTest
@Test( expected = RouteException.class )
public void deviation_2b_1_DeadlineInThePastNotAccepted() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -83,7 +85,7 @@ public class BookNewCargoTest
@Test( expected = RouteException.class )
public void deviation_2b_2_DeadlineTodayIsTooEarly() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -93,7 +95,7 @@ public class BookNewCargoTest
@Test
public void deviation_2b_3_DeadlineTomorrowIsOkay() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -103,7 +105,7 @@ public class BookNewCargoTest
@Test
public void step_2_CreateNewCargo() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -143,7 +145,7 @@ public class BookNewCargoTest
@Test( expected = FoundNoRoutesException.class )
public void deviation_3a_NoRoutesCanBeThatFast() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -157,7 +159,7 @@ public class BookNewCargoTest
@Test
public void step_3_CalculatePossibleRoutes() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
@@ -187,7 +189,7 @@ public class BookNewCargoTest
@Test
public void step_5_AssignCargoToRoute() throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
index 30c91f9..2277e71 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
@@ -18,6 +18,7 @@
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
import java.util.Date;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -74,13 +75,15 @@ public class BuildDeliverySnapshotTest
private TrackingId trackingId;
private Cargo cargo;
private Itinerary itinerary;
+ private UnitOfWorkFactory uowf;
@Before
public void prepareTest()
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ uowf = module.unitOfWorkFactory();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HONGKONG = uow.get( Location.class, CNHKG.code().get() );
STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
SHANGHAI = uow.get( Location.class, CNSHA.code().get() );
@@ -153,7 +156,7 @@ public class BuildDeliverySnapshotTest
{
deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
@@ -268,7 +271,7 @@ public class BuildDeliverySnapshotTest
{
deviation_3a_CargoHasNoHandlingHistory();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Unexpected receipt in Shanghai
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null );
@@ -294,7 +297,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4a_RECEIVE_1a_UnexpectedPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Expected receipt in Hong Kong
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, HandlingEventType.RECEIVE, HONGKONG, null );
@@ -318,7 +321,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4a_RECEIVE_1b_ExpectedPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Unexpected load in Tokyo
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, TOKYO, V100S );
@@ -340,7 +343,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4b_LOAD_2a_UnexpectedPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Expected load in Hong Kong
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, HONGKONG, V100S );
@@ -364,7 +367,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4b_LOAD_2b_ExpectedPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Load onto unexpected voyage
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, HONGKONG, V400S );
@@ -386,7 +389,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// The system doesn't currently check if handling events happen in the right order, so
@@ -415,7 +418,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Unexpected unload in Tokyo
@@ -508,7 +511,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4c_UNLOAD_1a_UnexpectedPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Unload at midpoint location of itinerary
@@ -534,7 +537,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4c_UNLOAD_1b_ExpectedMidpointLocation();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Unload at destination
@@ -563,7 +566,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4c_UNLOAD_1c_Destination();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Cargo was handled by the customs authorities
@@ -590,7 +593,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Cargo was claimed but not at destination location
@@ -616,7 +619,7 @@ public class BuildDeliverySnapshotTest
{
deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
// Cargo was claimed by customer at destination location
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
index e5f9ad6..6a434f9 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
@@ -17,6 +17,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -55,12 +56,14 @@ public class InspectCargoTest
private Voyage V200T;
private Voyage V300A;
private HandlingEvent handlingEvent;
+ private UnitOfWorkFactory uowf;
@Before
public void beforeEachTest()
throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ uowf = module.unitOfWorkFactory();
+ UnitOfWork uow = uowf.currentUnitOfWork();
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
SHANGHAI = uow.get( Location.class, CNSHA.code().get() );
@@ -89,7 +92,7 @@ public class InspectCargoTest
throws Exception
{
// Create misdirected handling event for cargo (receipt in Shanghai is unexpected)
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 0 ), day( 0 ), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -106,7 +109,7 @@ public class InspectCargoTest
public void deviation_3b_CargoHasArrived()
throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 15 ), day( 15 ), trackingId, HandlingEventType.UNLOAD, STOCKHOLM, V300A );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -124,7 +127,7 @@ public class InspectCargoTest
throws Exception
{
logger.info( " Handling cargo 'ABC' (unloaded in Dallas):" );
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 12 ), day( 12 ), trackingId, HandlingEventType.UNLOAD, DALLAS, V200T );
cargo.delivery().set( new BuildDeliverySnapshot( cargo, handlingEvent ).get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
index 060d8d3..81e3ae6 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
@@ -64,7 +64,7 @@ public class RegisterHandlingEventTest
@Before
public void beforeEachTest() throws Exception {
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID );
HONGKONG = uow.get( Location.class, CNHKG.code().get() );
STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
index a694e43..939a3d2 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
@@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.NextHandlingEvent;
@@ -57,23 +57,23 @@ public abstract class BaseData
protected UnLocode USCHI;
protected UnLocode USDAL;
protected UnLocode USNYC;
- protected final Module module;
+ protected ValueBuilderFactory vbf;
- protected BaseData( Module module )
+ protected BaseData( ValueBuilderFactory vbf )
{
- this.module = module;
+ this.vbf = vbf;
}
protected UnLocode unlocode( String unlocodeString )
{
- ValueBuilder<UnLocode> unlocode = module.newValueBuilder( UnLocode.class );
+ ValueBuilder<UnLocode> unlocode = vbf.newValueBuilder( UnLocode.class );
unlocode.prototype().code().set( unlocodeString );
return unlocode.newInstance();
}
protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, Date depTime, Date arrTime )
{
- ValueBuilder<CarrierMovement> carrierMovement = module.newValueBuilder( CarrierMovement.class );
+ ValueBuilder<CarrierMovement> carrierMovement = vbf.newValueBuilder( CarrierMovement.class );
carrierMovement.prototype().departureLocation().set( depLoc );
carrierMovement.prototype().arrivalLocation().set( arrLoc );
carrierMovement.prototype().departureTime().set( depTime );
@@ -83,7 +83,7 @@ public abstract class BaseData
protected Schedule schedule( CarrierMovement... carrierMovements )
{
- ValueBuilder<Schedule> schedule = module.newValueBuilder( Schedule.class );
+ ValueBuilder<Schedule> schedule = vbf.newValueBuilder( Schedule.class );
List<CarrierMovement> cm = new ArrayList<>();
cm.addAll( Arrays.asList( carrierMovements ) );
schedule.prototype().carrierMovements().set( cm );
@@ -92,7 +92,7 @@ public abstract class BaseData
protected Leg leg( Voyage voyage, Location load, Location unload, Date loadTime, Date unloadTime )
{
- ValueBuilder<Leg> leg = module.newValueBuilder( Leg.class );
+ ValueBuilder<Leg> leg = vbf.newValueBuilder( Leg.class );
leg.prototype().voyage().set( voyage );
leg.prototype().loadLocation().set( load );
leg.prototype().unloadLocation().set( unload );
@@ -103,7 +103,7 @@ public abstract class BaseData
protected Itinerary itinerary( Leg... legArray )
{
- ValueBuilder<Itinerary> itinerary = module.newValueBuilder( Itinerary.class );
+ ValueBuilder<Itinerary> itinerary = vbf.newValueBuilder( Itinerary.class );
List<Leg> legs = new ArrayList<>();
legs.addAll( Arrays.asList( legArray ) );
itinerary.prototype().legs().set( legs );
@@ -121,7 +121,7 @@ public abstract class BaseData
NextHandlingEvent nextHandlingEvent
)
{
- ValueBuilder<Delivery> delivery = module.newValueBuilder( Delivery.class );
+ ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
delivery.prototype().timestamp().set( new Date() );
delivery.prototype().lastHandlingEvent().set( lastHandlingEvent );
delivery.prototype().transportStatus().set( transportStatus );
@@ -141,7 +141,7 @@ public abstract class BaseData
Integer itineraryProgressIndex
)
{
- ValueBuilder<Delivery> delivery = module.newValueBuilder( Delivery.class );
+ ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
delivery.prototype().timestamp().set( date );
delivery.prototype().transportStatus().set( transportStatus );
delivery.prototype().routingStatus().set( routingStatus );
@@ -155,7 +155,7 @@ public abstract class BaseData
Voyage voyage
)
{
- ValueBuilder<NextHandlingEvent> nextHandlingEvent = module.newValueBuilder( NextHandlingEvent.class );
+ ValueBuilder<NextHandlingEvent> nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class );
nextHandlingEvent.prototype().handlingEventType().set( handlingEventType );
nextHandlingEvent.prototype().location().set( location );
nextHandlingEvent.prototype().time().set( time );
@@ -172,7 +172,7 @@ public abstract class BaseData
)
throws Exception
{
- ValueBuilder<ParsedHandlingEventData> attempt = module.newValueBuilder( ParsedHandlingEventData.class );
+ ValueBuilder<ParsedHandlingEventData> attempt = vbf.newValueBuilder( ParsedHandlingEventData.class );
attempt.prototype().registrationTime().set( registrationTime );
attempt.prototype().completionTime().set( completionTime );
attempt.prototype().trackingIdString().set( trackingIdString );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseDataService.java
index fd3a23e..c8ed3d2 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseDataService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseDataService.java
@@ -28,10 +28,11 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.GraphTraversalService;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitEdge;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitPath;
@@ -51,8 +52,8 @@ import static org.apache.zest.api.usecase.UsecaseBuilder.newUsecase;
/**
* Create basic sample data on startup of application.
*/
-@Mixins(BaseDataService.Mixin.class)
-@Activators(BaseDataService.Activator.class)
+@Mixins( BaseDataService.Mixin.class )
+@Activators( BaseDataService.Activator.class )
public interface BaseDataService
extends ServiceComposite
{
@@ -76,14 +77,17 @@ public interface BaseDataService
extends BaseData
implements BaseDataService
{
+ @Structure
+ UnitOfWorkFactory uowf;
+
@Service
GraphTraversalService graphTraversalService;
private static final Logger logger = LoggerFactory.getLogger( BaseDataService.class );
- protected Mixin( @Structure Module module )
+ protected Mixin( @Structure ValueBuilderFactory vbf )
{
- super( module );
+ super( vbf );
}
@Override
@@ -92,7 +96,7 @@ public interface BaseDataService
{
logger.debug( "CREATING BASIC DATA..." );
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "Create base data" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Create base data" ) );
// Create locations
location( unlocode( "AUMEL" ), "Melbourne" );
@@ -125,7 +129,7 @@ public interface BaseDataService
carrierMovements.add( carrierMovement( from, to, voyageEdge.getFromDate(), voyageEdge.getToDate() ) );
}
- ValueBuilder<Schedule> schedule = module.newValueBuilder( Schedule.class );
+ ValueBuilder<Schedule> schedule = vbf.newValueBuilder( Schedule.class );
schedule.prototype().carrierMovements().set( carrierMovements );
voyage( voyageNumber, schedule.newInstance() );
}
@@ -154,14 +158,14 @@ public interface BaseDataService
protected UnLocode unlocode( String unlocodeString )
{
- ValueBuilder<UnLocode> unlocode = module.newValueBuilder( UnLocode.class );
+ ValueBuilder<UnLocode> unlocode = vbf.newValueBuilder( UnLocode.class );
unlocode.prototype().code().set( unlocodeString );
return unlocode.newInstance();
}
protected Location location( UnLocode unlocode, String locationStr )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Location> location = uow.newEntityBuilder( Location.class, unlocode.code().get() );
location.instance().unLocode().set( unlocode );
location.instance().name().set( locationStr );
@@ -170,11 +174,11 @@ public interface BaseDataService
protected Voyage voyage( String voyageNumberStr, Schedule schedule )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Voyage> voyage = uow.newEntityBuilder( Voyage.class, voyageNumberStr );
// VoyageNumber
- ValueBuilder<VoyageNumber> voyageNumber = module.newValueBuilder( VoyageNumber.class );
+ ValueBuilder<VoyageNumber> voyageNumber = vbf.newValueBuilder( VoyageNumber.class );
voyageNumber.prototype().number().set( voyageNumberStr );
voyage.instance().voyageNumber().set( voyageNumber.newInstance() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
index 5753a0c..b4866c1 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
@@ -22,23 +22,23 @@ import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
import org.apache.zest.api.activation.ActivatorAdapter;
import org.apache.zest.api.activation.Activators;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.routing.AssignCargoToRoute;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.ProcessHandlingEvent;
@@ -55,6 +55,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinera
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,8 +74,8 @@ import static org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Contex
*
* Add more cases if needed in the loop below.
*/
-@Mixins(SampleDataService.Mixin.class)
-@Activators(SampleDataService.Activator.class)
+@Mixins( SampleDataService.Mixin.class )
+@Activators( SampleDataService.Activator.class )
public interface SampleDataService
extends ServiceComposite
{
@@ -91,11 +94,20 @@ public interface SampleDataService
}
}
- public abstract class Mixin
+ abstract class Mixin
implements SampleDataService
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ ValueBuilderFactory vbf;
+
+ @Structure
+ QueryBuilderFactory qbf;
+
+ @Structure
+ TransientBuilderFactory tbf;
@Service
RoutingService routingService;
@@ -112,7 +124,7 @@ public interface SampleDataService
public void insertSampleData()
throws Exception
{
- prepareContextBaseClass( module );
+ prepareContextBaseClass( uowf, vbf );
logger.info( "###### CREATING SAMPLE DATA... ##########################################" );
@@ -120,11 +132,11 @@ public interface SampleDataService
populateRandomCargos( 12 );
// Handle cargos
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "Create sample data" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Create sample data" ) );
try
{
int i = 11; // starting at 11 for sortable tracking id prefix in lists
- QueryBuilder<Cargo> qb = module.newQueryBuilder( Cargo.class );
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
for( Cargo cargo : uow.newQuery( qb ) )
{
@@ -157,7 +169,7 @@ public interface SampleDataService
Location origin = routeSpec.origin().get();
Location dest = routeSpec.destination().get();
Location badDest = null;
- Query<Location> locations = uow.newQuery( module.newQueryBuilder( Location.class ) );
+ Query<Location> locations = uow.newQuery( qbf.newQueryBuilder( Location.class ) );
for( Location loc : locations )
{
if( !origin.equals( loc ) && !dest.equals( loc ) )
@@ -193,8 +205,8 @@ public interface SampleDataService
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
// Find earliest wrong carrier movement (voyage) with same departure location
- final Query<Voyage> voyages = module.currentUnitOfWork()
- .newQuery( module.newQueryBuilder( Voyage.class ) );
+ final Query<Voyage> voyages = uowf.currentUnitOfWork()
+ .newQuery( qbf.newQueryBuilder( Voyage.class ) );
int depth = 0;
do
{
@@ -341,11 +353,11 @@ public interface SampleDataService
private void populateRandomCargos( int numberOfCargos )
{
Usecase usecase = UsecaseBuilder.newUsecase( "Populate Random Cargos" );
- UnitOfWork uow = module.newUnitOfWork( usecase );
+ UnitOfWork uow = uowf.newUnitOfWork( usecase );
CargoAggregateRoot cargos = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
- Query<Location> allLocations = uow.newQuery( module.newQueryBuilder( Location.class ) );
+ Query<Location> allLocations = uow.newQuery( qbf.newQueryBuilder( Location.class ) );
int locationSize = (int) allLocations.count();
// Make array for selection of location with random index
@@ -402,7 +414,7 @@ public interface SampleDataService
)
throws Exception
{
- ValueBuilder<ParsedHandlingEventData> event = module.newValueBuilder( ParsedHandlingEventData.class );
+ ValueBuilder<ParsedHandlingEventData> event = vbf.newValueBuilder( ParsedHandlingEventData.class );
event.prototype().registrationTime().set( registrationTime );
event.prototype().completionTime().set( completionTime );
event.prototype().trackingIdString().set( trackingIdString );
@@ -410,7 +422,7 @@ public interface SampleDataService
event.prototype().unLocodeString().set( unLocodeString );
event.prototype().voyageNumberString().set( voyageNumberString );
- module.newTransient( ProcessHandlingEvent.class ).register( event.newInstance() );
+ tbf.newTransient( ProcessHandlingEvent.class ).register( event.newInstance() );
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
index 55ceeab..ad391db 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
@@ -23,13 +23,17 @@ import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.zest.api.ZestAPI;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.bootstrap.ApplicationAssembler;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.EntityToDTOService;
@@ -54,7 +58,16 @@ public class WicketZestApplication
protected Module zestModule;
@Structure
- protected Module module;
+ protected UnitOfWorkFactory uowf;
+
+ @Structure
+ protected ValueBuilderFactory vbf;
+
+ @Structure
+ protected TransientBuilderFactory tbf;
+
+ @Structure
+ protected QueryBuilderFactory qbf;
@Structure
protected ZestAPI api;
@@ -118,10 +131,10 @@ public class WicketZestApplication
startZest();
handleUnitOfWork();
- Context.prepareContextBaseClass( module );
- BaseWebPage.prepareBaseWebPageClass( module );
+ Context.prepareContextBaseClass( uowf, vbf );
+ BaseWebPage.prepareBaseWebPageClass( tbf );
ReadOnlyModel.prepareModelBaseClass( zestModule, api, valueConverter );
- Queries.prepareQueriesBaseClass( module, module );
+ Queries.prepareQueriesBaseClass( uowf, qbf );
wicketInit();
}
@@ -163,14 +176,14 @@ public class WicketZestApplication
logger.debug( requestCycle.getRequest().toString() );
logger.debug( requestCycle.getRequest().getRequestParameters().toString() );
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "REQUEST" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "REQUEST" ) );
logger.debug( " ### NEW " + uow + " ### MODULE: " + zestModule );
}
@Override
public void onEndRequest( final RequestCycle requestCycle )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow != null )
{
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/dci/Context.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/dci/Context.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/dci/Context.java
index f74c29b..f57a0be 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/dci/Context.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/dci/Context.java
@@ -19,8 +19,9 @@ package org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.api.value.ValueComposite;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +42,8 @@ public abstract class Context
*
* All entities should be created through aggregate r
*/
- private static Module module;
+ private static ValueBuilderFactory vbf;
+ private static UnitOfWorkFactory uowf;
protected Context()
{
@@ -122,22 +124,23 @@ public abstract class Context
protected <T, U> T rolePlayer( Class<T> roleClass, Class<U> dataClass, String entityId )
{
- U dataObject = module.currentUnitOfWork().get( dataClass, entityId );
+ U dataObject = uowf.currentUnitOfWork().get( dataClass, entityId );
return rolePlayer( roleClass, dataObject );
}
protected static <T> T loadEntity( Class<T> entityRoleClass, String entityId )
{
- return module.currentUnitOfWork().get( entityRoleClass, entityId );
+ return uowf.currentUnitOfWork().get( entityRoleClass, entityId );
}
protected static <T extends ValueComposite> ValueBuilder<T> valueBuilder( Class<T> valueClass )
{
- return module.newValueBuilder( valueClass );
+ return vbf.newValueBuilder( valueClass );
}
- public static void prepareContextBaseClass( Module module )
+ public static void prepareContextBaseClass( UnitOfWorkFactory uowf, ValueBuilderFactory vbf )
{
- Context.module = module;
+ Context.uowf = uowf;
+ Context.vbf = vbf;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
index 459488b..4383ed1 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
@@ -73,10 +73,10 @@ public class EntityModel<T extends DTO, U extends EntityComposite>
private U loadEntity()
{
- U entity = module.currentUnitOfWork().get( entityClass, identity );
+ U entity = uowf.currentUnitOfWork().get( entityClass, identity );
if( entity == null )
{
- Usecase usecase = module.currentUnitOfWork().usecase();
+ Usecase usecase = uowf.currentUnitOfWork().usecase();
throw new NoSuchEntityException( EntityReference.parseEntityReference( identity ), entityClass, usecase );
}
return entity;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/JSONModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/JSONModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/JSONModel.java
index aa9a2d9..4aa7567 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/JSONModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/JSONModel.java
@@ -35,7 +35,7 @@ public class JSONModel<T, U extends ValueComposite>
@SuppressWarnings( "unchecked" )
public JSONModel( T valueComposite, Class<U> valueCompositeClass )
{
- json = module.findService( ValueSerializer.class ).get().serialize( (U) valueComposite );;
+ json = serviceFinder.findService( ValueSerializer.class ).get().serialize( (U) valueComposite );;
this.valueCompositeClass = valueCompositeClass;
}
@@ -59,7 +59,7 @@ public class JSONModel<T, U extends ValueComposite>
if( valueComposite == null && json != null )
{
// De-serialize
- valueComposite = (T) module.newValueFromSerializedState( valueCompositeClass, json ); // Unchecked cast
+ valueComposite = (T) vbf.newValueFromSerializedState( valueCompositeClass, json ); // Unchecked cast
}
return valueComposite;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
index fb99ade..ad3ef43 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
@@ -19,7 +19,10 @@ package org.apache.zest.sample.dcicargo.sample_b.infrastructure.model;
import org.apache.wicket.model.IModel;
import org.apache.zest.api.ZestAPI;
+import org.apache.zest.api.service.ServiceFinder;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.EntityToDTOService;
/**
@@ -34,7 +37,9 @@ public abstract class ReadOnlyModel<T>
static protected EntityToDTOService valueConverter;
static protected ZestAPI api;
- static protected Module module;
+ static protected ServiceFinder serviceFinder;
+ static protected UnitOfWorkFactory uowf;
+ static protected ValueBuilderFactory vbf;
/**
* This default implementation of setObject unconditionally throws an
@@ -64,7 +69,9 @@ public abstract class ReadOnlyModel<T>
EntityToDTOService entityToDTO
)
{
- module = m;
+ uowf = m.unitOfWorkFactory();
+ serviceFinder = m;
+ vbf = m;
ReadOnlyModel.api = api;
valueConverter = entityToDTO;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
index fa2c3ed..1c51598 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
@@ -19,6 +19,9 @@ package org.apache.zest.sample.dcicargo.sample_b.bootstrap.test;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.service.ServiceFinder;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -65,6 +68,10 @@ import static org.junit.Assert.*;
public class TestApplication
extends BaseData
{
+ protected static ServiceFinder serviceFinder;
+ protected static UnitOfWorkFactory uowf;
+ protected static QueryBuilderFactory qbf;
+
// Logger for sub classes
protected Logger logger = LoggerFactory.getLogger( getClass() );
@@ -157,7 +164,11 @@ public class TestApplication
System.out.println( "\n@@@@@@@@@@@ TEST SUITE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" );
app = new Energy4Java().newApplication( new TestAssembler() );
app.activate();
- Context.prepareContextBaseClass( findHostingModule() );
+ Module module = findHostingModule();
+ serviceFinder = module;
+ qbf = module;
+ uowf = module.unitOfWorkFactory();
+ Context.prepareContextBaseClass( module.unitOfWorkFactory(), module );
}
@@ -175,11 +186,11 @@ public class TestApplication
{
logger.info( name.getMethodName() );
Usecase usecase = UsecaseBuilder.newUsecase( "Usecase:" + name );
- UnitOfWork uow = module.newUnitOfWork(usecase);
+ UnitOfWork uow = uowf.newUnitOfWork( usecase);
populateTestData();
ServiceReference<RouteSpecificationFactoryService> routeSpecFactoryServiceRef =
- module.findService( RouteSpecificationFactoryService.class );
+ serviceFinder.findService( RouteSpecificationFactoryService.class );
routeSpecFactory = routeSpecFactoryServiceRef.get();
// Separate test suites in console output
@@ -189,16 +200,16 @@ public class TestApplication
@After
public void concludeTests()
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if (uow != null)
{
uow.discard();
}
- if( module.isUnitOfWorkActive() )
+ if( uowf.isUnitOfWorkActive() )
{
- while( module.isUnitOfWorkActive() )
+ while( uowf.isUnitOfWorkActive() )
{
- uow = module.currentUnitOfWork();
+ uow = uowf.currentUnitOfWork();
if( uow.isOpen() )
{
System.err.println( "UnitOfWork not cleaned up:" + uow.usecase().name() );
@@ -247,7 +258,7 @@ public class TestApplication
USDAL = unlocode( "USDAL" ); // Dallas
USNYC = unlocode( "USNYC" ); // New York
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
// Get locations created in BaseDataService on startup
MELBOURNE = uow.get( Location.class, "AUMEL" );
@@ -430,11 +441,11 @@ public class TestApplication
protected Voyage voyage( String voyageNumberStr, Schedule schedule )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Voyage> voyage = uow.newEntityBuilder( Voyage.class, voyageNumberStr );
// VoyageNumber
- ValueBuilder<VoyageNumber> voyageNumber = module.newValueBuilder( VoyageNumber.class );
+ ValueBuilder<VoyageNumber> voyageNumber = vbf.newValueBuilder( VoyageNumber.class );
voyageNumber.prototype().number().set( voyageNumberStr );
voyage.instance().voyageNumber().set( voyageNumber.newInstance() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
index 1995a0b..42e7a04 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
@@ -113,7 +113,7 @@ public class TestAssembler
private void assembleBootstrapLayer( LayerAssembly bootstrapLayer )
throws AssemblyException
{
- ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" );
+ ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" ).withDefaultUnitOfWorkFactory();
// Load base data on startup
bootstrapModule
@@ -125,7 +125,7 @@ public class TestAssembler
private void assembleContextLayer( LayerAssembly contextLayer )
throws AssemblyException
{
- ModuleAssembly roleMapModule = contextLayer.module( "CONTEXT-RoleMap" );
+ ModuleAssembly roleMapModule = contextLayer.module( "CONTEXT-RoleMap" ).withDefaultUnitOfWorkFactory();
// Role-playing entities
roleMapModule
@@ -143,13 +143,13 @@ public class TestAssembler
VoyageEntity.class )
.visibleIn( application );
- ModuleAssembly interactionModule = contextLayer.module( "CONTEXT-Interaction" );
+ ModuleAssembly interactionModule = contextLayer.module( "CONTEXT-Interaction" ).withDefaultUnitOfWorkFactory();
interactionModule
.transients(
ProcessHandlingEvent.class )
.visibleIn( application );
- ModuleAssembly contextServiceModule = contextLayer.module( "CONTEXT-Service" );
+ ModuleAssembly contextServiceModule = contextLayer.module( "CONTEXT-Service" ).withDefaultUnitOfWorkFactory();
contextServiceModule
.services(
ParseHandlingEventData.class,
@@ -167,7 +167,7 @@ public class TestAssembler
throws AssemblyException
{
// Non-role-playing values
- ModuleAssembly structureModule = dataLayer.module( "DATA-Structure" );
+ ModuleAssembly structureModule = dataLayer.module( "DATA-Structure" ).withDefaultUnitOfWorkFactory();
structureModule
.values(
TrackingId.class,
@@ -187,14 +187,14 @@ public class TestAssembler
private void assembleInfrastructureLayer( LayerAssembly infrastructureLayer )
throws AssemblyException
{
- ModuleAssembly serializationModule = infrastructureLayer.module( "INFRASTRUCTURE-Serialization" );
+ ModuleAssembly serializationModule = infrastructureLayer.module( "INFRASTRUCTURE-Serialization" ).withDefaultUnitOfWorkFactory();
serializationModule
.services( OrgJsonValueSerializationService.class )
.taggedWith( ValueSerialization.Formats.JSON )
.setMetaInfo( (Function<Application, Module>) application -> application.findModule( "CONTEXT", "CONTEXT-RoleMap" ) )
.visibleIn( application );
- ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" );
+ ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" ).withDefaultUnitOfWorkFactory();
indexingModule
.objects(
EntityStateSerializer.class,
@@ -207,14 +207,14 @@ public class TestAssembler
.visibleIn( application )
.instantiateOnStartup();
- ModuleAssembly entityStoreModule = infrastructureLayer.module( "INFRASTRUCTURE-EntityStore" );
+ ModuleAssembly entityStoreModule = infrastructureLayer.module( "INFRASTRUCTURE-EntityStore" ).withDefaultUnitOfWorkFactory();
entityStoreModule
.addServices(
MemoryEntityStoreService.class,
UuidIdentityGeneratorService.class )
.visibleIn( application );
- ModuleAssembly externalServiceModule = infrastructureLayer.module( "INFRASTRUCTURE-ExternalService" );
+ ModuleAssembly externalServiceModule = infrastructureLayer.module( "INFRASTRUCTURE-ExternalService" ).withDefaultUnitOfWorkFactory();
externalServiceModule
.importedServices(
GraphTraversalService.class )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
index cacd426..aa9a944 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
@@ -50,7 +50,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
}
@@ -101,7 +101,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
deviation_2b_DeadlineTomorrowIsOkay();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).getTrackingId();
cargo = uow.get( CargoEntity.class, trackingId.id().get() );
assertThat( cargo.routeSpecification().get().origin().get(), is( equalTo( HONGKONG ) ) );
@@ -114,7 +114,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
step_2_CanCreateRouteSpecification();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).getTrackingId();
cargo = uow.get( CargoEntity.class, trackingId.id().get() );
assertDelivery( null, null, null, null,
@@ -137,7 +137,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
deviation_4a_TrackingIdTooShort();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "yes" );
cargo = uow.get( CargoEntity.class, trackingId.id().get() );
assertThat( cargo.trackingId().get().id().get(), is( equalTo( "yes" ) ) );
@@ -157,7 +157,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
deviation_4a_TrackingIdTooLong();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "123456789012345678901234567890" );
cargo = uow.get( CargoEntity.class, trackingId.id().get() );
assertThat( cargo.trackingId().get().id().get(), is( equalTo( "123456789012345678901234567890" ) ) );
@@ -202,7 +202,7 @@ public class BookNewCargoTest extends TestApplication
throws Exception
{
step_4_CanAutoCreateTrackingIdFromNull();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "ABC" );
cargo = uow.get( CargoEntity.class, trackingId.id().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
index 7682ceb..f21169b 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
@@ -55,7 +55,7 @@ public class AssignCargoToRouteTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
index 00474d2..c35d4e2 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/RegisterNewDestinationTest.java
@@ -54,7 +54,7 @@ public class RegisterNewDestinationTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
index e8fb093..a8bb584 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/specification/DeriveUpdatedRouteSpecTest.java
@@ -42,7 +42,7 @@ public class DeriveUpdatedRouteSpecTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
index 1b61869..b1fb4c3 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
@@ -48,7 +48,7 @@ public class InspectArrivedCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
index 7b6bd59..7f32055 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
@@ -47,7 +47,7 @@ public class InspectCargoInCustomsTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
index bf8aa65..d161ef3 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
@@ -45,7 +45,7 @@ public class InspectClaimedCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
index ddc6026..6d9b4f3 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
@@ -63,7 +63,7 @@ public class InspectLoadedCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
// Create new cargo
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
index 89c45bf..c7591ae 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
@@ -53,7 +53,7 @@ public class InspectReceivedCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
index 4f6b473..a5d1242 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
@@ -47,7 +47,7 @@ public class InspectUnhandledCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
index a8b8a31..7146839 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
@@ -55,7 +55,7 @@ public class InspectUnloadedCargoTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
index d296149..1b81117 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
@@ -46,7 +46,7 @@ public class ParseHandlingEventDataTest extends TestApplication
{
super.prepareTest();
TestApplication.setup();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
@@ -60,7 +60,7 @@ public class ParseHandlingEventDataTest extends TestApplication
// Start ParseHandlingEventData service
ServiceReference<ParseHandlingEventData> ParseHandlingEventDataRef =
- module.findService( ParseHandlingEventData.class );
+ serviceFinder.findService( ParseHandlingEventData.class );
handlingEventParser = ParseHandlingEventDataRef.get();
}
[08/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
index bb7f78f..b67db87 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
@@ -21,6 +21,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Rule;
import org.junit.Test;
import org.apache.zest.api.common.Visibility;
@@ -61,7 +62,7 @@ public class Qi95IssueTest
{
application.activate();
Module domain = application.findModule( "Domain", "Domain" );
- UnitOfWorkFactory unitOfWorkFactory = domain;
+ UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
}
finally
@@ -79,7 +80,7 @@ public class Qi95IssueTest
{
application.activate();
Module domain = application.findModule( "Domain", "Domain" );
- UnitOfWorkFactory unitOfWorkFactory = domain;
+ UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
}
finally
@@ -97,7 +98,7 @@ public class Qi95IssueTest
{
application.activate();
Module domain = application.findModule( "Domain", "Domain" );
- UnitOfWorkFactory unitOfWorkFactory = domain;
+ UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
}
finally
@@ -116,7 +117,7 @@ public class Qi95IssueTest
application.activate();
Module domain = application.findModule( "Domain", "Domain" );
- UnitOfWorkFactory unitOfWorkFactory = domain;
+ UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
}
finally
@@ -278,6 +279,7 @@ public class Qi95IssueTest
throws AssemblyException
{
module.entities( ItemTypeEntity.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
} );
return domainLayer;
@@ -293,6 +295,7 @@ public class Qi95IssueTest
throws AssemblyException
{
new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
module.entities( NativeConfiguration.class ).visibleIn( Visibility.application );
module.forMixin( NativeConfiguration.class )
@@ -320,6 +323,7 @@ public class Qi95IssueTest
{
new OrgJsonValueSerializationAssembler().assemble( module );
new JdbmEntityStoreAssembler().visibleIn( Visibility.application ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
}
@@ -329,6 +333,7 @@ public class Qi95IssueTest
{
ModuleAssembly moduleAssembly = layerAssembly.module( name );
assembler.assemble( moduleAssembly );
+ new DefaultUnitOfWorkAssembler().assemble( moduleAssembly );
return moduleAssembly;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
index 29509ea..621b02f 100644
--- a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
+++ b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
@@ -73,7 +73,7 @@ public class SolrQueryServiceTest
throws UnitOfWorkCompletionException, InterruptedException
{
// Create and index an entity
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
TestEntity test = uow.newEntity( TestEntity.class );
test.name().set( "Hello World" );
uow.complete();
@@ -85,7 +85,7 @@ public class SolrQueryServiceTest
throws UnitOfWorkCompletionException
{
// Search for it
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
Query<TestEntity> query = uow.newQuery( module.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
TestEntity test = query.find();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
index 3079c84..d9cd3d1 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
@@ -62,7 +62,7 @@ import org.apache.zest.api.query.grammar.PropertyNotNullPredicate;
import org.apache.zest.api.query.grammar.PropertyNullPredicate;
import org.apache.zest.api.query.grammar.Variable;
import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.functional.Iterables;
import org.apache.zest.index.sql.support.api.SQLQuerying;
@@ -108,7 +108,7 @@ public abstract class AbstractSQLQuerying
private PostgreSQLTypeHelper _typeHelper;
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Structure
private ZestSPI spi;
@@ -1052,7 +1052,7 @@ public abstract class AbstractSQLQuerying
// EntityComposite?
if( value instanceof EntityComposite )
{
- value = module.currentUnitOfWork().get(
+ value = uowf.currentUnitOfWork().get(
(EntityComposite) value ).identity().get();
}
else
@@ -1853,7 +1853,7 @@ public abstract class AbstractSQLQuerying
fromClause, groupBy, having, qNameJoins, variables, values, valueSQLTypes );
} );
- // @formatter:on
+ // @formatter:on
}
else
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
index d6b2bcb..2e1389d 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
@@ -80,11 +80,11 @@ public class PostgreSQLDBIntegrityTest
public void createAndRemoveEntityAndVerifyNoExtraDataLeftInDB()
throws Exception
{
- UnitOfWork uow = this.module.newUnitOfWork();
+ UnitOfWork uow = this.uowf.newUnitOfWork();
TestEntity entity = uow.newEntity( TestEntity.class );
uow.complete();
- uow = this.module.newUnitOfWork();
+ uow = this.uowf.newUnitOfWork();
entity = uow.get( entity );
SQLConfiguration config = uow.get( SQLConfiguration.class, PostgreSQLIndexQueryAssembler.DEFAULT_IDENTITY );
String schemaName = config.schemaName().get();
@@ -127,16 +127,16 @@ public class PostgreSQLDBIntegrityTest
public void createAndModifyEntity()
throws Exception
{
- UnitOfWork uow = this.module.newUnitOfWork();
+ UnitOfWork uow = this.uowf.newUnitOfWork();
TestEntity entity = uow.newEntity( TestEntity.class );
uow.complete();
- uow = this.module.newUnitOfWork();
+ uow = this.uowf.newUnitOfWork();
entity = uow.get( entity );
entity.testString().set( "NewTestString" );
uow.complete();
- uow = this.module.newUnitOfWork();
+ uow = this.uowf.newUnitOfWork();
entity = uow.get( entity );
Assert.assertEquals( "New value did not store in indexing.", "NewTestString", entity
.testString().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
----------------------------------------------------------------------
diff --git a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
index 8fc6cdc..672d32f 100644
--- a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
+++ b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
@@ -59,7 +59,7 @@ public class NoMetricsInstalledTest extends AbstractZestTest
private void readEntity( int id )
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
Person p = uow.get( Person.class, "" + id );
@@ -74,7 +74,7 @@ public class NoMetricsInstalledTest extends AbstractZestTest
private void createEntity( int id )
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
uow.newEntity( Person.class, "" + id );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
----------------------------------------------------------------------
diff --git a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
index 3f13774..716ee1f 100644
--- a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
+++ b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
@@ -60,7 +60,7 @@ public class YammerTest extends AbstractZestTest
private void readEntity( int id )
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
Person p = uow.get( Person.class, "" + id );
@@ -75,7 +75,7 @@ public class YammerTest extends AbstractZestTest
private void createEntity( int id )
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
uow.newEntity( Person.class, "" + id );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
----------------------------------------------------------------------
diff --git a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
index 1e1f091..fe2b2fa 100644
--- a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
+++ b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
@@ -16,6 +16,7 @@ package org.apache.zest.migration;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.hamcrest.CoreMatchers;
import org.json.JSONException;
import org.json.JSONObject;
@@ -53,6 +54,7 @@ public class MigrationTest
throws AssemblyException
{
new EntityTestAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
module.objects( MigrationEventLogger.class );
module.importedServices( MigrationEventLogger.class ).importedBy( NewObjectImporter.class );
@@ -110,7 +112,7 @@ public class MigrationTest
}
};
- UnitOfWork uow = v1.module().newUnitOfWork();
+ UnitOfWork uow = v1.module().unitOfWorkFactory().newUnitOfWork();
TestEntity1_0 entity = uow.newEntity( TestEntity1_0.class );
entity.foo().set( "Some value" );
entity.fooManyAssoc().add( entity );
@@ -141,7 +143,7 @@ public class MigrationTest
BackupRestore testData = v1_1.module().findService( BackupRestore.class ).get();
data_v1.transferTo( testData.restore() );
- UnitOfWork uow = v1_1.module().newUnitOfWork();
+ UnitOfWork uow = v1_1.module().unitOfWorkFactory().newUnitOfWork();
TestEntity1_1 entity = uow.get( TestEntity1_1.class, id );
assertThat( "Property has been renamed", entity.newFoo().get(), CoreMatchers.equalTo( "Some value" ) );
assertThat( "ManyAssociation has been renamed", entity.newFooManyAssoc().count(), CoreMatchers.equalTo( 1 ) );
@@ -169,7 +171,7 @@ public class MigrationTest
// Test migration from 1.0 -> 2.0
{
data_v1.transferTo( testData.restore() );
- UnitOfWork uow = v2_0.module().newUnitOfWork();
+ UnitOfWork uow = v2_0.module().unitOfWorkFactory().newUnitOfWork();
TestEntity2_0 entity = uow.get( TestEntity2_0.class, id );
assertThat( "Property has been created", entity.bar().get(), CoreMatchers.equalTo( "Some value" ) );
assertThat( "Custom Property has been created", entity.customBar().get(), CoreMatchers.equalTo( "Hello Some value" ) );
@@ -198,7 +200,7 @@ public class MigrationTest
// Test migration from 1.0 -> 3.0
{
data_v1.transferTo( testData.restore() );
- UnitOfWork uow = v3_0.module().newUnitOfWork();
+ UnitOfWork uow = v3_0.module().unitOfWorkFactory().newUnitOfWork();
org.apache.zest.migration.moved.TestEntity2_0 entity = uow.get( org.apache.zest.migration.moved.TestEntity2_0.class, id );
uow.complete();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
index 8fd67cf..c95a8bc 100644
--- a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
+++ b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
@@ -93,7 +93,7 @@ public class ReindexerTest
// ----> Create data and wipe index
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
EntityBuilder<MyEntity> eBuilder = uow.newEntityBuilder( MyEntity.class );
MyEntity e = eBuilder.instance();
@@ -110,7 +110,7 @@ public class ReindexerTest
module.<ReindexerService>findService( ReindexerService.class ).get().reindex(); // Reindex
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
QueryBuilder<MyEntity> qBuilder = module.newQueryBuilder( MyEntity.class );
qBuilder = qBuilder.where( eq( templateFor( MyEntity.class ).name(), TEST_NAME ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
index f492b5c..934603c 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
@@ -20,27 +20,32 @@ import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
-@Mixins(AlarmPointFactory.Mixin.class)
+@Mixins( AlarmPointFactory.Mixin.class )
public interface AlarmPointFactory extends ServiceComposite
{
- AlarmPoint create(String identity, String systemName, String categoryName, AlarmClass alarmClass );
-
+ AlarmPoint create( String identity, String systemName, String categoryName, AlarmClass alarmClass );
+
abstract class Mixin
- implements AlarmPointFactory {
+ implements AlarmPointFactory
+ {
+
+ @Structure
+ private UnitOfWorkFactory uowf;
@Structure
- private Module module;
-
+ private ValueBuilderFactory vbf;
+
@Override
public AlarmPoint create( String identity, String systemName, String categoryName, AlarmClass alarmClass )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, identity );
- builder.instance().category().set( createCategory(categoryName) );
+ builder.instance().category().set( createCategory( categoryName ) );
builder.instance().alarmClass().set( alarmClass );
AlarmPoint.AlarmState prototype = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -53,14 +58,14 @@ public interface AlarmPointFactory extends ServiceComposite
private AlarmStatus createNormalAlarmStatus()
{
- ValueBuilder<AlarmStatus> builder = module.newValueBuilder( AlarmStatus.class );
- builder.prototypeFor(AlarmStatus.State.class).name().set( AlarmPoint.STATUS_NORMAL );
+ ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
+ builder.prototypeFor( AlarmStatus.State.class ).name().set( AlarmPoint.STATUS_NORMAL );
return builder.newInstance();
}
private AlarmCategory createCategory( String categoryName )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = vbf.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( categoryName );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
index 6d2ef32..08f45bb 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Locale;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.composite.TransientBuilder;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.composite.TransientComposite;
import org.apache.zest.api.concern.Concerns;
import org.apache.zest.api.injection.scope.Service;
@@ -27,9 +28,9 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
@@ -38,9 +39,9 @@ import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
public interface AlarmProxy extends AlarmPoint, TransientComposite
{
@Mixins( FactoryMixin.class )
- public interface Factory extends ServiceComposite
+ interface Factory extends ServiceComposite
{
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.REQUIRED)
+ @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.REQUIRED )
AlarmProxy create( String identity, String systemName, String categoryName, AlarmClass alarmClass );
}
@@ -48,7 +49,10 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
implements Factory
{
@Structure
- private Module module;
+ private TransientBuilderFactory tbf;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
@Service
private AlarmPointFactory factory;
@@ -56,7 +60,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
@Override
public AlarmProxy create( String identity, String systemName, String categoryName, AlarmClass alarmClass )
{
- UnitOfWork unitOfWork = module.currentUnitOfWork();
+ UnitOfWork unitOfWork = uowf.currentUnitOfWork();
AlarmPoint alarmPoint;
try
{
@@ -66,7 +70,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
{
alarmPoint = factory.create( identity, systemName, categoryName, alarmClass );
}
- TransientBuilder<AlarmProxy> builder = module.newTransientBuilder( AlarmProxy.class );
+ TransientBuilder<AlarmProxy> builder = tbf.newTransientBuilder( AlarmProxy.class );
builder.prototype().category().set( alarmPoint.category().get() );
builder.prototype().alarmClass().set( alarmClass );
builder.use( identity );
@@ -79,7 +83,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Uses
String identity;
@@ -199,7 +203,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
private AlarmPoint findAlarmPoint()
{
- return module.currentUnitOfWork().get( AlarmPoint.class, identity );
+ return uowf.currentUnitOfWork().get( AlarmPoint.class, identity );
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
index 2b27fc3..2589ed0 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
@@ -66,16 +66,16 @@ public class AlarmHistoryImplTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- if (module.isUnitOfWorkActive())
+ if (uowf.isUnitOfWorkActive())
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
uow.discard();
}
super.tearDown();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
index 1e0b3ca..fd79250 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
@@ -64,16 +64,16 @@ public class AlarmPointImplTest extends AbstractZestTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- if( module.isUnitOfWorkActive() )
+ if( uowf.isUnitOfWorkActive() )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
uow.discard();
}
super.tearDown();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
index 718a822..8cd14b3 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
@@ -51,7 +51,7 @@ public class AlarmProxyTest extends AbstractZestTest
public void givenAlarmPointWhenActivateExpectActivationEvent()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
// START SNIPPET: documentation
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
index b08e189..e1d6ea0 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
@@ -67,16 +67,16 @@ public class AlarmServiceTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- if (module.isUnitOfWorkActive())
+ if (uowf.isUnitOfWorkActive())
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
uow.discard();
}
super.tearDown();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
index 98079ac..0df9255 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
@@ -67,14 +67,14 @@ public class ExtendedAlarmModelTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow != null )
{
uow.discard();
@@ -942,7 +942,7 @@ public class ExtendedAlarmModelTest
private AlarmPoint createAlarm( String name )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
builder.instance().category().set( createCategory( "Testing" ) );
AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -961,7 +961,7 @@ public class ExtendedAlarmModelTest
private AlarmPoint getAlarm( String identity )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
return uow.get( AlarmPoint.class, identity );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
index a7dd590..78ff217 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
@@ -67,14 +67,14 @@ public class SimpleAlarmModelTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow != null )
{
uow.discard();
@@ -327,7 +327,7 @@ public class SimpleAlarmModelTest
private AlarmPoint createAlarm( String name )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
builder.instance().category().set( createCategory( "SimpleModelTest" ) );
AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -346,7 +346,7 @@ public class SimpleAlarmModelTest
private AlarmPoint getAlarm( String identity )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
return uow.get( AlarmPoint.class, identity );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
index 69dab9b..84d10b6 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
@@ -68,14 +68,14 @@ public class StandardAlarmModelTest
throws Exception
{
super.setUp();
- module.newUnitOfWork();
+ uowf.newUnitOfWork();
}
@Override
public void tearDown()
throws Exception
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow != null )
{
uow.discard();
@@ -453,7 +453,7 @@ public class StandardAlarmModelTest
private AlarmPoint createAlarm( String name )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
builder.instance().category().set( createCategory( "StandardModelTest" ) );
AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -472,7 +472,7 @@ public class StandardAlarmModelTest
private AlarmPoint getAlarm( String identity )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
return uow.get( AlarmPoint.class, identity );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
index ae9cf5d..02eeb15 100644
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
+++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
@@ -39,11 +39,12 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.functional.Iterables;
import org.apache.zest.spi.ZestSPI;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import static org.apache.zest.library.conversion.values.Shared.STRING_COLLECTION_TYPE_SPEC;
@@ -125,6 +126,9 @@ public class ValueToEntityMixin
private ZestSPI spi;
@Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
private ModuleSpi module;
@Override
@@ -299,7 +303,7 @@ public class ValueToEntityMixin
}
}
};
- return module.currentUnitOfWork().newEntityBuilderWithState(
+ return uowf.currentUnitOfWork().newEntityBuilderWithState(
entityType, identity, props, assocs, manyAssocs, namedAssocs
);
}
@@ -405,7 +409,7 @@ public class ValueToEntityMixin
}
}
};
- return module.currentUnitOfWork().newEntityBuilderWithState(
+ return uowf.currentUnitOfWork().newEntityBuilderWithState(
entityType, identity, props, assocs, manyAssocs, namedAssocs
);
}
@@ -484,7 +488,7 @@ public class ValueToEntityMixin
String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
if( assocId != null )
{
- eAssoc.set( module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
+ eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
}
else
{
@@ -526,7 +530,7 @@ public class ValueToEntityMixin
for( String eachAssoc : vAssocState )
{
eManyAssoc.add(
- module.currentUnitOfWork().get( (Class) eAssocDesc.type(), eachAssoc )
+ uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), eachAssoc )
);
}
}
@@ -570,7 +574,7 @@ public class ValueToEntityMixin
{
eNamedAssoc.put(
assocEntry.getKey(),
- module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
+ uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
);
}
}
@@ -624,7 +628,7 @@ public class ValueToEntityMixin
String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
if( assocId != null )
{
- eAssoc.set( module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
+ eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
}
else
{
@@ -666,7 +670,7 @@ public class ValueToEntityMixin
vAssocState.forEach( eachAssoc ->
{
eManyAssoc.add(
- module.currentUnitOfWork().get( (Class<?>) eAssocDesc.type(), eachAssoc )
+ uowf.currentUnitOfWork().get( (Class<?>) eAssocDesc.type(), eachAssoc )
);
} );
}
@@ -711,7 +715,7 @@ public class ValueToEntityMixin
{
eNamedAssoc.put(
assocEntry.getKey(),
- module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
+ uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
);
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
index ef06960..b268a62 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
@@ -62,7 +62,7 @@ public class EntityToValueTest
public void whenConvertingEntityToValueExpectCorrectValues()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
PersonEntity entity = setupPersonEntities( uow );
@@ -87,7 +87,7 @@ public class EntityToValueTest
public void givenUnqualifiedValueWhenConvertingEntityExpectCorrectMapping()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
PersonEntity niclas = setupPersonEntities( uow );
@@ -112,7 +112,7 @@ public class EntityToValueTest
public void givenUnqualifiedValue2WhenConvertingEntityExpectCorrectMapping()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
PersonEntity niclas = setupPersonEntities( uow );
@@ -137,7 +137,7 @@ public class EntityToValueTest
public void givenQualifiedValueNotFromSameInterfaceWhenConvertingEntityExpectNonOptionalException()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
PersonEntity niclas = setupPersonEntities( uow );
@@ -158,7 +158,7 @@ public class EntityToValueTest
public void whenConvertingEntityToValueUsingPrototypeOpportunityExpectCorrectValues()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
PersonEntity entity = setupPersonEntities( uow );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
index 4644d4d..4e8a087 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
@@ -52,7 +52,7 @@ public class NestedValuesConversionTest
public void testNestedValuesConversion()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
FooEntity fooEntity = createFooEntity( uow, "Test nested values conversion" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
index 8197ebe..0441b84 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
@@ -76,7 +76,7 @@ public class ValueToEntityTest
{
// See http://en.wikipedia.org/wiki/Template:Flintstones_family_tree
someBirthDate = createBirthDate( 1, 1, 1 );
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "InitialData" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "InitialData" ) ) )
{
ednaIdentity = createPerson( uow, "Edna", "Flintstone", someBirthDate ).identity().get();
zekeIdentity = createPerson( uow, "Zeke", "Flintstone", someBirthDate ).identity().get();
@@ -96,7 +96,7 @@ public class ValueToEntityTest
builder.prototype().spouse().set( ednaIdentity );
builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
PersonValue edValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
{
// START SNIPPET: creation
ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
@@ -129,7 +129,7 @@ public class ValueToEntityTest
builder.prototype().spouse().set( ednaIdentity );
builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
PersonValue2 edValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
@@ -163,7 +163,7 @@ public class ValueToEntityTest
builder.prototype().spouse().set( ednaIdentity );
builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
PersonValue3 edValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
@@ -197,7 +197,7 @@ public class ValueToEntityTest
builder.prototype().spouse().set( ednaIdentity );
builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
PersonValue4 edValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
@@ -213,7 +213,7 @@ public class ValueToEntityTest
throws UnitOfWorkCompletionException
{
String rickyIdentity;
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
{
PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -228,7 +228,7 @@ public class ValueToEntityTest
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
PersonValue rickyNewStateValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
{
PersonEntity rickyEntity = uow.get( PersonEntity.class, rickyIdentity );
// START SNIPPET: update
@@ -249,7 +249,7 @@ public class ValueToEntityTest
throws UnitOfWorkCompletionException
{
String rickyIdentity;
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
{
PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -264,7 +264,7 @@ public class ValueToEntityTest
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
PersonValue2 newStateValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
@@ -284,7 +284,7 @@ public class ValueToEntityTest
throws UnitOfWorkCompletionException
{
String rickyIdentity;
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
{
PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -299,7 +299,7 @@ public class ValueToEntityTest
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
PersonValue3 newStateValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
@@ -319,7 +319,7 @@ public class ValueToEntityTest
throws UnitOfWorkCompletionException
{
String rickyIdentity;
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
{
PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -334,7 +334,7 @@ public class ValueToEntityTest
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
PersonValue4 newStateValue = builder.newInstance();
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoopleWontWork" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoopleWontWork" ) ) )
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
index 858f29c..f0a2e11 100644
--- a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
+++ b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
@@ -66,14 +66,14 @@ public class JdbmEventStoreServiceTest
@Test
public void testDomainEvent() throws UnitOfWorkCompletionException, IOException
{
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Create entity" ));
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Create entity" ));
TestEntity entity = uow.newEntity( TestEntity.class );
uow.complete();
int count = 10;
for (int i = 0; i < count; i++)
{
- uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+ uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
uow.setMetaInfo( new Principal()
{
public String getName()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java b/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
index d55dac2..b5b6030 100644
--- a/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
+++ b/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
@@ -77,7 +77,7 @@ public class DomainEventSourceResourceSample
component.getDefaultHost().attach( "/ping", assembler.module().newObject( PingResource.class ) );
component.start();
- generateTestData(assembler.module());
+ generateTestData(assembler.module().unitOfWorkFactory());
}
private static void generateTestData(UnitOfWorkFactory unitOfWorkFactory) throws UnitOfWorkCompletionException
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
index 9f38d7f..911eeb7 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
@@ -103,21 +103,21 @@ public class ApplicationEventTest
}
};
- UnitOfWork uow1 = module.newUnitOfWork( UsecaseBuilder.newUsecase( "User signup" ) );
+ UnitOfWork uow1 = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "User signup" ) );
uow1.setMetaInfo( administratorPrincipal );
users.signup( null, "user1", Arrays.asList( "news-a", "news-b" ) );
uow1.complete();
Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
- UnitOfWork uow2 = module.newUnitOfWork();
+ UnitOfWork uow2 = uowf.newUnitOfWork();
uow2.setMetaInfo( administratorPrincipal );
users.signup( null, "user2", Collections.EMPTY_LIST );
uow2.complete();
Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
- UnitOfWork uow3 = module.newUnitOfWork();
+ UnitOfWork uow3 = uowf.newUnitOfWork();
uow3.setMetaInfo( administratorPrincipal );
users.signup( null, "user3", Collections.singletonList( "news-c" ) );
uow3.complete();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
index dcd5bee..c8fe3a6 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
@@ -78,7 +78,7 @@ public class DomainEventTest
};
// Perform UoW with usecase defined
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
uow.setMetaInfo( administratorPrincipal );
TestEntity entity = uow.newEntity( TestEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
index 9f357f5..1e1ce5e 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
@@ -72,7 +72,7 @@ public class DomainEventTrackerTest
@Test
public void testDomainEvent() throws UnitOfWorkCompletionException, IOException
{
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
uow.setMetaInfo( new Principal()
{
public String getName()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
index da2b1eb..b8785ee 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
@@ -18,6 +18,7 @@ package org.apache.zest.library.eventsourcing.domain.source.helper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
@@ -49,6 +50,7 @@ public class EventRouterTest
public void assemble( ModuleAssembly module ) throws AssemblyException
{
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
index 575ab5b..0402c4f 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.library.eventsourcing.domain.source.helper;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.activation.ActivationException;
@@ -55,6 +56,7 @@ public class EventsTest
public void assemble( ModuleAssembly module ) throws AssemblyException
{
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
index 0f6a970..94b1d56 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.library.eventsourcing.domain.source.helper;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
@@ -53,6 +54,7 @@ public class UnitOfWorkRouterTest
public void assemble( ModuleAssembly module ) throws AssemblyException
{
module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
----------------------------------------------------------------------
diff --git a/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java b/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
index a01b870..0f53355 100644
--- a/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
+++ b/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
@@ -18,6 +18,7 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.bootstrap.SingletonAssembler;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
import org.apache.zest.spi.query.IndexExporter;
import org.apache.zest.test.EntityTestAssembler;
@@ -84,11 +85,12 @@ public class HelloWorldCompositeTest
new EntityTestAssembler().assemble( module );
new RdfMemoryStoreAssembler().assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
};
// Create and update Entity
- UnitOfWork uow = assembler.module().newUnitOfWork();
+ UnitOfWork uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
try
{
Commands entity = uow.newEntity( Commands.class );
@@ -106,7 +108,7 @@ public class HelloWorldCompositeTest
assembler.module().findService( IndexExporter.class ).get().exportReadableToStream( System.out );
// Find it
- uow = assembler.module().newUnitOfWork();
+ uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
try
{
Data data = uow.newQuery( assembler.module()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
index a424aba..b86ab71 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
@@ -60,7 +60,7 @@ public class DebuggingTest
@Test
public void whenCallingMethodThenExpectDebugEntityCreated()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
// There is no Query capability available for Libraries, since that sits in Extensions.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
index 6438fc4..06dd6b9 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
@@ -70,7 +70,7 @@ public class TracingTest
SomeService sc = module.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
@@ -91,7 +91,7 @@ public class TracingTest
SomeService2 sc = module.findService( SomeService2.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
@@ -115,7 +115,7 @@ public class TracingTest
SomeService sc = module.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 789, sc.doSomethingModeratelyImportant() );
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
@@ -154,7 +154,7 @@ public class TracingTest
SomeService sc = module.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 753, sc.doSomethingInsanelyImportant() );
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
index 49edb94..89054bb 100755
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
@@ -95,7 +95,7 @@ public class EntitySerializerTest
void createDummyData()
throws UnitOfWorkCompletionException
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
ValueBuilder<TestValue> valueBuilder = module.newValueBuilder( TestValue.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
index 23b4eca..dbdb77a 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
@@ -81,7 +81,7 @@ public class EntityTypeSerializerTest
void createDummyData() throws UnitOfWorkCompletionException
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
ValueBuilder<Test2Value> vb2 = module.newValueBuilder( Test2Value.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
index cab3481..c1d0595 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
@@ -22,7 +22,9 @@ import java.io.File;
import java.io.IOException;
import java.util.Collections;
import org.apache.zest.api.type.HasTypes;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.Assert;
@@ -391,7 +393,7 @@ public class ContextResourceClientFactoryTest
@Override
protected Uniform createRoot( Request request, Response response )
{
- return module.newObject( RootResource.class, this );
+ return objectFactory.newObject( RootResource.class, this );
}
}
@@ -554,16 +556,19 @@ public class ContextResourceClientFactoryTest
private static int count = 0;
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ ValueBuilderFactory vbf;
public TestResult queryWithValue( TestQuery query )
{
- return module.newValueFromSerializedState( TestResult.class, "{'xyz':'"+query.abc().get()+"'}" );
+ return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'"+query.abc().get()+"'}" );
}
public TestResult queryWithoutValue()
{
- return module.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+ return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
}
public String queryWithStringResult( TestQuery query )
@@ -594,7 +599,7 @@ public class ContextResourceClientFactoryTest
count++;
if( count % 3 != 0 )
{
- module.currentUnitOfWork().addUnitOfWorkCallback( new UnitOfWorkCallback()
+ uowf.currentUnitOfWork().addUnitOfWorkCallback( new UnitOfWorkCallback()
{
public void beforeCompletion()
throws UnitOfWorkCompletionException
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
index 365bd83..da652d1 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.zest.library.rest.client;
+import org.apache.zest.api.composite.TransientBuilderFactory;
import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.Assert;
@@ -372,7 +373,7 @@ public class ContinuousIntegrationTest
@Override
protected Uniform createRoot( Request request, Response response )
{
- return module.newObject( RootResource.class, this );
+ return objectFactory.newObject( RootResource.class, this );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
index f673e6e..67c8584 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
@@ -1,12 +1,11 @@
/**
- *
* Copyright 2009-2011 Rickard Öberg AB
*
* Licensed 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
+ * 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,
@@ -37,10 +36,10 @@ import org.apache.zest.api.entity.EntityComposite;
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.property.PropertyDescriptor;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDescriptor;
@@ -83,6 +82,9 @@ public class ContextResource
// API fields
@Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
protected Module module;
// Private state
@@ -203,7 +205,7 @@ public class ContextResource
{
try
{
- T composite = module.currentUnitOfWork().get( entityClass, id );
+ T composite = uowf.currentUnitOfWork().get( entityClass, id );
current().select( composite );
return composite;
}
@@ -216,7 +218,7 @@ public class ContextResource
protected <T> T selectFromManyAssociation( ManyAssociation<T> manyAssociation, String id )
throws ResourceException
{
- T entity = (T) module.currentUnitOfWork().get( Object.class, id );
+ T entity = (T) uowf.currentUnitOfWork().get( Object.class, id );
if( !manyAssociation.contains( entity ) )
{
throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
@@ -225,13 +227,13 @@ public class ContextResource
current().select( entity );
return entity;
}
-
+
protected <T> T selectFromNamedAssociation( NamedAssociation<T> namedAssociation, String id )
throws ResourceException
{
- T entity = (T) module.currentUnitOfWork().get( Object.class, id );
+ T entity = (T) uowf.currentUnitOfWork().get( Object.class, id );
String name = namedAssociation.nameOf( entity );
- if(name == null)
+ if( name == null )
{
throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
}
@@ -677,7 +679,7 @@ public class ContextResource
.isAvailable() || request
.getResourceRef()
.getQuery() != null || queryMethod
- .getParameterTypes()[ 0 ].equals( Response.class ) ) ) )
+ .getParameterTypes()[ 0 ].equals( Response.class ) ) ) )
{
// Show form
try
@@ -871,7 +873,7 @@ public class ContextResource
{
ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
- valueDescriptor.state().properties().forEach(propertyDescriptor -> {
+ valueDescriptor.state().properties().forEach( propertyDescriptor -> {
String value = getValue( propertyDescriptor.qualifiedName().name(), queryAsForm, entityAsForm );
if( value == null )
{
@@ -882,7 +884,7 @@ public class ContextResource
}
}
form.add( propertyDescriptor.qualifiedName().name(), value );
- });
+ } );
}
else if( valueType.isInterface() && interactionMethod.getParameterTypes().length == 1 )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
index 7931255..100e639 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
@@ -1,12 +1,11 @@
/**
- *
* Copyright 2009-2011 Rickard Öberg AB
*
* Licensed 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
+ * 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,
@@ -24,9 +23,10 @@ import java.util.Map;
import org.apache.zest.api.cache.CacheOptions;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.object.ObjectFactory;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.library.rest.server.restlet.ResponseWriterDelegator;
@@ -53,7 +53,10 @@ public abstract class ContextRestlet
extends Restlet
{
@Structure
- protected Module module;
+ protected ObjectFactory objectFactory;
+
+ @Structure
+ protected UnitOfWorkFactory uowf;
@Service
private CommandResult commandResult;
@@ -61,7 +64,7 @@ public abstract class ContextRestlet
@Service
private ResponseWriterDelegator responseWriter;
- private Map<Class, Uniform> subResources = Collections.synchronizedMap( new HashMap<Class, Uniform>() );
+ private Map<Class, Uniform> subResources = Collections.synchronizedMap( new HashMap<>() );
@Override
public void handle( Request request, Response response )
@@ -83,7 +86,7 @@ public abstract class ContextRestlet
Reference ref = request.getResourceRef();
List<String> segments = ref.getScheme()
.equals( "riap" ) ? ref.getRelativeRef( new Reference( "riap://application/" ) )
- .getSegments() : ref.getRelativeRef().getSegments();
+ .getSegments() : ref.getRelativeRef().getSegments();
// Handle conversion of verbs into standard interactions
if( segments.get( segments.size() - 1 ).equals( "" ) )
@@ -106,7 +109,7 @@ public abstract class ContextRestlet
Usecase usecase = UsecaseBuilder.buildUsecase( getUsecaseName( request ) )
.withMetaInfo( request.getMethod().isSafe() ? CacheOptions.ALWAYS : CacheOptions.NEVER )
.newUsecase();
- UnitOfWork uow = module.newUnitOfWork( usecase );
+ UnitOfWork uow = uowf.newUnitOfWork( usecase );
ObjectSelection.newSelection();
@@ -194,7 +197,7 @@ public abstract class ContextRestlet
// Check if last modified and tag should be set
if( validity != null )
{
- UnitOfWork lastModifiedUoW = module.newUnitOfWork();
+ UnitOfWork lastModifiedUoW = uowf.newUnitOfWork();
try
{
@@ -244,7 +247,7 @@ public abstract class ContextRestlet
if( subResource == null )
{
// Instantiate and store subresource instance
- subResource = module.newObject( subResourceClass, this );
+ subResource = objectFactory.newObject( subResourceClass, this );
subResources.put( subResourceClass, subResource );
}
[18/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
index cb82864..cac1c7e 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
@@ -22,8 +22,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.grammar.OrderBy;
+import org.apache.zest.api.structure.Module;
import org.apache.zest.spi.query.EntityFinderException;
import org.apache.zest.spi.query.IndexExporter;
import org.apache.zest.test.indexing.model.Domain;
@@ -48,6 +50,8 @@ import static org.junit.Assert.assertThat;
public abstract class AbstractNamedQueryTest
extends AbstractAnyQueryTest
{
+ @Structure
+ Module moduleInstance;
protected final Map<String, Predicate<Composite>> queries = new HashMap<>();
@@ -74,7 +78,7 @@ public abstract class AbstractNamedQueryTest
public void showNetwork()
throws IOException
{
- IndexExporter indexerExporter = module.findService( IndexExporter.class ).get();
+ IndexExporter indexerExporter = moduleInstance.findService( IndexExporter.class ).get();
indexerExporter.exportReadableToStream( System.out );
}
@@ -82,7 +86,7 @@ public abstract class AbstractNamedQueryTest
public void script01()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script01" ) ) );
System.out.println( "*** script01: " + query );
@@ -93,7 +97,7 @@ public abstract class AbstractNamedQueryTest
public void script02()
throws EntityFinderException
{
- final Query<Domain> query = unitOfWork.newQuery( this.module
+ final Query<Domain> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Domain.class )
.where( queries.get( "script02" ) ) );
System.out.println( "*** script02: " + query );
@@ -104,7 +108,7 @@ public abstract class AbstractNamedQueryTest
public void script03()
throws EntityFinderException
{
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script03" ) ) );
System.out.println( "*** script03: " + query );
@@ -116,7 +120,7 @@ public abstract class AbstractNamedQueryTest
public void script04()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script04" ) ) );
System.out.println( "*** script04: " + query );
@@ -127,7 +131,7 @@ public abstract class AbstractNamedQueryTest
public void script05()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script05" ) ) );
System.out.println( "*** script05: " + query );
@@ -138,7 +142,7 @@ public abstract class AbstractNamedQueryTest
public void script06()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script06" ) ) );
System.out.println( "*** script06: " + query );
@@ -149,7 +153,7 @@ public abstract class AbstractNamedQueryTest
public void script07()
throws EntityFinderException
{
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script07" ) ) );
System.out.println( "*** script07: " + query );
@@ -160,7 +164,7 @@ public abstract class AbstractNamedQueryTest
public void script08()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script08" ) ) );
System.out.println( "*** script08: " + query );
@@ -171,7 +175,7 @@ public abstract class AbstractNamedQueryTest
public void script09()
throws EntityFinderException
{
- final Query<Female> query = unitOfWork.newQuery( this.module
+ final Query<Female> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Female.class )
.where( queries.get( "script09" ) ) );
System.out.println( "*** script09: " + query );
@@ -182,7 +186,7 @@ public abstract class AbstractNamedQueryTest
public void script10()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script10" ) ) );
System.out.println( "*** script10: " + query );
@@ -193,7 +197,7 @@ public abstract class AbstractNamedQueryTest
public void script11()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script11" ) ) );
System.out.println( "*** script11: " + query );
@@ -204,7 +208,7 @@ public abstract class AbstractNamedQueryTest
public void script12()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script12" ) ) );
System.out.println( "*** script12: " + query );
@@ -215,7 +219,7 @@ public abstract class AbstractNamedQueryTest
public void script13()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script13" ) ) );
System.out.println( "*** script13: " + query );
@@ -226,7 +230,7 @@ public abstract class AbstractNamedQueryTest
public void script14()
throws EntityFinderException
{
- final Query<Male> query = unitOfWork.newQuery( this.module
+ final Query<Male> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Male.class )
.where( queries.get( "script14" ) ) );
System.out.println( "*** script14: " + query );
@@ -237,7 +241,7 @@ public abstract class AbstractNamedQueryTest
public void script15()
throws EntityFinderException
{
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script15" ) ) );
System.out.println( "*** script15: " + query );
@@ -249,7 +253,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script16" ) ) );
query.orderBy( orderBy( nameable.name() ) );
@@ -263,7 +267,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script17" ) ) );
query.orderBy( orderBy( nameable.name() ) );
@@ -278,7 +282,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script18" ) ) );
query.orderBy( orderBy( nameable.name() ) );
@@ -292,7 +296,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Nameable nameable = templateFor( Nameable.class );
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script19" ) ) );
query.orderBy( orderBy( nameable.name() ) );
@@ -305,7 +309,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Person person = templateFor( Person.class );
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script20" ) ) );
query.orderBy( orderBy( person.name(), OrderBy.Order.DESCENDING ) );
@@ -318,7 +322,7 @@ public abstract class AbstractNamedQueryTest
throws EntityFinderException
{
Person person = templateFor( Person.class );
- final Query<Person> query = unitOfWork.newQuery( this.module
+ final Query<Person> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Person.class )
.where( queries.get( "script21" ) ) );
query.orderBy( orderBy( person.placeOfBirth().get().name() ), orderBy( person.yearOfBirth() ) );
@@ -330,7 +334,7 @@ public abstract class AbstractNamedQueryTest
public void script22()
throws EntityFinderException
{
- final Query<Nameable> query = unitOfWork.newQuery( this.module
+ final Query<Nameable> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Nameable.class )
.where( queries.get( "script22" ) ) );
System.out.println( "*** script22: " + query );
@@ -341,7 +345,7 @@ public abstract class AbstractNamedQueryTest
public void script24()
throws EntityFinderException
{
- final Query<Domain> query = unitOfWork.newQuery( this.module
+ final Query<Domain> query = unitOfWork.newQuery( this.moduleInstance
.newQueryBuilder( Domain.class )
.where( queries.get( "script24" ) ) );
query.setVariable( "domain", "Gaming" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
index e071204..852094a 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
@@ -24,6 +24,8 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
@@ -75,12 +77,15 @@ import static org.apache.zest.test.indexing.NameableAssert.verifyUnorderedResult
public abstract class AbstractQueryTest
extends AbstractAnyQueryTest
{
+ @Structure
+ Module moduleInstance;
+
@Test
public void showNetwork()
throws IOException
{
- IndexExporter indexerExporter = module.findService( IndexExporter.class ).get();
+ IndexExporter indexerExporter = moduleInstance.findService( IndexExporter.class ).get();
indexerExporter.exportReadableToStream( System.out );
}
@@ -88,7 +93,7 @@ public abstract class AbstractQueryTest
public void script01()
throws EntityFinderException
{
- final QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ final QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
final Query<Person> query = unitOfWork.newQuery( qb );
System.out.println( "*** script01: " + query );
verifyUnorderedResults( query, "Joe Doe", "Ann Doe", "Jack Doe" );
@@ -98,7 +103,7 @@ public abstract class AbstractQueryTest
public void script02()
throws EntityFinderException
{
- final QueryBuilder<Domain> qb = this.module.newQueryBuilder( Domain.class );
+ final QueryBuilder<Domain> qb = this.moduleInstance.newQueryBuilder( Domain.class );
final Nameable nameable = templateFor( Nameable.class );
final Query<Domain> query = unitOfWork.newQuery( qb.where( eq( nameable.name(), "Gaming" ) ) );
System.out.println( "*** script02: " + query );
@@ -109,7 +114,7 @@ public abstract class AbstractQueryTest
public void script03()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
System.out.println( "*** script03: " + query );
verifyUnorderedResults( query, "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
@@ -120,7 +125,7 @@ public abstract class AbstractQueryTest
public void script04()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person personTemplate = templateFor( Person.class );
City placeOfBirth = personTemplate.placeOfBirth().get();
Query<Person> query = unitOfWork.newQuery( qb.where( eq( placeOfBirth.name(), "Kuala Lumpur" ) ) );
@@ -132,7 +137,7 @@ public abstract class AbstractQueryTest
public void script04_ne()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person personTemplate = templateFor( Person.class );
City placeOfBirth = personTemplate.placeOfBirth().get();
Query<Person> query = unitOfWork.newQuery( qb.where( ne( placeOfBirth.name(), "Kuala Lumpur" ) ) );
@@ -144,7 +149,7 @@ public abstract class AbstractQueryTest
public void script05()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother()
.get()
@@ -160,7 +165,7 @@ public abstract class AbstractQueryTest
public void script06()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( ge( person.yearOfBirth(), 1973 ) ) );
System.out.println( "*** script06: " + query );
@@ -172,7 +177,7 @@ public abstract class AbstractQueryTest
public void script07()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
Person person = templateFor( Person.class );
Query<Nameable> query = unitOfWork.newQuery( qb.where(
and( ge( person.yearOfBirth(), 1900 ), eq( person.placeOfBirth().get().name(), "Penang" ) ) ) );
@@ -185,7 +190,7 @@ public abstract class AbstractQueryTest
public void script08()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( or( eq( person.yearOfBirth(), 1970 ), eq( person.yearOfBirth(), 1975 ) ) )
);
@@ -198,7 +203,7 @@ public abstract class AbstractQueryTest
public void script09()
throws EntityFinderException
{
- QueryBuilder<Female> qb = this.module.newQueryBuilder( Female.class );
+ QueryBuilder<Female> qb = this.moduleInstance.newQueryBuilder( Female.class );
Person person = templateFor( Person.class );
Query<Female> query = unitOfWork.newQuery( qb.where( or( eq( person.yearOfBirth(), 1970 ), eq( person.yearOfBirth(), 1975 ) ) )
);
@@ -210,7 +215,7 @@ public abstract class AbstractQueryTest
public void script10()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( not( eq( person.yearOfBirth(), 1975 ) ) ) );
System.out.println( "*** script10: " + query );
@@ -221,7 +226,7 @@ public abstract class AbstractQueryTest
public void script11()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( isNotNull( person.email() ) ) );
System.out.println( "*** script11: " + query );
@@ -232,7 +237,7 @@ public abstract class AbstractQueryTest
public void script12()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( isNull( person.email() ) ) );
System.out.println( "*** script12: " + query );
@@ -243,7 +248,7 @@ public abstract class AbstractQueryTest
public void script12_ne()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.email(), "joe@thedoes.net" ) ) );
System.out.println( "*** script12_ne: " + query );
@@ -254,7 +259,7 @@ public abstract class AbstractQueryTest
public void script13()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Male person = templateFor( Male.class );
Query<Person> query = unitOfWork.newQuery( qb.where( isNotNull( person.wife() ) ) );
System.out.println( "*** script13: " + query );
@@ -265,7 +270,7 @@ public abstract class AbstractQueryTest
public void script14()
throws EntityFinderException
{
- QueryBuilder<Male> qb = this.module.newQueryBuilder( Male.class );
+ QueryBuilder<Male> qb = this.moduleInstance.newQueryBuilder( Male.class );
Male person = templateFor( Male.class );
Query<Male> query = unitOfWork.newQuery( qb.where( isNull( person.wife() ) ) );
System.out.println( "*** script14: " + query );
@@ -276,7 +281,7 @@ public abstract class AbstractQueryTest
public void script15()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Male person = templateFor( Male.class );
Query<Person> query = unitOfWork.newQuery( qb.where( isNull( person.wife() ) ) );
System.out.println( "*** script15: " + query );
@@ -287,7 +292,7 @@ public abstract class AbstractQueryTest
public void script16()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
// should return only 2 entities
Nameable nameable = templateFor( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
@@ -301,7 +306,7 @@ public abstract class AbstractQueryTest
public void script17()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
// should return only 3 entities starting with forth one
Nameable nameable = templateFor( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
@@ -316,7 +321,7 @@ public abstract class AbstractQueryTest
public void script18()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
// should return all Nameable entities sorted by name
Nameable nameable = templateFor( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
@@ -330,7 +335,7 @@ public abstract class AbstractQueryTest
public void script19()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
// should return all Nameable entities with a name > "D" sorted by name
Nameable nameable = templateFor( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb.where( gt( nameable.name(), "D" ) ) );
@@ -343,7 +348,7 @@ public abstract class AbstractQueryTest
public void script20()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
// should return all Persons born after 1973 (Ann and Joe Doe) sorted descending by name
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( gt( person.yearOfBirth(), 1973 ) ) );
@@ -356,7 +361,7 @@ public abstract class AbstractQueryTest
public void script21()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
// should return all Persons sorted by name of the city they were born, and then by year they were born
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb );
@@ -369,7 +374,7 @@ public abstract class AbstractQueryTest
public void script22()
throws EntityFinderException
{
- QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class );
+ QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
Nameable nameable = templateFor( Nameable.class );
// should return Jack and Joe Doe
Query<Nameable> query = unitOfWork.newQuery( qb.where( matches( nameable.name(), "J.*Doe" ) ) );
@@ -381,7 +386,7 @@ public abstract class AbstractQueryTest
public void script23()
throws EntityFinderException
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Domain interests = oneOf( person.interests() );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( interests.name(), "Cars" ) ) );
@@ -393,7 +398,7 @@ public abstract class AbstractQueryTest
public void script24()
throws EntityFinderException
{
- final QueryBuilder<Domain> qb = this.module.newQueryBuilder( Domain.class );
+ final QueryBuilder<Domain> qb = this.moduleInstance.newQueryBuilder( Domain.class );
final Nameable nameable = templateFor( Nameable.class );
final Query<Domain> query = unitOfWork.newQuery( qb.where( eq( nameable.name(), "Gaming" ) ) );
System.out.println( "*** script24: " + query );
@@ -403,13 +408,13 @@ public abstract class AbstractQueryTest
@Test( expected = NotQueryableException.class )
public void script25()
{
- this.module.newQueryBuilder( File.class );
+ this.moduleInstance.newQueryBuilder( File.class );
}
@Test( expected = NotQueryableException.class )
public void script26()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
qb.where( eq( person.personalWebsite().get().file().get().value(), "some/path" ) );
}
@@ -417,7 +422,7 @@ public abstract class AbstractQueryTest
@Test( expected = NotQueryableException.class )
public void script27()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
qb.where( eq( person.personalWebsite().get().host().get().value(), "zest.apache.org" ) );
}
@@ -425,7 +430,7 @@ public abstract class AbstractQueryTest
@Test( expected = NotQueryableException.class )
public void script28()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
qb.where( eq( person.personalWebsite().get().port().get().value(), 8080 ) );
}
@@ -433,7 +438,7 @@ public abstract class AbstractQueryTest
@Test
public void script29()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.personalWebsite()
.get()
@@ -451,7 +456,7 @@ public abstract class AbstractQueryTest
@SuppressWarnings( "unchecked" )
public void script30()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
QueryParam queryParam = null; // oneOf( person.personalWebsite().get().queryParams() );
Query<Person> query = unitOfWork.newQuery( qb.where( and( eq( queryParam.name(), "foo" ), eq( queryParam.value(), "bar" ) ) ) );
@@ -463,7 +468,7 @@ public abstract class AbstractQueryTest
@Ignore( "Equality on Property<Map<?,?>> not implemented" )
public void script31()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Map<String, String> info = new HashMap<>( 0 );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.additionalInfo(), info ) ) );
@@ -474,7 +479,7 @@ public abstract class AbstractQueryTest
@Test
public void script32()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.address().get().line1(), "Qi Alley 4j" ) ) );
System.out.println( "*** script32: " + query );
@@ -484,7 +489,7 @@ public abstract class AbstractQueryTest
@Test
public void script33()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Domain gaming = unitOfWork.get( Domain.class, "Gaming" );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) );
@@ -496,7 +501,7 @@ public abstract class AbstractQueryTest
@Test
public void script34()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Female annDoe = unitOfWork.get( Female.class, "anndoe" );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) );
@@ -508,7 +513,7 @@ public abstract class AbstractQueryTest
@Test
public void script35()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( containsName( person.accounts(), "anns" ) ) );
System.out.println( "*** script35: " + query );
@@ -519,7 +524,7 @@ public abstract class AbstractQueryTest
@Test
public void script36()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Account anns = unitOfWork.get( Account.class, "accountOfAnnDoe" );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) );
@@ -532,7 +537,7 @@ public abstract class AbstractQueryTest
@Ignore( "Traversing of NamedAssociations is not implemented" )
public void script37()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.accounts().get( "anns" ).number(),
"accountOfAnnDoe" ) ) );
@@ -544,7 +549,7 @@ public abstract class AbstractQueryTest
@Test
public void script38()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.title(), Person.Title.DR ) ) );
System.out.println( "*** script38: " + query );
@@ -555,7 +560,7 @@ public abstract class AbstractQueryTest
@Test
public void script39()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.title(), Person.Title.DR ) ) );
System.out.println( "*** script39: " + query );
@@ -566,7 +571,7 @@ public abstract class AbstractQueryTest
@Test
public void script40_Date()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.dateValue(), new DateTime( "2010-03-04T13:24:35", UTC ).toDate() ) ) );
@@ -578,7 +583,7 @@ public abstract class AbstractQueryTest
@Test
public void script41_Date()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.dateValue(), new DateTime( "2010-03-04T13:24:35", UTC ).toDate() ) ) );
@@ -590,7 +595,7 @@ public abstract class AbstractQueryTest
@Test
public void script42_Date()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.dateValue(), new DateTime( "2010-03-04T14:24:35", forID( "CET" ) ).toDate() ) ) );
@@ -602,7 +607,7 @@ public abstract class AbstractQueryTest
@Test
public void script43_Date()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
and( gt( person.dateValue(), new DateTime( "2005-03-04T13:24:35", UTC ).toDate() ),
@@ -615,7 +620,7 @@ public abstract class AbstractQueryTest
@Test
public void script40_DateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.dateTimeValue(), new DateTime( "2010-03-04T13:24:35", UTC ) ) ) );
@@ -627,7 +632,7 @@ public abstract class AbstractQueryTest
@Test
public void script41_DateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.dateTimeValue(), new DateTime( "2010-03-04T13:24:35", UTC ) ) ) );
@@ -639,7 +644,7 @@ public abstract class AbstractQueryTest
@Test
public void script42_DateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.dateTimeValue(), new DateTime( "2010-03-04T14:24:35", forID( "CET" ) ) ) ) );
@@ -651,7 +656,7 @@ public abstract class AbstractQueryTest
@Test
public void script43_DateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
and( gt( person.dateTimeValue(), new DateTime( "2005-03-04T13:24:35", UTC ) ),
@@ -664,7 +669,7 @@ public abstract class AbstractQueryTest
@Test
public void script40_LocalDateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", UTC ) ) ) );
@@ -676,7 +681,7 @@ public abstract class AbstractQueryTest
@Test
public void script41_LocalDateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", UTC ) ) ) );
@@ -688,7 +693,7 @@ public abstract class AbstractQueryTest
@Test
public void script42_LocalDateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", forID( "CET" ) ) ) ) );
@@ -700,7 +705,7 @@ public abstract class AbstractQueryTest
@Test
public void script43_LocalDateTime()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
and( gt( person.localDateTimeValue(), new LocalDateTime( "2005-03-04T13:24:35", UTC ) ),
@@ -713,7 +718,7 @@ public abstract class AbstractQueryTest
@Test
public void script40_LocalDate()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.localDateValue(), new LocalDate( "2010-03-04", UTC ) ) ) );
@@ -725,7 +730,7 @@ public abstract class AbstractQueryTest
@Test
public void script41_LocalDate()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.localDateValue(), new LocalDate( "2010-03-04", UTC ) ) ) );
@@ -737,7 +742,7 @@ public abstract class AbstractQueryTest
@Test
public void script42_LocalDate()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.localDateValue(), new LocalDate( "2010-03-04", forID( "CET" ) ) ) ) );
@@ -749,7 +754,7 @@ public abstract class AbstractQueryTest
@Test
public void script43_LocalDate()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
and( gt( person.localDateValue(), new LocalDate( "2005-03-04", UTC ) ),
@@ -762,7 +767,7 @@ public abstract class AbstractQueryTest
@Test
public void script50_BigInteger()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.bigInteger(), new BigInteger( "23232323232323232323232323" ) ) ) );
@@ -774,7 +779,7 @@ public abstract class AbstractQueryTest
@Test
public void script51_BigInteger()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.bigInteger(), new BigInteger( "23232323232323232323232323" ) ) ) );
@@ -786,7 +791,7 @@ public abstract class AbstractQueryTest
@Test
public void script52_BigInteger()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ge( person.bigInteger(), new BigInteger( "23232323232323232323232323" ) ) ) );
@@ -798,7 +803,7 @@ public abstract class AbstractQueryTest
@Test
public void script50_BigDecimal()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
eq( person.bigDecimal(), new BigDecimal( "2342.76931348623157e+307" ) ) ) );
@@ -810,7 +815,7 @@ public abstract class AbstractQueryTest
@Test
public void script51_BigDecimal()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.bigDecimal(), new BigDecimal( "2342.76931348623157e+307" ) ) ) );
@@ -822,7 +827,7 @@ public abstract class AbstractQueryTest
@Test
public void script52_BigDecimal()
{
- QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+ QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
ge( person.bigDecimal(), new BigDecimal( "2342.76931348623157e+307" ) ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
index ac0e1c9..e0a4778 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
@@ -26,8 +26,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.property.Property;
@@ -41,13 +39,15 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.functional.Iterables;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.Test;
-import static org.junit.Assert.*;
import static org.apache.zest.io.Inputs.iterable;
import static org.apache.zest.io.Inputs.text;
import static org.apache.zest.io.Outputs.collection;
import static org.apache.zest.io.Outputs.text;
import static org.apache.zest.io.Transforms.map;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
/**
* Assert that ValueSerialization behaviour on Collections and Maps is correct.
@@ -64,12 +64,6 @@ public class AbstractCollectionSerializationTest
module.values( SomeValue.class );
}
- @Before
- public void before()
- {
- module.injectTo( this );
- }
-
@Service
@SuppressWarnings( "ProtectedField" )
protected ValueSerialization valueSerialization;
@@ -82,8 +76,8 @@ public class AbstractCollectionSerializationTest
iterable( byteCollection() ).transferTo( map( valueSerialization.serialize(), text( sb ) ) );
String output = sb.toString();
- List<Byte> list = new ArrayList<Byte>();
- text( output ).transferTo( map( valueSerialization.deserialize( Byte.class ), collection( list ) ) );
+ List<Byte> list = new ArrayList<>();
+ text( output ).transferTo( map( valueSerialization.deserialize( module, Byte.class ), collection( list ) ) );
assertEquals( byteCollection(), list );
}
@@ -96,7 +90,7 @@ public class AbstractCollectionSerializationTest
23, 42, -23, -42
};
String output = valueSerialization.serialize( primitiveArray );
- int[] deserialized = valueSerialization.deserialize( int[].class, output );
+ int[] deserialized = valueSerialization.deserialize( module, int[].class, output );
assertArrayEquals( primitiveArray, deserialized );
}
@@ -109,7 +103,7 @@ public class AbstractCollectionSerializationTest
9, null, -12, -12, 127, -128, 73
};
String output = valueSerialization.serialize( array );
- Byte[] deserialized = valueSerialization.deserialize( Byte[].class, output );
+ Byte[] deserialized = valueSerialization.deserialize( module, Byte[].class, output );
assertArrayEquals( array, deserialized );
}
@@ -119,7 +113,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( Iterables.iterable( byteCollection().toArray() ) );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Byte.class ) );
- List<Byte> list = valueSerialization.deserialize( collectionType, output );
+ List<Byte> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( byteCollection(), list );
}
@@ -129,8 +123,8 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( byteCollection() );
CollectionType collectionType = new CollectionType( Set.class, new ValueType( Byte.class ) );
- Set<Byte> list = valueSerialization.deserialize( collectionType, output );
- assertEquals( new LinkedHashSet<Byte>( byteCollection() ), list );
+ Set<Byte> list = valueSerialization.deserialize( module, collectionType, output );
+ assertEquals( new LinkedHashSet<>( byteCollection() ), list );
}
@Test
@@ -139,7 +133,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( characterCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Character.class ) );
- List<Character> list = valueSerialization.deserialize( collectionType, output );
+ List<Character> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( characterCollection(), list );
}
@@ -149,7 +143,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( shortCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Short.class ) );
- List<Short> list = valueSerialization.deserialize( collectionType, output );
+ List<Short> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( shortCollection(), list );
}
@@ -159,7 +153,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( integerCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Integer.class ) );
- List<Integer> list = valueSerialization.deserialize( collectionType, output );
+ List<Integer> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( integerCollection(), list );
}
@@ -169,7 +163,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( longCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Long.class ) );
- List<Long> list = valueSerialization.deserialize( collectionType, output );
+ List<Long> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( longCollection(), list );
}
@@ -179,7 +173,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( floatCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Float.class ) );
- List<Float> list = valueSerialization.deserialize( collectionType, output );
+ List<Float> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( floatCollection(), list );
}
@@ -189,7 +183,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( doubleCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( Double.class ) );
- List<Double> list = valueSerialization.deserialize( collectionType, output );
+ List<Double> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( doubleCollection(), list );
}
@@ -200,7 +194,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( bigIntegerCollection() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( BigInteger.class ) );
- List<BigInteger> list = valueSerialization.deserialize( collectionType, output );
+ List<BigInteger> list = valueSerialization.deserialize( module, collectionType, output );
assertEquals( bigIntegerCollection(), list );
}
@@ -210,7 +204,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( bigDecimalCollection() );
CollectionType collectionType = new CollectionType( Collection.class, new ValueType( BigDecimal.class ) );
- Collection<BigDecimal> collection = valueSerialization.deserialize( collectionType, output );
+ Collection<BigDecimal> collection = valueSerialization.deserialize( module, collectionType, output );
assertEquals( bigDecimalCollection(), collection );
}
@@ -220,7 +214,7 @@ public class AbstractCollectionSerializationTest
{
String output = valueSerialization.serialize( stringByteMap() );
MapType mapType = new MapType( Map.class, new ValueType( String.class ), new ValueType( Byte.class ) );
- Map<String, Byte> value = valueSerialization.deserialize( mapType, output );
+ Map<String, Byte> value = valueSerialization.deserialize( module, mapType, output );
assertEquals( stringByteMap(), value );
}
@@ -231,7 +225,7 @@ public class AbstractCollectionSerializationTest
String output = valueSerialization.serialize( stringMultiMap() );
CollectionType collectionType = new CollectionType( List.class, new ValueType( String.class ) );
MapType mapType = new MapType( Map.class, new ValueType( String.class ), collectionType );
- Map<String, List<String>> value = valueSerialization.deserialize( mapType, output );
+ Map<String, List<String>> value = valueSerialization.deserialize( module, mapType, output );
assertEquals( stringMultiMap(), value );
}
@@ -242,7 +236,7 @@ public class AbstractCollectionSerializationTest
String output = valueSerialization.serialize( stringListOfMaps() );
ValueType stringType = new ValueType( String.class );
CollectionType collectionType = new CollectionType( List.class, new MapType( Map.class, stringType, stringType ) );
- List<Map<String, String>> value = valueSerialization.deserialize( collectionType, output );
+ List<Map<String, String>> value = valueSerialization.deserialize( module, collectionType, output );
assertEquals( stringListOfMaps(), value );
}
@@ -253,13 +247,13 @@ public class AbstractCollectionSerializationTest
String output = valueSerialization.serialize( valueCompositesList() );
ValueCompositeType valueType = module.valueDescriptor( SomeValue.class.getName() ).valueType();
CollectionType collectionType = new CollectionType( List.class, valueType );
- List<SomeValue> value = valueSerialization.deserialize( collectionType, output );
+ List<SomeValue> value = valueSerialization.deserialize( module, collectionType, output );
assertEquals( valueCompositesList(), value );
}
private ArrayList<Byte> byteCollection()
{
- ArrayList<Byte> value = new ArrayList<Byte>();
+ ArrayList<Byte> value = new ArrayList<>();
value.add( (byte) 9 );
value.add( null );
value.add( (byte) -12 );
@@ -272,7 +266,7 @@ public class AbstractCollectionSerializationTest
private List<Character> characterCollection()
{
- List<Character> value = new ArrayList<Character>();
+ List<Character> value = new ArrayList<>();
value.add( 'Q' );
value.add( 'i' );
value.add( null );
@@ -283,7 +277,7 @@ public class AbstractCollectionSerializationTest
private Collection<Short> shortCollection()
{
- Collection<Short> value = new ArrayList<Short>();
+ Collection<Short> value = new ArrayList<>();
value.add( (short) -32768 );
value.add( (short) 32767 );
value.add( (short) -82 );
@@ -293,7 +287,7 @@ public class AbstractCollectionSerializationTest
private Collection<Integer> integerCollection()
{
- Collection<Integer> value = new ArrayList<Integer>();
+ Collection<Integer> value = new ArrayList<>();
value.add( Integer.MAX_VALUE );
value.add( -283 );
value.add( null );
@@ -304,7 +298,7 @@ public class AbstractCollectionSerializationTest
private Collection<Long> longCollection()
{
- Collection<Long> value = new ArrayList<Long>();
+ Collection<Long> value = new ArrayList<>();
value.add( 98239723L );
value.add( -1298233L );
value.add( -1L );
@@ -318,7 +312,7 @@ public class AbstractCollectionSerializationTest
private Collection<Float> floatCollection()
{
- Collection<Float> value = new ArrayList<Float>();
+ Collection<Float> value = new ArrayList<>();
value.add( -1f );
value.add( 1f );
value.add( 1f );
@@ -333,7 +327,7 @@ public class AbstractCollectionSerializationTest
private Collection<Double> doubleCollection()
{
- Collection<Double> value = new ArrayList<Double>();
+ Collection<Double> value = new ArrayList<>();
value.add( -1.0 );
value.add( 1.0 );
value.add( 0.0 );
@@ -347,7 +341,7 @@ public class AbstractCollectionSerializationTest
private Collection<BigInteger> bigIntegerCollection()
{
- Collection<BigInteger> value = new ArrayList<BigInteger>();
+ Collection<BigInteger> value = new ArrayList<>();
value.add( new BigInteger( "-1" ) );
value.add( BigInteger.ZERO );
value.add( BigInteger.ONE );
@@ -360,7 +354,7 @@ public class AbstractCollectionSerializationTest
private Collection<BigDecimal> bigDecimalCollection()
{
- Collection<BigDecimal> value = new ArrayList<BigDecimal>();
+ Collection<BigDecimal> value = new ArrayList<>();
value.add( new BigDecimal( "1.2" ) );
value.add( new BigDecimal( "3.4" ) );
value.add( null );
@@ -370,7 +364,7 @@ public class AbstractCollectionSerializationTest
private Map<String, Byte> stringByteMap()
{
- Map<String, Byte> value = new LinkedHashMap<String, Byte>();
+ Map<String, Byte> value = new LinkedHashMap<>();
value.put( "a", (byte) 9 );
value.put( "b", null );
value.put( "c", (byte) -12 );
@@ -379,8 +373,8 @@ public class AbstractCollectionSerializationTest
private Map<String, List<String>> stringMultiMap()
{
- Map<String, List<String>> value = new LinkedHashMap<String, List<String>>();
- List<String> list = new ArrayList<String>();
+ Map<String, List<String>> value = new LinkedHashMap<>();
+ List<String> list = new ArrayList<>();
list.add( "foo" );
list.add( "bar" );
list.add( null );
@@ -394,8 +388,8 @@ public class AbstractCollectionSerializationTest
private List<Map<String, String>> stringListOfMaps()
{
- List<Map<String, String>> value = new ArrayList<Map<String, String>>();
- Map<String, String> map = new LinkedHashMap<String, String>();
+ List<Map<String, String>> value = new ArrayList<>();
+ Map<String, String> map = new LinkedHashMap<>();
map.put( "foo", "bar" );
map.put( "cathedral", "bazar" );
map.put( "yield", null );
@@ -408,14 +402,14 @@ public class AbstractCollectionSerializationTest
private List<SomeValue> valueCompositesList()
{
- List<SomeValue> list = new ArrayList<SomeValue>();
+ List<SomeValue> list = new ArrayList<>();
list.add( newSomeValue( "", "bazar" ) );
list.add( null );
list.add( newSomeValue( "bar", null ) );
return list;
}
- public static interface SomeValue
+ public interface SomeValue
{
Property<String> foo();
@@ -426,7 +420,7 @@ public class AbstractCollectionSerializationTest
private SomeValue newSomeValue( String foo, String cathedral )
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = module.instance().newValueBuilder( SomeValue.class );
SomeValue value = builder.prototype();
value.foo().set( foo );
if( cathedral != null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
index 9a65bd3..a345eb8 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
@@ -49,12 +49,6 @@ public class AbstractJsonDateFormatTest
{
}
- @Before
- public void before()
- {
- module.injectTo( this );
- }
-
@Service
protected ValueDeserializer valueDeserializer;
@@ -63,7 +57,7 @@ public class AbstractJsonDateFormatTest
throws Exception
{
CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( collectionType, "[\"2009-08-12T14:54:27.895+0800\"]" );
+ List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+0800\"]" );
assertEquals( new DateTime( "2009-08-12T06:54:27.895Z", DateTimeZone.UTC ).toDate(), value.get( 0 ) );
}
@@ -73,7 +67,7 @@ public class AbstractJsonDateFormatTest
{
long tstamp = System.currentTimeMillis();
CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( collectionType, "[\"@" + tstamp + "@\"]" );
+ List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"@" + tstamp + "@\"]" );
assertEquals( new Date( tstamp ), value.get( 0 ) );
}
@@ -83,7 +77,7 @@ public class AbstractJsonDateFormatTest
{
long tstamp = System.currentTimeMillis();
CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( collectionType, "[\"/Date(" + tstamp + ")/\"]" );
+ List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"/Date(" + tstamp + ")/\"]" );
assertEquals( new Date( tstamp ), value.get( 0 ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
index a30ae27..129dcad 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
@@ -19,15 +19,14 @@ package org.apache.zest.test.value;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.test.AbstractZestTest;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+import org.junit.Test;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
@@ -43,11 +42,6 @@ public abstract class AbstractPlainValueSerializationTest
extends AbstractZestTest
{
- @Before
- public void before()
- {
- module.injectTo( this );
- }
@Service
@SuppressWarnings( "ProtectedField" )
protected ValueSerialization valueSerialization;
@@ -58,7 +52,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( 'q' );
assertThat( "Serialized", serialized, equalTo( "q" ) );
- Character deserialized = valueSerialization.deserialize( Character.class, serialized );
+ Character deserialized = valueSerialization.deserialize( module, Character.class, serialized );
assertThat( "Deserialized", deserialized, equalTo( 'q' ) );
}
@@ -68,7 +62,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( "" );
assertThat( "Serialized", serialized, equalTo( "" ) );
- String deserialized = valueSerialization.deserialize( String.class, serialized );
+ String deserialized = valueSerialization.deserialize( module, String.class, serialized );
assertThat( "Deserialized", deserialized, equalTo( "" ) );
}
@@ -78,7 +72,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( "test" );
assertThat( serialized, equalTo( "test" ) );
- String deserialized = valueSerialization.deserialize( String.class, serialized );
+ String deserialized = valueSerialization.deserialize( module, String.class, serialized );
assertThat( deserialized, equalTo( "test" ) );
}
@@ -88,7 +82,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( Boolean.TRUE );
assertThat( serialized, equalTo( "true" ) );
- Boolean deserialized = valueSerialization.deserialize( Boolean.class, serialized );
+ Boolean deserialized = valueSerialization.deserialize( module, Boolean.class, serialized );
assertThat( deserialized, equalTo( Boolean.TRUE ) );
}
@@ -97,7 +91,7 @@ public abstract class AbstractPlainValueSerializationTest
{
String serialized = valueSerialization.serialize( 42 );
assertThat( serialized, equalTo( "42" ) );
- Integer deserialized = valueSerialization.deserialize( Integer.class, serialized );
+ Integer deserialized = valueSerialization.deserialize( module, Integer.class, serialized );
assertThat( deserialized, equalTo( 42 ) );
}
@@ -107,7 +101,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( 42L );
assertThat( serialized, equalTo( "42" ) );
- Long deserialized = valueSerialization.deserialize( Long.class, serialized );
+ Long deserialized = valueSerialization.deserialize( module, Long.class, serialized );
assertThat( deserialized, equalTo( 42L ) );
}
@@ -117,7 +111,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( (short) 42 );
assertThat( serialized, equalTo( "42" ) );
- Short deserialized = valueSerialization.deserialize( Short.class, serialized );
+ Short deserialized = valueSerialization.deserialize( module, Short.class, serialized );
assertThat( deserialized, equalTo( (short) 42 ) );
}
@@ -126,7 +120,7 @@ public abstract class AbstractPlainValueSerializationTest
{
String serialized = valueSerialization.serialize( (byte) 42 );
assertThat( serialized, equalTo( "42" ) );
- Byte deserialized = valueSerialization.deserialize( Byte.class, serialized );
+ Byte deserialized = valueSerialization.deserialize( module, Byte.class, serialized );
assertThat( deserialized, equalTo( (byte) 42 ) );
}
@@ -136,7 +130,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( 42F );
assertThat( serialized, equalTo( "42.0" ) );
- Float deserialized = valueSerialization.deserialize( Float.class, serialized );
+ Float deserialized = valueSerialization.deserialize( module, Float.class, serialized );
assertThat( deserialized, equalTo( 42F ) );
}
@@ -146,7 +140,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( 42D );
assertThat( serialized, equalTo( "42.0" ) );
- Double deserialized = valueSerialization.deserialize( Double.class, serialized );
+ Double deserialized = valueSerialization.deserialize( module, Double.class, serialized );
assertThat( deserialized, equalTo( 42D ) );
}
@@ -159,7 +153,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( bigInteger );
assertThat( serialized, equalTo( "42424242424242424242424242" ) );
- BigInteger deserialized = valueSerialization.deserialize( BigInteger.class, serialized );
+ BigInteger deserialized = valueSerialization.deserialize( module, BigInteger.class, serialized );
assertThat( deserialized, equalTo( bigInteger ) );
}
@@ -172,7 +166,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( bigDecimal );
assertThat( serialized, equalTo( "4.22376931348623157E+310" ) );
- BigDecimal deserialized = valueSerialization.deserialize( BigDecimal.class, serialized );
+ BigDecimal deserialized = valueSerialization.deserialize( module, BigDecimal.class, serialized );
assertThat( deserialized, equalTo( bigDecimal ) );
}
@@ -182,7 +176,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( new DateTime( "2020-03-04T13:24:35", forID( "CET" ) ).toDate() );
assertThat( serialized, equalTo( "2020-03-04T12:24:35.000Z" ) );
- Date deserialized = valueSerialization.deserialize( Date.class, serialized );
+ Date deserialized = valueSerialization.deserialize( module, Date.class, serialized );
assertThat( deserialized, equalTo( new DateTime( "2020-03-04T13:24:35", forID( "CET" ) ).toDate() ) );
assertThat( deserialized, equalTo( new DateTime( "2020-03-04T12:24:35", UTC ).toDate() ) );
}
@@ -194,7 +188,7 @@ public abstract class AbstractPlainValueSerializationTest
// See https://github.com/JodaOrg/joda-time/issues/106
String serialized = valueSerialization.serialize( new DateTime( "2020-03-04T13:24:35", forOffsetHours( 1 ) ) );
assertThat( serialized, equalTo( "2020-03-04T13:24:35.000+01:00" ) );
- DateTime deserialized = valueSerialization.deserialize( DateTime.class, serialized );
+ DateTime deserialized = valueSerialization.deserialize( module, DateTime.class, serialized );
assertThat( deserialized, equalTo( new DateTime( "2020-03-04T13:24:35", forOffsetHours( 1 ) ) ) );
}
@@ -205,7 +199,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( new LocalDateTime( "2020-03-04T13:23:00", forID( "CET" ) ) );
assertThat( serialized, equalTo( "2020-03-04T13:23:00.000" ) );
- LocalDateTime deserialized = valueSerialization.deserialize( LocalDateTime.class, serialized );
+ LocalDateTime deserialized = valueSerialization.deserialize( module, LocalDateTime.class, serialized );
assertThat( deserialized, equalTo( new LocalDateTime( "2020-03-04T13:23:00", UTC ) ) );
}
@@ -215,7 +209,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( new LocalDate( "2020-03-04" ) );
assertThat( serialized, equalTo( "2020-03-04" ) );
- LocalDate deserialized = valueSerialization.deserialize( LocalDate.class, serialized );
+ LocalDate deserialized = valueSerialization.deserialize( module, LocalDate.class, serialized );
assertThat( deserialized, equalTo( new LocalDate( "2020-03-04" ) ) );
}
@@ -225,7 +219,7 @@ public abstract class AbstractPlainValueSerializationTest
String serialized = valueSerialization.serialize( EntityReference.parseEntityReference( "ABCD-1234" ) );
assertThat( serialized, equalTo( "ABCD-1234" ) );
- EntityReference deserialized = valueSerialization.deserialize( EntityReference.class, serialized );
+ EntityReference deserialized = valueSerialization.deserialize( module, EntityReference.class, serialized );
assertThat( deserialized, equalTo( EntityReference.parseEntityReference( "ABCD-1234" ) ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
index 7ff7406..179806d 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
@@ -23,11 +23,12 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -68,6 +69,9 @@ public abstract class AbstractValueCompositeSerializationTest
@Rule
public TestName testName = new TestName();
+ @Structure
+ Module moduleInstance;
+
@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
@@ -79,12 +83,6 @@ public abstract class AbstractValueCompositeSerializationTest
module.entities( BarEntity.class );
}
- @Before
- public void before()
- {
- module.injectTo( this );
- }
-
@Service
protected ValueSerialization valueSerialization;
@@ -103,7 +101,7 @@ public abstract class AbstractValueCompositeSerializationTest
String stateString = output.toString( "UTF-8" );
// Deserialize using Module API
- SomeValue some2 = module.newValueFromSerializedState( SomeValue.class, stateString );
+ SomeValue some2 = moduleInstance.newValueFromSerializedState( SomeValue.class, stateString );
assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
assertThat( "Same value", some, equalTo( some2 ) );
@@ -130,11 +128,11 @@ public abstract class AbstractValueCompositeSerializationTest
*/
private SomeValue buildSomeValue()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = moduleInstance.newValueBuilder( SomeValue.class );
SomeValue proto = builder.prototype();
- proto.anotherList().get().add( module.newValue( AnotherValue.class ) );
+ proto.anotherList().get().add( moduleInstance.newValue( AnotherValue.class ) );
- ValueBuilder<SpecificCollection> specificColBuilder = module.newValueBuilder( SpecificCollection.class );
+ ValueBuilder<SpecificCollection> specificColBuilder = moduleInstance.newValueBuilder( SpecificCollection.class );
SpecificCollection specificColProto = specificColBuilder.prototype();
List<String> genericList = new ArrayList<>( 2 );
genericList.add( "Some" );
@@ -173,10 +171,10 @@ public abstract class AbstractValueCompositeSerializationTest
proto.another().set( anotherValue1 );
// proto.arrayOfValues().set( new AnotherValue[] { anotherValue1, anotherValue2, anotherValue3 } );
proto.serializable().set( new SerializableObject() );
- proto.foo().set( module.newValue( FooValue.class ) );
- proto.fooValue().set( module.newValue( FooValue.class ) );
- proto.customFoo().set( module.newValue( CustomFooValue.class ) );
- proto.customFooValue().set( module.newValue( CustomFooValue.class ) );
+ proto.foo().set( moduleInstance.newValue( FooValue.class ) );
+ proto.fooValue().set( moduleInstance.newValue( FooValue.class ) );
+ proto.customFoo().set( moduleInstance.newValue( CustomFooValue.class ) );
+ proto.customFooValue().set( moduleInstance.newValue( CustomFooValue.class ) );
// Arrays
// TODO FIXME Disabled as ValueComposite equality fails here
@@ -206,7 +204,7 @@ public abstract class AbstractValueCompositeSerializationTest
private AnotherValue createAnotherValue( String val1, String val2 )
{
- ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<AnotherValue> valueBuilder = moduleInstance.newValueBuilder( AnotherValue.class );
valueBuilder.prototype().val1().set( val1 );
valueBuilder.prototypeFor( AnotherValueInternalState.class ).val2().set( val2 );
return valueBuilder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreTest.java b/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreTest.java
index f41579d..8660948 100644
--- a/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreTest.java
+++ b/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreTest.java
@@ -35,7 +35,7 @@ public class JdbmEntityStoreTest
@Before
public void testDataCleanup()
{
- FileConfiguration fileConfig = module.findService( FileConfiguration.class ).get();
+ FileConfiguration fileConfig = serviceFinder.findService( FileConfiguration.class ).get();
FileConfigurationDataWiper.registerApplicationPassivationDataWiper( fileConfig, application );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreWithCacheTest.java b/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreWithCacheTest.java
index c27c835..d1b677b 100644
--- a/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-jdbm/src/test/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreWithCacheTest.java
@@ -34,7 +34,7 @@ public class JdbmEntityStoreWithCacheTest
@Before
public void testDataCleanup()
{
- FileConfiguration fileConfig = module.findService( FileConfiguration.class ).get();
+ FileConfiguration fileConfig = serviceFinder.findService( FileConfiguration.class ).get();
FileConfigurationDataWiper.registerApplicationPassivationDataWiper( fileConfig, application );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreTest.java b/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreTest.java
index 4c84fab..d9b7267 100644
--- a/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreTest.java
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreTest.java
@@ -73,7 +73,7 @@ public class MongoMapEntityStoreTest
throws Exception
{
super.setUp();
- MongoMapEntityStoreService es = module.findService( MongoMapEntityStoreService.class ).get();
+ MongoMapEntityStoreService es = serviceFinder.findService( MongoMapEntityStoreService.class ).get();
mongo = es.mongoInstanceUsed();
dbName = es.dbInstanceUsed().getName();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreWithCacheTest.java b/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreWithCacheTest.java
index cd25cf0..e37db9a 100644
--- a/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreWithCacheTest.java
@@ -67,7 +67,7 @@ public class MongoMapEntityStoreWithCacheTest
throws Exception
{
super.setUp();
- MongoMapEntityStoreService es = module.findService( MongoMapEntityStoreService.class ).get();
+ MongoMapEntityStoreService es = serviceFinder.findService( MongoMapEntityStoreService.class ).get();
mongo = es.mongoInstanceUsed();
dbName = es.dbInstanceUsed().getName();
[22/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
index 6836d34..236b105 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
@@ -66,7 +66,7 @@ public class ValueTypeFactory
Serialization.Variant variant
)
{
- ValueType valueType = null;
+ ValueType valueType;
if( CollectionType.isCollection( type ) )
{
if( type instanceof ParameterizedType )
@@ -132,7 +132,7 @@ public class ValueTypeFactory
new AssociationsModel(),
new ManyAssociationsModel(),
new NamedAssociationsModel() );
- model = new ValueModel( valueComposite, Visibility.application, new MetaInfo(),
+ model = new ValueModel( module, valueComposite, Visibility.application, new MetaInfo(),
mixinsModel, valueStateModel, new CompositeMethodsModel( mixinsModel ) );
}
else
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
index ed8d137..3e6df36 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
@@ -25,7 +25,6 @@ import org.apache.zest.api.entity.LifecycleException;
import org.apache.zest.runtime.composite.FunctionStateResolver;
import org.apache.zest.runtime.entity.EntityInstance;
import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.module.ModuleSpi;
@@ -42,7 +41,6 @@ public final class EntityBuilderInstance<T>
private final EntityModel model;
private final ModuleUnitOfWork uow;
private final EntityStoreUnitOfWork store;
- private final ModuleSpi module;
private String identity;
private final BuilderEntityState entityState;
@@ -61,7 +59,7 @@ public final class EntityBuilderInstance<T>
}
public EntityBuilderInstance(
- ModelModule<EntityDescriptor> model,
+ EntityDescriptor model,
ModuleUnitOfWork uow,
EntityStoreUnitOfWork store,
String identity
@@ -71,27 +69,26 @@ public final class EntityBuilderInstance<T>
}
public EntityBuilderInstance(
- ModelModule<EntityDescriptor> model,
+ EntityDescriptor model,
ModuleUnitOfWork uow,
EntityStoreUnitOfWork store,
String identity,
FunctionStateResolver stateResolver
)
{
- this.model = (EntityModel) model.model();
- this.module = model.module();
+ this.model = (EntityModel) model;
this.uow = uow;
this.store = store;
this.identity = identity;
EntityReference reference = new EntityReference( identity );
- entityState = new BuilderEntityState( model.model(), reference );
+ entityState = new BuilderEntityState( model, reference );
this.model.initState( model.module(), entityState );
if( stateResolver != null )
{
stateResolver.populateState( this.model, entityState );
}
entityState.setPropertyValue( IDENTITY_STATE_NAME, identity );
- prototypeInstance = this.model.newInstance( uow, model.module(), entityState );
+ prototypeInstance = this.model.newInstance( uow, (ModuleSpi) model.module().instance(), entityState );
}
@SuppressWarnings( "unchecked" )
@@ -128,7 +125,7 @@ public final class EntityBuilderInstance<T>
entityState.copyTo( newEntityState );
- EntityInstance instance = model.newInstance( uow, module, newEntityState );
+ EntityInstance instance = model.newInstance( uow, (ModuleSpi) model.module().instance(), newEntityState );
Object proxy = instance.proxy();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
index 118510f..8d5f011 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
@@ -48,7 +48,7 @@ import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.query.QueryExecutionException;
import org.apache.zest.api.query.grammar.OrderBy;
import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
@@ -73,7 +73,6 @@ import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entity.EntityStatus;
import org.apache.zest.spi.entity.NamedAssociationState;
import org.apache.zest.spi.entitystore.EntityStore;
-import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import org.apache.zest.spi.query.EntityFinder;
import org.apache.zest.spi.query.EntityFinderException;
@@ -106,12 +105,12 @@ public class ModuleUnitOfWork
private UnitOfWorkInstance uow;
@Structure
- private ModuleSpi module;
+ private ModuleDescriptor module;
@Service
private UnitOfWorkFactory unitOfWorkFactory;
- public Module module()
+ public ModuleDescriptor module()
{
return module;
}
@@ -185,27 +184,24 @@ public class ModuleUnitOfWork
public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
throws EntityTypeNotFoundException
{
- ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
+ EntityDescriptor model = module.typeLookup().lookupEntityModel( type );
if( model == null )
{
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type.getName(), module );
}
- EntityStore entityStore = ((ModuleSpi) model.module()).entityStore();
+ EntityStore entityStore = ( (ModuleSpi) model.module().instance() ).entityStore();
// Generate id if necessary
if( identity == null )
{
- IdentityGenerator idGen = ((ModuleSpi) model.module()).identityGenerator();
+ IdentityGenerator idGen = ( (ModuleSpi) model.module().instance() ).identityGenerator();
if( idGen == null )
{
throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
}
- identity = idGen.generate( model.model().types().findFirst().orElse( null ) );
+ identity = idGen.generate( model.types().findFirst().orElse( null ) );
}
EntityBuilder<T> builder;
@@ -248,17 +244,15 @@ public class ModuleUnitOfWork
NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
- ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
+ EntityDescriptor model = module.typeLookup().lookupEntityModel( type );
if( model == null )
{
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type.getName(), module );
}
- EntityStore entityStore = model.module().entityStore();
+ ModuleSpi moduleSpi = (ModuleSpi) model.module().instance();
+ EntityStore entityStore = moduleSpi.entityStore();
FunctionStateResolver stateResolver = new FunctionStateResolver(
propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction
@@ -267,17 +261,19 @@ public class ModuleUnitOfWork
if( identity == null )
{
// Use identity from StateResolver if available
- PropertyModel identityModel = (PropertyModel) model.model().state().findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
+ PropertyModel identityModel = (PropertyModel) model
+ .state()
+ .findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
identity = (String) stateResolver.getPropertyState( identityModel );
if( identity == null )
{
// Generate identity
- IdentityGenerator idGen = model.module().identityGenerator();
+ IdentityGenerator idGen = moduleSpi.identityGenerator();
if( idGen == null )
{
throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
}
- identity = idGen.generate( model.model().types().findFirst().orElse( null ));
+ identity = idGen.generate( model.types().findFirst().orElse( null ) );
}
}
@@ -292,14 +288,11 @@ public class ModuleUnitOfWork
public <T> T get( Class<T> type, String identity )
throws EntityTypeNotFoundException, NoSuchEntityException
{
- Iterable<ModelModule<EntityDescriptor>> models = module.typeLookup().lookupEntityModels( type );
+ Iterable<? extends EntityDescriptor> models = module.typeLookup().lookupEntityModels( type );
if( !models.iterator().hasNext() )
{
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- ((ModuleSpi) module).findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( type.getName(), module );
}
return uow.get( parseEntityReference( identity ), this, models, type );
@@ -312,7 +305,7 @@ public class ModuleUnitOfWork
{
EntityComposite entityComposite = (EntityComposite) entity;
EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
- ModelModule<EntityDescriptor> model = new ModelModule<>( compositeInstance.module(), compositeInstance.entityModel() );
+ EntityDescriptor model = compositeInstance.entityModel();
Class<T> type = (Class<T>) compositeInstance.types().findFirst().orElse( null );
return uow.get( compositeInstance.identity(), this, Collections.singletonList( model ), type );
}
@@ -441,7 +434,7 @@ public class ModuleUnitOfWork
Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToValueNameAssociationMappingFunction<>( entityComposite );
@SuppressWarnings( "unchecked" )
- ValueBuilder<T> builder = module().newValueBuilderWithState(
+ ValueBuilder<T> builder = module().instance().newValueBuilderWithState(
primaryType, propertyFunction, assocationFunction, manyAssocFunction, namedAssocFunction );
return builder.newInstance();
}
@@ -499,7 +492,10 @@ public class ModuleUnitOfWork
Map<String, Object> variables
)
{
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+ final EntityFinder entityFinder = moduleUnitOfWork.module()
+ .instance()
+ .findService( EntityFinder.class )
+ .get();
try
{
@@ -534,7 +530,7 @@ public class ModuleUnitOfWork
Map<String, Object> variables
)
{
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+ EntityFinder entityFinder = moduleUnitOfWork.module().instance().findService( EntityFinder.class ).get();
try
{
@@ -556,18 +552,19 @@ public class ModuleUnitOfWork
Map<String, Object> variables
)
{
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+ EntityFinder entityFinder = moduleUnitOfWork.module().instance().findService( EntityFinder.class ).get();
try
{
- final Iterator<EntityReference> foundEntities = entityFinder.findEntities( resultType,
- whereClause,
- Iterables.toArray( OrderBy.class, orderBySegments ),
- firstResult,
- maxResults,
- variables == null ? Collections
- .<String, Object>emptyMap() : variables )
- .iterator();
+ final Iterator<EntityReference> foundEntities =
+ entityFinder.findEntities(
+ resultType,
+ whereClause,
+ Iterables.toArray( OrderBy.class, orderBySegments ),
+ firstResult,
+ maxResults,
+ variables == null ? Collections.<String, Object>emptyMap() : variables
+ ).iterator();
return new Iterator<T>()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
index 3a69e29..df7b682 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
@@ -21,11 +21,9 @@
package org.apache.zest.runtime.unitofwork;
import java.util.Stack;
-import org.apache.zest.api.common.Optional;
import org.apache.zest.api.composite.TransientBuilderFactory;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.metrics.MetricsProvider;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
@@ -64,7 +62,7 @@ public class UnitOfWorkFactoryMixin
@Override
public UnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
{
- UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( usecase, currentTime, metricsProvider() );
+ UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( module, usecase, currentTime, metricsProvider() );
return tbf.newTransient( UnitOfWork.class, unitOfWorkInstance );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
index 3a65c9f..4ba3c55 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -36,6 +36,7 @@ import org.apache.zest.api.metrics.MetricsCounterFactory;
import org.apache.zest.api.metrics.MetricsProvider;
import org.apache.zest.api.metrics.MetricsTimer;
import org.apache.zest.api.metrics.MetricsTimerFactory;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
@@ -57,7 +58,6 @@ import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
import org.apache.zest.spi.metrics.DefaultMetric;
import org.apache.zest.spi.module.ModuleSpi;
-import org.apache.zest.spi.structure.ModelModule;
import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.COMPLETED;
import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.DISCARDED;
@@ -79,6 +79,7 @@ public final class UnitOfWorkInstance
return current.get();
}
+ private final ModuleSpi module;
private long currentTime;
private MetricsProvider metrics;
final HashMap<EntityReference, EntityInstance> instanceCache;
@@ -97,8 +98,9 @@ public final class UnitOfWorkInstance
private List<UnitOfWorkCallback> callbacks;
- public UnitOfWorkInstance( Usecase usecase, long currentTime, MetricsProvider metrics )
+ public UnitOfWorkInstance( ModuleSpi module, Usecase usecase, long currentTime, MetricsProvider metrics )
{
+ this.module = module;
this.currentTime = currentTime;
this.open = true;
instanceCache = new HashMap<>();
@@ -119,7 +121,7 @@ public final class UnitOfWorkInstance
EntityStoreUnitOfWork uow = storeUnitOfWork.get( store );
if( uow == null )
{
- uow = store.newUnitOfWork( usecase, currentTime );
+ uow = store.newUnitOfWork( module.descriptor(), usecase, currentTime );
storeUnitOfWork.put( store, uow );
}
return uow;
@@ -127,7 +129,7 @@ public final class UnitOfWorkInstance
public <T> T get( EntityReference identity,
UnitOfWork uow,
- Iterable<ModelModule<EntityDescriptor>> potentialModels,
+ Iterable<? extends EntityDescriptor> potentialModels,
Class<T> mixinType
)
throws EntityTypeNotFoundException, NoSuchEntityException
@@ -141,11 +143,11 @@ public final class UnitOfWorkInstance
// Check if this is a root UoW, or if no parent UoW knows about this entity
EntityState entityState = null;
EntityModel model = null;
- ModuleSpi module = null;
+ ModuleDescriptor module = null;
// Figure out what EntityStore to use
- for( ModelModule<EntityDescriptor> potentialModel : potentialModels )
+ for( EntityDescriptor potentialModel : potentialModels )
{
- EntityStore store = potentialModel.module().entityStore();
+ EntityStore store = ((ModuleSpi) potentialModel.module().instance()).entityStore();
EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store );
try
{
@@ -171,15 +173,11 @@ public final class UnitOfWorkInstance
}
else
{
- throw new EntityTypeNotFoundException( mixinType.getName(),
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( mixinType.getName(), module );
}
}
// Create instance
- entityInstance = new EntityInstance( uow, module, model, entityState );
+ entityInstance = new EntityInstance( uow, model, entityState );
instanceCache.put( identity, entityInstance );
}
else
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
index 45e9282..ae438c5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
@@ -21,7 +21,6 @@ import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.structure.ModelModule;
/**
* Implementation of ValueBuilder
@@ -33,14 +32,14 @@ public final class ValueBuilderInstance<T>
private final ModuleInstance currentModule;
private final ValueInstance prototypeInstance;
- public ValueBuilderInstance( ModelModule<ValueDescriptor> compositeModelModule,
+ public ValueBuilderInstance( ValueDescriptor compositeModel,
ModuleInstance currentModule,
StateResolver stateResolver
)
{
- ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, stateResolver );
- ValueModel model = (ValueModel) compositeModelModule.model();
- prototypeInstance = model.newValueInstance( compositeModelModule.module(), state );
+ ValueStateInstance state = new ValueStateInstance( compositeModel, currentModule, stateResolver );
+ ValueModel model = (ValueModel) compositeModel;
+ prototypeInstance = model.newValueInstance( state );
prototypeInstance.prepareToBuild();
this.currentModule = currentModule;
}
@@ -70,7 +69,7 @@ public final class ValueBuilderInstance<T>
{
Class<Composite> valueType = (Class<Composite>) prototypeInstance.types().findFirst().orElse( null );
- ModelModule<ValueDescriptor> valueModel = currentModule.typeLookup().lookupValueModel( valueType );
+ ValueDescriptor valueModel = currentModule.typeLookup().lookupValueModel( valueType );
if( valueModel == null )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
index eafd07a..f3f236a 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
@@ -38,7 +38,6 @@ import org.apache.zest.runtime.composite.MixinsModel;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.composite.UsesInstance;
import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.runtime.structure.ModuleInstance;
/**
@@ -50,12 +49,12 @@ public class ValueBuilderWithPrototype<T>
private ValueInstance prototypeInstance;
private final ValueModel valueModel;
- public ValueBuilderWithPrototype( ModelModule<ValueDescriptor> compositeModelModule,
+ public ValueBuilderWithPrototype( ValueDescriptor compositeModelModule,
ModuleInstance currentModule,
T prototype
)
{
- valueModel = (ValueModel) compositeModelModule.model();
+ valueModel = (ValueModel) compositeModelModule;
// Only shallow clone, as all generic types of the ValueComposites are expected to be Immutable.
MixinsModel mixinsModel = valueModel.mixinsModel();
@@ -70,7 +69,6 @@ public class ValueBuilderWithPrototype<T>
ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, resolver );
ValueInstance valueInstance = new ValueInstance(
valueModel,
- currentModule,
mixins,
state
);
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
index 69c06c4..4beafd5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
@@ -18,21 +18,19 @@ import org.apache.zest.api.common.ConstructionException;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.runtime.structure.ModuleInstance;
public class ValueBuilderWithState<T> implements ValueBuilder<T>
{
- private final ModelModule<ValueDescriptor> model;
+ private final ValueDescriptor model;
private ValueInstance prototypeInstance;
- public ValueBuilderWithState( ModelModule<ValueDescriptor> compositeModelModule,
+ public ValueBuilderWithState( ValueDescriptor compositeModelModule,
ModuleInstance currentModule,
StateResolver stateResolver )
{
ValueStateInstance state = new ValueStateInstance( compositeModelModule, currentModule, stateResolver );
- ValueModel model = (ValueModel) compositeModelModule.model();
- ValueInstance instance = model.newValueInstance( compositeModelModule.module(), state );
+ ValueInstance instance = ((ValueModel) compositeModelModule).newValueInstance( state );
instance.prepareToBuild();
this.model = compositeModelModule;
this.prototypeInstance = instance;
@@ -70,7 +68,7 @@ public class ValueBuilderWithState<T> implements ValueBuilder<T>
prototypeInstance.prepareBuilderState();
// Check that it is valid
- ((ValueModel) model.model()).checkConstraints( prototypeInstance.state() );
+ ((ValueModel) model).checkConstraints( prototypeInstance.state() );
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
index c22890e..beb232c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
@@ -41,12 +41,11 @@ public final class ValueInstance
}
public ValueInstance( ValueModel compositeModel,
- ModuleSpi moduleInstance,
Object[] mixins,
ValueStateInstance state
)
{
- super( compositeModel, moduleInstance, mixins, state );
+ super( compositeModel, mixins, state );
}
/**
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
index 5b23765..f28a16e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueModel.java
@@ -18,6 +18,7 @@ import java.util.List;
import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.constraint.ConstraintViolationException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.composite.CompositeMethodsModel;
@@ -27,7 +28,6 @@ import org.apache.zest.runtime.composite.MixinsModel;
import org.apache.zest.runtime.composite.UsesInstance;
import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* Model for ValueComposites
@@ -37,7 +37,8 @@ public final class ValueModel extends CompositeModel
{
private ValueCompositeType valueType;
- public ValueModel( final List<Class<?>> types,
+ public ValueModel( final ModuleDescriptor module,
+ final List<Class<?>> types,
final Visibility visibility,
final MetaInfo metaInfo,
final MixinsModel mixinsModel,
@@ -45,7 +46,7 @@ public final class ValueModel extends CompositeModel
final CompositeMethodsModel compositeMethodsModel
)
{
- super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
+ super( module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
valueType = new ValueCompositeType( this );
}
@@ -88,13 +89,11 @@ public final class ValueModel extends CompositeModel
);
}
- public ValueInstance newValueInstance( ModuleSpi moduleInstance,
- ValueStateInstance state
- )
+ public ValueInstance newValueInstance( ValueStateInstance state )
{
Object[] mixins = mixinsModel.newMixinHolder();
- ValueInstance instance = new ValueInstance( this, moduleInstance, mixins, state );
+ ValueInstance instance = new ValueInstance( this, mixins, state );
// Instantiate all mixins
int i = 0;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
index 313567e..d5f32cc 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
@@ -36,7 +36,6 @@ import org.apache.zest.runtime.property.PropertyInfo;
import org.apache.zest.runtime.property.PropertyInstance;
import org.apache.zest.runtime.structure.ModuleInstance;
import org.apache.zest.runtime.unitofwork.EntityFunction;
-import org.apache.zest.spi.structure.ModelModule;
/**
* TODO
@@ -61,14 +60,14 @@ public final class ValueStateInstance
this.namedAssociations = namedAssociations;
}
- public ValueStateInstance( ModelModule<ValueDescriptor> compositeModelModule,
+ public ValueStateInstance( ValueDescriptor compositeModelModule,
ModuleInstance currentModule,
StateResolver stateResolver
)
{
EntityFunction entityFunction = new EntityFunction( currentModule.unitOfWorkFactory() );
- ValueModel valueModel = (ValueModel) compositeModelModule.model();
+ ValueModel valueModel = (ValueModel) compositeModelModule;
this.properties = new LinkedHashMap<>();
valueModel.state().properties().forEach( propertyDescriptor -> {
PropertyInfo builderInfo = propertyDescriptor.getBuilderInfo();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
index ed1b8c3..f603e5c 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
@@ -50,28 +50,28 @@ public class OptionalTest
@Test
public void givenOptionalMethodWhenCorrectInvokeThenNoException()
{
- TestComposite instance = module.newTransient( TestComposite.class );
+ TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class );
instance.doStuff( "Hello WOrld", "Hello World" );
}
@Test( expected = ConstraintViolationException.class )
public void givenOptionalMethodWhenMandatoryMissingThenException()
{
- TestComposite instance = module.newTransient( TestComposite.class );
+ TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class );
instance.doStuff( "Hello World", null );
}
@Test
public void givenOptionalMethodWhenOptionalMissingThenNoException()
{
- TestComposite instance = module.newTransient( TestComposite.class );
+ TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class );
instance.doStuff( null, "Hello World" );
}
@Test
public void givenOptionalPropertyWhenOptionalMissingThenNoException()
{
- TransientBuilder<TestComposite2> builder = module.newTransientBuilder( TestComposite2.class );
+ TransientBuilder<TestComposite2> builder = transientBuilderFactory.newTransientBuilder( TestComposite2.class );
builder.prototype().mandatoryProperty().set( "Hello World" );
TestComposite2 testComposite2 = builder.newInstance();
}
@@ -79,7 +79,7 @@ public class OptionalTest
@Test
public void givenOptionalPropertyWhenOptionalSetThenNoException()
{
- TransientBuilder<TestComposite2> builder = module.newTransientBuilder( TestComposite2.class );
+ TransientBuilder<TestComposite2> builder = transientBuilderFactory.newTransientBuilder( TestComposite2.class );
builder.prototype().mandatoryProperty().set( "Hello World" );
builder.prototype().optionalProperty().set( "Hello World" );
TestComposite2 testComposite2 = builder.newInstance();
@@ -88,7 +88,7 @@ public class OptionalTest
@Test( expected = ConstraintViolationException.class )
public void givenMandatoryPropertyWhenMandatoryMissingThenException()
{
- TestComposite2 testComposite2 = module.newTransient( TestComposite2.class );
+ TestComposite2 testComposite2 = transientBuilderFactory.newTransient( TestComposite2.class );
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
index e3f5a7e..83c2030 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
@@ -73,7 +73,7 @@ public class PropertyTypeTest
public void givenCompositeWithPropertyConstraintsWhenInstantiatedThenPropertiesWork()
throws Exception
{
- TransientBuilder<PersonComposite> builder = module.newTransientBuilder( PersonComposite.class );
+ TransientBuilder<PersonComposite> builder = transientBuilderFactory.newTransientBuilder( PersonComposite.class );
PersonComposite personComposite = builder.prototype();
personComposite.givenName().set( "Rickard" );
personComposite.familyName().set( "Öberg" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
index 42360ad..75410f8 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
@@ -51,7 +51,7 @@ public class ValueCompositeTest
@Test( expected = IllegalStateException.class )
public void testImmutabilityOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue some = builder.prototype();
some.other().set( "test" );
some = builder.newInstance();
@@ -61,7 +61,7 @@ public class ValueCompositeTest
@Test
public void testCreationOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue some = builder.prototype();
some.other().set( "test" );
builder.newInstance();
@@ -70,12 +70,12 @@ public class ValueCompositeTest
@Test
public void testEqualityOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue instance = builder.newInstance();
- builder = module.newValueBuilder( SomeValue.class );
+ builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue other = builder.newInstance();
@@ -86,12 +86,12 @@ public class ValueCompositeTest
@Test
public void testHashcodeOfValueComposite()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue instance = builder.newInstance();
- builder = module.newValueBuilder( SomeValue.class );
+ builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
prototype = builder.prototype();
prototype.other().set( "test" );
SomeValue other = builder.newInstance();
@@ -102,11 +102,11 @@ public class ValueCompositeTest
@Test
public void testModifyValue()
{
- ValueBuilder<AnotherValue> anotherBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<AnotherValue> anotherBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class );
anotherBuilder.prototype().val1().set( "Val1" );
AnotherValue anotherValue = anotherBuilder.newInstance();
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.some().set( "foo" );
prototype.other().set( "test" );
@@ -117,7 +117,7 @@ public class ValueCompositeTest
assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) );
// Modify value
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().some().set( "bar" );
instance = builder.newInstance();
@@ -126,7 +126,7 @@ public class ValueCompositeTest
assertThat( "AnotherValue.val1 has value Val1", instance.another().get().val1().get(), equalTo( "Val1" ) );
// Modify value again using method 2
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().other().set( "test2" );
instance = builder.newInstance();
@@ -137,25 +137,25 @@ public class ValueCompositeTest
@Test( expected = ConstraintViolationException.class )
public void givenValueWhenModifyToIncorrectValueThenThrowConstraintException()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
SomeValue prototype = builder.prototype();
prototype.some().set( "foo" );
SomeValue instance = builder.newInstance();
- builder = module.newValueBuilderWithPrototype( instance );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( instance );
builder.prototype().some().set( null );
}
@Test
public void givenValueWithListOfValueWhenPrototypeThenListedValuesAreEditable()
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
SomeValue some = builder.newInstance();
- builder = module.newValueBuilderWithPrototype( some );
+ builder = valueBuilderFactory.newValueBuilderWithPrototype( some );
builder.prototype().anotherList().get().get( 0 ).val1().set( "Foo" );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
some = builder.newInstance();
assertThat( "Val1 has been set", some.anotherList().get().get( 0 ).val1().get(), equalTo( "Foo" ) );
@@ -175,9 +175,9 @@ public class ValueCompositeTest
public void givenEntityWhenUpdateValueThenValueIsSet()
throws UnitOfWorkCompletionException
{
- ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class );
- builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) );
- ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+ ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
+ builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) );
+ ValueBuilder<AnotherValue> valueBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class );
valueBuilder.prototype().val1().set( "Foo" );
builder.prototype().another().set( valueBuilder.newInstance() );
builder.prototype().number().set( 42L );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/bootstrap/ServiceAssemblyTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/bootstrap/ServiceAssemblyTest.java b/core/runtime/src/test/java/org/apache/zest/bootstrap/ServiceAssemblyTest.java
index cead646..d9e78f8 100644
--- a/core/runtime/src/test/java/org/apache/zest/bootstrap/ServiceAssemblyTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/bootstrap/ServiceAssemblyTest.java
@@ -35,7 +35,7 @@ public class ServiceAssemblyTest extends AbstractZestTest
public void givenMyServiceWithTwoDeclarationsWhenActivatingServiceExpectServiceActivatedOnce()
throws Exception
{
- ServiceReference<MyService> ref = module.findService( MyService.class );
+ ServiceReference<MyService> ref = serviceFinder.findService( MyService.class );
MyService underTest = ref.get();
assertThat(underTest.activated(), equalTo(1));
underTest.passivateService();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/constraints/PropertyConstraintTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/constraints/PropertyConstraintTest.java b/core/runtime/src/test/java/org/apache/zest/constraints/PropertyConstraintTest.java
index 1a85577..dc19bb4 100644
--- a/core/runtime/src/test/java/org/apache/zest/constraints/PropertyConstraintTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/constraints/PropertyConstraintTest.java
@@ -41,7 +41,7 @@ public class PropertyConstraintTest
public void givenConstraintOnPropertyWhenInvalidValueThenThrowException()
throws Throwable
{
- TransientBuilder<Test> builder = module.newTransientBuilder( Test.class );
+ TransientBuilder<Test> builder = transientBuilderFactory.newTransientBuilder( Test.class );
builder.prototype().test().set( "XXXXXX" );
Test test = builder.newInstance();
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi230/Qi230IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi230/Qi230IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi230/Qi230IssueTest.java
index 9f9fea2..4165d8a 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi230/Qi230IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi230/Qi230IssueTest.java
@@ -49,8 +49,8 @@ public class Qi230IssueTest
public void whenDerefencingInsideConcernThisExpectItToWork()
throws Exception
{
- Result result = module.findService( Result.class ).get();
- Some some = module.findService( Some.class ).get();
+ Result result = serviceFinder.findService( Result.class ).get();
+ Some some = serviceFinder.findService( Some.class ).get();
assertEquals( "method()", some.method() );
assertEquals( some.identity(), result.some().identity() );
assertEquals( some.identity().get(), result.some().identity().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi377/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/IssueTest.java
index 8ce8c77..cc4cfe8 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/IssueTest.java
@@ -41,7 +41,7 @@ public class IssueTest
@Test
public void propertyNameCollisionsShouldWork()
{
- TeamMember m = module.newTransient( TeamMember.class );
+ TeamMember m = transientBuilderFactory.newTransient( TeamMember.class );
m.name().set( "Niclas" );
Person p = m;
p.name().set( "Chris" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
index d51309c..4b069e4 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
@@ -42,7 +42,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetNameToTheCompany()
{
- ValueBuilder<Company> builder = module.newValueBuilder( Company.class );
+ ValueBuilder<Company> builder = valueBuilderFactory.newValueBuilder( Company.class );
builder.prototype().name().set( "Acme" );
Company startUp = builder.newInstance();
}
@@ -50,8 +50,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetLeadToTheCompany()
{
- Company startUp = module.newValue( Company.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ Company startUp = valueBuilderFactory.newValue( Company.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.lead().set( niclas );
@@ -60,8 +60,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetLeadToTheSalesTeam()
{
- SalesTeam startUp = module.newValue( SalesTeam.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ SalesTeam startUp = valueBuilderFactory.newValue( SalesTeam.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.lead().set( niclas );
@@ -70,8 +70,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetLeadToTheResearchTeam()
{
- ResearchTeam startUp = module.newValue( ResearchTeam.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ ResearchTeam startUp = valueBuilderFactory.newValue( ResearchTeam.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.lead().set( niclas );
@@ -80,8 +80,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheCompany()
{
- Company startUp = module.newValue( Company.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ Company startUp = valueBuilderFactory.newValue( Company.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.employees().add( niclas );
@@ -90,8 +90,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheSalesTeam()
{
- SalesTeam startUp = module.newValue( SalesTeam.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ SalesTeam startUp = valueBuilderFactory.newValue( SalesTeam.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.employees().add( niclas );
@@ -100,8 +100,8 @@ public class ValueCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheResearchTeam()
{
- ResearchTeam startUp = module.newValue( ResearchTeam.class );
- ValueBuilder<Employee> builder = module.newValueBuilder( Employee.class );
+ ResearchTeam startUp = valueBuilderFactory.newValue( ResearchTeam.class );
+ ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
builder.prototype().identity().set( "niclas" );
Employee niclas = builder.newInstance();
startUp.employees().add( niclas );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi53/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi53/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi53/IssueTest.java
index 58b33c3..71daed8 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi53/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi53/IssueTest.java
@@ -46,7 +46,7 @@ public class IssueTest
public void genericPropertiesAndParameters()
throws SecurityException, NoSuchMethodException
{
- TransientBuilder<CostPerUnitComposite> builder = module.newTransientBuilder( CostPerUnitComposite.class );
+ TransientBuilder<CostPerUnitComposite> builder = transientBuilderFactory.newTransientBuilder( CostPerUnitComposite.class );
builder.prototype().unit().set( new Unit<Integer>( 10 ) );
CostPerUnitComposite test = builder.newInstance();
assertEquals( 10, test.unit().get().value );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi55/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi55/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi55/IssueTest.java
index f170407..847fa7c 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi55/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi55/IssueTest.java
@@ -38,9 +38,7 @@ public class IssueTest
@Test
public void objectWithGenericUsage()
{
- assertEquals( "Using - Test string", module.
- newObject( AClass.class, "Test string" ).
- uses() );
+ assertEquals( "Using - Test string", objectFactory.newObject( AClass.class, "Test string" ).uses() );
}
public static class AClass<T>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi65/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi65/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi65/IssueTest.java
index 676183d..40a7d58 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi65/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi65/IssueTest.java
@@ -42,7 +42,7 @@ public class IssueTest
public void constraintOnMethodParameter()
throws SecurityException, NoSuchMethodException
{
- TestComposite test = module.newTransient( TestComposite.class );
+ TestComposite test = transientBuilderFactory.newTransient( TestComposite.class );
test.someMethod( null );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi74/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi74/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi74/IssueTest.java
index 1a0a1ff..e6a6169 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi74/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi74/IssueTest.java
@@ -41,7 +41,7 @@ public class IssueTest
{
try
{
- TransientBuilder<ValueHolder> builder = module.newTransientBuilder( ValueHolder.class );
+ TransientBuilder<ValueHolder> builder = transientBuilderFactory.newTransientBuilder( ValueHolder.class );
builder.newInstance();
Assert.fail( "NotNull constraint violated but no exception is raised" );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
index 2fd8a7a..ccdfdc2 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
@@ -17,8 +17,6 @@
*/
package org.apache.zest.regression.qi78;
-import org.junit.Assert;
-import org.junit.Test;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.ApplicationDescriptor;
import org.apache.zest.api.structure.LayerDescriptor;
@@ -29,6 +27,8 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.functional.HierarchicalVisitorAdapter;
+import org.junit.Assert;
+import org.junit.Test;
public class IssueTest
{
@@ -79,12 +79,9 @@ public class IssueTest
{
if( visited instanceof LayerDescriptor )
{
- Iterable<? extends LayerDescriptor> usedLayers = ( (LayerDescriptor) visited ).usedLayers()
- .layers();
- for( LayerDescriptor usedLayerModel : usedLayers )
- {
+ ( (LayerDescriptor) visited ).usedLayers().layers().forEach( usedLayerModel -> {
Assert.assertNotNull( "Used layer model is null", usedLayerModel );
- }
+ } );
}
return false;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java b/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
index a9f7dfa..25dff76 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
@@ -52,11 +52,11 @@ public class ZestAPITest
unitOfWork.discard();
- api.moduleOf( module.newValue( TestValue.class ) );
+ api.moduleOf( valueBuilderFactory.newValue( TestValue.class ) );
- api.moduleOf( module.newTransient( TestTransient.class ) );
+ api.moduleOf( transientBuilderFactory.newTransient( TestTransient.class ) );
- api.moduleOf( module.findService( TestService.class ).get() );
+ api.moduleOf( serviceFinder.findService( TestService.class ).get() );
}
public interface TestTransient
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToFilterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToFilterTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToFilterTest.java
index 48a7682..39dd736 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToFilterTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToFilterTest.java
@@ -46,7 +46,7 @@ public class AppliesToFilterTest
public void givenAnAppliesToFilterWhenAppliedThenFilterMethods()
throws Exception
{
- Some some = module.newTransient( Some.class );
+ Some some = transientBuilderFactory.newTransient( Some.class );
Assert.assertEquals( ",", some.doStuff1() );
Assert.assertEquals( ",,..", some.doStuff2() );
Assert.assertEquals( ",,,", some.doStuff3() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
index f2ec635..58d9b66 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
@@ -61,7 +61,7 @@ public class AppliesToOrConditionQI241Test
try
{
- ServiceReference<SomeServiceCompositeWithFirstAnnotation> refWithFirst = module.findService(
+ ServiceReference<SomeServiceCompositeWithFirstAnnotation> refWithFirst = serviceFinder.findService(
SomeServiceCompositeWithFirstAnnotation.class );
SomeServiceCompositeWithFirstAnnotation someWithFirst = refWithFirst.get();
someWithFirst.doStuff();
@@ -80,7 +80,7 @@ public class AppliesToOrConditionQI241Test
try
{
- ServiceReference<SomeServiceCompositeWithSecondAnnotation> refWithSecond = module.findService(
+ ServiceReference<SomeServiceCompositeWithSecondAnnotation> refWithSecond = serviceFinder.findService(
SomeServiceCompositeWithSecondAnnotation.class );
SomeServiceCompositeWithSecondAnnotation someWithSecond = refWithSecond.get();
someWithSecond.doStuff();
@@ -99,7 +99,7 @@ public class AppliesToOrConditionQI241Test
try
{
- ServiceReference<SomeServiceCompositeWithTwoAnnotations> refWithTwo = module.findService(
+ ServiceReference<SomeServiceCompositeWithTwoAnnotations> refWithTwo = serviceFinder.findService(
SomeServiceCompositeWithTwoAnnotations.class );
SomeServiceCompositeWithTwoAnnotations someWithTwo = refWithTwo.get();
someWithTwo.doStuff();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToTest.java
index 1993d39..b45a5b3 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToTest.java
@@ -46,7 +46,7 @@ public class AppliesToTest
public void givenAnAppliesToWhenNoAnnotationExpectNoConcernInInvocationStack()
throws Exception
{
- Some some = module.newTransient( Some.class );
+ Some some = transientBuilderFactory.newTransient( Some.class );
Assert.assertEquals( ",", some.doStuff1() );
}
@@ -54,7 +54,7 @@ public class AppliesToTest
public void givenAnAppliesToWhenAnnotationIsOnMixinTypeExpectConcernInInvocationStack()
throws Exception
{
- Some some = module.newTransient( Some.class );
+ Some some = transientBuilderFactory.newTransient( Some.class );
Assert.assertEquals( ",,..", some.doStuff2() );
}
@@ -62,7 +62,7 @@ public class AppliesToTest
public void givenAnAppliesToWhenAnnotationIsOnMixinImplementationExpectConcernInInvocationStack()
throws Exception
{
- Some some = module.newTransient( Some.class );
+ Some some = transientBuilderFactory.newTransient( Some.class );
Assert.assertEquals( ",", some.doStuff1() );
Assert.assertEquals( ",,..", some.doStuff2() );
Assert.assertEquals( ",,,", some.doStuff3() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/FragmentAppliesToTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/FragmentAppliesToTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/FragmentAppliesToTest.java
index f29b850..c1847ad 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/FragmentAppliesToTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/FragmentAppliesToTest.java
@@ -53,7 +53,7 @@ public class FragmentAppliesToTest
public void testMixin()
throws Exception
{
- TransientBuilder<Composite1> builder = module.newTransientBuilder( Composite1.class );
+ TransientBuilder<Composite1> builder = transientBuilderFactory.newTransientBuilder( Composite1.class );
Composite1 instance = builder.newInstance();
assertNotNull( "DependencyOld not injected.", instance.getBuilderFactory() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
index 4ffc14b..0bc855d 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
@@ -431,7 +431,7 @@ public class AssociationEqualityTest
{
SomeWithAssociations some;
{
- ValueBuilder<SomeWithAssociations> builder = module.newValueBuilder( SomeWithAssociations.class );
+ ValueBuilder<SomeWithAssociations> builder = valueBuilderFactory.newValueBuilder( SomeWithAssociations.class );
builder.prototype().anEntity().set( associated );
builder.prototype().manyEntities().add( associated );
builder.prototype().namedEntities().put( "someKey", associated );
@@ -444,7 +444,7 @@ public class AssociationEqualityTest
{
OtherWithAssociations some;
{
- ValueBuilder<OtherWithAssociations> builder = module.newValueBuilder( OtherWithAssociations.class );
+ ValueBuilder<OtherWithAssociations> builder = valueBuilderFactory.newValueBuilder( OtherWithAssociations.class );
builder.prototype().anEntity().set( associated );
builder.prototype().manyEntities().add( associated );
builder.prototype().namedEntities().put( "someKey", associated );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java
index b7d7a68..1827f85 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DereferenceForBootstrappedConcernsTest.java
@@ -51,8 +51,8 @@ public class DereferenceForBootstrappedConcernsTest
public void whenDerefencingInsideConcernThisExpectItToWork()
throws Exception
{
- Result result = module.findService( Result.class ).get();
- Some some = module.findService( Some.class ).get();
+ Result result = serviceFinder.findService( Result.class ).get();
+ Some some = serviceFinder.findService( Some.class ).get();
assertEquals( "method()", some.method() );
assertEquals( some.identity(), result.some().identity() );
assertEquals( some.identity().get(), result.some().identity().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/AbstractMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/AbstractMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/AbstractMixinTest.java
index 9720920..e5000fc 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/AbstractMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/AbstractMixinTest.java
@@ -46,7 +46,7 @@ public class AbstractMixinTest
@Test
public void testAbstractMixin()
{
- TestComposite instance = module.newTransient( TestComposite.class );
+ TestComposite instance = transientBuilderFactory.newTransient( TestComposite.class );
Assert.assertEquals( "Hello WorldHello World", instance.test( "Hello World" ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/CompositeFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/CompositeFactoryImplTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/CompositeFactoryImplTest.java
index cca8c1a..290e987 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/CompositeFactoryImplTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/CompositeFactoryImplTest.java
@@ -44,7 +44,7 @@ public class CompositeFactoryImplTest
throws Exception
{
Class aClass = FirstComposite.class;
- TransientBuilder builder = module.newTransientBuilder( aClass );
+ TransientBuilder builder = transientBuilderFactory.newTransientBuilder( aClass );
builder.newInstance();
}
@@ -54,7 +54,7 @@ public class CompositeFactoryImplTest
{
try
{
- TransientBuilder<SecondComposite> builder = module.newTransientBuilder(
+ TransientBuilder<SecondComposite> builder = transientBuilderFactory.newTransientBuilder(
SecondComposite.class );
SecondComposite composition9 = builder.newInstance();
composition9.setValue( "satisfiedBy value" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/FunctionalListTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/FunctionalListTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/FunctionalListTest.java
index 28acf98..47ef00c 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/FunctionalListTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/FunctionalListTest.java
@@ -46,7 +46,7 @@ public class FunctionalListTest extends AbstractZestTest
@Test
public void givenArrayListWithMapOpCapabilityWhenMappingIntegerToStringExpectCorrectResult()
{
- List<Integer> integers = module.newTransient( List.class );
+ List<Integer> integers = transientBuilderFactory.newTransient( List.class );
integers.add( 5 );
integers.add( 15 );
integers.add( 45 );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/MapOverrideTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/MapOverrideTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/MapOverrideTest.java
index e75a057..53ff78d 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/MapOverrideTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/MapOverrideTest.java
@@ -56,7 +56,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingSizeExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -66,7 +66,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingIsEmptyExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -76,7 +76,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingContainsKeyExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -86,7 +86,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingContainsValueExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -96,7 +96,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingGetExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -106,7 +106,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingKeySetExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
@@ -122,7 +122,7 @@ public class MapOverrideTest
@Test
public void givenReadOnlyAnnotatedHashMapWhenCallingValuesExpectSuccess()
{
- ValueBuilder<Map> builder = module.newValueBuilder( Map.class );
+ ValueBuilder<Map> builder = valueBuilderFactory.newValueBuilder( Map.class );
Map<String, String> prototype = builder.prototype();
prototype.put( "Niclas", "Hedhman" );
Map<String, String> underTest = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test1.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test1.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test1.java
index f02c8a4..4234151 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test1.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test1.java
@@ -65,43 +65,43 @@ public class QI247Test1
@Test
public void testWithMixinToString()
{
- ObjectMethods withMixin = module.newTransient( ObjectMethods.class );
+ ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class );
checkToString( withMixin );
}
@Test
public void testWithMixinHashCode()
{
- ObjectMethods withMixin = module.newTransient( ObjectMethods.class );
+ ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class );
checkHashCode( withMixin );
}
@Test
public void testWithMixinSelfEquals()
{
- ObjectMethods withMixin = module.newTransient( ObjectMethods.class );
+ ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class );
checkSelfEquals( withMixin );
}
@Test
public void testWithMixinSelfEquals2()
{
- ObjectMethods withMixin = module.newTransient( ObjectMethods.class );
+ ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class );
assertTrue( withMixin.equals( withMixin ) );
}
@Test
public void testWithMixinSelfSame()
{
- ObjectMethods withMixin = module.newTransient( ObjectMethods.class );
+ ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class );
assertSame( withMixin, withMixin );
}
@Test
public void testWithMixinTwoNotEqual()
{
- ObjectMethods first = module.newTransient( ObjectMethods.class );
- ObjectMethods second = module.newTransient( ObjectMethods.class );
+ ObjectMethods first = transientBuilderFactory.newTransient( ObjectMethods.class );
+ ObjectMethods second = transientBuilderFactory.newTransient( ObjectMethods.class );
checkTwoNotEqual( first, second );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test2.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test2.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test2.java
index e0783bb..ebe8ef3 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test2.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/QI247Test2.java
@@ -67,43 +67,43 @@ public class QI247Test2
@Test
public void testWithHandlerToString()
{
- ObjectMethods withHandler = module.newTransient( ObjectMethods.class );
+ ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class );
checkToString( withHandler );
}
@Test
public void testWithHandlerHashCode()
{
- ObjectMethods withHandler = module.newTransient( ObjectMethods.class );
+ ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class );
checkHashCode( withHandler );
}
@Test
public void testWithHandlerSelfEquals()
{
- ObjectMethods withHandler = module.newTransient( ObjectMethods.class );
+ ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class );
checkSelfEquals( withHandler );
}
@Test
public void testWithHandlerSelfEquals2()
{
- ObjectMethods withHandler = module.newTransient( ObjectMethods.class );
+ ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class );
assertTrue( withHandler.equals( withHandler ) );
}
@Test
public void testWithHandlerSelfSame()
{
- ObjectMethods withHandler = module.newTransient( ObjectMethods.class );
+ ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class );
assertSame( withHandler, withHandler );
}
@Test
public void testWithHandlerTwoNotEqual()
{
- ObjectMethods first = module.newTransient( ObjectMethods.class );
- ObjectMethods second = module.newTransient( ObjectMethods.class );
+ ObjectMethods first = transientBuilderFactory.newTransient( ObjectMethods.class );
+ ObjectMethods second = transientBuilderFactory.newTransient( ObjectMethods.class );
checkTwoNotEqual( first, second );
}
[26/34] zest-java git commit: ZEST-136 - Fixed up some smaller
issues. Still have the ServiceReference and ImportedService story messed up.
ServiceQualifiers are not handled correctly.
Posted by ni...@apache.org.
ZEST-136 - Fixed up some smaller issues. Still have the ServiceReference and ImportedService story messed up. ServiceQualifiers are not handled correctly.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/72314b85
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/72314b85
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/72314b85
Branch: refs/heads/develop
Commit: 72314b856f6360a899f48e56a2bf3ae2cc019e74
Parents: dedb068
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Dec 17 21:15:41 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Dec 17 21:15:41 2015 +0800
----------------------------------------------------------------------
.../zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java | 6 ++++--
.../org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java | 2 +-
.../org/apache/zest/runtime/service/ImportedServiceModel.java | 7 +++++--
.../java/org/apache/zest/runtime/value/ValueInstance.java | 2 +-
.../zest/spi/service/importer/InstanceImporterTest.java | 2 --
5 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/72314b85/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
index e7dd04f..44ee396 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ImportedServiceAssemblyImpl.java
@@ -24,6 +24,7 @@ import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.service.ServiceImporter;
import org.apache.zest.api.service.importer.InstanceImporter;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.bootstrap.ImportedServiceAssembly;
import org.apache.zest.runtime.activation.ActivatorsModel;
import org.apache.zest.runtime.service.ImportedServiceModel;
@@ -59,7 +60,7 @@ public final class ImportedServiceAssemblyImpl
}
@SuppressWarnings( { "raw", "unchecked" } )
- void addImportedServiceModel( List<ImportedServiceModel> serviceModels )
+ void addImportedServiceModel( ModuleDescriptor module, List<ImportedServiceModel> serviceModels )
{
try
{
@@ -69,7 +70,8 @@ public final class ImportedServiceAssemblyImpl
id = generateId( serviceModels, serviceType );
}
- ImportedServiceModel serviceModel = new ImportedServiceModel( serviceType,
+ ImportedServiceModel serviceModel = new ImportedServiceModel( module,
+ serviceType,
visibility,
serviceProvider,
id,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/72314b85/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
index e997460..6e2a356 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -568,7 +568,7 @@ public final class ModuleAssemblyImpl
for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
{
- importedServiceDeclaration.addImportedServiceModel( importedServiceModels );
+ importedServiceDeclaration.addImportedServiceModel( moduleModel, importedServiceModels );
}
// Check for duplicate service identities
http://git-wip-us.apache.org/repos/asf/zest-java/blob/72314b85/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
index f3bf992..8ca2dff 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
@@ -39,6 +39,7 @@ import org.apache.zest.runtime.activation.ActivatorsModel;
public final class ImportedServiceModel
implements ImportedServiceDescriptor, VisitableHierarchy<Object, Object>
{
+ private final ModuleDescriptor module;
private final Class<?> type;
private final Visibility visibility;
@SuppressWarnings( "raw" )
@@ -50,7 +51,8 @@ public final class ImportedServiceModel
private final String moduleName;
@SuppressWarnings( "raw" )
- public ImportedServiceModel( Class serviceType,
+ public ImportedServiceModel( ModuleDescriptor module,
+ Class serviceType,
Visibility visibility,
Class<? extends ServiceImporter> serviceImporter,
String identity,
@@ -60,6 +62,7 @@ public final class ImportedServiceModel
String moduleName
)
{
+ this.module = module;
type = serviceType;
this.visibility = visibility;
this.serviceImporter = serviceImporter;
@@ -91,7 +94,7 @@ public final class ImportedServiceModel
@Override
public ModuleDescriptor module()
{
- return null;
+ return module;
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/72314b85/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
index beb232c..184c05b 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueInstance.java
@@ -168,6 +168,6 @@ public final class ValueInstance
@Override
public String toString()
{
- return ( (ModuleSpi) module() ).valueSerialization().serialize( this.<ValueComposite>proxy() );
+ return ( (ModuleSpi) module().instance() ).valueSerialization().serialize( this.<ValueComposite>proxy() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/72314b85/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
index 045e89e..bca35ee 100644
--- a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/InstanceImporterTest.java
@@ -46,8 +46,6 @@ public class InstanceImporterTest
@Test
public void givenSingletonServiceObjectWhenServicesAreInjectedThenSingletonIsFound()
{
- module.instance().injectTo( this );
-
assertThat( "service is injected properly", service.helloWorld(), equalTo( "Hello World" ) );
}
[02/34] zest-java git commit: Inference didn't work in some cases
here. The Dependencies callSite can't be constructed,
but if line broken into two, then it worked.
Posted by ni...@apache.org.
Inference didn't work in some cases here. The Dependencies callSite can't be constructed, but if line broken into two, then it worked.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e120d16c
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e120d16c
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e120d16c
Branch: refs/heads/develop
Commit: e120d16c6b04f061071be1cad33b87e5600276f7
Parents: d845ea7
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Mon Dec 14 21:53:08 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Mon Dec 14 21:53:08 2015 +0800
----------------------------------------------------------------------
.../composite/AbstractModifierModel.java | 4 +-
.../zest/runtime/composite/MixinModel.java | 7 +--
.../apache/zest/index/rdf/MultiLayeredTest.java | 49 ++++++++++++++++++++
3 files changed, 53 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e120d16c/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
index a14d597..a2458d5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
@@ -70,8 +70,8 @@ public abstract class AbstractModifierModel
@SuppressWarnings( "unchecked" )
public Stream<DependencyModel> dependencies()
{
- return Stream.of( constructorsModel, injectedFieldsModel, injectedMethodsModel )
- .flatMap( Dependencies::dependencies );
+ Stream<? extends Dependencies> models = Stream.of( this.constructorsModel, injectedFieldsModel, injectedMethodsModel );
+ return models.flatMap( Dependencies::dependencies );
// return flattenIterables( map( DEPENDENCIES_FUNCTION, iterable( constructorsModel, injectedFieldsModel, injectedMethodsModel ) ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e120d16c/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
index abbe7b0..0beb55a 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/MixinModel.java
@@ -77,10 +77,8 @@ public final class MixinModel
public Stream<DependencyModel> dependencies()
{
- return Stream.of( constructorsModel, injectedFieldsModel, injectedMethodsModel )
- .flatMap( Dependencies::dependencies );
-// return Iterables.flatten( constructorsModel.dependencies(), injectedFieldsModel.dependencies(), injectedMethodsModel
-// .dependencies() );
+ Stream<? extends Dependencies> models = Stream.of( constructorsModel, injectedFieldsModel, injectedMethodsModel );
+ return models.flatMap( Dependencies::dependencies );
}
@Override
@@ -178,5 +176,4 @@ public final class MixinModel
{
return mixinClass.getName();
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e120d16c/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
new file mode 100644
index 0000000..7923b75
--- /dev/null
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.index.rdf;
+
+import org.apache.zest.api.common.Visibility;
+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.index.rdf.assembly.RdfMemoryStoreAssembler;
+import org.apache.zest.test.indexing.layered.AbstractMultiLayeredIndexingTest;
+
+public class MultiLayeredTest extends AbstractMultiLayeredIndexingTest
+{
+ public MultiLayeredTest()
+ {
+ super( IndexingModuleAssembler.class );
+ }
+
+ static class IndexingModuleAssembler
+ implements ModuleAssembler
+ {
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( module );
+ return module;
+ }
+ }
+}
[24/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
index c06a811..e997460 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -70,6 +70,7 @@ import org.apache.zest.runtime.service.ImportedServiceModel;
import org.apache.zest.runtime.service.ImportedServicesModel;
import org.apache.zest.runtime.service.ServiceModel;
import org.apache.zest.runtime.service.ServicesModel;
+import org.apache.zest.runtime.structure.LayerModel;
import org.apache.zest.runtime.structure.ModuleModel;
import org.apache.zest.runtime.value.ValueModel;
import org.apache.zest.runtime.value.ValuesModel;
@@ -504,7 +505,7 @@ public final class ModuleAssemblyImpl
}
}
- ModuleModel assembleModule( AssemblyHelper helper )
+ ModuleModel assembleModule( LayerModel layerModel, AssemblyHelper helper )
throws AssemblyException
{
List<TransientModel> transientModels = new ArrayList<>();
@@ -512,6 +513,18 @@ public final class ModuleAssemblyImpl
List<ValueModel> valueModels = new ArrayList<>();
List<ServiceModel> serviceModels = new ArrayList<>();
List<ImportedServiceModel> importedServiceModels = new ArrayList<>();
+ List<EntityModel> entityModels = new ArrayList<>();
+
+ ModuleModel moduleModel = new ModuleModel( name,
+ metaInfo,
+ layerModel,
+ new ActivatorsModel<>( activators ),
+ new TransientsModel( transientModels ),
+ new EntitiesModel( entityModels ),
+ new ObjectsModel( objectModels ),
+ new ValuesModel( valueModels ),
+ new ServicesModel( serviceModels ),
+ new ImportedServicesModel( importedServiceModels ) );
if( name == null )
{
@@ -520,18 +533,18 @@ public final class ModuleAssemblyImpl
for( TransientAssemblyImpl compositeDeclaration : transientAssemblies.values() )
{
- transientModels.add( compositeDeclaration.newTransientModel( metaInfoDeclaration, helper ) );
+ transientModels.add( compositeDeclaration.newTransientModel( moduleModel, metaInfoDeclaration, helper ) );
}
for( ValueAssemblyImpl valueDeclaration : valueAssemblies.values() )
{
- valueModels.add( valueDeclaration.newValueModel( metaInfoDeclaration, helper ) );
+ valueModels.add( valueDeclaration.newValueModel( moduleModel, metaInfoDeclaration, helper ) );
}
- List<EntityModel> entityModels = new ArrayList<>();
for( EntityAssemblyImpl entityDeclaration : entityAssemblies.values() )
{
- entityModels.add( entityDeclaration.newEntityModel( metaInfoDeclaration,
+ entityModels.add( entityDeclaration.newEntityModel( moduleModel,
+ metaInfoDeclaration,
metaInfoDeclaration,
metaInfoDeclaration,
metaInfoDeclaration,
@@ -540,7 +553,7 @@ public final class ModuleAssemblyImpl
for( ObjectAssemblyImpl objectDeclaration : objectAssemblies.values() )
{
- objectDeclaration.addObjectModel( objectModels );
+ objectDeclaration.addObjectModel( moduleModel, objectModels );
}
for( ServiceAssemblyImpl serviceDeclaration : serviceAssemblies )
@@ -550,7 +563,7 @@ public final class ModuleAssemblyImpl
serviceDeclaration.identity = generateId( serviceDeclaration.types() );
}
- serviceModels.add( serviceDeclaration.newServiceModel( metaInfoDeclaration, helper ) );
+ serviceModels.add( serviceDeclaration.newServiceModel( moduleModel, metaInfoDeclaration, helper ) );
}
for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
@@ -558,16 +571,6 @@ public final class ModuleAssemblyImpl
importedServiceDeclaration.addImportedServiceModel( importedServiceModels );
}
- ModuleModel moduleModel = new ModuleModel( name,
- metaInfo,
- new ActivatorsModel<>( activators ),
- new TransientsModel( transientModels ),
- new EntitiesModel( entityModels ),
- new ObjectsModel( objectModels ),
- new ValuesModel( valueModels ),
- new ServicesModel( serviceModels ),
- new ImportedServicesModel( importedServiceModels ) );
-
// Check for duplicate service identities
Set<String> identities = new HashSet<>();
for( ServiceModel serviceModel : serviceModels )
@@ -601,7 +604,7 @@ public final class ModuleAssemblyImpl
)
{
Class<? extends ServiceImporter> serviceFactoryType = importedServiceModel.serviceImporter();
- ObjectModel objectModel = new ObjectModel( serviceFactoryType, Visibility.module, new MetaInfo() );
+ ObjectModel objectModel = new ObjectModel( moduleModel, serviceFactoryType, Visibility.module, new MetaInfo() );
objectModels.add( objectModel );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
index 778ffef..9ea5b6b 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ObjectAssemblyImpl.java
@@ -21,6 +21,7 @@ import org.apache.zest.api.common.InvalidApplicationException;
import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.bootstrap.ObjectAssembly;
import org.apache.zest.runtime.object.ObjectModel;
@@ -51,11 +52,11 @@ public final class ObjectAssemblyImpl
return Stream.of( objectType );
}
- void addObjectModel( List<ObjectModel> objectModels )
+ void addObjectModel( ModuleDescriptor module, List<ObjectModel> objectModels )
{
try
{
- ObjectModel objectModel = new ObjectModel( objectType, visibility, metaInfo );
+ ObjectModel objectModel = new ObjectModel( module, objectType, visibility, metaInfo );
objectModels.add( objectModel );
}
catch( Throwable e )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
index 255c2d0..e606b10 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ServiceAssemblyImpl.java
@@ -31,6 +31,7 @@ import org.apache.zest.bootstrap.StateDeclarations;
import org.apache.zest.functional.Iterables;
import org.apache.zest.runtime.activation.ActivatorsModel;
import org.apache.zest.runtime.service.ServiceModel;
+import org.apache.zest.runtime.structure.ModuleModel;
/**
* Assembly of a Service.
@@ -59,14 +60,14 @@ public final class ServiceAssemblyImpl extends CompositeAssemblyImpl
}
@SuppressWarnings( { "raw", "unchecked" } )
- ServiceModel newServiceModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
+ ServiceModel newServiceModel( ModuleModel module, StateDeclarations stateDeclarations, AssemblyHelper helper )
{
try
{
buildComposite( helper, stateDeclarations );
List<Class<? extends Activator<?>>> activatorClasses = Iterables.toList(
Iterables.<Class<? extends Activator<?>>>flatten( activators, activatorsDeclarations( types.stream() ) ) );
- return new ServiceModel( types, visibility, metaInfo,
+ return new ServiceModel( module, types, visibility, metaInfo,
new ActivatorsModel( activatorClasses ),
mixinsModel, stateModel, compositeMethodsModel,
identity, instantiateOnStartup );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
index 8f3dcdc..100ceab 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/TransientAssemblyImpl.java
@@ -16,6 +16,7 @@ package org.apache.zest.runtime.bootstrap;
import org.apache.zest.api.common.InvalidApplicationException;
import org.apache.zest.api.composite.TransientComposite;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.bootstrap.StateDeclarations;
import org.apache.zest.bootstrap.TransientAssembly;
import org.apache.zest.runtime.composite.TransientModel;
@@ -43,15 +44,16 @@ public final class TransientAssemblyImpl extends CompositeAssemblyImpl
}
}
- TransientModel newTransientModel( StateDeclarations stateDeclarations, AssemblyHelper helper )
+ TransientModel newTransientModel( ModuleDescriptor module,
+ StateDeclarations stateDeclarations,
+ AssemblyHelper helper
+ )
{
try
{
buildComposite( helper, stateDeclarations );
- TransientModel transientModel = new TransientModel(
- types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
-
- return transientModel;
+ return new TransientModel(
+ module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
}
catch( Exception e )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
index 80d692f..af278bd 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ValueAssemblyImpl.java
@@ -18,19 +18,33 @@
*/
package org.apache.zest.runtime.bootstrap;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.util.List;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.GenericAssociationInfo;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.*;
+import org.apache.zest.api.common.InvalidApplicationException;
+import org.apache.zest.api.common.MetaInfo;
+import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.common.QualifiedName;
+import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.property.GenericPropertyInfo;
import org.apache.zest.api.property.Property;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.Annotations;
import org.apache.zest.api.util.Classes;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.bootstrap.StateDeclarations;
import org.apache.zest.bootstrap.ValueAssembly;
-import org.apache.zest.runtime.association.*;
+import org.apache.zest.runtime.association.AssociationModel;
+import org.apache.zest.runtime.association.AssociationsModel;
+import org.apache.zest.runtime.association.ManyAssociationModel;
+import org.apache.zest.runtime.association.ManyAssociationsModel;
+import org.apache.zest.runtime.association.NamedAssociationModel;
+import org.apache.zest.runtime.association.NamedAssociationsModel;
import org.apache.zest.runtime.composite.StateModel;
import org.apache.zest.runtime.composite.ValueConstraintsInstance;
import org.apache.zest.runtime.composite.ValueConstraintsModel;
@@ -38,11 +52,6 @@ import org.apache.zest.runtime.property.PropertyModel;
import org.apache.zest.runtime.value.ValueModel;
import org.apache.zest.runtime.value.ValueStateModel;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.List;
-
import static org.apache.zest.api.util.Annotations.isType;
import static org.apache.zest.api.util.Classes.typeOf;
@@ -73,9 +82,9 @@ public final class ValueAssemblyImpl
return new ValueStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
}
- ValueModel newValueModel(
- StateDeclarations stateDeclarations,
- AssemblyHelper helper
+ ValueModel newValueModel( ModuleDescriptor module,
+ StateDeclarations stateDeclarations,
+ AssemblyHelper helper
)
{
try
@@ -86,7 +95,7 @@ public final class ValueAssemblyImpl
buildComposite( helper, stateDeclarations );
return new ValueModel(
- types, visibility, metaInfo, mixinsModel, (ValueStateModel) stateModel, compositeMethodsModel );
+ module, types, visibility, metaInfo, mixinsModel, (ValueStateModel) stateModel, compositeMethodsModel );
}
catch( Exception e )
{
@@ -134,7 +143,7 @@ public final class ValueAssemblyImpl
List<Class<?>> constraintClasses
)
{
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
+ List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations.stream(), GenericPropertyInfo.propertyTypeOf( accessor ), ( (Member) accessor )
.getName(), optional, constraintClasses, accessor );
@@ -153,7 +162,7 @@ public final class ValueAssemblyImpl
List<Class<?>> constraintClasses
)
{
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
+ List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for Association references
@@ -181,7 +190,7 @@ public final class ValueAssemblyImpl
List<Class<?>> constraintClasses
)
{
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
+ List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for entities in ManyAssociation
@@ -208,7 +217,7 @@ public final class ValueAssemblyImpl
List<Class<?>> constraintClasses
)
{
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn(accessor);
+ List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
// Constraints for entities in NamedAssociation
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
index a2458d5..90398e0 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/AbstractModifierModel.java
@@ -18,9 +18,9 @@ import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.function.IntFunction;
import java.util.stream.Stream;
import org.apache.zest.api.common.ConstructionException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.injection.Dependencies;
@@ -28,7 +28,6 @@ import org.apache.zest.runtime.injection.DependencyModel;
import org.apache.zest.runtime.injection.InjectedFieldsModel;
import org.apache.zest.runtime.injection.InjectedMethodsModel;
import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.spi.module.ModuleSpi;
import static org.apache.zest.api.util.Classes.RAW_CLASS;
import static org.apache.zest.api.util.Classes.interfacesOf;
@@ -99,13 +98,13 @@ public abstract class AbstractModifierModel
}
// Context
- public InvocationHandler newInstance( ModuleSpi moduleInstance,
+ public InvocationHandler newInstance( ModuleDescriptor module,
InvocationHandler next,
ProxyReferenceInvocationHandler proxyHandler,
Method method
)
{
- InjectionContext injectionContext = new InjectionContext( moduleInstance, wrapNext( next ), proxyHandler );
+ InjectionContext injectionContext = new InjectionContext( module, wrapNext( next ), proxyHandler );
Object modifier = constructorsModel.newInstance( injectionContext );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
index 7349cfa..9cfe321 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
@@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.zest.api.common.ConstructionException;
import org.apache.zest.api.composite.MethodDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.NullArgumentException;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
@@ -99,12 +100,12 @@ public final class CompositeMethodModel
}
// Context
- public Object invoke( Object composite, Object[] params, MixinsInstance mixins, ModuleSpi moduleInstance )
+ public Object invoke( Object composite, Object[] params, MixinsInstance mixins, ModuleDescriptor module )
throws Throwable
{
constraintsInstance.checkValid( composite, method, params );
- CompositeMethodInstance methodInstance = getInstance( moduleInstance );
+ CompositeMethodInstance methodInstance = getInstance( module );
try
{
return mixins.invoke( composite, params, methodInstance );
@@ -115,30 +116,30 @@ public final class CompositeMethodModel
}
}
- private CompositeMethodInstance getInstance( ModuleSpi moduleInstance )
+ private CompositeMethodInstance getInstance( ModuleDescriptor module )
{
CompositeMethodInstance methodInstance = instancePool.obtainInstance();
if( methodInstance == null )
{
- methodInstance = newCompositeMethodInstance( moduleInstance );
+ methodInstance = newCompositeMethodInstance( module );
}
return methodInstance;
}
- private CompositeMethodInstance newCompositeMethodInstance( ModuleSpi moduleInstance )
+ private CompositeMethodInstance newCompositeMethodInstance( ModuleDescriptor module )
throws ConstructionException
{
FragmentInvocationHandler mixinInvocationHandler = mixins.newInvocationHandler( method );
InvocationHandler invoker = mixinInvocationHandler;
if( concerns != ConcernsModel.EMPTY_CONCERNS )
{
- ConcernsInstance concernsInstance = concerns.newInstance( method, moduleInstance, mixinInvocationHandler );
+ ConcernsInstance concernsInstance = concerns.newInstance( method, module, mixinInvocationHandler );
invoker = concernsInstance;
}
if( sideEffects != SideEffectsModel.EMPTY_SIDEEFFECTS )
{
- SideEffectsInstance sideEffectsInstance = sideEffects.newInstance( method, moduleInstance, invoker );
+ SideEffectsInstance sideEffectsInstance = sideEffects.newInstance( method, module, invoker );
invoker = sideEffectsInstance;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
index d3915c1..d74ab38 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodsModel.java
@@ -19,13 +19,11 @@ import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.stream.Stream;
import org.apache.zest.api.composite.MissingMethodException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.injection.Dependencies;
import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
-
-import static org.apache.zest.functional.Iterables.map;
/**
* Model for Composite methods. This includes both private and public methods.
@@ -56,7 +54,7 @@ public final class CompositeMethodsModel
Object proxy,
Method method,
Object[] args,
- ModuleSpi moduleInstance
+ ModuleDescriptor moduleInstance
)
throws Throwable
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
index 7bd02ef..e75166e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeModel.java
@@ -27,12 +27,12 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.composite.CompositeDescriptor;
import org.apache.zest.api.composite.InvalidCompositeException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.Iterables;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.injection.Dependencies;
import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
import static java.lang.reflect.Proxy.newProxyInstance;
import static org.apache.zest.functional.Iterables.first;
@@ -53,8 +53,10 @@ public abstract class CompositeModel
private volatile Class<?> primaryType;
protected Class<? extends Composite> proxyClass;
protected Constructor<? extends Composite> proxyConstructor;
+ protected ModuleDescriptor module;
- protected CompositeModel( final List<Class<?>> types,
+ protected CompositeModel( final ModuleDescriptor module,
+ final List<Class<?>> types,
final Visibility visibility,
final MetaInfo metaInfo,
final MixinsModel mixinsModel,
@@ -62,6 +64,7 @@ public abstract class CompositeModel
final CompositeMethodsModel compositeMethodsModel
)
{
+ this.module = module;
this.types = new LinkedHashSet<>( types );
this.visibility = visibility;
this.metaInfo = metaInfo;
@@ -205,12 +208,17 @@ public abstract class CompositeModel
public final Object invoke( MixinsInstance mixins,
Object proxy,
Method method,
- Object[] args,
- ModuleSpi moduleInstance
+ Object[] args
)
throws Throwable
{
- return compositeMethodsModel.invoke( mixins, proxy, method, args, moduleInstance );
+ return compositeMethodsModel.invoke( mixins, proxy, method, args, module );
+ }
+
+ @Override
+ public ModuleDescriptor module()
+ {
+ return module;
}
public Composite newProxy( InvocationHandler invocationHandler )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
index 11f91ad..bea4499 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/ConcernsModel.java
@@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import org.apache.zest.api.concern.ConcernsDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.Iterables;
import org.apache.zest.functional.VisitableHierarchy;
@@ -50,7 +51,7 @@ public final class ConcernsModel
}
// Context
- public ConcernsInstance newInstance( Method method, ModuleSpi moduleInstance,
+ public ConcernsInstance newInstance( Method method, ModuleDescriptor module,
FragmentInvocationHandler mixinInvocationHandler
)
{
@@ -60,7 +61,7 @@ public final class ConcernsModel
{
ConcernModel concernModel = concernsFor.get( i );
- nextConcern = concernModel.newInstance( moduleInstance, nextConcern, proxyHandler, method );
+ nextConcern = concernModel.newInstance( module, nextConcern, proxyHandler, method );
}
return new ConcernsInstance( nextConcern, mixinInvocationHandler, proxyHandler );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
index 26d2afa..709a26a 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/SideEffectsModel.java
@@ -21,12 +21,11 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import org.apache.zest.api.sideeffect.SideEffectsDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.Iterables;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.injection.Dependencies;
import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* JAVADOC
@@ -51,14 +50,14 @@ public final class SideEffectsModel
}
// Context
- public SideEffectsInstance newInstance( Method method, ModuleSpi moduleInstance, InvocationHandler invoker )
+ public SideEffectsInstance newInstance( Method method, ModuleDescriptor module, InvocationHandler invoker )
{
ProxyReferenceInvocationHandler proxyHandler = new ProxyReferenceInvocationHandler();
SideEffectInvocationHandlerResult result = new SideEffectInvocationHandlerResult();
List<InvocationHandler> sideEffects = new ArrayList<InvocationHandler>( sideEffectModels.size() );
for( SideEffectModel sideEffectModel : sideEffectModels )
{
- InvocationHandler sideEffect = sideEffectModel.newInstance( moduleInstance, result, proxyHandler, method );
+ InvocationHandler sideEffect = sideEffectModel.newInstance( module, result, proxyHandler, method );
sideEffects.add( sideEffect );
}
return new SideEffectsInstance( sideEffects, result, proxyHandler, invoker );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
index 2b0570c..c70fc68 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientBuilderInstance.java
@@ -19,8 +19,6 @@ import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.composite.TransientBuilder;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* JAVADOC
@@ -28,7 +26,6 @@ import org.apache.zest.spi.module.ModuleSpi;
public final class TransientBuilderInstance<T>
implements TransientBuilder<T>
{
- private ModuleSpi module;
private TransientModel model;
// lazy initialized in accessor
@@ -39,13 +36,12 @@ public final class TransientBuilderInstance<T>
private TransientStateInstance state;
- public TransientBuilderInstance( ModelModule<TransientDescriptor> modelModule,
+ public TransientBuilderInstance( TransientDescriptor model,
TransientStateInstance state,
UsesInstance uses
)
{
- this.model = (TransientModel) modelModule.model();
- this.module = modelModule.module();
+ this.model = (TransientModel) model;
this.state = state;
this.uses = uses;
}
@@ -63,7 +59,7 @@ public final class TransientBuilderInstance<T>
// Instantiate given value type
if( prototypeInstance == null )
{
- prototypeInstance = model.newInstance( module, uses, state );
+ prototypeInstance = model.newInstance( uses, state );
}
return prototypeInstance.<T>proxy();
@@ -75,7 +71,7 @@ public final class TransientBuilderInstance<T>
// Instantiate given value type
if( prototypeInstance == null )
{
- prototypeInstance = model.newInstance( module, uses, state );
+ prototypeInstance = model.newInstance( uses, state );
}
return prototypeInstance.newProxy( mixinType );
@@ -94,8 +90,7 @@ public final class TransientBuilderInstance<T>
model.checkConstraints( state );
- CompositeInstance compositeInstance =
- model.newInstance( module, uses, state );
+ CompositeInstance compositeInstance = model.newInstance( uses, state );
return compositeInstance.<T>proxy();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
index 5531d52..75f7266 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientInstance.java
@@ -25,10 +25,8 @@ import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.composite.Composite;
import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.api.structure.LayerDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
/**
* InvocationHandler for proxy objects.
@@ -46,16 +44,13 @@ public class TransientInstance
protected final Object[] mixins;
protected StateHolder state;
protected final CompositeModel compositeModel;
- private final ModuleSpi moduleInstance;
public TransientInstance( CompositeModel compositeModel,
- ModuleSpi moduleInstance,
Object[] mixins,
StateHolder state
)
{
this.compositeModel = compositeModel;
- this.moduleInstance = moduleInstance;
this.mixins = mixins;
this.state = state;
@@ -66,7 +61,7 @@ public class TransientInstance
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
- return compositeModel.invoke( this, proxy, method, args, moduleInstance );
+ return compositeModel.invoke( this, proxy, method, args );
}
@Override
@@ -87,7 +82,7 @@ public class TransientInstance
public Object invokeComposite( Method method, Object[] args )
throws Throwable
{
- return compositeModel.invoke( this, proxy, method, args, moduleInstance );
+ return compositeModel.invoke( this, proxy, method, args );
}
@Override
@@ -109,14 +104,14 @@ public class TransientInstance
}
@Override
- public Module module()
+ public ModuleDescriptor module()
{
- return moduleInstance;
+ return compositeModel.module();
}
- public Layer layer()
+ public LayerDescriptor layer()
{
- return ( (ModuleInstance) moduleInstance ).layerInstance();
+ return compositeModel.module().layer();
}
@Override
@@ -217,7 +212,7 @@ public class TransientInstance
"mixins=" + Arrays.asList( mixins ) +
", state=" + state +
", compositeModel=" + compositeModel +
- ", module=" + moduleInstance +
+ ", module=" + module() +
'}';
}
return buffer.toString();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
index cc3d343..97475e9 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/TransientModel.java
@@ -19,6 +19,7 @@ import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.api.constraint.ConstraintViolationException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.spi.module.ModuleSpi;
@@ -28,23 +29,23 @@ import org.apache.zest.spi.module.ModuleSpi;
public class TransientModel extends CompositeModel
implements TransientDescriptor
{
- public TransientModel( List<Class<?>> types, final Visibility visibility,
+ public TransientModel( ModuleDescriptor module,
+ List<Class<?>> types, final Visibility visibility,
final MetaInfo metaInfo,
final MixinsModel mixinsModel,
final StateModel stateModel,
final CompositeMethodsModel compositeMethodsModel
)
{
- super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
+ super( module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
}
- public TransientInstance newInstance( ModuleSpi moduleInstance,
- UsesInstance uses,
+ public TransientInstance newInstance( UsesInstance uses,
TransientStateInstance state
)
{
Object[] mixins = mixinsModel.newMixinHolder();
- TransientInstance compositeInstance = new TransientInstance( this, moduleInstance, mixins, state );
+ TransientInstance compositeInstance = new TransientInstance( this, mixins, state );
// Instantiate all mixins
int i = 0;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
index 15c8524..6149700 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
@@ -30,6 +30,7 @@ import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.entity.LifecycleException;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkException;
@@ -37,7 +38,6 @@ import org.apache.zest.runtime.composite.CompositeMethodInstance;
import org.apache.zest.runtime.composite.MixinsInstance;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.module.ModuleSpi;
import static java.util.stream.Collectors.toList;
@@ -54,7 +54,6 @@ public final class EntityInstance
private final EntityComposite proxy;
private final UnitOfWork uow;
- private final ModuleSpi moduleInstance;
private final EntityModel entityModel;
private final EntityReference identity;
private final EntityState entityState;
@@ -63,13 +62,11 @@ public final class EntityInstance
private EntityStateInstance state;
public EntityInstance( UnitOfWork uow,
- ModuleSpi moduleInstance,
EntityModel entityModel,
EntityState entityState
)
{
this.uow = uow;
- this.moduleInstance = moduleInstance;
this.entityModel = entityModel;
this.identity = entityState.identity();
this.entityState = entityState;
@@ -81,7 +78,7 @@ public final class EntityInstance
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
- return entityModel.invoke( this, this.proxy, method, args, moduleInstance );
+ return entityModel.invoke( this, this.proxy, method, args );
}
public EntityReference identity()
@@ -113,7 +110,7 @@ public final class EntityInstance
public Object invokeComposite( Method method, Object[] args )
throws Throwable
{
- return entityModel.invoke( this, proxy, method, args, moduleInstance );
+ return entityModel.invoke( this, proxy, method, args );
}
@Override
@@ -134,9 +131,9 @@ public final class EntityInstance
}
@Override
- public ModuleSpi module()
+ public ModuleDescriptor module()
{
- return moduleInstance;
+ return entityModel.module();
}
public UnitOfWork unitOfWork()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
index bac3936..209294b 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
@@ -27,6 +27,7 @@ import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.entity.Queryable;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.property.StateHolder;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.EntityCompositeAlreadyExistsException;
import org.apache.zest.api.util.Annotations;
import org.apache.zest.runtime.composite.CompositeMethodsModel;
@@ -60,7 +61,8 @@ public final class EntityModel extends CompositeModel
private final boolean queryable;
- public EntityModel( List<Class<?>> types,
+ public EntityModel( ModuleDescriptor module,
+ List<Class<?>> types,
Visibility visibility,
MetaInfo info,
EntityMixinsModel mixinsModel,
@@ -68,7 +70,7 @@ public final class EntityModel extends CompositeModel
CompositeMethodsModel compositeMethodsModel
)
{
- super( types, visibility, info, mixinsModel, stateModel, compositeMethodsModel );
+ super( module, types, visibility, info, mixinsModel, stateModel, compositeMethodsModel );
this.queryable = types.stream()
.flatMap( Annotations.ANNOTATIONS_OF )
@@ -92,7 +94,7 @@ public final class EntityModel extends CompositeModel
public EntityInstance newInstance( ModuleUnitOfWork uow, ModuleSpi moduleInstance, EntityState state )
{
- return new EntityInstance( uow, moduleInstance, this, state );
+ return new EntityInstance( uow, this, state );
}
public Object[] newMixinHolder()
@@ -133,7 +135,7 @@ public final class EntityModel extends CompositeModel
}
}
- public void initState( ModuleSpi module, EntityState entityState )
+ public void initState( ModuleDescriptor module, EntityState entityState )
{
// Set new properties to default value
state().properties().forEach( propertyDescriptor -> {
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
index f9cefac..aeaf81b 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/InjectionContext.java
@@ -16,17 +16,16 @@ package org.apache.zest.runtime.injection;
import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.property.StateHolder;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.runtime.composite.ProxyReferenceInvocationHandler;
import org.apache.zest.runtime.composite.UsesInstance;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
/**
* JAVADOC
*/
public final class InjectionContext
{
- private final ModuleSpi moduleInstance;
+ private final ModuleDescriptor module;
private CompositeInstance compositeInstance;
private UsesInstance uses;
private StateHolder state;
@@ -38,37 +37,37 @@ public final class InjectionContext
public InjectionContext( CompositeInstance compositeInstance, UsesInstance uses, StateHolder state )
{
- this.moduleInstance = (ModuleInstance) compositeInstance.module();
+ this.module = compositeInstance.module();
this.compositeInstance = compositeInstance;
this.uses = uses;
this.state = state;
}
// For concerns and side-effects
- public InjectionContext( ModuleSpi moduleInstance, Object next, ProxyReferenceInvocationHandler proxyHandler )
+ public InjectionContext( ModuleDescriptor module, Object next, ProxyReferenceInvocationHandler proxyHandler )
{
- this.moduleInstance = moduleInstance;
+ this.module = module;
this.next = next;
this.proxyHandler = proxyHandler;
}
- public InjectionContext( ModuleSpi moduleInstance, UsesInstance uses )
+ public InjectionContext( ModuleDescriptor module, UsesInstance uses )
{
- this.moduleInstance = moduleInstance;
+ this.module = module;
this.uses = uses;
}
// For inner classes
- public InjectionContext( ModuleSpi moduleInstance, UsesInstance uses, Object instance )
+ public InjectionContext( ModuleDescriptor module, UsesInstance uses, Object instance )
{
- this.moduleInstance = moduleInstance;
+ this.module = module;
this.uses = uses;
this.instance = instance;
}
- public ModuleSpi module()
+ public ModuleDescriptor module()
{
- return moduleInstance;
+ return module;
}
public CompositeInstance compositeInstance()
@@ -111,7 +110,7 @@ public final class InjectionContext
{
return "InjectionContext{" +
"compositeInstance=" + compositeInstance +
- ", module=" + moduleInstance +
+ ", module=" + module +
", uses=" + uses +
", state=" + state +
", next=" + next +
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
index 9b65780..4a7d455 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ServiceInjectionProviderFactory.java
@@ -196,11 +196,11 @@ public final class ServiceInjectionProviderFactory
{
if( serviceQualifier == null )
{
- return context.module().findService( serviceType );
+ return context.module().instance().findService( serviceType );
}
else
{
- return Iterables.first( Iterables.filter( serviceQualifier, context.module()
+ return Iterables.first( Iterables.filter( serviceQualifier, context.module().instance()
.findServices( serviceType ) ) );
}
}
@@ -214,11 +214,11 @@ public final class ServiceInjectionProviderFactory
{
if( serviceQualifier == null )
{
- return context.module().findServices( serviceType );
+ return context.module().instance().findServices( serviceType );
}
else
{
- return Iterables.filter( serviceQualifier, context.module().findServices( serviceType ) );
+ return Iterables.filter( serviceQualifier, context.module().instance().findServices( serviceType ) );
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
index 1fbb3a3..260aa26 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/StructureInjectionProviderFactory.java
@@ -24,8 +24,11 @@ import org.apache.zest.api.object.ObjectFactory;
import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.service.ServiceFinder;
import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ApplicationDescriptor;
import org.apache.zest.api.structure.Layer;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.bootstrap.InvalidInjectionException;
@@ -34,8 +37,7 @@ import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.runtime.injection.InjectionProvider;
import org.apache.zest.runtime.injection.InjectionProviderFactory;
import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.runtime.structure.ApplicationInstance;
public final class StructureInjectionProviderFactory
implements InjectionProviderFactory
@@ -69,49 +71,56 @@ public final class StructureInjectionProviderFactory
Class clazz = (Class) type1;
if( clazz.equals( TransientBuilderFactory.class ) )
{
- return context.module();
+ return context.module().instance();
}
else if( clazz.equals( ObjectFactory.class ) )
{
- return context.module();
+ return context.module().instance();
}
else if( clazz.equals( ValueBuilderFactory.class ) )
{
- return context.module();
+ return context.module().instance();
}
else if( clazz.equals( UnitOfWorkFactory.class ) )
{
- return context.module().unitOfWorkFactory();
+ return context.module().instance().unitOfWorkFactory();
}
else if( clazz.equals( QueryBuilderFactory.class ) )
{
- return context.module();
+ return context.module().instance();
}
else if( clazz.equals( ServiceFinder.class ) )
{
- return context.module();
+ return context.module().instance();
}
else if( Module.class.isAssignableFrom( clazz ) )
{
- return context.module();
+ return context.module().instance();
}
- else if( ModuleSpi.class.isAssignableFrom( clazz ) )
+ else if( ModuleDescriptor.class.isAssignableFrom( clazz ) )
{
return context.module();
}
else if( Layer.class.isAssignableFrom( clazz ) )
{
- return (( ModuleInstance) context.module()).layerInstance();
+ return context.module().layer().instance();
+ }
+ else if( LayerDescriptor.class.isAssignableFrom( clazz ) )
+ {
+ return context.module().layer();
}
else if( Application.class.isAssignableFrom( clazz ) )
{
- return (( ModuleInstance) context.module()).layerInstance().applicationInstance();
+ return context.module().layer().instance().application();
+ }
+ else if( ApplicationDescriptor.class.isAssignableFrom( clazz ) )
+ {
+ return context.module().layer().instance().application().descriptor();
}
else if( ZestAPI.class.isAssignableFrom( clazz ) )
{
- return (( ModuleInstance) context.module()).layerInstance().applicationInstance().runtime();
+ return (( ApplicationInstance) context.module().layer().instance().application()).runtime();
}
-
return null;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
index 0e5ed5a..0826e17 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/UsesInjectionProviderFactory.java
@@ -71,7 +71,7 @@ public final class UsesInjectionProviderFactory
{
// No @Uses object provided
// Try instantiating a Transient or Object for the given type
- Module moduleInstance = context.module();
+ Module moduleInstance = context.module().instance();
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
index 8764fba..27eb9dc 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectModel.java
@@ -21,6 +21,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.mixin.Initializable;
import org.apache.zest.api.mixin.InitializationException;
import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.composite.ConstructorsModel;
@@ -34,6 +35,7 @@ import org.apache.zest.runtime.injection.InjectionContext;
public final class ObjectModel
implements ObjectDescriptor, VisitableHierarchy<Object, Object>
{
+ private final ModuleDescriptor module;
private final Class<?> objectType;
private final Visibility visibility;
private final MetaInfo metaInfo;
@@ -41,11 +43,13 @@ public final class ObjectModel
private final InjectedFieldsModel injectedFieldsModel;
private final InjectedMethodsModel injectedMethodsModel;
- public ObjectModel( Class<?> objectType,
+ public ObjectModel( ModuleDescriptor module,
+ Class<?> objectType,
Visibility visibility,
MetaInfo metaInfo
)
{
+ this.module = module;
this.objectType = objectType;
this.visibility = visibility;
this.metaInfo = metaInfo;
@@ -69,6 +73,12 @@ public final class ObjectModel
}
@Override
+ public ModuleDescriptor module()
+ {
+ return module;
+ }
+
+ @Override
public <T> T metaInfo( Class<T> infoType )
{
return metaInfo.get( infoType );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
index e610807..9895468 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/object/ObjectsModel.java
@@ -49,7 +49,7 @@ public class ObjectsModel
return visitor.visitLeave( this );
}
- public Stream<ObjectModel> stream()
+ public Stream<ObjectModel> models()
{
return objectModels.stream();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
index 571bdb1..3f2923c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
@@ -33,6 +33,7 @@ import org.apache.zest.api.property.InvalidPropertyTypeException;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.Serialization;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
@@ -163,7 +164,7 @@ public class PropertyModel
}
@Override
- public Object initialValue( Module module )
+ public Object initialValue( ModuleDescriptor module )
{
// Use supplied value from assembly
Object value = initialValue;
@@ -173,7 +174,7 @@ public class PropertyModel
{
if( valueType instanceof ValueCompositeType )
{
- return module.newValue( valueType().types().findFirst().orElse( null ) );
+ return module.instance().newValue( valueType().types().findFirst().orElse( null ) );
}
else
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
index 648f5ba..f3bf992 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
@@ -27,7 +27,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.service.ImportedServiceDescriptor;
import org.apache.zest.api.service.ServiceImporter;
import org.apache.zest.api.service.ServiceImporterException;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.activation.ActivatorsInstance;
@@ -89,6 +89,12 @@ public final class ImportedServiceModel
}
@Override
+ public ModuleDescriptor module()
+ {
+ return null;
+ }
+
+ @Override
public <T> T metaInfo( Class<T> infoType )
{
return metaInfo.get( infoType );
@@ -119,7 +125,7 @@ public final class ImportedServiceModel
}
@SuppressWarnings( { "raw", "unchecked" } )
- public ActivatorsInstance<?> newActivatorsInstance( Module module )
+ public ActivatorsInstance<?> newActivatorsInstance( ModuleDescriptor module )
throws Exception
{
return new ActivatorsInstance( activatorsModel.newInstances( module ) );
@@ -143,11 +149,11 @@ public final class ImportedServiceModel
}
@SuppressWarnings( { "raw", "unchecked" } )
- public <T> ImportedServiceInstance<T> importInstance( Module module )
+ public <T> ImportedServiceInstance<T> importInstance( ModuleDescriptor module )
{
try
{
- ServiceImporter importer = module.newObject( serviceImporter );
+ ServiceImporter importer = module.instance().newObject( serviceImporter );
T instance = (T) importer.importService( this );
return new ImportedServiceInstance<>( instance, importer );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
index a44c7f5..b77370a 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
@@ -27,7 +27,7 @@ import org.apache.zest.api.activation.PassivationException;
import org.apache.zest.api.service.ServiceImporterException;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.service.ServiceUnavailableException;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.runtime.activation.ActivationDelegate;
/**
@@ -37,6 +37,7 @@ import org.apache.zest.runtime.activation.ActivationDelegate;
* to handle service passivation and unavailability correctly, any proxying must be done in the
* service importer.
* </p>
+ *
* @param <T> Service Type
*/
public final class ImportedServiceReferenceInstance<T>
@@ -44,12 +45,12 @@ public final class ImportedServiceReferenceInstance<T>
{
private volatile ImportedServiceInstance<T> serviceInstance;
private T instance;
- private final Module module;
+ private final ModuleDescriptor module;
private final ImportedServiceModel serviceModel;
private final ActivationDelegate activation = new ActivationDelegate( this );
private boolean active = false;
- public ImportedServiceReferenceInstance( ImportedServiceModel serviceModel, Module module )
+ public ImportedServiceReferenceInstance( ImportedServiceModel serviceModel, ModuleDescriptor module )
{
this.module = module;
this.serviceModel = serviceModel;
@@ -68,7 +69,7 @@ public final class ImportedServiceReferenceInstance<T>
}
@Override
- public <T> T metaInfo( Class<T> infoType )
+ public <M> M metaInfo( Class<M> infoType )
{
return serviceModel.metaInfo( infoType );
}
@@ -102,14 +103,7 @@ public final class ImportedServiceReferenceInstance<T>
{
try
{
- activation.passivate( new Runnable()
- {
- @Override
- public void run()
- {
- active = false;
- }
- } );
+ activation.passivate( () -> active = false );
}
finally
{
@@ -139,7 +133,7 @@ public final class ImportedServiceReferenceInstance<T>
}
}
- public Module module()
+ public ModuleDescriptor module()
{
return module;
}
@@ -159,14 +153,12 @@ public final class ImportedServiceReferenceInstance<T>
try
{
- activation.activate( serviceModel.newActivatorsInstance( module ), serviceInstance, new Runnable()
- {
- @Override
- public void run()
- {
+ activation.activate(
+ serviceModel.newActivatorsInstance( module ),
+ serviceInstance, () -> {
active = true;
}
- } );
+ );
}
catch( Exception e )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
index 7faf290..4178dc7 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesInstance.java
@@ -55,7 +55,7 @@ public class ImportedServicesInstance
public Stream<ImportedServiceModel> models()
{
- return servicesModel.stream();
+ return servicesModel.models();
}
@Override
@@ -112,6 +112,6 @@ public class ImportedServicesInstance
public Stream<? extends ImportedServiceDescriptor> stream()
{
- return servicesModel.stream();
+ return servicesModel.models();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
index 9853830..ea15932 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServicesModel.java
@@ -17,11 +17,10 @@ package org.apache.zest.runtime.service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
-import org.apache.zest.api.service.ImportedServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleInstance;
/**
* JAVADOC
@@ -36,7 +35,7 @@ public class ImportedServicesModel
this.importedServiceModels = importedServiceModels;
}
- public ImportedServicesInstance newInstance( ModuleInstance module )
+ public ImportedServicesInstance newInstance( ModuleDescriptor module )
{
List<ServiceReference<?>> serviceReferences = new ArrayList<>();
for( ImportedServiceModel serviceModel : importedServiceModels )
@@ -65,7 +64,7 @@ public class ImportedServicesModel
return visitor.visitLeave( this );
}
- public Stream<ImportedServiceModel> stream()
+ public Stream<ImportedServiceModel> models()
{
return importedServiceModels.stream();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
index 6a401d2..451bdfa 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceInstance.java
@@ -25,7 +25,6 @@ import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.util.Classes;
import org.apache.zest.runtime.composite.TransientInstance;
import org.apache.zest.runtime.composite.TransientStateInstance;
-import org.apache.zest.runtime.structure.ModuleInstance;
/**
* JAVADOC
@@ -43,12 +42,11 @@ public class ServiceInstance
private final boolean hasEnabledConfiguration;
public ServiceInstance( ServiceModel compositeModel,
- ModuleInstance moduleInstance,
Object[] mixins,
TransientStateInstance state
)
{
- super( compositeModel, moduleInstance, mixins, state );
+ super( compositeModel, mixins, state );
implementsServiceAvailable =
Classes.assignableTypeSpecification( Availability.class ).test( descriptor() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
index 7a3d3d8..11c38b8 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
@@ -33,7 +33,7 @@ import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.Classes;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.runtime.activation.ActivatorsInstance;
@@ -48,7 +48,6 @@ import org.apache.zest.runtime.composite.UsesInstance;
import org.apache.zest.runtime.injection.DependencyModel;
import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.runtime.property.PropertyInstance;
-import org.apache.zest.runtime.structure.ModuleInstance;
import static org.apache.zest.runtime.legacy.Specifications.translate;
@@ -77,7 +76,8 @@ public final class ServiceModel extends CompositeModel
private final ActivatorsModel<?> activatorsModel;
private final Class configurationType;
- public ServiceModel( List<Class<?>> types,
+ public ServiceModel( ModuleDescriptor module,
+ List<Class<?>> types,
Visibility visibility,
MetaInfo metaInfo,
ActivatorsModel<?> activatorsModel,
@@ -88,7 +88,7 @@ public final class ServiceModel extends CompositeModel
boolean instantiateOnStartup
)
{
- super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
+ super( module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
this.identity = identity;
this.instantiateOnStartup = instantiateOnStartup;
@@ -111,7 +111,7 @@ public final class ServiceModel extends CompositeModel
}
@SuppressWarnings( { "raw", "unchecked" } )
- public ActivatorsInstance<?> newActivatorsInstance( Module module )
+ public ActivatorsInstance<?> newActivatorsInstance( ModuleDescriptor module )
throws Exception
{
return new ActivatorsInstance( activatorsModel.newInstances( module ) );
@@ -144,7 +144,7 @@ public final class ServiceModel extends CompositeModel
return visitor.visitLeave( this );
}
- public ServiceInstance newInstance( final ModuleInstance module )
+ public ServiceInstance newInstance( final ModuleDescriptor module )
{
Object[] mixins = mixinsModel.newMixinHolder();
@@ -161,7 +161,7 @@ public final class ServiceModel extends CompositeModel
} );
TransientStateInstance state = new TransientStateInstance( properties );
- ServiceInstance compositeInstance = new ServiceInstance( this, module, mixins, state );
+ ServiceInstance compositeInstance = new ServiceInstance( this, mixins, state );
// Instantiate all mixins
int i = 0;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
index e7eb325..97928c5 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
@@ -34,9 +34,8 @@ import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceImporterException;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.service.ServiceUnavailableException;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.runtime.activation.ActivationDelegate;
-import org.apache.zest.runtime.structure.ModuleInstance;
/**
* Implementation of ServiceReference.
@@ -54,12 +53,12 @@ public final class ServiceReferenceInstance<T>
{
private volatile ServiceInstance instance;
private final T serviceProxy;
- private final ModuleInstance module;
+ private final ModuleDescriptor module;
private final ServiceModel serviceModel;
private final ActivationDelegate activation = new ActivationDelegate( this );
private boolean active = false;
- public ServiceReferenceInstance( ServiceModel serviceModel, ModuleInstance module )
+ public ServiceReferenceInstance( ServiceModel serviceModel, ModuleDescriptor module )
{
this.module = module;
this.serviceModel = serviceModel;
@@ -103,7 +102,7 @@ public final class ServiceReferenceInstance<T>
return getInstance().isAvailable();
}
- public Module module()
+ public ModuleDescriptor module()
{
return module;
}
@@ -276,7 +275,7 @@ public final class ServiceReferenceInstance<T>
}
@Override
- public Module module()
+ public ModuleDescriptor module()
{
return module;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
index 31e6738..3b2bea9 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesInstance.java
@@ -51,9 +51,9 @@ public class ServicesInstance
}
}
- public Stream<ServiceModel> models()
+ public Stream<? extends ServiceDescriptor> models()
{
- return servicesModel.stream();
+ return servicesModel.models();
}
@Override
@@ -105,8 +105,13 @@ public class ServicesInstance
activation.deregisterActivationEventListener( listener );
}
- public Stream<? extends ServiceDescriptor> stream()
+ public Stream<? extends ServiceDescriptor> descriptors()
{
- return servicesModel.stream();
+ return servicesModel.models();
+ }
+
+ public Stream<ServiceReference<?>> references()
+ {
+ return serviceReferences.stream();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
index 4635d42..d8d6929 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServicesModel.java
@@ -17,10 +17,11 @@ package org.apache.zest.runtime.service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
+import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
-import org.apache.zest.runtime.structure.ModuleInstance;
/**
* JAVADOC
@@ -35,7 +36,7 @@ public class ServicesModel
this.serviceModels = serviceModels;
}
- public ServicesInstance newInstance( ModuleInstance module )
+ public ServicesInstance newInstance( ModuleDescriptor module )
{
List<ServiceReference<?>> serviceReferences = new ArrayList<>();
for( ServiceModel serviceModel : serviceModels )
@@ -64,7 +65,7 @@ public class ServicesModel
return visitor.visitLeave( this );
}
- public Stream<ServiceModel> stream()
+ public Stream<? extends ServiceDescriptor> models()
{
return serviceModels.stream();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
index 0ca0b52..de6be04 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationInstance.java
@@ -155,7 +155,7 @@ public class ApplicationInstance
}
// Other methods
- /* package */ void addLayer( LayerInstance layer )
+ void addLayer( LayerInstance layer )
{
layer.registerActivationEventListener( activation );
layerInstances.add( layer );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
index fdcedfe..10e9f03 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ApplicationModel.java
@@ -25,6 +25,7 @@ import org.apache.zest.api.common.InvalidApplicationException;
import org.apache.zest.api.common.MetaInfo;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.ApplicationDescriptor;
+import org.apache.zest.api.structure.LayerDescriptor;
import org.apache.zest.bootstrap.ZestRuntime;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.runtime.activation.ActivatorsInstance;
@@ -124,31 +125,33 @@ public final class ApplicationModel
ApplicationInstance applicationInstance = new ApplicationInstance( this, (ZestRuntime) runtime, instanceMetaInfo );
// Create layer instances
- Map<LayerModel, LayerInstance> layerInstanceMap = new HashMap<>();
- Map<LayerModel, List<LayerInstance>> usedLayers = new HashMap<>();
+ Map<LayerDescriptor, LayerDescriptor> layerInstanceMap = new HashMap<>();
+ Map<LayerDescriptor, List<LayerDescriptor>> usedLayers = new HashMap<>();
for( LayerModel layer : layers )
{
- List<LayerInstance> usedLayerInstances = new ArrayList<>();
+ List<LayerDescriptor> usedLayerInstances = new ArrayList<>();
usedLayers.put( layer, usedLayerInstances );
UsedLayersInstance usedLayersInstance = layer.usedLayers().newInstance( usedLayerInstances );
- LayerInstance layerInstance = layer.newInstance( applicationInstance, usedLayersInstance );
+ LayerInstance layerInstance = layer.newInstance( applicationInstance );
applicationInstance.addLayer( layerInstance );
- layerInstanceMap.put( layer, layerInstance );
+ layerInstanceMap.put( layer, layerInstance.descriptor() );
}
// Resolve used layer instances
for( LayerModel layer : layers )
{
- List<LayerInstance> usedLayerInstances = usedLayers.get( layer );
- for( LayerModel usedLayer : layer.usedLayers().layers() )
- {
- LayerInstance layerInstance = layerInstanceMap.get( usedLayer );
- if( layerInstance == null )
+ List<LayerDescriptor> usedLayerInstances = usedLayers.get( layer );
+ layer.usedLayers().layers().forEach(
+ usedLayer ->
{
- throw new InvalidApplicationException( "Could not find used layer:" + usedLayer.name() );
- }
- usedLayerInstances.add( layerInstance );
- }
+ LayerDescriptor layerDescriptor = layerInstanceMap.get( usedLayer );
+ if( layerDescriptor == null )
+ {
+ throw new InvalidApplicationException( "Could not find used layer:" + usedLayer
+ .name() );
+ }
+ usedLayerInstances.add( layerDescriptor );
+ } );
}
return applicationInstance;
@@ -162,12 +165,10 @@ public final class ApplicationModel
@Override
public String toString()
{
- final StringBuilder sb = new StringBuilder();
- sb.append( "ApplicationModel" );
- sb.append( "{name='" ).append( name ).append( '\'' );
- sb.append( ", version='" ).append( version ).append( '\'' );
- sb.append( ", mode=" ).append( mode );
- sb.append( '}' );
- return sb.toString();
+ return "ApplicationModel" +
+ "{name='" + name + '\'' +
+ ", version='" + version + '\'' +
+ ", mode=" + mode +
+ '}';
}
}
[16/34] zest-java git commit: ZEST-136 - Massive changes to the
Runtime, refactoring the Model and Instance relationship.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxConfigurationDeserializationTest.java b/extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxConfigurationDeserializationTest.java
index 9e1c4df..9e166d5 100644
--- a/extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxConfigurationDeserializationTest.java
+++ b/extensions/valueserialization-stax/src/test/java/org/apache/zest/valueserialization/stax/StaxConfigurationDeserializationTest.java
@@ -46,7 +46,7 @@ public class StaxConfigurationDeserializationTest
@Test
public void serializeTest()
{
- ValueBuilder<ConfigSerializationConfig> builder = module.newValueBuilder( ConfigSerializationConfig.class );
+ ValueBuilder<ConfigSerializationConfig> builder = valueBuilderFactory.newValueBuilder( ConfigSerializationConfig.class );
builder.prototype().name().set( "main" );
builder.prototype().host().set( createHost() );
builder.prototype().identity().set( "configtest" );
@@ -57,7 +57,7 @@ public class StaxConfigurationDeserializationTest
private Host createHost()
{
- ValueBuilder<Host> builder = module.newValueBuilder( Host.class );
+ ValueBuilder<Host> builder = valueBuilderFactory.newValueBuilder( Host.class );
builder.prototype().ip().set( "12.23.34.45" );
builder.prototype().port().set( 1234 );
return builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
index 2589ed0..61e9e49 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
@@ -283,14 +283,14 @@ public class AlarmHistoryImplTest
private AlarmPoint createAlarm( String name )
{
- ServiceReference<AlarmSystem> ref = module.findService( AlarmSystem.class );
+ ServiceReference<AlarmSystem> ref = serviceFinder.findService( AlarmSystem.class );
alarmSystem = ref.get();
return alarmSystem.createAlarm( name, createCategory( "AlarmHistoryTest" ) );
}
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
index fd79250..1b3c1fc 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
@@ -224,14 +224,14 @@ public class AlarmPointImplTest extends AbstractZestTest
private AlarmPoint createAlarm( String name )
{
- ServiceReference<AlarmSystem> ref = module.findService( AlarmSystem.class );
+ ServiceReference<AlarmSystem> ref = serviceFinder.findService( AlarmSystem.class );
alarmSystem = ref.get();
return alarmSystem.createAlarm( name, createCategory( "AlarmPointImplTest" ) );
}
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
index e1d6ea0..3c9663a 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
@@ -85,7 +85,7 @@ public class AlarmServiceTest
@Test
public void testGetAlarmModels()
{
- AlarmSystem alarmService = (AlarmSystem) module.findService( AlarmSystem.class ).get();
+ AlarmSystem alarmService = (AlarmSystem) serviceFinder.findService( AlarmSystem.class ).get();
List<AlarmModelDescriptor> models = alarmService.alarmModels();
assertNotNull( models );
assertEquals( 2, models.size() );
@@ -95,7 +95,7 @@ public class AlarmServiceTest
public void testDefaultModel()
throws Exception
{
- AlarmSystem alarmService = (AlarmSystem) module.findService( AlarmSystem.class ).get();
+ AlarmSystem alarmService = (AlarmSystem) serviceFinder.findService( AlarmSystem.class ).get();
List<AlarmModelDescriptor> models = alarmService.alarmModels();
assertNotNull( models );
assertEquals( 2, models.size() );
@@ -108,7 +108,7 @@ public class AlarmServiceTest
public void testListeners()
throws Exception
{
- AlarmSystem alarmService = (AlarmSystem) module.findService( AlarmSystem.class ).get();
+ AlarmSystem alarmService = (AlarmSystem) serviceFinder.findService( AlarmSystem.class ).get();
AlarmPoint alarm = alarmService.createAlarm( "TestAlarm", createCategory("AlarmServiceTest") );
CountingListener listener1 = new CountingListener();
@@ -175,7 +175,7 @@ public class AlarmServiceTest
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
index 0df9255..159c5af 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
@@ -86,7 +86,7 @@ public class ExtendedAlarmModelTest
public void testDescription()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
boolean test1 = provider.modelDescription().toLowerCase().contains( "normal" );
boolean test2 = provider.modelDescription().toLowerCase().contains( "activated" );
boolean test3 = provider.modelDescription().toLowerCase().contains( "deactivated" );
@@ -119,7 +119,7 @@ public class ExtendedAlarmModelTest
public void testTriggers()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
List<String> triggers = provider.alarmTriggers();
assertEquals( 7, triggers.size() );
@@ -163,7 +163,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromNormal()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
AlarmEvent event1 = provider.evaluate( alarm, AlarmPoint.TRIGGER_ACTIVATE );
assertEquals( AlarmPoint.EVENT_ACTIVATION, event1.systemName().get() );
@@ -197,7 +197,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromActivated()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
@@ -239,7 +239,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromAcknowledged()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.acknowledge();
@@ -288,7 +288,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromDeactivated()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.deactivate();
@@ -336,7 +336,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromBlocked()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.trigger( "block" );
@@ -384,7 +384,7 @@ public class ExtendedAlarmModelTest
public void testStateChangeFromDisabled()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.trigger( "disable" );
@@ -434,7 +434,7 @@ public class ExtendedAlarmModelTest
{
try
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
provider.evaluate( underTest, "my-trigger" );
fail( "IllegalArgumentException not thrown." );
@@ -844,7 +844,7 @@ public class ExtendedAlarmModelTest
public void testComputeCondition()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus s1 = createStatus( AlarmPoint.STATUS_NORMAL );
assertFalse( provider.computeCondition( s1 ) );
AlarmStatus s2 = createStatus( AlarmPoint.STATUS_ACTIVATED );
@@ -866,7 +866,7 @@ public class ExtendedAlarmModelTest
public void testComputeTriggerNormal()
throws Exception
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_NORMAL );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -877,7 +877,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTriggerActivated()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_ACTIVATED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -888,7 +888,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTRiggerDeactivated()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_DEACTIVATED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -899,7 +899,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTriggerAcknowledged()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_ACKNOWLEDGED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -910,7 +910,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTriggerReactivated()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_REACTIVATED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -921,7 +921,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTriggerBlocked()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_BLOCKED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -932,7 +932,7 @@ public class ExtendedAlarmModelTest
@Test
public void testComputeTriggerDisabled()
{
- AlarmModel provider = module.findService( AlarmModel.class ).get();
+ AlarmModel provider = serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus status = createStatus( AlarmPoint.STATUS_DISABLED );
String trigger1 = provider.computeTrigger( status, true );
String trigger2 = provider.computeTrigger( status, false );
@@ -954,7 +954,7 @@ public class ExtendedAlarmModelTest
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
@@ -967,7 +967,7 @@ public class ExtendedAlarmModelTest
private AlarmStatus createStatus( String status )
{
- ValueBuilder<AlarmStatus> builder = module.newValueBuilder( AlarmStatus.class );
+ ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
statePrototype.creationDate().set( new Date() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
index 78ff217..9120110 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
@@ -113,7 +113,7 @@ public class SimpleAlarmModelTest
public void testTriggers()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
List<String> triggers = provider.alarmTriggers();
assertEquals( 2, triggers.size() );
@@ -157,7 +157,7 @@ public class SimpleAlarmModelTest
public void testStateChangeFromNormal()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
AlarmEvent event1 = provider.evaluate( alarm, AlarmPoint.TRIGGER_ACTIVATE );
assertEquals( AlarmPoint.EVENT_ACTIVATION, event1.systemName().get() );
@@ -183,7 +183,7 @@ public class SimpleAlarmModelTest
public void testStateChangeFromActivated()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
@@ -202,7 +202,7 @@ public class SimpleAlarmModelTest
{
try
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
provider.evaluate( underTest, "my-trigger" );
fail( "IllegalArgumentException not thrown." );
@@ -301,7 +301,7 @@ public class SimpleAlarmModelTest
public void testComputeCondition()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus s1 = createStatus( AlarmPoint.STATUS_NORMAL );
assertFalse( provider.computeCondition( s1 ) );
AlarmStatus s2 = createStatus( AlarmPoint.STATUS_ACTIVATED );
@@ -312,7 +312,7 @@ public class SimpleAlarmModelTest
public void testComputeTrigger()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus s1 = createStatus( AlarmPoint.STATUS_NORMAL );
AlarmStatus s2 = createStatus( AlarmPoint.STATUS_ACTIVATED );
String trigger1 = provider.computeTrigger( s1, true );
@@ -339,7 +339,7 @@ public class SimpleAlarmModelTest
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
@@ -352,7 +352,7 @@ public class SimpleAlarmModelTest
private AlarmStatus createStatus( String status )
{
- ValueBuilder<AlarmStatus> builder = module.newValueBuilder( AlarmStatus.class );
+ ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
statePrototype.creationDate().set( new Date() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
index 84d10b6..9a6539e 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
@@ -120,7 +120,7 @@ public class StandardAlarmModelTest
public void testTriggers()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
List<String> triggers = provider.alarmTriggers();
assertEquals( 3, triggers.size() );
@@ -164,7 +164,7 @@ public class StandardAlarmModelTest
public void testStateChangeFromNormal()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
AlarmEvent event1 = provider.evaluate( alarm, AlarmPoint.TRIGGER_ACTIVATE );
assertEquals( AlarmPoint.EVENT_ACTIVATION, event1.systemName().get() );
@@ -182,7 +182,7 @@ public class StandardAlarmModelTest
public void testStateChangeFromActivated()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
@@ -204,7 +204,7 @@ public class StandardAlarmModelTest
public void testStateChangeFromAcknowledged()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.acknowledge();
@@ -229,7 +229,7 @@ public class StandardAlarmModelTest
public void testStateChangeFromDeactivated()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint alarm = createAlarm( "Another 1" );
alarm.activate();
alarm.deactivate();
@@ -255,7 +255,7 @@ public class StandardAlarmModelTest
{
try
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmPoint underTest = createAlarm( "Test AlarmPoint" );
provider.evaluate( underTest, "my-trigger" );
fail( "IllegalArgumentException not thrown." );
@@ -413,7 +413,7 @@ public class StandardAlarmModelTest
public void testComputeCondition()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus s1 = createStatus( AlarmPoint.STATUS_NORMAL );
assertFalse( provider.computeCondition( s1 ) );
AlarmStatus s2 = createStatus( AlarmPoint.STATUS_ACTIVATED );
@@ -428,7 +428,7 @@ public class StandardAlarmModelTest
public void testComputeTrigger()
throws Exception
{
- AlarmModel provider = (AlarmModel) module.findService( AlarmModel.class ).get();
+ AlarmModel provider = (AlarmModel) serviceFinder.findService( AlarmModel.class ).get();
AlarmStatus s1 = createStatus( AlarmPoint.STATUS_NORMAL );
AlarmStatus s2 = createStatus( AlarmPoint.STATUS_ACTIVATED );
AlarmStatus s3 = createStatus( AlarmPoint.STATUS_DEACTIVATED );
@@ -465,7 +465,7 @@ public class StandardAlarmModelTest
private AlarmCategory createCategory( String name )
{
- ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+ ValueBuilder<AlarmCategory> builder = valueBuilderFactory.newValueBuilder( AlarmCategory.class );
builder.prototype().name().set( name );
return builder.newInstance();
}
@@ -478,7 +478,7 @@ public class StandardAlarmModelTest
private AlarmStatus createStatus( String status )
{
- ValueBuilder<AlarmStatus> builder = module.newValueBuilder( AlarmStatus.class );
+ ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
statePrototype.creationDate().set( new Date() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/circuitbreaker/src/test/java/org/apache/zest/library/circuitbreaker/BreaksCircuitOnThrowableTest.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/test/java/org/apache/zest/library/circuitbreaker/BreaksCircuitOnThrowableTest.java b/libraries/circuitbreaker/src/test/java/org/apache/zest/library/circuitbreaker/BreaksCircuitOnThrowableTest.java
index e08678c..df19cbf 100644
--- a/libraries/circuitbreaker/src/test/java/org/apache/zest/library/circuitbreaker/BreaksCircuitOnThrowableTest.java
+++ b/libraries/circuitbreaker/src/test/java/org/apache/zest/library/circuitbreaker/BreaksCircuitOnThrowableTest.java
@@ -45,7 +45,7 @@ public class BreaksCircuitOnThrowableTest
@Test
public void testSuccess()
{
- TestService service = ( TestService ) module.findService( TestService.class ).get();
+ TestService service = ( TestService ) serviceFinder.findService( TestService.class ).get();
service.successfulMethod();
service.successfulMethod();
service.successfulMethod();
@@ -54,7 +54,7 @@ public class BreaksCircuitOnThrowableTest
@Test
public void testThrowable()
{
- ServiceReference<TestService> serviceReference = module.findService( TestService.class );
+ ServiceReference<TestService> serviceReference = serviceFinder.findService( TestService.class );
TestService service = serviceReference.get();
try {
service.throwingMethod();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/constraints/src/test/java/org/apache/zest/library/constraints/ConstraintTest.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/test/java/org/apache/zest/library/constraints/ConstraintTest.java b/libraries/constraints/src/test/java/org/apache/zest/library/constraints/ConstraintTest.java
index 2072b06..e7dea60 100644
--- a/libraries/constraints/src/test/java/org/apache/zest/library/constraints/ConstraintTest.java
+++ b/libraries/constraints/src/test/java/org/apache/zest/library/constraints/ConstraintTest.java
@@ -38,7 +38,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testContainsFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().containsString().set( "bar" );
}
@@ -46,7 +46,7 @@ public class ConstraintTest
@Test
public void testContainsOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().containsString().set( "foo" );
cb.prototype().containsString().set( "xxxfooyyy" );
@@ -55,7 +55,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testEmailFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().email().set( "foo.com" );
}
@@ -63,7 +63,7 @@ public class ConstraintTest
@Test
public void testEmailOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().email().set( "rickard@gmail.com" );
}
@@ -71,35 +71,35 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testURLFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().url().set( "this is no url" );
}
@Test
public void testURLOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().url().set( "http://zest.apache.org/path?query=string#fragment" );
}
@Test( expected = ConstraintViolationException.class )
public void testURIFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().uri().set( "" );
}
@Test
public void testURIOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().uri().set( "http://zest.apache.org/path?query=string#fragment" );
}
@Test( expected = ConstraintViolationException.class )
public void testGreaterThanFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().greaterThan().set( 10 );
}
@@ -107,7 +107,7 @@ public class ConstraintTest
@Test
public void testGreaterThanOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().greaterThan().set( 11 );
}
@@ -115,7 +115,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testInstanceOfFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().instanceOf().set( new HashSet() );
}
@@ -123,7 +123,7 @@ public class ConstraintTest
@Test
public void testInstanceOfOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().instanceOf().set( new ArrayList() );
}
@@ -131,7 +131,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testLessThanFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().lessThan().set( 10 );
}
@@ -139,7 +139,7 @@ public class ConstraintTest
@Test
public void testLessThanOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().lessThan().set( 9 );
}
@@ -147,7 +147,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testMatchesFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().matches().set( "cba" );
}
@@ -155,7 +155,7 @@ public class ConstraintTest
@Test
public void testMatchesOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().matches().set( "abbccc" );
}
@@ -163,7 +163,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testMaxLengthFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().maxLength().set( "xxxxx" );
}
@@ -171,7 +171,7 @@ public class ConstraintTest
@Test
public void testMaxLengthOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().maxLength().set( "xxx" );
}
@@ -179,7 +179,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testMinLengthFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().minLength().set( "xx" );
}
@@ -187,7 +187,7 @@ public class ConstraintTest
@Test
public void testMinLengthOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().minLength().set( "xxx" );
}
@@ -195,7 +195,7 @@ public class ConstraintTest
@Test
public void testNotEmptyFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
try
{
cb.prototype().notEmptyString().set( "" );
@@ -227,7 +227,7 @@ public class ConstraintTest
@Test
public void testNotEmptyOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().notEmptyString().set( "X" );
cb.prototype().notEmptyCollection().set( Arrays.asList( "X" ) );
cb.prototype().notEmptyList().set( Arrays.asList( "X" ) );
@@ -236,7 +236,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testOneOfFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().oneOf().set( "Foo" );
}
@@ -244,7 +244,7 @@ public class ConstraintTest
@Test
public void testOneOfOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().oneOf().set( "Bar" );
}
@@ -252,7 +252,7 @@ public class ConstraintTest
@Test( expected = ConstraintViolationException.class )
public void testRangeFail()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().range().set( 101 );
}
@@ -260,7 +260,7 @@ public class ConstraintTest
@Test
public void testRangeOk()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().range().set( 0 );
cb.prototype().range().set( 50 );
@@ -270,7 +270,7 @@ public class ConstraintTest
@Test
public void testMethodParameters()
{
- TransientBuilder<TestCaseComposite> cb = module.newTransientBuilder( TestCaseComposite.class );
+ TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class );
cb.prototype().testParameters( 15 );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/constraints/src/test/java/org/apache/zest/library/constraints/qi70/IssueTest.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/test/java/org/apache/zest/library/constraints/qi70/IssueTest.java b/libraries/constraints/src/test/java/org/apache/zest/library/constraints/qi70/IssueTest.java
index 4f98467..60331c4 100644
--- a/libraries/constraints/src/test/java/org/apache/zest/library/constraints/qi70/IssueTest.java
+++ b/libraries/constraints/src/test/java/org/apache/zest/library/constraints/qi70/IssueTest.java
@@ -38,7 +38,7 @@ public class IssueTest
@Test( expected = ConstraintViolationException.class )
public void testNotEmpty()
{
- TransientBuilder<Sample> cb = module.newTransientBuilder( Sample.class );
+ TransientBuilder<Sample> cb = transientBuilderFactory.newTransientBuilder( Sample.class );
cb.prototypeFor( Sample.class ).stuff().set( null );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
index 72dc033..530efe7 100644
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
+++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
@@ -152,7 +152,7 @@ public interface EntityToValue
private <T> ValueBuilder<?> doConversion( final Class<T> valueType, Object entity )
{
- ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
+ ValueDescriptor valueDescriptor = module.descriptor().valueDescriptor( valueType.getName() );
if( valueDescriptor == null )
{
throw new NoSuchValueException( valueType.getName(), module.name() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
index 02eeb15..9ba478e 100644
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
+++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
@@ -37,6 +37,7 @@ import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
@@ -44,8 +45,6 @@ import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.functional.Iterables;
import org.apache.zest.spi.ZestSPI;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
import static org.apache.zest.library.conversion.values.Shared.STRING_COLLECTION_TYPE_SPEC;
import static org.apache.zest.library.conversion.values.Shared.STRING_MAP_TYPE_SPEC;
@@ -129,7 +128,7 @@ public class ValueToEntityMixin
private UnitOfWorkFactory uowf;
@Structure
- private ModuleSpi module;
+ private ModuleDescriptor module;
@Override
public <T> T create( Class<T> entityType, Object value )
@@ -187,11 +186,7 @@ public class ValueToEntityMixin
EntityDescriptor eDesc = module.entityDescriptor( entityType.getName() );
if( eDesc == null )
{
- throw new EntityTypeNotFoundException( entityType.getName(),
- module.name(),
- module.findVisibleEntityTypes()
- .map( ModelModule.toStringFunction )
- );
+ throw EntityTypeNotFoundException.create( entityType.getName(), module );
}
ValueComposite vComposite = (ValueComposite) value;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
index b268a62..8fae092 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
@@ -68,7 +68,7 @@ public class EntityToValueTest
PersonEntity entity = setupPersonEntities( uow );
// START SNIPPET: conversion
- EntityToValueService conversion = module.findService( EntityToValueService.class ).get();
+ EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
PersonValue value = conversion.convert( PersonValue.class, entity );
// END SNIPPET: conversion
assertEquals( "Niclas", value.firstName().get() );
@@ -92,7 +92,7 @@ public class EntityToValueTest
{
PersonEntity niclas = setupPersonEntities( uow );
- ServiceReference<EntityToValueService> reference = module.findService( EntityToValueService.class );
+ ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
EntityToValueService service = reference.get();
PersonValue2 niclasValue = service.convert( PersonValue2.class, niclas );
@@ -117,7 +117,7 @@ public class EntityToValueTest
{
PersonEntity niclas = setupPersonEntities( uow );
- ServiceReference<EntityToValueService> reference = module.findService( EntityToValueService.class );
+ ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
EntityToValueService service = reference.get();
PersonValue3 niclasValue = service.convert( PersonValue3.class, niclas );
@@ -142,7 +142,7 @@ public class EntityToValueTest
{
PersonEntity niclas = setupPersonEntities( uow );
- ServiceReference<EntityToValueService> reference = module.findService( EntityToValueService.class );
+ ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
EntityToValueService service = reference.get();
PersonValue4 niclasValue = service.convert( PersonValue4.class, niclas );
@@ -164,7 +164,7 @@ public class EntityToValueTest
PersonEntity entity = setupPersonEntities( uow );
// START SNIPPET: prototypeOpportunity
- EntityToValueService conversion = module.findService( EntityToValueService.class ).get();
+ EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
PersonValue value = conversion.convert( PersonValue.class, entity, new Function<PersonValue, PersonValue>()
{
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
index 4e8a087..388450d 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
@@ -56,7 +56,7 @@ public class NestedValuesConversionTest
try
{
FooEntity fooEntity = createFooEntity( uow, "Test nested values conversion" );
- EntityToValueService conversion = module.findService( EntityToValueService.class ).get();
+ EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
FooValue fooValue = conversion.convert( FooValue.class, fooEntity );
assertThat( fooValue.name().get(), equalTo( "Test nested values conversion" ) );
assertThat( fooValue.bar().get().bazar().get(), equalTo( "single" ) );
@@ -91,7 +91,7 @@ public class NestedValuesConversionTest
private BarValue createBarValue( String bazar )
{
- ValueBuilder<BarValue> builder = module.newValueBuilder( BarValue.class );
+ ValueBuilder<BarValue> builder = valueBuilderFactory.newValueBuilder( BarValue.class );
builder.prototype().bazar().set( bazar );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
index 0441b84..f4a3ba0 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
@@ -89,7 +89,7 @@ public class ValueToEntityTest
public void givenQualifiedValueWhenCreatingEntityExpectCorrectEntity()
throws UnitOfWorkCompletionException
{
- ValueBuilder<PersonValue> builder = module.newValueBuilder( PersonValue.class );
+ ValueBuilder<PersonValue> builder = valueBuilderFactory.newValueBuilder( PersonValue.class );
builder.prototype().firstName().set( "Ed" );
builder.prototype().lastName().set( "Flintstone" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -99,7 +99,7 @@ public class ValueToEntityTest
try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
{
// START SNIPPET: creation
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
PersonEntity edEntity = conversion.create( PersonEntity.class, edValue );
// END SNIPPET: creation
assertThat( edEntity.firstName(), equalTo( "Ed" ) );
@@ -122,7 +122,7 @@ public class ValueToEntityTest
public void givenUnqualifiedValueWhenCreatingEntityExpectCorrectEntity()
throws UnitOfWorkCompletionException
{
- ValueBuilder<PersonValue2> builder = module.newValueBuilder( PersonValue2.class );
+ ValueBuilder<PersonValue2> builder = valueBuilderFactory.newValueBuilder( PersonValue2.class );
builder.prototype().firstName().set( "Ed" );
builder.prototype().lastName().set( "Flintstone" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -131,7 +131,7 @@ public class ValueToEntityTest
PersonValue2 edValue = builder.newInstance();
try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
@@ -156,7 +156,7 @@ public class ValueToEntityTest
public void givenUnqualifiedValue2WhenCreatingEntityExpectCorrectEntity()
throws UnitOfWorkCompletionException
{
- ValueBuilder<PersonValue3> builder = module.newValueBuilder( PersonValue3.class );
+ ValueBuilder<PersonValue3> builder = valueBuilderFactory.newValueBuilder( PersonValue3.class );
builder.prototype().firstName().set( "Ed" );
builder.prototype().lastName().set( "Flintstone" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -165,7 +165,7 @@ public class ValueToEntityTest
PersonValue3 edValue = builder.newInstance();
try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
@@ -190,7 +190,7 @@ public class ValueToEntityTest
public void givenQualifiedValueNotFromSameInterfaceWhenCreatingEntityExpectNonOptionalException()
throws UnitOfWorkCompletionException
{
- ValueBuilder<PersonValue4> builder = module.newValueBuilder( PersonValue4.class );
+ ValueBuilder<PersonValue4> builder = valueBuilderFactory.newValueBuilder( PersonValue4.class );
builder.prototype().firstName().set( "Ed" );
builder.prototype().lastName().set( "Flintstone" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -199,7 +199,7 @@ public class ValueToEntityTest
PersonValue4 edValue = builder.newInstance();
try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
{
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
@@ -223,7 +223,7 @@ public class ValueToEntityTest
assertThat( ricky.children().count(), is( 1 ) );
uow.complete();
}
- ValueBuilder<PersonValue> builder = module.newValueBuilder( PersonValue.class );
+ ValueBuilder<PersonValue> builder = valueBuilderFactory.newValueBuilder( PersonValue.class );
builder.prototype().firstName().set( "Ricky" );
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -232,7 +232,7 @@ public class ValueToEntityTest
{
PersonEntity rickyEntity = uow.get( PersonEntity.class, rickyIdentity );
// START SNIPPET: update
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
conversion.update( rickyEntity, rickyNewStateValue );
// END SNIPPET: update
@@ -259,7 +259,7 @@ public class ValueToEntityTest
assertThat( ricky.children().count(), is( 1 ) );
uow.complete();
}
- ValueBuilder<PersonValue2> builder = module.newValueBuilder( PersonValue2.class );
+ ValueBuilder<PersonValue2> builder = valueBuilderFactory.newValueBuilder( PersonValue2.class );
builder.prototype().firstName().set( "Ricky" );
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -268,7 +268,7 @@ public class ValueToEntityTest
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
conversion.update( ricky, newStateValue );
assertThat( ricky.lastName(), equalTo( "Slaghoople" ) );
@@ -294,7 +294,7 @@ public class ValueToEntityTest
assertThat( ricky.children().count(), is( 1 ) );
uow.complete();
}
- ValueBuilder<PersonValue3> builder = module.newValueBuilder( PersonValue3.class );
+ ValueBuilder<PersonValue3> builder = valueBuilderFactory.newValueBuilder( PersonValue3.class );
builder.prototype().firstName().set( "Ricky" );
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -303,7 +303,7 @@ public class ValueToEntityTest
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
conversion.update( ricky, newStateValue );
assertThat( ricky.lastName(), equalTo( "Slaghoople" ) );
@@ -329,7 +329,7 @@ public class ValueToEntityTest
assertThat( ricky.children().count(), is( 1 ) );
uow.complete();
}
- ValueBuilder<PersonValue4> builder = module.newValueBuilder( PersonValue4.class );
+ ValueBuilder<PersonValue4> builder = valueBuilderFactory.newValueBuilder( PersonValue4.class );
builder.prototype().firstName().set( "Ricky" );
builder.prototype().lastName().set( "Slaghoople" );
builder.prototype().dateOfBirth().set( someBirthDate );
@@ -338,7 +338,7 @@ public class ValueToEntityTest
{
PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
- ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
+ ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
conversion.update( ricky, newStateValue );
assertThat( ricky.lastName(), equalTo( "Slaghople" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing-jdbm/src/main/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-jdbm/src/main/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreService.java b/libraries/eventsourcing-jdbm/src/main/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreService.java
index 0a13db2..270adec 100644
--- a/libraries/eventsourcing-jdbm/src/main/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreService.java
+++ b/libraries/eventsourcing-jdbm/src/main/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreService.java
@@ -125,7 +125,7 @@ public interface JdbmEventStoreService
@Override
public UnitOfWorkDomainEventsValue apply( String item )
{
- return valueSerialization.<UnitOfWorkDomainEventsValue>deserialize( eventsType, item );
+ return valueSerialization.<UnitOfWorkDomainEventsValue>deserialize( module, eventsType, item );
}
}, storeEvents0() ) );
@@ -251,7 +251,7 @@ public interface JdbmEventStoreService
{
byte[] eventData = (byte[]) tuple.getValue();
String eventJson = new String( eventData, "UTF-8" );
- return valueSerialization.<UnitOfWorkDomainEventsValue>deserialize( eventsType, eventJson );
+ return valueSerialization.<UnitOfWorkDomainEventsValue>deserialize( module, eventsType, eventJson );
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
index f0a2e11..c2e55c1 100644
--- a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
+++ b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
@@ -87,7 +87,7 @@ public class JdbmEventStoreServiceTest
uow.complete();
}
- EventSource source = (EventSource) module.findService( EventSource.class ).get();
+ EventSource source = serviceFinder.findService( EventSource.class ).get();
source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( new Function<UnitOfWorkDomainEventsValue, String>()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
index df58e76..6e0de34 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
@@ -29,6 +29,7 @@ import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
@@ -59,7 +60,7 @@ public abstract class AbstractApplicationEventStoreMixin
protected Lock lock = new ReentrantLock();
@Structure
- protected Module module;
+ protected ModuleDescriptor module;
@Structure
private ValueBuilderFactory vbf;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
index 8f63723..569f1d6 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
@@ -75,7 +75,7 @@ public interface DomainEventPlayerService
{
currentEventValue = domainEventValue;
// Get the entity
- Class entityType = module.classLoader().loadClass( domainEventValue.entityType().get() );
+ Class entityType = module.descriptor().classLoader().loadClass( domainEventValue.entityType().get() );
String id = domainEventValue.entityId().get();
Object entity = null;
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
index 52b0e19..58e4dbd 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
@@ -29,6 +29,7 @@ import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.io.Output;
import org.apache.zest.io.Receiver;
@@ -56,7 +57,7 @@ public abstract class AbstractEventStoreMixin
protected Lock lock = new ReentrantLock();
@Structure
- protected Module module;
+ protected ModuleDescriptor module;
private ExecutorService transactionNotifier;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
index 911eeb7..dec362b 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
@@ -92,7 +92,7 @@ public class ApplicationEventTest
@Test
public void testApplicationEvent() throws Exception
{
- Users users = module.newTransient( Users.class );
+ Users users = transientBuilderFactory.newTransient( Users.class );
Principal administratorPrincipal = new Principal()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
index c8fe3a6..bab1a8d 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
@@ -86,7 +86,7 @@ public class DomainEventTest
uow.complete();
// Print events
- EventSource source = (EventSource) module.findService( EventSource.class ).get();
+ EventSource source = serviceFinder.findService( EventSource.class ).get();
source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( new Function<UnitOfWorkDomainEventsValue, String>()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/http/src/test/java/org/apache/zest/library/http/JettyServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/java/org/apache/zest/library/http/JettyServiceTest.java b/libraries/http/src/test/java/org/apache/zest/library/http/JettyServiceTest.java
index 1944179..3a3b36f 100644
--- a/libraries/http/src/test/java/org/apache/zest/library/http/JettyServiceTest.java
+++ b/libraries/http/src/test/java/org/apache/zest/library/http/JettyServiceTest.java
@@ -68,7 +68,7 @@ public final class JettyServiceTest
public final void testInstantiation()
throws Throwable
{
- Iterable<ServiceReference<JettyService>> services = module.findServices( JettyService.class );
+ Iterable<ServiceReference<JettyService>> services = serviceFinder.findServices( JettyService.class );
assertNotNull( services );
Iterator<ServiceReference<JettyService>> iterator = services.iterator();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
index df007fe..e100c5d 100644
--- a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
+++ b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
@@ -17,6 +17,7 @@ package org.apache.zest.library.jmx;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
+import java.util.stream.Collectors;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -242,11 +243,10 @@ public interface ApplicationManagerService
this.layer = layer;
this.layerDescriptor = layerDescriptor;
- uses = "Uses: ";
- for( LayerDescriptor usedLayer : layerDescriptor.usedLayers().layers() )
- {
- uses += usedLayer.name() + " ";
- }
+ uses = layerDescriptor.usedLayers()
+ .layers()
+ .map( LayerDescriptor::name )
+ .collect( Collectors.joining(" ", "Uses: ", "") );
}
public String getUses()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ConfigurationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ConfigurationManagerService.java b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ConfigurationManagerService.java
index e558a16..bd277d6 100644
--- a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ConfigurationManagerService.java
+++ b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ConfigurationManagerService.java
@@ -61,6 +61,7 @@ import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.EnumType;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -150,7 +151,7 @@ public interface ConfigurationManagerService
String serviceClass = compositeInstance.types().findFirst().get().getName();
String name = configurableService.identity();
ServiceDescriptor serviceDescriptor = spi.serviceDescriptorFor( configurableService );
- Module module = spi.moduleOf( configurableService );
+ ModuleDescriptor module = spi.moduleOf( configurableService );
Class<Object> configurationClass = serviceDescriptor.configurationType();
if( configurationClass != null )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/JavaScriptMixinTest.java
----------------------------------------------------------------------
diff --git a/libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/JavaScriptMixinTest.java b/libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/JavaScriptMixinTest.java
index acf218d..defc9f6 100644
--- a/libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/JavaScriptMixinTest.java
+++ b/libraries/lang-javascript/src/test/java/org/apache/zest/library/javascript/JavaScriptMixinTest.java
@@ -29,7 +29,7 @@ public class JavaScriptMixinTest
@Test
public void testInvoke() throws Throwable
{
- DomainType domain = module.newTransient( DomainType.class );
+ DomainType domain = transientBuilderFactory.newTransient( DomainType.class );
Assert.assertEquals( "do1 script \" and ' for many cases is harder.", domain.do1() );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/locking/src/test/java/org/apache/zest/library/locking/LockingTest.java
----------------------------------------------------------------------
diff --git a/libraries/locking/src/test/java/org/apache/zest/library/locking/LockingTest.java b/libraries/locking/src/test/java/org/apache/zest/library/locking/LockingTest.java
index 574007f..487a89f 100644
--- a/libraries/locking/src/test/java/org/apache/zest/library/locking/LockingTest.java
+++ b/libraries/locking/src/test/java/org/apache/zest/library/locking/LockingTest.java
@@ -42,7 +42,7 @@ public class LockingTest
public void testLocking()
throws InterruptedException
{
- final TestComposite composite = module.newTransient( TestComposite.class );
+ final TestComposite composite = transientBuilderFactory.newTransient( TestComposite.class );
ExecutorService executor = Executors.newFixedThreadPool( 2 );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
index b86ab71..745f9b3 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
@@ -70,10 +70,10 @@ public class DebuggingTest
// QueryBuilder<DebugRecord> builder = module.newQueryBuilder( DebugRecord.class );
// Query<DebugRecord> query = builder.newQuery( uow );
// assertEquals( 0, query.count() );
- Some service = (Some) module.findService( Some.class ).get();
+ Some service = (Some) serviceFinder.findService( Some.class ).get();
String message = service.doSomething( "World!", 10 );
assertEquals( message, "Hello!" );
- EntityStore es = (EntityStore) module.findService( EntityStore.class ).get();
+ EntityStore es = (EntityStore) serviceFinder.findService( EntityStore.class ).get();
final String[] result = new String[1];
es.entityStates( module ).transferTo( Transforms.map( new Function<EntityState, EntityState>()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
index 06dd6b9..5caf950 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
@@ -67,11 +67,11 @@ public class TracingTest
public void whenTraceOnMixinTypeMethodExpectOneEntryInEntityStore()
throws Exception
{
- SomeService sc = module.findService( SomeService.class ).get();
+ SomeService sc = serviceFinder.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
UnitOfWork uow = uowf.newUnitOfWork();
- QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
+ QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
@@ -88,11 +88,11 @@ public class TracingTest
public void whenTraceAllOnCompositeTypeExpectTwoEntryInEntityStore()
throws Exception
{
- SomeService2 sc = module.findService( SomeService2.class ).get();
+ SomeService2 sc = serviceFinder.findService( SomeService2.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 456, sc.doSomethingLessImportant() );
UnitOfWork uow = uowf.newUnitOfWork();
- QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
+ QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
@@ -112,13 +112,13 @@ public class TracingTest
public void whenTraceOnMixinImplExpectTwoEntryInEntityStore()
throws Exception
{
- SomeService sc = module.findService( SomeService.class ).get();
+ SomeService sc = serviceFinder.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 789, sc.doSomethingModeratelyImportant() );
UnitOfWork uow = uowf.newUnitOfWork();
try
{
- QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
+ QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
TraceRecord template = templateFor( TraceRecord.class );
@@ -151,11 +151,11 @@ public class TracingTest
{
// It is not possible to put Annotation on Concern Methods, so it should only record one.
- SomeService sc = module.findService( SomeService.class ).get();
+ SomeService sc = serviceFinder.findService( SomeService.class ).get();
assertEquals( 123, sc.doSomethingImportant() );
assertEquals( 753, sc.doSomethingInsanelyImportant() );
UnitOfWork uow = uowf.newUnitOfWork();
- QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
+ QueryBuilder<TraceRecord> builder = queryBuilderFactory.newQueryBuilder( TraceRecord.class );
Query<TraceRecord> query = uow.newQuery( builder );
// IS sorting needed??
// TraceRecord template = templateFor( TraceRecord.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/metrics/src/test/java/org/apache/zest/library/metrics/MetricsTest.java
----------------------------------------------------------------------
diff --git a/libraries/metrics/src/test/java/org/apache/zest/library/metrics/MetricsTest.java b/libraries/metrics/src/test/java/org/apache/zest/library/metrics/MetricsTest.java
index adf1f55..9a066c1 100644
--- a/libraries/metrics/src/test/java/org/apache/zest/library/metrics/MetricsTest.java
+++ b/libraries/metrics/src/test/java/org/apache/zest/library/metrics/MetricsTest.java
@@ -76,7 +76,7 @@ public class MetricsTest extends AbstractZestTest
@Test
public void givenNonInstrumentedCompositeWhenCallingUpdateNameExpectNoReport()
{
- Country underTest = module.newTransient( Country1.class );
+ Country underTest = transientBuilderFactory.newTransient( Country1.class );
String result = runTest( underTest );
result = result.replace( "\r", "" );
assertTrue( lastLine( result, 1 ).contains( "=====================" ) );
@@ -86,7 +86,7 @@ public class MetricsTest extends AbstractZestTest
@Test
public void givenInstrumentedWithAllCompositeWhenCallingUpdateNameExpectReport()
{
- Country underTest = module.newTransient( Country2.class );
+ Country underTest = transientBuilderFactory.newTransient( Country2.class );
String result = runTest( underTest );
result = result.replace( "\r", "" );
assertThat( lastLine( result, 34 ), equalTo( "org.apache.zest.library.metrics.Country.SomeApplication:" ) );
@@ -103,7 +103,7 @@ public class MetricsTest extends AbstractZestTest
@Test
public void givenOneMethodAnnotatedWhenCallingUpdateNameExpectReportForThatMethodOnly()
{
- Country underTest = module.newTransient( Country3.class );
+ Country underTest = transientBuilderFactory.newTransient( Country3.class );
String result = runTest( underTest );
result = result.replace( "\r", "" );
assertThat( lastLine( result, 17 ), equalTo( "org.apache.zest.library.metrics.Country.SomeApplication:" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/osgi/src/test/java/org/apache/zest/library/osgi/OSGiServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/osgi/src/test/java/org/apache/zest/library/osgi/OSGiServiceTest.java b/libraries/osgi/src/test/java/org/apache/zest/library/osgi/OSGiServiceTest.java
index c3a31be..b610d9f 100644
--- a/libraries/osgi/src/test/java/org/apache/zest/library/osgi/OSGiServiceTest.java
+++ b/libraries/osgi/src/test/java/org/apache/zest/library/osgi/OSGiServiceTest.java
@@ -51,7 +51,7 @@ public class OSGiServiceTest
@Test
public void givenFelixFrameworkWhenStartingZestApplicationExpectServiceToBeRegisteredToOsgiBundleContext()
{
- MyService service = module.findService( MyService.class ).get();
+ MyService service = serviceFinder.findService( MyService.class ).get();
service.value().set( 15 );
assertEquals( (Integer) 15, service.value().get() );
String[] expectedClasses = new String[]
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rdf/src/test/java/org/apache/zest/library/rdf/ApplicationXmlTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/ApplicationXmlTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/ApplicationXmlTest.java
index 5d49305..5a5a847 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/ApplicationXmlTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/ApplicationXmlTest.java
@@ -59,7 +59,7 @@ public class ApplicationXmlTest extends AbstractZestTest
public void testApplicationXml()
throws Exception
{
- FileConfiguration fileConfig = (FileConfiguration) module.findService( FileConfiguration.class ).get();
+ FileConfiguration fileConfig = serviceFinder.findService( FileConfiguration.class ).get();
ApplicationSerializer parser = new ApplicationSerializer();
Iterable<Statement> graph = parser.serialize( application ); // TODO Fix this
writeN3( graph );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
index 89054bb..8aa0594 100755
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
@@ -68,10 +68,7 @@ public class EntitySerializerTest
throws Exception
{
super.setUp();
-
createDummyData();
-
- module.injectTo( this );
}
@Test
@@ -81,7 +78,7 @@ public class EntitySerializerTest
EntityReference entityReference = new EntityReference( "test2" );
Usecase usecase = UsecaseBuilder.newUsecase( "Test" );
long currentTime = System.currentTimeMillis();
- EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, currentTime );
+ EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( module, usecase, currentTime );
EntityState entityState = unitOfWork.entityStateOf( module, entityReference );
Iterable<Statement> graph = serializer.serialize( entityState );
@@ -98,9 +95,9 @@ public class EntitySerializerTest
UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
- ValueBuilder<TestValue> valueBuilder = module.newValueBuilder( TestValue.class );
+ ValueBuilder<TestValue> valueBuilder = valueBuilderFactory.newValueBuilder( TestValue.class );
valueBuilder.prototype().test1().set( 4L );
- ValueBuilder<Test2Value> valueBuilder2 = module.newValueBuilder( Test2Value.class );
+ ValueBuilder<Test2Value> valueBuilder2 = valueBuilderFactory.newValueBuilder( Test2Value.class );
valueBuilder2.prototype().data().set( "Habba" );
valueBuilder.prototype().test3().set( valueBuilder2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
@@ -121,7 +118,7 @@ public class EntitySerializerTest
niclasTemplate.group().add( 0, testEntity );
niclasTemplate.group().add( 0, testEntity );
niclasTemplate.group().add( 0, testEntity );
- valueBuilder = module.newValueBuilderWithPrototype( testValue );
+ valueBuilder = valueBuilderFactory.newValueBuilderWithPrototype( testValue );
valueBuilder.prototype().test1().set( 5L );
testValue = valueBuilder.newInstance();
niclasTemplate.value().set( testValue );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
index dbdb77a..5504bd4 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
@@ -59,10 +59,7 @@ public class EntityTypeSerializerTest
public void setUp() throws Exception
{
super.setUp();
-
createDummyData();
-
- module.injectTo( this );
}
@Test
@@ -84,10 +81,10 @@ public class EntityTypeSerializerTest
UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
- ValueBuilder<Test2Value> vb2 = module.newValueBuilder( Test2Value.class );
+ ValueBuilder<Test2Value> vb2 = valueBuilderFactory.newValueBuilder( Test2Value.class );
vb2.prototype().data().set( "Zout" );
- ValueBuilder<TestValue> valueBuilder = module.newValueBuilder( TestValue.class );
+ ValueBuilder<TestValue> valueBuilder = valueBuilderFactory.newValueBuilder( TestValue.class );
valueBuilder.prototype().test1().set( 4L );
valueBuilder.prototype().test3().set( vb2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
@@ -108,7 +105,7 @@ public class EntityTypeSerializerTest
niclasTemplate.group().add( 0, testEntity );
niclasTemplate.group().add( 0, testEntity );
niclasTemplate.group().add( 0, testEntity );
- valueBuilder = module.newValueBuilderWithPrototype( testValue );
+ valueBuilder = valueBuilderFactory.newValueBuilderWithPrototype( testValue );
valueBuilder.prototype().test1().set( 5L );
testValue = valueBuilder.newInstance();
niclasTemplate.value().set( testValue );
[11/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
new file mode 100755
index 0000000..118510f
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
@@ -0,0 +1,777 @@
+/*
+ * 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.runtime.unitofwork;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.zest.api.association.AssociationDescriptor;
+import org.apache.zest.api.association.AssociationStateHolder;
+import org.apache.zest.api.common.QualifiedName;
+import org.apache.zest.api.composite.Composite;
+import org.apache.zest.api.entity.EntityBuilder;
+import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.entity.IdentityGenerator;
+import org.apache.zest.api.entity.LifecycleException;
+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.property.Property;
+import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.property.StateHolder;
+import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryExecutionException;
+import org.apache.zest.api.query.grammar.OrderBy;
+import org.apache.zest.api.service.NoSuchServiceException;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
+import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
+import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
+import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.usecase.Usecase;
+import org.apache.zest.api.util.NullArgumentException;
+import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueComposite;
+import org.apache.zest.functional.Iterables;
+import org.apache.zest.runtime.association.AssociationInstance;
+import org.apache.zest.runtime.association.ManyAssociationInstance;
+import org.apache.zest.runtime.association.NamedAssociationInstance;
+import org.apache.zest.runtime.composite.FunctionStateResolver;
+import org.apache.zest.runtime.entity.EntityInstance;
+import org.apache.zest.runtime.entity.EntityModel;
+import org.apache.zest.runtime.property.PropertyModel;
+import org.apache.zest.runtime.value.ValueInstance;
+import org.apache.zest.spi.entity.EntityState;
+import org.apache.zest.spi.entity.EntityStatus;
+import org.apache.zest.spi.entity.NamedAssociationState;
+import org.apache.zest.spi.entitystore.EntityStore;
+import org.apache.zest.spi.structure.ModelModule;
+import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.spi.query.EntityFinder;
+import org.apache.zest.spi.query.EntityFinderException;
+import org.apache.zest.spi.query.QueryBuilderSPI;
+import org.apache.zest.spi.query.QuerySource;
+
+import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
+
+/**
+ * JAVADOC
+ */
+public class ModuleUnitOfWork
+ implements UnitOfWork
+{
+ private static final QualifiedName IDENTITY_STATE_NAME;
+
+ static
+ {
+ try
+ {
+ IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
+ }
+ catch( NoSuchMethodException e )
+ {
+ throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
+ }
+ }
+
+ @Uses
+ private UnitOfWorkInstance uow;
+
+ @Structure
+ private ModuleSpi module;
+
+ @Service
+ private UnitOfWorkFactory unitOfWorkFactory;
+
+ public Module module()
+ {
+ return module;
+ }
+
+ public UnitOfWorkInstance instance()
+ {
+ return uow;
+ }
+
+ @Override
+ public UnitOfWorkFactory unitOfWorkFactory()
+ {
+ return unitOfWorkFactory;
+ }
+
+ @Override
+ public long currentTime()
+ {
+ return uow.currentTime();
+ }
+
+ @Override
+ public Usecase usecase()
+ {
+ return uow.usecase();
+ }
+
+ @Override
+ public <T> T metaInfo( Class<T> infoType )
+ {
+ return uow.metaInfo().get( infoType );
+ }
+
+ @Override
+ public void setMetaInfo( Object metaInfo )
+ {
+ uow.metaInfo().set( metaInfo );
+ }
+
+ @Override
+ @SuppressWarnings( { "raw", "unchecked" } )
+ public <T> Query<T> newQuery( QueryBuilder<T> queryBuilder )
+ {
+ QueryBuilderSPI queryBuilderSPI = (QueryBuilderSPI) queryBuilder;
+
+ return queryBuilderSPI.newQuery( new UoWQuerySource( this ) );
+ }
+
+ @Override
+ public <T> T newEntity( Class<T> type )
+ throws EntityTypeNotFoundException, LifecycleException
+ {
+ return newEntity( type, null );
+ }
+
+ @Override
+ public <T> T newEntity( Class<T> type, String identity )
+ throws EntityTypeNotFoundException, LifecycleException
+ {
+ return newEntityBuilder( type, identity ).newInstance();
+ }
+
+ @Override
+ public <T> EntityBuilder<T> newEntityBuilder( Class<T> type )
+ throws EntityTypeNotFoundException
+ {
+ return newEntityBuilder( type, null );
+ }
+
+ @Override
+ public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
+ throws EntityTypeNotFoundException
+ {
+ ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
+
+ if( model == null )
+ {
+ throw new EntityTypeNotFoundException( type.getName(),
+ module.name(),
+ module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
+ );
+ }
+
+ EntityStore entityStore = ((ModuleSpi) model.module()).entityStore();
+
+ // Generate id if necessary
+ if( identity == null )
+ {
+ IdentityGenerator idGen = ((ModuleSpi) model.module()).identityGenerator();
+ if( idGen == null )
+ {
+ throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
+ }
+ identity = idGen.generate( model.model().types().findFirst().orElse( null ) );
+ }
+ EntityBuilder<T> builder;
+
+ builder = new EntityBuilderInstance<>( model,
+ this,
+ uow.getEntityStoreUnitOfWork( entityStore ),
+ identity );
+ return builder;
+ }
+
+ @Override
+ public <T> EntityBuilder<T> newEntityBuilderWithState(
+ Class<T> type,
+ Function<PropertyDescriptor, Object> propertyFunction,
+ Function<AssociationDescriptor, EntityReference> associationFunction,
+ Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
+ )
+ throws EntityTypeNotFoundException
+ {
+ return newEntityBuilderWithState( type, null,
+ propertyFunction,
+ associationFunction,
+ manyAssociationFunction,
+ namedAssociationFunction );
+ }
+
+ @Override
+ public <T> EntityBuilder<T> newEntityBuilderWithState(
+ Class<T> type, String identity,
+ Function<PropertyDescriptor, Object> propertyFunction,
+ Function<AssociationDescriptor, EntityReference> associationFunction,
+ Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
+ )
+ throws EntityTypeNotFoundException
+ {
+ NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
+ NullArgumentException.validateNotNull( "associationFunction", associationFunction );
+ NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
+ NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
+
+ ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
+
+ if( model == null )
+ {
+ throw new EntityTypeNotFoundException( type.getName(),
+ module.name(),
+ module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
+ );
+ }
+
+ EntityStore entityStore = model.module().entityStore();
+
+ FunctionStateResolver stateResolver = new FunctionStateResolver(
+ propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction
+ );
+
+ if( identity == null )
+ {
+ // Use identity from StateResolver if available
+ PropertyModel identityModel = (PropertyModel) model.model().state().findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
+ identity = (String) stateResolver.getPropertyState( identityModel );
+ if( identity == null )
+ {
+ // Generate identity
+ IdentityGenerator idGen = model.module().identityGenerator();
+ if( idGen == null )
+ {
+ throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
+ }
+ identity = idGen.generate( model.model().types().findFirst().orElse( null ));
+ }
+ }
+
+ return new EntityBuilderInstance<>( model,
+ this,
+ uow.getEntityStoreUnitOfWork( entityStore ),
+ identity,
+ stateResolver );
+ }
+
+ @Override
+ public <T> T get( Class<T> type, String identity )
+ throws EntityTypeNotFoundException, NoSuchEntityException
+ {
+ Iterable<ModelModule<EntityDescriptor>> models = module.typeLookup().lookupEntityModels( type );
+
+ if( !models.iterator().hasNext() )
+ {
+ throw new EntityTypeNotFoundException( type.getName(),
+ module.name(),
+ ((ModuleSpi) module).findVisibleEntityTypes().map( ModelModule.toStringFunction )
+ );
+ }
+
+ return uow.get( parseEntityReference( identity ), this, models, type );
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public <T> T get( T entity )
+ throws EntityTypeNotFoundException
+ {
+ EntityComposite entityComposite = (EntityComposite) entity;
+ EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
+ ModelModule<EntityDescriptor> model = new ModelModule<>( compositeInstance.module(), compositeInstance.entityModel() );
+ Class<T> type = (Class<T>) compositeInstance.types().findFirst().orElse( null );
+ return uow.get( compositeInstance.identity(), this, Collections.singletonList( model ), type );
+ }
+
+ @Override
+ public void remove( Object entity )
+ throws LifecycleException
+ {
+ uow.checkOpen();
+
+ EntityComposite entityComposite = (EntityComposite) entity;
+
+ EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
+
+ if( compositeInstance.status() == EntityStatus.NEW )
+ {
+ compositeInstance.remove( this );
+ uow.remove( compositeInstance.identity() );
+ }
+ else if( compositeInstance.status() == EntityStatus.LOADED || compositeInstance.status() == EntityStatus.UPDATED )
+ {
+ compositeInstance.remove( this );
+ }
+ else
+ {
+ throw new NoSuchEntityException( compositeInstance.identity(), compositeInstance.types(), usecase() );
+ }
+ }
+
+ @SuppressWarnings( "DuplicateThrows" )
+ @Override
+ public void complete()
+ throws UnitOfWorkCompletionException, ConcurrentEntityModificationException
+ {
+ uow.complete();
+ }
+
+ @Override
+ public void discard()
+ {
+ uow.discard();
+ }
+
+ @Override
+ public void close()
+ {
+ discard();
+ }
+
+ @Override
+ public boolean isOpen()
+ {
+ return uow.isOpen();
+ }
+
+ @Override
+ public boolean isPaused()
+ {
+ return uow.isPaused();
+ }
+
+ @Override
+ public void pause()
+ {
+ uow.pause();
+ }
+
+ @Override
+ public void resume()
+ {
+ uow.resume();
+ }
+
+ @Override
+ public void addUnitOfWorkCallback( UnitOfWorkCallback callback )
+ {
+ uow.addUnitOfWorkCallback( callback );
+ }
+
+ @Override
+ public void removeUnitOfWorkCallback( UnitOfWorkCallback callback )
+ {
+ uow.removeUnitOfWorkCallback( callback );
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if( this == o )
+ {
+ return true;
+ }
+ if( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ ModuleUnitOfWork that = (ModuleUnitOfWork) o;
+
+ return uow.equals( that.uow );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return uow.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return uow.toString();
+ }
+
+ public void addEntity( EntityInstance instance )
+ {
+ uow.addEntity( instance );
+ }
+
+ @Override
+ public <T extends Identity> T toValue( Class<T> primaryType, T entityComposite )
+ {
+ Function<PropertyDescriptor, Object> propertyFunction = new ToValuePropertyMappingFunction( entityComposite );
+ Function<AssociationDescriptor, EntityReference> assocationFunction = new ToValueAssociationMappingFunction<>( entityComposite );
+ Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToValueManyAssociationMappingFunction<>( entityComposite );
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToValueNameAssociationMappingFunction<>( entityComposite );
+
+ @SuppressWarnings( "unchecked" )
+ ValueBuilder<T> builder = module().newValueBuilderWithState(
+ primaryType, propertyFunction, assocationFunction, manyAssocFunction, namedAssocFunction );
+ return builder.newInstance();
+ }
+
+ @Override
+ public <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite )
+ {
+ Function<PropertyDescriptor, Object> propertyFunction = new ToEntityPropertyMappingFunction<>( valueComposite );
+ Function<AssociationDescriptor, EntityReference> assocationFunction = new ToEntityAssociationMappingFunction<>( valueComposite );
+ Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToEntityManyAssociationMappingFunction<>( valueComposite );
+ Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToEntityNameAssociationMappingFunction<>( valueComposite );
+
+ String identity = valueComposite.identity().get();
+ try
+ {
+ T entity = get( primaryType, identity );
+ // If successful, then this entity is to by modified.
+ EntityInstance instance = EntityInstance.entityInstanceOf( (EntityComposite) entity );
+ EntityState state = instance.entityState();
+ FunctionStateResolver stateResolver = new FunctionStateResolver( propertyFunction,
+ assocationFunction,
+ manyAssocFunction,
+ namedAssocFunction );
+ EntityModel model = (EntityModel) EntityInstance.entityInstanceOf( (EntityComposite) entity ).descriptor();
+ stateResolver.populateState( model, state );
+ return entity;
+ }
+ catch( NoSuchEntityException e )
+ {
+ EntityBuilder<T> entityBuilder = newEntityBuilderWithState( primaryType,
+ identity,
+ propertyFunction,
+ assocationFunction,
+ manyAssocFunction,
+ namedAssocFunction );
+ return entityBuilder.newInstance();
+ }
+ }
+
+ private static class UoWQuerySource implements QuerySource
+ {
+ private final ModuleUnitOfWork moduleUnitOfWork;
+
+ private UoWQuerySource( ModuleUnitOfWork moduleUnitOfWork )
+ {
+ this.moduleUnitOfWork = moduleUnitOfWork;
+ }
+
+ @Override
+ public <T> T find( Class<T> resultType,
+ Predicate<Composite> whereClause,
+ Iterable<OrderBy> orderBySegments,
+ Integer firstResult,
+ Integer maxResults,
+ Map<String, Object> variables
+ )
+ {
+ final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+
+ try
+ {
+ final EntityReference foundEntity = entityFinder.findEntity( resultType, whereClause, variables == null ? Collections
+ .<String, Object>emptyMap() : variables );
+ if( foundEntity != null )
+ {
+ try
+ {
+ return moduleUnitOfWork.get( resultType, foundEntity.identity() );
+ }
+ catch( NoSuchEntityException e )
+ {
+ return null; // Index is out of sync - entity has been removed
+ }
+ }
+ // No entity was found
+ return null;
+ }
+ catch( EntityFinderException e )
+ {
+ throw new QueryExecutionException( "Finder caused exception", e );
+ }
+ }
+
+ @Override
+ public <T> long count( Class<T> resultType,
+ Predicate<Composite> whereClause,
+ Iterable<OrderBy> orderBySegments,
+ Integer firstResult,
+ Integer maxResults,
+ Map<String, Object> variables
+ )
+ {
+ final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+
+ try
+ {
+ return entityFinder.countEntities( resultType, whereClause, variables == null ? Collections.<String, Object>emptyMap() : variables );
+ }
+ catch( EntityFinderException e )
+ {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ @Override
+ public <T> Iterator<T> iterator( final Class<T> resultType,
+ Predicate<Composite> whereClause,
+ Iterable<OrderBy> orderBySegments,
+ Integer firstResult,
+ Integer maxResults,
+ Map<String, Object> variables
+ )
+ {
+ final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
+
+ try
+ {
+ final Iterator<EntityReference> foundEntities = entityFinder.findEntities( resultType,
+ whereClause,
+ Iterables.toArray( OrderBy.class, orderBySegments ),
+ firstResult,
+ maxResults,
+ variables == null ? Collections
+ .<String, Object>emptyMap() : variables )
+ .iterator();
+
+ return new Iterator<T>()
+ {
+ @Override
+ public boolean hasNext()
+ {
+ return foundEntities.hasNext();
+ }
+
+ @Override
+ public T next()
+ {
+ final EntityReference foundEntity = foundEntities.next();
+ try
+ {
+ return moduleUnitOfWork.get( resultType, foundEntity.identity() );
+ }
+ catch( NoSuchEntityException e )
+ {
+ // Index is out of sync - entity has been removed
+ return null;
+ }
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ catch( EntityFinderException e )
+ {
+ throw new QueryExecutionException( "Query '" + toString() + "' could not be executed", e );
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "UnitOfWork( " + moduleUnitOfWork.usecase().name() + " )";
+ }
+ }
+
+ private class ToValuePropertyMappingFunction
+ implements Function<PropertyDescriptor, Object>
+ {
+ private Object entity;
+
+ public ToValuePropertyMappingFunction( Object entity )
+ {
+ this.entity = entity;
+ }
+
+ @Override
+ public Object apply( PropertyDescriptor propertyDescriptor )
+ {
+ EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
+ return entityState.propertyValueOf( propertyDescriptor.qualifiedName() );
+ }
+ }
+
+ private class ToValueAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, EntityReference>
+ {
+ private final T entity;
+
+ public ToValueAssociationMappingFunction( T entity )
+ {
+ this.entity = entity;
+ }
+
+ @Override
+ public EntityReference apply( AssociationDescriptor associationDescriptor )
+ {
+ EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
+ return entityState.associationValueOf( associationDescriptor.qualifiedName() );
+ }
+ }
+
+ private class ToValueManyAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, Iterable<EntityReference>>
+ {
+ private final T entity;
+
+ public ToValueManyAssociationMappingFunction( T entity )
+ {
+ this.entity = entity;
+ }
+
+ @Override
+ public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
+ {
+ EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
+ return entityState.manyAssociationValueOf( associationDescriptor.qualifiedName() );
+ }
+ }
+
+ private class ToValueNameAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, Map<String, EntityReference>>
+ {
+ private final T entity;
+
+ public ToValueNameAssociationMappingFunction( T entity )
+ {
+ this.entity = entity;
+ }
+
+ @Override
+ public Map<String, EntityReference> apply( AssociationDescriptor associationDescriptor )
+ {
+ Map<String, EntityReference> result = new HashMap<>();
+ EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
+ final NamedAssociationState state = entityState.namedAssociationValueOf( associationDescriptor.qualifiedName() );
+ for( String name : state )
+ {
+ result.put( name, state.get( name ) );
+ }
+ return result;
+ }
+ }
+
+ private class ToEntityPropertyMappingFunction<T>
+ implements Function<PropertyDescriptor, Object>
+ {
+ private final T value;
+
+ public ToEntityPropertyMappingFunction( T value )
+ {
+ this.value = value;
+ }
+
+ @Override
+ public Object apply( PropertyDescriptor propertyDescriptor )
+ {
+ StateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
+ Property<Object> property = state.propertyFor( propertyDescriptor.accessor() );
+ return property.get();
+ }
+ }
+
+ private class ToEntityAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, EntityReference>
+ {
+
+ private final T value;
+
+ public ToEntityAssociationMappingFunction( T value )
+ {
+ this.value = value;
+ }
+
+ @Override
+ public EntityReference apply( AssociationDescriptor associationDescriptor )
+ {
+ AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
+ AssociationInstance<T> association = (AssociationInstance<T>) state.associationFor( associationDescriptor.accessor() );
+ return association.getAssociationState().get();
+ }
+ }
+
+ private class ToEntityManyAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, Iterable<EntityReference>>
+ {
+
+ private final T value;
+
+ public ToEntityManyAssociationMappingFunction( T valueComposite )
+ {
+ this.value = valueComposite;
+ }
+
+ @Override
+ public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
+ {
+ AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
+ ManyAssociationInstance<T> association =
+ (ManyAssociationInstance<T>) state.manyAssociationFor( associationDescriptor.accessor() );
+ return association.getManyAssociationState();
+ }
+ }
+
+ private class ToEntityNameAssociationMappingFunction<T>
+ implements Function<AssociationDescriptor, Map<String, EntityReference>>
+ {
+ private final T value;
+
+ public ToEntityNameAssociationMappingFunction( T valueComposite )
+ {
+ this.value = valueComposite;
+ }
+
+ @Override
+ public Map<String, EntityReference> apply( AssociationDescriptor associationDescriptor )
+ {
+ AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
+ NamedAssociationInstance<T> association =
+ (NamedAssociationInstance<T>) state.namedAssociationFor( associationDescriptor.accessor() );
+ HashMap<String, EntityReference> result = new HashMap<>();
+ for( Map.Entry<String, EntityReference> entry : association.getEntityReferences() )
+ {
+ result.put( entry.getKey(), entry.getValue() );
+ }
+ return result;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
new file mode 100644
index 0000000..3a69e29
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
@@ -0,0 +1,100 @@
+/*
+ * 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.runtime.unitofwork;
+
+import java.util.Stack;
+import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.composite.TransientBuilderFactory;
+import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.injection.scope.Uses;
+import org.apache.zest.api.metrics.MetricsProvider;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.usecase.Usecase;
+import org.apache.zest.runtime.entity.EntityInstance;
+import org.apache.zest.spi.module.ModuleSpi;
+
+public class UnitOfWorkFactoryMixin
+ implements UnitOfWorkFactory
+{
+ @Structure
+ private TransientBuilderFactory tbf;
+
+ @Structure
+ private ModuleSpi module;
+
+ // Implementation of UnitOfWorkFactory
+ @Override
+ public UnitOfWork newUnitOfWork()
+ {
+ return newUnitOfWork( Usecase.DEFAULT );
+ }
+
+ @Override
+ public UnitOfWork newUnitOfWork( long currentTime )
+ {
+ return newUnitOfWork( Usecase.DEFAULT, currentTime );
+ }
+
+ @Override
+ public UnitOfWork newUnitOfWork( Usecase usecase )
+ {
+ return newUnitOfWork( usecase == null ? Usecase.DEFAULT : usecase, System.currentTimeMillis() );
+ }
+
+ @Override
+ public UnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+ {
+ UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( usecase, currentTime, metricsProvider() );
+ return tbf.newTransient( UnitOfWork.class, unitOfWorkInstance );
+ }
+
+ private MetricsProvider metricsProvider()
+ {
+ return module.metricsProvider();
+ }
+
+ @Override
+ public boolean isUnitOfWorkActive()
+ {
+ Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
+ return !stack.isEmpty();
+ }
+
+ @Override
+ public UnitOfWork currentUnitOfWork()
+ {
+ Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
+ if( stack.size() == 0 )
+ {
+ throw new IllegalStateException( "No current UnitOfWork active" );
+ }
+ return tbf.newTransient( UnitOfWork.class, stack.peek() );
+ }
+
+ @Override
+ public UnitOfWork getUnitOfWork( EntityComposite entity )
+ {
+ EntityInstance instance = EntityInstance.entityInstanceOf( entity );
+ return instance.unitOfWork();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
index fc0810b..3a65c9f 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -1,20 +1,23 @@
/*
- * Copyright (c) 2007-2013, Niclas Hedhman. All Rights Reserved.
+ * 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
*
- * Licensed 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
*
- * 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.
*
- * 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.runtime.unitofwork;
import java.util.ArrayList;
@@ -37,6 +40,7 @@ import org.apache.zest.api.type.HasTypes;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.unitofwork.UnitOfWorkException;
@@ -44,7 +48,6 @@ import org.apache.zest.api.unitofwork.UnitOfWorkOptions;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.runtime.entity.EntityInstance;
import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entity.EntityStatus;
import org.apache.zest.spi.entitystore.ConcurrentEntityStateModificationException;
@@ -53,8 +56,8 @@ import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
import org.apache.zest.spi.metrics.DefaultMetric;
-import org.apache.zest.spi.module.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.spi.structure.ModelModule;
import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.COMPLETED;
import static org.apache.zest.api.unitofwork.UnitOfWorkCallback.UnitOfWorkStatus.DISCARDED;
@@ -123,7 +126,7 @@ public final class UnitOfWorkInstance
}
public <T> T get( EntityReference identity,
- ModuleUnitOfWork uow,
+ UnitOfWork uow,
Iterable<ModelModule<EntityDescriptor>> potentialModels,
Class<T> mixinType
)
@@ -175,10 +178,8 @@ public final class UnitOfWorkInstance
);
}
}
-
// Create instance
entityInstance = new EntityInstance( uow, module, model, entityState );
-
instanceCache.put( identity, entityInstance );
}
else
@@ -390,10 +391,7 @@ public final class UnitOfWorkInstance
// Notify explicitly registered callbacks
if( callbacks != null )
{
- for( UnitOfWorkCallback callback : callbacks )
- {
- callback.beforeCompletion();
- }
+ callbacks.forEach( UnitOfWorkCallback::beforeCompletion );
}
// Notify entities
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
index 9f72fe2..45e9282 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderInstance.java
@@ -21,7 +21,7 @@ import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
/**
* Implementation of ValueBuilder
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
index a878ab2..eafd07a 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithPrototype.java
@@ -38,7 +38,7 @@ import org.apache.zest.runtime.composite.MixinsModel;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.composite.UsesInstance;
import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.runtime.structure.ModuleInstance;
/**
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
index db97002..69c06c4 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueBuilderWithState.java
@@ -18,7 +18,7 @@ import org.apache.zest.api.common.ConstructionException;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.runtime.composite.StateResolver;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.runtime.structure.ModuleInstance;
public class ValueBuilderWithState<T> implements ValueBuilder<T>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
index ed0083b..313567e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/value/ValueStateInstance.java
@@ -35,7 +35,8 @@ import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.property.PropertyInfo;
import org.apache.zest.runtime.property.PropertyInstance;
import org.apache.zest.runtime.structure.ModuleInstance;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.runtime.unitofwork.EntityFunction;
+import org.apache.zest.spi.structure.ModelModule;
/**
* TODO
@@ -65,6 +66,8 @@ public final class ValueStateInstance
StateResolver stateResolver
)
{
+ EntityFunction entityFunction = new EntityFunction( currentModule.unitOfWorkFactory() );
+
ValueModel valueModel = (ValueModel) compositeModelModule.model();
this.properties = new LinkedHashMap<>();
valueModel.state().properties().forEach( propertyDescriptor -> {
@@ -80,7 +83,7 @@ public final class ValueStateInstance
EntityReference value = stateResolver.getAssociationState( associationDescriptor );
AssociationInstance<Object> associationInstance1 = new AssociationInstance<>(
builderInfo,
- currentModule.getEntityFunction(),
+ entityFunction,
new ReferenceProperty( value ) );
associations.put( associationDescriptor.accessor(), associationInstance1 );
} );
@@ -93,7 +96,7 @@ public final class ValueStateInstance
ManyAssociationValueState manyAssociationState = new ManyAssociationValueState( value );
ManyAssociationInstance<Object> associationInstance = new ManyAssociationInstance<>(
builderInfo,
- currentModule.getEntityFunction(),
+ entityFunction,
manyAssociationState );
manyAssociations.put( associationDescriptor.accessor(), associationInstance );
} );
@@ -106,7 +109,7 @@ public final class ValueStateInstance
NamedAssociationValueState namedAssociationState = new NamedAssociationValueState( value );
NamedAssociationInstance<Object> associationInstance = new NamedAssociationInstance<>(
builderInfo,
- currentModule.getEntityFunction(),
+ entityFunction,
namedAssociationState );
namedAssociations.put( associationDescriptor.accessor(), associationInstance );
} );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
index 355ee8e..ed1b8c3 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/OptionalTest.java
@@ -95,7 +95,7 @@ public class OptionalTest
public void givenOptionalAssociationWhenOptionalMissingThenNoException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
TestComposite4 ref = unitOfWork.newEntity( TestComposite4.class );
@@ -116,7 +116,7 @@ public class OptionalTest
public void givenOptionalAssociationWhenOptionalSetThenNoException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
TestComposite4 ref = unitOfWork.newEntity( TestComposite4.class );
@@ -138,7 +138,7 @@ public class OptionalTest
public void givenMandatoryAssociationWhenMandatoryMissingThenException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
TestComposite4 ref = unitOfWork.newEntity( TestComposite4.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/api/common/PropertyErrorTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyErrorTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyErrorTest.java
index 1201329..6add3eb 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyErrorTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyErrorTest.java
@@ -41,7 +41,7 @@ public class PropertyErrorTest
public void givenEntityWithNonOptionPropertyWhenInstantiatedThenException()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
PersonEntity person = unitOfWork.newEntity( PersonEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
index 4bcc88a..e3f5a7e 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/PropertyTypeTest.java
@@ -49,7 +49,7 @@ public class PropertyTypeTest
public void givenEntityWithPropertyConstraintsWhenInstantiatedThenPropertiesWork()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder( PersonEntity.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
index 76b80bf..8b33ac0 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
@@ -44,7 +44,7 @@ public class RemovalTest
public void givenEntityIsCreatedAndUnitOfWorkIsNotCompletedWhenEntityIsRemoveThenSuccessfulRemoval()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, "123" );
builder.instance().test().set( "habba" );
TestEntity test = builder.newInstance();
@@ -56,7 +56,7 @@ public class RemovalTest
public void givenStandardPidRegulatorWhenNoChangeInInputExpectOutputToGoTowardsMinimum()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
PidRegulator regulator = null;
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
index 77d1a96..42360ad 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/ValueCompositeTest.java
@@ -183,7 +183,7 @@ public class ValueCompositeTest
builder.prototype().number().set( 42L );
SomeValue some = builder.newInstance();
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class );
entityBuilder.instance().someValue().set( some );
SomeEntity entity = entityBuilder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
index 0524c64..4688883 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
@@ -52,14 +52,14 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
throws UnitOfWorkCompletionException
{
String identity;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
Company startUp = uow.newEntity( Company.class );
startUp.name().set( "Acme" );
identity = ( (Identity) startUp ).identity().get();
uow.complete();
}
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
Company startUp = uow.get( Company.class, identity );
assertThat( startUp.name().get(), equalTo( "Acme" ) );
@@ -77,7 +77,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
throws UnitOfWorkCompletionException
{
String identity;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
Company startUp = uow.newEntity( Company.class );
Employee niclas = uow.newEntity( Employee.class );
@@ -87,7 +87,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
uow.complete();
}
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
Company startUp = uow.get( Company.class, identity );
Employee niclas = startUp.lead().get();
@@ -104,7 +104,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetLeadToTheSalesTeam()
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
SalesTeam startUp = uow.newEntity( SalesTeam.class );
Employee niclas = uow.newEntity( Employee.class );
@@ -116,7 +116,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToSetLeadToTheResearchTeam()
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
ResearchTeam startUp = uow.newEntity( ResearchTeam.class );
Employee niclas = uow.newEntity( Employee.class );
@@ -128,7 +128,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheCompany()
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
Company startUp = uow.newEntity( Company.class );
Employee niclas = uow.newEntity( Employee.class );
@@ -142,7 +142,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheSalesTeam()
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
SalesTeam startUp = uow.newEntity( SalesTeam.class );
Employee niclas = uow.newEntity( Employee.class );
@@ -154,7 +154,7 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
@Test
public void shouldBeAbleToAddEmployeesToTheResearchTeam()
{
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
ResearchTeam startUp = uow.newEntity( ResearchTeam.class );
Employee niclas = uow.newEntity( Employee.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
index a2933be..7564016 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
@@ -56,7 +56,7 @@ public class SetAssociationInSideEffectTest
@Test
public void whenSettingAnAssociationInASideEffectExpectItToWork()
{
- try( UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
+ try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
{
Pianist chris = uow.newEntity( Pianist.class, "Chris" );
Steinway modelD = uow.newEntity( Steinway.class, "ModelD-274" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
index ea2ebc1..ca655f8 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
@@ -17,6 +17,7 @@
*/
package org.apache.zest.regression.qi382;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.entity.EntityBuilder;
@@ -26,7 +27,6 @@ import org.apache.zest.api.entity.LifecycleException;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.value.ValueSerialization;
@@ -56,12 +56,12 @@ public class Qi382Test extends AbstractZestTest
public void givenCreationOfTwoEntitiesWhenAssigningOneToOtherExpectCompletionToSucceed()
throws UnitOfWorkCompletionException
{
- try( UnitOfWork unitOfWork = module.newUnitOfWork() )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork() )
{
Car car = unitOfWork.newEntity( Car.class, "Ferrari" );
unitOfWork.complete();
}
- try( UnitOfWork unitOfWork = module.newUnitOfWork() )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork() )
{
Car car = unitOfWork.get( Car.class, "Ferrari" );
assertThat( car, notNullValue() );
@@ -81,13 +81,13 @@ public class Qi382Test extends AbstractZestTest
private Car me;
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void create()
throws LifecycleException
{
- UnitOfWork unitOfWork = module.currentUnitOfWork();
+ UnitOfWork unitOfWork = uowf.currentUnitOfWork();
EntityBuilder<Person> builder = unitOfWork.newEntityBuilder( Person.class, "Niclas" );
builder.instance().car().set( me );
builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
index c4461cb..f3bcd2f 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
@@ -44,7 +44,7 @@ public class Qi383Test extends AbstractZestTest
public void givenUnitOfWorkInProgressWhenAddingSameEntityTwiceExpectException()
throws UnitOfWorkCompletionException
{
- try( UnitOfWork unitOfWork = module.newUnitOfWork() )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork() )
{
unitOfWork.newEntity( Car.class, "Ferrari" );
unitOfWork.newEntity( Car.class, "Ford" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi59/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi59/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi59/IssueTest.java
index 0363137..29baada 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi59/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi59/IssueTest.java
@@ -42,7 +42,7 @@ public class IssueTest
@Test
public void givenEntityWithConstrainedPropertyWhenInvalidPropertyValueSetThenThrowException()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
@@ -62,7 +62,7 @@ public class IssueTest
@Test
public void givenEntityWithComplexConstrainedPropertyWhenInvalidPropertyValueSetThenThrowException()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/regression/qi94/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi94/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi94/IssueTest.java
index d799ddc..18bc396 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi94/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi94/IssueTest.java
@@ -44,7 +44,7 @@ public class IssueTest
@Test
public void entityBuilderAssociationTypeIsNotNull()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Item> builder = uow.newEntityBuilder( Item.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java b/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
index df40a4d..a9f7dfa 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/ZestAPITest.java
@@ -45,7 +45,7 @@ public class ZestAPITest
public void testGetModuleOfComposite()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
TestEntity testEntity = unitOfWork.newEntity( TestEntity.class );
api.moduleOf( testEntity );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/ZestSPITest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/ZestSPITest.java b/core/runtime/src/test/java/org/apache/zest/runtime/ZestSPITest.java
index d171396..76f2433 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/ZestSPITest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/ZestSPITest.java
@@ -53,7 +53,7 @@ public class ZestSPITest
public void givenEntityWhenGettingStateThenGetCorrectState()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
TestEntity testEntity;
try
{
@@ -72,7 +72,7 @@ public class ZestSPITest
unitOfWork.discard();
}
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
testEntity = uow.get( testEntity );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
index 7054b37..f2ec635 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/appliesto/AppliesToOrConditionQI241Test.java
@@ -57,7 +57,7 @@ public class AppliesToOrConditionQI241Test
@Test
public void testMultiConcerns1()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
@@ -76,7 +76,7 @@ public class AppliesToOrConditionQI241Test
@Test
public void testMultiConcerns2()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
@@ -95,7 +95,7 @@ public class AppliesToOrConditionQI241Test
@Test
public void testMultiConcernsBoth()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
index d0c7147..8e9f338 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
@@ -56,7 +56,7 @@ public class AssociationAssignmentTest extends AbstractZestTest
public void givenAssignmentOfAssociationAtCreationWhenDereferencingAssocationExpectCorrectValue()
throws Exception
{
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
TheAssociatedType entity1 = work.newEntity( TheAssociatedType.class );
EntityBuilder<TheMainType> builder = work.newEntityBuilder( TheMainType.class );
builder.instance().assoc().set( entity1 );
@@ -67,7 +67,7 @@ public class AssociationAssignmentTest extends AbstractZestTest
assertThat(id1, notNullValue());
assertThat(id2, notNullValue());
- work = module.newUnitOfWork();
+ work = uowf.newUnitOfWork();
TheMainType entity3 = work.get(TheMainType.class, id2 );
TheAssociatedType entity4 = entity3.assoc().get();
assertThat( entity4.identity().get(), equalTo(id1));
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
index ab5222f..4ffc14b 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationEqualityTest.java
@@ -84,7 +84,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfTheSameTypeAndSameStateWhenTestingAssociationDescriptorEqualityExpectEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AnEntity anEntity = uow.newEntity( AnEntity.class );
@@ -127,7 +127,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfTheSameTypeAndDifferentStateWhenTestingAssociationDescriptorEqualityExpectEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
SomeWithAssociations some = buildSomeWithAssociation( uow.newEntity( AnEntity.class ) );
@@ -168,7 +168,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfDifferentTypeAndSameStateWhenTestingAssociationDescriptorEqualityExpectNotEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AnEntity anEntity = uow.newEntity( AnEntity.class );
@@ -214,7 +214,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfSameTypeAndDifferentStateWhenTestingAssociationStateEqualityExpectNotEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
SomeWithAssociations some = buildSomeWithAssociation( uow.newEntity( AnEntity.class ) );
@@ -248,7 +248,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingAssociationStateEqualityExpectEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AnEntity anEntity = uow.newEntity( AnEntity.class );
@@ -287,7 +287,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfTheSameTypeAndSameStateWhenTestingAssociationEqualityExpectEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AnEntity anEntity = uow.newEntity( AnEntity.class );
@@ -323,7 +323,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfTheSameTypeAndDifferentStateWhenTestingAssociationEqualityExpectNotEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
SomeWithAssociations some = buildSomeWithAssociation( uow.newEntity( AnEntity.class ) );
@@ -357,7 +357,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfDifferentTypesAndSameStateWhenTestingAssociationEqualityExpectNotEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
AnEntity anEntity = uow.newEntity( AnEntity.class );
@@ -393,7 +393,7 @@ public class AssociationEqualityTest
@Test
public void givenValuesOfDifferentTypesAndDifferentStateWhenTestingAssociationEqualityExpectNotEquals()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
SomeWithAssociations some = buildSomeWithAssociation( uow.newEntity( AnEntity.class ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
index 226dd47..5d7839b 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientAsClassTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.zest.runtime.composite;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.apache.zest.api.concern.ConcernOf;
+import org.apache.zest.api.concern.Concerns;
import org.junit.Ignore;
import org.junit.Test;
import org.apache.zest.bootstrap.AssemblyException;
@@ -30,15 +34,27 @@ import static org.junit.Assert.assertThat;
/**
* Test for QI-298.
*/
-@Ignore( "Awaiting QI-298" )
public class TransientAsClassTest
extends AbstractZestTest
{
+ public static class UnderTestConcern extends ConcernOf<InvocationHandler>
+ implements InvocationHandler
+ {
+
+ @Override
+ public Object invoke( Object proxy, Method method, Object[] args )
+ throws Throwable
+ {
+ return next.invoke( proxy, method, args ) + " bar";
+ }
+ }
+
+ @Concerns(UnderTestConcern.class)
public static class UnderTest
{
public String foo()
{
- return "bar";
+ return "foo";
}
}
@@ -53,6 +69,6 @@ public class TransientAsClassTest
public void test()
{
UnderTest underTest = module.newTransient( UnderTest.class );
- assertThat( underTest.foo(), equalTo( "bar" ) );
+ assertThat( underTest.foo(), equalTo( "foo bar" ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientClassLoaderTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientClassLoaderTest.java
new file mode 100644
index 0000000..56808b3
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/TransientClassLoaderTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.runtime.composite;
+
+public class TransientClassLoaderTest
+{
+
+ public void givenTransientWhenLoadingClassExpectSubclassGenerated()
+ {
+// new TransientClassLoader( getClass().getClassLoader() ).loadFragmentClass( mainType );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
index 9a951d9..d243c64 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/concerns/GenericConcernTest.java
@@ -42,7 +42,7 @@ public class GenericConcernTest
@Test
public void testNestedUnitOfWork()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
Some some = module.newTransient( Some.class );
some.doStuff();
uow.discard();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/AggregatedTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/AggregatedTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/AggregatedTest.java
index 58bacd2..abf5c66 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/AggregatedTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/AggregatedTest.java
@@ -54,7 +54,7 @@ public class AggregatedTest
CompanyEntity companyEntity;
PersonEntity personEntity, personEntity2;
EmployeeEntity employeeEntity, employeeEntity2;
- try( UnitOfWork unitOfWork = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Creation" ) ) )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Creation" ) ) )
{
{
EntityBuilder<PersonEntity> builder = unitOfWork.newEntityBuilder( PersonEntity.class );
@@ -100,7 +100,7 @@ public class AggregatedTest
unitOfWork.complete();
}
- try( UnitOfWork unitOfWork = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Removal" ) ) )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Removal" ) ) )
{
companyEntity = unitOfWork.get( companyEntity );
unitOfWork.remove( companyEntity );
@@ -108,7 +108,7 @@ public class AggregatedTest
unitOfWork.complete();
}
- try( UnitOfWork unitOfWork = module.newUnitOfWork( UsecaseBuilder.newUsecase( "No 1st employee" ) ) )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "No 1st employee" ) ) )
{
unitOfWork.get( employeeEntity );
fail( "Should not work" );
@@ -118,7 +118,7 @@ public class AggregatedTest
// Expected
}
- try( UnitOfWork unitOfWork = module.newUnitOfWork( UsecaseBuilder.newUsecase( "No 2nd employee" ) ) )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "No 2nd employee" ) ) )
{
unitOfWork.get( employeeEntity2 );
fail( "Should not work" );
@@ -128,7 +128,7 @@ public class AggregatedTest
// Expected
}
- try( UnitOfWork unitOfWork = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Persons not removed" ) ) )
+ try( UnitOfWork unitOfWork = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Persons not removed" ) ) )
{
unitOfWork.get( personEntity );
unitOfWork.get( personEntity2 );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
index 2f23f8a..cd501d1 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
@@ -17,11 +17,9 @@ package org.apache.zest.runtime.entity;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.Test;
import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.association.NamedAssociation;
import org.apache.zest.api.common.Optional;
@@ -29,7 +27,6 @@ import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.bootstrap.AssemblyException;
@@ -52,6 +49,7 @@ public class EntityBuilderWithStateTest
{
new EntityTestAssembler().assemble( module );
module.entities( SomeEntity.class );
+ new DefaultUnitOfWorkAssembler().assemble( module );
}
@Test
@@ -59,7 +57,7 @@ public class EntityBuilderWithStateTest
throws UnitOfWorkCompletionException
{
final String associatedIdentity;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
EntityBuilder<SomeEntity> builder = uow.newEntityBuilder( SomeEntity.class );
builder.instance().prop().set( "Associated" );
@@ -67,60 +65,40 @@ public class EntityBuilderWithStateTest
associatedIdentity = entity.identity().get();
uow.complete();
}
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
SomeEntity entity = uow.newEntityBuilderWithState(
SomeEntity.class,
- new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
+ descriptor -> {
+ if( "prop".equals( descriptor.qualifiedName().name() ) )
{
- if( "prop".equals( descriptor.qualifiedName().name() ) )
- {
- return "Foo";
- }
- return null;
+ return "Foo";
}
+ return null;
},
- new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor descriptor )
+ descriptor -> {
+ if( "ass".equals( descriptor.qualifiedName().name() ) )
{
- if( "ass".equals( descriptor.qualifiedName().name() ) )
- {
- return EntityReference.parseEntityReference( associatedIdentity );
- }
- return null;
+ return EntityReference.parseEntityReference( associatedIdentity );
}
+ return null;
},
- new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor descriptor )
+ descriptor -> {
+ if( "manyAss".equals( descriptor.qualifiedName().name() ) )
{
- if( "manyAss".equals( descriptor.qualifiedName().name() ) )
- {
- return Arrays.asList( EntityReference.parseEntityReference( associatedIdentity ) );
- }
- return null;
+ return Arrays.asList( EntityReference.parseEntityReference( associatedIdentity ) );
}
+ return null;
},
- new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor descriptor )
+ descriptor -> {
+ if( "namedAss".equals( descriptor.qualifiedName().name() ) )
{
- if( "namedAss".equals( descriptor.qualifiedName().name() ) )
- {
- return Collections.singletonMap(
- "foo",
- EntityReference.parseEntityReference( associatedIdentity )
- );
- }
- return null;
+ return Collections.singletonMap(
+ "foo",
+ EntityReference.parseEntityReference( associatedIdentity )
+ );
}
+ return null;
}
).newInstance();
assertThat( entity.prop().get(), equalTo( "Foo" ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCompositeEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCompositeEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCompositeEqualityTest.java
index 980a3dd..f451f70 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCompositeEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCompositeEqualityTest.java
@@ -49,7 +49,7 @@ public class EntityCompositeEqualityTest
throws Exception
{
super.setUp();
- unitOfWork = this.module.newUnitOfWork();
+ unitOfWork = this.uowf.newUnitOfWork();
myCompositeBuilder = unitOfWork.newEntityBuilder( MyComposite.class );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCreationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCreationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCreationTest.java
index d514312..d4b7f43 100755
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCreationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityCreationTest.java
@@ -79,7 +79,7 @@ public class EntityCreationTest
@Test
public void doTestUseUowNewEntity()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
SomeEntity entity = uow.newEntity( SomeEntity.class );
uow.discard();
}
@@ -87,7 +87,7 @@ public class EntityCreationTest
@Test
public void doTestUseEntityBuilder()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
EntityBuilder<SomeEntity> builder = uow.newEntityBuilder( SomeEntity.class );
SomeEntity entity = builder.newInstance();
uow.discard();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
index 2c15fdc..4a7c1d8 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
@@ -34,7 +34,7 @@ public class EntityTypeTest
public void givenSubclassedEntityWhenRequestingSuperclassExpectResolutionToWork()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, "123" );
[03/34] zest-java git commit: Starting to create a Multi Layer
abstract test framework for indexing.
Posted by ni...@apache.org.
Starting to create a Multi Layer abstract test framework for indexing.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/5d2a62be
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/5d2a62be
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/5d2a62be
Branch: refs/heads/develop
Commit: 5d2a62bef95828222c17c1c2b413ac43d8d2b71b
Parents: e120d16
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Mon Dec 14 21:54:10 2015 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Mon Dec 14 21:54:10 2015 +0800
----------------------------------------------------------------------
.../layered/LayeredLayerAssembler.java | 9 +-
.../test/indexing/AbstractComplexQueryTest.java | 2 +-
.../org/apache/zest/test/indexing/TestData.java | 11 +-
.../AbstractMultiLayeredIndexingTest.java | 101 +++++++++++++++++++
.../zest/test/indexing/layered/AccessLayer.java | 39 +++++++
.../test/indexing/layered/AccountModule.java | 52 ++++++++++
.../indexing/layered/ApplicationAssembler.java | 52 ++++++++++
.../zest/test/indexing/layered/ConfigLayer.java | 37 +++++++
.../test/indexing/layered/ConfigModule.java | 41 ++++++++
.../zest/test/indexing/layered/DomainLayer.java | 38 +++++++
.../test/indexing/layered/FamilyModule.java | 54 ++++++++++
.../test/indexing/layered/IndexingLayer.java | 37 +++++++
.../test/indexing/layered/PersistenceLayer.java | 37 +++++++
.../indexing/layered/PersistenceModule.java | 44 ++++++++
.../zest/test/indexing/layered/TestCase.java | 33 ++++++
.../zest/test/indexing/layered/TestCase1.java | 76 ++++++++++++++
.../zest/test/indexing/layered/TestCase2.java | 76 ++++++++++++++
.../test/indexing/layered/TestSuite1Module.java | 40 ++++++++
.../test/indexing/layered/TestSuite2Module.java | 38 +++++++
.../test/indexing/layered/TestSuite3Module.java | 38 +++++++
.../zest/test/indexing/model/Address.java | 1 -
.../apache/zest/test/indexing/model/Cat.java | 3 +-
.../apache/zest/test/indexing/model/City.java | 3 +-
.../apache/zest/test/indexing/model/Dog.java | 3 +-
.../apache/zest/test/indexing/model/Domain.java | 3 +-
.../apache/zest/test/indexing/model/Female.java | 3 +-
.../apache/zest/test/indexing/model/File.java | 1 -
.../apache/zest/test/indexing/model/Host.java | 1 -
.../apache/zest/test/indexing/model/Male.java | 3 +-
.../apache/zest/test/indexing/model/Port.java | 1 -
.../zest/test/indexing/model/Protocol.java | 1 -
.../zest/test/indexing/model/QueryParam.java | 1 -
.../apache/zest/test/indexing/model/URL.java | 1 -
33 files changed, 855 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
index 920ef54..898591e 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
@@ -63,17 +63,20 @@ public abstract class LayeredLayerAssembler
private ModuleAssembler instantiateAssembler( LayerAssembly layer,
Class<? extends ModuleAssembler> modulerAssemblerClass
)
- throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException
+ throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException
{
ModuleAssembler moduleAssembler;
try
{
- Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getConstructor( ModuleAssembly.class );
+ Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getDeclaredConstructor( ModuleAssembly.class );
+ assemblyConstructor.setAccessible( true );
moduleAssembler = assemblyConstructor.newInstance( layer );
}
catch( NoSuchMethodException e )
{
- moduleAssembler = modulerAssemblerClass.newInstance();
+ Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getDeclaredConstructor();
+ assemblyConstructor.setAccessible( true );
+ moduleAssembler = assemblyConstructor.newInstance();
}
return moduleAssembler;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
index 55b211c..4698753 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
@@ -56,7 +56,7 @@ public abstract class AbstractComplexQueryTest
public void showNetwork()
throws IOException
{
- IndexExporter indexerExporter = module.<IndexExporter>findService( IndexExporter.class ).get();
+ IndexExporter indexerExporter = module.findService( IndexExporter.class ).get();
indexerExporter.exportReadableToStream( System.out );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index e83b71b..b07055e 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import org.apache.zest.test.indexing.model.Dog;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
@@ -47,9 +48,9 @@ import static org.joda.time.DateTimeZone.UTC;
/**
* Utility class to populate Index/Query tests data.
*/
-class TestData
+public class TestData
{
- static void populate( Module module )
+ public static void populate( Module module )
throws UnitOfWorkCompletionException
{
try( UnitOfWork unitOfWork = module.newUnitOfWork() )
@@ -239,6 +240,12 @@ class TestData
felix.name().set( "Felix" );
catBuilder.newInstance();
}
+ {
+ EntityBuilder<Dog> builder = unitOfWork.newEntityBuilder( Dog.class );
+ Dog snoopy = builder.instance();
+ snoopy.name().set( "Snoopy" );
+ builder.newInstance();
+ }
unitOfWork.complete();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
new file mode 100644
index 0000000..7a55fe0
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AbstractMultiLayeredIndexingTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.activation.ActivationException;
+import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.test.indexing.TestData;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractMultiLayeredIndexingTest
+{
+ static Class<? extends ModuleAssembler> indexingAssembler;
+
+ protected Application application;
+ private Iterable<ServiceReference<TestCase>> suite1;
+ private Iterable<ServiceReference<TestCase>> suite2;
+ private Iterable<ServiceReference<TestCase>> suite3;
+
+ public AbstractMultiLayeredIndexingTest( Class<? extends ModuleAssembler> indexingAssembler )
+ {
+ AbstractMultiLayeredIndexingTest.indexingAssembler = indexingAssembler;
+ }
+
+ @Before
+ public void setup()
+ throws AssemblyException, ActivationException
+ {
+ ApplicationAssembler assembler =
+ new ApplicationAssembler( "Multi Layered Indexing Test", "1.0", Application.Mode.development );
+ assembler.initialize();
+ assembler.start();
+ application = assembler.application();
+ Module familyModule = application.findModule( "Domain Layer", "Family Module" );
+ TestData.populate( familyModule );
+ Module suite1Module = application.findModule( "Access Layer", "TestSuite1 Module" );
+ suite1 = suite1Module.findServices( TestCase.class );
+
+ Module suite2Module = application.findModule( "Access Layer", "TestSuite2 Module" );
+ suite2 = suite2Module.findServices( TestCase.class );
+
+ Module suite3Module = application.findModule( "Access Layer", "TestSuite3 Module" );
+ suite3 = suite3Module.findServices( TestCase.class );
+ }
+
+ @Test
+ public void suite1Tests()
+ throws Exception
+ {
+ Iterable<ServiceReference<TestCase>> suite = this.suite1;
+ runTest( suite );
+ }
+
+ @Test
+ public void suite2Tests()
+ throws Exception
+ {
+ runTest( suite2 );
+ }
+
+ @Test
+ public void suite3Tests()
+ throws Exception
+ {
+ runTest( suite3 );
+ }
+
+ private void runTest( Iterable<ServiceReference<TestCase>> suite )
+ throws Exception
+ {
+ for( ServiceReference<TestCase> ref : suite )
+ {
+ TestCase testCase = ref.get();
+ testCase.when();
+ testCase.given();
+ testCase.expect();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
new file mode 100644
index 0000000..6b1b4e7
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccessLayer.java
@@ -0,0 +1,39 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class AccessLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, TestSuite1Module.class );
+ createModule( layer, TestSuite2Module.class );
+ createModule( layer, TestSuite3Module.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java
new file mode 100644
index 0000000..0df4aee
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/AccountModule.java
@@ -0,0 +1,52 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.common.Visibility;
+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.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.test.indexing.model.Account;
+import org.apache.zest.test.indexing.model.Domain;
+import org.apache.zest.test.indexing.model.File;
+import org.apache.zest.test.indexing.model.Host;
+import org.apache.zest.test.indexing.model.Port;
+import org.apache.zest.test.indexing.model.Protocol;
+import org.apache.zest.test.indexing.model.QueryParam;
+import org.apache.zest.test.indexing.model.URL;
+
+class AccountModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer );
+ module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class )
+ .visibleIn( Visibility.layer );
+ module.services( UuidIdentityGeneratorService.class );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java
new file mode 100644
index 0000000..1b11738
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ApplicationAssembler.java
@@ -0,0 +1,52 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.bootstrap.ApplicationAssembly;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
+
+class ApplicationAssembler extends LayeredApplicationAssembler
+{
+
+ public ApplicationAssembler( String name, String version, Application.Mode mode )
+ throws AssemblyException
+ {
+ super( name, version, mode );
+ }
+
+ @Override
+ protected void assembleLayers( ApplicationAssembly assembly )
+ throws AssemblyException
+ {
+ LayerAssembly accessLayer = createLayer( AccessLayer.class );
+ LayerAssembly domainLayer = createLayer( DomainLayer.class );
+ LayerAssembly persistenceLayer = createLayer( PersistenceLayer.class );
+ LayerAssembly indexingLayer = createLayer( IndexingLayer.class );
+ LayerAssembly configLayer = createLayer( ConfigLayer.class );
+ accessLayer.uses( domainLayer );
+ domainLayer.uses( persistenceLayer, indexingLayer );
+ persistenceLayer.uses( configLayer );
+ indexingLayer.uses( configLayer );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
new file mode 100644
index 0000000..0b4fada
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigLayer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class ConfigLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, ConfigModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.java
new file mode 100644
index 0000000..00265f6
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/ConfigModule.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.test.indexing.layered;
+
+import org.apache.zest.api.common.Visibility;
+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.entitystore.memory.MemoryEntityStoreService;
+
+class ConfigModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
new file mode 100644
index 0000000..5704d48
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/DomainLayer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class DomainLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, FamilyModule.class );
+ createModule( layer, AccountModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
new file mode 100644
index 0000000..56a4939
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/FamilyModule.java
@@ -0,0 +1,54 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.common.Visibility;
+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.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.test.indexing.model.Address;
+import org.apache.zest.test.indexing.model.Cat;
+import org.apache.zest.test.indexing.model.City;
+import org.apache.zest.test.indexing.model.Dog;
+import org.apache.zest.test.indexing.model.Female;
+import org.apache.zest.test.indexing.model.Male;
+
+class FamilyModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( Male.class,
+ Female.class,
+ City.class,
+ Cat.class,
+ Dog.class ).visibleIn( Visibility.application );
+
+ module.values( Address.class ).visibleIn( Visibility.application );
+ module.services( UuidIdentityGeneratorService.class );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
new file mode 100644
index 0000000..489092d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/IndexingLayer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class IndexingLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, AbstractMultiLayeredIndexingTest.indexingAssembler );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
new file mode 100644
index 0000000..cc22513
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceLayer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+class PersistenceLayer extends LayeredLayerAssembler
+{
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, PersistenceModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
new file mode 100644
index 0000000..0b92f56
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/PersistenceModule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.value.ValueSerialization;
+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.entitystore.memory.MemoryEntityStoreService;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+
+class PersistenceModule
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
+ module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
new file mode 100644
index 0000000..5dd2e71
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase.java
@@ -0,0 +1,33 @@
+/*
+ * 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.test.indexing.layered;
+
+interface TestCase
+{
+ void given()
+ throws Exception;
+
+ void when()
+ throws Exception;
+
+ void expect()
+ throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
new file mode 100644
index 0000000..e2dd860
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase1.java
@@ -0,0 +1,76 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.query.QueryExpressions;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+import org.apache.zest.test.indexing.model.Male;
+import org.apache.zest.test.indexing.model.Person;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class TestCase1
+ implements TestCase
+{
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private QueryBuilderFactory qbf;
+
+ private QueryBuilder<Male> builder;
+
+ private Query<Male> query;
+
+ @Override
+ public void given()
+ throws Exception
+ {
+ QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
+ Male prototype = QueryExpressions.templateFor( Male.class );
+ builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
+ }
+
+ @Override
+ @UnitOfWorkPropagation
+ public void when()
+ throws Exception
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ query = uow.newQuery( builder );
+ }
+
+ @Override
+ public void expect()
+ throws Exception
+ {
+ assertThat( query.count(), equalTo(1) );
+ Male male = query.find();
+ assertThat( male.title().get(), equalTo( Person.Title.MR ));
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
new file mode 100644
index 0000000..dcd448a
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestCase2.java
@@ -0,0 +1,76 @@
+/*
+ * 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.test.indexing.layered;
+
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.query.QueryExpressions;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+import org.apache.zest.test.indexing.model.Male;
+import org.apache.zest.test.indexing.model.Person;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class TestCase2
+ implements TestCase
+{
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ @Structure
+ private QueryBuilderFactory qbf;
+
+ private QueryBuilder<Male> builder;
+
+ private Query<Male> query;
+
+ @Override
+ public void given()
+ throws Exception
+ {
+ QueryBuilder<Male> qb = qbf.newQueryBuilder( Male.class );
+ Male prototype = QueryExpressions.templateFor( Male.class );
+ builder = qb.where( QueryExpressions.eq(prototype.name(), "Joe Doe" ) );
+ }
+
+ @Override
+ @UnitOfWorkPropagation
+ public void when()
+ throws Exception
+ {
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ query = uow.newQuery( builder );
+ }
+
+ @Override
+ public void expect()
+ throws Exception
+ {
+ assertThat( query.count(), equalTo(1) );
+ Male male = query.find();
+ assertThat( male.title().get(), equalTo( Person.Title.MR ));
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
new file mode 100644
index 0000000..01011db
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite1Module.java
@@ -0,0 +1,40 @@
+/*
+ * 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.test.indexing.layered;
+
+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;
+
+class TestSuite1Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( TestCase.class ).withMixins( TestCase1.class );
+ module.services( TestCase.class ).withMixins( TestCase2.class );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
new file mode 100644
index 0000000..3d8a9e6
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite2Module.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered;
+
+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;
+
+class TestSuite2Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
new file mode 100644
index 0000000..2c41329
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/TestSuite3Module.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.indexing.layered;
+
+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;
+
+class TestSuite3Module
+ implements ModuleAssembler
+{
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
index 9ab3410..1d5c03a 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Address.java
@@ -21,7 +21,6 @@ import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
public interface Address
- extends ValueComposite
{
Property<String> line1();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Cat.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Cat.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Cat.java
index 7724170..81b4a7a 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Cat.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Cat.java
@@ -20,7 +20,6 @@ package org.apache.zest.test.indexing.model;
/**
* JAVADOC Add JavaDoc
*/
-public interface Cat
- extends Pet
+public interface Cat extends Pet
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/City.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/City.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/City.java
index 6c43294..5084add 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/City.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/City.java
@@ -22,8 +22,7 @@ import org.apache.zest.api.property.Property;
/**
* JAVADOC Add JavaDoc
*/
-public interface City
- extends Nameable
+public interface City extends Nameable
{
Property<String> country();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Dog.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Dog.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Dog.java
index 620b66d..0792416 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Dog.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Dog.java
@@ -20,7 +20,6 @@ package org.apache.zest.test.indexing.model;
/**
* JAVADOC Add JavaDoc
*/
-public interface Dog
- extends Pet
+public interface Dog extends Pet
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Domain.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Domain.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Domain.java
index f15f3e9..64512ef 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Domain.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Domain.java
@@ -22,8 +22,7 @@ import org.apache.zest.api.property.Property;
/**
* JAVADOC Add JavaDoc
*/
-public interface Domain
- extends Nameable
+public interface Domain extends Nameable
{
Property<String> description();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Female.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Female.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Female.java
index e4e7ca8..da8f0ce 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Female.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Female.java
@@ -23,8 +23,7 @@ import org.apache.zest.api.common.Optional;
/**
* JAVADOC Add JavaDoc
*/
-public interface Female
- extends Person
+public interface Female extends Person
{
@Optional
Association<Male> husband();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/File.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/File.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/File.java
index 552eddd..90077da 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/File.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/File.java
@@ -26,7 +26,6 @@ import org.apache.zest.api.value.ValueComposite;
*/
@Queryable( false )
public interface File
- extends ValueComposite
{
Property<String> value();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Host.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Host.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Host.java
index 555a173..5414f99 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Host.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Host.java
@@ -24,7 +24,6 @@ import org.apache.zest.api.value.ValueComposite;
* JAVADOC Add JavaDoc.
*/
public interface Host
- extends ValueComposite
{
Property<String> value();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Male.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Male.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Male.java
index a02b03e..c87f8d8 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Male.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Male.java
@@ -23,8 +23,7 @@ import org.apache.zest.api.common.Optional;
/**
* JAVADOC Add JavaDoc
*/
-public interface Male
- extends Person
+public interface Male extends Person
{
@Optional
Association<Female> wife();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Port.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Port.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Port.java
index 242dd82..aa2afb2 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Port.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Port.java
@@ -25,7 +25,6 @@ import org.apache.zest.api.value.ValueComposite;
* JAVADOC Add JavaDoc.
*/
public interface Port
- extends ValueComposite
{
@Queryable( false )
Property<Integer> value();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Protocol.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Protocol.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Protocol.java
index 04e2d1e..8e6735c 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Protocol.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Protocol.java
@@ -24,7 +24,6 @@ import org.apache.zest.api.value.ValueComposite;
* JAVADOC Add JavaDoc.
*/
public interface Protocol
- extends ValueComposite
{
Property<String> value();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/QueryParam.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/QueryParam.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/QueryParam.java
index 3f39f63..028238d 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/QueryParam.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/QueryParam.java
@@ -24,7 +24,6 @@ import org.apache.zest.api.value.ValueComposite;
* JAVADOC Add JavaDoc.
*/
public interface QueryParam
- extends ValueComposite
{
Property<String> name();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5d2a62be/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/URL.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/URL.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/URL.java
index 1cab264..44599c1 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/URL.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/URL.java
@@ -27,7 +27,6 @@ import org.apache.zest.api.value.ValueComposite;
* JAVADOC Add JavaDoc.
*/
public interface URL
- extends ValueComposite
{
Property<Protocol> protocol();
[09/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java
index bae6c61..55662db 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.zest.runtime.visibility;
-import org.junit.Test;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
@@ -25,17 +24,18 @@ import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.bootstrap.ApplicationAssembler;
import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+import org.junit.Test;
public class VisibilityInUnitOfWorkTest
{
@@ -60,19 +60,19 @@ public class VisibilityInUnitOfWorkTest
implements YourService
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void create()
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
YourEntity entity = uow.newEntity( YourEntity.class, "345" );
}
@Override
public YourEntity get()
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
return uow.get( YourEntity.class, "345" );
}
}
@@ -114,12 +114,12 @@ public class VisibilityInUnitOfWorkTest
private YourService service;
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public void create()
{
- try (UnitOfWork uow = module.newUnitOfWork())
+ try (UnitOfWork uow = uowf.newUnitOfWork())
{
uow.newEntity( MyEntity.class, "123" );
MyEntity entity1 = uow.get( MyEntity.class, "123" );
@@ -134,26 +134,25 @@ public class VisibilityInUnitOfWorkTest
throws AssemblyException
{
Energy4Java zest = new Energy4Java();
- return zest.newApplication( new ApplicationAssembler()
- {
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
- throws AssemblyException
- {
- ApplicationAssembly appAssembly = appFactory.newApplicationAssembly();
- LayerAssembly layer1 = appAssembly.layer( "layer1" );
- ModuleAssembly myModule = layer1.module( "My Module" );
- ModuleAssembly yourModule = layer1.module( "Your Module" );
- ModuleAssembly infraModule = layer1.module( "Infra Module" );
- myModule.services( MyService.class );
- myModule.entities( MyEntity.class );
- yourModule.entities( YourEntity.class );
- yourModule.services( YourService.class ).visibleIn( Visibility.layer );
- infraModule.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer );
- infraModule.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );
- infraModule.services( OrgJsonValueSerializationService.class ).visibleIn( Visibility.layer).taggedWith( ValueSerialization.Formats.JSON );
- return appAssembly;
- }
+ return zest.newApplication( appFactory -> {
+ ApplicationAssembly appAssembly = appFactory.newApplicationAssembly();
+ LayerAssembly layer1 = appAssembly.layer( "layer1" );
+ ModuleAssembly myModule = layer1.module( "My Module" );
+ ModuleAssembly yourModule = layer1.module( "Your Module" );
+ ModuleAssembly infraModule = layer1.module( "Infra Module" );
+ myModule.services( MyService.class );
+ myModule.entities( MyEntity.class );
+ new DefaultUnitOfWorkAssembler().assemble( myModule );
+ yourModule.entities( YourEntity.class );
+ yourModule.services( YourService.class ).visibleIn( Visibility.layer );
+ new DefaultUnitOfWorkAssembler().assemble( yourModule );
+ infraModule.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer );
+ infraModule.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );
+ infraModule.services( OrgJsonValueSerializationService.class )
+ .visibleIn( Visibility.layer )
+ .taggedWith( ValueSerialization.Formats.JSON );
+ new DefaultUnitOfWorkAssembler().assemble( infraModule );
+ return appAssembly;
} );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index ef78cce..8dedcfd 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -58,7 +58,7 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONException;
import org.json.JSONObject;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
index ec001b1..d553437 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -55,7 +55,7 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONArray;
import org.json.JSONException;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java
deleted file mode 100644
index 4445697..0000000
--- a/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java
+++ /dev/null
@@ -1,107 +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.zest.spi.module;
-
-import java.util.function.Function;
-import org.apache.zest.api.composite.ModelDescriptor;
-
-/**
- * TODO
- */
-public class ModelModule<T extends ModelDescriptor>
-{
-
- public static Function<ModelModule<?>, String> toStringFunction = item -> item.model()
- .types()
- .iterator()
- .next()
- .getName() + "[" + item.module().name() + "]";
-
- public static <T extends ModelDescriptor> Function<T, ModelModule<T>> modelModuleFunction( final ModuleSpi module )
- {
- return model1 -> new ModelModule<>( module, model1 );
- }
-
- public static Function<ModelModule<? extends ModelDescriptor>, ModelDescriptor> modelFunction()
- {
- return new Function<ModelModule<? extends ModelDescriptor>, ModelDescriptor>()
- {
- @Override
- public ModelDescriptor apply( ModelModule<? extends ModelDescriptor> modelModule )
- {
- return modelModule.model();
- }
- };
- }
-
- private final ModuleSpi module;
- private final T model;
-
- public ModelModule( ModuleSpi module, T model )
- {
- this.module = module;
- this.model = model;
- }
-
- public ModuleSpi module()
- {
- return module;
- }
-
- public T model()
- {
- return model;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if( this == o )
- {
- return true;
- }
- if( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- ModelModule that = (ModelModule) o;
-
- if( model != null ? !model.equals( that.model ) : that.model != null )
- {
- return false;
- }
-
- return !( module != null ? !module.equals( that.module ) : that.module != null );
- }
-
- @Override
- public int hashCode()
- {
- int result = module != null ? module.hashCode() : 0;
- result = 31 * result + ( model != null ? model.hashCode() : 0 );
- return result;
- }
-
- @Override
- public String toString()
- {
- return module.name() + ":" + model;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
index 3057b05..cb5208c 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
@@ -19,7 +19,10 @@ package org.apache.zest.spi.module;
import java.util.stream.Stream;
import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.entity.IdentityGenerator;
+import org.apache.zest.api.metrics.MetricsProvider;
import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.spi.structure.TypeLookup;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.spi.entitystore.EntityStore;
@@ -41,4 +44,8 @@ public interface ModuleSpi extends Module
Stream<ModelModule<? extends ModelDescriptor>> findVisibleObjectTypes();
Stream<ServiceReference<?>> findVisibleServiceTypes();
+
+ TypeLookup typeLookup();
+
+ MetricsProvider metricsProvider();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java b/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
new file mode 100644
index 0000000..6b584ae
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java
@@ -0,0 +1,107 @@
+/*
+ * 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.spi.structure;
+
+import java.util.function.Function;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.spi.module.ModuleSpi;
+
+/**
+ * TODO
+ */
+public class ModelModule<T extends ModelDescriptor>
+{
+
+ public static Function<ModelModule<?>, String> toStringFunction = item -> item.model()
+ .types()
+ .iterator()
+ .next()
+ .getName() + "[" + item.module()
+ .name() + "]";
+
+ public static <T extends ModelDescriptor> Function<T, ModelModule<T>> modelModuleFunction( final ModuleSpi module )
+ {
+ return model1 -> new ModelModule<>( module, model1 );
+ }
+
+ public static Function<ModelModule<? extends ModelDescriptor>, ModelDescriptor> modelFunction()
+ {
+ return modelModule -> {
+ return modelModule.model();
+ };
+ }
+
+ private final ModuleSpi module;
+ private final T model;
+
+ public ModelModule( ModuleSpi module, T model )
+ {
+ this.module = module;
+ this.model = model;
+ }
+
+ public ModuleSpi module()
+ {
+ return module;
+ }
+
+ public T model()
+ {
+ return model;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if( this == o )
+ {
+ return true;
+ }
+ if( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ ModelModule that = (ModelModule) o;
+
+ //noinspection SimplifiableIfStatement
+ if( model != null ? !model.equals( that.model ) : that.model != null )
+ {
+ return false;
+ }
+
+ return !( module != null ? !module.equals( that.module ) : that.module != null );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = module != null ? module.hashCode() : 0;
+ result = 31 * result + ( model != null ? model.hashCode() : 0 );
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return module.name() + ":" + model;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java b/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
new file mode 100644
index 0000000..94e0473
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java
@@ -0,0 +1,125 @@
+/*
+ * 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.spi.structure;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.stream.Stream;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.value.ValueDescriptor;
+
+public interface TypeLookup
+{
+ /**
+ * Lookup first Entity Model matching the given Type.
+ *
+ * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
+ * {@link #lookupEntityModels(Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Entity Model
+ */
+ ModelModule<EntityDescriptor> lookupEntityModel( Class type );
+
+ /**
+ * Lookup all Entity Models matching the given Type.
+ *
+ * <p>Returned Iterable contains, in order, Entity Models that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
+ * {@link #lookupEntityModel(Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return All matching Entity Models
+ */
+ Iterable<ModelModule<EntityDescriptor>> lookupEntityModels( Class type );
+
+ /**
+ * Lookup first ServiceReference matching the given Type.
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p>See {@link #lookupServiceReferences(Type)}.</p>
+ *
+ * @param <T> Service Type
+ * @param serviceType Looked up Type
+ *
+ * @return First matching ServiceReference
+ */
+ <T> ServiceReference<T> lookupServiceReference( Type serviceType );
+
+ /**
+ * Lookup all ServiceReferences matching the given Type.
+ *
+ * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
+ * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param <T> Service Type
+ * @param type Looked up Type
+ *
+ * @return All matching ServiceReferences
+ */
+ <T> List<ServiceReference<T>> lookupServiceReferences( Type type );
+
+ Stream<Class<?>> allVisibleObjects();
+
+ Stream<ModelModule<ObjectDescriptor>> allObjects();
+
+ Stream<ModelModule<TransientDescriptor>> allTransients();
+
+ Stream<ModelModule<ValueDescriptor>> allValues();
+
+ Stream<ModelModule<EntityDescriptor>> allEntities();
+
+ Stream<ServiceReference<?>> allServices();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java
index a035345..456c616 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java
@@ -14,20 +14,19 @@
package org.apache.zest.test;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.ApplicationDescriptor;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
import org.apache.zest.bootstrap.Assembler;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
import org.apache.zest.spi.ZestSPI;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
/**
* Base class for Zest scenario tests. This will create one Zest application per class instead of per test.
@@ -45,6 +44,7 @@ public abstract class AbstractZestScenarioTest
static protected Module module;
static protected Assembler assembler; // Initialize this in static block of subclass
+ private static UnitOfWorkFactory uowf;
@BeforeClass
public static void setUp()
@@ -64,6 +64,7 @@ public abstract class AbstractZestScenarioTest
// Assume only one module
module = application.findModule( "Layer 1", "Module 1" );
+ uowf = module.unitOfWorkFactory();
}
static protected ApplicationDescriptor newApplication()
@@ -71,15 +72,7 @@ public abstract class AbstractZestScenarioTest
{
final Assembler asm = assembler;
- ApplicationAssembler assembler = new ApplicationAssembler()
- {
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
- {
- return applicationFactory.newApplicationAssembly( asm );
- }
- };
+ ApplicationAssembler assembler = applicationFactory -> applicationFactory.newApplicationAssembly( asm );
try
{
return zest.newApplicationModel( assembler );
@@ -116,11 +109,11 @@ public abstract class AbstractZestScenarioTest
public void tearDown()
throws Exception
{
- if( module != null && module.isUnitOfWorkActive() )
+ if( uowf != null && uowf.isUnitOfWorkActive() )
{
- while( module.isUnitOfWorkActive() )
+ while( uowf.isUnitOfWorkActive() )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow.isOpen() )
{
uow.discard();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
index 8f2fb96..29c27aa 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
@@ -14,6 +14,9 @@
package org.apache.zest.test;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -30,6 +33,9 @@ import org.apache.zest.spi.module.ModuleSpi;
public abstract class AbstractZestTest extends AbstractZestBaseTest
implements Assembler
{
+ @Structure
+ protected UnitOfWorkFactory uowf;
+
protected ModuleSpi module;
@Before
@@ -52,6 +58,7 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
{
LayerAssembly layer = applicationAssembly.layer( "Layer 1" );
ModuleAssembly module = layer.module( "Module 1" );
+ new DefaultUnitOfWorkAssembler().assemble( module );
module.objects( AbstractZestTest.this.getClass() );
assemble( module );
}
@@ -61,11 +68,11 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
public void tearDown()
throws Exception
{
- if( module != null && module.isUnitOfWorkActive() )
+ if( uowf != null && uowf.isUnitOfWorkActive() )
{
- while( module.isUnitOfWorkActive() )
+ while( uowf.isUnitOfWorkActive() )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
if( uow.isOpen() )
{
System.err.println( "UnitOfWork not cleaned up:" + uow.usecase().name() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
index ab05212..e697375 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
@@ -121,5 +121,4 @@ public abstract class AbstractCachePoolTest
cache = cachePool.fetchCache( "1", String.class );
assertNull( "Value not missing", cache.get( "Habba" ) );
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index af74176..de6956d 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -155,14 +155,14 @@ public abstract class AbstractEntityStoreTest
public void whenNewEntityThenCanFindEntityAndCorrectValues()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
TestEntity instance = createEntity( unitOfWork );
unitOfWork.complete();
// Find entity
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
instance = unitOfWork.get( instance );
// Check state
@@ -276,19 +276,19 @@ public abstract class AbstractEntityStoreTest
public void whenRemovedEntityThenCannotFindEntity()
throws Exception
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
TestEntity newInstance = createEntity( unitOfWork );
String identity = newInstance.identity().get();
unitOfWork.complete();
// Remove entity
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
TestEntity instance = unitOfWork.get( newInstance );
unitOfWork.remove( instance );
unitOfWork.complete();
// Find entity
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
try
{
unitOfWork.get( TestEntity.class, identity );
@@ -311,21 +311,21 @@ public abstract class AbstractEntityStoreTest
TestEntity testEntity;
String version;
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
testEntity = builder.newInstance();
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
version = spi.entityStateOf( testEntity ).version();
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
String newVersion = spi.entityStateOf( testEntity ).version();
assertThat( "version has not changed", newVersion, equalTo( version ) );
@@ -341,14 +341,14 @@ public abstract class AbstractEntityStoreTest
TestEntity testEntity;
String version;
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
testEntity = builder.newInstance();
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
testEntity.name().set( "Rickard" );
version = spi.entityStateOf( testEntity ).version();
@@ -356,7 +356,7 @@ public abstract class AbstractEntityStoreTest
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
String newVersion = spi.entityStateOf( testEntity ).version();
assertThat( "version has changed", newVersion, not( equalTo( version ) ) );
@@ -372,14 +372,14 @@ public abstract class AbstractEntityStoreTest
TestEntity testEntity;
String version;
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
testEntity = builder.newInstance();
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
testEntity.manyAssociation().add( 0, testEntity );
version = spi.entityStateOf( testEntity ).version();
@@ -387,7 +387,7 @@ public abstract class AbstractEntityStoreTest
unitOfWork.complete();
}
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
testEntity = unitOfWork.get( testEntity );
String newVersion = spi.entityStateOf( testEntity ).version();
assertThat( "version has changed", newVersion, not( equalTo( version ) ) );
@@ -402,7 +402,7 @@ public abstract class AbstractEntityStoreTest
{
TestEntity testEntity;
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
testEntity = builder.newInstance();
@@ -414,7 +414,7 @@ public abstract class AbstractEntityStoreTest
String version;
{
// Start working with Entity in one UoW
- unitOfWork1 = module.newUnitOfWork();
+ unitOfWork1 = uowf.newUnitOfWork();
testEntity1 = unitOfWork1.get( testEntity );
version = spi.entityStateOf( testEntity1 ).version();
if( version.isEmpty() )
@@ -427,7 +427,7 @@ public abstract class AbstractEntityStoreTest
}
{
// Start working with same Entity in another UoW, and complete it
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
TestEntity testEntity2 = unitOfWork.get( testEntity );
assertThat( "version is correct", spi.entityStateOf( testEntity1 ).version(), equalTo( version ) );
testEntity2.name().set( "B" );
@@ -447,7 +447,7 @@ public abstract class AbstractEntityStoreTest
}
{
// Check values
- unitOfWork1 = module.newUnitOfWork();
+ unitOfWork1 = uowf.newUnitOfWork();
testEntity1 = unitOfWork1.get( testEntity );
assertThat( "property name has not been set", testEntity1.name().get(), equalTo( "B" ) );
assertThat( "version is incorrect", spi.entityStateOf( testEntity1 ).version(),
@@ -460,19 +460,19 @@ public abstract class AbstractEntityStoreTest
public void givenEntityStoredLoadedChangedWhenUnitOfWorkDiscardsThenDontStoreState()
throws UnitOfWorkCompletionException
{
- UnitOfWork unitOfWork = module.newUnitOfWork();
+ UnitOfWork unitOfWork = uowf.newUnitOfWork();
try
{
String identity = createEntity( unitOfWork ).identity().get();
unitOfWork.complete();
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
TestEntity entity = unitOfWork.get( TestEntity.class, identity );
assertThat( entity.intValue().get(), is( 42 ) );
entity.intValue().set( 23 );
unitOfWork.discard();
- unitOfWork = module.newUnitOfWork();
+ unitOfWork = uowf.newUnitOfWork();
entity = unitOfWork.get( TestEntity.class, identity );
assertThat( entity.intValue().get(), is( 42 ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
index de7676e..e9c18b5 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
@@ -82,7 +82,7 @@ public class AbstractAnyQueryTest
super.setUp();
TestData.populate( module );
- this.unitOfWork = this.module.newUnitOfWork();
+ this.unitOfWork = this.module.unitOfWorkFactory().newUnitOfWork();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index b07055e..48cd6b5 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -22,10 +22,6 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import org.apache.zest.test.indexing.model.Dog;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -42,6 +38,9 @@ import org.apache.zest.test.indexing.model.Person;
import org.apache.zest.test.indexing.model.Protocol;
import org.apache.zest.test.indexing.model.QueryParam;
import org.apache.zest.test.indexing.model.URL;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
import static org.joda.time.DateTimeZone.UTC;
@@ -53,7 +52,7 @@ public class TestData
public static void populate( Module module )
throws UnitOfWorkCompletionException
{
- try( UnitOfWork unitOfWork = module.newUnitOfWork() )
+ try (UnitOfWork unitOfWork = module.unitOfWorkFactory().newUnitOfWork())
{
NameableAssert.clear();
Domain gaming;
@@ -240,12 +239,6 @@ public class TestData
felix.name().set( "Felix" );
catBuilder.newInstance();
}
- {
- EntityBuilder<Dog> builder = unitOfWork.newEntityBuilder( Dog.class );
- Dog snoopy = builder.instance();
- snoopy.name().set( "Snoopy" );
- builder.newInstance();
- }
unitOfWork.complete();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
index d398e6f..567056a 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
@@ -43,6 +43,7 @@ class AccountModule
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer );
module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class )
.visibleIn( Visibility.layer );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
index ecd4939..66cc1c2 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
@@ -35,6 +35,7 @@ class ConfigModule
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
return module;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
index 9e24b3f..74562bf 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
@@ -41,6 +41,7 @@ class FamilyModule
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.entities( Male.class,
Female.class,
City.class,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
index b6ae1e7..b6f785a 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
@@ -37,6 +37,7 @@ class PersistenceModule
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
return module;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
index bf3fe2b..a21b168 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
@@ -40,6 +40,7 @@ public class TestExecutionModule
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.objects( testClass ).visibleIn( Visibility.layer );
return module;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
index efcb64b..bd7b015 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
@@ -37,6 +37,7 @@ class TestSuite1Module
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
declareTestCase( module, Suite1Case1.class );
declareTestCase( module, Suite1Case2.class );
return module;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
index ac3f655..b7560b6 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
@@ -33,6 +33,7 @@ class TestSuite2Module
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
return module;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
index f93ddf7..163cbbb 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
@@ -33,6 +33,7 @@ class TestSuite3Module
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
return module;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
index 4920ebd..7ff7406 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
@@ -92,7 +92,7 @@ public abstract class AbstractValueCompositeSerializationTest
public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
SomeValue some = buildSomeValue();
@@ -214,7 +214,7 @@ public abstract class AbstractValueCompositeSerializationTest
private BarEntity buildBarEntity( String cathedral )
{
- EntityBuilder<BarEntity> barBuilder = module.currentUnitOfWork().newEntityBuilder( BarEntity.class );
+ EntityBuilder<BarEntity> barBuilder = uowf.currentUnitOfWork().newEntityBuilder( BarEntity.class );
barBuilder.instance().cathedral().set( cathedral );
return barBuilder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
index 2c833e0..f34fdd4 100755
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -67,7 +67,7 @@ import org.apache.zest.spi.entitystore.EntityStoreSPI;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.entitystore.StateCommitter;
import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
index cd8faec..95ce3fe 100755
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -68,7 +68,7 @@ import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
import org.apache.zest.spi.entitystore.helpers.JSONKeys;
import org.apache.zest.spi.entitystore.helpers.Migration;
import org.apache.zest.spi.entitystore.helpers.StateStore;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
import org.json.JSONArray;
import org.json.JSONException;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
index c47bb9e..c33ddd0 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
@@ -75,7 +75,7 @@ public class DerbySQLEntityStoreTest
public void tearDown()
throws Exception
{
- UnitOfWork uow = this.module.newUnitOfWork( UsecaseBuilder.newUsecase(
+ UnitOfWork uow = this.uowf.newUnitOfWork( UsecaseBuilder.newUsecase(
"Delete " + getClass().getSimpleName() + " test data" ) );
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
index 7788b71..cb263ec 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
@@ -86,7 +86,7 @@ public class MySQLEntityStoreTest
{
return;
}
- UnitOfWork uow = this.module.newUnitOfWork(
+ UnitOfWork uow = this.uowf.newUnitOfWork(
UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" )
);
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
index 27e93f5..5504e36 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
@@ -112,7 +112,7 @@ public class PostgreSQLEntityStoreTest
public void tearDown()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork(
+ UnitOfWork uow = uowf.newUnitOfWork(
UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" )
);
try
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
index 6e50400..edd2652 100755
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
@@ -25,6 +25,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
import org.apache.zest.library.fileconfig.FileConfigurationOverride;
import org.apache.zest.library.fileconfig.FileConfigurationService;
@@ -46,6 +47,7 @@ public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest
module = module.layer().module( "module2" );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module );
+ new DefaultUnitOfWorkAssembler().assemble( module );
// Config module
LayerAssembly configLayer = module.layer().application().layer( "config" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
index f5efe83..6bf8c83 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
@@ -159,7 +159,7 @@ public class ElasticSearchTest
{
String title = "Foo Bar Bazar!";
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
EntityBuilder<Author> authorBuilder = uow.newEntityBuilder( Author.class );
Author author = authorBuilder.instance();
@@ -199,7 +199,7 @@ public class ElasticSearchTest
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
QueryBuilder<Post> queryBuilder = module.newQueryBuilder( Post.class );
Query<Post> query = uow.newQuery( queryBuilder );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
index 9947de2..b6b41f1 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
@@ -117,18 +117,18 @@ public class ImmenseTermTest
{
long count = 10_000L;
TestEntity testEntity;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testEntity = uow.newEntity( TestEntity.class );
for( long i = 0; i < count; i++ )
{
- TestEntity2 testEntity2 = module.currentUnitOfWork().newEntity( TestEntity2.class );
+ TestEntity2 testEntity2 = uowf.currentUnitOfWork().newEntity( TestEntity2.class );
testEntity2.property().set( "test" );
testEntity.manyAssociation().add( testEntity2 );
}
uow.complete();
}
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
testEntity = uow.get( testEntity );
Query<TestEntity2> query = uow.newQuery(
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
index 5a166c8..c0092a1 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
@@ -312,7 +312,7 @@ public class ContainsAllTest
builder = builder.where( QueryExpressions.containsAll(
QueryExpressions.templateFor( ExampleEntity.class ).strings(),
Iterables.iterable( strings ) ) );
- return this.module.currentUnitOfWork().newQuery( builder ).find();
+ return this.uowf.currentUnitOfWork().newQuery( builder ).find();
}
private ExampleEntity findEntityBasedOnValueStrings( String... valueStrings )
@@ -340,18 +340,18 @@ public class ContainsAllTest
)
);
- return this.module.currentUnitOfWork().newQuery( builder );
+ return this.uowf.currentUnitOfWork().newQuery( builder );
}
private ExampleEntity performContainsAllStringsTest( Set<String> entityStrings, Set<String> queryableStrings )
throws Exception
{
- UnitOfWork creatingUOW = this.module.newUnitOfWork();
+ UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
createEntityWithStrings( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
creatingUOW.complete();
- UnitOfWork queryingUOW = this.module.newUnitOfWork();
+ UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
try
{
String[] queryableStringsArray = new String[queryableStrings.size()];
@@ -367,12 +367,12 @@ public class ContainsAllTest
private ExampleEntity performContainsAllStringValueTest( Set<String> entityStrings, Set<String> queryableStrings )
throws Exception
{
- UnitOfWork creatingUOW = this.module.newUnitOfWork();
+ UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
createEntityWithComplexValues( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
creatingUOW.complete();
- UnitOfWork queryingUOW = this.module.newUnitOfWork();
+ UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
try
{
String[] queryableStringsArray = new String[queryableStrings.size()];
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
index 3d0ab4a..9fd4e54 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
@@ -143,7 +143,7 @@ public class ContainsTest extends AbstractZestTest
string
)
);
- return this.module.currentUnitOfWork().newQuery( builder ).find();
+ return this.uowf.currentUnitOfWork().newQuery( builder ).find();
}
@@ -167,17 +167,17 @@ public class ContainsTest extends AbstractZestTest
)
);
- return this.module.currentUnitOfWork().newQuery( builder);
+ return this.uowf.currentUnitOfWork().newQuery( builder);
}
private ExampleEntity performContainsStringTest(Set<String> entityStrings, String queryableString) throws Exception
{
- UnitOfWork creatingUOW = this.module.newUnitOfWork();
+ UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
ContainsAllTest.createEntityWithStrings(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
- UnitOfWork queryingUOW = this.module.newUnitOfWork();
+ UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
try
{
ExampleEntity entity = this.findEntity(queryableString);
@@ -191,12 +191,12 @@ public class ContainsTest extends AbstractZestTest
private ExampleEntity performContainsStringValueTest(Set<String> entityStrings, String queryableString) throws Exception
{
- UnitOfWork creatingUOW = this.module.newUnitOfWork();
+ UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
String[] entityStringsArray = new String[entityStrings.size()];
ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
creatingUOW.complete();
- UnitOfWork queryingUOW = this.module.newUnitOfWork();
+ UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
try
{
ExampleEntity entity = this.findEntityBasedOnValueString(queryableString);
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
index 7923b75..cd8aeae 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
@@ -42,7 +42,8 @@ public class MultiLayeredTest extends AbstractMultiLayeredIndexingTest
public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
throws AssemblyException
{
- new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( module );
+ module.withDefaultUnitOfWorkFactory();
+ new RdfMemoryStoreAssembler( Visibility.application, Visibility.module ).assemble( module );
return module;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
index f051935..c005360 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
@@ -89,7 +89,7 @@ public class RDFPerformanceTest extends AbstractZestTest
List<ExampleEntity> entities = new ArrayList<ExampleEntity>();
for (Integer x = 0; x < howMany; ++x)
{
- ExampleEntity exampleEntity = this.module.currentUnitOfWork().newEntity( ExampleEntity.class, "entity" + x );
+ ExampleEntity exampleEntity = this.uowf.currentUnitOfWork().newEntity( ExampleEntity.class, "entity" + x );
for (ExampleEntity entity : entities)
{
@@ -110,14 +110,14 @@ public class RDFPerformanceTest extends AbstractZestTest
{
for (ExampleEntity entity : entities)
{
- this.module.currentUnitOfWork().remove( this.module.currentUnitOfWork().get( entity ) );
+ this.uowf.currentUnitOfWork().remove( this.uowf.currentUnitOfWork().get( entity ) );
}
}
private List<ExampleEntity> doList( int howMany )
{
List<ExampleEntity> list = new ArrayList<ExampleEntity>();
- UnitOfWork uow = this.module.newUnitOfWork();
+ UnitOfWork uow = this.uowf.newUnitOfWork();
Iterator<ExampleEntity> iter = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ) ).iterator();
int found = 0;
while (iter.hasNext())
@@ -141,11 +141,11 @@ public class RDFPerformanceTest extends AbstractZestTest
private void doRemove( int howMany )
{
- Iterator<ExampleEntity> iter = this.module.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
+ Iterator<ExampleEntity> iter = this.uowf.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
Integer removed = 0;
while (iter.hasNext())
{
- this.module.currentUnitOfWork().remove( iter.next() );
+ this.uowf.currentUnitOfWork().remove( iter.next() );
++removed;
}
@@ -159,7 +159,7 @@ public class RDFPerformanceTest extends AbstractZestTest
{
long startTest = System.currentTimeMillis();
- UnitOfWork creatingUOW = this.module.newUnitOfWork();
+ UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
Long startingTime = System.currentTimeMillis();
List<ExampleEntity> entities = this.doCreate( howMany );
LOG.info( "Time to create " + howMany + " entities (ms): " + (System.currentTimeMillis() - startingTime) );
@@ -172,7 +172,7 @@ public class RDFPerformanceTest extends AbstractZestTest
List<ExampleEntity> entityList = this.doList( howMany );
startingTime = System.currentTimeMillis();
- UnitOfWork uow = this.module.newUnitOfWork();
+ UnitOfWork uow = this.uowf.newUnitOfWork();
for (int i = 0; i < 1000; i++)
{
Query<ExampleEntity> query = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ).
@@ -183,7 +183,7 @@ public class RDFPerformanceTest extends AbstractZestTest
long endTest = System.currentTimeMillis();
LOG.info( "Time to query " + howMany + " entities (ms): " + (endTest - startingTime) );
- UnitOfWork deletingUOW = this.module.newUnitOfWork();
+ UnitOfWork deletingUOW = this.uowf.newUnitOfWork();
startingTime = System.currentTimeMillis();
this.doRemoveAll( entityList );
// this.doRemove(200);
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
index d0b1d19..e1434f9 100755
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
@@ -24,6 +24,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
import org.apache.zest.test.EntityTestAssembler;
@@ -39,10 +40,12 @@ public class RdfNamedQueryMultimoduleTest
assembleValues( module, Visibility.module );
ModuleAssembly storeModule = layer.module( "store" );
+ new DefaultUnitOfWorkAssembler().assemble( storeModule );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule );
assembleValues( storeModule, Visibility.module );
ModuleAssembly indexModule = layer.module( "index" );
+ new DefaultUnitOfWorkAssembler().assemble( indexModule );
new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( indexModule );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
index d25f79a..390818e 100755
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
@@ -25,6 +25,7 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.LayerAssembly;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;
import org.apache.zest.library.rdf.repository.NativeConfiguration;
import org.apache.zest.test.EntityTestAssembler;
@@ -49,9 +50,11 @@ public class RdfQueryMultimoduleTest
ModuleAssembly storeModule = layer.module( "store" );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule );
assembleValues( storeModule, Visibility.module );
+ new DefaultUnitOfWorkAssembler().assemble( storeModule );
ModuleAssembly indexModule = layer.module( "index" );
new RdfNativeSesameStoreAssembler( Visibility.layer, Visibility.module ).assemble( indexModule );
+ new DefaultUnitOfWorkAssembler().assemble( indexModule );
LayerAssembly configLayer = module.layer().application().layer( "config" );
module.layer().uses( configLayer );
@@ -59,6 +62,7 @@ public class RdfQueryMultimoduleTest
config.entities( NativeConfiguration.class ).visibleIn( Visibility.application );
config.forMixin( NativeConfiguration.class ).declareDefaults().dataDirectory().set( DATA_DIR.getAbsolutePath() );
new EntityTestAssembler().assemble( config );
+ new DefaultUnitOfWorkAssembler().assemble( config );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
index 867a3a4..4469b75 100755
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
@@ -22,6 +22,7 @@ import java.io.File;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;
import org.apache.zest.library.rdf.repository.NativeConfiguration;
import org.apache.zest.spi.query.EntityFinderException;
@@ -51,6 +52,7 @@ public class RdfQueryTest
config.entities( NativeConfiguration.class ).visibleIn( Visibility.layer );
config.forMixin( NativeConfiguration.class ).declareDefaults().dataDirectory().set( DATA_DIR.getAbsolutePath() );
new EntityTestAssembler().assemble( config );
+ new DefaultUnitOfWorkAssembler().assemble( config );
}
@Test
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
index 009a5cd..1d83240 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
@@ -52,7 +52,7 @@ public class Qi173IssueTest
@Test
public void testPersistence()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
createCar( "Volvo", "S80", 2007 );
@@ -73,7 +73,7 @@ public class Qi173IssueTest
e.printStackTrace();
}
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
QueryBuilder<Car> qb = module.newQueryBuilder( Car.class );
Car template = QueryExpressions.templateFor( Car.class );
qb = qb.where( QueryExpressions.eq( template.year(), 2007 ) );
@@ -104,7 +104,7 @@ public class Qi173IssueTest
private String createCar( String manufacturer, String model, int year )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Car> builder = uow.newEntityBuilder( Car.class );
Car prototype = builder.instanceFor( Car.class );
prototype.manufacturer().set( manufacturer );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java
index f09d95c..b9402ec 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java
@@ -41,7 +41,7 @@ public abstract class AbstractIssueTest
protected final String newZestAccount()
throws UnitOfWorkCompletionException
{
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
EntityBuilder<AccountComposite> entityBuilder = work.newEntityBuilder( AccountComposite.class );
AccountComposite accountComposite = entityBuilder.instance();
accountComposite.name().set( DEFAULT_ACCOUNT_NAME );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
index f39421d..ed7c460 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
@@ -53,7 +53,7 @@ public final class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertNull( module.currentUnitOfWork() );
+ assertNull( uowf.currentUnitOfWork() );
accountService.getAccountById( id );
}
@@ -66,14 +66,14 @@ public final class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
- UnitOfWork parentUnitOfWork = module.newUnitOfWork();
+ UnitOfWork parentUnitOfWork = uowf.newUnitOfWork();
AccountComposite account = accountService.getAccountById( id );
assertNotNull( account );
- UnitOfWork currentUnitOfWork = module.currentUnitOfWork();
+ UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork();
assertEquals( parentUnitOfWork, currentUnitOfWork );
assertTrue( currentUnitOfWork.isOpen() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
index 40f692a..23a1d8b 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
@@ -49,12 +49,12 @@ public final class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
AccountComposite account = accountService.getAccountById( id );
assertNotNull( account );
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
}
@Test
@@ -65,14 +65,14 @@ public final class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
- UnitOfWork parentUnitOfWork = module.newUnitOfWork();
+ UnitOfWork parentUnitOfWork = uowf.newUnitOfWork();
AccountComposite account = accountService.getAccountById( id );
assertNotNull( account );
- UnitOfWork currentUnitOfWork = module.currentUnitOfWork();
+ UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork();
assertEquals( parentUnitOfWork, currentUnitOfWork );
assertTrue( currentUnitOfWork.isOpen() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
index 18dc869..1675973 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
@@ -49,12 +49,12 @@ public class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
AccountComposite account = accountService.getAccountById( id );
assertNotNull( account );
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
}
@Test
@@ -65,14 +65,14 @@ public class IssueTest
String id = newZestAccount();
// Make sure there's no unit of work
- assertFalse( module.isUnitOfWorkActive() );
+ assertFalse( uowf.isUnitOfWorkActive() );
- UnitOfWork parentUnitOfWork = module.newUnitOfWork();
+ UnitOfWork parentUnitOfWork = uowf.newUnitOfWork();
AccountComposite account = accountService.getAccountById( id );
assertNotNull( account );
- UnitOfWork currentUnitOfWork = module.currentUnitOfWork();
+ UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork();
assertEquals( parentUnitOfWork, currentUnitOfWork );
assertTrue( currentUnitOfWork.isOpen() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java
index f655b32..6904c24 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java
@@ -49,7 +49,7 @@ public class Qi66IssueTest
{
String accountIdentity = newZestAccount();
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
AccountComposite account = work.get( AccountComposite.class, accountIdentity );
assertNotNull( account );
@@ -74,7 +74,7 @@ public class Qi66IssueTest
private String newZestAccount()
throws UnitOfWorkCompletionException
{
- UnitOfWork work = module.newUnitOfWork();
+ UnitOfWork work = uowf.newUnitOfWork();
EntityBuilder<AccountComposite> entityBuilder = work.newEntityBuilder( AccountComposite.class );
AccountComposite accountComposite = entityBuilder.instance();
accountComposite.name().set( ACCOUNT_NAME );
[12/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
index bb9aa65..4bf431f 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
@@ -23,9 +23,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -42,7 +40,6 @@ import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.NoSuchTransientException;
import org.apache.zest.api.composite.TransientBuilder;
import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.entity.IdentityGenerator;
@@ -58,10 +55,8 @@ import org.apache.zest.api.service.NoSuchServiceException;
import org.apache.zest.api.service.ServiceDescriptor;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.util.NullArgumentException;
import org.apache.zest.api.value.NoSuchValueException;
import org.apache.zest.api.value.ValueBuilder;
@@ -73,13 +68,10 @@ import org.apache.zest.runtime.activation.ActivationDelegate;
import org.apache.zest.runtime.composite.FunctionStateResolver;
import org.apache.zest.runtime.composite.StateResolver;
import org.apache.zest.runtime.composite.TransientBuilderInstance;
-import org.apache.zest.runtime.composite.TransientModel;
import org.apache.zest.runtime.composite.TransientStateInstance;
import org.apache.zest.runtime.composite.TransientsModel;
import org.apache.zest.runtime.composite.UsesInstance;
import org.apache.zest.runtime.entity.EntitiesModel;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
import org.apache.zest.runtime.injection.InjectionContext;
import org.apache.zest.runtime.object.ObjectModel;
import org.apache.zest.runtime.object.ObjectsModel;
@@ -90,21 +82,18 @@ import org.apache.zest.runtime.service.ImportedServicesInstance;
import org.apache.zest.runtime.service.ImportedServicesModel;
import org.apache.zest.runtime.service.ServicesInstance;
import org.apache.zest.runtime.service.ServicesModel;
-import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
import org.apache.zest.runtime.value.ValueBuilderInstance;
import org.apache.zest.runtime.value.ValueBuilderWithPrototype;
import org.apache.zest.runtime.value.ValueBuilderWithState;
import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.runtime.value.ValueModel;
import org.apache.zest.runtime.value.ValuesModel;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.metrics.MetricsProviderAdapter;
-import org.apache.zest.spi.module.ModelModule;
import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerialization;
import static java.util.stream.Stream.concat;
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
import static org.apache.zest.api.util.Classes.modelTypeSpecification;
import static org.apache.zest.functional.Iterables.iterable;
import static org.apache.zest.runtime.legacy.Specifications.translate;
@@ -126,15 +115,15 @@ public class ModuleInstance
private final ImportedServicesInstance importedServices;
// Eager instance objects
private final ActivationDelegate activation;
- private final TypeLookup typeLookup;
+ private final TypeLookupImpl typeLookup;
private final QueryBuilderFactory queryBuilderFactory;
private final ClassLoader classLoader;
- private final EntityFunction entityFunction;
// Lazy assigned on accessors
private EntityStore store;
private IdentityGenerator generator;
private ValueSerialization valueSerialization;
private MetricsProvider metrics;
+ private UnitOfWorkFactory uowf;
@SuppressWarnings( "LeakingThisInConstructor" )
public ModuleInstance( ModuleModel moduleModel, LayerInstance layerInstance, TransientsModel transientsModel,
@@ -147,17 +136,16 @@ public class ModuleInstance
layer = layerInstance;
transients = transientsModel;
values = valuesModel;
- objects = objectsModel;
entities = entitiesModel;
services = servicesModel.newInstance( this );
+ objects = objectsModel;
importedServices = importedServicesModel.newInstance( this );
// Eager instance objects
activation = new ActivationDelegate( this );
- typeLookup = new TypeLookup( this );
+ typeLookup = new TypeLookupImpl( this );
queryBuilderFactory = new QueryBuilderFactoryImpl( this );
classLoader = new ModuleClassLoader( this, Thread.currentThread().getContextClassLoader() );
- entityFunction = new EntityFunction( this );
// Activation
services.registerActivationEventListener( activation );
@@ -316,7 +304,7 @@ public class ModuleInstance
}
InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
- return mixinType.cast( ((ObjectModel) modelModule.model()).newInstance( injectionContext ) );
+ return mixinType.cast( ( (ObjectModel) modelModule.model() ).newInstance( injectionContext ) );
}
@Override
@@ -332,7 +320,7 @@ public class ModuleInstance
}
InjectionContext injectionContext = new InjectionContext( modelModule.module(), UsesInstance.EMPTY_USES.use( uses ) );
- ((ObjectModel) modelModule.model()).inject( injectionContext, instance );
+ ( (ObjectModel) modelModule.model() ).inject( injectionContext, instance );
}
// Implementation of TransientBuilderFactory
@@ -352,7 +340,7 @@ public class ModuleInstance
modelModule.model().state().properties().forEach(
propertyModel ->
{
- Property<?> property = new PropertyInstance<>( ((PropertyModel) propertyModel).getBuilderInfo(),
+ Property<?> property = new PropertyInstance<>( ( (PropertyModel) propertyModel ).getBuilderInfo(),
propertyModel.initialValue( modelModule.module() ) );
properties.put( propertyModel.accessor(), property );
} );
@@ -495,57 +483,6 @@ public class ModuleInstance
}
}
- // Implementation of UnitOfWorkFactory
- @Override
- public UnitOfWork newUnitOfWork()
- {
- return newUnitOfWork( Usecase.DEFAULT );
- }
-
- @Override
- public UnitOfWork newUnitOfWork( long currentTime )
- {
- return newUnitOfWork( Usecase.DEFAULT, currentTime );
- }
-
- @Override
- public UnitOfWork newUnitOfWork( Usecase usecase )
- {
- return newUnitOfWork( usecase == null ? Usecase.DEFAULT : usecase, System.currentTimeMillis() );
- }
-
- @Override
- public UnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
- {
- UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( usecase, currentTime, metricsProvider() );
- return new ModuleUnitOfWork( ModuleInstance.this, unitOfWorkInstance );
- }
-
- @Override
- public boolean isUnitOfWorkActive()
- {
- Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
- return !stack.isEmpty();
- }
-
- @Override
- public UnitOfWork currentUnitOfWork()
- {
- Stack<UnitOfWorkInstance> stack = UnitOfWorkInstance.getCurrent();
- if( stack.size() == 0 )
- {
- throw new IllegalStateException( "No current UnitOfWork active" );
- }
- return new ModuleUnitOfWork( ModuleInstance.this, stack.peek() );
- }
-
- @Override
- public UnitOfWork getUnitOfWork( EntityComposite entity )
- {
- EntityInstance instance = EntityInstance.entityInstanceOf( entity );
- return instance.unitOfWork();
- }
-
// Implementation of QueryBuilderFactory
@Override
public <T> QueryBuilder<T> newQueryBuilder( final Class<T> resultType )
@@ -617,42 +554,24 @@ public class ModuleInstance
return layer;
}
- public TypeLookup typeLookup()
+ @Override
+ public TypeLookupImpl typeLookup()
{
return typeLookup;
}
- public BiFunction<EntityReference, Type, Object> getEntityFunction()
- {
- return entityFunction;
- }
-
- private static class EntityFunction
- implements BiFunction<EntityReference, Type, Object>
- {
-
- private final UnitOfWorkFactory uowf;
-
- private EntityFunction( UnitOfWorkFactory uowf )
- {
- this.uowf = uowf;
- }
-
- @Override
- public Object apply( EntityReference entityReference, Type type )
- {
- return uowf.currentUnitOfWork().get( RAW_CLASS.apply( type ), entityReference.identity() );
- }
- }
-
public EntityStore entityStore()
{
synchronized( this )
{
if( store == null )
{
- ServiceReference<EntityStore> service = findService( EntityStore.class );
- if( service == null )
+ ServiceReference<EntityStore> service = null;
+ try
+ {
+ service = findService( EntityStore.class );
+ }
+ catch( NoSuchServiceException e )
{
throw new UnitOfWorkException( "No EntityStore service available in module " + name() );
}
@@ -662,6 +581,27 @@ public class ModuleInstance
return store;
}
+ public UnitOfWorkFactory unitOfWorkFactory()
+ {
+ synchronized( this )
+ {
+ if( uowf == null )
+ {
+ ServiceReference<UnitOfWorkFactory> service = null;
+ try
+ {
+ service = findService( UnitOfWorkFactory.class );
+ }
+ catch( NoSuchServiceException e )
+ {
+ throw new UnitOfWorkException( "No UnitOfWorkFactory service available in module " + name() );
+ }
+ uowf = service.get();
+ }
+ }
+ return uowf;
+ }
+
public IdentityGenerator identityGenerator()
{
synchronized( this )
@@ -695,7 +635,7 @@ public class ModuleInstance
return valueSerialization;
}
- /* package */ MetricsProvider metricsProvider()
+ public MetricsProvider metricsProvider()
{
synchronized( this )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
deleted file mode 100755
index b5303d5..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 2009, Rickard Öberg. All Rights Reserved.
- * Copyright (c) 2013-2015, Niclas Hedhman. All Rights Reserved.
- * Copyright (c) 2013-2015, Paul Merlin. All Rights Reserved.
- *
- * Licensed 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.runtime.structure;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.IdentityGenerator;
-import org.apache.zest.api.entity.LifecycleException;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.property.StateHolder;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryExecutionException;
-import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
-import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.runtime.association.AssociationInstance;
-import org.apache.zest.runtime.association.ManyAssociationInstance;
-import org.apache.zest.runtime.association.NamedAssociationInstance;
-import org.apache.zest.runtime.composite.FunctionStateResolver;
-import org.apache.zest.runtime.entity.EntityInstance;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.property.PropertyModel;
-import org.apache.zest.runtime.unitofwork.EntityBuilderInstance;
-import org.apache.zest.runtime.unitofwork.UnitOfWorkInstance;
-import org.apache.zest.runtime.value.ValueInstance;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.entity.NamedAssociationState;
-import org.apache.zest.spi.entitystore.EntityStore;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.spi.query.EntityFinder;
-import org.apache.zest.spi.query.EntityFinderException;
-import org.apache.zest.spi.query.QueryBuilderSPI;
-import org.apache.zest.spi.query.QuerySource;
-
-import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
-
-/**
- * JAVADOC
- */
-public class ModuleUnitOfWork
- implements UnitOfWork
-{
- private static final QualifiedName IDENTITY_STATE_NAME;
-
- static
- {
- try
- {
- IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
- }
- catch( NoSuchMethodException e )
- {
- throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
- }
- }
-
- private final UnitOfWorkInstance uow;
- private final ModuleInstance module;
-
- ModuleUnitOfWork( ModuleInstance module, UnitOfWorkInstance uow )
- {
- this.module = module;
- this.uow = uow;
- }
-
- public ModuleInstance module()
- {
- return module;
- }
-
- public UnitOfWorkInstance instance()
- {
- return uow;
- }
-
- @Override
- public UnitOfWorkFactory unitOfWorkFactory()
- {
- return module;
- }
-
- @Override
- public long currentTime()
- {
- return uow.currentTime();
- }
-
- @Override
- public Usecase usecase()
- {
- return uow.usecase();
- }
-
- @Override
- public <T> T metaInfo( Class<T> infoType )
- {
- return uow.metaInfo().get( infoType );
- }
-
- @Override
- public void setMetaInfo( Object metaInfo )
- {
- uow.metaInfo().set( metaInfo );
- }
-
- @Override
- @SuppressWarnings( { "raw", "unchecked" } )
- public <T> Query<T> newQuery( QueryBuilder<T> queryBuilder )
- {
- QueryBuilderSPI queryBuilderSPI = (QueryBuilderSPI) queryBuilder;
-
- return queryBuilderSPI.newQuery( new UoWQuerySource( this ) );
- }
-
- @Override
- public <T> T newEntity( Class<T> type )
- throws EntityTypeNotFoundException, LifecycleException
- {
- return newEntity( type, null );
- }
-
- @Override
- public <T> T newEntity( Class<T> type, String identity )
- throws EntityTypeNotFoundException, LifecycleException
- {
- return newEntityBuilder( type, identity ).newInstance();
- }
-
- @Override
- public <T> EntityBuilder<T> newEntityBuilder( Class<T> type )
- throws EntityTypeNotFoundException
- {
- return newEntityBuilder( type, null );
- }
-
- @Override
- public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
- throws EntityTypeNotFoundException
- {
- ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
-
- if( model == null )
- {
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
- }
-
- EntityStore entityStore = model.module().entityStore();
-
- // Generate id if necessary
- if( identity == null )
- {
- IdentityGenerator idGen = model.module().identityGenerator();
- if( idGen == null )
- {
- throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
- }
- identity = idGen.generate( model.model().types().findFirst().orElse( null ) );
- }
- EntityBuilder<T> builder;
-
- builder = new EntityBuilderInstance<>( model,
- this,
- uow.getEntityStoreUnitOfWork( entityStore ),
- identity );
- return builder;
- }
-
- @Override
- public <T> EntityBuilder<T> newEntityBuilderWithState(
- Class<T> type,
- Function<PropertyDescriptor, Object> propertyFunction,
- Function<AssociationDescriptor, EntityReference> associationFunction,
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
- )
- throws EntityTypeNotFoundException
- {
- return newEntityBuilderWithState( type, null,
- propertyFunction,
- associationFunction,
- manyAssociationFunction,
- namedAssociationFunction );
- }
-
- @Override
- public <T> EntityBuilder<T> newEntityBuilderWithState(
- Class<T> type, String identity,
- Function<PropertyDescriptor, Object> propertyFunction,
- Function<AssociationDescriptor, EntityReference> associationFunction,
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssociationFunction
- )
- throws EntityTypeNotFoundException
- {
- NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
- NullArgumentException.validateNotNull( "associationFunction", associationFunction );
- NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
- NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
-
- ModelModule<EntityDescriptor> model = module.typeLookup().lookupEntityModel( type );
-
- if( model == null )
- {
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
- }
-
- EntityStore entityStore = model.module().entityStore();
-
- FunctionStateResolver stateResolver = new FunctionStateResolver(
- propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction
- );
-
- if( identity == null )
- {
- // Use identity from StateResolver if available
- PropertyModel identityModel = (PropertyModel) model.model().state().findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
- identity = (String) stateResolver.getPropertyState( identityModel );
- if( identity == null )
- {
- // Generate identity
- IdentityGenerator idGen = model.module().identityGenerator();
- if( idGen == null )
- {
- throw new NoSuchServiceException( IdentityGenerator.class.getName(), model.module().name() );
- }
- identity = idGen.generate( model.model().types().findFirst().orElse( null ));
- }
- }
-
- return new EntityBuilderInstance<>( model,
- this,
- uow.getEntityStoreUnitOfWork( entityStore ),
- identity,
- stateResolver );
- }
-
- @Override
- public <T> T get( Class<T> type, String identity )
- throws EntityTypeNotFoundException, NoSuchEntityException
- {
- Iterable<ModelModule<EntityDescriptor>> models = module.typeLookup().lookupEntityModels( type );
-
- if( !models.iterator().hasNext() )
- {
- throw new EntityTypeNotFoundException( type.getName(),
- module.name(),
- module.findVisibleEntityTypes().map( ModelModule.toStringFunction )
- );
- }
-
- return uow.get( parseEntityReference( identity ), this, models, type );
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- public <T> T get( T entity )
- throws EntityTypeNotFoundException
- {
- EntityComposite entityComposite = (EntityComposite) entity;
- EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
- ModelModule<EntityDescriptor> model = new ModelModule<>( compositeInstance.module(), compositeInstance.entityModel() );
- Class<T> type = (Class<T>) compositeInstance.types().findFirst().orElse( null );
- return uow.get( compositeInstance.identity(), this, Collections.singletonList( model ), type );
- }
-
- @Override
- public void remove( Object entity )
- throws LifecycleException
- {
- uow.checkOpen();
-
- EntityComposite entityComposite = (EntityComposite) entity;
-
- EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
-
- if( compositeInstance.status() == EntityStatus.NEW )
- {
- compositeInstance.remove( this );
- uow.remove( compositeInstance.identity() );
- }
- else if( compositeInstance.status() == EntityStatus.LOADED || compositeInstance.status() == EntityStatus.UPDATED )
- {
- compositeInstance.remove( this );
- }
- else
- {
- throw new NoSuchEntityException( compositeInstance.identity(), compositeInstance.types(), usecase() );
- }
- }
-
- @SuppressWarnings( "DuplicateThrows" )
- @Override
- public void complete()
- throws UnitOfWorkCompletionException, ConcurrentEntityModificationException
- {
- uow.complete();
- }
-
- @Override
- public void discard()
- {
- uow.discard();
- }
-
- @Override
- public void close()
- {
- discard();
- }
-
- @Override
- public boolean isOpen()
- {
- return uow.isOpen();
- }
-
- @Override
- public boolean isPaused()
- {
- return uow.isPaused();
- }
-
- @Override
- public void pause()
- {
- uow.pause();
- }
-
- @Override
- public void resume()
- {
- uow.resume();
- }
-
- @Override
- public void addUnitOfWorkCallback( UnitOfWorkCallback callback )
- {
- uow.addUnitOfWorkCallback( callback );
- }
-
- @Override
- public void removeUnitOfWorkCallback( UnitOfWorkCallback callback )
- {
- uow.removeUnitOfWorkCallback( callback );
- }
-
- @Override
- public boolean equals( Object o )
- {
- if( this == o )
- {
- return true;
- }
- if( o == null || getClass() != o.getClass() )
- {
- return false;
- }
-
- ModuleUnitOfWork that = (ModuleUnitOfWork) o;
-
- return uow.equals( that.uow );
- }
-
- @Override
- public int hashCode()
- {
- return uow.hashCode();
- }
-
- @Override
- public String toString()
- {
- return uow.toString();
- }
-
- public void addEntity( EntityInstance instance )
- {
- uow.addEntity( instance );
- }
-
- @Override
- public <T extends Identity> T toValue( Class<T> primaryType, T entityComposite )
- {
- Function<PropertyDescriptor, Object> propertyFunction = new ToValuePropertyMappingFunction( entityComposite );
- Function<AssociationDescriptor, EntityReference> assocationFunction = new ToValueAssociationMappingFunction<>( entityComposite );
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToValueManyAssociationMappingFunction<>( entityComposite );
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToValueNameAssociationMappingFunction<>( entityComposite );
-
- @SuppressWarnings( "unchecked" )
- ValueBuilder<T> builder = module().newValueBuilderWithState(
- primaryType, propertyFunction, assocationFunction, manyAssocFunction, namedAssocFunction );
- return builder.newInstance();
- }
-
- @Override
- public <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite )
- {
- Function<PropertyDescriptor, Object> propertyFunction = new ToEntityPropertyMappingFunction<>( valueComposite );
- Function<AssociationDescriptor, EntityReference> assocationFunction = new ToEntityAssociationMappingFunction<>( valueComposite );
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToEntityManyAssociationMappingFunction<>( valueComposite );
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToEntityNameAssociationMappingFunction<>( valueComposite );
-
- String identity = valueComposite.identity().get();
- try
- {
- T entity = get( primaryType, identity );
- // If successful, then this entity is to by modified.
- EntityInstance instance = EntityInstance.entityInstanceOf( (EntityComposite) entity );
- EntityState state = instance.entityState();
- FunctionStateResolver stateResolver = new FunctionStateResolver( propertyFunction,
- assocationFunction,
- manyAssocFunction,
- namedAssocFunction );
- EntityModel model = (EntityModel) EntityInstance.entityInstanceOf( (EntityComposite) entity ).descriptor();
- stateResolver.populateState( model, state );
- return entity;
- }
- catch( NoSuchEntityException e )
- {
- EntityBuilder<T> entityBuilder = newEntityBuilderWithState( primaryType,
- identity,
- propertyFunction,
- assocationFunction,
- manyAssocFunction,
- namedAssocFunction );
- return entityBuilder.newInstance();
- }
- }
-
- private static class UoWQuerySource implements QuerySource
- {
- private final ModuleUnitOfWork moduleUnitOfWork;
-
- private UoWQuerySource( ModuleUnitOfWork moduleUnitOfWork )
- {
- this.moduleUnitOfWork = moduleUnitOfWork;
- }
-
- @Override
- public <T> T find( Class<T> resultType,
- Predicate<Composite> whereClause,
- Iterable<OrderBy> orderBySegments,
- Integer firstResult,
- Integer maxResults,
- Map<String, Object> variables
- )
- {
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
- try
- {
- final EntityReference foundEntity = entityFinder.findEntity( resultType, whereClause, variables == null ? Collections
- .<String, Object>emptyMap() : variables );
- if( foundEntity != null )
- {
- try
- {
- return moduleUnitOfWork.get( resultType, foundEntity.identity() );
- }
- catch( NoSuchEntityException e )
- {
- return null; // Index is out of sync - entity has been removed
- }
- }
- // No entity was found
- return null;
- }
- catch( EntityFinderException e )
- {
- throw new QueryExecutionException( "Finder caused exception", e );
- }
- }
-
- @Override
- public <T> long count( Class<T> resultType,
- Predicate<Composite> whereClause,
- Iterable<OrderBy> orderBySegments,
- Integer firstResult,
- Integer maxResults,
- Map<String, Object> variables
- )
- {
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
- try
- {
- return entityFinder.countEntities( resultType, whereClause, variables == null ? Collections.<String, Object>emptyMap() : variables );
- }
- catch( EntityFinderException e )
- {
- e.printStackTrace();
- return 0;
- }
- }
-
- @Override
- public <T> Iterator<T> iterator( final Class<T> resultType,
- Predicate<Composite> whereClause,
- Iterable<OrderBy> orderBySegments,
- Integer firstResult,
- Integer maxResults,
- Map<String, Object> variables
- )
- {
- final EntityFinder entityFinder = moduleUnitOfWork.module().findService( EntityFinder.class ).get();
-
- try
- {
- final Iterator<EntityReference> foundEntities = entityFinder.findEntities( resultType,
- whereClause,
- Iterables.toArray( OrderBy.class, orderBySegments ),
- firstResult,
- maxResults,
- variables == null ? Collections
- .<String, Object>emptyMap() : variables )
- .iterator();
-
- return new Iterator<T>()
- {
- @Override
- public boolean hasNext()
- {
- return foundEntities.hasNext();
- }
-
- @Override
- public T next()
- {
- final EntityReference foundEntity = foundEntities.next();
- try
- {
- return moduleUnitOfWork.get( resultType, foundEntity.identity() );
- }
- catch( NoSuchEntityException e )
- {
- // Index is out of sync - entity has been removed
- return null;
- }
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
- catch( EntityFinderException e )
- {
- throw new QueryExecutionException( "Query '" + toString() + "' could not be executed", e );
- }
- }
-
- @Override
- public String toString()
- {
- return "UnitOfWork( " + moduleUnitOfWork.usecase().name() + " )";
- }
- }
-
- private class ToValuePropertyMappingFunction
- implements Function<PropertyDescriptor, Object>
- {
- private Object entity;
-
- public ToValuePropertyMappingFunction( Object entity )
- {
- this.entity = entity;
- }
-
- @Override
- public Object apply( PropertyDescriptor propertyDescriptor )
- {
- EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
- return entityState.propertyValueOf( propertyDescriptor.qualifiedName() );
- }
- }
-
- private class ToValueAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, EntityReference>
- {
- private final T entity;
-
- public ToValueAssociationMappingFunction( T entity )
- {
- this.entity = entity;
- }
-
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
- return entityState.associationValueOf( associationDescriptor.qualifiedName() );
- }
- }
-
- private class ToValueManyAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, Iterable<EntityReference>>
- {
- private final T entity;
-
- public ToValueManyAssociationMappingFunction( T entity )
- {
- this.entity = entity;
- }
-
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
- return entityState.manyAssociationValueOf( associationDescriptor.qualifiedName() );
- }
- }
-
- private class ToValueNameAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, Map<String, EntityReference>>
- {
- private final T entity;
-
- public ToValueNameAssociationMappingFunction( T entity )
- {
- this.entity = entity;
- }
-
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- Map<String, EntityReference> result = new HashMap<>();
- EntityState entityState = EntityInstance.entityInstanceOf( (EntityComposite) entity ).entityState();
- final NamedAssociationState state = entityState.namedAssociationValueOf( associationDescriptor.qualifiedName() );
- for( String name : state )
- {
- result.put( name, state.get( name ) );
- }
- return result;
- }
- }
-
- private class ToEntityPropertyMappingFunction<T>
- implements Function<PropertyDescriptor, Object>
- {
- private final T value;
-
- public ToEntityPropertyMappingFunction( T value )
- {
- this.value = value;
- }
-
- @Override
- public Object apply( PropertyDescriptor propertyDescriptor )
- {
- StateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
- Property<Object> property = state.propertyFor( propertyDescriptor.accessor() );
- return property.get();
- }
- }
-
- private class ToEntityAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, EntityReference>
- {
-
- private final T value;
-
- public ToEntityAssociationMappingFunction( T value )
- {
- this.value = value;
- }
-
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
- AssociationInstance<T> association = (AssociationInstance<T>) state.associationFor( associationDescriptor.accessor() );
- return association.getAssociationState().get();
- }
- }
-
- private class ToEntityManyAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, Iterable<EntityReference>>
- {
-
- private final T value;
-
- public ToEntityManyAssociationMappingFunction( T valueComposite )
- {
- this.value = valueComposite;
- }
-
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
- ManyAssociationInstance<T> association =
- (ManyAssociationInstance<T>) state.manyAssociationFor( associationDescriptor.accessor() );
- return association.getManyAssociationState();
- }
- }
-
- private class ToEntityNameAssociationMappingFunction<T>
- implements Function<AssociationDescriptor, Map<String, EntityReference>>
- {
- private final T value;
-
- public ToEntityNameAssociationMappingFunction( T valueComposite )
- {
- this.value = valueComposite;
- }
-
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- AssociationStateHolder state = ValueInstance.valueInstanceOf( (ValueComposite) value ).state();
- NamedAssociationInstance<T> association =
- (NamedAssociationInstance<T>) state.namedAssociationFor( associationDescriptor.accessor() );
- HashMap<String, EntityReference> result = new HashMap<>();
- for( Map.Entry<String, EntityReference> entry : association.getEntityReferences() )
- {
- result.put( entry.getKey(), entry.getValue() );
- }
- return result;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
deleted file mode 100755
index 6947b73..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookup.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright (c) 2008-2012, Rickard Öberg.
- * Copyright (c) 2008-2012, Niclas Hedhman.
- * Copyright (c) 2012, Paul Merlin.
- *
- * Licensed 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.runtime.structure;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.AmbiguousTypeException;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.api.service.NoSuchServiceException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.spi.module.ModelModule;
-
-import static java.util.stream.Stream.concat;
-import static org.apache.zest.api.common.Visibility.application;
-import static org.apache.zest.api.common.Visibility.layer;
-import static org.apache.zest.api.common.Visibility.module;
-import static org.apache.zest.api.util.Classes.RAW_CLASS;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.functional.Iterables.first;
-
-/**
- * Central place for Composite Type lookups.
- */
-public class TypeLookup
-{
-
- // Constructor parameters
- private final ModuleInstance moduleInstance;
- // Eager instance objects
- private final Map<Class<?>, ModelModule<ObjectDescriptor>> objectModels;
- private final Map<Class<?>, ModelModule<TransientDescriptor>> transientModels;
- private final Map<Class<?>, ModelModule<ValueDescriptor>> valueModels;
- private final Map<Class<?>, List<ModelModule<EntityDescriptor>>> allEntityModels;
- private final Map<Class<?>, ModelModule<EntityDescriptor>> unambiguousEntityModels;
- private final Map<Type, ServiceReference<?>> serviceReferences;
- private final Map<Type, List<ServiceReference<?>>> servicesReferences;
-
- /**
- * Create a new TypeLookup bound to the given ModuleInstance.
- *
- * @param moduleInstance ModuleInstance bound to this TypeLookup
- */
- TypeLookup( ModuleInstance moduleInstance )
- {
- // Constructor parameters
- this.moduleInstance = moduleInstance;
-
- // Eager instance objects
- objectModels = new ConcurrentHashMap<>();
- transientModels = new ConcurrentHashMap<>();
- valueModels = new ConcurrentHashMap<>();
- allEntityModels = new ConcurrentHashMap<>();
- unambiguousEntityModels = new ConcurrentHashMap<>();
- serviceReferences = new ConcurrentHashMap<>();
- servicesReferences = new ConcurrentHashMap<>();
- }
-
- /**
- * Lookup first Object Model matching the given Type.
- *
- * <p>First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param type Looked up Type
- *
- * @return First matching Object Model
- */
- ModelModule<ObjectDescriptor> lookupObjectModel( final Class type )
- {
- ModelModule<ObjectDescriptor> model = objectModels.get( type );
- if( model == null )
- {
- List<ModelModule<ObjectDescriptor>> allModels = allObjects().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
- if( model == null )
- {
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- objectModels.put( type, model );
- }
- }
- return model;
- }
-
- /**
- * Lookup first Transient Model matching the given Type.
- *
- * <p>First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param type Looked up Type
- *
- * @return First matching Transient Model
- */
- ModelModule<TransientDescriptor> lookupTransientModel( final Class type )
- {
- ModelModule<TransientDescriptor> model = transientModels.get( type );
- if( model == null )
- {
- List<ModelModule<TransientDescriptor>> allModels = allTransients().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
- if( model == null )
- {
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- transientModels.put( type, model );
- }
- }
- return model;
- }
-
- /**
- * Lookup first Value Model matching the given Type.
- *
- * <p>First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param type Looked up Type
- *
- * @return First matching Value Model
- */
- public ModelModule<ValueDescriptor> lookupValueModel( final Class type )
- {
- ModelModule<ValueDescriptor> model = valueModels.get( type );
- if( model == null )
- {
- List<ModelModule<ValueDescriptor>> allModels = allValues().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
- if( model == null )
- {
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- valueModels.put( type, model );
- }
- }
- return model;
- }
-
- /**
- * Lookup first Entity Model matching the given Type.
- *
- * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
- * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
- * {@link #lookupEntityModels(java.lang.Class)}.</p>
- *
- * @param type Looked up Type
- *
- * @return First matching Entity Model
- */
- ModelModule<EntityDescriptor> lookupEntityModel( final Class type )
- {
- ModelModule<EntityDescriptor> model = unambiguousEntityModels.get( type );
-
- if( model == null )
- {
- List<ModelModule<EntityDescriptor>> allModels = allEntities().collect( Collectors.toList() );
- model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
- if( model == null )
- {
- model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
- }
- if( model != null )
- {
- unambiguousEntityModels.put( type, model );
- }
- }
- return model;
- }
-
- /**
- * Lookup all Entity Models matching the given Type.
- *
- * <p>Returned Iterable contains, in order, Entity Models that: </p>
- *
- * <ul>
- * <li>exactly match the given type, in Visibility then Assembly order ;</li>
- * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
- * </ul>
- *
- * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
- * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
- * {@link #lookupEntityModel(java.lang.Class)}.</p>
- *
- * @param type Looked up Type
- *
- * @return All matching Entity Models
- */
- Iterable<ModelModule<EntityDescriptor>> lookupEntityModels( final Class type )
- {
- List<ModelModule<EntityDescriptor>> result = allEntityModels.get( type );
- if( result == null )
- {
- result = concat(
- allEntities().filter( ref -> new ExactTypeMatching<>( type ).test( ref.model() ) ),
- allEntities().filter( ref -> new AssignableFromTypeMatching<>( type ).test( ref.model() ) )
- ).distinct().collect( Collectors.toList() );
- allEntityModels.put( type, result );
- }
- return result;
- }
-
- /**
- * Lookup first ServiceReference matching the given Type.
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * <p>See {@link #lookupServiceReferences(Type)}.</p>
- *
- * @param <T> Service Type
- * @param serviceType Looked up Type
- *
- * @return First matching ServiceReference
- */
- <T> ServiceReference<T> lookupServiceReference( Type serviceType )
- {
- @SuppressWarnings( "unchecked" )
- ServiceReference<T> serviceReference = (ServiceReference<T>) serviceReferences.get( serviceType );
- if( serviceReference == null )
- {
- // Lazily resolve ServiceReference
- serviceReference = first( lookupServiceReferences( serviceType ) );
- if( serviceReference != null )
- {
- serviceReferences.put( serviceType, serviceReference );
- }
- }
-
- if( serviceReference == null )
- {
- throw new NoSuchServiceException( RAW_CLASS.apply( serviceType ).getName(), moduleInstance.name() );
- }
- return serviceReference;
- }
-
- /**
- * Lookup all ServiceReferences matching the given Type.
- *
- * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
- *
- * <ul>
- * <li>exactly match the given type, in Visibility then Assembly order ;</li>
- * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
- * </ul>
- *
- * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
- * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
- *
- * <p>Type lookup is done lazily and cached.</p>
- *
- * @param <T> Service Type
- * @param type Looked up Type
- *
- * @return All matching ServiceReferences
- */
- <T> List<ServiceReference<T>> lookupServiceReferences( final Type type )
- {
- List<ServiceReference<?>> serviceRefs = servicesReferences.get( type );
- if( serviceRefs == null )
- {
- serviceRefs = concat(
- allServices()
- .filter( new ExactTypeMatching<>( type ) ),
- allServices()
- .filter( new AssignableFromTypeMatching<>( type )
- )
- ).distinct().collect( Collectors.toList() );
- servicesReferences.put( type, serviceRefs );
- }
- List<ServiceReference<T>> result = new ArrayList<>();
- //noinspection unchecked
- serviceRefs.forEach( ref -> result.add( (ServiceReference<T>) ref ) );
- return result;
- }
-
- public Stream<Class<?>> allVisibleObjects()
- {
- return allObjects().flatMap( model -> model.model().types() );
- }
-
- private Stream<ModelModule<ObjectDescriptor>> allObjects()
- {
- return concat( moduleInstance.visibleObjects( module ),
- concat(
- moduleInstance.layerInstance().visibleObjects( layer ),
- concat(
- moduleInstance.layerInstance().visibleObjects( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleObjects()
- )
- )
- );
- }
-
- private Stream<ModelModule<TransientDescriptor>> allTransients()
- {
- return concat( moduleInstance.visibleTransients( module ),
- concat(
- moduleInstance.layerInstance().visibleTransients( layer ),
- concat(
- moduleInstance.layerInstance().visibleTransients( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleTransients()
- )
- )
- );
- }
-
- private Stream<ModelModule<ValueDescriptor>> allValues()
- {
- return concat( moduleInstance.visibleValues( module ),
- concat(
- moduleInstance.layerInstance().visibleValues( layer ),
- concat(
- moduleInstance.layerInstance().visibleValues( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleValues()
- )
- )
- );
- }
-
- private Stream<ModelModule<EntityDescriptor>> allEntities()
- {
- return concat( moduleInstance.visibleEntities( module ),
- concat(
- moduleInstance.layerInstance().visibleEntities( layer ),
- concat(
- moduleInstance.layerInstance().visibleEntities( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleEntities()
- )
- )
- );
- }
-
- private Stream<ServiceReference<?>> allServices()
- {
- return concat( moduleInstance.visibleServices( module ),
- concat(
- moduleInstance.layerInstance().visibleServices( layer ),
- concat(
- moduleInstance.layerInstance().visibleServices( application ),
- moduleInstance.layerInstance().usedLayersInstance().visibleServices()
- )
- )
- );
- }
-
- private <T extends ModelDescriptor> ModelModule<T> ambiguityMatching(
- Class type,
- List<ModelModule<T>> modelModules,
- TypeMatching<T> matching
- )
- {
- List<ModelModule<T>> models = modelModules.stream()
- .filter( ref -> matching.test( ref.model() ) )
- .filter( new SameVisibility<>() )
- .distinct()
- .collect( Collectors.toList() );
-
- if( models.size() > 1 )
- {
- throw new AmbiguousTypeException( "More than one type matches " + type.getName() + ": " + models + "]" );
- }
- if( models.isEmpty() )
- {
- return null;
- }
- return models.get( 0 );
- }
-
- private static abstract class TypeMatching<T extends HasTypes>
- implements Predicate<T>
- {
- protected final Type lookedUpType;
-
- protected TypeMatching( Type lookedUpType )
- {
- this.lookedUpType = lookedUpType;
- }
-
- @Override
- public final boolean test( T model )
- {
- if( lookedUpType instanceof Class )
- {
- return model.types().anyMatch( checkMatch( lookedUpType ) );
- }
- else
- {
- if( lookedUpType instanceof ParameterizedType )
- {
- // Foo<Bar> check
- // First check Foo
- ParameterizedType parameterizedType = (ParameterizedType) lookedUpType;
- Type rawType = parameterizedType.getRawType();
- if( !model.types().anyMatch( checkMatch( rawType ) ) )
- {
- return false;
- }
- // Then check Bar
- return interfacesOf( model.types() ).anyMatch( intf -> intf.equals( lookedUpType ) );
- }
- else if( lookedUpType instanceof WildcardType )
- {
- return true;
- }
- return false;
- }
- }
-
- protected abstract Predicate<Type> checkMatch( Type matchTo );
- }
-
- private static final class ExactTypeMatching<T extends HasTypes> extends TypeMatching<T>
- {
- private ExactTypeMatching( Type lookedUpType )
- {
- super( lookedUpType );
- }
-
- protected Predicate<Type> checkMatch( Type matchTo )
- {
- return matchTo::equals;
- }
- }
-
- private static final class AssignableFromTypeMatching<T extends HasTypes> extends TypeMatching<T>
- {
- private AssignableFromTypeMatching( Type lookedUpType )
- {
- super( lookedUpType );
- }
-
- protected Predicate<Type> checkMatch( Type matchTo )
- {
- // TODO; what to do if there is ParameterizedType here?? Now set to ClassCastException and see if anything surfaces
-// if( matchTo instanceof Class )
- {
- Class<?> clazz = (Class<?>) matchTo;
- return candidate ->
- !candidate.equals( matchTo ) && clazz.isAssignableFrom( (Class<?>) candidate );
- }
-// return candidate -> candidate.equals( matchTo );
- }
- }
-
- /**
- * This Predicate will filter out all Models that doesn't have the same visisbility as the first one.
- */
- private class SameVisibility<T extends ModelDescriptor>
- implements Predicate<ModelModule<T>>
- {
- private Visibility current = null;
-
- @Override
- public boolean test( ModelModule<T> model )
- {
- if( current == null )
- {
- current = model.model().visibility();
- return true;
- }
- return current == model.model().visibility();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
new file mode 100755
index 0000000..7835aaa
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
@@ -0,0 +1,538 @@
+/*
+ * Copyright (c) 2008-2012, Rickard Öberg.
+ * Copyright (c) 2008-2012, Niclas Hedhman.
+ * Copyright (c) 2012, Paul Merlin.
+ *
+ * Licensed 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.runtime.structure;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.composite.AmbiguousTypeException;
+import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.composite.TransientDescriptor;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.object.ObjectDescriptor;
+import org.apache.zest.api.service.NoSuchServiceException;
+import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.type.HasTypes;
+import org.apache.zest.api.value.ValueDescriptor;
+import org.apache.zest.spi.structure.ModelModule;
+import org.apache.zest.spi.structure.TypeLookup;
+
+import static java.util.stream.Stream.concat;
+import static org.apache.zest.api.common.Visibility.application;
+import static org.apache.zest.api.common.Visibility.layer;
+import static org.apache.zest.api.common.Visibility.module;
+import static org.apache.zest.api.util.Classes.RAW_CLASS;
+import static org.apache.zest.api.util.Classes.interfacesOf;
+import static org.apache.zest.functional.Iterables.first;
+
+/**
+ * Central place for Composite Type lookups.
+ */
+public class TypeLookupImpl
+ implements TypeLookup
+{
+
+ // Constructor parameters
+ private final ModuleInstance moduleInstance;
+ // Eager instance objects
+ private final Map<Class<?>, ModelModule<ObjectDescriptor>> objectModels;
+ private final Map<Class<?>, ModelModule<TransientDescriptor>> transientModels;
+ private final Map<Class<?>, ModelModule<ValueDescriptor>> valueModels;
+ private final Map<Class<?>, List<ModelModule<EntityDescriptor>>> allEntityModels;
+ private final Map<Class<?>, ModelModule<EntityDescriptor>> unambiguousEntityModels;
+ private final Map<Type, ServiceReference<?>> serviceReferences;
+ private final Map<Type, List<ServiceReference<?>>> servicesReferences;
+
+ /**
+ * Create a new TypeLookup bound to the given ModuleInstance.
+ *
+ * @param moduleInstance ModuleInstance bound to this TypeLookup
+ */
+ TypeLookupImpl( ModuleInstance moduleInstance )
+ {
+ // Constructor parameters
+ this.moduleInstance = moduleInstance;
+
+ // Eager instance objects
+ objectModels = new ConcurrentHashMap<>();
+ transientModels = new ConcurrentHashMap<>();
+ valueModels = new ConcurrentHashMap<>();
+ allEntityModels = new ConcurrentHashMap<>();
+ unambiguousEntityModels = new ConcurrentHashMap<>();
+ serviceReferences = new ConcurrentHashMap<>();
+ servicesReferences = new ConcurrentHashMap<>();
+ }
+
+ /**
+ * Lookup first Object Model matching the given Type.
+ *
+ * <p>First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Object Model
+ */
+ ModelModule<ObjectDescriptor> lookupObjectModel( final Class type )
+ {
+ ModelModule<ObjectDescriptor> model = objectModels.get( type );
+ if( model == null )
+ {
+ List<ModelModule<ObjectDescriptor>> allModels = allObjects().collect( Collectors.toList() );
+ model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ if( model == null )
+ {
+ model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
+ }
+ if( model != null )
+ {
+ objectModels.put( type, model );
+ }
+ }
+ return model;
+ }
+
+ /**
+ * Lookup first Transient Model matching the given Type.
+ *
+ * <p>First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Transient Model
+ */
+ ModelModule<TransientDescriptor> lookupTransientModel( final Class type )
+ {
+ ModelModule<TransientDescriptor> model = transientModels.get( type );
+ if( model == null )
+ {
+ List<ModelModule<TransientDescriptor>> allModels = allTransients().collect( Collectors.toList() );
+ model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ if( model == null )
+ {
+ model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
+ }
+ if( model != null )
+ {
+ transientModels.put( type, model );
+ }
+ }
+ return model;
+ }
+
+ /**
+ * Lookup first Value Model matching the given Type.
+ *
+ * <p>First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Value Model
+ */
+ public ModelModule<ValueDescriptor> lookupValueModel( final Class type )
+ {
+ ModelModule<ValueDescriptor> model = valueModels.get( type );
+ if( model == null )
+ {
+ List<ModelModule<ValueDescriptor>> allModels = allValues().collect( Collectors.toList() );
+ model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ if( model == null )
+ {
+ model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
+ }
+ if( model != null )
+ {
+ valueModels.put( type, model );
+ }
+ }
+ return model;
+ }
+
+ /**
+ * Lookup first Entity Model matching the given Type.
+ *
+ * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned.
+ * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see
+ * {@link #lookupEntityModels(java.lang.Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return First matching Entity Model
+ */
+ @Override
+ public ModelModule<EntityDescriptor> lookupEntityModel( final Class type )
+ {
+ ModelModule<EntityDescriptor> model = unambiguousEntityModels.get( type );
+
+ if( model == null )
+ {
+ List<ModelModule<EntityDescriptor>> allModels = allEntities().collect( Collectors.toList() );
+ model = ambiguityMatching( type, allModels, new ExactTypeMatching<>( type ) );
+ if( model == null )
+ {
+ model = ambiguityMatching( type, allModels, new AssignableFromTypeMatching<>( type ) );
+ }
+ if( model != null )
+ {
+ unambiguousEntityModels.put( type, model );
+ }
+ }
+ return model;
+ }
+
+ /**
+ * Lookup all Entity Models matching the given Type.
+ *
+ * <p>Returned Iterable contains, in order, Entity Models that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p>
+ * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see
+ * {@link #lookupEntityModel(java.lang.Class)}.</p>
+ *
+ * @param type Looked up Type
+ *
+ * @return All matching Entity Models
+ */
+ @Override
+ public Iterable<ModelModule<EntityDescriptor>> lookupEntityModels( final Class type )
+ {
+ List<ModelModule<EntityDescriptor>> result = allEntityModels.get( type );
+ if( result == null )
+ {
+ result = concat(
+ allEntities().filter( ref -> new ExactTypeMatching<>( type ).test( ref.model() ) ),
+ allEntities().filter( ref -> new AssignableFromTypeMatching<>( type ).test( ref.model() ) )
+ ).distinct().collect( Collectors.toList() );
+ allEntityModels.put( type, result );
+ }
+ return result;
+ }
+
+ /**
+ * Lookup first ServiceReference matching the given Type.
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * <p>See {@link #lookupServiceReferences(Type)}.</p>
+ *
+ * @param <T> Service Type
+ * @param serviceType Looked up Type
+ *
+ * @return First matching ServiceReference
+ */
+ @Override
+ public <T> ServiceReference<T> lookupServiceReference( Type serviceType )
+ {
+ @SuppressWarnings( "unchecked" )
+ ServiceReference<T> serviceReference = (ServiceReference<T>) serviceReferences.get( serviceType );
+ if( serviceReference == null )
+ {
+ // Lazily resolve ServiceReference
+ serviceReference = first( lookupServiceReferences( serviceType ) );
+ if( serviceReference != null )
+ {
+ serviceReferences.put( serviceType, serviceReference );
+ }
+ }
+
+ if( serviceReference == null )
+ {
+ throw new NoSuchServiceException( RAW_CLASS.apply( serviceType ).getName(), moduleInstance.name() );
+ }
+ return serviceReference;
+ }
+
+ /**
+ * Lookup all ServiceReferences matching the given Type.
+ *
+ * <p>Returned Iterable contains, in order, ServiceReferences that: </p>
+ *
+ * <ul>
+ * <li>exactly match the given type, in Visibility then Assembly order ;</li>
+ * <li>match a type assignable to the given type, in Visibility then Assembly order.</li>
+ * </ul>
+ *
+ * <p>Multiple <b>exact</b> matches with the same Visibility are <b>allowed</b> to enable polymorphic lookup/injection.</p>
+ * <p>Multiple <b>assignable</b> matches with the same Visibility are <b>allowed</b> for the very same reason.</p>
+ *
+ * <p>Type lookup is done lazily and cached.</p>
+ *
+ * @param <T> Service Type
+ * @param type Looked up Type
+ *
+ * @return All matching ServiceReferences
+ */
+ @Override
+ public <T> List<ServiceReference<T>> lookupServiceReferences( final Type type )
+ {
+ List<ServiceReference<?>> serviceRefs = servicesReferences.get( type );
+ if( serviceRefs == null )
+ {
+ serviceRefs = concat(
+ allServices()
+ .filter( new ExactTypeMatching<>( type ) ),
+ allServices()
+ .filter( new AssignableFromTypeMatching<>( type )
+ )
+ ).distinct().collect( Collectors.toList() );
+ servicesReferences.put( type, serviceRefs );
+ }
+ List<ServiceReference<T>> result = new ArrayList<>();
+ //noinspection unchecked
+ serviceRefs.forEach( ref -> result.add( (ServiceReference<T>) ref ) );
+ return result;
+ }
+
+ @Override
+ public Stream<Class<?>> allVisibleObjects()
+ {
+ return allObjects().flatMap( model -> model.model().types() );
+ }
+
+ @Override
+ public Stream<ModelModule<ObjectDescriptor>> allObjects()
+ {
+ return concat( moduleInstance.visibleObjects( module ),
+ concat(
+ moduleInstance.layerInstance().visibleObjects( layer ),
+ concat(
+ moduleInstance.layerInstance().visibleObjects( application ),
+ moduleInstance.layerInstance().usedLayersInstance().visibleObjects()
+ )
+ )
+ );
+ }
+
+ @Override
+ public Stream<ModelModule<TransientDescriptor>> allTransients()
+ {
+ return concat( moduleInstance.visibleTransients( module ),
+ concat(
+ moduleInstance.layerInstance().visibleTransients( layer ),
+ concat(
+ moduleInstance.layerInstance().visibleTransients( application ),
+ moduleInstance.layerInstance().usedLayersInstance().visibleTransients()
+ )
+ )
+ );
+ }
+
+ @Override
+ public Stream<ModelModule<ValueDescriptor>> allValues()
+ {
+ return concat( moduleInstance.visibleValues( module ),
+ concat(
+ moduleInstance.layerInstance().visibleValues( layer ),
+ concat(
+ moduleInstance.layerInstance().visibleValues( application ),
+ moduleInstance.layerInstance().usedLayersInstance().visibleValues()
+ )
+ )
+ );
+ }
+
+ @Override
+ public Stream<ModelModule<EntityDescriptor>> allEntities()
+ {
+ return concat( moduleInstance.visibleEntities( module ),
+ concat(
+ moduleInstance.layerInstance().visibleEntities( layer ),
+ concat(
+ moduleInstance.layerInstance().visibleEntities( application ),
+ moduleInstance.layerInstance().usedLayersInstance().visibleEntities()
+ )
+ )
+ );
+ }
+
+ @Override
+ public Stream<ServiceReference<?>> allServices()
+ {
+ return concat( moduleInstance.visibleServices( module ),
+ concat(
+ moduleInstance.layerInstance().visibleServices( layer ),
+ concat(
+ moduleInstance.layerInstance().visibleServices( application ),
+ moduleInstance.layerInstance().usedLayersInstance().visibleServices()
+ )
+ )
+ );
+ }
+
+ private <T extends ModelDescriptor> ModelModule<T> ambiguityMatching(
+ Class type,
+ List<ModelModule<T>> modelModules,
+ TypeMatching<T> matching
+ )
+ {
+ List<ModelModule<T>> models = modelModules.stream()
+ .filter( ref -> matching.test( ref.model() ) )
+ .filter( new SameVisibility<>() )
+ .distinct()
+ .collect( Collectors.toList() );
+
+ if( models.size() > 1 )
+ {
+ throw new AmbiguousTypeException( "More than one type matches " + type.getName() + ": " + models + "]" );
+ }
+ if( models.isEmpty() )
+ {
+ return null;
+ }
+ return models.get( 0 );
+ }
+
+ private static abstract class TypeMatching<T extends HasTypes>
+ implements Predicate<T>
+ {
+ protected final Type lookedUpType;
+
+ protected TypeMatching( Type lookedUpType )
+ {
+ this.lookedUpType = lookedUpType;
+ }
+
+ @Override
+ public final boolean test( T model )
+ {
+ if( lookedUpType instanceof Class )
+ {
+ return model.types().anyMatch( checkMatch( lookedUpType ) );
+ }
+ else
+ {
+ if( lookedUpType instanceof ParameterizedType )
+ {
+ // Foo<Bar> check
+ // First check Foo
+ ParameterizedType parameterizedType = (ParameterizedType) lookedUpType;
+ Type rawType = parameterizedType.getRawType();
+ if( !model.types().anyMatch( checkMatch( rawType ) ) )
+ {
+ return false;
+ }
+ // Then check Bar
+ return interfacesOf( model.types() ).anyMatch( intf -> intf.equals( lookedUpType ) );
+ }
+ else if( lookedUpType instanceof WildcardType )
+ {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ protected abstract Predicate<Type> checkMatch( Type matchTo );
+ }
+
+ private static final class ExactTypeMatching<T extends HasTypes> extends TypeMatching<T>
+ {
+ private ExactTypeMatching( Type lookedUpType )
+ {
+ super( lookedUpType );
+ }
+
+ protected Predicate<Type> checkMatch( Type matchTo )
+ {
+ return matchTo::equals;
+ }
+ }
+
+ private static final class AssignableFromTypeMatching<T extends HasTypes> extends TypeMatching<T>
+ {
+ private AssignableFromTypeMatching( Type lookedUpType )
+ {
+ super( lookedUpType );
+ }
+
+ protected Predicate<Type> checkMatch( Type matchTo )
+ {
+ // TODO; what to do if there is ParameterizedType here?? Now set to ClassCastException and see if anything surfaces
+// if( matchTo instanceof Class )
+ {
+ Class<?> clazz = (Class<?>) matchTo;
+ return candidate ->
+ !candidate.equals( matchTo ) && clazz.isAssignableFrom( (Class<?>) candidate );
+ }
+// return candidate -> candidate.equals( matchTo );
+ }
+ }
+
+ /**
+ * This Predicate will filter out all Models that doesn't have the same visisbility as the first one.
+ */
+ private class SameVisibility<T extends ModelDescriptor>
+ implements Predicate<ModelModule<T>>
+ {
+ private Visibility current = null;
+
+ @Override
+ public boolean test( ModelModule<T> model )
+ {
+ if( current == null )
+ {
+ current = model.model().visibility();
+ return true;
+ }
+ return current == model.model().visibility();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
index 5a9bc94..ebf4b9c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/UsedLayersInstance.java
@@ -17,13 +17,12 @@ package org.apache.zest.runtime.structure;
import java.util.List;
import java.util.stream.Stream;
import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.ModelDescriptor;
import org.apache.zest.api.composite.TransientDescriptor;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.object.ObjectDescriptor;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
/**
* JAVADOC
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
index 425e851..ed8d137 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
@@ -25,8 +25,7 @@ import org.apache.zest.api.entity.LifecycleException;
import org.apache.zest.runtime.composite.FunctionStateResolver;
import org.apache.zest.runtime.entity.EntityInstance;
import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.spi.module.ModelModule;
-import org.apache.zest.runtime.structure.ModuleUnitOfWork;
+import org.apache.zest.spi.structure.ModelModule;
import org.apache.zest.spi.entity.EntityState;
import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
import org.apache.zest.spi.module.ModuleSpi;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityFunction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityFunction.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityFunction.java
new file mode 100644
index 0000000..a7524db
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityFunction.java
@@ -0,0 +1,46 @@
+/*
+ * 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.runtime.unitofwork;
+
+import java.lang.reflect.Type;
+import java.util.function.BiFunction;
+import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+
+import static org.apache.zest.api.util.Classes.RAW_CLASS;
+
+public class EntityFunction
+ implements BiFunction<EntityReference, Type, Object>
+{
+
+ private final UnitOfWorkFactory uowf;
+
+ public EntityFunction( UnitOfWorkFactory uowf )
+ {
+ this.uowf = uowf;
+ }
+
+ @Override
+ public Object apply( EntityReference entityReference, Type type )
+ {
+ return uowf.currentUnitOfWork().get( RAW_CLASS.apply( type ), entityReference.identity() );
+ }
+}
[05/34] zest-java git commit: ZEST-132,
ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a
customizable Transient Class can be a Transient directly,
with itself as both the Composite Type and the Mixin. SideEffects declaratio
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
index 8482f0f..eb6e2db 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
@@ -60,7 +60,7 @@ public class RegisterHandlingEventTest extends TestApplication
throws Exception
{
super.prepareTest();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
@@ -129,11 +129,11 @@ public class RegisterHandlingEventTest extends TestApplication
throws Exception
{
deviation_3c_VoyageNumber_Unknown();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
// Receive 1st time (store event so that it turns up in query)
uow.complete();
- tempUow = module.newUnitOfWork();
+ tempUow = uowf.newUnitOfWork();
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HONGKONG, noVoyage );
tempUow.complete();
@@ -148,11 +148,11 @@ public class RegisterHandlingEventTest extends TestApplication
throws Exception
{
deviation_4a_DuplicateEvent_Receive();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
uow.complete();
// In customs 1st time
- tempUow = module.newUnitOfWork();
+ tempUow = uowf.newUnitOfWork();
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CUSTOMS, HONGKONG, noVoyage );
tempUow.complete();
@@ -167,11 +167,11 @@ public class RegisterHandlingEventTest extends TestApplication
throws Exception
{
deviation_4a_DuplicateEvent_Customs();
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
uow.complete();
// Claimed 1st time
- tempUow = module.newUnitOfWork();
+ tempUow = uowf.newUnitOfWork();
handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CLAIM, HONGKONG, noVoyage );
tempUow.complete();
@@ -200,8 +200,8 @@ public class RegisterHandlingEventTest extends TestApplication
deviation_5a_NoHandlingAfterClaim();
// Delete handling events from memory
- tempUow = module.newUnitOfWork();
- Query<HandlingEventEntity> events = tempUow.newQuery( module.newQueryBuilder( HandlingEventEntity.class ) );
+ tempUow = uowf.newUnitOfWork();
+ Query<HandlingEventEntity> events = tempUow.newQuery( qbf.newQueryBuilder( HandlingEventEntity.class ) );
for( HandlingEvent event : events )
{
tempUow.remove( event );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
----------------------------------------------------------------------
diff --git a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
index 76c82e9..78f470b 100644
--- a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
+++ b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
@@ -14,6 +14,8 @@
package org.apache.zest.dci.moneytransfer.test;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -45,6 +47,7 @@ public class TransferMoneyTest
public static final String CHECKING_ACCOUNT_ID = "CheckingAccountId";
public static final String CREDITOR_ID1 = "BakerAccount";
public static final String CREDITOR_ID2 = "ButcherAccount";
+ private static UnitOfWorkFactory uowf;
@BeforeClass
public static void setup()
@@ -55,6 +58,7 @@ public class TransferMoneyTest
public void assemble( ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.entities(
CheckingAccountRolemap.class,
SavingsAccountRolemap.class,
@@ -63,7 +67,7 @@ public class TransferMoneyTest
new EntityTestAssembler().assemble( module );
}
};
-
+ uowf = assembler.module().unitOfWorkFactory();
bootstrapData( assembler );
}
@@ -85,7 +89,7 @@ public class TransferMoneyTest
public void printBalances()
{
- UnitOfWork uow = assembler.module().newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
try
{
@@ -105,7 +109,7 @@ public class TransferMoneyTest
private static void bootstrapData( SingletonAssembler assembler )
throws Exception
{
- UnitOfWork uow = assembler.module().newUnitOfWork( newUsecase( "Bootstrap data" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Bootstrap data" ) );
try
{
SavingsAccountEntity savingsAccount = uow.newEntity( SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID );
@@ -134,8 +138,7 @@ public class TransferMoneyTest
public void transferHalfOfMoneyFromSavingsToChecking()
throws Exception
{
- UnitOfWork uow = assembler.module()
- .newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
try
{
@@ -163,8 +166,7 @@ public class TransferMoneyTest
public void transferTwiceOfMoneyFromSavingsToChecking()
throws Exception
{
- UnitOfWork uow = assembler.module()
- .newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
try
{
@@ -192,7 +194,7 @@ public class TransferMoneyTest
public void payAllBills()
throws Exception
{
- UnitOfWork uow = assembler.module().newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
try
{
BalanceData source = uow.get( BalanceData.class, CHECKING_ACCOUNT_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
----------------------------------------------------------------------
diff --git a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
index 8507b8b..7d4a11c 100644
--- a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
+++ b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
@@ -14,6 +14,8 @@
package org.apache.zest.dci.moneytransfer.test;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -44,6 +46,7 @@ public class TransferMoneyTest2
public static final String CHECKING_ACCOUNT_ID = "CheckingAccountId";
public static final String CREDITOR_ID1 = "BakerAccount";
public static final String CREDITOR_ID2 = "ButcherAccount";
+ private static UnitOfWorkFactory uowf;
@BeforeClass
public static void setup()
@@ -54,6 +57,7 @@ public class TransferMoneyTest2
public void assemble( ModuleAssembly module )
throws AssemblyException
{
+ module.withDefaultUnitOfWorkFactory();
module.entities(
CheckingAccountEntity.class,
SavingsAccountEntity.class,
@@ -67,7 +71,7 @@ public class TransferMoneyTest2
};
module = assembler.module();
-
+ uowf = module.unitOfWorkFactory();
bootstrapData();
}
@@ -89,7 +93,7 @@ public class TransferMoneyTest2
private void printBalances()
{
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
+ UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
try
{
@@ -109,7 +113,7 @@ public class TransferMoneyTest2
private static void bootstrapData()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "Bootstrap data" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Bootstrap data" ) );
try
{
SavingsAccountEntity account = uow.newEntity( SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID );
@@ -138,7 +142,7 @@ public class TransferMoneyTest2
public void transferHalfOfMoneyFromSavingsToChecking()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
try
{
@@ -166,7 +170,7 @@ public class TransferMoneyTest2
public void transferTwiceOfMoneyFromSavingsToChecking()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
try
{
@@ -194,7 +198,7 @@ public class TransferMoneyTest2
public void payAllBills()
throws Exception
{
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
try
{
BalanceData source = uow.get( BalanceData.class, CHECKING_ACCOUNT_ID );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
index e232e59..d120cc5 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
@@ -25,11 +25,12 @@ import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.functional.Iterables;
import org.apache.zest.library.rest.server.api.ObjectSelection;
import org.apache.zest.sample.forum.domainevent.DomainEventValue;
@@ -47,7 +48,11 @@ public interface EventsService
implements InvocationHandler
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ ValueBuilderFactory vbf;
+
@Structure
Application application;
@@ -55,9 +60,9 @@ public interface EventsService
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
- UnitOfWork unitOfWork = module.currentUnitOfWork();
+ UnitOfWork unitOfWork = uowf.currentUnitOfWork();
- ValueBuilder<DomainEventValue> builder = module.newValueBuilder( DomainEventValue.class );
+ ValueBuilder<DomainEventValue> builder = vbf.newValueBuilder( DomainEventValue.class );
DomainEventValue prototype = builder.prototype();
prototype.version().set( application.version() );
prototype.timestamp().set( unitOfWork.currentTime() );
@@ -69,7 +74,7 @@ public interface EventsService
{
idx++;
String name = "param" + idx;
- ValueBuilder<ParameterValue> parameterBuilder = module.newValueBuilder( ParameterValue.class );
+ ValueBuilder<ParameterValue> parameterBuilder = vbf.newValueBuilder( ParameterValue.class );
parameterBuilder.prototype().name().set( name );
parameterBuilder.prototype().value().set( arg );
prototype.parameters().get().add( parameterBuilder.newInstance() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
index f4f61f7..8280726 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
@@ -22,7 +22,9 @@ import org.apache.zest.api.constraint.Name;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.rest.server.api.ResourceIndex;
import org.apache.zest.library.rest.server.api.dci.Role;
import org.apache.zest.sample.forum.data.entity.Board;
@@ -36,7 +38,10 @@ public class ForumAdministration
implements ResourceIndex<Query<Board>>
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ QueryBuilderFactory qbf;
ForumAdmin forumAdmin = new ForumAdmin();
Administrator administrator = new Administrator();
@@ -61,17 +66,15 @@ public class ForumAdministration
protected class ForumAdmin
extends Role<Forum>
{
- @Structure
- Module module;
public Query<Board> boards()
{
- return module.newQueryBuilder( Board.class ).newQuery( self.boards() );
+ return qbf.newQueryBuilder( Board.class ).newQuery( self.boards() );
}
public Board createBoard( String name )
{
- Board board = module.currentUnitOfWork().newEntity( Board.class );
+ Board board = uowf.currentUnitOfWork().newEntity( Board.class );
board.name().set( name );
administrator.makeModerator( board );
return board;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
index 7ed4e4e..64654b9 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
@@ -22,7 +22,7 @@ import org.apache.zest.api.constraint.Name;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.rest.server.api.ResourceIndex;
import org.apache.zest.library.rest.server.api.dci.Role;
import org.apache.zest.sample.forum.data.entity.Forum;
@@ -36,7 +36,7 @@ public class ForumsAdministration
implements ResourceIndex<Query<Forum>>
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
ForumsAdmin forumsAdmin = new ForumsAdmin();
Administrator administrator = new Administrator();
@@ -68,7 +68,7 @@ public class ForumsAdministration
public Forum createForum( String name )
{
- Forum forum = module.currentUnitOfWork().newEntity( Forum.class );
+ Forum forum = uowf.currentUnitOfWork().newEntity( Forum.class );
forum.name().set( name );
administrator.makeModerator( forum );
return forum;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
index bac5019..d18005f 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
@@ -20,23 +20,33 @@ package org.apache.zest.sample.forum.context.login;
import org.apache.zest.api.constraint.Name;
import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.query.QueryExpressions;
import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.forum.data.entity.User;
+import static org.apache.zest.api.query.QueryExpressions.*;
+
/**
* TODO
*/
public class Login
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ QueryBuilderFactory qbf;
public void login( @Name( "name" ) String name, @Name( "password" ) String password )
{
- User user = module.currentUnitOfWork()
- .newQuery( module.newQueryBuilder( User.class )
- .where( QueryExpressions.eq( QueryExpressions.templateFor( User.class ).name(), name ) ) )
+ QueryBuilder<User> builder = qbf.newQueryBuilder( User.class )
+ .where( eq( templateFor( User.class ).name(), name ) );
+
+ User user = uowf.currentUnitOfWork()
+ .newQuery( builder )
.find();
if( user == null || !user.isCorrectPassword( password ) )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
index 563f6b0..3730b11 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
@@ -20,14 +20,14 @@ package org.apache.zest.sample.forum.context.view;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.rest.server.api.ResourceIndex;
import org.apache.zest.library.rest.server.api.dci.Role;
import org.apache.zest.sample.forum.data.Moderators;
import org.apache.zest.sample.forum.data.entity.Board;
-import org.apache.zest.sample.forum.data.entity.Topic;
import org.apache.zest.sample.forum.data.entity.Forum;
import org.apache.zest.sample.forum.data.entity.Post;
+import org.apache.zest.sample.forum.data.entity.Topic;
import org.apache.zest.sample.forum.data.entity.User;
import static org.apache.zest.api.property.Numbers.add;
@@ -94,15 +94,15 @@ public class ViewBoard
extends Role<Board>
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
Topic createTopic( String subject, String message, BoardViewer poster )
{
- Topic topic = module.currentUnitOfWork().newEntity( Topic.class );
+ Topic topic = uowf.currentUnitOfWork().newEntity( Topic.class );
topic.subject().set( subject );
- Post post = module.currentUnitOfWork().newEntity( Post.class );
+ Post post = uowf.currentUnitOfWork().newEntity( Post.class );
post.message().set( message );
// Moderation checks
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
index 09adc3c..7df3a0e 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
@@ -22,7 +22,7 @@ import java.util.Date;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.property.Numbers;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.library.rest.server.api.ResourceIndex;
import org.apache.zest.library.rest.server.api.dci.Role;
import org.apache.zest.sample.forum.data.entity.Post;
@@ -62,14 +62,14 @@ public class ViewPost
extends Role<Topic>
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
public Post reply( String message, PostView viewPost )
{
- Post post = module.currentUnitOfWork().newEntity( Post.class );
+ Post post = uowf.currentUnitOfWork().newEntity( Post.class );
post.message().set( message );
post.createdBy().set( poster.self() );
- post.createdOn().set( new Date( module.currentUnitOfWork().currentTime() ) );
+ post.createdOn().set( new Date( uowf.currentUnitOfWork().currentTime() ) );
post.replyTo().set( viewPost.self() );
self().lastPost().set( post );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
index 6c5e785..fe446f8 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
@@ -22,7 +22,8 @@ import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.forum.data.Administrators;
import static org.apache.zest.api.query.QueryExpressions.templateFor;
@@ -42,12 +43,15 @@ public interface Forums
implements Forums
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ QueryBuilderFactory qbf;
public Query<Forum> forums()
{
- return module.currentUnitOfWork()
- .newQuery( module.newQueryBuilder( Forum.class ) )
+ return uowf.currentUnitOfWork()
+ .newQuery( qbf.newQueryBuilder( Forum.class ) )
.orderBy( templateFor( Forum.class ).name() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
index b41f56f..0f18cfe 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
@@ -23,7 +23,8 @@ import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.forum.context.Events;
import org.apache.zest.sample.forum.context.signup.Registration;
@@ -47,28 +48,31 @@ public interface Users
implements Users
{
@Structure
- Module module;
+ UnitOfWorkFactory uowf;
+
+ @Structure
+ QueryBuilderFactory qbf;
@Override
public Query<User> users()
{
- return module.currentUnitOfWork()
- .newQuery( module.newQueryBuilder( User.class ) )
+ return uowf.currentUnitOfWork()
+ .newQuery( qbf.newQueryBuilder( User.class ) )
.orderBy( templateFor( User.class ).realName() );
}
@Override
public User userNamed( String name )
{
- return module.currentUnitOfWork().newQuery(
- module.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(), name ) )
+ return uowf.currentUnitOfWork().newQuery(
+ qbf.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(), name ) )
).find();
}
@Override
public void signedup( Registration registration )
{
- EntityBuilder<User> builder = module.currentUnitOfWork().newEntityBuilder( User.class );
+ EntityBuilder<User> builder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
builder.instance().name().set( registration.name().get() );
builder.instance().realName().set( registration.realName().get() );
builder.instance().email().set( registration.email().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
index ed347f2..6cbec1a 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
@@ -26,11 +26,12 @@ import org.apache.zest.api.concern.Concerns;
import org.apache.zest.api.concern.GenericConcern;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.functional.Iterables;
import org.apache.zest.library.rest.server.api.ObjectSelection;
import org.restlet.Request;
@@ -46,7 +47,10 @@ public @interface DomainEvent
extends GenericConcern
{
@Structure
- Module module;
+ ValueBuilderFactory vbf;
+
+ @Structure
+ UnitOfWorkFactory uowf;
@Structure
Application application;
@@ -57,9 +61,9 @@ public @interface DomainEvent
{
Object result = next.invoke( proxy, method, args );
- UnitOfWork unitOfWork = module.currentUnitOfWork();
+ UnitOfWork unitOfWork = uowf.currentUnitOfWork();
- ValueBuilder<DomainEventValue> builder = module.newValueBuilder( DomainEventValue.class );
+ ValueBuilder<DomainEventValue> builder = vbf.newValueBuilder( DomainEventValue.class );
DomainEventValue prototype = builder.prototype();
prototype.version().set( application.version() );
prototype.timestamp().set( unitOfWork.currentTime() );
@@ -71,7 +75,7 @@ public @interface DomainEvent
{
idx++;
String name = "param" + idx;
- ValueBuilder<ParameterValue> parameterBuilder = module.newValueBuilder( ParameterValue.class );
+ ValueBuilder<ParameterValue> parameterBuilder = vbf.newValueBuilder( ParameterValue.class );
parameterBuilder.prototype().name().set( name );
parameterBuilder.prototype().value().set( arg );
prototype.parameters().get().add( parameterBuilder.newInstance() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
index c63077d..edf6fb1 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
@@ -33,6 +33,6 @@ public class ForumRestlet
@Override
protected Uniform createRoot( Request request, Response response )
{
- return module.newObject( RootResource.class, this );
+ return objectFactory.newObject( RootResource.class, this );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
index c220d91..c635717 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
@@ -25,10 +25,10 @@ import org.apache.zest.api.mixin.InitializationException;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.forum.data.entity.Forums;
import org.apache.zest.sample.forum.data.entity.Users;
@@ -40,28 +40,27 @@ import org.apache.zest.sample.forum.data.entity.Users;
public interface BootstrapData
extends ServiceComposite
{
-
+
void insertInitialData()
- throws Exception;
+ throws Exception;
class Activator
- extends ActivatorAdapter<ServiceReference<BootstrapData>>
+ extends ActivatorAdapter<ServiceReference<BootstrapData>>
{
@Override
public void afterActivation( ServiceReference<BootstrapData> activated )
- throws Exception
+ throws Exception
{
activated.get().insertInitialData();
}
-
}
-
+
abstract class Mixin
implements BootstrapData
{
@Structure
- Module module;
+ private UnitOfWorkFactory module;
@Override
public void insertInitialData()
@@ -96,6 +95,5 @@ public interface BootstrapData
throw new InitializationException( e );
}
}
-
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
----------------------------------------------------------------------
diff --git a/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java b/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
index ddb2d3e..4592e17 100644
--- a/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
+++ b/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
@@ -72,14 +72,14 @@ public class Main
try {
- UnitOfWork uow = domainModule.newUnitOfWork();
+ UnitOfWork uow = domainModule.unitOfWorkFactory().newUnitOfWork();
EntityBuilder<PretextEntity> builder = uow.newEntityBuilder( PretextEntity.class );
PretextEntity pretext = builder.instance();
pretext.reason().set( "Testing purpose" );
builder.newInstance();
uow.complete();
- uow = domainModule.newUnitOfWork();
+ uow = domainModule.unitOfWorkFactory().newUnitOfWork();
QueryBuilder<PretextEntity> queryBuilder = domainModule.newQueryBuilder( PretextEntity.class );
queryBuilder = queryBuilder.where( eq( templateFor( PretextEntity.class ).reason(), "Testing purpose" ) );
Query<PretextEntity> query = uow.newQuery( queryBuilder );
@@ -107,7 +107,7 @@ public class Main
{
// EntityStore Data
{
- UnitOfWork uow = persistenceModule.newUnitOfWork();
+ UnitOfWork uow = persistenceModule.unitOfWorkFactory().newUnitOfWork();
try {
SQLConfiguration config = uow.get( SQLConfiguration.class,
PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
@@ -134,7 +134,7 @@ public class Main
// Indexing Data
{
- UnitOfWork uow = persistenceModule.newUnitOfWork();
+ UnitOfWork uow = persistenceModule.unitOfWorkFactory().newUnitOfWork();
try {
SQLConfiguration config = uow.get( SQLConfiguration.class, PostgreSQLIndexQueryAssembler.DEFAULT_IDENTITY );
Connection connection = persistenceModule.findService( DataSource.class ).get().getConnection();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java b/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
index b35ace8..93eafd0 100644
--- a/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
+++ b/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
@@ -25,16 +25,16 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.Callable;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.zest.api.service.ServiceFinder;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.bootstrap.ApplicationAssemblerAdapter;
import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.ModuleAssembly;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +49,8 @@ public abstract class AbstractEntityStorePerformanceTest
private final Assembler infrastructure;
private final Logger logger;
private Application application;
- protected Module module;
+ protected UnitOfWorkFactory uowf;
+ protected ServiceFinder serviceFinder;
private final int ITERATIONS = 20000;
@@ -66,23 +67,15 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( SimpleProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( SimpleProduct.class );
createZestRuntime( assembler );
for( int i = 0; i < 10000; i++ )
{
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "Warmup " + i ) ) )
+ try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Warmup " + i ) ))
{
SimpleProduct product = uow.newEntity( SimpleProduct.class );
- String id = product.identity().get();
+ product.identity().get();
}
}
}
@@ -103,42 +96,28 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( SimpleProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( SimpleProduct.class );
createZestRuntime( assembler );
- profile( new Callable<Void>()
- {
- @Override
- public Void call()
- throws Exception
+ profile( () -> {
+ Report report = new Report( storeName );
+ report.start( "createEntityWithSingleProperty" );
+ for( int i = 0; i < ITERATIONS; i++ )
{
- Report report = new Report( storeName );
- report.start( "createEntityWithSingleProperty" );
- for( int i = 0; i < ITERATIONS; i++ )
+ try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityWithSingleProperty " + i ) ))
{
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityWithSingleProperty " + i ) ) )
- {
- SimpleProduct product = uow.newEntity( SimpleProduct.class );
- String id = product.identity().get();
- uow.complete();
- }
- if( i % 1000 == 0 )
- {
- logger.info( "Iteration {}", i );
- }
+ SimpleProduct product = uow.newEntity( SimpleProduct.class );
+ product.identity().get();
+ uow.complete();
+ }
+ if( i % 1000 == 0 )
+ {
+ logger.info( "Iteration {}", i );
}
- report.stop( ITERATIONS );
- writeReport( report );
- return null;
}
+ report.stop( ITERATIONS );
+ writeReport( report );
+ return null;
} );
}
finally
@@ -153,42 +132,28 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( SimpleProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( SimpleProduct.class );
createZestRuntime( assembler );
- profile( new Callable<Void>()
- {
- @Override
- public Void call()
- throws Exception
+ profile( () -> {
+ Report report = new Report( storeName );
+ report.start( "createEntityInBulkWithSingleProperty" );
+ int bulk = 0;
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
+ for( int i = 0; i < ITERATIONS; i++ )
{
- Report report = new Report( storeName );
- report.start( "createEntityInBulkWithSingleProperty" );
- int bulk = 0;
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
- for( int i = 0; i < ITERATIONS; i++ )
+ SimpleProduct product = uow.newEntity( SimpleProduct.class );
+ product.identity().get();
+ if( i % 1000 == 0 )
{
- SimpleProduct product = uow.newEntity( SimpleProduct.class );
- String id = product.identity().get();
- if( i % 1000 == 0 )
- {
- uow.complete();
- bulk++;
- uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
- }
+ uow.complete();
+ bulk++;
+ uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
}
- uow.complete();
- report.stop( ITERATIONS );
- writeReport( report );
- return null;
}
+ uow.complete();
+ report.stop( ITERATIONS );
+ writeReport( report );
+ return null;
} );
}
finally
@@ -203,37 +168,23 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( ComplexProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( ComplexProduct.class );
createZestRuntime( assembler );
- profile( new Callable<Void>()
- {
- @Override
- public Void call()
- throws Exception
+ profile( () -> {
+ Report report = new Report( storeName );
+ report.start( "createEntityWithComplexType" );
+ for( int i = 0; i < ITERATIONS; i++ )
{
- Report report = new Report( storeName );
- report.start( "createEntityWithComplexType" );
- for( int i = 0; i < ITERATIONS; i++ )
+ try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityWithComplexType " + i ) ))
{
- try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityWithComplexType " + i ) ) )
- {
- ComplexProduct product = uow.newEntity( ComplexProduct.class );
- String id = product.identity().get();
- uow.complete();
- }
+ ComplexProduct product = uow.newEntity( ComplexProduct.class );
+ product.identity().get();
+ uow.complete();
}
- report.stop( ITERATIONS );
- writeReport( report );
- return null;
}
+ report.stop( ITERATIONS );
+ writeReport( report );
+ return null;
} );
}
finally
@@ -248,42 +199,28 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( ComplexProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( ComplexProduct.class );
createZestRuntime( assembler );
- profile( new Callable<Void>()
- {
- @Override
- public Void call()
- throws Exception
+ profile( () -> {
+ Report report = new Report( storeName );
+ report.start( "createEntityInBulkWithComplexType" );
+ int bulk = 0;
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
+ for( int i = 0; i < ITERATIONS; i++ )
{
- Report report = new Report( storeName );
- report.start( "createEntityInBulkWithComplexType" );
- int bulk = 0;
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
- for( int i = 0; i < ITERATIONS; i++ )
+ ComplexProduct product = uow.newEntity( ComplexProduct.class );
+ product.identity().get();
+ if( i % 1000 == 0 )
{
- ComplexProduct product = uow.newEntity( ComplexProduct.class );
- String id = product.identity().get();
- if( i % 1000 == 0 )
- {
- uow.complete();
- bulk++;
- uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
- }
+ uow.complete();
+ bulk++;
+ uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
}
- uow.complete();
- report.stop( ITERATIONS );
- writeReport( report );
- return null;
}
+ uow.complete();
+ report.stop( ITERATIONS );
+ writeReport( report );
+ return null;
} );
}
finally
@@ -298,19 +235,11 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- Assembler assembler = new Assembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( ComplexProduct.class );
- }
- };
+ Assembler assembler = module -> module.entities( ComplexProduct.class );
createZestRuntime( assembler );
{
int bulk = 0;
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
for( int i = 0; i < ITERATIONS; i++ )
{
ComplexProduct product = uow.newEntity( ComplexProduct.class, "product" + i );
@@ -320,42 +249,34 @@ public abstract class AbstractEntityStorePerformanceTest
{
uow.complete();
bulk++;
- uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
+ uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
}
}
uow.complete();
}
- profile( new Callable<Void>()
- {
- @Override
- public Void call()
- throws Exception
+ profile( () -> {
+ Report report = new Report( storeName );
+ int bulk = 0;
+ UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
+ Random rnd = new Random();
+ report.start( "readEntityWithComplexType" );
+ String id = rnd.nextInt( ITERATIONS ) + "";
+ for( int i = 0; i < ITERATIONS; i++ )
{
- Report report = new Report( storeName );
- int bulk = 0;
- UnitOfWork uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
- Random rnd = new Random();
- report.start( "readEntityWithComplexType" );
- String id = rnd.nextInt( ITERATIONS ) + "";
- for( int i = 0; i < ITERATIONS; i++ )
+ ComplexProduct product = uow.get( ComplexProduct.class, "product" + id );
+ product.name().get();
+ if( i % 100 == 0 )
{
- ComplexProduct product = uow.get( ComplexProduct.class, "product" + id );
-
- String name = product.name().get();
-
- if( i % 100 == 0 )
- {
- uow.discard();
- bulk++;
- uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
- }
+ uow.discard();
+ bulk++;
+ uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
}
- uow.complete();
- report.stop( ITERATIONS );
- writeReport( report );
- return null;
}
+ uow.complete();
+ report.stop( ITERATIONS );
+ writeReport( report );
+ return null;
} );
}
finally
@@ -376,10 +297,13 @@ public abstract class AbstractEntityStorePerformanceTest
throws IOException
{
File dir = new File( "build/reports/perf/" );
- dir.mkdirs();
+ if( !dir.mkdirs() )
+ {
+ System.out.println( "Couldn't create Performance result directory." );
+ }
String name = dir.getAbsolutePath() + "/result-" + report.name() + ".xml";
FileWriter writer = new FileWriter( name, true );
- try( BufferedWriter out = new BufferedWriter( writer ) )
+ try (BufferedWriter out = new BufferedWriter( writer ))
{
report.writeTo( out );
out.flush();
@@ -392,20 +316,21 @@ public abstract class AbstractEntityStorePerformanceTest
{
Energy4Java zest = new Energy4Java();
Assembler[][][] assemblers = new Assembler[][][]
- {
{
{
- infrastructure, testSetup
+ {
+ infrastructure, testSetup
+ }
}
- }
- };
+ };
application = zest.newApplication( new ApplicationAssemblerAdapter( assemblers )
{
} );
application.activate();
Module moduleInstance = application.findModule( "Layer 1", "Module 1" );
- module = moduleInstance;
+ uowf = moduleInstance.unitOfWorkFactory();
+ serviceFinder = moduleInstance;
}
protected void cleanUp()
@@ -413,10 +338,10 @@ public abstract class AbstractEntityStorePerformanceTest
{
try
{
- if( module != null && module.isUnitOfWorkActive() )
+ if( uowf != null && uowf.isUnitOfWorkActive() )
{
UnitOfWork current;
- while( module.isUnitOfWorkActive() && ( current = module.currentUnitOfWork() ) != null )
+ while( uowf.isUnitOfWorkActive() && ( current = uowf.currentUnitOfWork() ) != null )
{
if( current.isOpen() )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
index 180ee27..3abd538 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
@@ -87,17 +87,17 @@ public class DerbySQLEntityStorePerformanceTest
protected void cleanUp()
throws Exception
{
- if( module == null )
+ if( uowf == null )
{
return;
}
- UnitOfWork uow = this.module.newUnitOfWork( UsecaseBuilder.newUsecase(
+ UnitOfWork uow = this.uowf.newUnitOfWork( UsecaseBuilder.newUsecase(
"Delete " + getClass().getSimpleName() + " test data" ) );
try
{
SQLConfiguration config = uow.get( SQLConfiguration.class,
DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
- Connection connection = module.findService( DataSource.class ).get().getConnection();
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
String schemaName = config.schemaName().get();
if( schemaName == null )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
index 47238a8..3e04c01 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
@@ -115,7 +115,7 @@ public class PostgreSQLEntityStorePerformanceTest
application.activate();
Module moduleInstance = application.findModule( "Layer 1", "config" );
- UnitOfWorkFactory uowf = moduleInstance;
+ UnitOfWorkFactory uowf = moduleInstance.unitOfWorkFactory();
UnitOfWork uow = uowf.newUnitOfWork();
try
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
index 321f30f..912172e 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
@@ -20,6 +20,8 @@ package org.apache.zest.test.performance.indexing.rdf;
import java.io.File;
import org.apache.derby.iapi.services.io.FileUtil;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -70,6 +72,7 @@ public class QueryPerformanceTest
private Application application;
private Module module;
+ private UnitOfWorkFactory uowf;
private static final String QUERY1 = "PREFIX ns0: <urn:zest:type:org.apache.zest.api.entity.Identity#> \n"
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
@@ -136,6 +139,7 @@ public class QueryPerformanceTest
module = application.findModule( LAYER_DOMAIN, MODULE_DOMAIN );
application.activate();
indexingDataDir = module.findService( RdfIndexingService.class ).get().dataDir();
+ uowf = module.unitOfWorkFactory();
}
@After
@@ -196,7 +200,7 @@ public class QueryPerformanceTest
private LeadRepository populateEntityStore()
throws UnitOfWorkCompletionException
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
LeadRepository leadRepo = module.findService( LeadRepositoryService.class ).get();
@@ -212,7 +216,7 @@ public class QueryPerformanceTest
{
System.out.print( "\r" + i );
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
}
leadFactory.create( "Lead" + i );
}
@@ -237,7 +241,7 @@ public class QueryPerformanceTest
{
long start;
long end;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
start = System.currentTimeMillis();
Lead lead = leadRepo.findByName( nameOfEntity );
@@ -258,7 +262,7 @@ public class QueryPerformanceTest
{
long start;
long end;
- try( UnitOfWork uow = module.newUnitOfWork() )
+ try( UnitOfWork uow = uowf.newUnitOfWork() )
{
start = System.currentTimeMillis();
Lead lead = leadRepo.findByFixedQuery( queryName );
@@ -338,12 +342,12 @@ public class QueryPerformanceTest
implements LeadEntityFactory
{
@Structure
- private Module module;
+ private UnitOfWorkFactory uowf;
@Override
public Lead create( String name )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<LeadEntity> builder = uow.newEntityBuilder( LeadEntity.class );
Lead prototype = builder.instanceFor( LeadEntity.class );
prototype.name().set( name );
@@ -368,21 +372,24 @@ public class QueryPerformanceTest
implements LeadRepository
{
@Structure
- private Module module;
+ private QueryBuilderFactory qbf;
+
+ @Structure
+ private UnitOfWorkFactory uowf;
@Override
public Lead findByFixedQuery( String queryString )
{
- UnitOfWork uow = module.currentUnitOfWork();
- Query<Lead> query = uow.newQuery( module.newQueryBuilder( Lead.class ).where( SesameExpressions.sparql( queryString ) ) );
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ Query<Lead> query = uow.newQuery( qbf.newQueryBuilder( Lead.class ).where( SesameExpressions.sparql( queryString ) ) );
return query.find();
}
@Override
public Lead findByName( String name )
{
- UnitOfWork uow = module.currentUnitOfWork();
- QueryBuilder<Lead> builder = module.newQueryBuilder( Lead.class );
+ UnitOfWork uow = uowf.currentUnitOfWork();
+ QueryBuilder<Lead> builder = qbf.newQueryBuilder( Lead.class );
Lead template = templateFor( Lead.class );
Query<Lead> query = uow.newQuery( builder.where( eq( template.name(), name ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties b/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
index b694372..4e5c3f6 100644
--- a/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
+++ b/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
@@ -15,7 +15,7 @@
ICON_Application=application.png
ICON_Layer=layer.png
-ICON_Module=module.png
+ICON_Module=unitOfWorkFactory.png
ICON_Service=service.png
ICON_ImportedService=importedService.png
ICON_Entity=entity.png
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java b/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
index ddf04b3..80a2cd6 100644
--- a/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
+++ b/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
@@ -75,7 +75,7 @@ public class EnvisageSample
public void createTestData()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
createCar( "Volvo", "S80", 2007 );
@@ -101,7 +101,7 @@ public class EnvisageSample
private String createCar( String manufacturer, String model, int year )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Car> builder = uow.newEntityBuilder( Car.class );
Car prototype = builder.instanceFor( CarEntity.class );
prototype.manufacturer().set( manufacturer );
@@ -113,7 +113,7 @@ public class EnvisageSample
private String createAnimal( String name, String sound )
{
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<Animal> builder = uow.newEntityBuilder( Animal.class );
Animal prototype = builder.instanceFor( AnimalEntity.class );
prototype.name().set( name );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
index e91636b..98e4a7d 100644
--- a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
+++ b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
@@ -51,24 +51,18 @@ public class VisitableDetailTest
throws AssemblyException, ActivationException
{
ApplicationDescriptor application = new Energy4Java().newApplicationModel(
- new ApplicationAssembler()
- {
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
- {
- ApplicationAssembly app = applicationFactory.newApplicationAssembly();
- app.setName( "UnderTestApp" );
- app.withActivators( ApplicationActivator.class );
+ applicationFactory -> {
+ ApplicationAssembly app = applicationFactory.newApplicationAssembly();
+ app.setName( "UnderTestApp" );
+ app.withActivators( ApplicationActivator.class );
- LayerAssembly layer = app.layer( "LayerName" );
- layer.withActivators( LayerActivator.class );
+ LayerAssembly layer = app.layer( "LayerName" );
+ layer.withActivators( LayerActivator.class );
- ModuleAssembly module = layer.module( "ModuleName" );
- module.withActivators( ModuleActivator.class );
+ ModuleAssembly module = layer.module( "ModuleName" );
+ module.withActivators( ModuleActivator.class );
- return app;
- }
+ return app;
}
);
ApplicationDetailDescriptor detail = createApplicationDetailDescriptor( application );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
----------------------------------------------------------------------
diff --git a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
index 3ce8125..8c31e1b 100644
--- a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
+++ b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
@@ -37,7 +37,7 @@ public class HelloTest4 extends AbstractZestTest
@Test
public void givenHelloValueInitializedToHelloWorldWhenCallingSayExpectHelloWorld()
{
- UnitOfWork uow = module.newUnitOfWork();
+ UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityBuilder<Hello> builder = uow.newEntityBuilder( Hello.class, "123" );
@@ -45,7 +45,7 @@ public class HelloTest4 extends AbstractZestTest
builder.instanceFor( Hello.State.class ).name().set( "World" );
builder.newInstance();
uow.complete();
- uow = module.newUnitOfWork();
+ uow = uowf.newUnitOfWork();
Hello underTest = uow.get( Hello.class, "123" );
String result = underTest.say();
uow.complete();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
----------------------------------------------------------------------
diff --git a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
index d71b98c..26a0a92 100644
--- a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
+++ b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
@@ -33,10 +33,11 @@ import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
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.demo.tenminute.Confirmable;
import org.apache.zest.demo.tenminute.HasCustomer;
@@ -56,7 +57,9 @@ import org.apache.zest.api.query.QueryBuilder;
// END SNIPPET: 6
public class ThirtyMinutesDocs
{
- Module module;
+ private QueryBuilderFactory queryBuilderFactory;
+ private ValueBuilderFactory valueBuilderFactory;
+ private UnitOfWorkFactory unitOfWorkFactory;
// START SNIPPET: 6
@Structure private UnitOfWorkFactory uowFactory; //Injected
@@ -65,7 +68,7 @@ public class ThirtyMinutesDocs
{
// START SNIPPET: 6
UnitOfWork uow = uowFactory.currentUnitOfWork();
- QueryBuilder<Order> builder = module.newQueryBuilder( Order.class );
+ QueryBuilder<Order> builder = queryBuilderFactory.newQueryBuilder( Order.class );
String orderNumber = "12345";
HasSequenceNumber template = templateFor( HasSequenceNumber.class );
@@ -94,10 +97,10 @@ public class ThirtyMinutesDocs
{
Report report = null;
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
// START SNIPPET: 7
- QueryBuilder<Order> builder = module.newQueryBuilder( Order.class );
+ QueryBuilder<Order> builder = queryBuilderFactory.newQueryBuilder( Order.class );
Calendar cal = Calendar.getInstance();
cal.setTime( new Date() );
@@ -116,10 +119,10 @@ public class ThirtyMinutesDocs
{
Report report = null;
- UnitOfWork uow = module.currentUnitOfWork();
+ UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
// START SNIPPET: 8
- QueryBuilder<HasCustomer> builder = module.newQueryBuilder( HasCustomer.class );
+ QueryBuilder<HasCustomer> builder = queryBuilderFactory.newQueryBuilder( HasCustomer.class );
Calendar cal = Calendar.getInstance();
cal.setTime( new Date() );
@@ -200,7 +203,7 @@ public class ThirtyMinutesDocs
private Action<M> addAction( M item, Action.Type type )
{
ValueBuilder<Action> builder =
- module.newValueBuilder(Action.class); // [4]
+ valueBuilderFactory.newValueBuilder( Action.class); // [4]
Action<M> prototype = builder.prototypeFor( Action.class );
prototype.item().set( item );
prototype.action().set( type );
[27/34] zest-java git commit: Merge branch 'develop' into ZEST-105
Posted by ni...@apache.org.
Merge branch 'develop' into ZEST-105
Also fixed a sequencing problem in type lookup of services.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/9a5c94c3
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/9a5c94c3
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/9a5c94c3
Branch: refs/heads/develop
Commit: 9a5c94c3453705a5ad22d95a85a8aeeeb0256e57
Parents: 72314b8 8a6ddd2
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Wed Apr 13 17:40:23 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Wed Apr 13 17:40:23 2016 +0800
----------------------------------------------------------------------
.../org/apache/zest/api/dataset/DataSet.java | 36 ------
.../apache/zest/api/dataset/DataSetSource.java | 27 ----
.../java/org/apache/zest/api/dataset/Query.java | 64 ----------
.../api/dataset/iterable/IterableDataSet.java | 57 ---------
.../api/dataset/iterable/IterableQuery.java | 127 -------------------
.../zest/api/dataset/iterable/package.html | 21 ---
.../org/apache/zest/api/dataset/package.html | 21 ---
.../dataset/iterable/IterableDataSetTest.java | 61 ---------
8 files changed, 414 deletions(-)
----------------------------------------------------------------------