http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java deleted file mode 100644 index 69563a0..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Assemblers.java +++ /dev/null @@ -1,448 +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.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.zest.api.common.Visibility visibility ); - - /** - * Get Visibility. - * <p>Default to {@link org.apache.zest.api.common.Visibility#module}.</p> - * @return Visibility - */ - org.apache.zest.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.zest.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.zest.api.common.Visibility#module}.</p> - * @return Configuration Visibility - */ - org.apache.zest.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.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module; - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility ) - { - this.visibility = visibility; - return (AssemblerType) this; - } - - @Override - public final org.apache.zest.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.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module; - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType withConfig( ModuleAssembly configModule, - org.apache.zest.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.zest.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.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module; - private String identity; - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility ) - { - this.visibility = visibility; - return (AssemblerType) this; - } - - @Override - public final org.apache.zest.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.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module; - private ModuleAssembly configModule = null; - private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module; - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility ) - { - this.visibility = visibility; - return (AssemblerType) this; - } - - @Override - public final org.apache.zest.api.common.Visibility visibility() - { - return visibility; - } - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType withConfig( ModuleAssembly configModule, - org.apache.zest.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.zest.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.zest.api.common.Visibility configVisibility = org.apache.zest.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.zest.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.zest.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.zest.api.common.Visibility visibility = org.apache.zest.api.common.Visibility.module; - private String identity; - private ModuleAssembly configModule = null; - private org.apache.zest.api.common.Visibility configVisibility = org.apache.zest.api.common.Visibility.module; - - @Override - @SuppressWarnings( "unchecked" ) - public final AssemblerType visibleIn( org.apache.zest.api.common.Visibility visibility ) - { - this.visibility = visibility; - return (AssemblerType) this; - } - - @Override - public final org.apache.zest.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.zest.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.zest.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/zest/bootstrap/AssemblyException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java deleted file mode 100644 index 1fcb544..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyException.java +++ /dev/null @@ -1,46 +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.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/zest/bootstrap/AssemblySpecifications.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java deleted file mode 100644 index 39aa005..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblySpecifications.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.bootstrap; - -import java.util.Arrays; -import java.util.function.Predicate; -import org.apache.zest.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/zest/bootstrap/AssemblyVisitor.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java deleted file mode 100644 index ce6b5fe..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitor.java +++ /dev/null @@ -1,60 +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.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/zest/bootstrap/AssemblyVisitorAdapter.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java deleted file mode 100644 index b2a9420..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssemblyVisitorAdapter.java +++ /dev/null @@ -1,83 +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.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/zest/bootstrap/AssociationDeclarations.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java deleted file mode 100644 index ee9c1a4..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/AssociationDeclarations.java +++ /dev/null @@ -1,32 +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.bootstrap; - -import java.lang.reflect.AccessibleObject; -import org.apache.zest.api.common.MetaInfo; - -/** - * This provides declared {@link org.apache.zest.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/zest/bootstrap/BindingException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java deleted file mode 100644 index 238d5cf..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BindingException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.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 ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java deleted file mode 100644 index cda42bf..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/BootstrapException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.bootstrap; - -/** - * This exception is thrown if no ApplicationFactory provider can be found - */ -public class BootstrapException - extends RuntimeException -{ - public BootstrapException( String message ) - { - super( message ); - } - - public BootstrapException( String message, Throwable cause ) - { - super( message, cause ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java deleted file mode 100644 index c792048..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ClassScanner.java +++ /dev/null @@ -1,182 +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.bootstrap; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.CodeSource; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -/** - * Scan classpath for classes that matches given criteria. Useful for automated assemblies with lots of similar classes. - */ -public class ClassScanner -{ - private static final ValidClass VALID_CLASS_PREDICATE = new ValidClass(); - - /** - * Get all classes from the same package of the given class, and recursively in all subpackages. - * <p> - * This only works if the seed class is loaded from a file: URL. Jar files are possible as well. Abstract classes - * are not included in the results. For further filtering use e.g. Stream.filter. - * </p> - * @param seedClass starting point for classpath scanning - * - * @return Stream of all concrete classes in the same package as the seedclass, and also all classes in subpackages. - */ - public static Stream<? extends Class<?>> findClasses( final Class<?> seedClass ) - { - CodeSource codeSource = seedClass.getProtectionDomain().getCodeSource(); - if( codeSource == null ) - { - return Stream.of(); - } - - URL location = codeSource.getLocation(); - - if( !location.getProtocol().equals( "file" ) ) - { - throw new IllegalArgumentException( - "Can only enumerate classes from file system locations. URL is:" + location ); - } - - final File file; - try - { - file = new File( location.toURI().getPath() ); - } - catch( URISyntaxException e ) - { - throw new IllegalArgumentException( - "The file location of codebase is invalid. Can not convert to URI. URL is:" + location ); - } - - if( file.getName().endsWith( ".jar" ) ) - { - try - { - final String packageName = seedClass.getPackage().getName().replace( '.', '/' ); - - JarFile jarFile = new JarFile( file ); - List<JarEntry> entries = Collections.list( jarFile.entries() ); - try - { - return entries.stream() - .filter( jarEntry -> jarEntry.getName().startsWith( packageName ) - && jarEntry.getName().endsWith( ".class" ) ) - .map( jarEntry -> - { - String name = jarEntry.getName(); - name = name.substring( 0, name.length() - 6 ); - name = name.replace( '/', '.' ); - try - { - return seedClass.getClassLoader().loadClass( name ); - } - catch( ClassNotFoundException e ) - { - return null; - } - } ) - .filter( VALID_CLASS_PREDICATE ); - } - finally - { - jarFile.close(); - } - } - catch( IOException e ) - { - throw new IllegalArgumentException( "Could not open jar file " + file, e ); - } - } - else - { - final File path = new File( file, seedClass.getPackage().getName().replace( '.', File.separatorChar ) ); - Stream<File> classFiles = findFiles( path, candidate -> candidate.getName().endsWith( ".class" ) ); - return classFiles - .map( classFile -> - { - String fileName = classFile.getAbsolutePath().substring( file.toString().length() + 1 ); - fileName = fileName.replace( File.separatorChar, '.' ).substring( 0, fileName.length() - 6 ); - try - { - return seedClass.getClassLoader().loadClass( fileName ); - } - catch( ClassNotFoundException e ) - { - return null; - } - } ) - .filter( VALID_CLASS_PREDICATE ); - } - } - - /** - * Useful specification for filtering classes based on a regular expression matching the class names. - * <p> - * Example: matches(".*Model") -> match only class names that end with Model - * </p> - * - * @param regex The regular expression to be matched. - * - * @return regex class name specification - */ - public static Predicate<Class<?>> matches( String regex ) - { - final Pattern pattern = Pattern.compile( regex ); - return aClass -> pattern.matcher( aClass.getName() ).matches(); - } - - private static Stream<File> findFiles( File directory, final Predicate<File> filter ) - { - File[] listedFiles = directory.listFiles(); - if( listedFiles == null ) - { - return Stream.of(); - } - return Stream.concat( Stream.of( listedFiles ).filter( filter ), - Stream.of( listedFiles ) - .filter( File::isDirectory ) - .map( dir -> findFiles( dir, filter ) ) - .flatMap( Function.identity() ) ); - } - - private static class ValidClass - implements Predicate<Class<?>> - { - @Override - public boolean test( Class<?> item ) - { - return ( item.isInterface() || !Modifier.isAbstract( item.getModifiers() ) ) - && ( !item.isEnum() && !item.isAnonymousClass() ); - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java deleted file mode 100644 index 19b26ea..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationAssembly.java +++ /dev/null @@ -1,30 +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.bootstrap; - -import org.apache.zest.api.type.HasTypes; - -/** - * This represents the assembly information of a single ConfigurationComposite in a Module. - */ -public interface ConfigurationAssembly - extends HasTypes -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java deleted file mode 100644 index 270fd68..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ConfigurationDeclaration.java +++ /dev/null @@ -1,89 +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.bootstrap; - -import org.apache.zest.api.common.Visibility; - -/** - * Fluent API for declaring configurations. Instances - * of this API are acquired by calling {@link ModuleAssembly#configurations(Class[])}. - */ -public interface ConfigurationDeclaration -{ - /** - * Set additional metainfo for this configuration declaration. - * - * @param info metainfo that can be retrieved from the CompositeDescriptor. - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration setMetaInfo( Object info ); - - /** - * Set visibility for declared entities. - * - * @param visibility The {@link Visibility} that this ConfigurationComposite will have. - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration visibleIn( Visibility visibility ); - - /** - * Declare additional concerns for these configurations. - * - * @param concerns The concerns that are to be added to the ConfigurationComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration withConcerns( Class<?>... concerns ); - - /** - * Declare additional side-effects for these configurations. - * - * @param sideEffects The sideeffects that are to be added to the ConfigurationComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration withSideEffects( Class<?>... sideEffects ); - - /** - * Declare additional mixins for these configurations. - * <p> - * This can be useful to override any default mixins from the configuration interface. - * </p> - * @param mixins The mixins that are to be added to the ConfigurationComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration withMixins( Class<?>... mixins ); - - /** - * Declare additional interfaces for these declared interfaces. - * <p> - * This can be useful to add types that the Configuration should implement, but - * which you do not want to include in the entity interface itself. - * </p> - * @param types list of interfaces to add - * - * @return This instance for a fluid DSL - */ - ConfigurationDeclaration withTypes( Class<?>... types ); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java deleted file mode 100644 index 7435d39..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/Energy4Java.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.bootstrap; - -import org.apache.zest.api.PolygeneAPI; -import org.apache.zest.api.structure.Application; -import org.apache.zest.api.structure.ApplicationDescriptor; -import org.apache.zest.spi.PolygeneSPI; - -/** - * Main bootstrap class for starting Polygene and creating new applications. - * <p> - * Instantiate this and call one of the factory methods to get started. - * </p> - * <p> - * This class will use the Service Loader mechanism in Java to try to locate a runtime that implements - * the PolygeneRuntime interface. This avoids a direct dependency from the bootstrap to the runtime. - * </p> - */ -public final class Energy4Java -{ - private PolygeneRuntime runtime; - - public Energy4Java( RuntimeFactory runtimeFactory ) - { - this( runtimeFactory.createRuntime() ); - } - - public Energy4Java() - { - this( new RuntimeFactory.StandaloneApplicationRuntimeFactory().createRuntime() ); - } - - public Energy4Java( PolygeneRuntime runtime ) - { - if( runtime == null ) - { - throw new BootstrapException( "Can not create Polygene without a Polygene Runtime." ); - } - this.runtime = runtime; - } - - public ApplicationDescriptor newApplicationModel( ApplicationAssembler assembler ) - throws AssemblyException - { - ApplicationAssembly assembly = assembler.assemble( runtime.applicationAssemblyFactory() ); - - if( assembly == null ) - { - throw new AssemblyException( "Application assembler did not return any ApplicationAssembly" ); - } - - try - { - ApplicationModelFactory modelFactory = runtime.applicationModelFactory(); - return modelFactory.newApplicationModel( assembly ); - } - catch( RuntimeException e ) - { - throw new AssemblyException( "Unable to create Application Model.", e ); - } - } - - public Application newApplication( ApplicationAssembler assembler, Object... importedServiceInstances ) - throws AssemblyException - { - ApplicationDescriptor model = newApplicationModel( assembler ); - return model.newInstance( runtime.spi(), importedServiceInstances ); - } - - public PolygeneSPI spi() - { - return runtime.spi(); - } - - public PolygeneAPI api() - { - return runtime.spi(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java deleted file mode 100644 index 7703a61..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityAssembly.java +++ /dev/null @@ -1,30 +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.bootstrap; - -import org.apache.zest.api.type.HasTypes; - -/** - * This represents the assembly information of a single EntityComposite in a Module. - */ -public interface EntityAssembly - extends HasTypes -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java deleted file mode 100644 index 8c07dbf..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/EntityDeclaration.java +++ /dev/null @@ -1,89 +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.bootstrap; - -import org.apache.zest.api.common.Visibility; - -/** - * Fluent API for declaring entities. Instances - * of this API are acquired by calling {@link ModuleAssembly#entities(Class[])}. - */ -public interface EntityDeclaration -{ - /** - * Set additional metainfo for this entity declaration. - * - * @param info metainfo that can be retrieved from the EntityDescriptor. - * - * @return This instance for a fluid DSL - */ - EntityDeclaration setMetaInfo( Object info ); - - /** - * Set visibility for declared entities. - * - * @param visibility The {@link Visibility} that this EntityComposite will have. - * - * @return This instance for a fluid DSL - */ - EntityDeclaration visibleIn( Visibility visibility ); - - /** - * Declare additional concerns for these entities. - * - * @param concerns The concerns that are to be added to the EntityComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - EntityDeclaration withConcerns( Class<?>... concerns ); - - /** - * Declare additional side-effects for these entitites. - * - * @param sideEffects The sideeffects that are to be added to the EntityComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - EntityDeclaration withSideEffects( Class<?>... sideEffects ); - - /** - * Declare additional mixins for these entities. - * <p> - * This can be useful to override any default mixins from the entity interface. - * </p> - * @param mixins The mixins that are to be added to the EntityComposite beyond the statically declared ones. - * - * @return This instance for a fluid DSL - */ - EntityDeclaration withMixins( Class<?>... mixins ); - - /** - * Declare additional interfaces for these declared interfaces. - * <p> - * This can be useful to add types that the entities should implement, but - * which you do not want to include in the entity interface itself. - * </p> - * @param types list of interfaces to add - * - * @return This instance for a fluid DSL - */ - EntityDeclaration withTypes( Class<?>... types ); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java deleted file mode 100644 index 22768aa..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceAssembly.java +++ /dev/null @@ -1,30 +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.bootstrap; - -import org.apache.zest.api.type.HasTypes; - -/** - * This represents the assembly information of a single imported service in a Module. - */ -public interface ImportedServiceAssembly - extends HasTypes -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java deleted file mode 100644 index 7cb41cd..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ImportedServiceDeclaration.java +++ /dev/null @@ -1,64 +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.bootstrap; - -import org.apache.zest.api.activation.Activator; -import org.apache.zest.api.common.Visibility; -import org.apache.zest.api.service.ServiceImporter; -import org.apache.zest.api.service.importer.InstanceImporter; -import org.apache.zest.api.service.importer.NewObjectImporter; -import org.apache.zest.api.service.importer.ServiceInstanceImporter; -import org.apache.zest.api.service.importer.ServiceSelectorImporter; - -/** - * Fluent API for declaring imported services. Instances - * of this API are acquired by calling {@link ModuleAssembly#importedServices(Class[])}. - */ -public interface ImportedServiceDeclaration -{ - // Convenience constants for common service importers - public static final Class<? extends ServiceImporter> INSTANCE = InstanceImporter.class; - public static final Class<? extends ServiceImporter> NEW_OBJECT = NewObjectImporter.class; - public static final Class<? extends ServiceImporter> SERVICE_SELECTOR = ServiceSelectorImporter.class; - public static final Class<? extends ServiceImporter> SERVICE_IMPORTER = ServiceInstanceImporter.class; - - ImportedServiceDeclaration visibleIn( Visibility visibility ); - - ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass ); - - ImportedServiceDeclaration identifiedBy( String identity ); - - ImportedServiceDeclaration taggedWith( String... tags ); - - ImportedServiceDeclaration setMetaInfo( Object serviceAttribute ); - - ImportedServiceDeclaration importOnStartup(); - - /** - * Set the imported service activators. Activators are executed in order around - * the ServiceReference activation and passivation. - * - * @param activators the imported service activators - * @return the assembly - */ - @SuppressWarnings( { "unchecked","varargs" } ) - ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators ); -} \ 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/zest/bootstrap/InjectionException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java deleted file mode 100644 index d55fc47..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InjectionException.java +++ /dev/null @@ -1,43 +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.bootstrap; - -/** - * Thrown by the Polygene runtime if a dependency can not be injected. - */ -public class InjectionException - extends RuntimeException -{ - public InjectionException( String s ) - { - super( s ); - } - - public InjectionException( String s, Throwable throwable ) - { - super( s, throwable ); - } - - public InjectionException( Throwable throwable ) - { - super( throwable ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java deleted file mode 100644 index 6d5b6db..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/InvalidInjectionException.java +++ /dev/null @@ -1,37 +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.bootstrap; - -/** - * Thrown by the Polygene runtime if a dependency injection declaration is invalid. - */ -public class InvalidInjectionException - extends Exception -{ - public InvalidInjectionException( String s ) - { - super( s ); - } - - public InvalidInjectionException( String s, Throwable throwable ) - { - super( s, throwable ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java deleted file mode 100644 index 57b3cad..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerAssembly.java +++ /dev/null @@ -1,124 +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.bootstrap; - -import java.util.function.Predicate; -import org.apache.zest.api.activation.Activator; -import org.apache.zest.api.structure.Layer; - -/** - * Fluid API for declaring a layer in an application. This is obtained by calling {@link ApplicationAssembly#layer(String)}. - */ -public interface LayerAssembly -{ - /** - * Get an assembly for a particular Module. If this is called many times with the same name, then the same module - * is affected. - * - * @param name The name of the Module to retrieve or create. - * - * @return The ModuleAssembly for the Module. - */ - ModuleAssembly module( String name ); - - ApplicationAssembly application(); - - String name(); - - LayerAssembly setName( String name ); - - LayerAssembly setMetaInfo( Object info ); - - LayerAssembly uses( LayerAssembly... layerAssembly ); - - /** - * Set the layer activators. Activators are executed in order around the - * Layer activation and passivation. - * - * @param activators the layer activators - * @return the assembly - */ - @SuppressWarnings( { "unchecked","varargs" } ) - LayerAssembly withActivators( Class<? extends Activator<Layer>>... activators ); - - <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor ) - throws ThrowableType; - - /** - * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the EntityComposite types of interest. - * - * @return An EntityDeclaration for the specified EntityComposite types. - */ - EntityDeclaration entities( Predicate<? super EntityAssembly> specification ); - - /** - * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the ServiceComposite types of interest. - * - * @return An ServiceDeclaration for the specified ServiceComposite types. - */ - ServiceDeclaration services( Predicate<? super ServiceAssembly> specification ); - - /** - * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the TransientComposite types of interest. - * - * @return An TransientDeclaration for the specified TransientComposite types. - */ - TransientDeclaration transients( Predicate<? super TransientAssembly> specification ); - - /** - * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the ValueComposite types of interest. - * - * @return An ValueDeclaration for the specified ValueComposite types. - */ - ValueDeclaration values( Predicate<? super ValueAssembly> specification ); - - /** - * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the Object types of interest. - * - * @return An ObjectDeclaration for the specified Object types. - */ - ObjectDeclaration objects( Predicate<? super ObjectAssembly> specification ); - - /** - * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can - * be used to work with all of the assemblies in this Layer matched by the specification. - * - * @param specification The Specification that specifies the Imported Service types of interest. - * - * @return An ImportedServiceDeclaration for the specified Imported Service types. - */ - ImportedServiceDeclaration importedServices( Predicate<? super ImportedServiceAssembly> specification ); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java deleted file mode 100644 index 938f990..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/LayerName.java +++ /dev/null @@ -1,42 +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.bootstrap; - -/** - * Set the name of the layer - */ -public final class LayerName - implements Assembler -{ - private final String name; - - public LayerName( String name ) - { - this.name = name; - } - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - module.layer().setName( name ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java deleted file mode 100644 index 0dcaf61..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ManyAssociationDeclarations.java +++ /dev/null @@ -1,32 +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.bootstrap; - -import java.lang.reflect.AccessibleObject; -import org.apache.zest.api.common.MetaInfo; - -/** - * This provides declared {@link org.apache.zest.api.association.ManyAssociation} information that the runtime can use. - */ -public interface ManyAssociationDeclarations -{ - 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/zest/bootstrap/MetaInfoDeclaration.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java deleted file mode 100644 index 2feafd3..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MetaInfoDeclaration.java +++ /dev/null @@ -1,221 +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.bootstrap; - -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.Map; -import org.apache.zest.api.common.MetaInfo; -import org.apache.zest.api.property.Property; - -/** - * Declaration of a Property or Association. - */ -public final class MetaInfoDeclaration - implements StateDeclarations, AssociationDeclarations, ManyAssociationDeclarations, NamedAssociationDeclarations -{ - Map<Class<?>, InfoHolder<?>> mixinPropertyDeclarations = new HashMap<>(); - - public MetaInfoDeclaration() - { - } - - public <T> MixinDeclaration<T> on( Class<T> mixinType ) - { - @SuppressWarnings( "unchecked" ) - InfoHolder<T> propertyDeclarationHolder = (InfoHolder<T>) mixinPropertyDeclarations.get( mixinType ); - if( propertyDeclarationHolder == null ) - { - propertyDeclarationHolder = new InfoHolder<>( mixinType ); - mixinPropertyDeclarations.put( mixinType, propertyDeclarationHolder ); - } - return propertyDeclarationHolder; - } - - @Override - public MetaInfo metaInfoFor( AccessibleObject accessor ) - { - for( Map.Entry<Class<?>, InfoHolder<?>> entry : mixinPropertyDeclarations.entrySet() ) - { - InfoHolder<?> holder = entry.getValue(); - MetaInfo metaInfo = holder.metaInfoFor( accessor ); - if( metaInfo != null ) - { - Class<?> mixinType = entry.getKey(); - return metaInfo.withAnnotations( mixinType ) - .withAnnotations( accessor ) - .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor ) - .getType() ); - } - } - // TODO is this code reached at all?? - Class<?> declaringType = ( (Member) accessor ).getDeclaringClass(); - return new MetaInfo().withAnnotations( declaringType ) - .withAnnotations( accessor ) - .withAnnotations( accessor instanceof Method ? ( (Method) accessor ).getReturnType() : ( (Field) accessor ).getType() ); - } - - @Override - public Object initialValueOf( AccessibleObject accessor ) - { - for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() ) - { - final Object initialValue = propertyDeclarationHolder.initialValueOf( accessor ); - if( initialValue != null ) - { - return initialValue; - } - } - return null; - } - - @Override - public boolean useDefaults( AccessibleObject accessor ) - { - for( InfoHolder<?> propertyDeclarationHolder : mixinPropertyDeclarations.values() ) - { - final boolean useDefaults = propertyDeclarationHolder.useDefaults( accessor ); - if( useDefaults ) - { - return useDefaults; - } - } - return false; - } - - private static class InfoHolder<T> - implements InvocationHandler, StateDeclarations, MixinDeclaration<T> - { - private final static class MethodInfo - { - Object initialValue; - boolean useDefaults; - MetaInfo metaInfo; - - private MethodInfo( MetaInfo metaInfo ) - { - this.metaInfo = metaInfo; - } - } - - private final Class<T> mixinType; - private final Map<AccessibleObject, MethodInfo> methodInfos = new HashMap<>(); - // temporary holder - private MetaInfo metaInfo = null; - - private InfoHolder( Class<T> mixinType ) - { - this.mixinType = mixinType; - } - - @Override - @SuppressWarnings( "raw" ) - public Object invoke( Object o, Method method, Object[] objects ) - throws Throwable - { - final MethodInfo methodInfo = new MethodInfo( metaInfo ); - methodInfo.useDefaults = true; - methodInfos.put( method, methodInfo ); - metaInfo = null; // reset - final Class<?> returnType = method.getReturnType(); - try - { - return Proxy.newProxyInstance( returnType.getClassLoader(), new Class[]{ returnType }, - ( o1, method1, objects1 ) -> { - if( method1.getName().equals( "set" ) ) - { - methodInfo.initialValue = objects1[ 0 ]; - } - return null; - } ); - } - catch( IllegalArgumentException e ) - { - throw new IllegalArgumentException( - "Only methods with " + Property.class.getName() + " as return type can have declareDefaults()" ); - } - } - - public MethodInfo matches( AccessibleObject accessor ) - { - return methodInfos.get( accessor ); - } - - @Override - public MetaInfo metaInfoFor( AccessibleObject accessor ) - { - final MethodInfo methodInfo = matches( accessor ); - if( methodInfo == null ) - { - return null; - } - return methodInfo.metaInfo; - } - - @Override - public Object initialValueOf( AccessibleObject accessor ) - { - final MethodInfo methodInfo = matches( accessor ); - if( methodInfo == null ) - { - return null; - } - return methodInfo.initialValue; - } - - @Override - public boolean useDefaults( AccessibleObject accessor ) - { - final MethodInfo methodInfo = matches( accessor ); - if( methodInfo == null ) - { - return false; - } - return methodInfo.useDefaults; - } - - // DSL Interface - - @Override - @SuppressWarnings( "raw" ) - public T declareDefaults() - { - return mixinType.cast( - Proxy.newProxyInstance( mixinType.getClassLoader(), new Class[]{ mixinType }, this ) ); - } - - @Override - public MixinDeclaration<T> setMetaInfo( Object info ) - { - if( metaInfo == null ) - { - metaInfo = new MetaInfo(); - } - metaInfo.set( info ); - return this; - } - } -} \ 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/zest/bootstrap/MixinDeclaration.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java deleted file mode 100644 index 57328f4..0000000 --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/MixinDeclaration.java +++ /dev/null @@ -1,33 +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.bootstrap; - -/** - * Fluent API for declaring information about properties - * - * @param <T> Parameterized mixin type - */ -public interface MixinDeclaration<T> -{ - T declareDefaults(); - - MixinDeclaration<T> setMetaInfo( Object info ); -}
