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:20 UTC
[44/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/core/api/src/main/java/org/apache/polygene/api/configuration/ConfigurationComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/configuration/ConfigurationComposite.java b/core/api/src/main/java/org/apache/polygene/api/configuration/ConfigurationComposite.java
new file mode 100644
index 0000000..726664f
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/configuration/ConfigurationComposite.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.configuration;
+
+import org.apache.polygene.api.composite.Composite;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.entity.Queryable;
+
+/**
+ * Services that want to be configurable should have a ConfigurationComposite that contains all the settings.
+ * They are treated as EntityComposites, and are therefore stored in an EntityStore. There will be one instance
+ * per service instance that uses each ConfigurationComposite, and the reference of the entity is the same as that
+ * of the service.
+ */
+@Queryable( false )
+public interface ConfigurationComposite
+ extends HasIdentity, Composite
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/configuration/Enabled.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/configuration/Enabled.java b/core/api/src/main/java/org/apache/polygene/api/configuration/Enabled.java
new file mode 100644
index 0000000..764ef4e
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/configuration/Enabled.java
@@ -0,0 +1,34 @@
+/*
+ * 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.configuration;
+
+import org.apache.polygene.api.common.UseDefaults;
+import org.apache.polygene.api.property.Property;
+
+/**
+ * Common configuration for setting whether a service is enabled or not. A disabled service
+ * is not considered to be available. Let your own ConfigurationComposite extend this interface to use.
+ */
+public interface Enabled
+{
+ @UseDefaults
+ Property<Boolean> enabled();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/configuration/NoSuchConfigurationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/configuration/NoSuchConfigurationException.java b/core/api/src/main/java/org/apache/polygene/api/configuration/NoSuchConfigurationException.java
new file mode 100644
index 0000000..ed2b3a0
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/configuration/NoSuchConfigurationException.java
@@ -0,0 +1,50 @@
+/*
+ * 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.configuration;
+
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.identity.Identity;
+
+public class NoSuchConfigurationException extends RuntimeException
+{
+ private final Class<? extends HasIdentity> configType;
+ private final Identity identity;
+
+ public NoSuchConfigurationException( Class<? extends HasIdentity> configType,
+ Identity identity,
+ Exception cause
+ )
+ {
+ super( "No configuration found for '" + identity + "' and configuration " + configType.getName() + " has one or more non-Optional properties.", cause );
+ this.configType = configType;
+ this.identity = identity;
+ }
+
+ public Class<? extends HasIdentity> configType()
+ {
+ return configType;
+ }
+
+ public Identity identity()
+ {
+ return identity;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/configuration/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/configuration/package.html b/core/api/src/main/java/org/apache/polygene/api/configuration/package.html
new file mode 100644
index 0000000..b923bc3
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/configuration/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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>Configuration API.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/Constraint.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/Constraint.java b/core/api/src/main/java/org/apache/polygene/api/constraint/Constraint.java
new file mode 100644
index 0000000..603b7e5
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/Constraint.java
@@ -0,0 +1,45 @@
+/*
+ * 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.constraint;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/**
+ * All Constraints must implement this interface, which is used for each
+ * value validation.
+ */
+public interface Constraint<ANNOTATION extends Annotation, TYPE>
+ extends Serializable
+{
+ /**
+ * For each value or parameter which should be checked this method will be invoked.
+ * If the method returns true the value is valid. If it returns false the value
+ * is considered invalid. When all constraints have been checked a ConstraintViolationException
+ * will be thrown with all the constraint violations that were found.
+ *
+ * @param annotation the annotation to match
+ * @param value the value to be checked
+ *
+ * @return true if valid, false if invalid
+ */
+ boolean isValid( ANNOTATION annotation, TYPE value );
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDeclaration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDeclaration.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDeclaration.java
new file mode 100644
index 0000000..36988ee
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDeclaration.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.constraint;
+
+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;
+
+/**
+ * All annotations that are used to trigger Constraints must have this annotation.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.ANNOTATION_TYPE )
+@Documented
+public @interface ConstraintDeclaration
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDescriptor.java
new file mode 100644
index 0000000..9c929ef
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintDescriptor.java
@@ -0,0 +1,31 @@
+/*
+ * 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.constraint;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Constraint Descriptor.
+ */
+public interface ConstraintDescriptor
+{
+ Annotation annotation();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintImplementationNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintImplementationNotFoundException.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintImplementationNotFoundException.java
new file mode 100644
index 0000000..1d42685
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintImplementationNotFoundException.java
@@ -0,0 +1,34 @@
+/*
+ * 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.constraint;
+
+import org.apache.polygene.api.common.InvalidApplicationException;
+
+/**
+ * This exception is thrown if a Constraint implementation can not be found.
+ */
+public class ConstraintImplementationNotFoundException
+ extends InvalidApplicationException
+{
+ public ConstraintImplementationNotFoundException( String message )
+ {
+ super( message );
+ }
+}
\ 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/constraint/ConstraintViolation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.java
new file mode 100644
index 0000000..1236bbf
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolation.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.constraint;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/**
+ * When a constraint violation has occurred (ie Constraint.isValid has returned false) it
+ * is put in a collection of all violations that have occurred for this value check.
+ */
+public final class ConstraintViolation
+ implements Serializable
+{
+ private String name;
+ private final Annotation constraint;
+ private final Object value;
+
+ public ConstraintViolation( String name, Annotation constraint, Object value )
+ {
+ this.name = name;
+ this.constraint = constraint;
+ this.value = value;
+ }
+
+ public String name()
+ {
+ return name;
+ }
+
+ public Annotation constraint()
+ {
+ return constraint;
+ }
+
+ public Object value()
+ {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
new file mode 100644
index 0000000..cc1b1b0
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java
@@ -0,0 +1,261 @@
+/*
+ * 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.constraint;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.polygene.api.composite.Composite;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.util.Classes;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * This Exception is thrown when there is one or more Constraint Violations in a method
+ * call.
+ * <p>
+ * The Constraint Violations are aggregated per method, and this exception will contain those
+ * violations, together with the Composite instance it happened on as well as the Method that
+ * was invoked. The Exception also has support for localized messages of these violations.
+ * </p>
+ */
+public class ConstraintViolationException
+ extends IllegalArgumentException
+{
+ private static final long serialVersionUID = 1L;
+
+ private final Collection<ConstraintViolation> constraintViolations;
+ private String methodName;
+ private String mixinTypeName;
+ private String instanceToString;
+ private List<? extends Type> instanceTypes;
+
+ public ConstraintViolationException( Composite instance, Member method,
+ Collection<ConstraintViolation> constraintViolations
+ )
+ {
+ this( instance.toString(), Classes.interfacesOf( instance.getClass() ), method, constraintViolations );
+ }
+
+ public ConstraintViolationException( String instanceToString,
+ Stream<? extends Type> instanceTypes,
+ Member method,
+ Collection<ConstraintViolation> violations
+ )
+ {
+ this.instanceToString = instanceToString;
+ this.instanceTypes = instanceTypes.collect( Collectors.toList() );
+ mixinTypeName = method.getDeclaringClass().getName();
+ methodName = method.getName();
+ this.constraintViolations = violations;
+ }
+
+ public ConstraintViolationException( Identity identity,
+ List<? extends Type> instanceTypes,
+ String mixinTypeName,
+ String methodName,
+ Collection<ConstraintViolation> violations
+ )
+ {
+ this.instanceToString = identity.toString();
+ this.instanceTypes = instanceTypes;
+ this.mixinTypeName = mixinTypeName;
+ this.methodName = methodName;
+ this.constraintViolations = violations;
+ }
+
+ public Collection<ConstraintViolation> constraintViolations()
+ {
+ return constraintViolations;
+ }
+
+ /**
+ * Creates localized messages of all the constraint violations that has occured.
+ * <p>
+ * The key "<code>polygene.constraint.<i><strong>CompositeType</strong></i>.<i><strong>methodName</strong></i></code>"
+ * will be used to lookup the text formatting
+ * pattern from the ResourceBundle, where <strong><code><i>CompositeType</i></code></strong> is the
+ * class name of the Composite where the constraint was violated. If such key does not exist, then the
+ * key "<code>polygene.constraint</code>" will be used, and if that one also doesn't exist, or
+ * the resourceBundle argument is null, then the default patterns will be used;
+ * </p>
+ * <table summary="Localization of constraint vioations.">
+ * <tr><th>Type of Composite</th><th>Pattern used</th></tr>
+ * <tr><td>Composite</td>
+ * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1}</code></td>
+ * </tr>
+ * <tr><td>EntityComposite</td>
+ * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}]</code></td>
+ * </tr>
+ * <tr><td>ServiceComposite</td>
+ * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in service {0}</code></td>
+ * </tr>
+ * </table>
+ * Then format each ConstraintViolation according to such pattern, where the following argument are passed;
+ * <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr>
+ * <tr>
+ * <td>{0}</td>
+ * <td>Composite instance toString()</td>
+ * </tr>
+ * <tr>
+ * <td>{1}</td>
+ * <td>CompositeType class name</td>
+ * </tr>
+ * <tr>
+ * <td>{2}</td>
+ * <td>MixinType class name</td>
+ * </tr>
+ * <tr>
+ * <td>{3}</td>
+ * <td>MixinType method name</td>
+ * </tr>
+ * <tr>
+ * <td>{4}</td>
+ * <td>Annotation toString()</td>
+ * </tr>
+ * <tr>
+ * <td>{5}</td>
+ * <td>toString() of value passed as the argument, or "null" text if argument was null.</td>
+ * </tr>
+ * </table>
+ * <p>
+ * <b>NOTE!!!</b> This class is still under construction and will be modified further.
+ * </p>
+ *
+ * @param bundle The ResourceBundle for Localization, or null if default formatting and locale to be used.
+ *
+ * @return An array of localized messages of the violations incurred.
+ */
+ public String[] localizedMessagesFrom( ResourceBundle bundle )
+ {
+ String pattern = "Constraint violation in {0}.{1} for method ''{3}'' with constraint \"{4}({6})\", for value ''{5}''";
+
+ ArrayList<String> list = new ArrayList<>();
+ for( ConstraintViolation violation : constraintViolations )
+ {
+ Locale locale;
+ if( bundle != null )
+ {
+ try
+ {
+ pattern = bundle.getString( "polygene.constraint." + mixinTypeName + "." + methodName );
+ }
+ catch( MissingResourceException e1 )
+ {
+ try
+ {
+ pattern = bundle.getString( "polygene.constraint" );
+ }
+ catch( MissingResourceException e2 )
+ {
+ // ignore. The default pattern will be used.
+ }
+ }
+ locale = bundle.getLocale();
+ }
+ else
+ {
+ locale = Locale.getDefault();
+ }
+ MessageFormat format = new MessageFormat( pattern, locale );
+
+ Annotation annotation = violation.constraint();
+ String name = violation.name();
+ Object value = violation.value();
+ String classes;
+ if( instanceTypes.stream().count() == 1 )
+ {
+ Type type = instanceTypes.stream().findFirst().get();
+ classes = Classes.RAW_CLASS.apply( type ).getSimpleName();
+ }
+ else
+ {
+ classes = "[" + instanceTypes.stream()
+ .map( Classes.RAW_CLASS )
+ .map( Class::getSimpleName ).collect( joining( "," ) ) + "]";
+ }
+ Object[] args = new Object[]
+ {
+ instanceToString,
+ classes,
+ mixinTypeName,
+ methodName,
+ annotation.toString(),
+ "" + value,
+ name
+ };
+ StringBuffer text = new StringBuffer();
+ format.format( args, text, null );
+ list.add( text.toString() );
+ }
+ String[] result = new String[ list.size() ];
+ list.toArray( result );
+ return result;
+ }
+
+ public String localizedMessage()
+ {
+ String[] messages = localizedMessagesFrom( null );
+ StringBuilder result = new StringBuilder();
+ boolean first = true;
+ for( String message : messages )
+ {
+ if( !first )
+ {
+ result.append( ',' );
+ }
+ first = false;
+ result.append( message );
+ }
+ return result.toString();
+ }
+
+ @Override
+ public String getLocalizedMessage()
+ {
+ return localizedMessage();
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return localizedMessage();
+ }
+
+ public String methodName()
+ {
+ return methodName;
+ }
+
+ public String mixinTypeName()
+ {
+ return mixinTypeName;
+ }
+}
\ 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/constraint/Constraints.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/Constraints.java b/core/api/src/main/java/org/apache/polygene/api/constraint/Constraints.java
new file mode 100644
index 0000000..e5516a3
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/Constraints.java
@@ -0,0 +1,42 @@
+/*
+ * 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.constraint;
+
+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 by composites and mixins to declare what Constraints
+ * can be applied in the Composite.
+ * <p>
+ * Constraints implement the {@link Constraint} interface
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE } )
+@Documented
+public @interface Constraints
+{
+ Class<? extends Constraint<?, ?>>[] value();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintsDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintsDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintsDescriptor.java
new file mode 100644
index 0000000..8637abe
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintsDescriptor.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.constraint;
+
+/**
+ * Constraints Descriptor.
+ */
+public interface ConstraintsDescriptor
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/constraint/Name.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/Name.java b/core/api/src/main/java/org/apache/polygene/api/constraint/Name.java
new file mode 100644
index 0000000..1ef59c8
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/Name.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.constraint;
+
+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;
+
+/**
+ * Annotation for parameter names. This is used to add extra information for constraint exception.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.PARAMETER } )
+@Documented
+public @interface Name
+{
+ String value();
+}
\ 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/constraint/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/constraint/package.html b/core/api/src/main/java/org/apache/polygene/api/constraint/package.html
new file mode 100644
index 0000000..87e14b7
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/constraint/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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>Constraint API.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/Aggregated.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/Aggregated.java b/core/api/src/main/java/org/apache/polygene/api/entity/Aggregated.java
new file mode 100644
index 0000000..7db81cd
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/Aggregated.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.entity;
+
+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;
+
+/**
+ * Marks an association as aggregating the referenced Entities
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.METHOD } )
+@Documented
+public @interface Aggregated
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilder.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilder.java
new file mode 100644
index 0000000..0fcdeff
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilder.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.entity;
+
+import org.apache.polygene.api.common.ConstructionException;
+
+/**
+ * EntityBuilders are used to instantiate EntityComposites. They can be acquired from
+ * {@link org.apache.polygene.api.unitofwork.UnitOfWork#newEntityBuilder(Class)} and allows the client
+ * to provide additional settings before instantiating the Composite.
+ *
+ * After calling newInstance() the builder becomes invalid, and may not be called again.
+ */
+public interface EntityBuilder<T>
+{
+ /**
+ * Get a representation of the state for the new Composite.
+ * It is possible to access and update properties and associations,
+ * even immutable ones since the builder represents the initial state.
+ *
+ * @return a proxy implementing the Composite type
+ */
+ T instance();
+
+ /**
+ * Get a representation of the state of the given type for the new Composite.
+ * This is primarily used if you want to provide state for a private mixin type.
+ *
+ * @param mixinType the mixin which you want to provide state for
+ *
+ * @return a proxy implementing the given mixin type
+ */
+ <K> K instanceFor( Class<K> mixinType );
+
+ /**
+ * Create a new Entity instance.
+ *
+ * @return a new Entity instance
+ *
+ * @throws org.apache.polygene.api.common.ConstructionException
+ * thrown if it was not possible to instantiate the Composite
+ * @throws LifecycleException if the entity could not be created
+ */
+ T newInstance()
+ throws ConstructionException, LifecycleException;
+}
\ 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/entity/EntityBuilderTemplate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilderTemplate.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilderTemplate.java
new file mode 100644
index 0000000..00daed2
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityBuilderTemplate.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.entity;
+
+import org.apache.polygene.api.structure.Module;
+
+/**
+ * EntityBuilderTemplate.
+ */
+public abstract class EntityBuilderTemplate<T>
+{
+ Class<T> type;
+
+ protected EntityBuilderTemplate( Class<T> type )
+ {
+ this.type = type;
+ }
+
+ protected abstract void build( T prototype );
+
+ public T newInstance( Module module )
+ {
+ EntityBuilder<T> builder = module.unitOfWorkFactory().currentUnitOfWork().newEntityBuilder( type );
+ build( builder.instance() );
+ return builder.newInstance();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/EntityComposite.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityComposite.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityComposite.java
new file mode 100644
index 0000000..4fa9cb9
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityComposite.java
@@ -0,0 +1,36 @@
+/*
+ * 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.entity;
+
+import org.apache.polygene.api.association.AssociationMixin;
+import org.apache.polygene.api.association.ManyAssociationMixin;
+import org.apache.polygene.api.association.NamedAssociationMixin;
+import org.apache.polygene.api.composite.Composite;
+import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.mixin.Mixins;
+
+/**
+ * EntityComposites are Composites that has mutable state persisted in EntityStores and equality defined from its
+ * reference.
+ */
+@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } )
+public interface EntityComposite extends HasIdentity, Composite
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/EntityDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityDescriptor.java
new file mode 100644
index 0000000..1ff6180
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityDescriptor.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.entity;
+
+import org.apache.polygene.api.association.AssociationStateDescriptor;
+import org.apache.polygene.api.composite.CompositeDescriptor;
+import org.apache.polygene.api.composite.StatefulCompositeDescriptor;
+
+/**
+ * Entity Descriptor.
+ */
+public interface EntityDescriptor
+ extends CompositeDescriptor, StatefulCompositeDescriptor
+{
+ @Override
+ AssociationStateDescriptor state();
+
+ boolean queryable();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
new file mode 100644
index 0000000..731d3c3
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
@@ -0,0 +1,123 @@
+/*
+ * 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.entity;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.identity.StringIdentity;
+import org.apache.polygene.api.util.NullArgumentException;
+
+/**
+ * An EntityReference is reference of a specific Entity instance.
+ * <p>When stringified, the reference is used as-is. Example:</p>
+ * <pre>123456-abcde</pre>
+ */
+public final class EntityReference
+ implements Serializable
+{
+ /**
+ * Parse an Entity reference to an EntityReference.
+ *
+ * @param identityString the EntityReference reference
+ * @return the EntityReference represented by the given reference
+ */
+ public static EntityReference parseEntityReference(String identityString)
+ {
+ return new EntityReference( new StringIdentity( identityString ) );
+ }
+
+ /**
+ * @param object an EntityComposite
+ * @return the EntityReference for the given EntityComposite
+ */
+ public static EntityReference entityReferenceFor(Object object)
+ {
+ return new EntityReference(((EntityComposite) object).identity().get());
+ }
+
+ public static EntityReference create(Identity identity)
+ {
+ if (identity == null)
+ {
+ return null;
+ }
+ return new EntityReference(identity);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private Identity identity;
+
+ /**
+ * @param identity reference reference
+ * @throws NullArgumentException if reference is null or empty
+ */
+ private EntityReference( Identity identity )
+ {
+ Objects.requireNonNull(identity,"reference must not be null");
+ this.identity = identity;
+ }
+
+ /**
+ *
+ * @return The reference of the Entity that this EntityReference.is referring to
+ */
+ public final Identity identity()
+ {
+ return identity;
+ }
+
+ /**
+ * @return An URI representation of this EntityReference.
+ */
+ public String toURI()
+ {
+ return "urn:polygene:entity:" + identity;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+ EntityReference that = (EntityReference) o;
+ return identity.equals(that.identity);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return identity.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return identity.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java b/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
new file mode 100644
index 0000000..187ef37
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.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.api.entity;
+
+/**
+ * Lifecycle interface for all Composites.
+ * <p>
+ * This Lifecycle interface is a built-in feature of the Polygene runtime, similar to the Initializable interface.
+ * Any Mixin that implements this interface AND is part of an EntityComposite will have these two methods called
+ * upon creation/removal of the EntityComposite instance to/from the EntityStore. Meaning, the create method is called
+ * only when the identifiable EntityComposite is created the first time, and not when it is read from its persisted
+ * state and created into memory.
+ * </p>
+ * <p>
+ * Example;
+ * </p>
+ * <pre><code>
+ * public interface System
+ * {
+ * Property<User> admin();
+ * }
+ *
+ * public class SystemAdminMixin<LifeCycle>
+ * implements System, Lifecyle, ...
+ * {
+ * @Structure private UnitOfWork uow;
+ * @This private Identity meAsIdentity;
+ *
+ * public void create()
+ * {
+ * String thisId = meAsIdentity.reference().get();
+ * EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class );
+ * User admin = builder.newInstance();
+ * admin.set( admin );
+ * }
+ *
+ * public void remove()
+ * {
+ * uow.remove( admin.get() );
+ * }
+ * }
+ *
+ * @Mixins( SystemAdminMixin.class )
+ * public interface SystemEntity extends System, EntityComposite
+ * {}
+ *
+ * </code></pre>
+ */
+public interface Lifecycle
+{
+ /**
+ * Creation callback method.
+ * <p>
+ * Called by the Polygene runtime before the newInstance of the entity completes, before the constraints are checked,
+ * allowing for additional initialization.
+ * </p>
+ * @throws Exception if the entity could not be created
+ */
+ void create() throws Exception;
+
+ /**
+ * Removal callback method.
+ * <p>
+ * Called by the Polygene runtime before the entity is removed from the system, allowing
+ * for clean-up operations.
+ * </p>
+ * @throws Exception if the entity could not be removed
+ */
+ void remove() throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/entity/LifecycleException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/LifecycleException.java b/core/api/src/main/java/org/apache/polygene/api/entity/LifecycleException.java
new file mode 100644
index 0000000..e0b2580
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/LifecycleException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.api.entity;
+
+/**
+ * Thrown if Lifecycle invocation fails
+ */
+public class LifecycleException
+ extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public LifecycleException()
+ {
+ }
+
+ public LifecycleException( 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/entity/Queryable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/Queryable.java b/core/api/src/main/java/org/apache/polygene/api/entity/Queryable.java
new file mode 100644
index 0000000..4a3f563
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/Queryable.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.entity;
+
+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 to mark entity types or properties/associations that are indexable.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Queryable
+{
+ boolean value() default true;
+}
\ 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/entity/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/package.html b/core/api/src/main/java/org/apache/polygene/api/entity/package.html
new file mode 100644
index 0000000..39a3223
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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>Entity API.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/event/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/event/package.html b/core/api/src/main/java/org/apache/polygene/api/event/package.html
new file mode 100644
index 0000000..4972ae6
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/event/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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>Event API.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
new file mode 100644
index 0000000..4e139d1
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.identity;
+
+import java.lang.reflect.Method;
+import org.apache.polygene.api.common.QualifiedName;
+import org.apache.polygene.api.injection.scope.State;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Immutable;
+import org.apache.polygene.api.property.Property;
+
+/**
+ * This interface provides the identity of the object which may be used
+ * to store the state in a database. It is not the responsibility of the
+ * framework to come up with a good identity string.
+ */
+@Mixins( HasIdentity.HasIdentityMixin.class )
+public interface HasIdentity
+{
+ Method IDENTITY_METHOD = HasIdentityMixin.identityMethod();
+ QualifiedName IDENTITY_STATE_NAME = HasIdentityMixin.stateName();
+
+ @Immutable
+ Property<Identity> identity();
+
+ /**
+ * Default Identity implementation.
+ */
+ class HasIdentityMixin
+ implements HasIdentity
+ {
+ @State
+ private Property<Identity> identity;
+
+
+ @Override
+ public Property<Identity> identity()
+ {
+ return identity;
+ }
+
+ private static QualifiedName stateName()
+ {
+ return QualifiedName.fromAccessor( identityMethod() );
+ }
+
+ private static Method identityMethod()
+ {
+ try
+ {
+ return HasIdentity.class.getMethod( "identity" );
+ }
+ catch( NoSuchMethodException e )
+ {
+ throw new InternalError( "Polygene Core Runtime codebase is corrupted." );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/Identifiable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/Identifiable.java b/core/api/src/main/java/org/apache/polygene/api/identity/Identifiable.java
new file mode 100644
index 0000000..001ce7e
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/Identifiable.java
@@ -0,0 +1,25 @@
+/*
+ * 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.identity;
+
+public interface Identifiable
+{
+ Identity identity();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/Identity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/Identity.java b/core/api/src/main/java/org/apache/polygene/api/identity/Identity.java
new file mode 100644
index 0000000..1db6d6d
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/Identity.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.identity;
+
+/**
+ * Representation of an Identity.
+ * Identity is an opaque, immutable data type.
+ * Identity is a very central concept in any domain model.
+ *
+ */
+public interface Identity
+{
+ String toString();
+
+ byte[] toBytes();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/IdentityGenerator.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/IdentityGenerator.java b/core/api/src/main/java/org/apache/polygene/api/identity/IdentityGenerator.java
new file mode 100644
index 0000000..d407b0e
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/IdentityGenerator.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.identity;
+
+import org.apache.polygene.api.mixin.Mixins;
+
+/**
+ * Generator for identities of EntityComposite's.
+ */
+@Mixins( UuidGeneratorMixin.class )
+public interface IdentityGenerator
+{
+ /**
+ * Generate a new id for the given Composite type
+ *
+ * @param compositeType the type of composite
+ *
+ * @return a new reference
+ */
+ Identity generate( Class<?> compositeType );
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
new file mode 100644
index 0000000..d5c43f9
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
@@ -0,0 +1,86 @@
+/*
+ * 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.identity;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+
+public class StringIdentity
+ implements Identity
+{
+ private final String value;
+
+ public StringIdentity(String value)
+ {
+ Objects.requireNonNull( value, "Identity can not be null." );
+ this.value = value;
+ }
+
+ public StringIdentity(byte[] bytes)
+ {
+ value = new String(bytes, StandardCharsets.UTF_8);
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+ @Override
+ public byte[] toBytes()
+ {
+ return value.getBytes(StandardCharsets.UTF_8);
+ }
+
+ @Override
+ public String toString()
+ {
+ return value;
+ }
+
+ public static Identity fromString(String serializedState)
+ {
+ return new StringIdentity( serializedState );
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ StringIdentity that = (StringIdentity) o;
+
+ return value.equals(that.value);
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
new file mode 100644
index 0000000..0add4c6
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.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.identity;
+
+import java.util.UUID;
+
+public class UuidGeneratorMixin
+ implements IdentityGenerator
+{
+ @Override
+ public Identity generate(Class<?> compositeType)
+ {
+ return StringIdentity.fromString(UUID.randomUUID().toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/injection/InjectionScope.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/InjectionScope.java b/core/api/src/main/java/org/apache/polygene/api/injection/InjectionScope.java
new file mode 100644
index 0000000..cc7b3a4
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/InjectionScope.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.injection;
+
+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 is used to annotate annotation types which are used for injection.
+ * Each scope signifies a particular scope from which the injection value should be taken.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.ANNOTATION_TYPE } )
+@Documented
+public @interface InjectionScope
+{
+}
\ 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/injection/package.html
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/package.html b/core/api/src/main/java/org/apache/polygene/api/injection/package.html
new file mode 100644
index 0000000..155a5e4
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/package.html
@@ -0,0 +1,24 @@
+<!--
+ ~ 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>Dependency Injection API.</h2>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/injection/scope/Invocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/Invocation.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Invocation.java
new file mode 100644
index 0000000..4305532
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Invocation.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.api.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a
+ * invocation specific resource.
+ * These include:
+ * <pre><code>
+ * - The Method being invoked.
+ *
+ * - An AnnotationElement with annotations
+ * from both mixin type, mixin
+ * implementation.
+ *
+ * - An Annotation of a specific type
+ * </code></pre>
+ * Examples:
+ * <pre><code>
+ * @Invocation Method theInvokedMethod
+ * @Invocation AnnotationElement annotations
+ * @Invocation Matches matchesAnnotation
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Invocation
+{
+}
\ 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/injection/scope/Service.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/Service.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Service.java
new file mode 100644
index 0000000..3fb344a
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Service.java
@@ -0,0 +1,48 @@
+/*
+ * 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.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a service dependency into a Fragment.
+ * <p>
+ * Examples:
+ * </p>
+ * <pre><code>
+ * @Service MyService service
+ * @Service Iterable<MyService> services
+ * @Service ServiceReference<MyService> serviceRef
+ * @Service Iterable<ServiceReference<MyService>> serviceRefs
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Service
+{
+}
+
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/polygene/api/injection/scope/State.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/State.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/State.java
new file mode 100644
index 0000000..ab60507
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/State.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.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a property, association or
+ * StateHolder.
+ * <pre><code>
+ * @State Property<StringState propertyName;
+ * @State Association<MyEntityState associationName;
+ * @State ManyAssociation<MyEntityState manyAssociationName;
+ * @State NamedAssociation<MyEntityState namedAssociationName;
+ * @State StateHolder state;
+ * @State AssociationStateHolder associationState;
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface State
+{
+ /**
+ * Name of the property or association.
+ * If not set then name will be name of field.
+ *
+ * @return the name
+ */
+ public abstract String value() default "";
+}
\ 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/injection/scope/Structure.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/Structure.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Structure.java
new file mode 100644
index 0000000..b2114ab
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Structure.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.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a
+ * resource specific for the module which the
+ * injected object/fragment is instantiated in.
+ * <p>
+ * Valid types are:
+ * </p>
+ * <pre><code>
+ * - TransientBuilderFactory
+ * - ObjectBuilderFactory
+ * - UnitOfWorkFactory
+ * - ServiceFinder
+ * - Module
+ * - Layer
+ * - Application
+ * - PolygeneAPI
+ * - PolygeneSPI
+ * </code></pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface Structure
+{
+}
\ 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/injection/scope/This.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/This.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/This.java
new file mode 100644
index 0000000..1816ac5
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/This.java
@@ -0,0 +1,47 @@
+/*
+ * 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.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a reference to the same Composite
+ * as the fragment is a part of.
+ * <p>
+ * If the Composite type does not implement the type of the field or parameter
+ * then it will be referencing a private mixin.
+ * </p>
+ * <p>
+ * Calls to the reference will have the same semantics as calls to the Composite itself.
+ * Specifically the same set of Modifiers will be used.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.FIELD, ElementType.PARAMETER } )
+@Documented
+@InjectionScope
+public @interface This
+{
+}
\ 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/injection/scope/Uses.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/injection/scope/Uses.java b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Uses.java
new file mode 100644
index 0000000..ea590e4
--- /dev/null
+++ b/core/api/src/main/java/org/apache/polygene/api/injection/scope/Uses.java
@@ -0,0 +1,45 @@
+/*
+ * 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.injection.scope;
+
+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;
+import org.apache.polygene.api.injection.InjectionScope;
+
+/**
+ * Annotation to denote the injection of a dependency to be used by a Mixin. The injected
+ * object is provided either by the TransientBuilder.uses() declarations, or if an instance of the appropriate types is not
+ * found, then a new Transient or Object is instantiated.
+ * Call {@link org.apache.polygene.api.composite.TransientBuilder#use} to provide the instance
+ * to be injected.
+ *
+ * Example:
+ * <pre>@Uses SomeType someInstance</pre>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.PARAMETER, ElementType.FIELD } )
+@Documented
+@InjectionScope
+public @interface Uses
+{
+}
\ No newline at end of file