http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java b/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java deleted file mode 100644 index 3ee4357..0000000 --- a/core/api/src/test/java/org/apache/zest/api/util/ClassesTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.api.util; - -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.util.HashSet; -import java.util.Set; -import org.junit.Test; - -import static org.apache.zest.api.util.Classes.interfacesOf; -import static org.apache.zest.api.util.Classes.interfacesWithMethods; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -/** - * Tests for Classes - */ -public class ClassesTest -{ - - @Test - public void givenClassWithInterfacesWhenInterfacesOfThenGetCorrectSet() - { - assertThat( "one interface returned", interfacesOf( A.class ).count(), equalTo( 1L ) ); - assertThat( "two interface returned", interfacesOf( B.class ).count(), equalTo( 2L ) ); - assertThat( "tree interface returned", interfacesOf( C.class ).count(), equalTo( 4L ) ); - } - - @Test - public void givenClassWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet() - { - HashSet<Class<?>> interfaces = new HashSet<Class<?>>(); - interfaces.add( B.class ); - Set<Class<?>> types = interfacesWithMethods( interfaces ); - assertThat( "one interface returned", types.size(), equalTo( 1 ) ); - assertThat( "correct interface returned", types.contains( B.class ), is( true ) ); - } - - @Test - public void givenClassesWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet() - { - assertThat( "one interface returned", interfacesOf( C.class ).filter( Methods.HAS_METHODS ) - .count(), equalTo( 1L ) ); - boolean isIn = interfacesOf( C.class ).filter( Methods.HAS_METHODS ) - .anyMatch( B.class::equals ); - assertThat( "correct interface returned", isIn, is( true ) ); - } - - @Test - public void givenClassNameWhenToUriThenUriIsReturned() - { - assertThat( "URI is correct", Classes.toURI( A.class ), equalTo( "urn:zest:type:org.apache.zest.api.util.ClassesTest-A" ) ); - } - - @Test - public void givenUriWhenToClassNameThenClassNameIsReturned() - { - assertThat( "Class name is correct", Classes.toClassName( "urn:zest:type:org.apache.zest.api.util.ClassesTest-A" ), equalTo( "org.apache.zest.api.util.ClassesTest$A" ) ); - } - - @Test - public void givenGenericTypeWithWildCardWhenGetRawClassThenCorrectTypeIsReturned() - throws NoSuchMethodException - { - Type returnType = Generics.class.getMethod( "wildcard" ).getGenericReturnType(); - Type wildcardType = ( (ParameterizedType) returnType ).getActualTypeArguments()[ 0 ]; - assertThat( "Return type is A", Classes.RAW_CLASS.apply( wildcardType ), equalTo( (Class) A.class ) ); - } - - @Test - public void givenTypeVariableWhenResolveThenResolved() - { - for( Method method : Type1.class.getMethods() ) - { - Type type = method.getGenericReturnType(); - TypeVariable typeVariable = (TypeVariable) type; - Type resolvedType = Classes.resolveTypeVariable( typeVariable, method.getDeclaringClass(), Type1.class ); - System.out.println( type + "=" + resolvedType ); - switch( method.getName() ) - { - case "type": - assertThat( resolvedType, equalTo( (Type) String.class ) ); - break; - case "type1": - assertThat( resolvedType, equalTo( (Type) String.class ) ); - break; - case "type2": - assertThat( resolvedType, equalTo( (Type) Long.class ) ); - break; - } - } - } - - @Test - public void givenGenericTypeWhenGetSimpleGenericNameThenCorrectStringIsReturned() - throws NoSuchMethodException - { - assertThat( "Simple Generic Name is 'A'", - Classes.simpleGenericNameOf( A.class ), - equalTo( "A" ) ); - assertThat( "Simple Generic Name is 'B'", - Classes.simpleGenericNameOf( B.class ), - equalTo( "B" ) ); - assertThat( "Simple Generic Name is 'C'", - Classes.simpleGenericNameOf( C.class ), - equalTo( "C" ) ); - - assertThat( "Simple Generic Name is 'Generics'", - Classes.simpleGenericNameOf( Generics.class ), - equalTo( "Generics" ) ); - assertThat( "Simple Generic Name is 'Iterable<? extends A>'", - Classes.simpleGenericNameOf( Generics.class.getMethod( "wildcard" ).getGenericReturnType() ), - equalTo( "Iterable<? extends A>" ) ); - - assertThat( "Simple Generic Name is 'Type1'", - Classes.simpleGenericNameOf( Type1.class ), - equalTo( "Type1" ) ); - assertThat( "Simple Generic Name is 'TYPE'", - Classes.simpleGenericNameOf( Type1.class.getMethod( "type" ).getGenericReturnType() ), - equalTo( "TYPE" ) ); - assertThat( "Simple Generic Name is 'TYPE1'", - Classes.simpleGenericNameOf( Type1.class.getMethod( "type1" ).getGenericReturnType() ), - equalTo( "TYPE1" ) ); - assertThat( "Simple Generic Name is 'TYPE2'", - Classes.simpleGenericNameOf( Type1.class.getMethod( "type2" ).getGenericReturnType() ), - equalTo( "TYPE2" ) ); - - assertThat( "Simple Generic Name is 'Type2'", - Classes.simpleGenericNameOf( Type2.class ), - equalTo( "Type2" ) ); - assertThat( "Simple Generic Name is 'TYPE'", - Classes.simpleGenericNameOf( Type2.class.getMethod( "type" ).getGenericReturnType() ), - equalTo( "TYPE" ) ); - assertThat( "Simple Generic Name is 'TYPE1'", - Classes.simpleGenericNameOf( Type2.class.getMethod( "type1" ).getGenericReturnType() ), - equalTo( "TYPE1" ) ); - assertThat( "Simple Generic Name is 'TYPE2'", - Classes.simpleGenericNameOf( Type2.class.getMethod( "type2" ).getGenericReturnType() ), - equalTo( "TYPE2" ) ); - - assertThat( "Simple Generic Name is 'Type3'", - Classes.simpleGenericNameOf( Type3.class ), - equalTo( "Type3" ) ); - assertThat( "Simple Generic Name is 'TYPE'", - Classes.simpleGenericNameOf( Type3.class.getMethod( "type" ).getGenericReturnType() ), - equalTo( "TYPE" ) ); - } - - interface A - { - } - - interface B - extends A - { - - public void doStuff(); - } - - interface C - extends A, B - { - } - - interface Generics - { - - Iterable<? extends A> wildcard(); - } - - interface Type1 - extends Type2<String, Long> - { - } - - interface Type2<TYPE1, TYPE2> - extends Type3<TYPE1> - { - - TYPE1 type1(); - - TYPE2 type2(); - } - - interface Type3<TYPE> - { - - TYPE type(); - } -}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/zest/api/util/CollectorsTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/zest/api/util/CollectorsTest.java b/core/api/src/test/java/org/apache/zest/api/util/CollectorsTest.java deleted file mode 100644 index 7d9ade2..0000000 --- a/core/api/src/test/java/org/apache/zest/api/util/CollectorsTest.java +++ /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.api.util; - -import java.util.Optional; -import java.util.stream.Stream; -import org.junit.Test; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -public class CollectorsTest -{ - @Test - public void single() - { - assertThat( Stream.of( 1L ).collect( Collectors.single() ), is( 1L ) ); - - try - { - Stream.of().collect( Collectors.single() ); - fail( "Should have failed" ); - } - catch( IllegalArgumentException ex ) {} - try - { - Stream.of( 1, 1 ).collect( Collectors.single() ); - fail( "Should have failed" ); - } - catch( IllegalArgumentException ex ) {} - try - { - Stream.of( 1, 1, 1 ).collect( Collectors.single() ); - fail( "Should have failed" ); - } - catch( IllegalArgumentException ex ) {} - } - - @Test - public void singleOrEmpty() - { - assertEquals( Optional.empty(), Stream.of().collect( Collectors.singleOrEmpty() ) ); - assertEquals( Optional.of( 1 ), Stream.of( 1 ).collect( Collectors.singleOrEmpty() ) ); - - try - { - Stream.of( 1, 1 ).collect( Collectors.singleOrEmpty() ); - fail( "Should have failed" ); - } - catch( IllegalArgumentException ex ) {} - try - { - Stream.of( 1, 1, 1 ).collect( Collectors.singleOrEmpty() ); - fail( "Should have failed" ); - } - catch( IllegalArgumentException ex ) {} - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java b/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java deleted file mode 100644 index e0f829e..0000000 --- a/core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.api.value; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Stream; -import org.apache.zest.api.injection.scope.Service; -import org.apache.zest.api.property.Property; -import org.apache.zest.api.structure.Application; -import org.apache.zest.api.structure.Module; -import org.apache.zest.api.type.CollectionType; -import org.apache.zest.bootstrap.Assembler; -import org.apache.zest.bootstrap.AssemblyException; -import org.apache.zest.bootstrap.Energy4Java; -import org.apache.zest.bootstrap.ModuleAssembly; -import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; -import org.apache.zest.test.AbstractPolygeneTest; -import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationAssembler; -import org.junit.Test; - -import static java.util.stream.Collectors.toList; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Snippets: - * - default : default ValueSerialization - * - service : assembled service ValueSerialization - * - lookup : ValueSerialization values module finder - */ -public class DocumentationSupport - extends AbstractPolygeneTest -{ - - // START SNIPPET: default - // START SNIPPET: service - public interface SomeValue // (1) - { - - Property<String> foo(); - } - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - module.values( SomeValue.class ); // (2) - // END SNIPPET: default - new OrgJsonValueSerializationAssembler().assemble( module ); // (3) - new DefaultUnitOfWorkAssembler().assemble( module ); - // START SNIPPET: default - } - // END SNIPPET: default - // END SNIPPET: service - - @Test - // START SNIPPET: default - public void defaultValueSerialization() - { - SomeValue someValue = someNewValueInstance(); // (3) - String json = someValue.toString(); // (4) - SomeValue someNewValue = valueBuilderFactory.newValueFromSerializedState( SomeValue.class, json ); // (5) - // END SNIPPET: default - - assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) ); - assertThat( someNewValue, equalTo( someValue ) ); - - // START SNIPPET: default - } - - // END SNIPPET: default - // START SNIPPET: service - @Service - private ValueSerializer valueSerializer; // (4) - @Service - private ValueDeserializer valueDeserializer; // (4) - - // END SNIPPET: service - @Test - // START SNIPPET: service - public void assembledDefaultServiceSerialization() - { - SomeValue someValue = someNewValueInstance(); // (5) - String json = valueSerializer.serialize( someValue ); // (6) - SomeValue someNewValue = valueDeserializer.deserialize( module, SomeValue.class, json ); // (7) - // END SNIPPET: service - - assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) ); - assertThat( someNewValue, equalTo( someValue ) ); - - // START SNIPPET: service - } - // END SNIPPET: service - - static enum AcmeValue - { - - foo, bar - } - - @Test - // START SNIPPET: stream - public void assembledServiceStreamingSerialization() - { - // END SNIPPET: stream - - List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() ); - ByteArrayOutputStream targetStream = new ByteArrayOutputStream(); - - // START SNIPPET: stream - // (1) - Iterable<AcmeValue> data = dataSource; // Eg. Entities converted to Values - OutputStream output = targetStream; // Eg. streaming JSON over HTTP - - // (2) - valueSerializer.serialize( data, output ); - // END SNIPPET: stream - - byte[] serialized = targetStream.toByteArray(); - ByteArrayInputStream sourceStream = new ByteArrayInputStream( serialized ); - - // START SNIPPET: stream - // (3) - InputStream input = sourceStream; // Eg. reading incoming JSON - - // (4) - List<AcmeValue> values = valueDeserializer.deserialize( module, CollectionType.listOf( AcmeValue.class ), input ); - // END SNIPPET: stream - - assertThat( values, equalTo( dataSource ) ); - - // START SNIPPET: stream - } - // END SNIPPET: stream - - @Test - // START SNIPPET: io - public void assembledServiceIOSerialization() - throws IOException - { - // END SNIPPET: io - - List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() ); - StringWriter stringOutput = new StringWriter(); - PrintWriter output = new PrintWriter( stringOutput ); - - - // START SNIPPET: io - // (1) - // Eg. Entities converted to Values - Stream<AcmeValue> queryResult = dataSource.stream(); - - // (2) - Function<AcmeValue, String> serialize = valueSerializer.serialize(); - - // (3) - // Eg. pipe data to another process or to a file - queryResult.map( serialize ).forEach( output::println ); - // END SNIPPET: io - - output.flush(); - String string = stringOutput.toString(); - List<String> input = Arrays.asList( string.split( System.lineSeparator() ) ); - - // START SNIPPET: io - // (4) - Stream<String> lines = input.stream(); - - // (5) - Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( module, AcmeValue.class ); - - // Deserialization of a collection of AcmeValue from a String. - // One serialized AcmeValue per line. - // (6) - List<AcmeValue> values = lines.map( deserialize ).collect( toList() ); - // END SNIPPET: io - - assertThat( dataSource, equalTo( values ) ); - - // START SNIPPET: io - } - // END SNIPPET: io - - @Test - // TODO Move to SPI ! - // TODO Include in each ValueSerialization extensions documentation - public void assembledWithValuesModuleSerialization() - throws Exception - { - Application app = new Energy4Java().newApplication( applicationFactory -> { - Assembler[][][] pancakes = new Assembler[][][] - { - { - { - valuesModule -> { - valuesModule.layer().setName( "SINGLE-Layer" ); - valuesModule.setName( "VALUES-Module" ); - - valuesModule.values( SomeValue.class ); - new DefaultUnitOfWorkAssembler().assemble( valuesModule ); - } - }, - { - servicesModule -> { - servicesModule.setName( "SERVICES-Module" ); - - Function<Application, Module> valuesModuleFinder = new Function<Application, Module>() - { - @Override - public Module apply( Application app1 ) - { - return app1.findModule( "SINGLE-Layer", "VALUES-Module" ); - } - }; - new OrgJsonValueSerializationAssembler(). - withValuesModuleFinder( valuesModuleFinder ). - assemble( servicesModule ); - } - } - } - }; - return applicationFactory.newApplicationAssembly( pancakes ); - } ); - app.activate(); - try - { - Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" ); - SomeValue someValue = someNewValueInstance(); - - Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" ); - ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get(); - - String json = valueSerialization.serialize( someValue ); - assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) ); - - SomeValue someNewValue = valueSerialization.deserialize( module, SomeValue.class, json ); - assertThat( someNewValue, equalTo( someValue ) ); - } - finally - { - app.passivate(); - } - } - - private SomeValue someNewValueInstance( ) - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - builder.prototype().foo().set( "bar" ); - return builder.newInstance(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java deleted file mode 100644 index 27fef11..0000000 --- a/core/api/src/test/java/org/apache/zest/api/value/ValueBuilderTemplateTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.api.value; - -import org.junit.Test; -import org.apache.zest.api.property.Property; -import org.apache.zest.bootstrap.AssemblyException; -import org.apache.zest.bootstrap.ModuleAssembly; -import org.apache.zest.test.AbstractPolygeneTest; - -/** - * TODO - */ -public class ValueBuilderTemplateTest - extends AbstractPolygeneTest -{ - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - module.values( TestValue.class ); - } - - @Test - public void testTemplate() - { - new TestBuilder( "Rickard" ).newInstance( module ); - } - - @Test - public void testAnonymousTemplate() - { - new ValueBuilderTemplate<TestValue>( TestValue.class ) - { - @Override - protected void build( TestValue prototype ) - { - prototype.name().set( "Rickard" ); - } - }.newInstance( module ); - } - - interface TestValue - extends ValueComposite - { - Property<String> name(); - } - - class TestBuilder - extends ValueBuilderTemplate<TestValue> - { - String name; - - TestBuilder( String name ) - { - super( TestValue.class ); - this.name = name; - } - - @Override - protected void build( TestValue prototype ) - { - prototype.name().set( name ); - } - } - - ; -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java ---------------------------------------------------------------------- diff --git a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java b/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java deleted file mode 100644 index fad1082..0000000 --- a/core/api/src/test/java/org/apache/zest/api/value/ValueCompositeTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.api.value; - -import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.apache.zest.api.association.Association; -import org.apache.zest.api.association.ManyAssociation; -import org.apache.zest.api.common.Optional; -import org.apache.zest.api.common.UseDefaults; -import org.apache.zest.api.constraint.ConstraintViolationException; -import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.entity.EntityComposite; -import org.apache.zest.api.property.Property; -import org.apache.zest.api.unitofwork.UnitOfWork; -import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException; -import org.apache.zest.bootstrap.AssemblyException; -import org.apache.zest.bootstrap.ModuleAssembly; -import org.apache.zest.library.constraints.annotation.MaxLength; -import org.apache.zest.test.AbstractPolygeneTest; -import org.apache.zest.test.EntityTestAssembler; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -/** - * Tests for ValueComposites - */ -public class ValueCompositeTest - extends AbstractPolygeneTest -{ - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - module.values( SomeValue.class, AnotherValue.class, AssociationValue.class ); - module.entities( SomeEntity.class ); - new EntityTestAssembler().assemble( module ); - } - - @Test( expected = IllegalStateException.class ) - public void testImmutabilityOfValueComposite() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue some = builder.prototype(); - some.other().set( "test" ); - some = builder.newInstance(); - some.other().set( "test2" ); - } - - @Test - public void testCreationOfValueComposite() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue some = builder.prototype(); - some.other().set( "test" ); - builder.newInstance(); - - // Check that @UseDefaults works for ValueComposites - assertEquals( "{\"val1\":\"\"}", some.another().get().toString() ); - } - - @Test - public void testEqualityOfValueComposite() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue prototype = builder.prototype(); - prototype.other().set( "test" ); - SomeValue instance = builder.newInstance(); - SomeValue other = builder.newInstance(); - Assert.assertFalse( "Instances should not be the same.", instance == other ); - Assert.assertEquals( "Equal values.", instance, other ); - } - - @Test - public void testHashcodeOfValueComposite() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue prototype = builder.prototype(); - prototype.other().set( "test" ); - SomeValue instance = builder.newInstance(); - SomeValue other = builder.newInstance(); - Assert.assertFalse( "Instances should not be the same.", instance == other ); - Assert.assertEquals( "Equal values.", instance.hashCode(), other.hashCode() ); - } - - @Test - public void testModifyValue() - { - ValueBuilder<AnotherValue> anotherBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class ); - anotherBuilder.prototype().val1().set( "Val1" ); - AnotherValue anotherValue = anotherBuilder.newInstance(); - - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue prototype = builder.prototype(); - prototype.some().set( "foo" ); - prototype.other().set( "test" ); - prototype.xyzzyList().get().add( "blah" ); - prototype.another().set( anotherValue ); - SomeValue instance = builder.newInstance(); - - assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) ); - - // Modify value - builder = valueBuilderFactory.newValueBuilderWithPrototype( instance ); - builder.prototype().some().set( "bar" ); - instance = builder.newInstance(); - - assertThat( "Other is set to test", instance.other().get(), equalTo( "test" ) ); - assertThat( "List has value blah", instance.xyzzyList().get().get( 0 ), equalTo( "blah" ) ); - assertThat( "AnotherValue.val1 has value Val1", instance.another().get().val1().get(), equalTo( "Val1" ) ); - - // Modify value again using method 2 - builder = valueBuilderFactory.newValueBuilderWithPrototype( instance ); - builder.prototype().other().set( "test2" ); - instance = builder.newInstance(); - - assertThat( "Other is set to test2", instance.other().get(), equalTo( "test2" ) ); - assertThat( "Some is set to bar", instance.some().get(), equalTo( "bar" ) ); - } - - @Test( expected = ConstraintViolationException.class ) - public void givenValueWhenModifyToIncorrectValueThenThrowConstraintException() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - SomeValue prototype = builder.prototype(); - prototype.some().set( "foo" ); - SomeValue instance = builder.newInstance(); - - builder = valueBuilderFactory.newValueBuilderWithPrototype( instance ); - builder.prototype().some().set( "123456" ); - } - - @Test - public void givenValueWithListOfValueWhenPrototypeThenListedValuesAreEditable() - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); - SomeValue some = builder.newInstance(); - - builder = valueBuilderFactory.newValueBuilderWithPrototype( some ); - builder.prototype().anotherList().get().get( 0 ).val1().set( "Foo" ); - builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); - some = builder.newInstance(); - - assertThat( "Val1 has been set", some.anotherList().get().get( 0 ).val1().get(), equalTo( "Foo" ) ); - - try - { - some.anotherList().get().get( 0 ).val1().set( "Bar" ); - Assert.fail( "Should not be allowed to modify value" ); - } - catch( IllegalStateException e ) - { - // Ok - } - } - - @Test - public void givenEntityWhenUpdateValueThenValueIsSet() - throws UnitOfWorkCompletionException - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); - ValueBuilder<AnotherValue> valueBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class ); - valueBuilder.prototype().val1().set( "Foo" ); - builder.prototype().another().set( valueBuilder.newInstance() ); - builder.prototype().number().set( 42L ); - SomeValue some = builder.newInstance(); - - UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); - try - { - EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class ); - entityBuilder.instance().someValue().set( some ); - SomeEntity entity = entityBuilder.newInstance(); - - assertThat( "Value has been set", entity.someValue().get().another().get().val1().get(), equalTo( "Foo" ) ); - - unitOfWork.complete(); - } - finally - { - unitOfWork.discard(); - } - } - - @Test - public void givenValueWithAssociationsWhenNewUoWThenCanRead() - throws UnitOfWorkCompletionException - { - ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class ); - builder.prototype().anotherList().get().add( valueBuilderFactory.newValue( AnotherValue.class ) ); - ValueBuilder<AnotherValue> valueBuilder = valueBuilderFactory.newValueBuilder( AnotherValue.class ); - valueBuilder.prototype().val1().set( "Foo" ); - builder.prototype().another().set( valueBuilder.newInstance() ); - builder.prototype().number().set( 42L ); - SomeValue some = builder.newInstance(); - - UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); - AssociationValue associationValue; - try - { - EntityBuilder<SomeEntity> entityBuilder = unitOfWork.newEntityBuilder( SomeEntity.class ); - entityBuilder.instance().someValue().set( some ); - SomeEntity entity = entityBuilder.newInstance(); - - ValueBuilder<AssociationValue> associationBuilder = valueBuilderFactory.newValueBuilder( AssociationValue.class ); - associationBuilder.prototype().some().set( entity ); - associationValue = associationBuilder.newInstance(); - - String json = associationValue.toString(); - - unitOfWork.complete(); - - unitOfWork = unitOfWorkFactory.newUnitOfWork(); - - AssociationValue newAssociationValue = valueBuilderFactory.newValueFromSerializedState( AssociationValue.class, json ); - - Assert.assertEquals( associationValue.some().get(), newAssociationValue.some().get() ); - } - finally - { - unitOfWork.discard(); - } - - // Should allow the toString() to print the entityRefs. - System.out.println( associationValue.toString() ); - try - { - associationValue.some().get(); - fail( "Should have thrown an exception" ); - } - catch( Exception e ) - { - // Ok - } - } - - public enum TestEnum - { - somevalue, anothervalue - } - - public interface SomeValue - extends ValueComposite - { - @UseDefaults - @MaxLength( 5 ) - Property<String> some(); - - @UseDefaults - Property<String> other(); - - @UseDefaults - Property<Long> number(); - - @UseDefaults - Property<List<String>> xyzzyList(); - - @UseDefaults - Property<AnotherValue> another(); - - @UseDefaults - Property<List<AnotherValue>> anotherList(); - - @UseDefaults - Property<TestEnum> testEnum(); - } - - public interface AnotherValue - extends ValueComposite - { - @UseDefaults - Property<String> val1(); - } - - public interface AssociationValue - extends ValueComposite - { - @Optional - Association<SomeEntity> some(); - - ManyAssociation<SomeEntity> manySome(); - } - - public interface SomeEntity - extends EntityComposite - { - Property<SomeValue> someValue(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties ---------------------------------------------------------------------- diff --git a/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties b/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties new file mode 100644 index 0000000..600ed6f --- /dev/null +++ b/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties @@ -0,0 +1,21 @@ +# +# 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. +# +# +# + +me = { name : Niclas, address={ street1 : "Henan Lu 555", street2 : "Block 15", city : { cityName : "Shanghai", country : { countryName : "China" } } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties ---------------------------------------------------------------------- diff --git a/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties b/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties deleted file mode 100644 index 600ed6f..0000000 --- a/core/api/src/test/resources/org/apache/zest/api/configuration/MyService.properties +++ /dev/null @@ -1,21 +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. -# -# -# - -me = { name : Niclas, address={ street1 : "Henan Lu 555", street2 : "Block 15", city : { cityName : "Shanghai", country : { countryName : "China" } } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembler.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembler.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembler.java new file mode 100644 index 0000000..37f4f5b --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembler.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.bootstrap; + +/** + * Implement this interface to create the root class that + * is responsible for assembling your entire application. + * + * Model introspectors will instantiate this class and call assemble + * to create the application, which will then be visited to get + * information about its structure. + * + * Application deployment servers will instantiate this, call assemble, + * and then activate the created application, which will be the runtime + * instance that forms your application. + */ +public interface ApplicationAssembler +{ + ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory ) + throws AssemblyException; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblerAdapter.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblerAdapter.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblerAdapter.java new file mode 100644 index 0000000..22fe614 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblerAdapter.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +/** + * Helper base class for application assemblers that + * want to either create applications using only one layer/module, + * or that wants to create pancake-layered applications. + */ +public class ApplicationAssemblerAdapter + implements ApplicationAssembler +{ + private final Assembler[][][] assemblers; + + protected ApplicationAssemblerAdapter( Assembler assembler ) + { + this.assemblers = new Assembler[][][]{ { { assembler } } }; + } + + protected ApplicationAssemblerAdapter( Assembler[][][] assemblers ) + { + this.assemblers = assemblers; + } + + @Override + public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory ) + throws AssemblyException + { + return applicationFactory.newApplicationAssembly( assemblers ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembly.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembly.java new file mode 100644 index 0000000..5996f1a --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssembly.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +import org.apache.polygene.api.activation.Activator; +import org.apache.polygene.api.structure.Application; + +/** + * An application assembly. This can be used by Assemblers to programmatically + * set the name of the application and create new layers. + */ +public interface ApplicationAssembly +{ + /** + * Create a new layer assembly + * + * @param name of the new layer + * + * @return a LayerAssembly instance + */ + LayerAssembly layer( String name ); + + /** + * Get an assembly for a particular Module. If this is called many times with the same names, then the same module + * is affected. + * + * @param layerName The name of the Layer + * @param moduleName The name of the Module to retrieve or create. + * @return The ModuleAssembly for the Module. + */ + ModuleAssembly module( String layerName, String moduleName ); + + /** + * Get the currently set name of the application + * + * @return the name of the application + */ + String name(); + + /** + * Get the currently set mode of the application + * + * @return the application mode + */ + Application.Mode mode(); + + /** + * Set the name of the application + * + * @param name of the application + * + * @return the assembly + */ + ApplicationAssembly setName( String name ); + + /** + * Set the version of the application. This can be in any format, but + * most likely will follow the Dewey format, i.e. x.y.z. + * + * @param version of the application + * + * @return the assembly + */ + ApplicationAssembly setVersion( String version ); + + /** + * Set the application mode. This will be set to "production" by default. You can + * set the system property "mode" to either "development", "satisfiedBy" or "production" + * to explicitly set the mode. If that is not an option, then call this method + * during assembly to set the mode. The mode may then be queried by assemblers, + * and they may assemble the application differentlly depending on this setting. + * + * @param mode the application mode + * + * @return the assembly + */ + ApplicationAssembly setMode( Application.Mode mode ); + + ApplicationAssembly setMetaInfo( Object info ); + + /** + * Set the application activators. Activators are executed in order around the + * Application activation and passivation. + * + * @param activators the application activators + * @return the assembly + */ + @SuppressWarnings( { "unchecked","varargs" } ) + ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators ); + + <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor ) + throws ThrowableType; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblyFactory.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblyFactory.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblyFactory.java new file mode 100644 index 0000000..1622686 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationAssemblyFactory.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.bootstrap; + +/** + * Factory for creating new Polygene application assemblies. Typically + * you will implement one or more Assemblers, wrap them in an ApplicationAssembler, + * which then uses this factory to assemble and create applications. + */ +public interface ApplicationAssemblyFactory +{ + /** + * Create a new application with one layer and one module. + * + * @param assembler the assembler for the single module + * + * @return the application instance + * + * @throws AssemblyException if the application could not be assembled + */ + ApplicationAssembly newApplicationAssembly( Assembler assembler ) + throws AssemblyException; + + /** + * Create a new application with the same amount of layers + * as the first array size, with modules according to the second array size, + * and then use the third array for assemblers of each module. This gives you + * a simple way to create "pancake" layered applications. + * + * @param assemblers the set of assemblers for the application + * + * @return the application instance + * + * @throws AssemblyException if the application could not be assembled + */ + ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers ) + throws AssemblyException; + + /** + * Create a new ApplicationAssembly that can be used for the above method. + * + * @return a new ApplicationAssembly + */ + ApplicationAssembly newApplicationAssembly(); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationModelFactory.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationModelFactory.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationModelFactory.java new file mode 100644 index 0000000..6d7c32d --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationModelFactory.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.bootstrap; + +import org.apache.polygene.api.structure.ApplicationDescriptor; + +/** + * Factory for ApplicationModelSPI's. Takes an ApplicationAssembly, executes it, + * and builds an application model from it, which can then be instantiated and activated. + */ +public interface ApplicationModelFactory +{ + ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly ) + throws AssemblyException; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationName.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationName.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationName.java new file mode 100644 index 0000000..2e1e553 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/ApplicationName.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.bootstrap; + +/** + * Set the name of the application + */ +public final class ApplicationName + implements Assembler +{ + private String name; + + public ApplicationName( String name ) + { + this.name = name; + } + + @Override + public void assemble( ModuleAssembly module ) + throws AssemblyException + { + module.layer().application().setName( name ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assembler.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assembler.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assembler.java new file mode 100644 index 0000000..901f8d9 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assembler.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.bootstrap; + +/** + * ModuleAssemblies are configured by Assemblers. This + * is the interface you would implement in order to provide + * all configuration and additional metainfo that is needed + * to instantiate a Polygene application. + */ +public interface Assembler +{ + /** + * Assemblers receive a callback to the ModuleAssembly + * they are supposed to configure. They can use this + * to register objects, composites, services etc. and + * the additional metadata that may exist for these + * artifacts. + * <p> + * An Assembler may create new Modules by calling + * {@link org.apache.polygene.bootstrap.ModuleAssembly#layer()} and + * then {@link LayerAssembly#module(String)} (String)}. + * This allows an Assembler to bootstrap an entire Layer with + * more Modules. + * </p> + * @param module the Module to assemble + * + * @throws AssemblyException thrown if the assembler tries to do something illegal + */ + void assemble( ModuleAssembly module ) + throws AssemblyException; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblerCollection.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblerCollection.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblerCollection.java new file mode 100644 index 0000000..8bee7cb --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblerCollection.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.bootstrap; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; + +/** + * Assembler that delegates to a collection of Assemblers. + * <p> + * Makes it easy to collect and compose assemblers into bigger assemblers. + * </p> + */ +public final class AssemblerCollection + implements Assembler +{ + Collection<Assembler> assemblers; + + public AssemblerCollection( Assembler... assemblers ) + { + this.assemblers = Arrays.asList( assemblers ); + } + + @SafeVarargs + public AssemblerCollection( Class<? extends Assembler>... assemblyClasses ) + throws AssemblyException + { + assemblers = new ArrayList<>(); + for( Class<? extends Assembler> assemblyClass : assemblyClasses ) + { + try + { + Assembler assembler = assemblyClass.newInstance(); + assemblers.add( assembler ); + } + catch( Exception e ) + { + throw new AssemblyException( "Could not instantiate assembly with class " + assemblyClass.getName(), e ); + } + } + } + + public AssemblerCollection( Collection<Assembler> assemblers ) + { + this.assemblers = assemblers; + } + + @Override + public void assemble( ModuleAssembly module ) + throws AssemblyException + { + for( Assembler assembler : assemblers ) + { + assembler.assemble( module ); + } + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assemblers.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assemblers.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assemblers.java new file mode 100644 index 0000000..b24a5e6 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Assemblers.java @@ -0,0 +1,448 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.bootstrap; + +/** + * Assembler adapters for common use cases (visibility, reference, configuration). + */ +public class Assemblers +{ + private Assemblers() + { + } + + /** + * Assembler with Visibility interface. + * @param <AssemblerType> Parameterized type of Assembler + */ + public interface Visible<AssemblerType> + extends Assembler + { + /** + * Set Visibility. + * @param visibility Visibility + * @return This Assembler instance + */ + AssemblerType visibleIn( org.apache.polygene.api.common.Visibility visibility ); + + /** + * Get Visibility. + * <p>Default to {@link org.apache.polygene.api.common.Visibility#module}.</p> + * @return Visibility + */ + org.apache.polygene.api.common.Visibility visibility(); + } + + /** + * Assembler with Identity interface. + * @param <AssemblerType> Parameterized type of Assembler + */ + public interface Identifiable<AssemblerType> + extends Assembler + { + /** + * Set Identity. + * @param identity Identity + * @return This Assembler instance + */ + AssemblerType identifiedBy( String identity ); + + /** + * @return {@literal true} if {@link #identity()} do not return null, {@literal false} otherwise + */ + boolean hasIdentity(); + + /** + * Get Identity. + * <p>Default to {@literal null}.</p> + * @return Identity + */ + String identity(); + } + + /** + * Assembler with Configuration interface. + * @param <AssemblerType> Parameterized type of Assembler + */ + public interface Configurable<AssemblerType> + extends Assembler + { + /** + * Set Configuration Module and Visibility. + * @param configModule Configuration Module + * @param configVisibility Configuration Visiblity + * @return This Assembler instance + */ + AssemblerType withConfig( ModuleAssembly configModule, + org.apache.polygene.api.common.Visibility configVisibility ); + + /** + * @return {@literal true} if {@link #configModule() ()} do not return null, {@literal false} otherwise + */ + boolean hasConfig(); + + /** + * Get Configuration Module. + * <p>Default to {@literal null}.</p> + * @return Configuration Module + */ + ModuleAssembly configModule(); + + /** + * Get Configuration Visibility. + * <p>Default to {@link org.apache.polygene.api.common.Visibility#module}.</p> + * @return Configuration Visibility + */ + org.apache.polygene.api.common.Visibility configVisibility(); + } + + /** + * Assembler with Visibility adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class Visibility<AssemblerType> + implements Visible<AssemblerType> + { + private org.apache.polygene.api.common.Visibility visibility = org.apache.polygene.api.common.Visibility.module; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType visibleIn( org.apache.polygene.api.common.Visibility visibility ) + { + this.visibility = visibility; + return (AssemblerType) this; + } + + @Override + public final org.apache.polygene.api.common.Visibility visibility() + { + return visibility; + } + } + + /** + * Assembler with Identity adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class Identity<AssemblerType> + implements Identifiable<AssemblerType> + { + private String identity; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType identifiedBy( String identity ) + { + this.identity = identity; + return (AssemblerType) this; + } + + @Override + public final boolean hasIdentity() + { + return identity != null; + } + + @Override + public final String identity() + { + return identity; + } + } + + /** + * Assembler with Configuration adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class Config<AssemblerType> + implements Configurable<AssemblerType> + { + private ModuleAssembly configModule = null; + private org.apache.polygene.api.common.Visibility configVisibility = org.apache.polygene.api.common.Visibility.module; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType withConfig( ModuleAssembly configModule, + org.apache.polygene.api.common.Visibility configVisibility ) + { + this.configModule = configModule; + this.configVisibility = configVisibility; + return (AssemblerType) this; + } + + @Override + public final boolean hasConfig() + { + return configModule != null; + } + + @Override + public final ModuleAssembly configModule() + { + return configModule; + } + + @Override + public final org.apache.polygene.api.common.Visibility configVisibility() + { + return configVisibility; + } + } + + /** + * Assembler with Visibility and Identity adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class VisibilityIdentity<AssemblerType> + implements Visible<AssemblerType>, + Identifiable<AssemblerType> + { + private org.apache.polygene.api.common.Visibility visibility = org.apache.polygene.api.common.Visibility.module; + private String identity; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType visibleIn( org.apache.polygene.api.common.Visibility visibility ) + { + this.visibility = visibility; + return (AssemblerType) this; + } + + @Override + public final org.apache.polygene.api.common.Visibility visibility() + { + return visibility; + } + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType identifiedBy( String identityString ) + { + this.identity = identityString; + return (AssemblerType) this; + } + + @Override + public final boolean hasIdentity() + { + return identity != null; + } + + @Override + public final String identity() + { + return identity; + } + } + + /** + * Assembler with Visibility and Configuration adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class VisibilityConfig<AssemblerType> + implements Visible<AssemblerType>, + Configurable<AssemblerType> + { + private org.apache.polygene.api.common.Visibility visibility = org.apache.polygene.api.common.Visibility.module; + private ModuleAssembly configModule = null; + private org.apache.polygene.api.common.Visibility configVisibility = org.apache.polygene.api.common.Visibility.module; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType visibleIn( org.apache.polygene.api.common.Visibility visibility ) + { + this.visibility = visibility; + return (AssemblerType) this; + } + + @Override + public final org.apache.polygene.api.common.Visibility visibility() + { + return visibility; + } + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType withConfig( ModuleAssembly configModule, + org.apache.polygene.api.common.Visibility configVisibility ) + { + this.configModule = configModule; + this.configVisibility = configVisibility; + return (AssemblerType) this; + } + + @Override + public final boolean hasConfig() + { + return configModule != null; + } + + @Override + public final ModuleAssembly configModule() + { + return configModule; + } + + @Override + public final org.apache.polygene.api.common.Visibility configVisibility() + { + return configVisibility; + } + } + + /** + * Assembler with Identity and Configuration adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class IdentityConfig<AssemblerType> + implements Identifiable<AssemblerType>, + Configurable<AssemblerType> + { + private String identity; + private ModuleAssembly configModule = null; + private org.apache.polygene.api.common.Visibility configVisibility = org.apache.polygene.api.common.Visibility.module; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType identifiedBy( String identity ) + { + this.identity = identity; + return (AssemblerType) this; + } + + @Override + public final boolean hasIdentity() + { + return identity != null; + } + + @Override + public final String identity() + { + return identity; + } + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType withConfig( ModuleAssembly configModule, + org.apache.polygene.api.common.Visibility configVisibility ) + { + this.configModule = configModule; + this.configVisibility = configVisibility; + return (AssemblerType) this; + } + + @Override + public final boolean hasConfig() + { + return configModule != null; + } + + @Override + public final ModuleAssembly configModule() + { + return configModule; + } + + @Override + public final org.apache.polygene.api.common.Visibility configVisibility() + { + return configVisibility; + } + } + + /** + * Assembler with Visibility, Identity and Configuation adapter. + * @param <AssemblerType> Parameterized type of Assembler + */ + public static abstract class VisibilityIdentityConfig<AssemblerType> + implements Visible<AssemblerType>, + Identifiable<AssemblerType>, + Configurable<AssemblerType> + { + private org.apache.polygene.api.common.Visibility visibility = org.apache.polygene.api.common.Visibility.module; + private String identity; + private ModuleAssembly configModule = null; + private org.apache.polygene.api.common.Visibility configVisibility = org.apache.polygene.api.common.Visibility.module; + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType visibleIn( org.apache.polygene.api.common.Visibility visibility ) + { + this.visibility = visibility; + return (AssemblerType) this; + } + + @Override + public final org.apache.polygene.api.common.Visibility visibility() + { + return visibility; + } + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType identifiedBy( String identity ) + { + this.identity = identity; + return (AssemblerType) this; + } + + @Override + public final boolean hasIdentity() + { + return identity != null; + } + + @Override + public final String identity() + { + return identity; + } + + @Override + @SuppressWarnings( "unchecked" ) + public final AssemblerType withConfig( ModuleAssembly configModule, + org.apache.polygene.api.common.Visibility configVisibility ) + { + this.configModule = configModule; + this.configVisibility = configVisibility; + return (AssemblerType) this; + } + + @Override + public final boolean hasConfig() + { + return configModule != null; + } + + @Override + public final ModuleAssembly configModule() + { + return configModule; + } + + @Override + public final org.apache.polygene.api.common.Visibility configVisibility() + { + return configVisibility; + } + } + +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyException.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyException.java new file mode 100644 index 0000000..0f88b72 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +/** + * Thrown by ModuleAssembly if the Assembler tries to make an invalid assembly. + */ +public class AssemblyException extends RuntimeException +{ + public AssemblyException() + { + } + + public AssemblyException( String string ) + { + super( string ); + } + + public AssemblyException( String string, Throwable throwable ) + { + super( string, throwable ); + } + + public AssemblyException( Throwable throwable ) + { + super( throwable ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblySpecifications.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblySpecifications.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblySpecifications.java new file mode 100644 index 0000000..756d496 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblySpecifications.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ +package org.apache.polygene.bootstrap; + +import java.util.Arrays; +import java.util.function.Predicate; +import org.apache.polygene.api.type.HasTypes; + +/** + * Utility specifications for Assemblies. + */ +public class AssemblySpecifications +{ + public static Predicate<HasTypes> ofAnyType( final Class... types ) + { + return item -> item.types().anyMatch( a -> Arrays.stream( types ).anyMatch( a::equals ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitor.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitor.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitor.java new file mode 100644 index 0000000..a04e8f8 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitor.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.bootstrap; + +/** + * Visitor interface to visit the whole or parts of an assembly. + * <p> + * Implement this interface and call visit() on ApplicationAssembly, LayerAssembly or ModuleAssembly. + * </p> + * <p> + * This can be used to, for example, add metadata to all entities, add concerns on composites, or similar. + * </p> + */ +public interface AssemblyVisitor<ThrowableType extends Throwable> +{ + public void visitApplication( ApplicationAssembly assembly ) + throws ThrowableType; + + public void visitLayer( LayerAssembly assembly ) + throws ThrowableType; + + public void visitModule( ModuleAssembly assembly ) + throws ThrowableType; + + public void visitComposite( TransientDeclaration declaration ) + throws ThrowableType; + + public void visitEntity( EntityDeclaration declaration ) + throws ThrowableType; + + public void visitService( ServiceDeclaration declaration ) + throws ThrowableType; + + public void visitImportedService( ImportedServiceDeclaration declaration ) + throws ThrowableType; + + public void visitValue( ValueDeclaration declaration ) + throws ThrowableType; + + public void visitObject( ObjectDeclaration declaration ) + throws ThrowableType; +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitorAdapter.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitorAdapter.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitorAdapter.java new file mode 100644 index 0000000..019f4ad --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyVisitorAdapter.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +/** + * Base class for assembly visitors. Subclass and override + * the particular methods you are interested in. + */ +public class AssemblyVisitorAdapter<ThrowableType extends Throwable> + implements AssemblyVisitor<ThrowableType> +{ + @Override + public void visitApplication( ApplicationAssembly assembly ) + throws ThrowableType + { + } + + @Override + public void visitLayer( LayerAssembly assembly ) + throws ThrowableType + { + } + + @Override + public void visitModule( ModuleAssembly assembly ) + throws ThrowableType + { + } + + @Override + public void visitComposite( TransientDeclaration declaration ) + throws ThrowableType + { + } + + @Override + public void visitEntity( EntityDeclaration declaration ) + throws ThrowableType + { + } + + @Override + public void visitService( ServiceDeclaration declaration ) + throws ThrowableType + { + } + + @Override + public void visitImportedService( ImportedServiceDeclaration declaration ) + throws ThrowableType + { + } + + @Override + public void visitValue( ValueDeclaration declaration ) + throws ThrowableType + { + } + + @Override + public void visitObject( ObjectDeclaration declaration ) + throws ThrowableType + { + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssociationDeclarations.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssociationDeclarations.java new file mode 100644 index 0000000..b7a6d8d --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssociationDeclarations.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.bootstrap; + +import java.lang.reflect.AccessibleObject; +import org.apache.polygene.api.common.MetaInfo; + +/** + * This provides declared {@link org.apache.polygene.api.association.Association} information that the runtime can use. + */ +public interface AssociationDeclarations +{ + MetaInfo metaInfoFor( AccessibleObject accessor ); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/BindingException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/BindingException.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/BindingException.java new file mode 100644 index 0000000..bbd2dd1 --- /dev/null +++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/BindingException.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.polygene.bootstrap; + +/** + * Thrown by the Polygene runtime if a dependency can not be bound. + */ +public class BindingException + extends Exception +{ + public BindingException( String s ) + { + super( s ); + } + + public BindingException( String s, InvalidInjectionException ex ) + { + super( s, ex ); + } +}
