You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/12/17 10:28:23 UTC
[47/81] [abbrv] [partial] zest-java git commit: ZEST-195 ;
Replace all "zest" with "polygene"
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/release/CheckReleaseSpecTask.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/CheckReleaseSpecTask.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/release/CheckReleaseSpecTask.groovy
deleted file mode 100644
index 72eb41d..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/CheckReleaseSpecTask.groovy
+++ /dev/null
@@ -1,75 +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.gradle.release
-
-import groovy.transform.CompileStatic
-import org.gradle.api.DefaultTask
-import org.gradle.api.GradleException
-import org.gradle.api.Project
-import org.gradle.api.artifacts.ProjectDependency
-import org.gradle.api.tasks.TaskAction
-
-@CompileStatic
-class CheckReleaseSpecTask extends DefaultTask
-{
- CheckReleaseSpecTask()
- {
- description = 'Ensure that no releasable module depend on module(s) that don\'t fit the release criteria.'
- doFirst {
- def approvedProjects = project.extensions.getByType( ReleaseSpecExtension ).approvedProjects
- dependsOn approvedProjects.collect { each -> each.configurations.getByName( 'runtime' ) }
- }
- }
-
- @TaskAction
- void check()
- {
- Map<Project, Set<ProjectDependency>> notReleasable = [ : ]
- def approvedProjects = project.extensions.getByType( ReleaseSpecExtension ).approvedProjects
- approvedProjects.each { approvedProject ->
- def projectDependencies = approvedProject.configurations.getByName( 'runtime' ).allDependencies.findAll {
- it instanceof ProjectDependency
- } as Set<ProjectDependency>
- projectDependencies.each { dep ->
- def depNotReleaseApproved = approvedProjects.findAll { rp ->
- rp.group == dep.dependencyProject.group && rp.name == dep.dependencyProject.name
- }.isEmpty()
- if( depNotReleaseApproved )
- {
- if( !notReleasable[ approvedProject ] )
- {
- notReleasable[ approvedProject ] = [ ] as Set
- }
- notReleasable[ approvedProject ] << dep
- }
- }
- }
- if( !notReleasable.isEmpty() )
- {
- def errorMessage = new StringBuilder()
- errorMessage << "At least one releasable module depends on module(s) that don't fit the release criteria!\n"
- errorMessage << "\tOffending module -> Non releasable dependencies\n"
- notReleasable.each { k, v ->
- def noRlsDeps = v.collect { d -> ':' + d.dependencyProject.group + ':' + d.dependencyProject.name }
- errorMessage << "\t$k -> ${ noRlsDeps })\n"
- }
- errorMessage << "Check the dev-status.xml file content in each modules directory."
- throw new GradleException( errorMessage.toString() )
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ModuleReleaseSpec.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ModuleReleaseSpec.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ModuleReleaseSpec.groovy
deleted file mode 100644
index 0d81bac..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ModuleReleaseSpec.groovy
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.gradle.release;
-
-import org.gradle.api.Project
-
-class ModuleReleaseSpec
-{
- def boolean satisfiedBy( Project project )
- {
- def devStatusFile = new File( project.projectDir, "dev-status.xml" )
- if( !devStatusFile.exists() )
- {
- return false
- }
- def module = new XmlSlurper().parse( devStatusFile )
- def codebase = module.status.codebase.text()
- def docs = module.status.documentation.text()
- def tests = module.status.unittests.text()
- def satisfied = ( codebase == 'none' && docs == 'complete' && tests != 'complete' )
- satisfied |= ( codebase == 'early' && ( docs == 'complete' || docs == 'good') && (tests == 'complete' || tests == 'good' ) )
- satisfied |= ( codebase == 'beta' && (docs == 'complete' || docs == 'good' || docs == 'brief') && (tests == 'complete' || tests == 'good' || tests == 'some') )
- satisfied |= ( codebase == 'stable' )
- satisfied |= ( codebase == 'mature' )
- // TODO Add a task to report this easily
- // println "$project.name($satisfied) -> $codebase, $docs, $tests"
- return satisfied
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseApprovedProjectsTask.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseApprovedProjectsTask.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseApprovedProjectsTask.groovy
deleted file mode 100644
index 3fe168e..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseApprovedProjectsTask.groovy
+++ /dev/null
@@ -1,57 +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.gradle.release
-
-import groovy.json.JsonBuilder
-import groovy.transform.CompileStatic
-import org.gradle.api.DefaultTask
-import org.gradle.api.file.FileCollection
-import org.gradle.api.tasks.InputFiles
-import org.gradle.api.tasks.OutputFile
-import org.gradle.api.tasks.TaskAction
-
-/**
- * Write paths of release approved projects to a JSON file.
- *
- * This task sole purpose is proper up-do-date behaviour when changing {@literal dev-status.xml} files.
- */
-@CompileStatic
-class ReleaseApprovedProjectsTask extends DefaultTask
-{
- @InputFiles
- FileCollection getDevStatusFiles()
- {
- return project.files( project.allprojects
- .collect( { project -> project.file( 'dev-status.xml' ) } )
- .findAll( { it.exists() } ) )
- }
-
- @OutputFile
- File getJsonApprovedProjects()
- {
- return new File( new File( project.buildDir, 'release' ), 'approved-projects.json' )
- }
-
- @TaskAction
- void approveProjects()
- {
- def releaseSpec = project.extensions.getByType( ReleaseSpecExtension )
- jsonApprovedProjects.parentFile.mkdirs()
- jsonApprovedProjects.text = new JsonBuilder( releaseSpec.approvedProjects.collect( { it.path } ) ).toPrettyString()
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecExtension.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecExtension.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecExtension.groovy
deleted file mode 100644
index 4ca5813..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecExtension.groovy
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.gradle.release
-
-import groovy.transform.CompileStatic
-import org.gradle.api.Project
-
-/**
- * Provide release approved projects.
- *
- * There's no up-to-date checking on Gradle extensions.
- * Depend on {@link ReleaseApprovedProjectsTask} to get a good up-to-date behavior.
- */
-@CompileStatic
-class ReleaseSpecExtension
-{
- static final String NAME = 'releaseSpec'
- Set<Project> approvedProjects
-
- ReleaseSpecExtension( Project rootProject )
- {
- def spec = new ModuleReleaseSpec()
- approvedProjects = rootProject.allprojects.findAll( { p -> spec.satisfiedBy( p ) } )
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecPlugin.groovy
deleted file mode 100644
index 55eac67..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/release/ReleaseSpecPlugin.groovy
+++ /dev/null
@@ -1,56 +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.gradle.release
-
-import groovy.transform.CompileStatic
-import org.apache.zest.gradle.TaskGroups
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.api.Task
-
-@CompileStatic
-class ReleaseSpecPlugin implements Plugin<Project>
-{
- static class TaskNames
- {
- static final String RELEASE_APPROVED_PROJECTS = 'releaseSpecApprovedProjects'
- static final String CHECK_RELEASE_SPEC = 'checkReleaseSpec'
- }
-
- @Override
- void apply( final Project project )
- {
- if( project != project.rootProject )
- {
- throw new IllegalStateException( "This plugin is only applicable to the root project" )
- }
- applyReleaseSpec( project )
- }
-
- private static void applyReleaseSpec( Project project )
- {
- project.extensions.create( ReleaseSpecExtension.NAME, ReleaseSpecExtension, project.rootProject )
- project.tasks.create( TaskNames.RELEASE_APPROVED_PROJECTS, ReleaseApprovedProjectsTask ) { Task task ->
- task.group = TaskGroups.RELEASE
- task.description = 'Apply release specification to projects in the build'
- }
- project.tasks.create( TaskNames.CHECK_RELEASE_SPEC, CheckReleaseSpecTask ) { Task task ->
- task.group = TaskGroups.RELEASE_VERIFICATION
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
deleted file mode 100644
index 30075cf..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/tasks/ExecLogged.groovy
+++ /dev/null
@@ -1,117 +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.gradle.tasks
-
-import groovy.transform.CompileStatic
-import org.gradle.api.Action
-import org.gradle.api.GradleException
-import org.gradle.api.Project
-import org.gradle.api.tasks.AbstractExecTask
-import org.gradle.api.tasks.OutputFile
-import org.gradle.api.tasks.TaskAction
-import org.gradle.internal.logging.ConsoleRenderer
-import org.gradle.process.ExecSpec
-
-@CompileStatic
-class ExecLogged extends AbstractExecTask<ExecLogged>
-{
- @OutputFile
- File stdoutFile = project.file( "$project.buildDir/tmp/${ getName() }/stdout.log" )
-
- @OutputFile
- File stderrFile = project.file( "$project.buildDir/tmp/${ getName() }/stderr.log" )
-
- ExecLogged()
- {
- super( ExecLogged.class )
- }
-
- @TaskAction
- protected void exec()
- {
- [ stdoutFile, stderrFile ].each { it.parentFile.mkdirs() }
- def outStream = stdoutFile.newOutputStream()
- def errStream = stderrFile.newOutputStream()
- try
- {
- super.exec()
- }
- catch( Exception ex )
- {
- throw new GradleException( errorMessage( ex, stdoutFile, stderrFile ), ex )
- }
- finally
- {
- close outStream, errStream
- }
- }
-
- static void execLogged( Project project, File stdoutFile, File stderrFile, Action<? super ExecSpec> specAction )
- {
- [ stdoutFile, stderrFile ].each { it.parentFile.mkdirs() }
- def outStream = stdoutFile.newOutputStream()
- def errStream = stderrFile.newOutputStream()
- try
- {
- project.exec { ExecSpec spec ->
- specAction.execute( spec )
- spec.standardOutput = outStream
- spec.errorOutput = errStream
- }
- }
- catch( Exception ex )
- {
- throw new GradleException( errorMessage( ex, stdoutFile, stderrFile ), ex )
- }
- finally
- {
- close outStream, errStream
- }
- }
-
- private static void close( Closeable... closeables )
- throws IOException
- {
- def errors = [ ] as List<IOException>
- for( Closeable closeable : closeables )
- {
- try
- {
- closeable.close()
- }
- catch( IOException ex )
- {
- errors.add( ex )
- }
- }
- if( !errors.empty )
- {
- def ex = new IOException( 'Failed to close some' )
- errors.each { ex.addSuppressed it }
- throw ex
- }
- }
-
- private static String errorMessage( Exception ex, File stdoutFile, File stderrFile )
- {
- def consoleRenderer = new ConsoleRenderer()
- return "${ ex.message }\n" +
- "\tSTDOUT ${ consoleRenderer.asClickableFileUrl( stdoutFile ) }\n" +
- "\tSTDERR ${ consoleRenderer.asClickableFileUrl( stderrFile ) }"
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/test/AggregatedJacocoReportTask.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/test/AggregatedJacocoReportTask.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/test/AggregatedJacocoReportTask.groovy
deleted file mode 100644
index 40c2278..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/test/AggregatedJacocoReportTask.groovy
+++ /dev/null
@@ -1,91 +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.gradle.test
-
-import org.gradle.api.DefaultTask
-import org.gradle.api.Project
-import org.gradle.api.file.FileCollection
-import org.gradle.api.tasks.InputFiles
-import org.gradle.api.tasks.OutputDirectory
-import org.gradle.api.tasks.TaskAction
-
-class AggregatedJacocoReportTask extends DefaultTask
-{
- @InputFiles
- FileCollection getJacocoExecDataDirectories()
- {
- return project.files( project.subprojects.collect( { Project p -> "${ p.buildDir.path }/jacoco" } ) )
- }
-
- @OutputDirectory
- File getOutputDirectory()
- {
- return project.file( "$project.buildDir/reports/coverage" )
- }
-
- @TaskAction
- void report()
- {
- def coveredProjects = project.subprojects.findAll { p -> new File( "${ p.buildDir.path }/jacoco" ).exists() }
- def coreProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.core' ) }
- def libProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.lib' ) }
- def extProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.ext' ) }
- def toolsProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tool' ) }
- def tutoProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tuto' ) }
- def samplesProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.sample' ) }
- def classpath = project.configurations.getByName( 'jacoco' ).asPath
- project.ant {
- taskdef name: 'jacocoreport', classname: 'org.jacoco.ant.ReportTask', classpath: classpath
- mkdir dir: outputDirectory
- jacocoreport {
- executiondata {
- coveredProjects.collect { p -> fileset( dir: "${ p.buildDir.path }/jacoco" ) { include( name: '*.exec' ) } }
- }
- structure( name: "Apache Polygene\u2122 (Java Edition) SDK" ) {
- group( name: "Core" ) {
- classfiles { coreProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { coreProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- group( name: "Libraries" ) {
- classfiles { libProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { libProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- group( name: "Extensions" ) {
- classfiles { extProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { extProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- group( name: "Tools" ) {
- classfiles { toolsProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { toolsProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- group( name: "Tutorials" ) {
- classfiles { tutoProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { tutoProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- group( name: "Samples" ) {
- classfiles { samplesProjects.collect { p -> fileset dir: "${ p.buildDir.path }/classes/main" } }
- sourcefiles { samplesProjects.collect { p -> fileset dir: "${ p.projectDir.path }/src/main/java" } }
- }
- }
- csv destfile: "${ outputDirectory }/jacoco.csv", encoding: "UTF-8"
- xml destfile: "${ outputDirectory }/jacoco.xml", encoding: "UTF-8"
- html destdir: outputDirectory, encoding: "UTF-8", locale: "en", footer: "Apache Polygene\u2122 (Java Edition) SDK"
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/version/VersionClassPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/version/VersionClassPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/version/VersionClassPlugin.groovy
deleted file mode 100644
index a78f588..0000000
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/version/VersionClassPlugin.groovy
+++ /dev/null
@@ -1,98 +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.gradle.version
-
-import groovy.transform.CompileStatic
-import org.gradle.api.Project
-import org.gradle.api.Plugin
-import org.gradle.api.Task
-import org.gradle.api.file.SourceDirectorySet
-import org.gradle.api.plugins.JavaPlugin
-import org.gradle.api.plugins.JavaPluginConvention
-import org.gradle.api.tasks.SourceSet
-import org.gradle.api.tasks.bundling.Jar
-
-// TODO:release:perf Placeholder for date for dev versions
-// TODO:release:perf Add git data, placeholders for dev versions
-@CompileStatic
-class VersionClassPlugin implements Plugin<Project>
-{
- def void apply( Project project )
- {
- project.getPlugins().apply( JavaPlugin.class )
- def genSrc = 'generated-src/version'
- def generatedSrcDir = new File( project.buildDir, genSrc )
-
- Task makeVersionClassTask = project.task( 'makeVersionClass' )
- makeVersionClassTask.doLast {
- def now = new Date()
- def tmpGroup = project.name
- if( tmpGroup.startsWith( "org.apache.zest.core" ) )
- {
- tmpGroup = tmpGroup - ".core"
- }
- tmpGroup = tmpGroup.replace( '-', '_' )
- def outFilename = "java/" + tmpGroup.replace( '.', '/' ) + "/BuildVersion.java"
- def outFile = new File( generatedSrcDir, outFilename )
- outFile.getParentFile().mkdirs()
- def f = new FileWriter( outFile )
- f.write( 'package ' + tmpGroup + ';\n' )
- f.write( """
-/**
- * Simple class for storing the version derived from the build system.
- *
- */
-public interface BuildVersion
-{
- /** The version of the project from the gradle build.gradle file. */
- String VERSION = \"""" + project.version + """\";
-
- /** The name of the project from the gradle build.gradle file. */
- String NAME = \"""" + project.name + """\";
-
- /** The group of the project from the gradle build.gradle file. */
- String GROUP = \"""" + project.group + """\";
-
- /** The date this file was generated, usually the last date that the project was modified. */
- String DATE = \"""" + now + """\";
-
- /** The full details of the version, including the build date. */
- String DETAILED_VERSION = GROUP + ":" + NAME + ":" + VERSION + " " + DATE;
-}\n
-""" )
- f.close()
- }
- def sourceSets = project.convention.getPlugin( JavaPluginConvention ).sourceSets
- sourceSets.create( "version" ) { SourceSet sourceSet ->
- sourceSet.java { SourceDirectorySet dirSet ->
- dirSet.srcDir project.buildDir.name + '/' + genSrc + '/java'
- }
- }
- makeVersionClassTask.getInputs().files( sourceSets.getByName( 'main' ).allSource )
- makeVersionClassTask.getOutputs().file( generatedSrcDir )
- if( project.getBuildFile() != null && project.getBuildFile().exists() )
- {
- makeVersionClassTask.getInputs().files( project.getBuildFile() )
- }
- project.getTasks().getByName( 'compileJava' ).dependsOn( 'compileVersionJava' )
- project.getTasks().getByName( 'compileVersionJava' ).dependsOn( 'makeVersionClass' )
- project.getTasks().getByName( 'jar' ) { Jar task ->
- task.from sourceSets.getByName( 'version' ).output
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/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
new file mode 100644
index 0000000..ae03999
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/ZestAPI.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/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/Activation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/Activation.java b/core/api/src/main/java/org/apache/polygene/api/activation/Activation.java
new file mode 100644
index 0000000..3b03d82
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/Activation.java
@@ -0,0 +1,60 @@
+/*
+ * 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.activation;
+
+/**
+ * Interface used by Structure elements and Services that can be activated and passivated.
+ * <p>Application and Layer expose this interface so you can activate and passivate them.</p>
+ * <p>Module and ServiceComposite activation/passivation is handled by the Polygene runtime.</p>
+ */
+@SuppressWarnings("JavaDoc")
+public interface Activation
+{
+ /**
+ * Activate.
+ * <p>Fail fast execution order is:</p>
+ * <ul>
+ * <li>Fire {@link ActivationEvent.EventType#ACTIVATING}</li>
+ * <li>Call {@link Activator#beforeActivation(java.lang.Object)} on each Activator</li>
+ * <li>Call {@link #activate()} children</li>
+ * <li>Call {@link Activator#afterActivation(java.lang.Object)} on each Activator</li>
+ * <li>Fire {@link ActivationEvent.EventType#ACTIVATED}</li>
+ * </ul>
+ * <p>If an Exception is thrown, already activated nodes are passivated.</p>
+ * @throws ActivationException with first Exception of activation plus the PassivationException if any
+ */
+ void activate()
+ throws ActivationException;
+
+ /**
+ * Passivate.
+ * <p>Fail safe execution order is:</p>
+ * <ul>
+ * <li>Fire {@link ActivationEvent.EventType#PASSIVATING}</li>
+ * <li>Call {@link Activator#beforePassivation(java.lang.Object)} on each Activator</li>
+ * <li>Call {@link #passivate()} children</li>
+ * <li>Call {@link Activator#afterPassivation(java.lang.Object)} on each Activator</li>
+ * <li>Fire {@link ActivationEvent.EventType#PASSIVATED}</li>
+ * </ul>
+ * @throws PassivationException after passivation with all Exceptions of passivation if any
+ */
+ void passivate()
+ throws PassivationException;
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEvent.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEvent.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEvent.java
new file mode 100644
index 0000000..f40488f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEvent.java
@@ -0,0 +1,99 @@
+/*
+ * 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.activation;
+
+import java.time.Instant;
+import org.apache.polygene.api.time.SystemTime;
+
+/**
+ * ActivationEvents are fired during activation and passivation of instances in Polygene.
+ */
+public final class ActivationEvent
+{
+ public enum EventType
+ {
+ ACTIVATING, ACTIVATED, PASSIVATING, PASSIVATED
+ }
+
+ private final Instant timestamp;
+ private final Object source;
+ private final EventType type;
+
+ public ActivationEvent( Object source, EventType type )
+ {
+ this.timestamp = SystemTime.now();
+ this.source = source;
+ this.type = type;
+ }
+
+ /**
+ * @return the source of the Activation event
+ */
+ public Object source()
+ {
+ return source;
+ }
+
+ /**
+ * @return the type of the Activation event
+ */
+ public EventType type()
+ {
+ return type;
+ }
+
+
+ /**
+ *
+ * @return The instant that this event was created.
+ */
+ public Instant eventTime()
+ {
+ return timestamp;
+ }
+
+ /**
+ * @return an informative message describing the event
+ */
+ public String message()
+ {
+ switch( type )
+ {
+ case ACTIVATING:
+ return "Activating " + source;
+ case ACTIVATED:
+ return "Activated " + source;
+ case PASSIVATING:
+ return "Passivating " + source;
+ case PASSIVATED:
+ return "Passivated " + source;
+ }
+ return "";
+ }
+
+ /**
+ * @see #message()
+ */
+ @Override
+ public String toString()
+ {
+ return message() + "@" + timestamp;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListener.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListener.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListener.java
new file mode 100644
index 0000000..108ebc6
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListener.java
@@ -0,0 +1,29 @@
+/*
+ * 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.activation;
+
+/**
+ * Listener for ActivationEvent events
+ */
+public interface ActivationEventListener
+{
+ void onEvent( ActivationEvent event )
+ throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListenerRegistration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListenerRegistration.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListenerRegistration.java
new file mode 100644
index 0000000..2e7d83a
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationEventListenerRegistration.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.api.activation;
+
+/**
+ * Use this to register listeners for ActivationEvents.
+ *
+ * This is implemented by Application, Layer, Module, for example.
+ */
+public interface ActivationEventListenerRegistration
+{
+ /**
+ * @param listener will be notified when Activation events occur
+ */
+ void registerActivationEventListener( ActivationEventListener listener );
+
+ /**
+ * @param listener will not be notified when Activation events occur anymore
+ */
+ void deregisterActivationEventListener( ActivationEventListener listener );
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivationException.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationException.java
new file mode 100644
index 0000000..cf6d978
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivationException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.activation;
+
+/**
+ * Thrown when unable to activate.
+ */
+public class ActivationException extends Exception
+{
+ private static final long serialVersionUID = 1L;
+ public ActivationException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/Activator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/Activator.java b/core/api/src/main/java/org/apache/polygene/api/activation/Activator.java
new file mode 100644
index 0000000..90a68b5
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/Activator.java
@@ -0,0 +1,72 @@
+/*
+ * 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.activation;
+
+/**
+ * Assemble Activators to hook Services Activation.
+ *
+ * @param <ActivateeType> Type of the activatee.
+ *
+ * @see ActivatorAdapter
+ * @see org.apache.polygene.api.service.ServiceActivation
+ */
+public interface Activator<ActivateeType>
+{
+
+ /**
+ * Called before activatee activation.
+ *
+ * @param activating The instance that is about to be activated.
+ *
+ * @throws Exception Allowed to throw Exception which will be wrapped in an ActivationException
+ */
+ void beforeActivation( ActivateeType activating )
+ throws Exception;
+
+ /**
+ * Called after activatee activation.
+ *
+ * @param activated The instance that has just been activated.
+ *
+ * @throws Exception Allowed to throw Exception which will be wrapped in an ActivationException
+ */
+ void afterActivation( ActivateeType activated )
+ throws Exception;
+
+ /**
+ * Called before activatee passivation.
+ *
+ * @param passivating The instance that is about to be passivated.
+ *
+ * @throws Exception Allowed to throw Exception which will be wrapped in an PassivationException
+ */
+ void beforePassivation( ActivateeType passivating )
+ throws Exception;
+
+ /**
+ * Called after activatee passivation.
+ *
+ * @param passivated The instance that has just been passivated.
+ *
+ * @throws Exception Allowed to throw Exception which will be wrapped in an PassivationException
+ */
+ void afterPassivation( ActivateeType passivated )
+ throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorAdapter.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorAdapter.java
new file mode 100644
index 0000000..208e492
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorAdapter.java
@@ -0,0 +1,70 @@
+/*
+ * 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.activation;
+
+/**
+ * Adapter for Activator.
+ * <p>If you are thinking about Service activation, see {@link org.apache.polygene.api.service.ServiceActivatorAdapter}.</p>
+ *
+ * @param <ActivateeType> Type of the activatee.
+ */
+public class ActivatorAdapter<ActivateeType>
+ implements Activator<ActivateeType>
+{
+ /**
+ * Called before activatee activation.
+ * @param activating Activating activatee
+ */
+ @Override
+ public void beforeActivation( ActivateeType activating )
+ throws Exception
+ {
+ }
+
+ /**
+ * Called after activatee activation.
+ * @param activated Activating activatee
+ */
+ @Override
+ public void afterActivation( ActivateeType activated )
+ throws Exception
+ {
+ }
+
+ /**
+ * Called before activatee passivation.
+ * @param passivating Passivating activatee
+ */
+ @Override
+ public void beforePassivation( ActivateeType passivating )
+ throws Exception
+ {
+ }
+
+ /**
+ * Called after activatee passivation.
+ * @param passivated Passivated activatee
+ */
+ @Override
+ public void afterPassivation( ActivateeType passivated )
+ throws Exception
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorDescriptor.java
new file mode 100644
index 0000000..75b482f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ActivatorDescriptor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.activation;
+
+/**
+ * Activator Descriptor.
+ */
+public interface ActivatorDescriptor
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/Activators.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/Activators.java b/core/api/src/main/java/org/apache/polygene/api/activation/Activators.java
new file mode 100644
index 0000000..912760a
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/Activators.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.activation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used in ServiceComposites to declare Activator implementation classes.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+public @interface Activators
+{
+
+ /**
+ * @return Activator implementation classes.
+ */
+ Class<? extends Activator<?>>[] value();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/ApplicationPassivationThread.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/ApplicationPassivationThread.java b/core/api/src/main/java/org/apache/polygene/api/activation/ApplicationPassivationThread.java
new file mode 100644
index 0000000..7197257
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/ApplicationPassivationThread.java
@@ -0,0 +1,114 @@
+/*
+ * 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.activation;
+
+import java.io.PrintStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.polygene.api.structure.Application;
+
+/**
+ * Application Passivation Thread to use as a Shutdown Hook.
+ * <pre>Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application ) );</pre>
+ */
+public final class ApplicationPassivationThread
+ extends Thread
+{
+ /**
+ * Create a new Application Passivation Thread that output errors to STDERR.
+ * @param application The Application to passivate
+ */
+ @SuppressWarnings("unused")
+ public ApplicationPassivationThread(final Application application )
+ {
+ this( application, null, null );
+ }
+
+ /**
+ * Create a new Application Passivation Thread that output errors to a Logger.
+ * @param application The Application to passivate
+ * @param logger Logger for errors
+ */
+ @SuppressWarnings("unused")
+ public ApplicationPassivationThread(Application application, Logger logger )
+ {
+ this( application, null, logger );
+ }
+
+ /**
+ * Create a new Application Passivation Thread that output errors to a PrintStream.
+ * @param application The Application to passivate
+ * @param output PrintStream for errors
+ */
+ public ApplicationPassivationThread( Application application, PrintStream output )
+ {
+ this( application, output, null );
+ }
+
+ private ApplicationPassivationThread( Application application, PrintStream output, Logger logger )
+ {
+ super( new ApplicationPassivation( application, output, logger ),
+ application.name() + " Passivation Thread" );
+ }
+
+ private static class ApplicationPassivation
+ implements Runnable
+ {
+
+ private final Application application;
+ private final PrintStream output;
+ private final Logger logger;
+
+ private ApplicationPassivation( Application application, PrintStream output, Logger logger )
+ {
+ this.application = application;
+ this.output = output;
+ this.logger = logger;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ application.passivate();
+ }
+ catch( PassivationException ex )
+ {
+ String message = application.name() + " " + ex.getMessage();
+ if( logger != null )
+ {
+ logger.log( Level.SEVERE, message, ex );
+ }
+ else if( output != null )
+ {
+ output.println( message );
+ ex.printStackTrace( output );
+ }
+ else
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/PassivationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/PassivationException.java b/core/api/src/main/java/org/apache/polygene/api/activation/PassivationException.java
new file mode 100644
index 0000000..98eaa0f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/PassivationException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.activation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Thrown when unable to passivate.
+ *
+ * Printed StackTrace contains all causes in order as suppressed exceptions.
+ */
+public final class PassivationException
+ extends Exception
+{
+
+ private static final long serialVersionUID = 1L;
+ private final List<Exception> causes;
+
+ /**
+ * Create new PassivationException.
+ * @param exceptions All exceptions encountered during passivation, in order
+ */
+ public PassivationException( Collection<Exception> exceptions )
+ {
+ super( "Passivation Exception - [has " + exceptions.size() + " cause(s)]" );
+ exceptions.forEach( this::addSuppressed );
+ this.causes = new ArrayList<>( exceptions );
+ }
+
+ /**
+ * @return All exceptions encountered during passivation, in order
+ */
+ public List<Exception> causes()
+ {
+ return causes;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/activation/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/activation/package.html b/core/api/src/main/java/org/apache/polygene/api/activation/package.html
new file mode 100644
index 0000000..c11d85f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/activation/package.html
@@ -0,0 +1,29 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ ~
+ -->
+<html>
+ <body>
+ <h2>Activation API.</h2>
+ <p>
+ The Activation API package contains types used by client code to integrate with the Polygene\u2122 Runtime activation
+ mechanism. In assembly, client code can easily listen to Structure (Application, Layers and Modules) and
+ Services activation events, or, declare Structure and Service Activators.
+ </p>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AbstractAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AbstractAssociation.java b/core/api/src/main/java/org/apache/polygene/api/association/AbstractAssociation.java
new file mode 100644
index 0000000..55ec7d8
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AbstractAssociation.java
@@ -0,0 +1,28 @@
+/*
+ * 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.association;
+
+/**
+ * Base interface for all associations.
+ */
+public interface AbstractAssociation
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/Association.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/Association.java b/core/api/src/main/java/org/apache/polygene/api/association/Association.java
new file mode 100644
index 0000000..5e458ce
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/Association.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.association;
+
+import org.apache.polygene.api.entity.EntityReference;
+
+/**
+ * Association to a single EntityComposite.
+ */
+public interface Association<T> extends AbstractAssociation
+{
+ /**
+ * Get the associated entity.
+ *
+ * @return the associated entity
+ */
+ T get();
+
+ /**
+ * Set the associated entity.
+ *
+ * @param associated the entity
+ *
+ * @throws IllegalArgumentException thrown if the entity is not a valid reference for this association
+ * @throws IllegalStateException thrown if association is immutable
+ */
+ void set( T associated )
+ throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * @return the the reference of the associated entity.
+ */
+ EntityReference reference();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AssociationDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AssociationDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/association/AssociationDescriptor.java
new file mode 100644
index 0000000..e7a1c01
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AssociationDescriptor.java
@@ -0,0 +1,69 @@
+/*
+ * 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.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Type;
+import org.apache.polygene.api.common.QualifiedName;
+import org.apache.polygene.api.structure.MetaInfoHolder;
+
+/**
+ * Association Descriptor.
+ */
+public interface AssociationDescriptor extends MetaInfoHolder
+{
+ /**
+ * Get the qualified name of the association. This is constructed by
+ * concatenating the name of the declaring interface with the name
+ * of the method, using ":" as separator.
+ * <p>
+ * Example:
+ * </p>
+ * <p>
+ * com.somecompany.MyInterface with association method
+ * </p>
+ * <pre><code>
+ * Association<String> someAssociation();
+ * </code></pre>
+ * will have the qualified name:
+ * <pre><code>
+ * com.somecompany.MyInterface:someAssociation
+ * </code></pre>
+ *
+ * @return the qualified name of the association
+ */
+ QualifiedName qualifiedName();
+
+ /**
+ * Get the type of the associated Entities
+ *
+ * @return the type of the associated Entities
+ */
+ Type type();
+
+ boolean isImmutable();
+
+ boolean isAggregated();
+
+ AccessibleObject accessor();
+
+ boolean queryable();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AssociationMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AssociationMixin.java b/core/api/src/main/java/org/apache/polygene/api/association/AssociationMixin.java
new file mode 100644
index 0000000..e26d324
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AssociationMixin.java
@@ -0,0 +1,58 @@
+/*
+ * 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.association;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.apache.polygene.api.common.AppliesTo;
+import org.apache.polygene.api.common.AppliesToFilter;
+import org.apache.polygene.api.injection.scope.State;
+
+/**
+ * Generic mixin for associations.
+ */
+@AppliesTo( { AssociationMixin.AssociationFilter.class } )
+public final class AssociationMixin
+ implements InvocationHandler
+{
+ @State
+ private AssociationStateHolder associations;
+
+ @Override
+ public Object invoke( Object proxy, Method method, Object[] args )
+ throws Throwable
+ {
+ return associations.associationFor( method );
+ }
+
+ /**
+ * Associations generic mixin AppliesToFilter.
+ */
+ static class AssociationFilter
+ implements AppliesToFilter
+ {
+ @Override
+ public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass )
+ {
+ return Association.class.isAssignableFrom( method.getReturnType() );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateDescriptor.java
new file mode 100644
index 0000000..dbee470
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateDescriptor.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.association;
+
+import java.util.stream.Stream;
+import org.apache.polygene.api.common.QualifiedName;
+import org.apache.polygene.api.composite.StateDescriptor;
+
+/**
+ * Associations State Descriptor.
+ */
+public interface AssociationStateDescriptor extends StateDescriptor
+{
+ AssociationDescriptor getAssociationByName( String name )
+ throws IllegalArgumentException;
+
+ AssociationDescriptor getAssociationByQualifiedName( QualifiedName name )
+ throws IllegalArgumentException;
+
+ AssociationDescriptor getManyAssociationByName( String name )
+ throws IllegalArgumentException;
+
+ AssociationDescriptor getManyAssociationByQualifiedName( QualifiedName name )
+ throws IllegalArgumentException;
+
+ AssociationDescriptor getNamedAssociationByName( String name )
+ throws IllegalArgumentException;
+
+ AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
+ throws IllegalArgumentException;
+
+ Stream<? extends AssociationDescriptor> associations();
+
+ Stream<? extends AssociationDescriptor> manyAssociations();
+
+ Stream<? extends AssociationDescriptor> namedAssociations();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateHolder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateHolder.java b/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateHolder.java
new file mode 100644
index 0000000..6b1cf42
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AssociationStateHolder.java
@@ -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.api.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.stream.Stream;
+import org.apache.polygene.api.property.StateHolder;
+
+/**
+ * This represents the state of a entity (properties+associations).
+ */
+public interface AssociationStateHolder
+ extends StateHolder
+{
+ /**
+ * Get an association for a specific accessor method.
+ *
+ * @param associationMethod for the association
+ *
+ * @return the association
+ */
+ <T> Association<T> associationFor( AccessibleObject associationMethod );
+
+ /**
+ * Get all associations.
+ *
+ * @return stream of associations
+ */
+ Stream<? extends Association<?>> allAssociations();
+
+ /**
+ * Get a many-association for a specific accessor method.
+ *
+ * @param manyassociationMethod for the many-association
+ *
+ * @return the association
+ */
+ <T> ManyAssociation<T> manyAssociationFor( AccessibleObject manyassociationMethod );
+
+ /**
+ * Get all ManyAssociations.
+ *
+ * @return stream of many-associations
+ */
+ Stream<? extends ManyAssociation<?>> allManyAssociations();
+
+ /**
+ * Get a named-association for a specific accessor method.
+ *
+ * @param namedassociationMethod for the named-association
+ *
+ * @return the association
+ */
+ <T> NamedAssociation<T> namedAssociationFor( AccessibleObject namedassociationMethod );
+
+ /**
+ * Get all named-associations.
+ *
+ * @return stream of named-associations
+ */
+ Stream<? extends NamedAssociation<?>> allNamedAssociations();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/AssociationWrapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/AssociationWrapper.java b/core/api/src/main/java/org/apache/polygene/api/association/AssociationWrapper.java
new file mode 100644
index 0000000..b41b41f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/AssociationWrapper.java
@@ -0,0 +1,81 @@
+/*
+ * 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.association;
+
+import org.apache.polygene.api.entity.EntityReference;
+
+/**
+ * If you want to catch getting and setting association, then create a GenericConcern
+ * that wraps the Polygene-supplied Association instance with AssociationWrappers. Override
+ * get() and/or set() to perform your custom code.
+ */
+public class AssociationWrapper
+ implements Association<Object>
+{
+ protected Association<Object> next;
+
+ public AssociationWrapper( Association<Object> next )
+ {
+ this.next = next;
+ }
+
+ public Association<Object> next()
+ {
+ return next;
+ }
+
+ @Override
+ public Object get()
+ {
+ return next.get();
+ }
+
+ @Override
+ public void set( Object associated )
+ throws IllegalArgumentException
+ {
+ next.set( associated );
+ }
+
+ @Override
+ public EntityReference reference()
+ {
+ return next.reference();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return next.hashCode();
+ }
+
+ @Override
+ @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+ public boolean equals( Object obj )
+ {
+ return next.equals( obj );
+ }
+
+ @Override
+ public String toString()
+ {
+ return next.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/GenericAssociationInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/GenericAssociationInfo.java b/core/api/src/main/java/org/apache/polygene/api/association/GenericAssociationInfo.java
new file mode 100644
index 0000000..c42f172
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/GenericAssociationInfo.java
@@ -0,0 +1,63 @@
+/*
+ * 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.association;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import static org.apache.polygene.api.util.Classes.typeOf;
+
+/**
+ * Generic Association info.
+ */
+public final class GenericAssociationInfo
+{
+ public static Type associationTypeOf( AccessibleObject accessor )
+ {
+ return toAssociationType( typeOf( accessor ) );
+ }
+
+ public static Type toAssociationType( Type methodReturnType )
+ {
+ if( methodReturnType instanceof ParameterizedType )
+ {
+ ParameterizedType parameterizedType = (ParameterizedType) methodReturnType;
+ if( AbstractAssociation.class.isAssignableFrom( (Class<?>) parameterizedType.getRawType() ) )
+ {
+ return parameterizedType.getActualTypeArguments()[ 0 ];
+ }
+ }
+ if (!(methodReturnType instanceof Class))
+ {
+ throw new IllegalArgumentException( "Unable to make an association with " + methodReturnType );
+ }
+ Type[] interfaces = ((Class<?>) methodReturnType).getGenericInterfaces();
+ for (Type anInterface : interfaces)
+ {
+ Type associationType = toAssociationType(anInterface);
+ if (associationType != null)
+ {
+ return associationType;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
new file mode 100644
index 0000000..a2247b9
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
@@ -0,0 +1,58 @@
+/*
+ * 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.association;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Stream;
+import org.apache.polygene.api.entity.EntityReference;
+
+/**
+ * Association to a collection of entities.
+ */
+public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
+{
+ /**
+ * Returns the number of references in this association.
+ * @return the number of references in this association.
+ */
+ int count();
+
+ boolean contains( T entity );
+
+ boolean add( int i, T entity );
+
+ boolean add( T entity );
+
+ boolean remove( T entity );
+
+ T get( int i );
+
+ List<T> toList();
+
+ Set<T> toSet();
+
+ /**
+ * Returns a stream of the references to the associated entities.
+ * @return the references to the associated entities.
+ */
+ Stream<EntityReference> references();
+}