ZEST-195 ; Clean up the mistakes in the rename.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/b02063bd Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/b02063bd Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/b02063bd Branch: refs/heads/develop Commit: b02063bd7482c61cead2211dae901cc0d78fe187 Parents: 54b69c4 Author: Niclas Hedhman <[email protected]> Authored: Wed Dec 14 09:38:03 2016 +0800 Committer: Niclas Hedhman <[email protected]> Committed: Wed Dec 14 09:38:07 2016 +0800 ---------------------------------------------------------------------- .../polygene/gradle/PolygeneExtension.groovy | 79 ++++ .../apache/polygene/gradle/ZestExtension.groovy | 79 ---- .../gradle/publish/MavenMetadata.groovy | 2 +- .../org/apache/polygene/api/PolygeneAPI.java | 188 ++++++++++ .../java/org/apache/polygene/api/ZestAPI.java | 188 ---------- .../DeclareConfigurationDefaultsTest.java | 2 +- .../api/injection/scope/StateFieldTest.java | 2 +- .../decoratorMixin/DecoratorMixinTest.java | 2 +- .../api/property/PropertyErrorTest.java | 2 +- .../api/unitofwork/UnitOfWorkTemplateTest.java | 2 +- .../polygene/bootstrap/PolygeneRuntime.java | 38 ++ .../apache/polygene/bootstrap/ZestRuntime.java | 38 -- .../polygene/runtime/PolygeneRuntimeImpl.java | 360 +++++++++++++++++++ .../polygene/runtime/ZestRuntimeImpl.java | 360 ------------------- .../polygene/api/common/OptionalTest.java | 2 +- .../polygene/api/common/PropertyErrorTest.java | 2 +- .../polygene/api/common/PropertyTypeTest.java | 2 +- .../polygene/api/common/ValueCompositeTest.java | 2 +- .../regression/qi230/Qi230IssueTest.java | 2 +- ...faceCollisionWithRelatedReturnTypesTest.java | 2 +- .../polygene/regression/qi383/Qi383Test.java | 2 +- .../polygene/regression/qi59/IssueTest.java | 2 +- .../polygene/runtime/PolygeneAPITest.java | 87 +++++ .../polygene/runtime/PolygeneSPITest.java | 129 +++++++ .../apache/polygene/runtime/ZestAPITest.java | 87 ----- .../apache/polygene/runtime/ZestSPITest.java | 129 ------- .../runtime/appliesto/AppliesToFilterTest.java | 2 +- .../AppliesToOrConditionQI241Test.java | 2 +- .../association/AssociationEqualityTest.java | 2 +- .../DereferenceForBootstrappedConcernsTest.java | 2 +- .../runtime/composite/AbstractMixinTest.java | 2 +- .../composite/CompositeFactoryImplTest.java | 2 +- .../runtime/composite/MapOverrideTest.java | 2 +- .../polygene/runtime/composite/QI247Test2.java | 2 +- .../runtime/composite/TransientAsClassTest.java | 2 +- .../runtime/concerns/GenericConcernTest.java | 2 +- .../concerns/PropertyInheritanceTest.java | 2 +- .../runtime/constraints/ConstraintsTest.java | 2 +- .../polygene/runtime/entity/AggregatedTest.java | 2 +- .../entity/EntityCompositeEqualityTest.java | 2 +- .../runtime/entity/EntityCreationTest.java | 2 +- .../polygene/runtime/entity/EntityTypeTest.java | 2 +- .../polygene/runtime/entity/QI273Test.java | 2 +- .../entity/associations/AssociationTest.java | 2 +- .../associations/ImmutableAssociationTest.java | 2 +- .../IllegalUnitOfWorkInjectionTest.java | 2 +- .../runtime/injection/UsesGenericClassTest.java | 2 +- .../runtime/injection/UsesGraphTest.java | 2 +- .../ServiceInstantiationTests.java | 2 +- .../runtime/mixin/AssemblyMixinTest.java | 2 +- .../InvokeServiceFromModuleAssemblyTest.java | 2 +- .../mixin/MethodInterceptionMixinTest.java | 2 +- .../runtime/mixin/PrivateMixinTest.java | 2 +- .../polygene/runtime/mixin/Qi228Test.java | 2 +- .../runtime/property/ImmutablePropertyTest.java | 2 +- .../property/PropertyStringArrayTest.java | 2 +- .../polygene/runtime/property/PropertyTest.java | 2 +- .../query/QueryBuilderFactoryImplTest.java | 2 +- .../runtime/service/ComplexActivatableTest.java | 2 +- .../runtime/service/ServiceFinderTest.java | 2 +- .../sideeffects/GenericSideEffectTest.java | 2 +- .../sideeffects/SampleTransientTest.java | 2 +- .../runtime/threaded/ContextCompositeTest.java | 2 +- .../unitofwork/AutoCloseableUoWTest.java | 2 +- .../runtime/value/ValueCompositeBasicsTest.java | 2 +- .../service/importer/NewObjectImporterTest.java | 2 +- .../importer/ServiceInstanceImporterTest.java | 2 +- .../test/composite/CleanStackTraceTest.java | 2 +- .../org/apache/polygene/spi/PolygeneSPI.java | 75 ++++ .../java/org/apache/polygene/spi/ZestSPI.java | 75 ---- .../polygene/test/AbstractPolygeneBaseTest.java | 135 +++++++ .../test/AbstractPolygeneScenarioTest.java | 142 ++++++++ .../polygene/test/AbstractPolygeneTest.java | 120 +++++++ .../polygene/test/AbstractZestBaseTest.java | 135 ------- .../polygene/test/AbstractZestScenarioTest.java | 142 -------- .../apache/polygene/test/AbstractZestTest.java | 120 ------- .../test/cache/AbstractCachePoolTest.java | 2 +- ...AbstractValueCompositeSerializationTest.java | 2 +- doap.rdf | 2 +- .../entitystore/DocumentationSupport.java | 2 +- .../postgresql/PostgreSQLDBIntegrityTest.java | 2 +- .../library/alarm/AlarmHistoryImplTest.java | 2 +- .../library/alarm/AlarmPointImplTest.java | 2 +- .../library/alarm/SimpleAlarmModelTest.java | 2 +- .../library/alarm/StandardAlarmModelTest.java | 2 +- .../BreaksCircuitOnThrowableTest.java | 2 +- .../library/constraints/ConstraintTest.java | 2 +- .../library/http/AbstractJettyTest.java | 3 +- .../library/http/JettyJMXStatisticsTest.java | 2 +- libraries/http/src/test/resources/logback.xml | 2 +- .../http/src/vhost-test/resources/logback.xml | 2 +- .../polygene/library/jmx/PolygeneMBeans.java | 39 ++ .../apache/polygene/library/jmx/ZestMBeans.java | 39 -- .../library/groovy/GroovyMixinTest.java | 2 +- .../metrics/AbstractTimingCaptureTest.java | 3 +- .../polygene/library/rdf/PolygeneEntity.java | 39 ++ .../library/rdf/PolygeneEntityType.java | 39 ++ .../polygene/library/rdf/PolygeneRdf.java | 87 +++++ .../apache/polygene/library/rdf/ZestEntity.java | 39 -- .../polygene/library/rdf/ZestEntityType.java | 39 -- .../apache/polygene/library/rdf/ZestRdf.java | 87 ----- .../rdf/serializer/AbstractSerializer.java | 2 +- .../library/rdf/ApplicationXmlTest.java | 2 +- .../rdf/entity/EntitySerializerTest.java | 2 +- .../rdf/entity/EntityTypeSerializerTest.java | 2 +- .../rdf/repository/MemoryRepositoryTest.java | 2 +- .../rest/client/ContinuousIntegrationTest.java | 2 +- .../library/rest/admin/PolygeneFinder.java | 45 +++ .../rest/admin/PolygeneServerServlet.java | 44 +++ .../admin/PolygeneServerServletService.java | 34 ++ .../polygene/library/rest/admin/ZestFinder.java | 45 --- .../library/rest/admin/ZestServerServlet.java | 44 --- .../rest/admin/ZestServerServletService.java | 34 -- .../library/restlet/PolygeneEntityRestlet.java | 311 ++++++++++++++++ .../library/restlet/PolygeneServerServlet.java | 51 +++ .../library/restlet/ZestEntityRestlet.java | 311 ---------------- .../library/restlet/ZestServerServlet.java | 51 --- .../serialization/PolygeneConverter.java | 268 ++++++++++++++ .../restlet/serialization/ZestConverter.java | 268 -------------- .../library/servlet/PolygeneFilter.java | 51 +++ .../library/servlet/PolygeneServlet.java | 56 +++ .../library/servlet/PolygeneServletSupport.java | 44 +++ .../polygene/library/servlet/ZestFilter.java | 51 --- .../polygene/library/servlet/ZestServlet.java | 56 --- .../library/servlet/ZestServletSupport.java | 44 --- .../library/shiro/PasswordDomainTest.java | 4 +- .../library/shiro/PermissionsDomainTest.java | 4 +- .../library/shiro/RealmServiceTest.java | 4 +- .../library/shiro/StandaloneShiroTest.java | 4 +- .../library/shiro/web/WebHttpShiroTest.java | 2 +- .../library/shiro/web/WebRealmServiceTest.java | 2 +- .../library/spring/bootstrap/Constants.java | 2 +- .../bootstrap/PolygeneApplicationBootstrap.java | 88 +++++ .../bootstrap/ZestApplicationBootstrap.java | 88 ----- .../internal/PolygeneNamespaceHandler.java | 34 ++ .../internal/ZestNamespaceHandler.java | 34 -- .../PolygeneApplicationFactoryBean.java | 119 ++++++ .../PolygeneBootstrapBeanDefinitionParser.java | 103 ++++++ .../application/ZestApplicationFactoryBean.java | 119 ------ .../ZestBootstrapBeanDefinitionParser.java | 103 ------ .../PolygeneServiceBeanDefinitionParser.java | 55 +++ .../ZestServiceBeanDefinitionParser.java | 55 --- .../library/spring/MyPolygeneBootstrapper.java | 50 +++ .../library/spring/MyZestBootstrapper.java | 50 --- .../bootstrap/PolygeneExportServiceTest.java | 59 +++ .../spring/bootstrap/PolygeneTestBootstrap.java | 57 +++ .../spring/bootstrap/ZestExportServiceTest.java | 59 --- .../spring/bootstrap/ZestTestBootstrap.java | 58 --- .../importer/PolygeneImportServiceTest.java | 118 ++++++ .../spring/importer/ZestImportServiceTest.java | 118 ------ .../sql/datasource/ExternalDataSourceTest.java | 2 +- .../uid/sequence/PersistingSequencingTest.java | 2 +- .../uid/sequence/TransientSequencingTest.java | 2 +- .../library/uid/uuid/UuidServiceTest.java | 2 +- .../src/docs/tutorials/howto-depend-on-zest.txt | 40 +-- .../docs/tutorials/howto-releasing-apache.txt | 8 +- .../README-for-regression-reporting.txt | 2 +- .../idea/PolygeneApplicationComponent.java | 133 +++++++ .../plugin/idea/ZestApplicationComponent.java | 133 ------- .../common/inspections/AbstractInspection.java | 4 +- .../ZestStructureAnnotationConstants.java | 2 +- tools/shell/src/dist/bin/zest-boot | 4 +- .../tutorials/cargo/step2/Step2TestCase.java | 2 +- .../polygene/tutorials/hello/HelloTest.java | 2 +- .../polygene/tutorials/hello/HelloTest4.java | 2 +- .../tutorials/services/step2/LibraryTest.java | 2 +- .../tutorials/services/step3/LibraryTest.java | 2 +- .../tutorials/services/step4/LibraryTest.java | 2 +- .../tutorials/services/step6/LibraryTest.java | 2 +- 169 files changed, 3409 insertions(+), 3410 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy new file mode 100644 index 0000000..41e472a --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.polygene.gradle + +import groovy.transform.CompileStatic +import org.gradle.api.Project +import org.gradle.api.artifacts.Dependency + +@CompileStatic +class PolygeneExtension +{ + private final Project project + final Core core + + PolygeneExtension( Project project ) + { + this.project = project + this.core = new Core() + } + + boolean isDevelopmentVersion() + { + return project.version == '0' || project.version.toString().contains( 'SNAPSHOT' ) + } + + boolean isReleaseVersion() + { + return !isDevelopmentVersion() + } + + class Core + { + Dependency api = core( 'api' ) + Dependency spi = core( 'spi' ) + Dependency runtime = core( 'runtime' ) + Dependency bootstrap = core( 'bootstrap' ) + Dependency testsupport = core( 'testsupport' ) + } + + private Dependency core( String name ) + { + return dependency( 'org.apache.polygene.core', "org.apache.polygene.core.$name" ) + } + + Dependency library( String name ) + { + return dependency( 'org.apache.polygene.libraries', "org.apache.polygene.library.$name" ) + } + + Dependency extension( String name ) + { + return dependency( 'org.apache.polygene.extensions', "org.apache.polygene.extension.$name" ) + } + + Dependency tool( String name ) + { + return dependency( 'org.apache.polygene.tools', "org.apache.polygene.tool.$name" ) + } + + private Dependency dependency( String group, String name ) + { + project.dependencies.project( path: ":$group:$name" ) + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/buildSrc/src/main/groovy/org/apache/polygene/gradle/ZestExtension.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/ZestExtension.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/ZestExtension.groovy deleted file mode 100644 index 41e472a..0000000 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/ZestExtension.groovy +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.polygene.gradle - -import groovy.transform.CompileStatic -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency - -@CompileStatic -class PolygeneExtension -{ - private final Project project - final Core core - - PolygeneExtension( Project project ) - { - this.project = project - this.core = new Core() - } - - boolean isDevelopmentVersion() - { - return project.version == '0' || project.version.toString().contains( 'SNAPSHOT' ) - } - - boolean isReleaseVersion() - { - return !isDevelopmentVersion() - } - - class Core - { - Dependency api = core( 'api' ) - Dependency spi = core( 'spi' ) - Dependency runtime = core( 'runtime' ) - Dependency bootstrap = core( 'bootstrap' ) - Dependency testsupport = core( 'testsupport' ) - } - - private Dependency core( String name ) - { - return dependency( 'org.apache.polygene.core', "org.apache.polygene.core.$name" ) - } - - Dependency library( String name ) - { - return dependency( 'org.apache.polygene.libraries', "org.apache.polygene.library.$name" ) - } - - Dependency extension( String name ) - { - return dependency( 'org.apache.polygene.extensions', "org.apache.polygene.extension.$name" ) - } - - Dependency tool( String name ) - { - return dependency( 'org.apache.polygene.tools', "org.apache.polygene.tool.$name" ) - } - - private Dependency dependency( String group, String name ) - { - project.dependencies.project( path: ":$group:$name" ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/buildSrc/src/main/groovy/org/apache/polygene/gradle/publish/MavenMetadata.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/publish/MavenMetadata.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/publish/MavenMetadata.groovy index 74c5dcf..85f9ebd 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/publish/MavenMetadata.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/publish/MavenMetadata.groovy @@ -33,7 +33,7 @@ class MavenMetadata inceptionYear '2007' issueManagement { system 'jira' - url 'https://issues.apache.org/jira/browse/ZEST' + url 'https://issues.apache.org/jira/browse/POLYGENE' } scm { url "https://github.com/apache/polygene-java" http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/main/java/org/apache/polygene/api/PolygeneAPI.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/PolygeneAPI.java b/core/api/src/main/java/org/apache/polygene/api/PolygeneAPI.java new file mode 100644 index 0000000..ae03999 --- /dev/null +++ b/core/api/src/main/java/org/apache/polygene/api/PolygeneAPI.java @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.api; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; +import java.util.function.Function; +import org.apache.polygene.api.association.AbstractAssociation; +import org.apache.polygene.api.association.AssociationDescriptor; +import org.apache.polygene.api.composite.Composite; +import org.apache.polygene.api.composite.CompositeDescriptor; +import org.apache.polygene.api.composite.CompositeInstance; +import org.apache.polygene.api.composite.InvalidCompositeException; +import org.apache.polygene.api.composite.ModelDescriptor; +import org.apache.polygene.api.composite.TransientDescriptor; +import org.apache.polygene.api.entity.EntityDescriptor; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.property.PropertyDescriptor; +import org.apache.polygene.api.service.ServiceDescriptor; +import org.apache.polygene.api.structure.ModuleDescriptor; +import org.apache.polygene.api.value.ValueDescriptor; + +/** + * Encapsulation of the Polygene API. + */ +public interface PolygeneAPI +{ + /** + * If a Modifier gets a reference to the Composite using @This, + * then that reference must be dereferenced using this method + * before handing it out for others to use. + * + * @param <T> Parameterized type of the Composite + * @param composite instance reference injected in Modified using @This + * + * @return the dereferenced Composite + */ + <T> T dereference( T composite ); + + /** + * Returns the Module or UnitOfWork where the Composite belongs. + * + * @param compositeOrUow The Composite (Service, Value, Entity or Transient) or UnitOfWork to lookup the Module it + * belongs to. + * + * @return The Module instance where the Composite or UnitOfWork belongs to. + */ + ModuleDescriptor moduleOf( Object compositeOrUow ); + + /** + * Returns the ModelDescriptor of the Composite. + * + * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the + * ModelDescriptor + * + * @return The ModelDescriptor of the Composite + */ + ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference ); + + /** + * Returns the CompositeDescriptor of the Composite. + * + * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the + * CompositeDescriptor + * + * @return The CompositeDescriptor of the Composite + */ + CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference ); + + /** + * Returns the TransientDescriptor of the TransientComposite. + * + * @param transsient The TransientComposite for which to lookup the TransientDescriptor + * + * @return The TransientDescriptor of the TransientComposite + */ + TransientDescriptor transientDescriptorFor( Object transsient ); + + /** + * Returns the EntityDescriptor of the EntityComposite. + * + * @param entity The EntityComposite for which to lookup the EntityDescriptor + * + * @return The EntityDescriptor of the EntityComposite + */ + EntityDescriptor entityDescriptorFor( Object entity ); + + /** + * Returns the ValueDescriptor of the ValueComposite. + * + * @param value The ValueComposite for which to lookup the ValueDescriptor + * + * @return The ValueDescriptor of the ValueComposite + */ + ValueDescriptor valueDescriptorFor( Object value ); + + /** + * Returns the ServiceDescriptor of the ServiceComposite. + * + * @param service The ServiceComposite for which to lookup the ServiceDescriptor + * + * @return The ServiceDescriptor of the ServiceComposite + */ + ServiceDescriptor serviceDescriptorFor( Object service ); + + /** + * Returns the PropertyDescriptor of the Property. + * + * @param property The Property for which to lookup the PropertyDescriptor + * + * @return The PropertyDescriptor of the Property + */ + PropertyDescriptor propertyDescriptorFor( Property<?> property ); + + /** + * Returns the AssociationDescriptor of the Association. + * + * @param association The Association for which to lookup the AssociationDescriptor + * + * @return The AssociationDescriptor of the Association + */ + AssociationDescriptor associationDescriptorFor( AbstractAssociation association ); + + /** + * Function that returns the CompositeDescriptor of a Composite. + */ + Function<Composite, CompositeDescriptor> FUNCTION_DESCRIPTOR_FOR = composite -> { + if( composite instanceof Proxy ) + { + InvocationHandler invocationHandler = Proxy.getInvocationHandler( composite ); + return ( (CompositeInstance) invocationHandler ).descriptor(); + } + try + { + Class<? extends Composite> compositeClass = composite.getClass(); + Field instanceField = compositeClass.getField( "_instance" ); + Object instance = instanceField.get( composite ); + return ( (CompositeInstance) instance ).descriptor(); + } + catch( Exception e ) + { + InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" ); + exception.initCause( e ); + throw exception; + } + }; + + /** + * Function that returns the CompositeInstance of a Composite. + */ + Function<Composite, CompositeInstance> FUNCTION_COMPOSITE_INSTANCE_OF = composite -> { + if( composite instanceof Proxy ) + { + return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) ); + } + try + { + Class<? extends Composite> compositeClass = composite.getClass(); + Field instanceField = compositeClass.getField( "_instance" ); + Object instance = instanceField.get( composite ); + return (CompositeInstance) instance; + } + catch( Exception e ) + { + InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" ); + exception.initCause( e ); + throw exception; + } + }; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/main/java/org/apache/polygene/api/ZestAPI.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/polygene/api/ZestAPI.java b/core/api/src/main/java/org/apache/polygene/api/ZestAPI.java deleted file mode 100644 index ae03999..0000000 --- a/core/api/src/main/java/org/apache/polygene/api/ZestAPI.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.polygene.api; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Proxy; -import java.util.function.Function; -import org.apache.polygene.api.association.AbstractAssociation; -import org.apache.polygene.api.association.AssociationDescriptor; -import org.apache.polygene.api.composite.Composite; -import org.apache.polygene.api.composite.CompositeDescriptor; -import org.apache.polygene.api.composite.CompositeInstance; -import org.apache.polygene.api.composite.InvalidCompositeException; -import org.apache.polygene.api.composite.ModelDescriptor; -import org.apache.polygene.api.composite.TransientDescriptor; -import org.apache.polygene.api.entity.EntityDescriptor; -import org.apache.polygene.api.property.Property; -import org.apache.polygene.api.property.PropertyDescriptor; -import org.apache.polygene.api.service.ServiceDescriptor; -import org.apache.polygene.api.structure.ModuleDescriptor; -import org.apache.polygene.api.value.ValueDescriptor; - -/** - * Encapsulation of the Polygene API. - */ -public interface PolygeneAPI -{ - /** - * If a Modifier gets a reference to the Composite using @This, - * then that reference must be dereferenced using this method - * before handing it out for others to use. - * - * @param <T> Parameterized type of the Composite - * @param composite instance reference injected in Modified using @This - * - * @return the dereferenced Composite - */ - <T> T dereference( T composite ); - - /** - * Returns the Module or UnitOfWork where the Composite belongs. - * - * @param compositeOrUow The Composite (Service, Value, Entity or Transient) or UnitOfWork to lookup the Module it - * belongs to. - * - * @return The Module instance where the Composite or UnitOfWork belongs to. - */ - ModuleDescriptor moduleOf( Object compositeOrUow ); - - /** - * Returns the ModelDescriptor of the Composite. - * - * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the - * ModelDescriptor - * - * @return The ModelDescriptor of the Composite - */ - ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference ); - - /** - * Returns the CompositeDescriptor of the Composite. - * - * @param compositeOrServiceReference The Composite (Service, Value, Entity or Transient) for which to lookup the - * CompositeDescriptor - * - * @return The CompositeDescriptor of the Composite - */ - CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference ); - - /** - * Returns the TransientDescriptor of the TransientComposite. - * - * @param transsient The TransientComposite for which to lookup the TransientDescriptor - * - * @return The TransientDescriptor of the TransientComposite - */ - TransientDescriptor transientDescriptorFor( Object transsient ); - - /** - * Returns the EntityDescriptor of the EntityComposite. - * - * @param entity The EntityComposite for which to lookup the EntityDescriptor - * - * @return The EntityDescriptor of the EntityComposite - */ - EntityDescriptor entityDescriptorFor( Object entity ); - - /** - * Returns the ValueDescriptor of the ValueComposite. - * - * @param value The ValueComposite for which to lookup the ValueDescriptor - * - * @return The ValueDescriptor of the ValueComposite - */ - ValueDescriptor valueDescriptorFor( Object value ); - - /** - * Returns the ServiceDescriptor of the ServiceComposite. - * - * @param service The ServiceComposite for which to lookup the ServiceDescriptor - * - * @return The ServiceDescriptor of the ServiceComposite - */ - ServiceDescriptor serviceDescriptorFor( Object service ); - - /** - * Returns the PropertyDescriptor of the Property. - * - * @param property The Property for which to lookup the PropertyDescriptor - * - * @return The PropertyDescriptor of the Property - */ - PropertyDescriptor propertyDescriptorFor( Property<?> property ); - - /** - * Returns the AssociationDescriptor of the Association. - * - * @param association The Association for which to lookup the AssociationDescriptor - * - * @return The AssociationDescriptor of the Association - */ - AssociationDescriptor associationDescriptorFor( AbstractAssociation association ); - - /** - * Function that returns the CompositeDescriptor of a Composite. - */ - Function<Composite, CompositeDescriptor> FUNCTION_DESCRIPTOR_FOR = composite -> { - if( composite instanceof Proxy ) - { - InvocationHandler invocationHandler = Proxy.getInvocationHandler( composite ); - return ( (CompositeInstance) invocationHandler ).descriptor(); - } - try - { - Class<? extends Composite> compositeClass = composite.getClass(); - Field instanceField = compositeClass.getField( "_instance" ); - Object instance = instanceField.get( composite ); - return ( (CompositeInstance) instance ).descriptor(); - } - catch( Exception e ) - { - InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" ); - exception.initCause( e ); - throw exception; - } - }; - - /** - * Function that returns the CompositeInstance of a Composite. - */ - Function<Composite, CompositeInstance> FUNCTION_COMPOSITE_INSTANCE_OF = composite -> { - if( composite instanceof Proxy ) - { - return ( (CompositeInstance) Proxy.getInvocationHandler( composite ) ); - } - try - { - Class<? extends Composite> compositeClass = composite.getClass(); - Field instanceField = compositeClass.getField( "_instance" ); - Object instance = instanceField.get( composite ); - return (CompositeInstance) instance; - } - catch( Exception e ) - { - InvalidCompositeException exception = new InvalidCompositeException( "Could not get _instance field" ); - exception.initCause( e ); - throw exception; - } - }; -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/test/java/org/apache/polygene/api/configuration/DeclareConfigurationDefaultsTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/polygene/api/configuration/DeclareConfigurationDefaultsTest.java b/core/api/src/test/java/org/apache/polygene/api/configuration/DeclareConfigurationDefaultsTest.java index c088df7..d0384a8 100644 --- a/core/api/src/test/java/org/apache/polygene/api/configuration/DeclareConfigurationDefaultsTest.java +++ b/core/api/src/test/java/org/apache/polygene/api/configuration/DeclareConfigurationDefaultsTest.java @@ -31,7 +31,7 @@ import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; public class DeclareConfigurationDefaultsTest - extends AbstractPolygeneTest + extends AbstractPolygeneTest { @Mixins( FooServiceMixin.class ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java b/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java index 13c6e60..a4b8b30 100644 --- a/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java +++ b/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java @@ -20,6 +20,7 @@ package org.apache.polygene.api.injection.scope; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Assert; import org.junit.Test; import org.apache.polygene.api.association.Association; @@ -32,7 +33,6 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java index 4b658e5..40f59d3 100644 --- a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java +++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java @@ -21,11 +21,11 @@ package org.apache.polygene.api.mixin.decoratorMixin; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertThat; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java b/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java index f0fe7a1..c299300 100644 --- a/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java +++ b/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java @@ -20,13 +20,13 @@ package org.apache.polygene.api.property; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.constraint.ConstraintViolationException; import org.apache.polygene.api.entity.EntityComposite; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java index 5f4b2ae..43bd5b7 100644 --- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java +++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java @@ -19,13 +19,13 @@ */ package org.apache.polygene.api.unitofwork; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.entity.EntityBuilderTemplate; import org.apache.polygene.api.entity.EntityComposite; import org.apache.polygene.api.property.Property; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/PolygeneRuntime.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/PolygeneRuntime.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/PolygeneRuntime.java new file mode 100644 index 0000000..c5c5386 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/PolygeneRuntime.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +import org.apache.polygene.api.PolygeneAPI; +import org.apache.polygene.spi.PolygeneSPI; + +/** + * This interface has to be implemented by Polygene runtimes. + */ +public interface PolygeneRuntime +{ + ApplicationAssemblyFactory applicationAssemblyFactory(); + + ApplicationModelFactory applicationModelFactory(); + + PolygeneAPI api(); + + PolygeneSPI spi(); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ZestRuntime.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ZestRuntime.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ZestRuntime.java deleted file mode 100644 index c5c5386..0000000 --- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ZestRuntime.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.polygene.bootstrap; - -import org.apache.polygene.api.PolygeneAPI; -import org.apache.polygene.spi.PolygeneSPI; - -/** - * This interface has to be implemented by Polygene runtimes. - */ -public interface PolygeneRuntime -{ - ApplicationAssemblyFactory applicationAssemblyFactory(); - - ApplicationModelFactory applicationModelFactory(); - - PolygeneAPI api(); - - PolygeneSPI spi(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/main/java/org/apache/polygene/runtime/PolygeneRuntimeImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/PolygeneRuntimeImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/PolygeneRuntimeImpl.java new file mode 100644 index 0000000..2a0be69 --- /dev/null +++ b/core/runtime/src/main/java/org/apache/polygene/runtime/PolygeneRuntimeImpl.java @@ -0,0 +1,360 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.runtime; + +import java.lang.reflect.InvocationHandler; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Stream; +import org.apache.polygene.api.PolygeneAPI; +import org.apache.polygene.api.association.AbstractAssociation; +import org.apache.polygene.api.association.Association; +import org.apache.polygene.api.association.AssociationDescriptor; +import org.apache.polygene.api.association.AssociationStateHolder; +import org.apache.polygene.api.association.AssociationWrapper; +import org.apache.polygene.api.association.ManyAssociation; +import org.apache.polygene.api.association.ManyAssociationWrapper; +import org.apache.polygene.api.association.NamedAssociation; +import org.apache.polygene.api.association.NamedAssociationWrapper; +import org.apache.polygene.api.composite.Composite; +import org.apache.polygene.api.composite.CompositeDescriptor; +import org.apache.polygene.api.composite.CompositeInstance; +import org.apache.polygene.api.composite.ModelDescriptor; +import org.apache.polygene.api.composite.TransientComposite; +import org.apache.polygene.api.composite.TransientDescriptor; +import org.apache.polygene.api.entity.EntityComposite; +import org.apache.polygene.api.entity.EntityDescriptor; +import org.apache.polygene.api.entity.EntityReference; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.property.PropertyDescriptor; +import org.apache.polygene.api.property.PropertyWrapper; +import org.apache.polygene.api.property.StateHolder; +import org.apache.polygene.api.service.ServiceComposite; +import org.apache.polygene.api.service.ServiceDescriptor; +import org.apache.polygene.api.service.ServiceReference; +import org.apache.polygene.api.structure.ModuleDescriptor; +import org.apache.polygene.api.unitofwork.UnitOfWork; +import org.apache.polygene.api.value.ValueComposite; +import org.apache.polygene.api.value.ValueDescriptor; +import org.apache.polygene.bootstrap.ApplicationAssemblyFactory; +import org.apache.polygene.bootstrap.ApplicationModelFactory; +import org.apache.polygene.bootstrap.PolygeneRuntime; +import org.apache.polygene.runtime.association.AbstractAssociationInstance; +import org.apache.polygene.runtime.bootstrap.ApplicationAssemblyFactoryImpl; +import org.apache.polygene.runtime.bootstrap.ApplicationModelFactoryImpl; +import org.apache.polygene.runtime.composite.ProxyReferenceInvocationHandler; +import org.apache.polygene.runtime.composite.TransientInstance; +import org.apache.polygene.runtime.entity.EntityInstance; +import org.apache.polygene.runtime.property.PropertyInstance; +import org.apache.polygene.runtime.service.ImportedServiceReferenceInstance; +import org.apache.polygene.runtime.service.ServiceInstance; +import org.apache.polygene.runtime.service.ServiceReferenceInstance; +import org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork; +import org.apache.polygene.runtime.value.ValueInstance; +import org.apache.polygene.spi.PolygeneSPI; +import org.apache.polygene.spi.entity.EntityState; + +import static java.lang.reflect.Proxy.getInvocationHandler; +import static org.apache.polygene.runtime.composite.TransientInstance.compositeInstanceOf; + +/** + * Incarnation of Polygene. + */ +public final class PolygeneRuntimeImpl + implements PolygeneSPI, PolygeneRuntime +{ + private final ApplicationAssemblyFactory applicationAssemblyFactory; + private final ApplicationModelFactory applicationModelFactory; + + public PolygeneRuntimeImpl() + { + applicationAssemblyFactory = new ApplicationAssemblyFactoryImpl(); + applicationModelFactory = new ApplicationModelFactoryImpl(); + } + + @Override + public ApplicationAssemblyFactory applicationAssemblyFactory() + { + return applicationAssemblyFactory; + } + + @Override + public ApplicationModelFactory applicationModelFactory() + { + return applicationModelFactory; + } + + @Override + public PolygeneAPI api() + { + return this; + } + + @Override + public PolygeneSPI spi() + { + return this; + } + + // API + + @Override + @SuppressWarnings( "unchecked" ) + public <T> T dereference( T composite ) + { + InvocationHandler handler = getInvocationHandler( composite ); + if( handler instanceof ProxyReferenceInvocationHandler ) + { + return (T) ( (ProxyReferenceInvocationHandler) handler ).proxy(); + } + if( handler instanceof CompositeInstance ) + { + return composite; + } + return null; + } + + @Override + public ModuleDescriptor moduleOf( Object compositeOrServiceReferenceOrUow ) + { + if( compositeOrServiceReferenceOrUow instanceof TransientComposite ) + { + TransientComposite composite = (TransientComposite) compositeOrServiceReferenceOrUow; + return TransientInstance.compositeInstanceOf( composite ).module(); + } + else if( compositeOrServiceReferenceOrUow instanceof EntityComposite ) + { + EntityComposite composite = (EntityComposite) compositeOrServiceReferenceOrUow; + return EntityInstance.entityInstanceOf( composite ).module(); + } + else if( compositeOrServiceReferenceOrUow instanceof ValueComposite ) + { + ValueComposite composite = (ValueComposite) compositeOrServiceReferenceOrUow; + return ValueInstance.valueInstanceOf( composite ).module(); + } + else if( compositeOrServiceReferenceOrUow instanceof ServiceComposite ) + { + ServiceComposite composite = (ServiceComposite) compositeOrServiceReferenceOrUow; + InvocationHandler handler = getInvocationHandler( composite ); + if( handler instanceof ServiceInstance ) + { + return ( (ServiceInstance) handler ).module(); + } + return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).module(); + } + else if( compositeOrServiceReferenceOrUow instanceof UnitOfWork ) + { + ModuleUnitOfWork unitOfWork = (ModuleUnitOfWork) compositeOrServiceReferenceOrUow; + return unitOfWork.module(); + } + else if( compositeOrServiceReferenceOrUow instanceof ServiceReferenceInstance ) + { + ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow; + return reference.module(); + } + else if( compositeOrServiceReferenceOrUow instanceof ImportedServiceReferenceInstance ) + { + ImportedServiceReferenceInstance<?> importedServiceReference + = (ImportedServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow; + return importedServiceReference.module(); + } + throw new IllegalArgumentException( "Wrong type. Must be one of " + + Arrays.asList( TransientComposite.class, ValueComposite.class, + ServiceComposite.class, ServiceReference.class, + UnitOfWork.class ) ); + } + + @Override + public ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference ) + { + if( compositeOrServiceReference instanceof TransientComposite ) + { + TransientComposite composite = (TransientComposite) compositeOrServiceReference; + return TransientInstance.compositeInstanceOf( composite ).descriptor(); + } + else if( compositeOrServiceReference instanceof EntityComposite ) + { + EntityComposite composite = (EntityComposite) compositeOrServiceReference; + return EntityInstance.entityInstanceOf( composite ).descriptor(); + } + else if( compositeOrServiceReference instanceof ValueComposite ) + { + ValueComposite composite = (ValueComposite) compositeOrServiceReference; + return ValueInstance.valueInstanceOf( composite ).descriptor(); + } + else if( compositeOrServiceReference instanceof ServiceComposite ) + { + ServiceComposite composite = (ServiceComposite) compositeOrServiceReference; + InvocationHandler handler = getInvocationHandler( composite ); + if( handler instanceof ServiceInstance ) + { + return ( (ServiceInstance) handler ).descriptor(); + } + return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).descriptor(); + } + else if( compositeOrServiceReference instanceof ServiceReferenceInstance ) + { + ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReference; + return reference.serviceDescriptor(); + } + else if( compositeOrServiceReference instanceof ImportedServiceReferenceInstance ) + { + ImportedServiceReferenceInstance<?> importedServiceReference + = (ImportedServiceReferenceInstance<?>) compositeOrServiceReference; + return importedServiceReference.serviceDescriptor(); + } + throw new IllegalArgumentException( "Wrong type. Must be one of " + + Arrays.asList( TransientComposite.class, ValueComposite.class, + ServiceComposite.class, ServiceReference.class ) ); + } + + @Override + public CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference ) + { + return (CompositeDescriptor) modelDescriptorFor( compositeOrServiceReference ); + } + + // Descriptors + + @Override + public TransientDescriptor transientDescriptorFor( Object transsient ) + { + if( transsient instanceof TransientComposite ) + { + TransientInstance transientInstance = compositeInstanceOf( (Composite) transsient ); + return (TransientDescriptor) transientInstance.descriptor(); + } + throw new IllegalArgumentException( "Wrong type. Must be subtype of " + TransientComposite.class ); + } + + @Override + public StateHolder stateOf( TransientComposite composite ) + { + return TransientInstance.compositeInstanceOf( composite ).state(); + } + + @Override + public EntityDescriptor entityDescriptorFor( Object entity ) + { + if( entity instanceof EntityComposite ) + { + EntityInstance entityInstance = (EntityInstance) getInvocationHandler( entity ); + return entityInstance.entityModel(); + } + throw new IllegalArgumentException( "Wrong type. Must be subtype of " + EntityComposite.class ); + } + + @Override + public AssociationStateHolder stateOf( EntityComposite composite ) + { + return EntityInstance.entityInstanceOf( composite ).state(); + } + + @Override + public ValueDescriptor valueDescriptorFor( Object value ) + { + if( value instanceof ValueComposite ) + { + ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) value ); + return valueInstance.descriptor(); + } + throw new IllegalArgumentException( "Wrong type. Must be subtype of " + ValueComposite.class ); + } + + @Override + public AssociationStateHolder stateOf( ValueComposite composite ) + { + return ValueInstance.valueInstanceOf( composite ).state(); + } + + @Override + public ServiceDescriptor serviceDescriptorFor( Object service ) + { + if( service instanceof ServiceReferenceInstance ) + { + ServiceReferenceInstance<?> ref = (ServiceReferenceInstance<?>) service; + return ref.serviceDescriptor(); + } + if( service instanceof ServiceComposite ) + { + ServiceComposite composite = (ServiceComposite) service; + return (ServiceDescriptor) ServiceInstance.serviceInstanceOf( composite ).descriptor(); + } + throw new IllegalArgumentException( "Wrong type. Must be subtype of " + + ServiceComposite.class + " or " + ServiceReference.class ); + } + + @Override + public PropertyDescriptor propertyDescriptorFor( Property<?> property ) + { + while( property instanceof PropertyWrapper ) + { + property = ( (PropertyWrapper) property ).next(); + } + + return (PropertyDescriptor) ( (PropertyInstance<?>) property ).propertyInfo(); + } + + @Override + public AssociationDescriptor associationDescriptorFor( AbstractAssociation association ) + { + while( association instanceof AssociationWrapper ) + { + association = ( (AssociationWrapper) association ).next(); + } + + while( association instanceof ManyAssociationWrapper ) + { + association = ( (ManyAssociationWrapper) association ).next(); + } + + while( association instanceof NamedAssociationWrapper ) + { + association = ( (NamedAssociationWrapper) association ).next(); + } + + return (AssociationDescriptor) ( (AbstractAssociationInstance) association ).associationInfo(); + } + + // SPI + @Override + public EntityState entityStateOf( EntityComposite composite ) + { + return EntityInstance.entityInstanceOf( composite ).entityState(); + } + + @Override + public EntityReference entityReferenceOf( Association<?> assoc ) + { + return assoc.reference(); + } + + @Override + public Stream<EntityReference> entityReferencesOf( ManyAssociation<?> assoc ) + { + return assoc.references(); + } + + @Override + public Stream<Map.Entry<String, EntityReference>> entityReferencesOf( NamedAssociation<?> assoc ) + { + return assoc.references(); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/main/java/org/apache/polygene/runtime/ZestRuntimeImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/ZestRuntimeImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/ZestRuntimeImpl.java deleted file mode 100644 index 2a0be69..0000000 --- a/core/runtime/src/main/java/org/apache/polygene/runtime/ZestRuntimeImpl.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.polygene.runtime; - -import java.lang.reflect.InvocationHandler; -import java.util.Arrays; -import java.util.Map; -import java.util.stream.Stream; -import org.apache.polygene.api.PolygeneAPI; -import org.apache.polygene.api.association.AbstractAssociation; -import org.apache.polygene.api.association.Association; -import org.apache.polygene.api.association.AssociationDescriptor; -import org.apache.polygene.api.association.AssociationStateHolder; -import org.apache.polygene.api.association.AssociationWrapper; -import org.apache.polygene.api.association.ManyAssociation; -import org.apache.polygene.api.association.ManyAssociationWrapper; -import org.apache.polygene.api.association.NamedAssociation; -import org.apache.polygene.api.association.NamedAssociationWrapper; -import org.apache.polygene.api.composite.Composite; -import org.apache.polygene.api.composite.CompositeDescriptor; -import org.apache.polygene.api.composite.CompositeInstance; -import org.apache.polygene.api.composite.ModelDescriptor; -import org.apache.polygene.api.composite.TransientComposite; -import org.apache.polygene.api.composite.TransientDescriptor; -import org.apache.polygene.api.entity.EntityComposite; -import org.apache.polygene.api.entity.EntityDescriptor; -import org.apache.polygene.api.entity.EntityReference; -import org.apache.polygene.api.property.Property; -import org.apache.polygene.api.property.PropertyDescriptor; -import org.apache.polygene.api.property.PropertyWrapper; -import org.apache.polygene.api.property.StateHolder; -import org.apache.polygene.api.service.ServiceComposite; -import org.apache.polygene.api.service.ServiceDescriptor; -import org.apache.polygene.api.service.ServiceReference; -import org.apache.polygene.api.structure.ModuleDescriptor; -import org.apache.polygene.api.unitofwork.UnitOfWork; -import org.apache.polygene.api.value.ValueComposite; -import org.apache.polygene.api.value.ValueDescriptor; -import org.apache.polygene.bootstrap.ApplicationAssemblyFactory; -import org.apache.polygene.bootstrap.ApplicationModelFactory; -import org.apache.polygene.bootstrap.PolygeneRuntime; -import org.apache.polygene.runtime.association.AbstractAssociationInstance; -import org.apache.polygene.runtime.bootstrap.ApplicationAssemblyFactoryImpl; -import org.apache.polygene.runtime.bootstrap.ApplicationModelFactoryImpl; -import org.apache.polygene.runtime.composite.ProxyReferenceInvocationHandler; -import org.apache.polygene.runtime.composite.TransientInstance; -import org.apache.polygene.runtime.entity.EntityInstance; -import org.apache.polygene.runtime.property.PropertyInstance; -import org.apache.polygene.runtime.service.ImportedServiceReferenceInstance; -import org.apache.polygene.runtime.service.ServiceInstance; -import org.apache.polygene.runtime.service.ServiceReferenceInstance; -import org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork; -import org.apache.polygene.runtime.value.ValueInstance; -import org.apache.polygene.spi.PolygeneSPI; -import org.apache.polygene.spi.entity.EntityState; - -import static java.lang.reflect.Proxy.getInvocationHandler; -import static org.apache.polygene.runtime.composite.TransientInstance.compositeInstanceOf; - -/** - * Incarnation of Polygene. - */ -public final class PolygeneRuntimeImpl - implements PolygeneSPI, PolygeneRuntime -{ - private final ApplicationAssemblyFactory applicationAssemblyFactory; - private final ApplicationModelFactory applicationModelFactory; - - public PolygeneRuntimeImpl() - { - applicationAssemblyFactory = new ApplicationAssemblyFactoryImpl(); - applicationModelFactory = new ApplicationModelFactoryImpl(); - } - - @Override - public ApplicationAssemblyFactory applicationAssemblyFactory() - { - return applicationAssemblyFactory; - } - - @Override - public ApplicationModelFactory applicationModelFactory() - { - return applicationModelFactory; - } - - @Override - public PolygeneAPI api() - { - return this; - } - - @Override - public PolygeneSPI spi() - { - return this; - } - - // API - - @Override - @SuppressWarnings( "unchecked" ) - public <T> T dereference( T composite ) - { - InvocationHandler handler = getInvocationHandler( composite ); - if( handler instanceof ProxyReferenceInvocationHandler ) - { - return (T) ( (ProxyReferenceInvocationHandler) handler ).proxy(); - } - if( handler instanceof CompositeInstance ) - { - return composite; - } - return null; - } - - @Override - public ModuleDescriptor moduleOf( Object compositeOrServiceReferenceOrUow ) - { - if( compositeOrServiceReferenceOrUow instanceof TransientComposite ) - { - TransientComposite composite = (TransientComposite) compositeOrServiceReferenceOrUow; - return TransientInstance.compositeInstanceOf( composite ).module(); - } - else if( compositeOrServiceReferenceOrUow instanceof EntityComposite ) - { - EntityComposite composite = (EntityComposite) compositeOrServiceReferenceOrUow; - return EntityInstance.entityInstanceOf( composite ).module(); - } - else if( compositeOrServiceReferenceOrUow instanceof ValueComposite ) - { - ValueComposite composite = (ValueComposite) compositeOrServiceReferenceOrUow; - return ValueInstance.valueInstanceOf( composite ).module(); - } - else if( compositeOrServiceReferenceOrUow instanceof ServiceComposite ) - { - ServiceComposite composite = (ServiceComposite) compositeOrServiceReferenceOrUow; - InvocationHandler handler = getInvocationHandler( composite ); - if( handler instanceof ServiceInstance ) - { - return ( (ServiceInstance) handler ).module(); - } - return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).module(); - } - else if( compositeOrServiceReferenceOrUow instanceof UnitOfWork ) - { - ModuleUnitOfWork unitOfWork = (ModuleUnitOfWork) compositeOrServiceReferenceOrUow; - return unitOfWork.module(); - } - else if( compositeOrServiceReferenceOrUow instanceof ServiceReferenceInstance ) - { - ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow; - return reference.module(); - } - else if( compositeOrServiceReferenceOrUow instanceof ImportedServiceReferenceInstance ) - { - ImportedServiceReferenceInstance<?> importedServiceReference - = (ImportedServiceReferenceInstance<?>) compositeOrServiceReferenceOrUow; - return importedServiceReference.module(); - } - throw new IllegalArgumentException( "Wrong type. Must be one of " - + Arrays.asList( TransientComposite.class, ValueComposite.class, - ServiceComposite.class, ServiceReference.class, - UnitOfWork.class ) ); - } - - @Override - public ModelDescriptor modelDescriptorFor( Object compositeOrServiceReference ) - { - if( compositeOrServiceReference instanceof TransientComposite ) - { - TransientComposite composite = (TransientComposite) compositeOrServiceReference; - return TransientInstance.compositeInstanceOf( composite ).descriptor(); - } - else if( compositeOrServiceReference instanceof EntityComposite ) - { - EntityComposite composite = (EntityComposite) compositeOrServiceReference; - return EntityInstance.entityInstanceOf( composite ).descriptor(); - } - else if( compositeOrServiceReference instanceof ValueComposite ) - { - ValueComposite composite = (ValueComposite) compositeOrServiceReference; - return ValueInstance.valueInstanceOf( composite ).descriptor(); - } - else if( compositeOrServiceReference instanceof ServiceComposite ) - { - ServiceComposite composite = (ServiceComposite) compositeOrServiceReference; - InvocationHandler handler = getInvocationHandler( composite ); - if( handler instanceof ServiceInstance ) - { - return ( (ServiceInstance) handler ).descriptor(); - } - return ( (ServiceReferenceInstance.ServiceInvocationHandler) handler ).descriptor(); - } - else if( compositeOrServiceReference instanceof ServiceReferenceInstance ) - { - ServiceReferenceInstance<?> reference = (ServiceReferenceInstance<?>) compositeOrServiceReference; - return reference.serviceDescriptor(); - } - else if( compositeOrServiceReference instanceof ImportedServiceReferenceInstance ) - { - ImportedServiceReferenceInstance<?> importedServiceReference - = (ImportedServiceReferenceInstance<?>) compositeOrServiceReference; - return importedServiceReference.serviceDescriptor(); - } - throw new IllegalArgumentException( "Wrong type. Must be one of " - + Arrays.asList( TransientComposite.class, ValueComposite.class, - ServiceComposite.class, ServiceReference.class ) ); - } - - @Override - public CompositeDescriptor compositeDescriptorFor( Object compositeOrServiceReference ) - { - return (CompositeDescriptor) modelDescriptorFor( compositeOrServiceReference ); - } - - // Descriptors - - @Override - public TransientDescriptor transientDescriptorFor( Object transsient ) - { - if( transsient instanceof TransientComposite ) - { - TransientInstance transientInstance = compositeInstanceOf( (Composite) transsient ); - return (TransientDescriptor) transientInstance.descriptor(); - } - throw new IllegalArgumentException( "Wrong type. Must be subtype of " + TransientComposite.class ); - } - - @Override - public StateHolder stateOf( TransientComposite composite ) - { - return TransientInstance.compositeInstanceOf( composite ).state(); - } - - @Override - public EntityDescriptor entityDescriptorFor( Object entity ) - { - if( entity instanceof EntityComposite ) - { - EntityInstance entityInstance = (EntityInstance) getInvocationHandler( entity ); - return entityInstance.entityModel(); - } - throw new IllegalArgumentException( "Wrong type. Must be subtype of " + EntityComposite.class ); - } - - @Override - public AssociationStateHolder stateOf( EntityComposite composite ) - { - return EntityInstance.entityInstanceOf( composite ).state(); - } - - @Override - public ValueDescriptor valueDescriptorFor( Object value ) - { - if( value instanceof ValueComposite ) - { - ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) value ); - return valueInstance.descriptor(); - } - throw new IllegalArgumentException( "Wrong type. Must be subtype of " + ValueComposite.class ); - } - - @Override - public AssociationStateHolder stateOf( ValueComposite composite ) - { - return ValueInstance.valueInstanceOf( composite ).state(); - } - - @Override - public ServiceDescriptor serviceDescriptorFor( Object service ) - { - if( service instanceof ServiceReferenceInstance ) - { - ServiceReferenceInstance<?> ref = (ServiceReferenceInstance<?>) service; - return ref.serviceDescriptor(); - } - if( service instanceof ServiceComposite ) - { - ServiceComposite composite = (ServiceComposite) service; - return (ServiceDescriptor) ServiceInstance.serviceInstanceOf( composite ).descriptor(); - } - throw new IllegalArgumentException( "Wrong type. Must be subtype of " - + ServiceComposite.class + " or " + ServiceReference.class ); - } - - @Override - public PropertyDescriptor propertyDescriptorFor( Property<?> property ) - { - while( property instanceof PropertyWrapper ) - { - property = ( (PropertyWrapper) property ).next(); - } - - return (PropertyDescriptor) ( (PropertyInstance<?>) property ).propertyInfo(); - } - - @Override - public AssociationDescriptor associationDescriptorFor( AbstractAssociation association ) - { - while( association instanceof AssociationWrapper ) - { - association = ( (AssociationWrapper) association ).next(); - } - - while( association instanceof ManyAssociationWrapper ) - { - association = ( (ManyAssociationWrapper) association ).next(); - } - - while( association instanceof NamedAssociationWrapper ) - { - association = ( (NamedAssociationWrapper) association ).next(); - } - - return (AssociationDescriptor) ( (AbstractAssociationInstance) association ).associationInfo(); - } - - // SPI - @Override - public EntityState entityStateOf( EntityComposite composite ) - { - return EntityInstance.entityInstanceOf( composite ).entityState(); - } - - @Override - public EntityReference entityReferenceOf( Association<?> assoc ) - { - return assoc.reference(); - } - - @Override - public Stream<EntityReference> entityReferencesOf( ManyAssociation<?> assoc ) - { - return assoc.references(); - } - - @Override - public Stream<Map.Entry<String, EntityReference>> entityReferencesOf( NamedAssociation<?> assoc ) - { - return assoc.references(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/api/common/OptionalTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/OptionalTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/OptionalTest.java index 5fc0c31..6a43690 100644 --- a/core/runtime/src/test/java/org/apache/polygene/api/common/OptionalTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/api/common/OptionalTest.java @@ -20,6 +20,7 @@ package org.apache.polygene.api.common; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.association.Association; import org.apache.polygene.api.composite.TransientBuilder; @@ -32,7 +33,6 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import static org.hamcrest.CoreMatchers.notNullValue; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyErrorTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyErrorTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyErrorTest.java index 1f85ae5..97aba67 100644 --- a/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyErrorTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyErrorTest.java @@ -20,6 +20,7 @@ package org.apache.polygene.api.common; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.constraint.ConstraintViolationException; import org.apache.polygene.api.entity.EntityComposite; @@ -27,7 +28,6 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyTypeTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyTypeTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyTypeTest.java index b200422..4f33076 100644 --- a/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyTypeTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/api/common/PropertyTypeTest.java @@ -22,6 +22,7 @@ package org.apache.polygene.api.common; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.composite.TransientBuilder; import org.apache.polygene.api.composite.TransientComposite; @@ -34,7 +35,6 @@ import org.apache.polygene.api.property.Property; import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; /** http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/api/common/ValueCompositeTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/ValueCompositeTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/ValueCompositeTest.java index ef90cea..0a6d1d3 100644 --- a/core/runtime/src/test/java/org/apache/polygene/api/common/ValueCompositeTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/api/common/ValueCompositeTest.java @@ -21,6 +21,7 @@ package org.apache.polygene.api.common; import java.util.List; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Assert; import org.junit.Test; import org.apache.polygene.api.constraint.ConstraintViolationException; @@ -33,7 +34,6 @@ import org.apache.polygene.api.value.ValueBuilder; import org.apache.polygene.api.value.ValueComposite; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import static org.hamcrest.CoreMatchers.equalTo; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/regression/qi230/Qi230IssueTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi230/Qi230IssueTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi230/Qi230IssueTest.java index f2130b4..271147f 100644 --- a/core/runtime/src/test/java/org/apache/polygene/regression/qi230/Qi230IssueTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi230/Qi230IssueTest.java @@ -20,6 +20,7 @@ package org.apache.polygene.regression.qi230; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.PolygeneAPI; import org.apache.polygene.api.composite.Composite; @@ -33,7 +34,6 @@ import org.apache.polygene.api.mixin.NoopMixin; import org.apache.polygene.api.service.ServiceComposite; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import static org.junit.Assert.assertEquals; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java index fd6813d..f766590 100644 --- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java @@ -21,6 +21,7 @@ package org.apache.polygene.regression.qi377; import org.apache.polygene.api.identity.HasIdentity; import org.apache.polygene.api.identity.Identity; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.association.Association; import org.apache.polygene.api.association.ManyAssociation; @@ -30,7 +31,6 @@ import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import static org.hamcrest.core.IsEqual.equalTo; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java index c174c58..a44f20a 100644 --- a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java +++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java @@ -20,6 +20,7 @@ package org.apache.polygene.regression.qi383; import org.apache.polygene.api.identity.StringIdentity; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.entity.EntityComposite; import org.apache.polygene.api.unitofwork.EntityCompositeAlreadyExistsException; @@ -29,7 +30,6 @@ import org.apache.polygene.api.value.ValueSerialization; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.entitystore.memory.MemoryEntityStoreService; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationService; public class Qi383Test extends AbstractPolygeneTest http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/regression/qi59/IssueTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi59/IssueTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi59/IssueTest.java index 9790b01..37f0dff 100644 --- a/core/runtime/src/test/java/org/apache/polygene/regression/qi59/IssueTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi59/IssueTest.java @@ -20,6 +20,7 @@ package org.apache.polygene.regression.qi59; +import org.apache.polygene.test.AbstractPolygeneTest; import org.junit.Test; import org.apache.polygene.api.entity.EntityComposite; import org.apache.polygene.api.property.Property; @@ -27,7 +28,6 @@ import org.apache.polygene.api.unitofwork.UnitOfWork; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.constraints.annotation.NotEmpty; -import org.apache.polygene.test.AbstractPolygeneTest; import org.apache.polygene.test.EntityTestAssembler; import static org.junit.Assert.fail; http://git-wip-us.apache.org/repos/asf/zest-java/blob/b02063bd/core/runtime/src/test/java/org/apache/polygene/runtime/PolygeneAPITest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/PolygeneAPITest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/PolygeneAPITest.java new file mode 100644 index 0000000..24419d6 --- /dev/null +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/PolygeneAPITest.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.runtime; + +import org.junit.Test; +import org.apache.polygene.api.composite.TransientComposite; +import org.apache.polygene.api.entity.EntityComposite; +import org.apache.polygene.api.service.ServiceComposite; +import org.apache.polygene.api.unitofwork.UnitOfWork; +import org.apache.polygene.api.value.ValueComposite; +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.apache.polygene.test.EntityTestAssembler; + +/** + * JAVADOC + */ +public class PolygeneAPITest + extends AbstractPolygeneTest +{ + public void assemble( ModuleAssembly module ) + throws AssemblyException + { + new EntityTestAssembler().assemble( module ); + module.transients( TestTransient.class ); + module.entities( TestEntity.class ); + module.values( TestValue.class ); + module.services( TestService.class ); + } + + @Test + public void testGetModuleOfComposite() + throws Exception + { + UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); + TestEntity testEntity = unitOfWork.newEntity( TestEntity.class ); + + api.moduleOf( testEntity ); + + unitOfWork.discard(); + + api.moduleOf( valueBuilderFactory.newValue( TestValue.class ) ); + + api.moduleOf( transientBuilderFactory.newTransient( TestTransient.class ) ); + + api.moduleOf( serviceFinder.findService( TestService.class ).get() ); + } + + public interface TestTransient + extends TransientComposite + { + } + + public interface TestEntity + extends EntityComposite + { + } + + public interface TestValue + extends ValueComposite + { + } + + public interface TestService + extends ServiceComposite + { + } +} \ No newline at end of file
