Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A0531826B for ; Thu, 17 Dec 2015 13:16:19 +0000 (UTC) Received: (qmail 20915 invoked by uid 500); 17 Dec 2015 13:16:19 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 20870 invoked by uid 500); 17 Dec 2015 13:16:19 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 20689 invoked by uid 99); 17 Dec 2015 13:16:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Dec 2015 13:16:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5B0ECE112C; Thu, 17 Dec 2015 13:16:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: niclas@apache.org To: commits@zest.apache.org Date: Thu, 17 Dec 2015 13:16:27 -0000 Message-Id: <0e06a53ae4854705bd4a8d1244e8ccd4@git.apache.org> In-Reply-To: <2bbb54267a634474a398b5bf10554eac@git.apache.org> References: <2bbb54267a634474a398b5bf10554eac@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/12] zest-java git commit: ZEST-136 - Massive changes to the Runtime, refactoring the Model and Instance relationship. 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/ZEST-105 Commit: dedb068e4b56fce8d6c21f5938396eb84da63f7c Parents: 81561b0 Author: Niclas Hedhman Authored: Thu Dec 17 20:40:00 2015 +0800 Committer: Niclas Hedhman 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 extends ThreadLocal { - private Module module; + private ModuleDescriptor module; private Class type; - public CompositeContext( Module module, Class type ) + public CompositeContext( ModuleDescriptor module, Class type ) { this.module = module; this.type = type; @@ -42,7 +42,7 @@ public class CompositeContext @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 newProxy( Class 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) type, value ); + return ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( composite ).module().instance().newValueFromSerializedState( (Class) 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 ) 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 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 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 visibleObjects( Visibility visibility ); + + Stream visibleTransients( Visibility visibility ); + + Stream visibleEntities( Visibility visibility ); + + Stream visibleValues( Visibility visibility ); + + Stream 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 transientComposites(); - - Stream valueComposites(); - - Stream serviceComposites(); - - Stream entityComposites(); - - Stream importedServices(); + LayerDescriptor layer(); - Stream 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 findVisibleTransientTypes(); + + Stream findVisibleValueTypes(); + + Stream findVisibleEntityTypes(); + + Stream findVisibleObjectTypes(); + + Stream transientComposites(); + + Stream valueComposites(); + + Stream entityComposites(); + + Stream objects(); + + Stream importedServices(); + + Stream 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. + * + *

First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple assignable matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Type lookup is done lazily and cached.

+ * + * @param type Looked up Type + * + * @return First matching Object Model + */ + ObjectDescriptor lookupObjectModel( Class type ); + + /** + * Lookup first Transient Model matching the given Type. + * + *

First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple assignable matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Type lookup is done lazily and cached.

+ * + * @param type Looked up Type + * + * @return First matching Transient Model + */ + TransientDescriptor lookupTransientModel( Class type ); + + /** + * Lookup first Value Model matching the given Type. + * + *

First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple assignable matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Type lookup is done lazily and cached.

+ * + * @param type Looked up Type + * + * @return First matching Value Model + */ + ValueDescriptor lookupValueModel( Class type ); + + /** + * Lookup first Entity Model matching the given Type. + * + *

First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple assignable matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Type lookup is done lazily and cached.

+ * + *

Should be used for creational use cases only. For non-creational use cases see + * {@link #lookupEntityModels(Class)}.

+ * + * @param type Looked up Type + * + * @return First matching Entity Model + */ + EntityDescriptor lookupEntityModel( Class type ); + + /** + * Lookup all Entity Models matching the given Type. + * + *

Returned Iterable contains, in order, Entity Models that:

+ * + *
    + *
  • exactly match the given type, in Visibility then Assembly order ;
  • + *
  • match a type assignable to the given type, in Visibility then Assembly order.
  • + *
+ * + *

Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ *

Multiple assignable matches are allowed to enable polymorphic fetches and queries.

+ * + *

Type lookup is done lazily and cached.

+ * + *

Should be used for non-creational use cases only. For creational use cases see + * {@link #lookupEntityModel(Class)}.

+ * + * @param type Looked up Type + * + * @return All matching Entity Models + */ + Iterable lookupEntityModels( Class type ); + + /** + * Lookup first ServiceDescriptor/ImportedServiceDescriptor matching the given Type. + * + *

Type lookup is done lazily and cached.

+ * + *

See {@link #lookupServiceModels(Type)}.

+ * + * @param serviceType Looked up Type + * + * @return First matching Service + */ + ModelDescriptor lookupServiceModel( Type serviceType ); + + /** + * Lookup all ServiceDescriptors matching the given Type. + * + *

Returned List contains, in order, ServiceReferences that:

+ * + *
    + *
  • exactly match the given type, in Visibility then Assembly order ;
  • + *
  • match a type assignable to the given type, in Visibility then Assembly order.
  • + *
+ * + *

Multiple exact matches with the same Visibility are allowed to enable polymorphic lookup/injection.

+ *

Multiple assignable matches with the same Visibility are allowed for the very same reason.

+ * + *

Type lookup is done lazily and cached.

+ * + * @param type Looked up Type + * + * @return All matching ServiceReferences + */ + List lookupServiceModels( Type type ); + + Stream allObjects(); + + Stream allTransients(); + + Stream allValues(); + + Stream allEntities(); + + Stream allServices(); + + Stream> 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 layers(); + Stream 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 visibility ) + private EntityTypeNotFoundException( String entityType, String moduleName, Stream 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 propertyFunction, Function associationFunction, Function> manyAssociationFunction, - Function> namedAssociationFunction ) + Function> namedAssociationFunction + ) throws EntityTypeNotFoundException, AmbiguousTypeException; /** @@ -234,7 +236,8 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable Function propertyFunction, Function associationFunction, Function> manyAssociationFunction, - Function> namedAssociationFunction ) + Function> namedAssociationFunction + ) throws EntityTypeNotFoundException, AmbiguousTypeException; /** @@ -431,4 +434,12 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable * @return The new or updated Entity */ T toEntity( Class 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 protected abstract void build( T prototype ); - public T newInstance( Module module ) + public T newInstance( ModuleDescriptor module ) { - ValueBuilder builder = module.newValueBuilder( type ); + ValueBuilder 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. * *

- * Serialized state must be one of: + * Serialized state must be one of: *

*
    - *
  • a ValueComposite,
  • - *
  • an EntityReference,
  • - *
  • a Collection,
  • - *
  • a Map,
  • - *
  • a Plain Value.
  • + *
  • a ValueComposite,
  • + *
  • an EntityReference,
  • + *
  • a Collection,
  • + *
  • a Map,
  • + *
  • a Plain Value.
  • *
*

- * 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. *

*

- * Plain values can be one of: + * Plain values can be one of: *

*
    - *
  • String,
  • - *
  • Character or char,
  • - *
  • Boolean or boolean,
  • - *
  • Integer or int,
  • - *
  • Long or long,
  • - *
  • Short or short,
  • - *
  • Byte or byte,
  • - *
  • Float or float,
  • - *
  • Double or double,
  • - *
  • BigInteger,
  • - *
  • BigDecimal,
  • - *
  • Date,
  • - *
  • DateTime (JodaTime),
  • - *
  • LocalDateTime (JodaTime),
  • - *
  • LocalDate (JodaTime).
  • + *
  • String,
  • + *
  • Character or char,
  • + *
  • Boolean or boolean,
  • + *
  • Integer or int,
  • + *
  • Long or long,
  • + *
  • Short or short,
  • + *
  • Byte or byte,
  • + *
  • Float or float,
  • + *
  • Double or double,
  • + *
  • BigInteger,
  • + *
  • BigDecimal,
  • + *
  • Date,
  • + *
  • DateTime (JodaTime),
  • + *
  • LocalDateTime (JodaTime),
  • + *
  • LocalDate (JodaTime).
  • *
*

- * 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. *

*

- * 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. *

*/ public interface ValueDeserializer @@ -76,10 +76,11 @@ public interface ValueDeserializer *

The returned Function may throw {@link ValueSerializationException}.

* * @param type the value type - * @param the parametrized function return type + * @param the parametrized function return type + * * @return a deserialization function */ - Function deserialize( Class type ); + Function deserialize( ModuleDescriptor module, Class type ); /** * Factory method for a typed deserialize function. @@ -87,10 +88,11 @@ public interface ValueDeserializer *

The returned Function may throw {@link ValueSerializationException}.

* * @param valueType the value type - * @param the parametrized function return type + * @param the parametrized function return type + * * @return a deserialization function */ - Function deserialize( ValueType valueType ); + Function deserialize( ModuleDescriptor module, ValueType valueType ); /** * Factory method for an untyped deserialize function. @@ -100,53 +102,61 @@ public interface ValueDeserializer * @param the parametrized function return type * @return a deserialization function */ - BiFunction deserialize(); +// BiFunction deserialize(); /** * Deserialize a value from a state. * - * @param the parametrized returned type - * @param type the value type + * @param the parametrized returned type + * @param type the value type * @param input the state + * * @return the value + * * @throws ValueSerializationException if the deserialization failed */ - T deserialize( Class type, String input ) + T deserialize( ModuleDescriptor module, Class type, String input ) throws ValueSerializationException; /** * Deserialize a value from a state. * - * @param the parametrized returned type + * @param 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 deserialize( ValueType valueType, String input ) + T deserialize( ModuleDescriptor module, ValueType valueType, String input ) throws ValueSerializationException; /** * Deserialize a value from a state. * - * @param the parametrized returned type - * @param type the value type + * @param the parametrized returned type + * @param type the value type * @param input the state stream + * * @return the value + * * @throws ValueSerializationException if the deserialization failed */ - T deserialize( Class type, InputStream input ) + T deserialize( ModuleDescriptor module, Class type, InputStream input ) throws ValueSerializationException; /** * Deserialize a value from a state. * - * @param the parametrized returned type + * @param 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 deserialize( ValueType valueType, InputStream input ) + 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 builder = module.newTransientBuilder( View1.class ); + TransientBuilder 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 builder = module.newTransientBuilder( View2.class ); + TransientBuilder 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 values = valueDeserializer.deserialize( CollectionType.listOf( AcmeValue.class ), input ); + List values = valueDeserializer.deserialize( module, CollectionType.listOf( AcmeValue.class ), input ); // END SNIPPET: stream assertThat( values, equalTo( dataSource ) ); @@ -197,7 +191,7 @@ public class DocumentationSupport List values = new ArrayList(); // (5) - Function deserialize = valueDeserializer.deserialize( AcmeValue.class ); + Function 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 anotherBuilder = module.newValueBuilder( AnotherValue.class ); + ValueBuilder anotherBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class ); anotherBuilder.prototype().val1().set( "Val1" ); AnotherValue anotherValue = anotherBuilder.newInstance(); - ValueBuilder builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) ); - ValueBuilder valueBuilder = module.newValueBuilder( AnotherValue.class ); + ValueBuilder builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); + builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); + ValueBuilder 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 builder = module.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( module.newValue( AnotherValue.class ) ); - ValueBuilder valueBuilder = module.newValueBuilder( AnotherValue.class ); + ValueBuilder builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); + builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); + ValueBuilder 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 associationBuilder = module.newValueBuilder( AssociationValue.class ); + ValueBuilder 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 return activators; } - public Iterable> newInstances( Module module ) + public Iterable> newInstances( ModuleDescriptor module ) throws ActivationException { List> activators = new ArrayList<>(); for( ActivatorModel 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 ); }