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:39 UTC
[03/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/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
deleted file mode 100644
index 5cf8ab3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/association/NamedAssociationsModel.java
+++ /dev/null
@@ -1,130 +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.runtime.association;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Member;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.stream.Stream;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.util.HierarchicalVisitor;
-import org.apache.zest.api.util.VisitableHierarchy;
-import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
-import org.apache.zest.runtime.value.ValueStateInstance;
-import org.apache.zest.spi.entity.EntityState;
-
-/**
- * Model for NamedAssociations.
- */
-public final class NamedAssociationsModel
- implements VisitableHierarchy<NamedAssociationsModel, NamedAssociationModel>
-{
- private final Map<AccessibleObject, NamedAssociationModel> mapAccessorAssociationModel = new LinkedHashMap<>();
-
- public NamedAssociationsModel()
- {
- }
-
- public Stream<NamedAssociationModel> namedAssociations()
- {
- return mapAccessorAssociationModel.values().stream();
- }
-
- public void addNamedAssociation( NamedAssociationModel model )
- {
- mapAccessorAssociationModel.put( model.accessor(), model );
- }
-
- @Override
- public <ThrowableType extends Throwable> boolean accept( HierarchicalVisitor<? super NamedAssociationsModel, ? super NamedAssociationModel, ThrowableType> visitor )
- throws ThrowableType
- {
- if( visitor.visitEnter( this ) )
- {
- for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
- {
- if( !associationModel.accept( visitor ) )
- {
- break;
- }
- }
- }
- return visitor.visitLeave( this );
- }
-
- public <T> NamedAssociation<T> newInstance( AccessibleObject accessor,
- EntityState entityState,
- ModuleUnitOfWork uow )
- {
- return mapAccessorAssociationModel.get( accessor ).newInstance( uow, entityState );
- }
-
- public NamedAssociationModel getNamedAssociation( AccessibleObject accessor )
- throws IllegalArgumentException
- {
- if( false )
- {
- return (NamedAssociationModel) getNamedAssociationByName( QualifiedName.fromAccessor( accessor ).name() );
- }
- NamedAssociationModel namedAssociationModel = mapAccessorAssociationModel.get( accessor );
- if( namedAssociationModel == null )
- {
- throw new IllegalArgumentException( "No named-association found with name:" + ( (Member) accessor ).getName() );
- }
- return namedAssociationModel;
- }
-
- public AssociationDescriptor getNamedAssociationByName( String name )
- throws IllegalArgumentException
- {
- for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
- {
- if( associationModel.qualifiedName().name().equals( name ) )
- {
- return associationModel;
- }
- }
- throw new IllegalArgumentException( "No named-association found with name:" + name );
- }
-
- public AssociationDescriptor getNamedAssociationByQualifiedName( QualifiedName name )
- throws IllegalArgumentException
- {
- for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
- {
- if( associationModel.qualifiedName().equals( name ) )
- {
- return associationModel;
- }
- }
- throw new IllegalArgumentException( "No named-association found with qualified name:" + name );
- }
-
- public void checkConstraints( ValueStateInstance state )
- {
- for( NamedAssociationModel associationModel : mapAccessorAssociationModel.values() )
- {
- associationModel.checkAssociationConstraints( state.namedAssociationFor( associationModel.accessor() ) );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
deleted file mode 100644
index 162c7ca..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AndAppliesToFilter.java
+++ /dev/null
@@ -1,47 +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.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class AndAppliesToFilter
- implements AppliesToFilter
-{
- private final AppliesToFilter left;
- private final AppliesToFilter right;
-
- AndAppliesToFilter( AppliesToFilter left, AppliesToFilter right )
- {
- this.left = left;
- this.right = right;
- }
-
- @Override
- public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
- {
- return left.appliesTo( method, mixin, compositeType, fragmentClass ) &&
- right.appliesTo( method, mixin, compositeType, fragmentClass );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
deleted file mode 100644
index 17912b0..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AnnotationAppliesToFilter.java
+++ /dev/null
@@ -1,47 +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.runtime.bootstrap;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesToFilter;
-
-/**
- * JAVADOC
- */
-final class AnnotationAppliesToFilter
- implements AppliesToFilter
-{
- @SuppressWarnings( "raw" )
- private final Class annotationType;
-
- @SuppressWarnings( "raw" )
- AnnotationAppliesToFilter( Class type )
- {
- this.annotationType = type;
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass )
- {
- return method.getAnnotation( annotationType ) != null;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
deleted file mode 100644
index 20c4fe1..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyFactoryImpl.java
+++ /dev/null
@@ -1,79 +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.runtime.bootstrap;
-
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-/**
- * Factory for ApplicationAssembly.
- */
-public final class ApplicationAssemblyFactoryImpl
- implements ApplicationAssemblyFactory
-{
- @Override
- public ApplicationAssembly newApplicationAssembly( Assembler assembler )
- throws AssemblyException
- {
- return newApplicationAssembly( new Assembler[][][]{ { { assembler } } } );
- }
-
- @Override
- public ApplicationAssembly newApplicationAssembly( Assembler[][][] assemblers )
- throws AssemblyException
- {
- ApplicationAssembly applicationAssembly = newApplicationAssembly();
-
- // Build all layers bottom-up
- LayerAssembly below = null;
- for( int layer = assemblers.length - 1; layer >= 0; layer-- )
- {
- // Create Layer
- LayerAssembly layerAssembly = applicationAssembly.layer( "Layer " + ( layer + 1 ) );
- for( int module = 0; module < assemblers[ layer ].length; module++ )
- {
- // Create Module
- ModuleAssembly moduleAssembly = layerAssembly.module( "Module " + ( module + 1 ) );
- for( Assembler assembler : assemblers[ layer ][ module ] )
- {
- // Register Assembler
- assembler.assemble( moduleAssembly );
- }
- }
- if( below != null )
- {
- layerAssembly.uses( below ); // Link layers
- }
- below = layerAssembly;
- }
- return applicationAssembly;
- }
-
- @Override
- public ApplicationAssembly newApplicationAssembly()
- {
- return new ApplicationAssemblyImpl();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
deleted file mode 100644
index 02476f9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationAssemblyImpl.java
+++ /dev/null
@@ -1,157 +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.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.zest.api.activation.Activator;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.AssemblyVisitor;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-/**
- * The representation of an entire application. From
- * this you can set information about the application
- * and create LayerAssemblies.
- */
-public final class ApplicationAssemblyImpl
- implements ApplicationAssembly
-{
- private final Map<String, LayerAssemblyImpl> layerAssemblies = new LinkedHashMap<>();
- private String name = "Application";
- private String version = "1.0"; // Default version
- private Application.Mode mode;
- private final MetaInfo metaInfo = new MetaInfo();
- private final List<Class<? extends Activator<Application>>> activators = new ArrayList<>();
-
- public ApplicationAssemblyImpl()
- {
- mode = Application.Mode.valueOf( System.getProperty( "mode", "production" ) );
- }
-
- @Override
- public LayerAssembly layer( String name )
- {
- if( name != null )
- {
- LayerAssemblyImpl existing = layerAssemblies.get( name );
- if( existing != null )
- {
- return existing;
- }
- }
- LayerAssemblyImpl layerAssembly = new LayerAssemblyImpl( this, name );
- layerAssemblies.put( name, layerAssembly );
- return layerAssembly;
- }
-
- @Override
- public ModuleAssembly module( String layerName, String moduleName )
- {
- return layer( layerName ).module( moduleName );
- }
-
- @Override
- public ApplicationAssembly setName( String name )
- {
- this.name = name;
- return this;
- }
-
- @Override
- public ApplicationAssembly setVersion( String version )
- {
- this.version = version;
- return this;
- }
-
- @Override
- public ApplicationAssembly setMode( Application.Mode mode )
- {
- this.mode = mode;
- return this;
- }
-
- @Override
- public ApplicationAssembly setMetaInfo( Object info )
- {
- metaInfo.set( info );
- return this;
- }
-
- @Override
- @SafeVarargs
- public final ApplicationAssembly withActivators( Class<? extends Activator<Application>>... activators )
- {
- this.activators.addAll( Arrays.asList( activators ) );
- return this;
- }
-
- @Override
- public <ThrowableType extends Throwable> void visit( AssemblyVisitor<ThrowableType> visitor )
- throws ThrowableType
- {
- visitor.visitApplication( this );
- for( LayerAssemblyImpl layerAssembly : layerAssemblies.values() )
- {
- layerAssembly.visit( visitor );
- }
- }
-
- public Collection<LayerAssemblyImpl> layerAssemblies()
- {
- return layerAssemblies.values();
- }
-
- public List<Class<? extends Activator<Application>>> activators()
- {
- return activators;
- }
-
- public MetaInfo metaInfo()
- {
- return metaInfo;
- }
-
- @Override
- public String name()
- {
- return name;
- }
-
- public String version()
- {
- return version;
- }
-
- @Override
- public Application.Mode mode()
- {
- return mode;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
deleted file mode 100644
index ed22f92..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ApplicationModelFactoryImpl.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.runtime.bootstrap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.zest.api.composite.ModelDescriptor;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.api.structure.Layer;
-import org.apache.zest.api.util.HierarchicalVisitor;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationModelFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.runtime.activation.ActivatorsModel;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.injection.InjectedFieldModel;
-import org.apache.zest.runtime.model.Binder;
-import org.apache.zest.runtime.model.Resolution;
-import org.apache.zest.runtime.structure.ApplicationModel;
-import org.apache.zest.runtime.structure.LayerModel;
-import org.apache.zest.runtime.structure.ModuleModel;
-import org.apache.zest.runtime.structure.UsedLayersModel;
-
-/**
- * Factory for Applications.
- */
-public final class ApplicationModelFactoryImpl
- implements ApplicationModelFactory
-{
- @Override
- public ApplicationDescriptor newApplicationModel( ApplicationAssembly assembly )
- throws AssemblyException
- {
- AssemblyHelper helper = createAssemblyHelper( assembly );
-
- ApplicationAssemblyImpl applicationAssembly = (ApplicationAssemblyImpl) assembly;
- ActivatorsModel<Application> applicationActivators = new ActivatorsModel<>( applicationAssembly.activators() );
- List<LayerModel> layerModels = new ArrayList<>();
- final ApplicationModel applicationModel = new ApplicationModel( applicationAssembly.name(),
- applicationAssembly.version(),
- applicationAssembly.mode(),
- applicationAssembly.metaInfo(),
- applicationActivators,
- layerModels );
- Map<LayerAssembly, LayerModel> mapAssemblyModel = new HashMap<>();
- Map<LayerAssembly, List<LayerModel>> mapUsedLayers = new HashMap<>();
-
- // Build all layers
- List<LayerAssemblyImpl> layerAssemblies = new ArrayList<>( applicationAssembly.layerAssemblies() );
- for( LayerAssemblyImpl layerAssembly : layerAssemblies )
- {
- List<LayerModel> usedLayers = new ArrayList<>();
- mapUsedLayers.put( layerAssembly, usedLayers );
-
- UsedLayersModel usedLayersModel = new UsedLayersModel( usedLayers );
- List<ModuleModel> moduleModels = new ArrayList<>();
- String name = layerAssembly.name();
- if( name == null )
- {
- throw new AssemblyException( "Layer must have name set" );
- }
- ActivatorsModel<Layer> layerActivators = new ActivatorsModel<>( layerAssembly.activators() );
- LayerModel layerModel = new LayerModel( name, layerAssembly.metaInfo(), usedLayersModel, layerActivators, moduleModels );
-
- for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() )
- {
- moduleModels.add( moduleAssembly.assembleModule( layerModel, helper ) );
- }
- mapAssemblyModel.put( layerAssembly, layerModel );
- layerModels.add( layerModel );
- }
-
- // Populate used layer lists
- for( LayerAssemblyImpl layerAssembly : layerAssemblies )
- {
- Set<LayerAssembly> usesLayers = layerAssembly.uses();
- List<LayerModel> usedLayers = mapUsedLayers.get( layerAssembly );
- for( LayerAssembly usesLayer : usesLayers )
- {
- LayerModel layerModel = mapAssemblyModel.get( usesLayer );
- usedLayers.add( layerModel );
- }
- }
-
- // Bind model
- // This will resolve all dependencies
- try
- {
-// applicationModel.bind();
- applicationModel.accept( new BindingVisitor( applicationModel ) );
- }
- catch( BindingException e )
- {
- throw new AssemblyException( "Unable to bind: " + applicationModel, e );
- }
-
- return applicationModel;
- }
-
- private AssemblyHelper createAssemblyHelper( ApplicationAssembly assembly )
- {
- if( assembly instanceof ApplicationAssemblyImpl )
- {
- ApplicationAssemblyImpl impl = (ApplicationAssemblyImpl) assembly;
- AssemblyHelper helper = impl.metaInfo().get( AssemblyHelper.class );
- if( helper != null )
- {
- return helper;
- }
- }
- return new AssemblyHelper();
- }
-
- private static class BindingVisitor
- implements HierarchicalVisitor<Object, Object, BindingException>
- {
- private LayerModel layer;
- private ModuleModel module;
- private ModelDescriptor objectDescriptor;
- private CompositeMethodModel compositeMethodModel;
-
- private Resolution resolution;
- private final ApplicationModel applicationModel;
-
- private BindingVisitor( ApplicationModel applicationModel )
- {
- this.applicationModel = applicationModel;
- }
-
- @Override
- public boolean visitEnter( Object visited )
- throws BindingException
- {
- if( visited instanceof Binder )
- {
- Binder binder = (Binder) visited;
- binder.bind( resolution );
-
- return false;
- }
- else if( visited instanceof CompositeMethodModel )
- {
- compositeMethodModel = (CompositeMethodModel) visited;
- resolution = new Resolution( applicationModel, layer, module, objectDescriptor, compositeMethodModel, null );
- }
- else if( visited instanceof ModelDescriptor )
- {
- objectDescriptor = (ModelDescriptor) visited;
- resolution = new Resolution( applicationModel, layer, module, objectDescriptor, null, null );
- }
- else if( visited instanceof InjectedFieldModel )
- {
- InjectedFieldModel fieldModel = (InjectedFieldModel) visited;
- fieldModel.bind( new Resolution( applicationModel, layer, module,
- objectDescriptor, compositeMethodModel, fieldModel.field() ) );
- }
- else if( visited instanceof ModuleModel )
- {
- module = (ModuleModel) visited;
- }
- else if( visited instanceof LayerModel )
- {
- layer = (LayerModel) visited;
- }
-
- return true;
- }
-
- @Override
- public boolean visitLeave( Object visited )
- throws BindingException
- {
- return true;
- }
-
- @Override
- public boolean visit( Object visited )
- throws BindingException
- {
- if( visited instanceof Binder )
- {
- ( (Binder) visited ).bind( resolution );
- }
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
deleted file mode 100644
index e181c8b..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java
+++ /dev/null
@@ -1,214 +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.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.common.AppliesToFilter;
-import org.apache.zest.api.common.ConstructionException;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.runtime.composite.ConcernModel;
-import org.apache.zest.runtime.composite.ConstraintDeclaration;
-import org.apache.zest.runtime.composite.FragmentClassLoader;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.SideEffectModel;
-
-/**
- * This helper is used when building the application model. It keeps track
- * of already created classloaders and various models
- */
-@SuppressWarnings("WeakerAccess")
-public class AssemblyHelper
-{
- private Map<Class, Class> instantiationClasses = new HashMap<>();
- private Map<Class, ConstraintDeclaration> constraintDeclarations = new HashMap<>();
- private Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>();
- private Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>();
-
- protected MixinModel getMixinModel(Class mixinClass)
- {
- return new MixinModel( mixinClass, instantiationClass( mixinClass ) );
- }
-
- protected ConcernModel getConcernModel(Class concernClass)
- {
- return new ConcernModel( concernClass, instantiationClass( concernClass ) );
- }
-
- protected SideEffectModel getSideEffectModel(Class sideEffectClass)
- {
- return new SideEffectModel( sideEffectClass, instantiationClass( sideEffectClass ) );
- }
-
- protected Class instantiationClass(Class fragmentClass)
- {
- Class instantiationClass = fragmentClass;
- if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
- {
- instantiationClass = instantiationClasses.get( fragmentClass );
-
- if( instantiationClass == null )
- {
- try
- {
- FragmentClassLoader fragmentLoader = getModifierClassLoader( fragmentClass.getClassLoader() );
- instantiationClass = fragmentLoader.loadFragmentClass( fragmentClass );
- instantiationClasses.put( fragmentClass, instantiationClass );
- }
- catch( ClassNotFoundException | VerifyError e )
- {
- throw new ConstructionException( "Could not generate mixin subclass " + fragmentClass.getName(), e );
- }
- }
- }
- return instantiationClass;
- }
-
- protected FragmentClassLoader getModifierClassLoader( ClassLoader classLoader )
- {
- FragmentClassLoader cl = modifierClassLoaders.get( classLoader );
- if( cl == null )
- {
- cl = instantiateFragmentClassLoader( classLoader );
- modifierClassLoaders.put( classLoader, cl );
- }
- return cl;
- }
-
- protected FragmentClassLoader instantiateFragmentClassLoader( ClassLoader classLoader )
- {
- return new FragmentClassLoader( classLoader );
- }
-
- public boolean appliesTo( Class<?> fragmentClass, Method method, Iterable<Class<?>> types, Class<?> mixinClass )
- {
- AppliesToFilter appliesToFilter = appliesToInstances.get( fragmentClass );
- if( appliesToFilter == null )
- {
- appliesToFilter = createAppliesToFilter( fragmentClass );
- appliesToInstances.put( fragmentClass, appliesToFilter );
- }
- for( Class<?> compositeType : types )
- {
- if( appliesToFilter.appliesTo( method, mixinClass, compositeType, fragmentClass ) )
- {
- return true;
- }
- }
- return false;
- }
-
- protected AppliesToFilter createAppliesToFilter( Class<?> fragmentClass )
- {
- AppliesToFilter result = null;
- if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) )
- {
- result = new TypedFragmentAppliesToFilter();
- if( Modifier.isAbstract( fragmentClass.getModifiers() ) )
- {
- result = new AndAppliesToFilter( result, new ImplementsMethodAppliesToFilter() );
- }
- }
- result = applyAppliesTo( result, fragmentClass );
- if( result == null )
- {
- return AppliesToFilter.ALWAYS;
- }
- return result;
- }
-
- protected AppliesToFilter applyAppliesTo( AppliesToFilter existing, Class<?> modifierClass )
- {
- AppliesTo appliesTo = modifierClass.getAnnotation( AppliesTo.class );
- if( appliesTo != null )
- {
- // Use "or" for all filters specified in the annotation
- AppliesToFilter appliesToAnnotation = null;
- for( Class<?> appliesToClass : appliesTo.value() )
- {
- AppliesToFilter filter;
- if( AppliesToFilter.class.isAssignableFrom( appliesToClass ) )
- {
- try
- {
- @SuppressWarnings("unchecked")
- Constructor<AppliesToFilter> cons = (Constructor<AppliesToFilter>) appliesToClass.getDeclaredConstructor();
- cons.setAccessible(true);
- filter = cons.newInstance();
- }
- catch( Exception e )
- {
- throw new ConstructionException( e );
- }
- }
- else if( Annotation.class.isAssignableFrom( appliesToClass ) )
- {
- filter = new AnnotationAppliesToFilter( appliesToClass );
- }
- else // Type check
- {
- filter = new TypeCheckAppliesToFilter( appliesToClass );
- }
-
- if( appliesToAnnotation == null )
- {
- appliesToAnnotation = filter;
- }
- else
- {
- appliesToAnnotation = new OrAppliesToFilter( appliesToAnnotation, filter );
- }
- }
- // Add to the rest of the rules using "and"
- if( existing == null )
- {
- return appliesToAnnotation;
- }
- else
- {
- return new AndAppliesToFilter( existing, appliesToAnnotation );
- }
- }
- return existing;
- }
-
- public boolean appliesTo( Class<? extends Constraint<?, ?>> constraint,
- Class<? extends Annotation> annotationType,
- Type valueType
- )
- {
- ConstraintDeclaration constraintDeclaration = constraintDeclarations.get( constraint );
- if( constraintDeclaration == null )
- {
- constraintDeclaration = new ConstraintDeclaration( constraint );
- constraintDeclarations.put( constraint, constraintDeclaration );
- }
-
- return constraintDeclaration.appliesTo( annotationType, valueType );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
deleted file mode 100644
index c9ee5b3..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
+++ /dev/null
@@ -1,909 +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.runtime.bootstrap;
-
-import java.lang.annotation.Annotation;
-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.Modifier;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.GenericAssociationInfo;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.MetaInfo;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.composite.InvalidCompositeException;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.constraint.ConstraintDeclaration;
-import org.apache.zest.api.constraint.Constraints;
-import org.apache.zest.api.constraint.Name;
-import org.apache.zest.api.entity.Lifecycle;
-import org.apache.zest.api.injection.scope.State;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Initializable;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.GenericPropertyInfo;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.sideeffect.SideEffects;
-import org.apache.zest.api.type.HasTypes;
-import org.apache.zest.api.util.Annotations;
-import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Fields;
-import org.apache.zest.api.util.HierarchicalVisitorAdapter;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.runtime.association.AssociationModel;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.AbstractConstraintModel;
-import org.apache.zest.runtime.composite.CompositeConstraintModel;
-import org.apache.zest.runtime.composite.CompositeMethodModel;
-import org.apache.zest.runtime.composite.CompositeMethodsModel;
-import org.apache.zest.runtime.composite.ConcernModel;
-import org.apache.zest.runtime.composite.ConcernsModel;
-import org.apache.zest.runtime.composite.ConstraintModel;
-import org.apache.zest.runtime.composite.ConstraintsModel;
-import org.apache.zest.runtime.composite.Genericpredicate;
-import org.apache.zest.runtime.composite.MixinModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.SideEffectModel;
-import org.apache.zest.runtime.composite.SideEffectsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.composite.ValueConstraintsInstance;
-import org.apache.zest.runtime.composite.ValueConstraintsModel;
-import org.apache.zest.runtime.injection.Dependencies;
-import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.runtime.property.PropertiesModel;
-import org.apache.zest.runtime.property.PropertyModel;
-
-import static java.util.stream.Stream.concat;
-import static org.apache.zest.api.util.Annotations.isType;
-import static org.apache.zest.api.util.Annotations.typeHasAnnotation;
-import static org.apache.zest.api.util.Classes.classHierarchy;
-import static org.apache.zest.api.util.Classes.interfacesOf;
-import static org.apache.zest.api.util.Classes.isAssignableFrom;
-import static org.apache.zest.api.util.Classes.typeOf;
-import static org.apache.zest.api.util.Classes.typesOf;
-import static org.apache.zest.api.util.Classes.wrapperClass;
-
-/**
- * Declaration of a Composite.
- */
-public abstract class CompositeAssemblyImpl
- implements HasTypes
-{
- protected List<Class<?>> concerns = new ArrayList<>();
- protected List<Class<?>> sideEffects = new ArrayList<>();
- protected List<Class<?>> mixins = new ArrayList<>();
- protected List<Class<?>> types = new ArrayList<>();
- protected MetaInfo metaInfo = new MetaInfo();
- protected Visibility visibility = Visibility.module;
-
- protected boolean immutable;
- protected PropertiesModel propertiesModel;
- protected StateModel stateModel;
- protected MixinsModel mixinsModel;
- protected CompositeMethodsModel compositeMethodsModel;
- private AssemblyHelper helper;
- protected StateDeclarations stateDeclarations;
-
- protected Set<String> registeredStateNames = new HashSet<>();
-
- public CompositeAssemblyImpl( Class<?> mainType )
- {
- types.add( mainType );
- }
-
- @Override
- public Stream<Class<?>> types()
- {
- return types.stream();
- }
-
- protected StateModel createStateModel()
- {
- return new StateModel( propertiesModel );
- }
-
- protected MixinsModel createMixinsModel()
- {
- return new MixinsModel();
- }
-
- protected void buildComposite( AssemblyHelper helper,
- StateDeclarations stateDeclarations
- )
- {
- this.stateDeclarations = stateDeclarations;
- this.helper = helper;
- for( Class<?> compositeType : types )
- {
- metaInfo = new MetaInfo( metaInfo ).withAnnotations( compositeType );
- addAnnotationsMetaInfo( compositeType, metaInfo );
- }
-
- immutable = metaInfo.get( Immutable.class ) != null;
- propertiesModel = new PropertiesModel();
- stateModel = createStateModel();
- mixinsModel = createMixinsModel();
-// compositeMethodsModel = new CompositeMethodsModel();
- compositeMethodsModel = new CompositeMethodsModel( mixinsModel );
-
- // Implement composite methods
- List<Class<?>> constraintClasses = toList( constraintDeclarations( getAllTypes() ) );
- List<Class<?>> concernClasses = toList( concat( concerns.stream(), concernDeclarations( getAllTypes() ) ) );
- List<Class<?>> sideEffectClasses = toList( concat( sideEffects.stream(), sideEffectDeclarations( getAllTypes() ) ) );
- List<Class<?>> mixinClasses = toList( concat( mixins.stream(), mixinDeclarations( getAllTypes() ) ) );
- //noinspection unchecked
- implementMixinType( types,
- constraintClasses,
- concernClasses,
- sideEffectClasses,
- mixinClasses
- );
-
- // Add state from methods and fields
- //noinspection unchecked
- addState( constraintClasses );
- }
-
- private List<Class<?>> toList( Stream<Class<?>> stream )
- {
- return stream.collect( Collectors.toList() );
- }
-
- protected void addAnnotationsMetaInfo( Class<?> type, MetaInfo compositeMetaInfo )
- {
- Class[] declaredInterfaces = type.getInterfaces();
- for( int i = declaredInterfaces.length - 1; i >= 0; i-- )
- {
- addAnnotationsMetaInfo( declaredInterfaces[ i ], compositeMetaInfo );
- }
- compositeMetaInfo.withAnnotations( type );
- }
-
- protected void implementMixinType( List<? extends Class<?>> types,
- List<Class<?>> constraintClasses,
- List<Class<?>> concernClasses,
- List<Class<?>> sideEffectClasses,
- List<Class<?>> mixinClasses
- )
- {
- Set<Class<?>> thisDependencies = new HashSet<>();
- types.forEach( mixinType -> {
- for( Method method : mixinType.getMethods() )
- {
- if( !compositeMethodsModel.isImplemented( method )
- && !Proxy.class.equals( method.getDeclaringClass().getSuperclass() )
- && !Proxy.class.equals( method.getDeclaringClass() )
- && !Modifier.isStatic( method.getModifiers() ) )
- {
- MixinModel mixinModel = implementMethod( method, mixinClasses );
- ConcernsModel concernsModel = concernsFor(
- method,
- mixinModel.mixinClass(),
- concat( concernDeclarations( mixinModel.mixinClass() ),
- concernClasses.stream() )
- );
- SideEffectsModel sideEffectsModel = sideEffectsFor(
- method,
- mixinModel.mixinClass(),
- concat( sideEffectDeclarations( mixinModel.mixinClass() ),
- sideEffectClasses.stream() )
- );
- method.setAccessible( true );
- ConstraintsModel constraints = constraintsFor(
- method,
- toList( concat( constraintDeclarations( mixinModel.mixinClass() ),
- constraintClasses.stream() ) )
- );
- CompositeMethodModel methodComposite = new CompositeMethodModel(
- method,
- constraints,
- concernsModel,
- sideEffectsModel,
- mixinsModel
- );
-
- Stream<? extends Dependencies> source = Stream.of( methodComposite, mixinModel );
- source.flatMap( Dependencies::dependencies )
- .filter( new DependencyModel.ScopeSpecification( This.class ) )
- .map( DependencyModel::rawInjectionType )
- .forEach( thisDependencies::add );
-
- interfacesOf( mixinModel.mixinClass() )
- .map( Classes.RAW_CLASS )
- .filter( clazz -> Stream.of( Initializable.class, Lifecycle.class, InvocationHandler.class )
- .noneMatch( c -> c.equals( clazz ) ) )
- .forEach( thisDependencies::add );
-
- compositeMethodsModel.addMethod( methodComposite );
- }
- }
- // Add type to set of mixin types
- mixinsModel.addMixinType( mixinType );
- } );
-
- // Implement all @This dependencies that were found
- thisDependencies.forEach( thisDependency -> {
- // Add additional declarations from the @This type
- Stream<Class<?>> typeConstraintClasses = concat(
- constraintClasses.stream(),
- constraintDeclarations( thisDependency ) );
- Stream<Class<?>> typeConcernClasses = concat(
- concernClasses.stream(),
- concernDeclarations( thisDependency ) );
- Stream<Class<?>> typeSideEffectClasses = concat(
- sideEffectClasses.stream(),
- sideEffectDeclarations( thisDependency ) );
- Stream<Class<?>> typeMixinClasses = concat(
- mixinClasses.stream(),
- mixinDeclarations( thisDependency ) );
- List<? extends Class<?>> singleton = Collections.singletonList( thisDependency );
- implementMixinType( singleton,
- toList( typeConstraintClasses ),
- toList( typeConcernClasses ),
- toList( typeSideEffectClasses ),
- toList( typeMixinClasses )
- );
- } );
- }
-
- @SuppressWarnings( "raw" )
- protected MixinModel implementMethod( Method method, List<Class<?>> mixinDeclarations )
- {
- MixinModel implementationModel = mixinsModel.mixinFor( method );
- if( implementationModel != null )
- {
- return implementationModel;
- }
- Class mixinClass = findTypedImplementation( method, mixinDeclarations.stream() );
- if( mixinClass != null )
- {
- return implementMethodWithClass( method, mixinClass );
- }
-
- // Check generic implementations
- mixinClass = findGenericImplementation( method, mixinDeclarations.stream() );
- if( mixinClass != null )
- {
- return implementMethodWithClass( method, mixinClass );
- }
-
- throw new InvalidCompositeException( "No implementation found for method \n " + method.toGenericString()
- + "\nin\n " + types );
- }
-
- private Class<?> findTypedImplementation( final Method method, Stream<Class<?>> mixins )
- {
- // Check if mixinClass implements the method. If so, check if the mixinClass is generic or if the filter passes.
- // If a mixinClass is both generic AND non-generic at the same time, then the filter applies to the non-generic
- // side only.
- Predicate<Class<?>> appliesToSpec = item -> helper.appliesTo( item, method, types, item );
- return mixins.filter( isAssignableFrom( method.getDeclaringClass() )
- .and( Genericpredicate.INSTANCE.or( appliesToSpec ) ) )
- .findFirst().orElse( null );
- }
-
- private Class<?> findGenericImplementation( final Method method, Stream<Class<?>> mixins )
- {
- // Check if mixinClass is generic and the applies-to filter passes
- Predicate<Class<?>> appliesToSpec = item -> helper.appliesTo( item, method, types, item );
- return mixins.filter( Genericpredicate.INSTANCE.and( appliesToSpec ) ).findFirst().orElse( null );
- }
-
- private MixinModel implementMethodWithClass( Method method, Class mixinClass )
- {
- MixinModel mixinModel = mixinsModel.getMixinModel( mixinClass );
- if( mixinModel == null )
- {
- mixinModel = helper.getMixinModel( mixinClass );
- mixinsModel.addMixinModel( mixinModel );
- }
-
- mixinsModel.addMethodMixin( method, mixinModel );
-
- return mixinModel;
- }
-
- protected void addState( final List<Class<?>> constraintClasses )
- {
- // Add method state
- compositeMethodsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
- {
- @Override
- public boolean visitEnter( Object visited )
- throws RuntimeException
- {
- if( visited instanceof CompositeMethodModel )
- {
- CompositeMethodModel methodModel = (CompositeMethodModel) visited;
- if( methodModel.method().getParameterTypes().length == 0 )
- {
- addStateFor( methodModel.method(), constraintClasses );
- }
-
- return false;
- }
-
- return super.visitEnter( visited );
- }
- } );
-
- // Add field state
- mixinsModel.accept( new HierarchicalVisitorAdapter<Object, Object, RuntimeException>()
- {
- @Override
- public boolean visitEnter( Object visited )
- throws RuntimeException
- {
- if( visited instanceof MixinModel )
- {
- MixinModel model = (MixinModel) visited;
- Consumer<Field> addState = field -> addStateFor( field, constraintClasses );
- Fields.FIELDS_OF.apply( model.mixinClass() )
- .filter( Annotations.hasAnnotation( State.class ) )
- .forEach( addState );
- return false;
- }
- return super.visitEnter( visited );
- }
- } );
- }
-
- protected void addStateFor( AccessibleObject accessor, List<Class<?>> constraintClasses )
- {
- String stateName = QualifiedName.fromAccessor( accessor ).name();
-
- if( registeredStateNames.contains( stateName ) )
- {
- return; // Skip already registered names
- }
-
- Class<?> accessorType = Classes.RAW_CLASS.apply( typeOf( accessor ) );
- if( Property.class.isAssignableFrom( accessorType ) )
- {
- propertiesModel.addProperty( newPropertyModel( accessor, constraintClasses ) );
- registeredStateNames.add( stateName );
- }
- else if( Association.class.isAssignableFrom( accessorType ) )
- {
- associationsModel().addAssociation( newAssociationModel( accessor, constraintClasses ) );
- registeredStateNames.add( stateName );
- }
- else if( ManyAssociation.class.isAssignableFrom( accessorType ) )
- {
- manyAssociationsModel().addManyAssociation( newManyAssociationModel( accessor, constraintClasses ) );
- registeredStateNames.add( stateName );
- }
- else if( NamedAssociation.class.isAssignableFrom( accessorType ) )
- {
- namedAssociationsModel().addNamedAssociation( newNamedAssociationModel( accessor, constraintClasses ) );
- registeredStateNames.add( stateName );
- }
- }
-
- protected AssociationsModel associationsModel()
- {
- return null;
- }
-
- protected ManyAssociationsModel manyAssociationsModel()
- {
- return null;
- }
-
- protected NamedAssociationsModel namedAssociationsModel()
- {
- return null;
- }
-
- protected PropertyModel newPropertyModel( AccessibleObject accessor,
- List<Class<?>> constraintClasses
- )
- {
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
- boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
- ValueConstraintsModel valueConstraintsModel = constraintsFor(
- annotations.stream(),
- GenericPropertyInfo.propertyTypeOf( accessor ),
- ( (Member) accessor ).getName(),
- optional,
- constraintClasses,
- accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
- MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
- UseDefaults useDefaultsDeclaration = metaInfo.get( UseDefaults.class );
- Object initialValue = stateDeclarations.initialValueOf( accessor );
- if( initialValue == null && useDefaultsDeclaration != null )
- {
- initialValue = useDefaultsDeclaration.value();
- }
- boolean useDefaults = useDefaultsDeclaration != null || stateDeclarations.useDefaults( accessor );
- boolean immutable = this.immutable || metaInfo.get( Immutable.class ) != null;
- return new PropertyModel(
- accessor,
- immutable,
- useDefaults,
- valueConstraintsInstance,
- metaInfo,
- initialValue
- );
- }
-
- // Model
- private ConstraintsModel constraintsFor( Method method,
- List<Class<?>> constraintClasses
- )
- {
- List<ValueConstraintsModel> parameterConstraintModels = Collections.emptyList();
- Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- Type[] parameterTypes = method.getGenericParameterTypes();
- boolean constrained = false;
- for( int i = 0; i < parameterAnnotations.length; i++ )
- {
- Annotation[] parameterAnnotation = parameterAnnotations[ i ];
-
- Name nameAnnotation = (Name) Stream.of( parameterAnnotation ).filter( isType( Name.class ) )
- .findFirst().orElse( null );
- String name = nameAnnotation == null ? "param" + ( i + 1 ) : nameAnnotation.value();
-
- boolean optional = Stream.of( parameterAnnotation ).filter( isType( Optional.class ) )
- .findFirst().isPresent();
- ValueConstraintsModel parameterConstraintsModel = constraintsFor(
- Arrays.stream( parameterAnnotation ),
- parameterTypes[ i ],
- name,
- optional,
- constraintClasses,
- method );
- if( parameterConstraintsModel.isConstrained() )
- {
- constrained = true;
- }
-
- if( parameterConstraintModels.isEmpty() )
- {
- parameterConstraintModels = new ArrayList<>();
- }
- parameterConstraintModels.add( parameterConstraintsModel );
- }
-
- if( !constrained )
- {
- return new ConstraintsModel( Collections.<ValueConstraintsModel>emptyList() );
- }
- else
- {
- return new ConstraintsModel( parameterConstraintModels );
- }
- }
-
- protected ValueConstraintsModel constraintsFor(
- Stream<Annotation> constraintAnnotations,
- Type valueType,
- String name,
- boolean optional,
- Iterable<Class<?>> constraintClasses,
- AccessibleObject accessor
- )
- {
- valueType = wrapperClass( valueType );
-
- List<AbstractConstraintModel> constraintModels = new ArrayList<>();
- List<Annotation> filtered = constraintAnnotations
- .filter( typeHasAnnotation( ConstraintDeclaration.class ) )
- .collect( Collectors.toList() );
-
- // TODO: This massive block below should be cleaned up.
- nextConstraint:
- for( Annotation constraintAnnotation : filtered )
- {
- // Check composite declarations first
- Class<? extends Annotation> annotationType = constraintAnnotation.annotationType();
- for( Class<?> constraint : constraintClasses )
- {
- Class<? extends Constraint<?, ?>> constraintType = (Class<? extends Constraint<?, ?>>) constraint;
- if( helper.appliesTo( constraintType, annotationType, valueType ) )
- {
- constraintModels.add( new ConstraintModel( constraintAnnotation, constraintType ) );
- continue nextConstraint;
- }
- }
-
- // Check the annotation itself
- Constraints constraints = annotationType.getAnnotation( Constraints.class );
- if( constraints != null )
- {
- for( Class<? extends Constraint<?, ?>> constraintClass : constraints.value() )
- {
- if( helper.appliesTo( constraintClass, annotationType, valueType ) )
- {
- constraintModels.add( new ConstraintModel( constraintAnnotation, constraintClass ) );
- continue nextConstraint;
- }
- }
- }
-
- // No implementation found!
- // Check if if it's a composite constraints
- if( Arrays.stream( annotationType.getAnnotations() )
- .anyMatch( typeHasAnnotation( ConstraintDeclaration.class ) ) )
- {
- ValueConstraintsModel valueConstraintsModel = constraintsFor(
- Arrays.stream( annotationType.getAnnotations() ),
- valueType,
- name,
- optional,
- constraintClasses,
- accessor );
- CompositeConstraintModel compositeConstraintModel = new CompositeConstraintModel(
- constraintAnnotation,
- valueConstraintsModel );
- constraintModels.add( compositeConstraintModel );
- }
- else
- {
- throw new InvalidCompositeException(
- "Cannot find implementation of constraint @"
- + annotationType.getSimpleName()
- + " for "
- + valueType
- + " in method "
- + ( (Member) accessor ).getName()
- + " of composite " + types );
- }
- }
- return new ValueConstraintsModel( constraintModels, name, optional );
- }
-
- private ConcernsModel concernsFor( Method method,
- Class<?> mixinClass,
- Stream<Class<?>> concernClasses
- )
- {
- List<ConcernModel> concernsFor = new ArrayList<>();
- concernClasses.forEach( concern -> {
- if( helper.appliesTo( concern, method, types, mixinClass ) )
- {
- addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel( concern ) );
- }
- else
- {
- // Lookup method in mixin
- if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
- {
- try
- {
- Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
- if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
- {
- addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel( concern ) );
- }
- }
- catch( NoSuchMethodException e )
- {
- // Ignore
- }
- }
- }
- } );
-
- // Check annotations on method that have @Concerns annotations themselves
- for( Annotation annotation : method.getAnnotations() )
- {
- @SuppressWarnings( "raw" )
- Concerns concerns = annotation.annotationType().getAnnotation( Concerns.class );
- if( concerns != null )
- {
- for( Class<?> concern : concerns.value() )
- {
- if( helper.appliesTo( concern, method, types, mixinClass ) )
- {
- ConcernModel concernModel = helper.getConcernModel( concern );
- addConcernOrRepositionIfExists( concernsFor, concernModel );
- }
- }
- }
- }
-
- if( concernsFor.isEmpty() )
- {
- return ConcernsModel.EMPTY_CONCERNS;
- }
- else
- {
- return new ConcernsModel( concernsFor );
- }
- }
-
- private void addConcernOrRepositionIfExists( List<ConcernModel> concernsFor, ConcernModel concernModel )
- {
- // This remove/add is to allow re-ordering of the concerns
- concernsFor.remove( concernModel );
- concernsFor.add( concernModel );
- }
-
- private SideEffectsModel sideEffectsFor( Method method,
- Class<?> mixinClass,
- Stream<Class<?>> sideEffectClasses
- )
- {
- List<SideEffectModel> sideEffectsFor = new ArrayList<>();
- sideEffectClasses.forEach( sideEffect -> {
- SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
- if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
- {
- addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
- }
- else
- {
- // Lookup method in mixin
- if( !InvocationHandler.class.isAssignableFrom( mixinClass ) )
- {
- try
- {
- Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes() );
- if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass ) )
- {
- addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
- }
- }
- catch( NoSuchMethodException e )
- {
- // Ignore
- }
- }
- }
- } );
-
- // Check annotations on method that have @Concerns annotations themselves
- for( Annotation annotation : method.getAnnotations() )
- {
- @SuppressWarnings( "raw" )
- SideEffects sideEffects = annotation.annotationType().getAnnotation( SideEffects.class );
- if( sideEffects != null )
- {
- for( Class<?> sideEffect : sideEffects.value() )
- {
- if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
- {
- SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
- addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
- }
- }
- }
- }
-
- if( sideEffectsFor.isEmpty() )
- {
- return SideEffectsModel.EMPTY_SIDEEFFECTS;
- }
- else
- {
- return new SideEffectsModel( sideEffectsFor );
- }
- }
-
- private void addSideEffectOrRepositionIfExists( List<SideEffectModel> sideEffectsFor,
- SideEffectModel sideEffectModel
- )
- {
- // This add/remove is to allow reording of SideEffects.
- sideEffectsFor.remove( sideEffectModel );
- sideEffectsFor.add( sideEffectModel );
- }
-
- @SuppressWarnings( "unchecked" )
- private Stream<Class<?>> constraintDeclarations( Class<?> type )
- {
- Stream<? extends Type> types = getTypes( type );
- return constraintDeclarations( types );
- }
-
- private Stream<Class<?>> constraintDeclarations( Stream<? extends Type> types )
- {
- return types
- .filter( mixinType -> Annotations.annotationOn( mixinType, Constraints.class ) != null )
- .flatMap( mixinType -> Arrays.stream( Annotations.annotationOn( mixinType, Constraints.class ).value() ) );
- }
-
- @SuppressWarnings( "unchecked" )
- private Stream<Class<?>> concernDeclarations( Class<?> type )
- {
- Stream<? extends Type> types = getTypes( type );
- return concernDeclarations( types );
- }
-
- private Stream<Class<?>> concernDeclarations( Stream<? extends Type> types )
- {
- return types
- .filter( mixinType -> Annotations.annotationOn( mixinType, Concerns.class ) != null )
- .flatMap( new Function<Type, Stream<? extends Class<?>>>()
- {
- @Override
- public Stream<? extends Class<?>> apply( Type mixinType )
- {
- return Arrays.stream( Annotations.annotationOn( mixinType, Concerns.class ).value() );
- }
- } );
- }
-
- @SuppressWarnings( "unchecked" )
- protected Stream<Class<?>> sideEffectDeclarations( Class<?> type )
- {
- Stream<? extends Type> types = getTypes( type );
- return sideEffectDeclarations( types );
- }
-
- private Stream<Class<?>> sideEffectDeclarations( Stream<? extends Type> types )
- {
- return types
- .filter( mixinType -> Annotations.annotationOn( mixinType, SideEffects.class ) != null )
- .flatMap( mixinType -> Arrays.stream( Annotations.annotationOn( mixinType, SideEffects.class ).value() ) );
- }
-
- protected Stream<Class<?>> mixinDeclarations( Class<?> type )
- {
- //Stream<? extends Type> types = typesOf( type );
- return mixinDeclarations( Stream.of( type ) );
- }
-
- private Stream<Class<?>> mixinDeclarations( Stream<? extends Class> types )
- {
- return types.flatMap( this::getTypes ).flatMap( Classes::typesOf )
- .filter( mixinType -> Annotations.annotationOn( mixinType, Mixins.class ) != null )
- .flatMap( mixinType -> Arrays.stream( Annotations.annotationOn( mixinType, Mixins.class ).value() ) );
- }
-
- private Stream<Class> getAllTypes()
- {
- return this.types.stream().flatMap( this::getTypes );
- }
-
- private Stream<Class> getTypes( Class<?> clazz )
- {
- if( clazz.isInterface() )
- {
- return typesOf( clazz ).map( Classes.RAW_CLASS );
- }
- else
- {
- return classHierarchy( clazz ).map( Classes.RAW_CLASS );
- }
- }
-
- public AssociationModel newAssociationModel( AccessibleObject accessor,
- List<Class<?>> constraintClasses
- )
- {
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
- boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
-
- // Constraints for Association references
- ValueConstraintsModel constraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance;
- if( constraintsModel.isConstrained() )
- {
- valueConstraintsInstance = constraintsModel.newInstance();
- }
- else
- {
- valueConstraintsInstance = new ValueConstraintsInstance( Collections.emptyList(), ( (Member) accessor ).getName(), true );
- }
-
- // Constraints for the Association itself
- constraintsModel = constraintsFor( annotations.stream(), Association.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance associationValueConstraintsInstance;
- if( constraintsModel.isConstrained() )
- {
- associationValueConstraintsInstance = constraintsModel.newInstance();
- }
- else
- {
- associationValueConstraintsInstance = new ValueConstraintsInstance( Collections.emptyList(), ( (Member) accessor ).getName(), true );
- }
-
- MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
- return new AssociationModel( accessor, valueConstraintsInstance, associationValueConstraintsInstance, metaInfo );
- }
-
- public ManyAssociationModel newManyAssociationModel( AccessibleObject accessor,
- List<Class<?>> constraintClasses
- )
- {
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
- boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
-
- // Constraints for entities in ManyAssociation
- ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
-
- // Constraints for the ManyAssociation itself
- valueConstraintsModel = constraintsFor( annotations.stream(), ManyAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance manyValueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- manyValueConstraintsInstance = valueConstraintsModel.newInstance();
- }
- MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
- return new ManyAssociationModel( accessor, valueConstraintsInstance, manyValueConstraintsInstance, metaInfo );
- }
-
- public NamedAssociationModel newNamedAssociationModel( AccessibleObject accessor,
- List<Class<?>> constraintClasses
- )
- {
- List<Annotation> annotations = Annotations.findAccessorAndTypeAnnotationsIn( accessor );
- boolean optional = annotations.stream().anyMatch( isType( Optional.class ) );
-
- // Constraints for entities in NamedAssociation
- ValueConstraintsModel valueConstraintsModel = constraintsFor( annotations.stream(), GenericAssociationInfo
- .associationTypeOf( accessor ), ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance valueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- valueConstraintsInstance = valueConstraintsModel.newInstance();
- }
-
- // Constraints for the NamedAssociation itself
- valueConstraintsModel = constraintsFor( annotations.stream(), NamedAssociation.class, ( (Member) accessor ).getName(), optional, constraintClasses, accessor );
- ValueConstraintsInstance namedValueConstraintsInstance = null;
- if( valueConstraintsModel.isConstrained() )
- {
- namedValueConstraintsInstance = valueConstraintsModel.newInstance();
- }
- MetaInfo metaInfo = stateDeclarations.metaInfoFor( accessor );
- return new NamedAssociationModel( accessor, valueConstraintsInstance, namedValueConstraintsInstance, metaInfo );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
deleted file mode 100644
index 4fc466a..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationAssemblyImpl.java
+++ /dev/null
@@ -1,45 +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.runtime.bootstrap;
-
-import java.util.stream.Stream;
-import org.apache.zest.bootstrap.ConfigurationAssembly;
-
-/**
- * Declaration of a EntityComposite.
- */
-public final class ConfigurationAssemblyImpl
- implements ConfigurationAssembly
-{
- private ValueAssemblyImpl value;
- private EntityAssemblyImpl entity;
-
- public ConfigurationAssemblyImpl( Class<?> mainType )
- {
- value = new ValueAssemblyImpl( mainType );
- entity = new EntityAssemblyImpl( mainType );
- }
-
- @Override
- public Stream<Class<?>> types()
- {
- return value.types();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
deleted file mode 100644
index 761f820..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/ConfigurationDeclarationImpl.java
+++ /dev/null
@@ -1,126 +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.runtime.bootstrap;
-
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.ConfigurationDeclaration;
-
-import static java.util.Arrays.asList;
-
-/**
- * Declaration of a Composite. Created by {@link org.apache.zest.bootstrap.ModuleAssembly#configurations(Class[])}.
- */
-public final class ConfigurationDeclarationImpl
- implements ConfigurationDeclaration
-{
- private final Iterable<EntityAssemblyImpl> entities;
- private final Iterable<ValueAssemblyImpl> values;
-
- public ConfigurationDeclarationImpl( Iterable<EntityAssemblyImpl> entities, Iterable<ValueAssemblyImpl> values )
- {
- this.entities = entities;
- this.values = values;
- }
-
- @Override
- public ConfigurationDeclaration setMetaInfo( Object info )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.metaInfo.set( info );
- }
- for( ValueAssemblyImpl value : values )
- {
- value.metaInfo.set( info );
- }
- return this;
- }
-
- @Override
- public ConfigurationDeclaration visibleIn( Visibility visibility )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.visibility = visibility;
- }
- for( ValueAssemblyImpl value : values )
- {
- value.visibility = visibility;
- }
- return this;
- }
-
- @Override
- public ConfigurationDeclaration withConcerns( Class<?>... concerns )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.concerns.addAll( asList( concerns ) );
- }
- for( ValueAssemblyImpl value : values )
- {
- value.concerns.addAll( asList( concerns ) );
- }
- return this;
- }
-
- @Override
- public ConfigurationDeclaration withSideEffects( Class<?>... sideEffects )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.sideEffects.addAll( asList( sideEffects ) );
- }
- for( ValueAssemblyImpl value : values )
- {
- value.sideEffects.addAll( asList( sideEffects ) );
- }
- return this;
- }
-
- @Override
- public ConfigurationDeclaration withMixins( Class<?>... mixins )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.mixins.addAll( asList( mixins ) );
- }
- for( ValueAssemblyImpl value : values )
- {
- value.mixins.addAll( asList( mixins ) );
- }
- return this;
- }
-
- @Override
- public ConfigurationDeclaration withTypes( Class<?>... types )
- {
- for( EntityAssemblyImpl entity : entities )
- {
- entity.types.addAll( asList( types ) );
- }
- for( ValueAssemblyImpl value : values )
- {
- value.types.addAll( asList( types ) );
- }
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
deleted file mode 100644
index 4a775f9..0000000
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/EntityAssemblyImpl.java
+++ /dev/null
@@ -1,121 +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.runtime.bootstrap;
-
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.bootstrap.AssociationDeclarations;
-import org.apache.zest.bootstrap.EntityAssembly;
-import org.apache.zest.bootstrap.ManyAssociationDeclarations;
-import org.apache.zest.bootstrap.NamedAssociationDeclarations;
-import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.runtime.association.AssociationsModel;
-import org.apache.zest.runtime.association.ManyAssociationsModel;
-import org.apache.zest.runtime.association.NamedAssociationsModel;
-import org.apache.zest.runtime.composite.MixinsModel;
-import org.apache.zest.runtime.composite.StateModel;
-import org.apache.zest.runtime.entity.EntityMixinsModel;
-import org.apache.zest.runtime.entity.EntityModel;
-import org.apache.zest.runtime.entity.EntityStateModel;
-
-/**
- * Declaration of a EntityComposite.
- */
-public final class EntityAssemblyImpl
- extends CompositeAssemblyImpl
- implements EntityAssembly
-{
- private AssociationDeclarations associationDeclarations;
- private ManyAssociationDeclarations manyAssociationDeclarations;
- private NamedAssociationDeclarations namedAssociationDeclarations;
- private AssociationsModel associationsModel;
- private ManyAssociationsModel manyAssociationsModel;
- private NamedAssociationsModel namedAssociationsModel;
-
- public EntityAssemblyImpl( Class<?> entityType )
- {
- super( entityType );
- // The composite must always implement EntityComposite, as a marker interface
- if( !EntityComposite.class.isAssignableFrom( entityType ) )
- {
- types.add( EntityComposite.class );
- }
- }
-
- @Override
- protected MixinsModel createMixinsModel()
- {
- return new EntityMixinsModel();
- }
-
- @Override
- protected AssociationsModel associationsModel()
- {
- return associationsModel;
- }
-
- @Override
- protected ManyAssociationsModel manyAssociationsModel()
- {
- return manyAssociationsModel;
- }
-
- @Override
- protected NamedAssociationsModel namedAssociationsModel()
- {
- return namedAssociationsModel;
- }
-
- @Override
- protected StateModel createStateModel()
- {
- return new EntityStateModel( propertiesModel, associationsModel, manyAssociationsModel, namedAssociationsModel );
- }
-
- EntityModel newEntityModel(
- ModuleDescriptor module,
- StateDeclarations stateDeclarations,
- AssociationDeclarations associationDecs,
- ManyAssociationDeclarations manyAssociationDecs,
- NamedAssociationDeclarations namedAssociationDecs,
- AssemblyHelper helper
- )
- {
- this.associationDeclarations = associationDecs;
- this.manyAssociationDeclarations = manyAssociationDecs;
- this.namedAssociationDeclarations = namedAssociationDecs;
- try
- {
- associationsModel = new AssociationsModel();
- manyAssociationsModel = new ManyAssociationsModel();
- namedAssociationsModel = new NamedAssociationsModel();
- buildComposite( helper, stateDeclarations );
-
- return new EntityModel( module, types, visibility, metaInfo,
- (EntityMixinsModel) mixinsModel,
- (EntityStateModel) stateModel, compositeMethodsModel );
- }
- catch( Exception e )
- {
- throw new InvalidApplicationException( "Could not register " + types, e );
- }
- }
-}