You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/12/17 10:27:55 UTC
[19/81] [abbrv] [partial] zest-java git commit: ZEST-195 ;
Replace all "zest" with "polygene"
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
deleted file mode 100644
index 8965815..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleAssembly.java
+++ /dev/null
@@ -1,243 +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.Module;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-
-/**
- * The ModuleAssembly is used to register any information about * what the module should contain, such as composites,
- * entities and services.
- * <p>
- * Use the methods and the fluent API's to declare how the module should be constructed.
- * </p>
- */
-public interface ModuleAssembly
-{
- /**
- * Access the layer assembly for this module.
- *
- * @return The Layer containing this Module.
- */
- LayerAssembly layer();
-
- /**
- * 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 );
-
- /**
- * Set the name of this module.
- *
- * @param name The name that this Module should have.
- *
- * @return This instance to support the fluid DSL of bootstrap.
- */
- ModuleAssembly setName( String name );
-
- /**
- * Access the currently set name for this module.
- *
- * @return The name of this Module.
- */
- String name();
-
- ModuleAssembly setMetaInfo( Object info );
-
- /**
- * Set the module activators. Activators are executed in order around the
- * Module activation and passivation.
- *
- * @param activators the module activators
- *
- * @return the assembly
- */
- @SuppressWarnings( { "unchecked", "varargs" } )
- ModuleAssembly withActivators( Class<? extends Activator<Module>>... activators );
-
- /**
- * Declare a list of TransientComposites for this Module. Use the TransientDeclaration that is returned to
- * declare further settings. Note that the TransientDeclaration works on all of the types specified.
- *
- * @param transientTypes The types that specifies the Transient types.
- *
- * @return An TransientDeclaration for the specified Transient types.
- */
- TransientDeclaration transients( Class<?>... transientTypes );
-
- /**
- * Given a Specification for TransientAssembly's, returns a TransientDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- /**
- * Declare a list of ValueComposites for this Module. Use the ValueDeclaration that is returned to
- * declare further settings. Note that the ValueDeclaration works on all of the types specified.
- *
- * @param valueTypes The types that specifies the Value types.
- *
- * @return An ValueDeclaration for the specified Value types.
- */
- ValueDeclaration values( Class<?>... valueTypes );
-
- /**
- * Given a Specification for ValueAssembly's, returns a ValueDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- /**
- * Declare a list of EntityComposites for this Module. Use the EntityDeclaration that is returned to
- * declare further settings. Note that the EntityDeclaration works on all of the types specified.
- *
- * @param entityTypes The types that specifies the Entity types.
- *
- * @return An EntityDeclaration for the specified Entity types.
- */
- EntityDeclaration entities( Class<?>... entityTypes );
-
- /**
- * Given a Specification for EntityAssembly's, returns a EntityDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- /**
- * Declare a list of Configuration Composites for this Module. Use the ConfigurationDeclaration that is returned to
- * declare further settings. Note that the ConfigurationDeclaration works on all of the types specified.
- *
- * @param configurationTypes The types that specifies the Configuration types.
- *
- * @return An ConfigurationDeclaration for the specified Configuration types.
- */
- ConfigurationDeclaration configurations( Class<?>... configurationTypes );
-
- /**
- * Given a Specification for ConfigurationAssembly's, returns a ConfigurationDeclaration that can
- * be used to work with all of the assemblies matched by the specification.
- *
- * @param specification The Specification that specifies the ConfigurationComposite types of interest.
- *
- * @return An ConfigurationDeclaration for the specified EntityComposite types.
- */
- ConfigurationDeclaration configurations( Predicate<HasTypes> specification );
-
- /**
- * Declare a list of object classes for this Module. Use the ObjectDeclaration that is returned to
- * declare further settings. Note that the ObjectDeclaration works on all of the types specified.
- *
- * @param objectTypes The types that specifies the Object types.
- *
- * @return An ObjectDeclaration for the specified Object types.
- *
- * @throws AssemblyException on invalid assembly
- */
- ObjectDeclaration objects( Class<?>... objectTypes )
- throws AssemblyException;
-
- /**
- * Given a Specification for ObjectAssembly's, returns a ObjectDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- /**
- * Create a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
- * declare further settings. This will always create new assemblies for the specified types, instead
- * of potentially working on already declared types like the services(...) method.
- *
- * @param serviceTypes The types that specifies the Service types.
- *
- * @return An ServiceDeclaration for the specified Service types.
- */
- ServiceDeclaration addServices( Class<?>... serviceTypes );
-
- /**
- * Declare a list of ServiceComposites for this Module. Use the ServiceDeclaration that is returned to
- * declare further settings. Note that the ServiceDeclaration works on all of the types specified.
- *
- * @param serviceTypes The types that specifies the Service types.
- *
- * @return An ServiceDeclaration for the specified Service types.
- */
- ServiceDeclaration services( Class<?>... serviceTypes );
-
- /**
- * Given a Specification for ServiceAssembly's, returns a ServiceDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- /**
- * Declare a list of imported services for this Module. Use the ImportedServiceDeclaration that is returned to
- * declare further settings. Note that the ImportedServiceDeclaration works on all of the types specified.
- *
- * @param serviceTypes The types that specifies the Imported Service types.
- *
- * @return An ImportedServiceDeclaration for the specified Imported Service types.
- */
- ImportedServiceDeclaration importedServices( Class<?>... serviceTypes );
-
- /**
- * Given a Specification for ImportedServiceAssembly's, returns a ImportedServiceDeclaration that can
- * be used to work with all of the assemblies 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 );
-
- <T> MixinDeclaration<T> forMixin( Class<T> mixinType );
-
- public <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/zest/bootstrap/ModuleName.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.java
deleted file mode 100644
index e6de34c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ModuleName.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 module
- */
-public final class ModuleName
- implements Assembler
-{
- private final String name;
-
- public ModuleName( String name )
- {
- this.name = name;
- }
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.setName( name );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
deleted file mode 100644
index 6969494..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/NamedAssociationDeclarations.java
+++ /dev/null
@@ -1,31 +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.NamedAssociation} information that the runtime can use.
- */
-public interface NamedAssociationDeclarations
-{
- 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/ObjectAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.java
deleted file mode 100644
index c9b4ef9..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectAssembly.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 object type in a Module.
- */
-public interface ObjectAssembly
- extends HasTypes
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.java
deleted file mode 100644
index 7b7f6da..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ObjectDeclaration.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 org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring objects.Instances
- * of this API are acquired by calling {@link ModuleAssembly#objects(Class[])}.
- */
-public interface ObjectDeclaration
-{
- ObjectDeclaration setMetaInfo( Object info );
-
- ObjectDeclaration visibleIn( Visibility visibility )
- throws IllegalStateException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
deleted file mode 100644
index 326dd0c..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/RuntimeFactory.java
+++ /dev/null
@@ -1,63 +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;
-
-/**
- * Polygene runtime factory.
- */
-public interface RuntimeFactory
-{
- PolygeneRuntime createRuntime();
-
- /**
- * Standalone application Polygene runtime factory.
- */
- public final class StandaloneApplicationRuntimeFactory
- implements RuntimeFactory
- {
- @Override
- public PolygeneRuntime createRuntime()
- {
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- Class<? extends PolygeneRuntime> runtimeClass = loadRuntimeClass( loader );
- return runtimeClass.newInstance();
- }
- catch( ClassNotFoundException e )
- {
- System.err.println( "Polygene Runtime jar is not present in the classpath." );
- }
- catch( InstantiationException | IllegalAccessException e )
- {
- System.err.println( "Invalid Polygene Runtime class. If you are providing your own Polygene Runtime, please " +
- "contact dev@zest.apache.org mailing list for assistance." );
- }
- return null;
- }
-
- @SuppressWarnings( { "unchecked" } )
- private Class<? extends PolygeneRuntime> loadRuntimeClass( ClassLoader loader )
- throws ClassNotFoundException
- {
- return (Class<? extends PolygeneRuntime>) loader.loadClass( "org.apache.zest.runtime.PolygeneRuntimeImpl" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.java
deleted file mode 100644
index 4d0c2a2..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceAssembly.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.identity.Identifiable;
-import org.apache.zest.api.type.HasTypes;
-
-/**
- * This represents the assembly information of a single ServiceComposite in a Module.
- */
-public interface ServiceAssembly extends HasTypes, Identifiable
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
deleted file mode 100644
index f17ad8a..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ServiceDeclaration.java
+++ /dev/null
@@ -1,59 +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;
-
-/**
- * Fluent API for declaring services hosted in Polygene. Instances
- * of this API are acquired by calling {@link ModuleAssembly#services(Class[])}.
- */
-public interface ServiceDeclaration
-{
- ServiceDeclaration setMetaInfo( Object serviceAttribute );
-
- ServiceDeclaration visibleIn( Visibility visibility );
-
- ServiceDeclaration withConcerns( Class<?>... concerns );
-
- ServiceDeclaration withSideEffects( Class<?>... sideEffects );
-
- ServiceDeclaration withMixins( Class<?>... mixins );
-
- ServiceDeclaration withTypes( Class<?>... types );
-
- ServiceDeclaration identifiedBy( String identity );
-
- ServiceDeclaration taggedWith( String... tags );
-
- ServiceDeclaration instantiateOnStartup();
-
- /**
- * Set the service activators. Activators are executed in order around the
- * ServiceReference activation and passivation.
- *
- * @param activators the service activators
- * @return the assembly
- */
- @SuppressWarnings( { "unchecked","varargs" } )
- ServiceDeclaration withActivators( Class<? extends Activator<?>>... activators );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
deleted file mode 100644
index 5d6117b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/SingletonAssembler.java
+++ /dev/null
@@ -1,129 +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.activation.ActivationException;
-import org.apache.zest.api.composite.TransientBuilderFactory;
-import org.apache.zest.api.object.ObjectFactory;
-import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilderFactory;
-
-/**
- * Base class for Assembler that creates an Application
- * with one Layer and one Module. Create a subclass of this
- * and implement the {@link Assembler#assemble(ModuleAssembly)} method.
- * Once the SingletonAssembler is instantiated it will have created and activated
- * an Application which can be accessed from {@link org.apache.zest.bootstrap.SingletonAssembler#application()}.
- * You can also easily access any resources specific for the single Module, such as the TransientBuilderFactory.
- */
-public abstract class SingletonAssembler
- implements Assembler
-{
- private Energy4Java zest;
- private Application applicationInstance;
- private final Module moduleInstance;
-
- /**
- * Creates a Polygene Runtime instance containing one Layer with one Module.
- * The Layer will be named "Layer 1" and the Module will be named "Module 1". It is possible to add
- * additional layers and modules via the Assembler interface that must be implemented in the subclass of this
- * class.
- *
- * @throws AssemblyException Either if the model can not be created from the disk, or some inconsistency in
- * the programming model makes it impossible to create it.
- * @throws ActivationException If the automatic {@code activate()} method is throwing this Exception..
- */
- public SingletonAssembler()
- throws AssemblyException, ActivationException
- {
-// START SNIPPET: actual
- zest = new Energy4Java();
- applicationInstance = zest.newApplication(
- applicationFactory -> applicationFactory.newApplicationAssembly( SingletonAssembler.this )
- );
-
- try
- {
- beforeActivation( applicationInstance );
- applicationInstance.activate();
- }
- catch( Exception e )
- {
- if( e instanceof ActivationException )
- {
- throw ( (ActivationException) e );
- }
- throw new ActivationException( "Could not activate application", e );
- }
-// START SNIPPET: actual
-
- moduleInstance = applicationInstance.findModule( "Layer 1", "Module 1" );
- }
-
- public final PolygeneAPI runtime()
- {
- return zest.spi();
- }
-
- public final Application application()
- {
- return applicationInstance;
- }
-
- public final Module module()
- {
- return moduleInstance;
- }
-
- protected void beforeActivation( Application application )
- throws Exception
- {
- }
-
- protected UnitOfWorkFactory unitOfWorkFactory()
- {
- return moduleInstance.unitOfWorkFactory();
- }
-
- protected ServiceFinder serviceFinder()
- {
- return moduleInstance.serviceFinder();
- }
-
- protected ValueBuilderFactory valueBuilderFactory()
- {
- return moduleInstance.valueBuilderFactory();
- }
-
- protected TransientBuilderFactory transientBuilderFactory()
- {
- return moduleInstance.transientBuilderFactory();
- }
-
- protected ObjectFactory objectFactory()
- {
- return moduleInstance.objectFactory();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
deleted file mode 100644
index 55ed93d..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/StateDeclarations.java
+++ /dev/null
@@ -1,36 +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.property.Property} information that the runtime can use.
- */
-public interface StateDeclarations
-{
- MetaInfo metaInfoFor( AccessibleObject accessor );
-
- Object initialValueOf( AccessibleObject accessor );
-
- boolean useDefaults( AccessibleObject accessor );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.java
deleted file mode 100644
index dac0396..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientAssembly.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 TransientComposite in a Module.
- */
-public interface TransientAssembly
- extends HasTypes
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.java
deleted file mode 100644
index 6e9436b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/TransientDeclaration.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;
-
-import org.apache.zest.api.common.Visibility;
-
-/**
- * Fluent API for declaring TransientComposites. Instances
- * of this API are acquired by calling {@link ModuleAssembly#transients(Class[])}.
- */
-public interface TransientDeclaration
-{
- TransientDeclaration setMetaInfo( Object info );
-
- TransientDeclaration visibleIn( Visibility visibility );
-
- TransientDeclaration withConcerns( Class<?>... concerns );
-
- TransientDeclaration withSideEffects( Class<?>... sideEffects );
-
- TransientDeclaration withMixins( Class<?>... mixins );
-
- TransientDeclaration withTypes( Class<?>... roles );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.java
deleted file mode 100644
index 8a892cd..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueAssembly.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 ValueComposite in a Module.
- */
-public interface ValueAssembly
- extends HasTypes
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
deleted file mode 100644
index 51c0116..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ValueDeclaration.java
+++ /dev/null
@@ -1,41 +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 values
- */
-public interface ValueDeclaration
-{
- ValueDeclaration setMetaInfo( Object info );
-
- ValueDeclaration visibleIn( Visibility visibility );
-
- ValueDeclaration withConcerns( Class<?>... concerns );
-
- ValueDeclaration withSideEffects( Class<?>... sideEffects );
-
- ValueDeclaration withMixins( Class<?>... mixins );
-
- ValueDeclaration withTypes( Class<?>... roles );
-}
\ 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/ZestRuntime.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ZestRuntime.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ZestRuntime.java
deleted file mode 100644
index 72d83c7..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/ZestRuntime.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.PolygeneAPI;
-import org.apache.zest.spi.PolygeneSPI;
-
-/**
- * This interface has to be implemented by Polygene runtimes.
- */
-public interface PolygeneRuntime
-{
- ApplicationAssemblyFactory applicationAssemblyFactory();
-
- ApplicationModelFactory applicationModelFactory();
-
- PolygeneAPI api();
-
- PolygeneSPI spi();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
deleted file mode 100644
index 7c53bea..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ApplicationBuilder.java
+++ /dev/null
@@ -1,303 +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.builder;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.apache.zest.api.activation.ActivationEventListener;
-import org.apache.zest.api.activation.ActivationEventListenerRegistration;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.ApplicationPassivationThread;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-/**
- * Application Builder.
- */
-public class ApplicationBuilder
- implements ActivationEventListenerRegistration
-{
- private final String applicationName;
- private String applicationVersion;
- private Application.Mode applicationMode;
- private final List<Object> metaInfos = new ArrayList<>();
- private boolean passivationShutdownHook;
- private final Map<String, LayerDeclaration> layers = new HashMap<>();
- private final List<ActivationEventListener> activationListeners = new ArrayList<>();
-
- public ApplicationBuilder( String applicationName )
- {
- this.applicationName = applicationName;
- }
-
- public ApplicationBuilder version( String version )
- {
- applicationVersion = version;
- return this;
- }
-
- public ApplicationBuilder mode( Application.Mode mode )
- {
- applicationMode = mode;
- return this;
- }
-
- public ApplicationBuilder metaInfo( Object... metaInfos )
- {
- for( Object metaInfo : metaInfos )
- {
- this.metaInfos.add( metaInfo );
- }
- return this;
- }
-
- /**
- * Register a JVM shutdown hook that passivate the Application.
- *
- * The hook is registered after activating the Application and before {@link #afterActivation()}.
- *
- * @return This builder
- */
- public ApplicationBuilder withPassivationShutdownHook()
- {
- this.passivationShutdownHook = true;
- return this;
- }
-
- /**
- * Create and activate a new Application.
- * @return Activated Application
- * @throws AssemblyException if the assembly failed
- * @throws ActivationException if the activation failed
- */
- public Application newApplication()
- throws AssemblyException, ActivationException
- {
- Energy4Java zest = new Energy4Java();
- ApplicationDescriptor model = zest.newApplicationModel( new ApplicationAssembler()
- {
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory factory )
- throws AssemblyException
- {
- ApplicationAssembly assembly = factory.newApplicationAssembly();
- assembly.setName( applicationName );
- if( applicationVersion != null )
- {
- assembly.setVersion( applicationVersion );
- }
- if( applicationMode != null )
- {
- assembly.setMode( applicationMode );
- }
- for( Object metaInfo : metaInfos )
- {
- assembly.setMetaInfo( metaInfo );
- }
- HashMap<String, LayerAssembly> createdLayers = new HashMap<>();
- for( Map.Entry<String, LayerDeclaration> entry : layers.entrySet() )
- {
- LayerAssembly layer = entry.getValue().createLayer( assembly );
- createdLayers.put( entry.getKey(), layer );
- }
- for( LayerDeclaration layer : layers.values() )
- {
- layer.initialize( createdLayers );
- }
- return assembly;
- }
- } );
- Application application = model.newInstance( zest.api() );
- for( ActivationEventListener activationListener : activationListeners )
- {
- application.registerActivationEventListener( activationListener );
- }
- beforeActivation();
- application.activate();
- if( passivationShutdownHook )
- {
- Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application ) );
- }
- afterActivation();
- return application;
- }
-
- /**
- * Called before application activation.
- */
- protected void beforeActivation()
- {
- }
-
- /**
- * Called after application activation.
- */
- protected void afterActivation()
- {
- }
-
- @Override
- public void registerActivationEventListener( ActivationEventListener listener )
- {
- activationListeners.add( listener );
- }
-
- @Override
- public void deregisterActivationEventListener( ActivationEventListener listener )
- {
- activationListeners.remove( listener );
- }
-
- /**
- * Declare Layer.
- * @param layerName Name of the Layer
- * @return Layer declaration for the given name, new if did not already exists
- */
- public LayerDeclaration withLayer( String layerName )
- {
- LayerDeclaration layerDeclaration = layers.get( layerName );
- if( layerDeclaration != null )
- {
- return layerDeclaration;
- }
- layerDeclaration = new LayerDeclaration( layerName );
- layers.put( layerName, layerDeclaration );
- return layerDeclaration;
- }
-
- /**
- * Load an ApplicationBuilder from a JSON String.
- * @param json JSON String
- * @return Application Builder loaded from JSON
- * @throws JSONException if unable to read JSON
- * @throws AssemblyException if unable to declare the assembly
- */
- public static ApplicationBuilder fromJson( String json )
- throws JSONException, AssemblyException
- {
- JSONObject root = new JSONObject( json );
- return fromJson( root );
- }
-
- /**
- * Load an ApplicationBuilder from a JSON InputStream.
- * @param json JSON input
- * @return Application Builder loaded from JSON
- * @throws JSONException if unable to read JSON
- * @throws AssemblyException if unable to declare the assembly
- */
- public static ApplicationBuilder fromJson( InputStream json )
- throws JSONException, AssemblyException
- {
- String jsonString = new Scanner( json, "UTF-8" ).useDelimiter( "\\A" ).next();
- return fromJson( jsonString );
- }
-
- /**
- * Load an ApplicationBuilder from a JSONObject.
- * @param root JSON object
- * @return Application Builder loaded from JSON
- * @throws JSONException if unable to read JSON
- * @throws AssemblyException if unable to declare the assembly
- */
- public static ApplicationBuilder fromJson( JSONObject root )
- throws JSONException, AssemblyException
- {
- String applicationName = root.getString( "name" );
- ApplicationBuilder builder = new ApplicationBuilder( applicationName );
- builder.configureWithJson( root );
- return builder;
- }
-
- /** Configures the application struucture from a JSON document.
- *
- * @param root The JSON document root.
- * @throws JSONException if the JSON document isn't valid.
- * @throws AssemblyException if probelms in the Assemblers provided in the JSON document.
- */
- protected void configureWithJson( JSONObject root )
- throws JSONException, AssemblyException
- {
- JSONArray layers = root.optJSONArray( "layers" );
- if( layers != null )
- {
- for( int i = 0; i < layers.length(); i++ )
- {
- JSONObject layerObject = layers.getJSONObject( i );
- String layerName = layerObject.getString( "name" );
- LayerDeclaration layerDeclaration = withLayer( layerName );
- JSONArray using = layerObject.optJSONArray( "uses" );
- if( using != null )
- {
- for( int j = 0; j < using.length(); j++ )
- {
- layerDeclaration.using( using.getString( j ) );
- }
- }
- JSONArray modules = layerObject.optJSONArray( "modules" );
- if( modules != null )
- {
- for( int k = 0; k < modules.length(); k++ )
- {
- JSONObject moduleObject = modules.getJSONObject( k );
- String moduleName = moduleObject.getString( "name" );
- ModuleDeclaration moduleDeclaration = layerDeclaration.withModule( moduleName );
- JSONArray assemblers = moduleObject.optJSONArray( "assemblers" );
- if( assemblers != null )
- {
- for( int m = 0; m < assemblers.length(); m++ )
- {
- String string = assemblers.getString( m );
- moduleDeclaration.withAssembler( string );
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * {@literal main} method that read JSON from STDIN.
- * <p>Passivation exceptions are written to STDERR if any.</p>
- * @param args Unused
- * @throws JSONException if unable to read JSON
- * @throws AssemblyException if the assembly failed
- * @throws ActivationException if the activation failed
- */
- public static void main( String[] args )
- throws JSONException, ActivationException, AssemblyException
- {
- fromJson( System.in ).withPassivationShutdownHook().newApplication();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
deleted file mode 100644
index 710743e..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
+++ /dev/null
@@ -1,111 +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.builder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.StreamSupport;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-/**
- * Provides declared {@link org.apache.zest.api.structure.Layer} information that the {@link ApplicationBuilder} can use.
- */
-public class LayerDeclaration
-{
- private final String layerName;
- private final List<String> using = new ArrayList<>();
- private final Map<String, ModuleDeclaration> modules = new HashMap<>();
- private LayerAssembly layer;
-
- LayerDeclaration( String layerName )
- {
- this.layerName = layerName;
- }
-
- /**
- * Declare using layer.
- * @param layerName Used layer name
- * @return This Layer declaration
- */
- public LayerDeclaration using( String layerName )
- {
- this.using.add( layerName );
- return this;
- }
-
- /**
- * Declare using layers.
- * @param layerNames Used layers names
- * @return This Layer declaration
- */
- public LayerDeclaration using( Iterable<String> layerNames )
- {
- StreamSupport.stream( layerNames.spliterator(), false )
- .forEach( using::add );
- return this;
- }
-
- /**
- * Declare Module.
- * @param moduleName Name of the Module
- * @return Module declaration for the given name, new if did not already exists
- */
- public ModuleDeclaration withModule( String moduleName )
- {
- ModuleDeclaration module = modules.get( moduleName );
- if( module != null )
- {
- return module;
- }
- module = new ModuleDeclaration( moduleName );
- modules.put( moduleName, module );
- return module;
- }
-
- LayerAssembly createLayer( ApplicationAssembly application )
- {
- layer = application.layer( layerName );
- layer.setName( layerName );
- for( ModuleDeclaration module : modules.values() )
- {
- ModuleAssembly assembly = module.createModule( layer );
- }
- return layer;
- }
-
- void initialize( HashMap<String, LayerAssembly> createdLayers )
- throws AssemblyException
- {
- for( String uses : using )
- {
- LayerAssembly usedLayer = createdLayers.get( uses );
- layer.uses( usedLayer );
- }
- for( ModuleDeclaration module : modules.values() )
- {
- module.initialize();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
deleted file mode 100644
index 0a4b5fa..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
+++ /dev/null
@@ -1,168 +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.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.StreamSupport;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-import static java.util.stream.Collectors.toList;
-import static org.apache.zest.api.util.Classes.isAssignableFrom;
-
-/**
- * Provides declared {@link org.apache.zest.api.structure.Module} information that the {@link ApplicationBuilder} can use.
- */
-public class ModuleDeclaration
-{
- private final String moduleName;
- private final List<Assembler> assemblers = new ArrayList<>();
- private ModuleAssembly module;
-
- public ModuleDeclaration( String moduleName )
- {
- this.moduleName = moduleName;
- }
-
- /**
- * Declare Assembler.
- * @param assembler Assembler instance
- * @return This Module declaration
- */
- public ModuleDeclaration withAssembler( Assembler assembler )
- {
- assemblers.add( assembler );
- return this;
- }
-
- /**
- * Declare Assembler.
- * @param classname Assembler class name
- * @return This Module declaration
- * @throws AssemblyException if unable to load class, not an Assembler or unable to instanciate
- */
- public ModuleDeclaration withAssembler( String classname )
- throws AssemblyException
- {
- Class<? extends Assembler> clazz = loadClass( classname );
- return withAssembler( clazz );
- }
-
- /**
- * Declare Assembler.
- * @param assemblerClass Assembler class
- * @return This Module declaration
- * @throws AssemblyException not an Assembler or if unable to instanciate
- */
- public ModuleDeclaration withAssembler( Class<?> assemblerClass )
- throws AssemblyException
- {
- Assembler assembler = createAssemblerInstance( assemblerClass );
- assemblers.add( assembler );
- return this;
- }
-
- /**
- * Declare Assemblers.
- * <p>Declare several Assemblers from an Iterable of Class objects.</p>
- * <p>Typically used along {@link org.apache.zest.bootstrap.ClassScanner}.</p>
- * @param assemblerClasses Assembler classes
- * @return This Module declaration
- * @throws AssemblyException if one of the Class is not an Assembler or unable to instantiate
- */
- public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses )
- throws AssemblyException
- {
- List<Class<?>> notAssemblers = StreamSupport.stream( assemblerClasses.spliterator(), false )
- .filter( isAssignableFrom( Assembler.class ).negate() )
- .collect( toList() );
- if( !notAssemblers.isEmpty() )
- {
- throw new AssemblyException(
- "Classes " + notAssemblers + " are not implementing " + Assembler.class.getName()
- );
- }
- for( Class<?> assemblerClass : assemblerClasses )
- {
- withAssembler( assemblerClass );
- }
- return this;
- }
-
- ModuleAssembly createModule( LayerAssembly layer )
- {
- module = layer.module( moduleName );
- return module;
- }
-
- void initialize()
- throws AssemblyException
- {
- for( Assembler assembler : assemblers )
- {
- assembler.assemble( module );
- }
- }
-
- @SuppressWarnings( "unchecked" )
- private Class<? extends Assembler> loadClass( String classname )
- throws AssemblyException
- {
- Class<?> clazz;
- try
- {
- clazz = getClass().getClassLoader().loadClass( classname );
- }
- catch( Exception e )
- {
- throw new AssemblyException( "Unable to load class " + classname, e );
- }
- if( !Assembler.class.isAssignableFrom( clazz ) )
- {
- throw new AssemblyException(
- "Class " + classname + " is not implementing " + Assembler.class.getName()
- );
- }
- //noinspection unchecked
- return (Class<? extends Assembler>) clazz;
- }
-
- private Assembler createAssemblerInstance( Class<?> assemblerClass )
- throws AssemblyException
- {
- if( !Assembler.class.isAssignableFrom( assemblerClass ) )
- {
- throw new AssemblyException(
- "Class " + assemblerClass + " is not implementing " + Assembler.class.getName()
- );
- }
- try
- {
- return (Assembler) assemblerClass.newInstance();
- }
- catch( Exception e )
- {
- throw new AssemblyException( "Unable to instantiate " + assemblerClass, e );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
deleted file mode 100644
index 6c1ff92..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/package.html
+++ /dev/null
@@ -1,28 +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.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Application Builder.</h2>
- <p>
- Generic ApplicationBuilder, which simplifies the creation of Application Structure, either by a fluid DSL
- or from a JSON file.
- </p>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/identity/DefaultIdentityGeneratorAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/identity/DefaultIdentityGeneratorAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/identity/DefaultIdentityGeneratorAssembler.java
deleted file mode 100644
index 94b9f3b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/identity/DefaultIdentityGeneratorAssembler.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.identity;
-
-import org.apache.zest.api.identity.IdentityGenerator;
-import org.apache.zest.api.identity.UuidGeneratorMixin;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public class DefaultIdentityGeneratorAssembler
- implements Assembler
-{
-
- @Override
- public void assemble(ModuleAssembly module)
- throws AssemblyException
- {
- module.services(IdentityGenerator.class).withMixins(UuidGeneratorMixin.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/IllegalLayerAssemblerException.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/IllegalLayerAssemblerException.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/IllegalLayerAssemblerException.java
deleted file mode 100644
index 0b62ae0..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/IllegalLayerAssemblerException.java
+++ /dev/null
@@ -1,31 +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.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-
-public class IllegalLayerAssemblerException extends AssemblyException
-{
- public IllegalLayerAssemblerException( String message )
- {
- super( message );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
deleted file mode 100644
index b6b0dd0..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayerAssembler.java
+++ /dev/null
@@ -1,29 +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.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public interface LayerAssembler
-{
- LayerAssembly assemble( LayerAssembly layer )
- throws AssemblyException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
deleted file mode 100644
index 809b01e..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredApplicationAssembler.java
+++ /dev/null
@@ -1,297 +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.layered;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.activation.PassivationException;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.LayerAssembly;
-
-public abstract class LayeredApplicationAssembler
- implements ApplicationAssembler
-{
- protected final Energy4Java zest;
- protected final String name;
- protected final String version;
-
- private final Application.Mode mode;
- private final HashMap<Class<? extends LayerAssembler>, LayerAssembler> assemblers = new HashMap<>();
-
- private ApplicationAssembly assembly;
- protected ApplicationDescriptor model;
- protected Application application;
-
- public LayeredApplicationAssembler( String name, String version, Application.Mode mode )
- throws AssemblyException
- {
- this.name = name;
- this.version = version;
- this.mode = mode;
- zest = new Energy4Java();
- }
-
- public void initialize()
- throws AssemblyException
- {
- model = zest.newApplicationModel( this );
- onModelCreated( model );
- instantiateApplication( zest, model );
- }
-
- public ApplicationAssembly assembly()
- {
- return assembly;
- }
-
- /**
- * This method is called from the <code>initialize</code> method to instantiate the Polygene application from the
- * application model.
- *
- * <p>
- * The default implementation simply calls;
- * </p>
- * <pre><code>
- * application = model.newInstance( zest.spi() );
- * </code></pre>
- *
- * @param zest The Polygene runtime engine.
- * @param model The application model descriptor.
- */
- protected void instantiateApplication( Energy4Java zest, ApplicationDescriptor model )
- {
- application = model.newInstance( zest.spi() );
- }
-
- /**
- * This method is called after the Application Model has been created, before the instantiation of the Polygene
- * application.
- *
- * <p>
- * The default implementation does nothing. Applications may have advanced features to inspect or
- * modify the model prior to instantiation, and this is the place where such advanced manipulation is
- * expected to take place.
- * </p>
- *
- * @param model The model that has just been created.
- */
- protected void onModelCreated( ApplicationDescriptor model )
- {
- }
-
- public ApplicationDescriptor model()
- {
- return model;
- }
-
- public Application application()
- {
- return application;
- }
-
- public void start()
- throws ActivationException
- {
- application.activate();
- }
-
- public void stop()
- throws PassivationException
- {
- application.passivate();
- }
-
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
- throws AssemblyException
- {
- assembly = applicationFactory.newApplicationAssembly();
- assembly.setName( name );
- assembly.setVersion( version );
- assembly.setMode( mode );
- assembleLayers( assembly );
- return assembly;
- }
-
- protected LayerAssembly createLayer( Class<? extends LayerAssembler> layerAssemblerClass )
- throws IllegalArgumentException
- {
- try
- {
- String classname = layerAssemblerClass.getSimpleName();
- if( classname.endsWith( "Layer" ) )
- {
- classname = classname.substring( 0, classname.length() - 5 ) + " Layer";
- }
- setNameIfPresent( layerAssemblerClass, classname );
- LayerAssembly layer = assembly.layer( classname );
-
- LayerAssembler layerAssembler = instantiateLayerAssembler( layerAssemblerClass, layer );
- assemblers.put( layerAssemblerClass, layerAssembler );
- assembleLayer( layerAssembler, layer );
- return layer;
- }
- catch( Exception e )
- {
- throw new IllegalArgumentException( "Unable to instantiate layer with " + layerAssemblerClass.getSimpleName(), e );
- }
- }
-
- protected void assembleLayer( LayerAssembler layerAssembler, LayerAssembly layer )
- throws AssemblyException
- {
- layerAssembler.assemble( layer );
- }
-
- protected <T extends LayerAssembler> LayerAssembler instantiateLayerAssembler( Class<T> layerAssemblerClass,
- LayerAssembly layer
- )
- throws InstantiationException, IllegalAccessException, InvocationTargetException, IllegalLayerAssemblerException
- {
- LayerAssembler assembler = createWithFactoryMethod( layerAssemblerClass, layer );
- if( assembler != null )
- {
- return assembler;
- }
- assembler = createWithConstructor( layerAssemblerClass, layer );
- if( assembler != null )
- {
- return assembler;
- }
- throw new IllegalLayerAssemblerException( "No matching factory method nor constructor found in " + layerAssemblerClass );
- }
-
- private LayerAssembler createWithFactoryMethod( Class<? extends LayerAssembler> layerAssemblerClass,
- LayerAssembly layer
- )
- throws InvocationTargetException, IllegalAccessException
- {
- try
- {
- Method factoryMethod = layerAssemblerClass.getDeclaredMethod( "create", LayerAssembly.class );
- factoryMethod.setAccessible( true );
- int modifiers = factoryMethod.getModifiers();
- if( Modifier.isStatic( modifiers ) && LayerAssembler.class.isAssignableFrom( factoryMethod.getReturnType() ) )
- {
- return (LayerAssembler) factoryMethod.invoke( null, layer );
- }
- }
- catch( NoSuchMethodException e )
- {
- try
- {
- Method factoryMethod = layerAssemblerClass.getDeclaredMethod( "create" );
- factoryMethod.setAccessible( true );
- int modifiers = factoryMethod.getModifiers();
- if( Modifier.isStatic( modifiers ) && LayerAssembler.class.isAssignableFrom( factoryMethod.getReturnType() ) )
- {
- return (LayerAssembler) factoryMethod.invoke( null );
- }
- }
- catch( NoSuchMethodException e1 )
- {
- }
- }
- return null;
- }
-
- private LayerAssembler createWithConstructor( Class<? extends LayerAssembler> layerAssemblerClass,
- LayerAssembly assembly
- )
- throws IllegalAccessException, InvocationTargetException, InstantiationException
- {
- try
- {
- Constructor<? extends LayerAssembler> constructor = layerAssemblerClass.getConstructor( LayerAssembly.class );
- if( constructor != null )
- {
- constructor.setAccessible( true );
- return constructor.newInstance( assembly );
- }
- }
- catch( NoSuchMethodException e )
- {
- try
- {
- Constructor<? extends LayerAssembler> constructor = layerAssemblerClass.getDeclaredConstructor();
- if( constructor != null )
- {
- constructor.setAccessible( true );
- System.out.println(constructor);
- return constructor.newInstance();
- }
- }
- catch( NoSuchMethodException e1 )
- {
- return null;
- }
- }
- return null;
- }
-
- static void setNameIfPresent( Class<?> clazz, String classname )
- throws IllegalAccessException
- {
- try
- {
- Field field = clazz.getDeclaredField( "NAME" );
- if( Modifier.isStatic( field.getModifiers() ) )
- {
- field.setAccessible( true );
- field.set( null, classname );
- }
- }
- catch( Exception e )
- {
- // Ignore and consider normal.
- }
- }
-
- @SuppressWarnings( "unchecked" )
- protected <T extends LayerAssembler> T assemblerOf( Class<T> layerAssemblerClass )
- {
- return (T) assemblers.get( layerAssemblerClass );
- }
-
- /**
- * Called from the <code>assemble</code> method to assemble the layers in the application.
- *
- * <p>
- * This method must be implemented, and is typically a list of LayerAssembler instantiations, followed
- * by {@link LayerAssembly#uses(LayerAssembly...)} declarations.
- * </p>
- *
- * @param assembly Application assembly
- * @throws AssemblyException on invalid assembly
- */
- protected abstract void assembleLayers( ApplicationAssembly assembly )
- throws AssemblyException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
deleted file mode 100644
index 62f8bc7..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/LayeredLayerAssembler.java
+++ /dev/null
@@ -1,90 +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.layered;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public abstract class LayeredLayerAssembler
- implements LayerAssembler
-{
- private HashMap<Class<? extends ModuleAssembler>, ModuleAssembler> assemblers = new HashMap<>();
-
- protected ModuleAssembly createModule( LayerAssembly layer, Class<? extends ModuleAssembler> moduleAssemblerClass )
- {
- try
- {
- ModuleAssembler moduleAssembler = instantiateAssembler( layer, moduleAssemblerClass );
- String moduleName = createModuleName( moduleAssemblerClass );
- LayeredApplicationAssembler.setNameIfPresent( moduleAssemblerClass, moduleName );
- ModuleAssembly module = layer.module( moduleName );
- assemblers.put( moduleAssemblerClass, moduleAssembler );
- ModuleAssembly assembly = moduleAssembler.assemble( layer, module );
- if( assembly == null )
- {
- return module;
- }
- return assembly;
- }
- catch( Exception e )
- {
- throw new IllegalArgumentException( "Unable to instantiate module with " + moduleAssemblerClass.getSimpleName(), e );
- }
- }
-
- protected String createModuleName( Class<? extends ModuleAssembler> modulerAssemblerClass )
- {
- String moduleName = modulerAssemblerClass.getSimpleName();
- if( moduleName.endsWith( "Module" ) )
- {
- moduleName = moduleName.substring( 0, moduleName.length() - 6 ) + " Module";
- }
- return moduleName;
- }
-
- protected ModuleAssembler instantiateAssembler( LayerAssembly layer,
- Class<? extends ModuleAssembler> modulerAssemblerClass
- )
- throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException
- {
- ModuleAssembler moduleAssembler;
- try
- {
- Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getDeclaredConstructor( ModuleAssembly.class );
- assemblyConstructor.setAccessible( true );
- moduleAssembler = assemblyConstructor.newInstance( layer );
- }
- catch( NoSuchMethodException e )
- {
- Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getDeclaredConstructor();
- assemblyConstructor.setAccessible( true );
- moduleAssembler = assemblyConstructor.newInstance();
- }
- return moduleAssembler;
- }
-
- @SuppressWarnings( "unchecked" )
- protected <T extends ModuleAssembler> T assemblerOf( Class<T> moduleAssemblerType )
- {
- return (T) assemblers.get( moduleAssemblerType );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.java
deleted file mode 100644
index 1b416c8..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/ModuleAssembler.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.layered;
-
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public interface ModuleAssembler
-{
- ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
- throws AssemblyException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
deleted file mode 100644
index 0b8300b..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/layered/package.html
+++ /dev/null
@@ -1,24 +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.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Layered Assembly.</h2>
- </body>
-</html>