ZEST-180, ZEST-186, ZEST-187, ZEST-188 Big Identity refactoring UnitOfWorkFactory is auto added to all modules that doesn't declare one IdentityGenerator is auto-added to all modules that deosn't declare one. Removed DCI/DDD examples, due to poor use of Identity conflicting with new Identity model. Not trivial to fix properly, but the hack would be a bad example of how to use identities.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/103c59cb Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/103c59cb Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/103c59cb Branch: refs/heads/develop Commit: 103c59cbeb2907d0b3a132a1aa852e2e1b8585ae Parents: e030bd8 Author: Niclas Hedhman <[email protected]> Authored: Sun Oct 23 22:16:52 2016 +0800 Committer: Niclas Hedhman <[email protected]> Committed: Sun Oct 23 22:16:54 2016 +0800 ---------------------------------------------------------------------- .../zest/api/configuration/Configuration.java | 59 +- .../configuration/ConfigurationComposite.java | 6 +- .../NoSuchConfigurationException.java | 16 +- .../ConstraintViolationException.java | 5 +- .../apache/zest/api/entity/EntityComposite.java | 6 +- .../apache/zest/api/entity/EntityReference.java | 80 +-- .../org/apache/zest/api/entity/Identity.java | 61 -- .../zest/api/entity/IdentityGenerator.java | 35 - .../org/apache/zest/api/entity/Lifecycle.java | 2 +- .../apache/zest/api/identity/HasIdentity.java | 83 +++ .../apache/zest/api/identity/Identifiable.java | 6 + .../org/apache/zest/api/identity/Identity.java | 14 + .../zest/api/identity/IdentityGenerator.java | 39 ++ .../zest/api/identity/StringIdentity.java | 67 ++ .../zest/api/identity/UuidGeneratorMixin.java | 13 + .../apache/zest/api/query/QueryExpressions.java | 33 +- .../grammar/AssociationNotNullPredicate.java | 2 +- .../query/grammar/AssociationNullPredicate.java | 2 +- .../api/query/grammar/MatchesPredicate.java | 10 +- .../DuplicateServiceIdentityException.java | 2 +- .../zest/api/service/IdentityDescriptor.java | 28 - .../api/service/ImportedServiceDescriptor.java | 3 +- .../zest/api/service/ServiceComposite.java | 4 +- .../zest/api/service/ServiceDescriptor.java | 4 +- .../zest/api/service/ServiceReference.java | 13 +- .../importer/ServiceInstanceImporter.java | 7 +- .../api/service/qualifier/ServiceQualifier.java | 4 +- .../org/apache/zest/api/type/ValueType.java | 6 + .../EntityCompositeAlreadyExistsException.java | 14 +- .../api/unitofwork/NoSuchEntityException.java | 25 +- .../apache/zest/api/unitofwork/UnitOfWork.java | 49 +- .../apache/zest/api/value/ValueComposite.java | 2 +- .../zest/api/value/ValueDeserializer.java | 2 +- .../apache/zest/api/value/ValueSerializer.java | 2 +- .../java/org/apache/zest/api/OperatorsTest.java | 11 +- .../api/activation/ActivationEventsTest.java | 1 - .../apache/zest/api/unitofwork/RemovalTest.java | 4 +- .../org/apache/zest/bootstrap/Assemblers.java | 6 +- .../apache/zest/bootstrap/ModuleAssembly.java | 32 - .../apache/zest/bootstrap/ServiceAssembly.java | 4 +- .../DefaultIdentityGeneratorAssembler.java | 19 + .../runtime/activation/ActivationDelegate.java | 3 +- .../AbstractAssociationInstance.java | 8 +- .../association/AssociationInstance.java | 4 +- .../association/ManyAssociationInstance.java | 6 +- .../association/NamedAssociationInstance.java | 4 +- .../bootstrap/ImportedServiceAssemblyImpl.java | 18 +- .../runtime/bootstrap/ModuleAssemblyImpl.java | 507 +++++++------- .../runtime/bootstrap/ServiceAssemblyImpl.java | 5 +- .../bootstrap/ServiceDeclarationImpl.java | 3 +- .../zest/runtime/entity/EntityInstance.java | 22 +- .../apache/zest/runtime/entity/EntityModel.java | 26 +- .../provider/ThisInjectionProviderFactory.java | 2 +- .../runtime/service/ImportedServiceModel.java | 7 +- .../ImportedServiceReferenceInstance.java | 3 +- .../zest/runtime/service/ServiceModel.java | 26 +- .../service/ServiceReferenceInstance.java | 3 +- .../zest/runtime/structure/ModuleInstance.java | 3 +- .../runtime/unitofwork/BuilderEntityState.java | 2 +- .../unitofwork/EntityBuilderInstance.java | 33 +- .../runtime/unitofwork/EntityStateStore.java | 2 +- .../runtime/unitofwork/ModuleUnitOfWork.java | 66 +- .../runtime/unitofwork/UnitOfWorkInstance.java | 18 +- .../org/apache/zest/api/common/RemovalTest.java | 3 +- .../bootstrap/ApplicationAssemblerTest.java | 6 + ...faceCollisionWithRelatedReturnTypesTest.java | 11 +- .../qi377/SetAssociationInSideEffectTest.java | 7 +- ...alueCollisionWithRelatedReturnTypesTest.java | 21 +- .../apache/zest/regression/qi382/Qi382Test.java | 13 +- .../apache/zest/regression/qi383/Qi383Test.java | 7 +- .../ImportedServiceActivationTest.java | 3 +- .../association/AssociationAssignmentTest.java | 6 +- .../entity/EntityBuilderWithStateTest.java | 13 +- .../zest/runtime/entity/EntityTypeTest.java | 7 +- .../runtime/entity/EntityVisibilityTest.java | 28 +- .../ConstructorInjectionOfThisTest.java | 2 - .../runtime/injection/ServiceInjectionTest.java | 8 +- .../injection/UnitOfWorkInjectionTest.java | 3 +- .../zest/runtime/mixin/AssemblyMixinTest.java | 6 +- .../zest/runtime/mixin/AssemblyRoleTest.java | 6 +- .../apache/zest/runtime/mixin/JDKMixinTest.java | 14 +- .../runtime/objects/ObjectVisibilityTest.java | 28 +- .../runtime/query/IterableQuerySourceTest.java | 3 +- .../org/apache/zest/runtime/query/Network.java | 26 +- .../zest/runtime/service/ConfigurationTest.java | 6 +- .../runtime/service/ServiceVisibilityTest.java | 28 +- .../structure/TypeToCompositeLookupTest.java | 19 +- .../transients/TransientVisibilityTest.java | 27 +- .../unitofwork/PrivateEntityUnitOfWorkTest.java | 24 +- .../zest/runtime/unitofwork/RemovalTest.java | 25 +- .../runtime/value/AssociationToValueTest.java | 9 +- .../ValueInjectionDeserializationTest.java | 3 +- .../value/ValueSerializationRegressionTest.java | 9 +- .../zest/runtime/value/ValueVisibilityTest.java | 37 +- .../runtime/value/ValueWithAssociationTest.java | 28 +- .../visibility/VisibilityInUnitOfWorkTest.java | 14 +- .../importer/ServiceInstanceImporterTest.java | 3 +- .../memory/MemoryEntityStoreTest.java | 2 +- .../memory/MemoryMapEntityStoreMixin.java | 2 +- .../java/org/apache/zest/spi/cache/Cache.java | 2 +- .../org/apache/zest/spi/cache/CachePool.java | 2 +- .../org/apache/zest/spi/entity/EntityState.java | 6 +- .../zest/spi/entity/QualifiedIdentity.java | 143 ---- .../ConcurrentModificationCheckConcern.java | 5 +- .../DefaultEntityStoreUnitOfWork.java | 7 +- .../EntityAlreadyExistsException.java | 12 +- .../entitystore/EntityNotFoundException.java | 12 +- .../spi/entitystore/EntityStateVersions.java | 14 +- .../zest/spi/entitystore/EntityStoreSPI.java | 6 +- .../spi/entitystore/EntityStoreUnitOfWork.java | 13 +- .../entitystore/helpers/DefaultEntityState.java | 16 +- .../entitystore/helpers/JSONEntityState.java | 19 +- .../zest/spi/entitystore/helpers/JSONKeys.java | 2 +- .../helpers/JSONManyAssociationState.java | 16 +- .../helpers/JSONMapEntityStoreMixin.java | 62 +- .../helpers/JSONNamedAssociationState.java | 8 +- .../helpers/MapEntityStoreMixin.java | 48 +- .../org/apache/zest/spi/module/ModuleSpi.java | 2 +- .../spi/uuid/UuidIdentityGeneratorMixin.java | 8 +- .../spi/uuid/UuidIdentityGeneratorService.java | 2 +- .../spi/value/ValueDeserializerAdapter.java | 11 +- .../zest/spi/value/ValueSerializerAdapter.java | 25 +- .../helpers/JSONManyAssociationStateTest.java | 18 +- .../apache/zest/test/EntityTestAssembler.java | 2 +- ...bstractConfigurationDeserializationTest.java | 4 +- .../test/entity/AbstractEntityStoreTest.java | 5 +- .../test/indexing/AbstractEntityFinderTest.java | 2 +- .../zest/test/indexing/AbstractQueryTest.java | 7 +- .../zest/test/indexing/NameableAssert.java | 6 +- .../org/apache/zest/test/indexing/TestData.java | 9 +- .../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 - .../zest/test/indexing/model/Nameable.java | 3 +- .../AbstractPlainValueSerializationTest.java | 4 +- .../zest/cache/ehcache/EhCachePoolMixin.java | 4 +- .../ehcache/assembly/EhCacheAssembler.java | 2 +- .../zest/cache/memcache/MemcacheAssembler.java | 2 +- .../entitystore/file/FileEntityStoreMixin.java | 8 +- .../file/assembly/FileEntityStoreAssembler.java | 2 +- .../geode/GeodeEntityStoreMixin.java | 6 +- .../assembly/GeodeEntityStoreAssembler.java | 2 +- .../hazelcast/HazelcastEntityStoreMixin.java | 6 +- .../assembly/HazelcastEntityStoreAssembler.java | 2 +- .../jclouds/JCloudsMapEntityStoreMixin.java | 15 +- .../assembly/JCloudsEntityStoreAssembler.java | 2 +- .../entitystore/jdbm/JdbmEntityStoreMixin.java | 16 +- .../jdbm/assembly/JdbmEntityStoreAssembler.java | 2 +- .../leveldb/LevelDBEntityStoreMixin.java | 22 +- .../assembly/LevelDBEntityStoreAssembler.java | 2 +- .../assembly/MemoryEntityStoreAssembler.java | 2 +- .../mongodb/MongoMapEntityStoreMixin.java | 6 +- .../assembly/MongoDBEntityStoreAssembler.java | 2 +- .../prefs/PreferencesEntityStoreMixin.java | 65 +- .../prefs/PreferencesEntityStoreService.java | 2 +- .../PreferenceEntityStoreAssembler.java | 2 +- .../redis/RedisMapEntityStoreMixin.java | 10 +- .../assembly/RedisEntityStoreAssembler.java | 2 +- .../riak/RiakMapEntityStoreMixin.java | 8 +- .../riak/assembly/RiakEntityStoreAssembler.java | 2 +- .../entitystore/sql/SQLEntityStoreMixin.java | 25 +- .../AbstractSQLEntityStoreAssembler.java | 13 +- .../DatabaseSQLServiceStatementsMixin.java | 4 +- .../sql/internal/SQLEntityState.java | 4 +- .../sql/DerbySQLEntityStoreTest.java | 3 +- .../entitystore/sql/MySQLEntityStoreTest.java | 3 +- .../sql/PostgreSQLEntityStoreTest.java | 3 +- .../elasticsearch/ElasticSearchIndexer.java | 49 +- .../assembly/ESClusterIndexQueryAssembler.java | 2 +- .../ESFilesystemIndexQueryAssembler.java | 2 +- .../filesystem/ESFilesystemSupport.java | 17 +- .../index/elasticsearch/ElasticSearchTest.java | 20 +- extensions/indexing-rdf/src/docs/index-rdf.txt | 145 ++++ .../index/rdf/indexing/RdfIndexingService.java | 12 +- .../index/rdf/query/TupleQueryExecutor.java | 6 +- .../rdf/query/internal/RdfQueryParserImpl.java | 4 +- .../zest/index/rdf/query/internal/Triples.java | 6 +- .../apache/zest/index/rdf/MultiLayeredTest.java | 1 - .../zest/index/rdf/RDFPerformanceTest.java | 6 +- .../zest/index/rdf/RdfNamedQueryTest.java | 187 ++++-- .../zest/index/rdf/qi173/Qi173IssueTest.java | 3 +- .../zest/index/rdf/qi64/AbstractIssueTest.java | 7 +- .../AccountService.java | 5 +- .../withPropagationMandatory/IssueTest.java | 5 +- .../withPropagationRequired/AccountService.java | 5 +- .../qi64/withPropagationRequired/IssueTest.java | 5 +- .../AccountService.java | 5 +- .../withPropagationRequiresNew/IssueTest.java | 5 +- .../zest/index/rdf/qi66/Qi66IssueTest.java | 9 +- .../zest/index/solr/EmbeddedSolrService.java | 2 +- .../solr/internal/SolrEntityIndexerMixin.java | 4 +- .../indexing-solr/src/test/resources/schema.xml | 2 +- .../AbstractSQLIndexQueryAssembler.java | 8 +- .../index/sql/internal/SQLEntityFinder.java | 4 +- .../support/skeletons/AbstractSQLIndexing.java | 18 +- .../support/skeletons/AbstractSQLQuerying.java | 8 +- .../support/skeletons/AbstractSQLStartup.java | 4 +- .../skeletons/SQLCompatEntityStateWrapper.java | 4 +- .../metrics/yammer/NoMetricsInstalledTest.java | 6 +- .../apache/zest/metrics/yammer/YammerTest.java | 5 +- .../apache/zest/migration/MigrationTest.java | 13 +- .../reindexer/internal/ReindexerMixin.java | 18 +- .../StaxConfigurationDeserializationTest.java | 3 +- .../apache/zest/library/alarm/AlarmEvent.java | 12 +- .../apache/zest/library/alarm/AlarmPoint.java | 3 +- .../zest/library/alarm/AlarmPointFactory.java | 5 +- .../apache/zest/library/alarm/AlarmProxy.java | 11 +- .../apache/zest/library/alarm/AlarmSystem.java | 3 +- .../library/alarm/AlarmSystemAssembler.java | 2 +- .../alarm/ExtendedAlarmModelService.java | 22 +- .../library/alarm/SimpleAlarmModelService.java | 8 +- .../alarm/StandardAlarmModelService.java | 14 +- .../zest/library/alarm/AlarmProxyTest.java | 5 +- .../library/alarm/ExtendedAlarmModelTest.java | 41 +- .../library/alarm/SimpleAlarmModelTest.java | 11 +- .../library/alarm/StandardAlarmModelTest.java | 17 +- .../zest/library/appbrowser/AppBrowserTest.java | 8 +- .../jmx/CircuitBreakerManagement.java | 35 +- .../fileconfig/FileConfigurationAssembler.java | 2 +- .../zest/library/http/AbstractJettyMixin.java | 15 +- .../apache/zest/library/http/JettyMixin.java | 4 +- .../library/http/JettyServiceAssembler.java | 2 +- .../zest/library/http/SecureJettyMixin.java | 4 +- .../library/jmx/ApplicationManagerService.java | 16 +- .../jmx/ConfigurationManagerService.java | 17 +- libraries/lang-scala/build.gradle | 46 -- libraries/lang-scala/dev-status.xml | 38 -- libraries/lang-scala/src/docs/lang-scala.txt | 117 ---- .../zest/library/scala/ScalaTraitMixin.java | 241 ------- .../org/apache/zest/library/scala/package.html | 24 - .../scala/ExclamationGenericConcern.scala | 42 -- .../zest/library/scala/HelloThereConcern.scala | 28 - .../library/scala/HelloWorldComposite.scala | 27 - .../library/scala/HelloWorldComposite2.scala | 21 - .../library/scala/HelloWorldCompositeTest.java | 132 ---- .../zest/library/scala/HelloWorldMixin.scala | 26 - .../zest/library/scala/HelloWorldMixin2.scala | 27 - .../zest/library/scala/HelloWorldMixin3.scala | 28 - .../apache/zest/library/scala/TestEntity.scala | 68 -- .../apache/zest/library/scala/TestService.scala | 31 - .../debug/service/DebuggingServiceMixin.java | 2 +- .../log/service/LoggingServiceMixin.java | 2 +- .../trace/service/TraceServiceMixin.java | 3 +- .../zest/library/logging/DebuggingTest.java | 9 +- .../zest/library/osgi/OSGiServiceExporter.java | 2 +- .../zest/library/osgi/OSGiServiceTest.java | 2 +- .../rdf/entity/EntityStateSerializer.java | 8 +- .../rdf/repository/NativeRepositoryService.java | 2 +- .../rdf/entity/EntitySerializerTest.java | 7 +- .../rdf/entity/EntityTypeSerializerTest.java | 5 +- .../org/apache/zest/library/rdf/entity/test.xml | 2 +- .../apache/zest/library/rdf/entity/test2.xml | 2 +- .../rest/server/api/ContextResource.java | 11 +- .../rest/server/api/ResourceValidity.java | 2 +- .../server/restlet/RequestReaderDelegator.java | 5 +- .../server/restlet/ResponseWriterDelegator.java | 5 +- .../requestreader/DefaultRequestReader.java | 8 +- .../library/rest/admin/EntitiesResource.java | 6 +- .../zest/library/rest/admin/EntityResource.java | 30 +- .../library/rest/admin/RestApplication.java | 2 +- .../zest/library/rest/admin/sparqlform.html | 8 +- .../library/rest/admin/DummyDataService.java | 7 +- .../zest/library/rest/admin/RestTest.java | 19 +- .../zest/library/restlet/ZestEntityRestlet.java | 6 +- .../zest/library/restlet/ZrestApplication.java | 10 +- .../zest/library/restlet/crud/EntityList.java | 4 +- .../restlet/crud/EntityListResource.java | 16 +- .../library/restlet/crud/EntityResource.java | 16 +- .../restlet/crud/HasIdentitySpecification.java | 44 ++ .../restlet/crud/IdentitySpecification.java | 43 -- .../library/restlet/identity/CanonicalName.java | 4 +- .../restlet/identity/IdentityManager.java | 42 +- .../InvalidIdentityFormatException.java | 2 +- .../restlet/repository/CrudRepository.java | 11 +- .../restlet/repository/RepositoryLocator.java | 6 +- .../repository/SmallCrudRepositoryMixin.java | 22 +- .../restlet/resource/CreationResource.java | 13 +- .../resource/DefaultResourceFactoryImpl.java | 6 +- .../library/restlet/resource/EntryPoint.java | 4 +- .../restlet/resource/EntryPointResource.java | 7 +- .../restlet/resource/ResourceBuilder.java | 45 +- .../restlet/resource/ResourceFactory.java | 4 +- .../restlet/resource/ServerResource.java | 16 +- .../apache/zest/library/restlet/Customer.java | 4 +- .../org/apache/zest/library/restlet/Order.java | 4 +- .../apache/zest/library/restlet/Product.java | 4 +- .../shiro/assembly/PasswordDomainAssembler.java | 2 +- .../assembly/StandaloneShiroAssembler.java | 2 +- .../bootstrap/ZestApplicationBootstrap.java | 2 +- .../internal/service/ServiceFactoryBean.java | 1 - .../internal/service/ServiceLocator.java | 6 +- .../library/spring/importer/SpringImporter.java | 2 +- .../spring/bootstrap/ZestTestBootstrap.java | 4 +- .../sql/liquibase/LiquibaseAssembler.java | 2 +- ...bstractPooledDataSourceServiceAssembler.java | 2 +- .../sql/assembly/DataSourceAssembler.java | 5 +- .../assembly/ExternalDataSourceAssembler.java | 3 +- .../AbstractDataSourceServiceImporterMixin.java | 9 +- .../sql/datasource/DataSourceConfiguration.java | 4 +- .../library/sql/datasource/DataSources.java | 3 +- .../DataSourceConfigurationManagerService.java | 14 +- ...taSourceConfigurationManagerServiceTest.java | 4 +- .../zest/library/uowfile/internal/UoWFile.java | 2 +- .../zest/library/uowfile/HasUoWFileTest.java | 63 +- .../zest/library/uowfile/HasUoWFilesTest.java | 61 +- .../createEntity/ManufacturerRepository.java | 4 +- .../ManufacturerRepositoryMixin.java | 5 +- samples/dci-cargo/README.txt | 22 - samples/dci-cargo/dcisample_a/build.gradle | 50 -- .../pathfinder_a/api/GraphTraversalService.java | 43 -- .../dcicargo/pathfinder_a/api/TransitEdge.java | 85 --- .../dcicargo/pathfinder_a/api/TransitPath.java | 51 -- .../dcicargo/pathfinder_a/api/package.html | 26 - .../pathfinder_a/internal/GraphDAO.java | 60 -- .../internal/GraphTraversalServiceImpl.java | 108 --- .../dcicargo/pathfinder_a/internal/package.html | 26 - .../sample/dcicargo/pathfinder_a/package.html | 34 - .../bootstrap/DCISampleApplication_a.java | 83 --- .../VisualizeApplicationStructure.java | 59 -- .../sample_a/bootstrap/assembly/Assembler.java | 279 -------- .../sample_a/bootstrap/sampledata/BaseData.java | 122 ---- .../bootstrap/sampledata/BaseDataService.java | 180 ----- .../bootstrap/sampledata/SampleDataService.java | 318 --------- .../communication/query/BookingQueries.java | 74 -- .../communication/query/CommonQueries.java | 76 --- .../communication/query/HandlingQueries.java | 77 --- .../communication/query/TrackingQueries.java | 77 --- .../sample_a/communication/web/BasePage.java | 77 --- .../web/booking/BookNewCargoPage.java | 154 ----- .../web/booking/BookingBasePage.java | 39 -- .../web/booking/CargoDetailsPage.java | 180 ----- .../web/booking/CargoListPage.java | 99 --- .../web/booking/ChangeDestinationPage.java | 108 --- .../web/booking/RouteCargoPage.java | 69 -- .../communication/web/booking/RoutePanel.java | 118 ---- .../web/handling/RegisterHandlingEventPage.java | 146 ---- .../web/tracking/HandlingHistoryPanel.java | 85 --- .../web/tracking/NextHandlingEventPanel.java | 100 --- .../web/tracking/TrackCargoPage.java | 201 ------ .../sample_a/context/rolemap/CargoRoleMap.java | 31 - .../sample_a/context/rolemap/CargosRoleMap.java | 31 - .../context/rolemap/HandlingEventRoleMap.java | 34 - .../context/rolemap/HandlingEventsRoleMap.java | 32 - .../context/rolemap/ItineraryRoleMap.java | 36 - .../rolemap/RouteSpecificationRoleMap.java | 36 - .../context/shipping/booking/BookNewCargo.java | 253 ------- .../shipping/booking/BuildDeliverySnapshot.java | 569 ---------------- .../shipping/booking/RouteException.java | 28 - .../context/shipping/handling/InspectCargo.java | 108 --- .../handling/RegisterHandlingEvent.java | 274 -------- .../context/support/ApplicationEvents.java | 154 ----- .../context/support/FoundNoRoutesException.java | 60 -- .../RegisterHandlingEventAttemptDTO.java | 51 -- .../context/support/RoutingService.java | 155 ----- .../sample_a/data/shipping/cargo/Cargo.java | 54 -- .../sample_a/data/shipping/cargo/Cargos.java | 80 --- .../data/shipping/cargo/RouteSpecification.java | 75 --- .../data/shipping/cargo/TrackingId.java | 34 - .../data/shipping/delivery/Delivery.java | 129 ---- .../delivery/ExpectedHandlingEvent.java | 47 -- .../data/shipping/delivery/RoutingStatus.java | 31 - .../data/shipping/delivery/TransportStatus.java | 32 - .../data/shipping/handling/HandlingEvent.java | 74 -- .../shipping/handling/HandlingEventType.java | 60 -- .../data/shipping/handling/HandlingEvents.java | 89 --- .../data/shipping/itinerary/Itinerary.java | 95 --- .../sample_a/data/shipping/itinerary/Leg.java | 48 -- .../data/shipping/location/Location.java | 60 -- .../data/shipping/location/UnLocode.java | 40 -- .../data/shipping/voyage/CarrierMovement.java | 42 -- .../sample_a/data/shipping/voyage/Schedule.java | 34 - .../sample_a/data/shipping/voyage/Voyage.java | 37 - .../data/shipping/voyage/VoyageNumber.java | 33 - .../infrastructure/WicketZestApplication.java | 252 ------- .../sample_a/infrastructure/conversion/DTO.java | 31 - .../sample_a/infrastructure/dci/Context.java | 129 ---- .../sample_a/infrastructure/dci/RoleMixin.java | 55 -- .../infrastructure/model/EntityModel.java | 81 --- .../infrastructure/model/JSONModel.java | 71 -- .../sample_a/infrastructure/model/Queries.java | 42 -- .../infrastructure/model/QueryModel.java | 76 --- .../infrastructure/model/ReadOnlyModel.java | 67 -- .../wicket/color/CorrectColor.java | 33 - .../infrastructure/wicket/color/ErrorColor.java | 36 - .../wicket/form/AbstractForm.java | 68 -- .../wicket/form/DateTextFieldWithPicker.java | 228 ------- .../wicket/form/SelectorInForm.java | 72 -- .../infrastructure/wicket/link/LinkPanel.java | 47 -- .../infrastructure/wicket/page/BaseWebPage.java | 58 -- .../wicket/prevnext/PrevNext.java | 123 ---- .../infrastructure/wicket/tabs/TabsPanel.java | 93 --- .../src/main/resources/log4j.properties | 34 - .../sample_a/communication/web/BasePage.html | 128 ---- .../web/booking/BookNewCargoPage.html | 91 --- .../web/booking/BookingBasePage.html | 43 -- .../web/booking/CargoDetailsPage.html | 109 --- .../web/booking/CargoListPage.html | 69 -- .../web/booking/ChangeDestinationPage.html | 80 --- .../web/booking/RouteCargoPage.html | 55 -- .../communication/web/booking/RoutePanel.html | 64 -- .../web/handling/RegisterHandlingEventPage.html | 90 --- .../RegisterHandlingEventPage.properties | 26 - .../web/tracking/HandlingHistoryPanel.html | 50 -- .../tracking/HandlingHistoryPanel.properties | 26 - .../web/tracking/NextHandlingEventPanel.html | 41 -- .../tracking/NextHandlingEventPanel.properties | 28 - .../web/tracking/TrackCargoPage.html | 70 -- .../web/tracking/TrackCargoPage.properties | 29 - .../context/shipping/booking/BookNewCargo.txt | 75 --- .../shipping/booking/BuildDeliverySnapshot.txt | 157 ----- .../context/shipping/handling/InspectCargo.txt | 24 - .../shipping/handling/RegisterHandlingEvent.txt | 79 --- .../infrastructure/wicket/link/LinkPanel.html | 41 -- .../wicket/prevnext/PrevNext.html | 47 -- .../infrastructure/wicket/tabs/TabsPanel.html | 51 -- .../dcisample_a/src/main/webapp/WEB-INF/web.xml | 42 -- .../src/main/webapp/css/prev-next.css | 51 -- .../dcisample_a/src/main/webapp/css/style.css | 179 ----- .../dcisample_a/src/main/webapp/css/tabs.css | 77 --- .../src/main/webapp/graphics/icon/cross.png | Bin 655 -> 0 bytes .../src/main/webapp/graphics/icon/error.png | Bin 666 -> 0 bytes .../src/main/webapp/graphics/icon/next.png | Bin 653 -> 0 bytes .../main/webapp/graphics/icon/next_disabled.png | Bin 1461 -> 0 bytes .../src/main/webapp/graphics/icon/prev-next.psd | Bin 26535 -> 0 bytes .../src/main/webapp/graphics/icon/prev.png | Bin 625 -> 0 bytes .../main/webapp/graphics/icon/prev_disabled.png | Bin 1429 -> 0 bytes .../src/main/webapp/graphics/icon/tick.png | Bin 537 -> 0 bytes .../webapp/graphics/icon/triangle-closed.png | Bin 1024 -> 0 bytes .../main/webapp/graphics/icon/triangle-open.png | Bin 1159 -> 0 bytes .../src/main/webapp/graphics/tabs/bg.png | Bin 938 -> 0 bytes .../src/main/webapp/graphics/tabs/left.png | Bin 1175 -> 0 bytes .../src/main/webapp/graphics/tabs/left_on.png | Bin 1176 -> 0 bytes .../src/main/webapp/graphics/tabs/original.psd | Bin 41548 -> 0 bytes .../src/main/webapp/graphics/tabs/right.png | Bin 1450 -> 0 bytes .../src/main/webapp/graphics/tabs/right_on.png | Bin 1459 -> 0 bytes .../dcicargo/sample_a/bootstrap/Start8081.java | 70 -- .../bootstrap/test/TestApplication.java | 120 ---- .../sample_a/bootstrap/test/TestAssembler.java | 226 ------- .../shipping/booking/BookNewCargoTest.java | 240 ------- .../booking/BuildDeliverySnapshotTest.java | 672 ------------------- .../shipping/handling/InspectCargoTest.java | 140 ---- .../handling/RegisterHandlingEventTest.java | 250 ------- samples/dci-cargo/dcisample_b/build.gradle | 50 -- .../pathfinder_b/api/GraphTraversalService.java | 48 -- .../dcicargo/pathfinder_b/api/TransitEdge.java | 85 --- .../dcicargo/pathfinder_b/api/TransitPath.java | 73 -- .../dcicargo/pathfinder_b/api/package.html | 26 - .../pathfinder_b/internal/GraphDAO.java | 100 --- .../internal/GraphTraversalServiceImpl.java | 138 ---- .../dcicargo/pathfinder_b/internal/package.html | 26 - .../sample/dcicargo/pathfinder_b/package.html | 34 - .../bootstrap/DCISampleApplication_b.java | 86 --- .../VisualizeApplicationStructure.java | 59 -- .../sample_b/bootstrap/assembly/Assembler.java | 281 -------- .../sample_b/bootstrap/sampledata/BaseData.java | 196 ------ .../bootstrap/sampledata/BaseDataService.java | 192 ------ .../bootstrap/sampledata/SampleDataService.java | 424 ------------ .../communication/query/BookingQueries.java | 87 --- .../communication/query/CommonQueries.java | 76 --- .../communication/query/HandlingQueries.java | 77 --- .../communication/query/TrackingQueries.java | 75 --- .../sample_b/communication/web/BasePage.java | 78 --- .../web/booking/BookNewCargoPage.java | 152 ----- .../web/booking/BookingBasePage.java | 39 -- .../web/booking/CargoDetailsPage.java | 215 ------ .../web/booking/CargoListPage.java | 117 ---- .../web/booking/ChangeDestinationPage.java | 113 ---- .../web/booking/ReRouteCargoPage.java | 74 -- .../web/booking/RouteCargoPage.java | 67 -- .../communication/web/booking/RoutePanel.java | 124 ---- .../IncidentLoggingApplicationMockupPage.java | 268 -------- .../web/tracking/HandlingHistoryPanel.java | 92 --- .../web/tracking/NextHandlingEventPanel.java | 100 --- .../web/tracking/TrackCargoPage.java | 201 ------ .../interaction/booking/BookNewCargo.java | 137 ---- .../exception/ChangeDestinationException.java | 63 -- .../booking/exception/RoutingException.java | 31 - .../exception/UnsatisfyingRouteException.java | 47 -- .../booking/routing/AssignCargoToRoute.java | 201 ------ .../booking/routing/RegisterNewDestination.java | 126 ---- .../DeriveUpdatedRouteSpecification.java | 156 ----- .../handling/ProcessHandlingEvent.java | 145 ---- .../handling/ProcessHandlingEventException.java | 28 - .../inspection/InspectCargoDeliveryStatus.java | 161 ----- .../inspection/event/InspectArrivedCargo.java | 166 ----- .../inspection/event/InspectCargoInCustoms.java | 160 ----- .../inspection/event/InspectClaimedCargo.java | 160 ----- .../inspection/event/InspectLoadedCargo.java | 271 -------- .../inspection/event/InspectReceivedCargo.java | 183 ----- .../inspection/event/InspectUnhandledCargo.java | 148 ---- .../inspection/event/InspectUnloadedCargo.java | 218 ------ .../exception/CargoArrivedException.java | 40 -- .../exception/CargoHijackedException.java | 44 -- .../exception/CargoMisdirectedException.java | 59 -- .../exception/CargoMisroutedException.java | 52 -- .../exception/CargoNotRoutedException.java | 38 -- .../exception/InspectionException.java | 31 - .../exception/InspectionFailedException.java | 37 - .../exception/UnexpectedCarrierException.java | 38 -- .../parsing/ParseHandlingEventData.java | 121 ---- .../parsing/dto/ParsedHandlingEventData.java | 73 -- .../InvalidHandlingEventDataException.java | 28 - .../registration/RegisterHandlingEvent.java | 224 ------- .../exception/AlreadyClaimedException.java | 39 -- .../CannotRegisterHandlingEventException.java | 68 -- .../exception/ChronologicalException.java | 43 -- .../exception/DuplicateEventException.java | 54 -- .../exception/MissingVoyageNumberException.java | 45 -- .../exception/NonRoutedCargoException.java | 45 -- .../exception/UnknownCargoException.java | 39 -- .../exception/UnknownEventTypeException.java | 42 -- .../exception/UnknownLocationException.java | 39 -- .../exception/UnknownVoyageException.java | 39 -- .../sample_b/context/rolemap/CargoRoleMap.java | 60 -- .../sample_b/context/rolemap/CargosRoleMap.java | 35 - .../context/rolemap/HandlingEventsRoleMap.java | 35 - .../context/service/routing/RoutingService.java | 149 ---- .../exception/FoundNoRoutesException.java | 60 -- .../data/aggregateroot/CargoAggregateRoot.java | 38 -- .../HandlingEventAggregateRoot.java | 38 -- .../sample_b/data/factory/CargoFactory.java | 104 --- .../data/factory/HandlingEventFactory.java | 96 --- .../RouteSpecificationFactoryService.java | 90 --- .../exception/CannotCreateCargoException.java | 37 - .../CannotCreateHandlingEventException.java | 37 - ...CannotCreateRouteSpecificationException.java | 39 -- .../sample_b/data/structure/cargo/Cargo.java | 57 -- .../structure/cargo/RouteSpecification.java | 96 --- .../data/structure/delivery/Delivery.java | 140 ---- .../structure/delivery/NextHandlingEvent.java | 56 -- .../data/structure/delivery/RoutingStatus.java | 33 - .../structure/delivery/TransportStatus.java | 34 - .../data/structure/handling/HandlingEvent.java | 96 --- .../structure/handling/HandlingEventType.java | 62 -- .../data/structure/itinerary/Itinerary.java | 115 ---- .../sample_b/data/structure/itinerary/Leg.java | 48 -- .../data/structure/location/Location.java | 62 -- .../data/structure/location/UnLocode.java | 43 -- .../data/structure/tracking/TrackingId.java | 42 -- .../data/structure/voyage/CarrierMovement.java | 45 -- .../data/structure/voyage/Schedule.java | 37 - .../sample_b/data/structure/voyage/Voyage.java | 89 --- .../data/structure/voyage/VoyageNumber.java | 36 - .../infrastructure/WicketZestApplication.java | 247 ------- .../sample_b/infrastructure/conversion/DTO.java | 38 -- .../sample_b/infrastructure/dci/Context.java | 148 ---- .../sample_b/infrastructure/dci/RoleMixin.java | 66 -- .../infrastructure/model/EntityModel.java | 86 --- .../infrastructure/model/JSONModel.java | 73 -- .../sample_b/infrastructure/model/Queries.java | 44 -- .../infrastructure/model/QueryModel.java | 73 -- .../infrastructure/model/ReadOnlyModel.java | 76 --- .../wicket/color/CorrectColor.java | 35 - .../infrastructure/wicket/color/ErrorColor.java | 35 - .../wicket/form/AbstractForm.java | 69 -- .../wicket/form/DateTextFieldWithPicker.java | 230 ------- .../wicket/form/SelectorInForm.java | 79 --- .../infrastructure/wicket/link/LinkPanel.java | 49 -- .../infrastructure/wicket/page/BaseWebPage.java | 58 -- .../wicket/prevnext/PrevNext.java | 124 ---- .../infrastructure/wicket/tabs/TabsPanel.java | 105 --- .../src/main/resources/log4j.properties | 34 - .../sample_b/communication/web/BasePage.html | 128 ---- .../web/booking/BookNewCargoPage.html | 91 --- .../web/booking/BookingBasePage.html | 43 -- .../web/booking/CargoDetailsPage.html | 130 ---- .../web/booking/CargoListPage.html | 69 -- .../web/booking/ChangeDestinationPage.html | 80 --- .../web/booking/ReRouteCargoPage.html | 55 -- .../web/booking/RouteCargoPage.html | 55 -- .../communication/web/booking/RoutePanel.html | 64 -- .../IncidentLoggingApplicationMockupPage.html | 111 --- ...identLoggingApplicationMockupPage.properties | 26 - .../web/tracking/HandlingHistoryPanel.html | 50 -- .../tracking/HandlingHistoryPanel.properties | 26 - .../web/tracking/NextHandlingEventPanel.html | 41 -- .../tracking/NextHandlingEventPanel.properties | 28 - .../web/tracking/TrackCargoPage.html | 70 -- .../web/tracking/TrackCargoPage.properties | 29 - .../sample_b/context/usecase/_ShipCargo.txt | 50 -- .../context/usecase/booking/BookNewCargo.txt | 51 -- .../booking/ChangeDestinationOfCargo.txt | 39 -- .../context/usecase/booking/ReRouteCargo.txt | 33 - .../context/usecase/booking/RouteCargo.txt | 27 - .../booking/routing/AssignCargoToRoute.txt | 42 -- .../booking/routing/RegisterNewDestination.txt | 30 - .../DeriveUpdatedRouteSpecification.txt | 32 - .../usecase/handling/_ProcessHandlingEvent.txt | 67 -- .../inspection/InspectCargoDeliveryStatus.txt | 57 -- .../inspection/event/InspectArrivedCargo.txt | 38 -- .../inspection/event/InspectCargoInCustoms.txt | 38 -- .../inspection/event/InspectClaimedCargo.txt | 38 -- .../inspection/event/InspectLoadedCargo.txt | 60 -- .../inspection/event/InspectReceivedCargo.txt | 35 - .../inspection/event/InspectUnhandledCargo.txt | 32 - .../inspection/event/InspectUnloadedCargo.txt | 45 -- .../handling/parsing/ParseHandlingEventData.txt | 62 -- .../registration/RegisterHandlingEvent.txt | 76 --- .../infrastructure/wicket/link/LinkPanel.html | 41 -- .../wicket/prevnext/PrevNext.html | 47 -- .../infrastructure/wicket/tabs/TabsPanel.html | 51 -- .../dcisample_b/src/main/webapp/WEB-INF/web.xml | 42 -- .../src/main/webapp/css/prev-next.css | 51 -- .../dcisample_b/src/main/webapp/css/style.css | 178 ----- .../dcisample_b/src/main/webapp/css/tabs.css | 77 --- .../src/main/webapp/graphics/icon/cross.png | Bin 655 -> 0 bytes .../src/main/webapp/graphics/icon/error.png | Bin 666 -> 0 bytes .../src/main/webapp/graphics/icon/next.png | Bin 653 -> 0 bytes .../main/webapp/graphics/icon/next_disabled.png | Bin 1461 -> 0 bytes .../src/main/webapp/graphics/icon/prev-next.psd | Bin 26535 -> 0 bytes .../src/main/webapp/graphics/icon/prev.png | Bin 625 -> 0 bytes .../main/webapp/graphics/icon/prev_disabled.png | Bin 1429 -> 0 bytes .../src/main/webapp/graphics/icon/tick.png | Bin 537 -> 0 bytes .../webapp/graphics/icon/triangle-closed.png | Bin 1024 -> 0 bytes .../main/webapp/graphics/icon/triangle-open.png | Bin 1159 -> 0 bytes .../src/main/webapp/graphics/tabs/bg.png | Bin 938 -> 0 bytes .../src/main/webapp/graphics/tabs/left.png | Bin 1175 -> 0 bytes .../src/main/webapp/graphics/tabs/left_on.png | Bin 1176 -> 0 bytes .../src/main/webapp/graphics/tabs/original.psd | Bin 41548 -> 0 bytes .../src/main/webapp/graphics/tabs/right.png | Bin 1450 -> 0 bytes .../src/main/webapp/graphics/tabs/right_on.png | Bin 1459 -> 0 bytes .../dcicargo/sample_b/bootstrap/Start8082.java | 70 -- .../bootstrap/test/TestApplication.java | 463 ------------- .../sample_b/bootstrap/test/TestAssembler.java | 226 ------- .../context/test/booking/BookNewCargoTest.java | 220 ------ .../booking/routing/AssignCargoToRouteTest.java | 198 ------ .../routing/RegisterNewDestinationTest.java | 316 --------- .../DeriveUpdatedRouteSpecTest.java | 160 ----- .../event/InspectArrivedCargoTest.java | 140 ---- .../event/InspectCargoInCustomsTest.java | 138 ---- .../event/InspectClaimedCargoTest.java | 133 ---- .../event/InspectLoadedCargoTest.java | 515 -------------- .../event/InspectReceivedCargoTest.java | 286 -------- .../event/InspectUnhandledCargoTest.java | 130 ---- .../event/InspectUnloadedCargoTest.java | 345 ---------- .../parsing/ParseHandlingEventDataTest.java | 142 ---- .../registration/RegisterHandlingEventTest.java | 233 ------- .../testing/ExpectedException.java | 103 --- .../moneytransfer/context/PayBillsContext.java | 5 +- .../moneytransfer/context/PayBillsContext2.java | 7 +- .../zest/dci/moneytransfer/test/AccountIds.java | 13 + .../moneytransfer/test/TransferMoneyTest.java | 7 +- .../moneytransfer/test/TransferMoneyTest2.java | 7 +- .../zest/sample/forum/data/entity/Forums.java | 4 +- .../zest/sample/forum/data/entity/Users.java | 4 +- .../rest/resource/forum/BoardResource.java | 3 +- .../rest/resource/forum/ForumResource.java | 3 +- .../rest/resource/forum/ForumsResource.java | 3 +- .../zest/sample/rental/domain/RentalShop.java | 3 +- .../sample/rental/domain/dev/InitialData.java | 3 +- .../zest/sample/rental/web/BookingPage.java | 5 +- .../apache/zest/sample/rental/web/MainPage.java | 5 +- .../org/apache/zest/sample/sqlsupport/Main.java | 5 +- settings.gradle | 3 - .../AbstractEntityStorePerformanceTest.java | 5 +- .../indexing/rdf/QueryPerformanceTest.java | 30 +- .../apache/zest/envisage/print/PDFWriter.java | 2 +- .../zest/envisage/sample/EnvisageSample.java | 5 +- .../initialdata/SamplePersonInitialData.java | 3 +- .../domain/school/assembly/SchoolEntity.java | 7 +- .../domain/school/assembly/StudentEntity.java | 3 +- .../domain/school/assembly/SubjectEntity.java | 3 +- .../app/templates/CrudModule/bootstrap.tmpl | 1 - .../app/templates/Heroes/Hero.tmpl | 4 +- .../templates/RdfIndexingModule/bootstrap.tmpl | 2 - .../app/templates/RestApiModule/bootstrap.tmpl | 2 - .../app/templates/SecurityModule/bootstrap.tmpl | 1 - .../app/templates/StorageModule/bootstrap.tmpl | 2 - .../zest/tools/model/VisitableDetailTest.java | 14 + .../create/project/common/CrudModuleWriter.java | 1 - .../create/project/common/CustomerWriter.java | 4 +- .../project/common/IndexingModuleWriter.java | 2 - .../create/project/common/OrderItemWriter.java | 4 +- .../project/common/OrderModuleWriter.java | 1 - .../create/project/common/OrderWriter.java | 4 +- .../project/common/SecurityModuleWriter.java | 1 - .../project/common/StorageModuleWriter.java | 1 - .../project/restapp/OrderModuleWriter.java | 1 - .../project/restapp/RestModuleWriter.java | 2 - .../SingletonApplicationAssemblerWriter.java | 1 - .../apache/zest/tutorials/hello/HelloTest4.java | 9 +- 686 files changed, 2363 insertions(+), 31590 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/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 2d7181f..b9044eb 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 @@ -27,7 +27,8 @@ import org.apache.zest.api.composite.Composite; import org.apache.zest.api.composite.PropertyMapper; import org.apache.zest.api.constraint.ConstraintViolationException; import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.injection.scope.This; @@ -56,12 +57,12 @@ import org.apache.zest.api.value.ValueSerialization; * where MyServiceConfiguration extends {@link ConfigurationComposite}, which itself is an ordinary * {@link org.apache.zest.api.entity.EntityComposite}. The Configuration implementation * will either locate an instance of the given Configuration type in the - * persistent store using the identity of the Service, or create a new such instance + * persistent store using the reference of the Service, or create a new such instance * if one doesn't already exist. * </p> * <p> * If a new Configuration instance is created then it will be populated with properties - * from the properties file whose filesystem name is the same as the identity (e.g. "MyService.properties"). + * from the properties file whose filesystem name is the same as the reference (e.g. "MyService.properties"). * If a service is not given a name via the {@code org.apache.zest.bootstrap.ServiceDeclaration#identifiedBy(String)}, the * name will default to the FQCN of the ServiceComposite type. * </p> @@ -174,6 +175,7 @@ public interface Configuration<T> @Service private Iterable<ServiceReference<ValueSerialization>> valueSerialization; + public ConfigurationMixin() { } @@ -235,25 +237,24 @@ public interface Configuration<T> { ServiceDescriptor serviceModel = api.serviceDescriptorFor( serviceComposite ); - String identity = serviceComposite.identity().get(); V configuration; try { - configuration = uow.get( serviceModel.<V>configurationType(), identity ); + configuration = uow.get( serviceModel.<V>configurationType(), serviceComposite.identity().get() ); uow.pause(); } catch( NoSuchEntityException | NoSuchEntityTypeException e ) { - return (V) initializeConfigurationInstance( serviceComposite, uow, serviceModel, identity ); + return (V) initializeConfigurationInstance( serviceComposite, uow, serviceModel, serviceComposite.identity().get() ); } return configuration; } @SuppressWarnings( "unchecked" ) - private <V extends Identity> V initializeConfigurationInstance( ServiceComposite serviceComposite, - UnitOfWork uow, - ServiceDescriptor serviceModel, - String identity + private <V extends HasIdentity> V initializeConfigurationInstance(ServiceComposite serviceComposite, + UnitOfWork uow, + ServiceDescriptor serviceModel, + Identity identity ) throws InstantiationException { @@ -310,7 +311,7 @@ public interface Configuration<T> private <C, V> V tryLoadPropertiesFile( UnitOfWork buildUow, Class<C> compositeType, Class<V> configType, - String identity + Identity identity ) throws InstantiationException { @@ -345,39 +346,39 @@ public interface Configuration<T> return type.getResourceAsStream( resourceName ); } - private <C, V extends Identity> V tryLoadJsonFile( UnitOfWork uow, - Class<C> compositeType, - Class<V> configType, - String identity + private <C, V extends HasIdentity> V tryLoadJsonFile(UnitOfWork uow, + Class<C> compositeType, + Class<V> configType, + Identity identity ) { return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.JSON, ".json" ); } - private <C, V extends Identity> V tryLoadYamlFile( UnitOfWork uow, - Class<C> compositeType, - Class<V> configType, - String identity + private <C, V extends HasIdentity> V tryLoadYamlFile(UnitOfWork uow, + Class<C> compositeType, + Class<V> configType, + Identity identity ) { return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.YAML, ".yaml" ); } - private <C, V extends Identity> V tryLoadXmlFile( UnitOfWork uow, - Class<C> compositeType, - Class<V> configType, - String identity + private <C, V extends HasIdentity> V tryLoadXmlFile(UnitOfWork uow, + Class<C> compositeType, + Class<V> configType, + Identity identity ) { return readConfig( uow, compositeType, configType, identity, ValueSerialization.Formats.XML, ".xml" ); } - private <C, V extends Identity> V readConfig( UnitOfWork uow, - Class<C> compositeType, - Class<V> configType, - String identity, - String format, - String extension + private <C, V extends HasIdentity> V readConfig(UnitOfWork uow, + Class<C> compositeType, + Class<V> configType, + Identity identity, + String format, + String extension ) { for( ServiceReference<ValueSerialization> serializerRef : valueSerialization ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java b/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java index 81d5dfd..351be27 100644 --- a/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java +++ b/core/api/src/main/java/org/apache/zest/api/configuration/ConfigurationComposite.java @@ -21,17 +21,17 @@ package org.apache.zest.api.configuration; import org.apache.zest.api.composite.Composite; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; import org.apache.zest.api.entity.Queryable; /** * Services that want to be configurable should have a ConfigurationComposite that contains all the settings. * They are treated as EntityComposites, and are therefore stored in an EntityStore. There will be one instance - * per service instance that uses each ConfigurationComposite, and the identity of the entity is the same as that + * per service instance that uses each ConfigurationComposite, and the reference of the entity is the same as that * of the service. */ @Queryable( false ) public interface ConfigurationComposite - extends Identity, Composite + extends HasIdentity, Composite { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java b/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java index bff0a08..0bfc3fe 100644 --- a/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java +++ b/core/api/src/main/java/org/apache/zest/api/configuration/NoSuchConfigurationException.java @@ -20,16 +20,16 @@ package org.apache.zest.api.configuration; -import org.apache.zest.api.constraint.ConstraintViolationException; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; public class NoSuchConfigurationException extends RuntimeException { - private final Class<? extends Identity> configType; - private final String identity; + private final Class<? extends HasIdentity> configType; + private final Identity identity; - public NoSuchConfigurationException( Class<? extends Identity> configType, - String identity, + public NoSuchConfigurationException( Class<? extends HasIdentity> configType, + Identity identity, Exception cause ) { @@ -38,12 +38,12 @@ public class NoSuchConfigurationException extends RuntimeException this.identity = identity; } - public Class<? extends Identity> configType() + public Class<? extends HasIdentity> configType() { return configType; } - public String identity() + public Identity identity() { return identity; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java index e4819e5..bfd0445 100644 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java +++ b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.zest.api.ZestAPI; import org.apache.zest.api.composite.Composite; +import org.apache.zest.api.identity.Identity; import static java.util.stream.Collectors.joining; @@ -76,14 +77,14 @@ public class ConstraintViolationException this.constraintViolations = violations; } - public ConstraintViolationException( String instanceToString, + public ConstraintViolationException( Identity identity, List<Class<?>> instanceTypes, String mixinTypeName, String methodName, Collection<ConstraintViolation> violations ) { - this.instanceToString = instanceToString; + this.instanceToString = identity.toString(); this.instanceTypes = instanceTypes; this.mixinTypeName = mixinTypeName; this.methodName = methodName; http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java index 4e935d6..44de095 100644 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java +++ b/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java @@ -23,14 +23,14 @@ import org.apache.zest.api.association.AssociationMixin; import org.apache.zest.api.association.ManyAssociationMixin; import org.apache.zest.api.association.NamedAssociationMixin; import org.apache.zest.api.composite.Composite; +import org.apache.zest.api.identity.HasIdentity; import org.apache.zest.api.mixin.Mixins; /** * EntityComposites are Composites that has mutable state persisted in EntityStores and equality defined from its - * identity. + * reference. */ @Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } ) -public interface EntityComposite - extends Identity, Composite +public interface EntityComposite extends HasIdentity, Composite { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java index 0cb1e65..a6a5e0e 100644 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java +++ b/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java @@ -21,80 +21,67 @@ package org.apache.zest.api.entity; import java.io.Serializable; +import java.util.Objects; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.util.NullArgumentException; /** - * An EntityReference is identity of a specific Entity instance. - * <p>When stringified, the identity is used as-is. Example:</p> + * An EntityReference is reference of a specific Entity instance. + * <p>When stringified, the reference is used as-is. Example:</p> * <pre>123456-abcde</pre> */ public final class EntityReference - implements Serializable + implements Serializable { /** - * Parse an URI to an EntityReference. - * @param uri the URI to parse - * @return the EntityReference represented by the given URI + * Parse an Entity reference to an EntityReference. + * + * @param identityString the EntityReference reference + * @return the EntityReference represented by the given reference */ - public static EntityReference parseURI( String uri ) + public static EntityReference parseEntityReference(String identityString) { - String identity = uri.substring( "urn:zest:entity:".length() ); - return new EntityReference( identity ); - } - - /** - * Parse an Entity identity to an EntityReference. - * @param identity the EntityReference identity - * @return the EntityReference represented by the given identity - */ - public static EntityReference parseEntityReference( String identity ) - { - return new EntityReference( identity ); + return new EntityReference( new StringIdentity( identityString ) ); } /** * @param object an EntityComposite * @return the EntityReference for the given EntityComposite */ - public static EntityReference entityReferenceFor( Object object ) + public static EntityReference entityReferenceFor(Object object) { - return new EntityReference( (EntityComposite) object ); + return new EntityReference(((EntityComposite) object).identity().get()); } - public static EntityReference create( Identity identity ) + public static EntityReference create(Identity identity) { - if( identity == null ) + if (identity == null) + { return null; - return new EntityReference( identity.identity().get() ); + } + return new EntityReference(identity); } private static final long serialVersionUID = 1L; - private String identity; + private Identity identity; /** - * @param entityComposite a non-null EntityComposite - * @throws NullPointerException if entityComposite is null + * @param identity reference reference + * @throws NullArgumentException if reference is null or empty */ - public EntityReference( EntityComposite entityComposite ) + private EntityReference( Identity identity ) { - this( entityComposite.identity().get() ); - } - - /** - * @param identity reference identity - * @throws NullArgumentException if identity is null or empty - */ - public EntityReference( String identity ) - { - NullArgumentException.validateNotEmpty( "identity", identity ); + Objects.requireNonNull(identity,"reference must not be null"); this.identity = identity; } /** - * @return This EntityReference identity. + * + * @return The reference of the Entity that this EntityReference.is referring to */ - public final String identity() + public final Identity identity() { return identity; } @@ -108,18 +95,18 @@ public final class EntityReference } @Override - public boolean equals( Object o ) + public boolean equals(Object o) { - if( this == o ) + if (this == o) { return true; } - if( o == null || getClass() != o.getClass() ) + if (o == null || getClass() != o.getClass()) { return false; } EntityReference that = (EntityReference) o; - return identity.equals( that.identity ); + return identity.equals(that.identity); } @Override @@ -128,12 +115,9 @@ public final class EntityReference return identity.hashCode(); } - /** - * @return This EntityReference identity. - */ @Override public String toString() { - return identity; + return identity.toString(); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/entity/Identity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Identity.java b/core/api/src/main/java/org/apache/zest/api/entity/Identity.java deleted file mode 100644 index 3803201..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/Identity.java +++ /dev/null @@ -1,61 +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.api.entity; - -import org.apache.zest.api.injection.scope.State; -import org.apache.zest.api.mixin.Mixins; -import org.apache.zest.api.property.Immutable; -import org.apache.zest.api.property.Property; - -/** - * This interface provides the identity of the object which may be used - * to store the state in a database. It is not the responsibility of the - * framework to come up with a good identity string. - */ -@Mixins( Identity.IdentityMixin.class ) -public interface Identity -{ - /** - * Returns the client view of the identity. - * <p> - * It is unique within the owning repository, but potentially not unique globally and between - * types. - * </p> - * @return The Identity of 'this' composite. - */ - @Immutable - Property<String> identity(); - - /** - * Default Identity implementation. - */ - class IdentityMixin - implements Identity - { - @State - private Property<String> identity; - - @Override - public Property<String> identity() - { - return identity; - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java b/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java deleted file mode 100644 index eb3268b..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/IdentityGenerator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.api.entity; - -/** - * Generator for identities of EntityComposite's. - */ -public interface IdentityGenerator -{ - /** - * Generate a new id for the given Composite type - * - * @param compositeType the type of composite - * - * @return a new identity - */ - String generate( Class<?> compositeType ); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java b/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java index bfcf474..e7bde27 100644 --- a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java +++ b/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java @@ -45,7 +45,7 @@ package org.apache.zest.api.entity; * * public void create() * { - * String thisId = meAsIdentity.identity().get(); + * String thisId = meAsIdentity.reference().get(); * EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class ); * User admin = builder.newInstance(); * admin.set( admin ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java b/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java new file mode 100644 index 0000000..cd14f0f --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java @@ -0,0 +1,83 @@ +/* + * 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.identity; + +import java.lang.reflect.Method; +import org.apache.zest.api.common.QualifiedName; +import org.apache.zest.api.injection.scope.State; +import org.apache.zest.api.mixin.Mixins; +import org.apache.zest.api.property.Immutable; +import org.apache.zest.api.property.Property; + +/** + * This interface provides the identity of the object which may be used + * to store the state in a database. It is not the responsibility of the + * framework to come up with a good identity string. + */ +@Mixins( HasIdentity.HasIdentityMixin.class ) +public interface HasIdentity +{ + Method IDENTITY_METHOD = HasIdentityMixin.identityMethod(); + QualifiedName IDENTITY_STATE_NAME = HasIdentityMixin.stateName(); + + @Immutable + Property<Identity> identity(); + + /** + * Default Identity implementation. + */ + class HasIdentityMixin + implements HasIdentity + { + @State + private Property<Identity> identity; + + + @Override + public Property<Identity> identity() + { + return identity; + } + + private static QualifiedName stateName() + { + try + { + return QualifiedName.fromAccessor( HasIdentity.class.getMethod( "identity" ) ); + } + catch( NoSuchMethodException e ) + { + throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: EntityBuilderInstance" ); + } + } + + private static Method identityMethod() + { + try + { + return HasIdentity.class.getMethod( "identity" ); + } + catch( NoSuchMethodException e ) + { + throw new InternalError( "Zest Core Runtime codebase is corrupted." ); + } + } + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java b/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java new file mode 100644 index 0000000..23c733e --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java @@ -0,0 +1,6 @@ +package org.apache.zest.api.identity; + +public interface Identifiable +{ + Identity identity(); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/Identity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/Identity.java b/core/api/src/main/java/org/apache/zest/api/identity/Identity.java new file mode 100644 index 0000000..a0a15b3 --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/Identity.java @@ -0,0 +1,14 @@ +package org.apache.zest.api.identity; + +/** + * Representation of an Identity. + * Identity is an opaque, immutable data type. + * Identity is a very central concept in any domain model. + * + */ +public interface Identity +{ + String toString(); + + byte[] toBytes(); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java b/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java new file mode 100644 index 0000000..d15c8ab --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.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.api.identity; + +import org.apache.zest.api.mixin.Mixins; + +/** + * Generator for identities of EntityComposite's. + */ +@Mixins( UuidGeneratorMixin.class ) +public interface IdentityGenerator +{ + /** + * Generate a new id for the given Composite type + * + * @param compositeType the type of composite + * + * @return a new reference + */ + Identity generate( Class<?> compositeType ); + +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java new file mode 100644 index 0000000..d7acb09 --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java @@ -0,0 +1,67 @@ +package org.apache.zest.api.identity; + +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +public class StringIdentity + implements Identity +{ + private final String value; + + public StringIdentity(String value) + { + Objects.requireNonNull( value, "Identity can not be null." ); + this.value = value; + } + + public StringIdentity(byte[] bytes) + { + value = new String(bytes, StandardCharsets.UTF_8); + } + + public String value() + { + return value; + } + + @Override + public byte[] toBytes() + { + return value.getBytes(StandardCharsets.UTF_8); + } + + @Override + public String toString() + { + return value; + } + + public static Identity fromString(String serializedState) + { + return new StringIdentity( serializedState ); + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + StringIdentity that = (StringIdentity) o; + + return value.equals(that.value); + + } + + @Override + public int hashCode() + { + return value.hashCode(); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java new file mode 100644 index 0000000..854fe95 --- /dev/null +++ b/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java @@ -0,0 +1,13 @@ +package org.apache.zest.api.identity; + +import java.util.UUID; + +public class UuidGeneratorMixin + implements IdentityGenerator +{ + @Override + public Identity generate(Class<?> compositeType) + { + return StringIdentity.fromString(UUID.randomUUID().toString()); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java b/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java index ef17f5e..dea7134 100644 --- a/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java +++ b/core/api/src/main/java/org/apache/zest/api/query/QueryExpressions.java @@ -32,7 +32,8 @@ 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.composite.Composite; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.State; import org.apache.zest.api.property.GenericPropertyInfo; import org.apache.zest.api.property.Property; @@ -64,6 +65,7 @@ import org.apache.zest.api.query.grammar.PropertyReference; import org.apache.zest.api.query.grammar.Variable; import org.apache.zest.api.util.NullArgumentException; +import static org.apache.zest.api.identity.HasIdentity.IDENTITY_METHOD; import static org.apache.zest.functional.Iterables.first; import static org.apache.zest.functional.Iterables.prepend; @@ -73,19 +75,6 @@ import static org.apache.zest.functional.Iterables.prepend; public final class QueryExpressions { // This is used for eq(Association,Composite) - private static final Method IDENTITY_METHOD; - - static - { - try - { - IDENTITY_METHOD = Identity.class.getMethod( "identity" ); - } - catch( NoSuchMethodException e ) - { - throw new InternalError( "Zest Core API codebase is corrupted. Contact Zest team: QueryExpressions" ); - } - } // Templates and variables -----------------------------------------------| @@ -368,14 +357,16 @@ public final class QueryExpressions * * @return a new EQUALS specification for an Association. */ - public static <T> EqPredicate<String> eq( Association<T> association, T value ) + public static <T> EqPredicate<Identity> eq( Association<T> association, T value ) { - return new EqPredicate<>( new PropertyFunction<String>( null, - association( association ), - null, - null, - IDENTITY_METHOD ), - value.toString() ); + return new EqPredicate<>( + new PropertyFunction<>( + null, + association(association), + null, + null, + IDENTITY_METHOD), + ((HasIdentity) value).identity().get()); } /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullPredicate.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullPredicate.java index 3b6444d..29ce85e 100644 --- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullPredicate.java +++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNotNullPredicate.java @@ -63,6 +63,6 @@ public class AssociationNotNullPredicate<T> @Override public String toString() { - return association.toString() + "is not null"; + return association.toString() + " is not null"; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullPredicate.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullPredicate.java index 4cf596a..a304ae0 100644 --- a/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullPredicate.java +++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/AssociationNullPredicate.java @@ -63,6 +63,6 @@ public class AssociationNullPredicate<T> @Override public String toString() { - return association.toString() + "is null"; + return association.toString() + " is null"; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java index 3e410f4..ce8f7b3 100644 --- a/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java +++ b/core/api/src/main/java/org/apache/zest/api/query/grammar/MatchesPredicate.java @@ -81,14 +81,6 @@ public class MatchesPredicate @Override public String toString() { - return new StringBuilder() - .append( "( " ) - .append( property ) - .append( " matches " ) - .append( "\"" ) - .append( value ) - .append( "\"" ) - .append( " )" ) - .toString(); + return "( " + property + " matches " + "\"" + value + "\"" + " )"; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java b/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java index 3b60ec2..b5b13e6 100644 --- a/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java +++ b/core/api/src/main/java/org/apache/zest/api/service/DuplicateServiceIdentityException.java @@ -23,7 +23,7 @@ package org.apache.zest.api.service; import org.apache.zest.api.common.InvalidApplicationException; /** - * Thrown when a duplicate service identity is detected. + * Thrown when a duplicate service reference is detected. */ public class DuplicateServiceIdentityException extends InvalidApplicationException http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java deleted file mode 100644 index 26947b3..0000000 --- a/core/api/src/main/java/org/apache/zest/api/service/IdentityDescriptor.java +++ /dev/null @@ -1,28 +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.api.service; - -/** - * Identity Descriptor. - */ -public interface IdentityDescriptor -{ - String identity(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java index 8f5464e..e68f4b7 100644 --- a/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java +++ b/core/api/src/main/java/org/apache/zest/api/service/ImportedServiceDescriptor.java @@ -21,12 +21,13 @@ package org.apache.zest.api.service; import org.apache.zest.api.composite.ModelDescriptor; +import org.apache.zest.api.identity.Identifiable; /** * {@code ServiceDescriptor} provides meta information of a service. */ public interface ImportedServiceDescriptor - extends ModelDescriptor, IdentityDescriptor + extends ModelDescriptor, Identifiable { Class<? extends ServiceImporter> serviceImporter(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java index 37ffd25..48ff167 100644 --- a/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java +++ b/core/api/src/main/java/org/apache/zest/api/service/ServiceComposite.java @@ -21,13 +21,13 @@ package org.apache.zest.api.service; import org.apache.zest.api.composite.Composite; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; /** * All Composites being used to implement Services * must extend this interface. */ public interface ServiceComposite - extends Identity, Composite + extends HasIdentity, Composite { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java b/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java index 84d3d2e..8de5ff1 100644 --- a/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java +++ b/core/api/src/main/java/org/apache/zest/api/service/ServiceDescriptor.java @@ -22,14 +22,16 @@ package org.apache.zest.api.service; import org.apache.zest.api.composite.CompositeDescriptor; import org.apache.zest.api.composite.StatefulCompositeDescriptor; +import org.apache.zest.api.identity.Identifiable; /** * {@code ServiceDescriptor} provides meta informations of a service. */ public interface ServiceDescriptor - extends CompositeDescriptor, IdentityDescriptor, StatefulCompositeDescriptor + extends CompositeDescriptor, StatefulCompositeDescriptor, Identifiable { boolean isInstantiateOnStartup(); <T> Class<T> configurationType(); + } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/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 7e8e970..cce52e4 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 @@ -22,6 +22,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.identity.Identifiable; import org.apache.zest.api.structure.MetaInfoHolder; import org.apache.zest.api.type.HasTypes; @@ -30,14 +31,9 @@ import org.apache.zest.api.type.HasTypes; * You can also access the actual service through get(), that can then be invoked. */ public interface ServiceReference<T> - extends HasTypes, ActivationEventListenerRegistration, MetaInfoHolder + extends HasTypes, ActivationEventListenerRegistration, MetaInfoHolder, Identifiable { /** - * @return the service's identity - */ - String identity(); - - /** * @return the actual service */ T get(); @@ -52,9 +48,8 @@ public interface ServiceReference<T> */ boolean isAvailable(); - /** Returns the ServiceModel of the service referenced by this ServiceReference. - * - * @return + /** + * @return the ServiceModel of the service referenced by this ServiceReference. */ ModelDescriptor model(); }
