http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceBuilder.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceBuilder.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceBuilder.java index b08de66..e18c117 100644 --- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceBuilder.java +++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceBuilder.java @@ -22,7 +22,9 @@ package org.apache.zest.library.restlet.resource; import java.io.IOException; import java.util.Collections; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -46,13 +48,13 @@ import org.restlet.routing.Router; @Mixins( ResourceBuilder.Mixin.class ) public interface ResourceBuilder { - EntityRef createEntityRef( String name, Reference base ); + EntityRef createEntityRef(Identity name, Reference base ); - EntityRef createEntityRef( String name, RestLink get, RestLink put, RestLink delete ); + EntityRef createEntityRef( Identity name, RestLink get, RestLink put, RestLink delete ); - RestLink createRestLink( String name, Reference base, Method method ); + RestLink createRestLink( Identity name, Reference base, Method method ); - RestLink createRestLink( String name, Reference base, Method method, String description ); + RestLink createRestLink( Identity name, Reference base, Method method, String description ); Command createCommand( Reference base ); @@ -60,9 +62,9 @@ public interface ResourceBuilder FormField createFormField( String name, String type ); - <T extends Identity> Representation toRepresentation( Class<T> type, T composite ); + <T extends HasIdentity> Representation toRepresentation(Class<T> type, T composite ); - <T extends Identity> T toObject( Class<T> type, Representation representation ) + <T extends HasIdentity> T toObject(Class<T> type, Representation representation ) throws IOException; Route findRoute( String name, Router router ); @@ -83,16 +85,17 @@ public interface ResourceBuilder converter = new ZestConverter( objectFactory ); } - public EntityRef createEntityRef( String identity, Reference base ) + @Override + public EntityRef createEntityRef( Identity identity, Reference base ) { - String name = identityManager.extractName( identity ); - RestLink get = createRestLink( name, base, Method.GET ); - RestLink put = createRestLink( name, base, Method.PUT ); - RestLink delete = createRestLink( name, base, Method.DELETE ); - return createEntityRef( name, get, put, delete ); + RestLink get = createRestLink( identity, base, Method.GET ); + RestLink put = createRestLink( identity, base, Method.PUT ); + RestLink delete = createRestLink( identity, base, Method.DELETE ); + return createEntityRef( identity, get, put, delete ); } - public EntityRef createEntityRef( String identity, RestLink get, RestLink put, RestLink delete ) + @Override + public EntityRef createEntityRef( Identity identity, RestLink get, RestLink put, RestLink delete ) { ValueBuilder<EntityRef> refBuilder = vbf.newValueBuilder( EntityRef.class ); EntityRef refPrototype = refBuilder.prototype(); @@ -103,9 +106,10 @@ public interface ResourceBuilder return refBuilder.newInstance(); } - public RestLink createRestLink( String name, Reference base, Method method ) + @Override + public RestLink createRestLink( Identity identity, Reference base, Method method ) { - name = identityManager.extractName( name ); + String name = identityManager.extractName( identity ); ValueBuilder<RestLink> builder = vbf.newValueBuilder( RestLink.class ); RestLink prototype = builder.prototype(); @@ -116,8 +120,9 @@ public interface ResourceBuilder } @Override - public RestLink createRestLink( String name, Reference base, Method method, String description ) + public RestLink createRestLink( Identity identity, Reference base, Method method, String description ) { + String name = identityManager.extractName( identity ); ValueBuilder<RestLink> builder = vbf.newValueBuilder( RestLink.class ); RestLink prototype = builder.prototype(); prototype.path().set( base.toUri().resolve( name ).getPath() + "/" ); @@ -138,7 +143,7 @@ public interface ResourceBuilder public RestForm createNameForm( Reference base ) { ValueBuilder<RestForm> builder = vbf.newValueBuilder( RestForm.class ); - builder.prototype().link().set( createRestLink( "form", base, Method.POST ) ); + builder.prototype().link().set( createRestLink( new StringIdentity( "form" ), base, Method.POST ) ); builder.prototype().fields().set( Collections.singletonList( createFormField( "name", FormField.TEXT ) ) ); return builder.newInstance(); } @@ -152,13 +157,13 @@ public interface ResourceBuilder } @Override - public <T extends Identity> Representation toRepresentation( Class<T> type, T composite ) + public <T extends HasIdentity> Representation toRepresentation(Class<T> type, T composite ) { return converter.toRepresentation( composite, new Variant(), null ); } @Override - public <T extends Identity> T toObject( Class<T> type, Representation representation ) + public <T extends HasIdentity> T toObject(Class<T> type, Representation representation ) throws IOException { return converter.toObject( representation, type, null );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceFactory.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceFactory.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceFactory.java index fcebb07..c9a0403 100644 --- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceFactory.java +++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ResourceFactory.java @@ -20,12 +20,12 @@ package org.apache.zest.library.restlet.resource; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; import org.restlet.Context; import org.restlet.Request; import org.restlet.Response; -public interface ResourceFactory<K extends Identity, T extends ServerResource<K>> +public interface ResourceFactory<K extends HasIdentity, T extends ServerResource<K>> { T create( Class<T> resourceType, Request request, Response response, Context context ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ServerResource.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ServerResource.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ServerResource.java index 702612f..6976ebd 100644 --- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ServerResource.java +++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/resource/ServerResource.java @@ -21,7 +21,9 @@ package org.apache.zest.library.restlet.resource; import org.apache.zest.api.common.Optional; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identifiable; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -35,10 +37,8 @@ import org.restlet.Response; import org.restlet.routing.Router; @Mixins( { ServerResource.NotPresent.class, ServerResource.IdentityMixin.class } ) -public interface ServerResource<T extends Identity> +public interface ServerResource<T extends HasIdentity> extends Identifiable { - String identity(); - T get(); void put( T value ); @@ -63,7 +63,7 @@ public interface ServerResource<T extends Identity> Property<Router> router(); } - abstract class IdentityMixin<T extends Identity> + abstract class IdentityMixin<T extends HasIdentity> implements ServerResource<T> { @This @@ -73,7 +73,7 @@ public interface ServerResource<T extends Identity> private IdentityManager identityManager; @Override - public String identity() + public Identity identity() { return identityManager.generate( parameters.entityType().get(), parameters.id().get() ); } @@ -83,13 +83,13 @@ public interface ServerResource<T extends Identity> implements ServerResource { @Override - public Identity get() + public HasIdentity get() { throw new NotPresentException(); } @Override - public void put( Identity value ) + public void put( HasIdentity value ) { throw new NotPresentException(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java index 4bc0743..4e38778 100644 --- a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java +++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Customer.java @@ -20,8 +20,8 @@ package org.apache.zest.library.restlet; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; -public interface Customer extends Identity +public interface Customer extends HasIdentity { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java index 93c01a4..0cb696f 100644 --- a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java +++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Order.java @@ -20,8 +20,8 @@ package org.apache.zest.library.restlet; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; -public interface Order extends Identity +public interface Order extends HasIdentity { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java ---------------------------------------------------------------------- diff --git a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java index 0eb0ff5..24a75b7 100644 --- a/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java +++ b/libraries/restlet/src/test/java/org/apache/zest/library/restlet/Product.java @@ -20,8 +20,8 @@ package org.apache.zest.library.restlet; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; -public interface Product extends Identity +public interface Product extends HasIdentity { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/PasswordDomainAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/PasswordDomainAssembler.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/PasswordDomainAssembler.java index c353f8e..4f39f1a 100644 --- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/PasswordDomainAssembler.java +++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/PasswordDomainAssembler.java @@ -40,7 +40,7 @@ public class PasswordDomainAssembler visibleIn( visibility() ); if( hasIdentity() ) { - service.identifiedBy( identity() ); + service.identifiedBy( identity().toString() ); } if( hasConfig() ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/StandaloneShiroAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/StandaloneShiroAssembler.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/StandaloneShiroAssembler.java index 39242e5..24f60d4 100644 --- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/StandaloneShiroAssembler.java +++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/assembly/StandaloneShiroAssembler.java @@ -38,7 +38,7 @@ public class StandaloneShiroAssembler instantiateOnStartup(); if( hasIdentity() ) { - service.identifiedBy( identity() ); + service.identifiedBy( identity().toString() ); } if( hasConfig() ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/ZestApplicationBootstrap.java ---------------------------------------------------------------------- diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/ZestApplicationBootstrap.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/ZestApplicationBootstrap.java index bbc18f7..1c7a878 100644 --- a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/ZestApplicationBootstrap.java +++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/ZestApplicationBootstrap.java @@ -34,7 +34,7 @@ import org.springframework.context.ApplicationContextAware; * <li>Create a class that extends {@link ZestApplicationBootstrap}.</li> * <li>Sets the layer and module that register BeanFactory service.</li> * <li>Assemble Zest application by implementing #assemble method.</li> - * <li>Sets the identity of bean factory service. This identity is the spring + * <li>Sets the reference of bean factory service. This reference is the spring * bean name.</li> * <li>Declare Zest bootstrap in spring xml application context. * <pre><code> http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceFactoryBean.java ---------------------------------------------------------------------- diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceFactoryBean.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceFactoryBean.java index 8bd19c6..f9b427b 100644 --- a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceFactoryBean.java +++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceFactoryBean.java @@ -23,7 +23,6 @@ import org.apache.zest.api.service.ServiceReference; import org.apache.zest.api.structure.Application; import org.springframework.beans.factory.FactoryBean; -import static org.apache.zest.functional.Iterables.first; import static org.springframework.util.Assert.notNull; public final class ServiceFactoryBean http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java ---------------------------------------------------------------------- diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java index dcfa5ec..7bb8d6c 100644 --- a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java +++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java @@ -67,7 +67,7 @@ final class ServiceLocator else if( visited instanceof ServiceDescriptor ) { ServiceDescriptor aDescriptor = (ServiceDescriptor) visited; - String identity = aDescriptor.identity(); + String identity = aDescriptor.identity().toString(); if( serviceId.equals( identity ) ) { layerName = tempLayerName; @@ -97,7 +97,7 @@ final class ServiceLocator if( visited instanceof ImportedServiceDescriptor ) { ImportedServiceDescriptor aDescriptor = (ImportedServiceDescriptor) visited; - String identity = aDescriptor.identity(); + String identity = aDescriptor.identity().toString(); if( serviceId.equals( identity ) ) { layerName = tempLayerName; @@ -118,7 +118,7 @@ final class ServiceLocator Iterable<ServiceReference<Object>> serviceRefs = module.findServices( serviceType ); for( ServiceReference<Object> serviceRef : serviceRefs ) { - if( serviceId.equals( serviceRef.identity() ) ) + if( serviceId.equals( serviceRef.identity().toString() ) ) { return serviceRef; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/spring/src/main/java/org/apache/zest/library/spring/importer/SpringImporter.java ---------------------------------------------------------------------- diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/importer/SpringImporter.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/importer/SpringImporter.java index 5838441..f5ae5de 100644 --- a/libraries/spring/src/main/java/org/apache/zest/library/spring/importer/SpringImporter.java +++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/importer/SpringImporter.java @@ -47,7 +47,7 @@ public class SpringImporter { return serviceDescriptor. metaInfo( ApplicationContext.class ). - getBean( serviceDescriptor.identity(), serviceDescriptor.type() ); + getBean( serviceDescriptor.identity().toString(), serviceDescriptor.type() ); } catch( Throwable e ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/spring/src/test/java/org/apache/zest/library/spring/bootstrap/ZestTestBootstrap.java ---------------------------------------------------------------------- diff --git a/libraries/spring/src/test/java/org/apache/zest/library/spring/bootstrap/ZestTestBootstrap.java b/libraries/spring/src/test/java/org/apache/zest/library/spring/bootstrap/ZestTestBootstrap.java index 41e19e2..3ccedca 100644 --- a/libraries/spring/src/test/java/org/apache/zest/library/spring/bootstrap/ZestTestBootstrap.java +++ b/libraries/spring/src/test/java/org/apache/zest/library/spring/bootstrap/ZestTestBootstrap.java @@ -47,8 +47,8 @@ public final class ZestTestBootstrap ModuleAssembly moduleAssembly = layerAssembly.module( MODULE ); moduleAssembly.services( CommentServiceComposite.class ).identifiedBy( COMMENT_SERVICE_ID ); // inject Spring bean as a service - moduleAssembly.importedServices( TextProcessingService.class ).setMetaInfo( - this.applicationContext.getBean( TO_UPPERCASE_SERVICE_ID ) ); + moduleAssembly.importedServices( TextProcessingService.class ) + .setMetaInfo( this.applicationContext.getBean( TO_UPPERCASE_SERVICE_ID ) ); } public void setApplicationContext( ApplicationContext applicationContext ) throws BeansException http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql-liquibase/src/main/java/org/apache/zest/library/sql/liquibase/LiquibaseAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql-liquibase/src/main/java/org/apache/zest/library/sql/liquibase/LiquibaseAssembler.java b/libraries/sql-liquibase/src/main/java/org/apache/zest/library/sql/liquibase/LiquibaseAssembler.java index 62efb06..d7cdbe3 100644 --- a/libraries/sql-liquibase/src/main/java/org/apache/zest/library/sql/liquibase/LiquibaseAssembler.java +++ b/libraries/sql-liquibase/src/main/java/org/apache/zest/library/sql/liquibase/LiquibaseAssembler.java @@ -36,7 +36,7 @@ public class LiquibaseAssembler instantiateOnStartup(); if( hasIdentity() ) { - service.identifiedBy( identity() ); + service.identifiedBy( identity().toString() ); } if( hasConfig() ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java index e48fff6..292dfc2 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java @@ -39,7 +39,7 @@ public abstract class AbstractPooledDataSourceServiceAssembler<AssemblerType> { configModule().entities( DataSourceConfiguration.class ).visibleIn( configVisibility() ); } - onAssemble( module, identity() == null ? DEFAULT_DATASOURCE_SERVICE_IDENTITY : identity(), visibility() ); + onAssemble( module, identity() == null ? DEFAULT_DATASOURCE_SERVICE_IDENTITY : identity().toString(), visibility() ); } protected abstract void onAssemble( ModuleAssembly module, String identity, Visibility visibility ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/DataSourceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/DataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/DataSourceAssembler.java index b8ac6b6..bcc2fff 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/DataSourceAssembler.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/DataSourceAssembler.java @@ -20,6 +20,7 @@ package org.apache.zest.library.sql.assembly; import javax.sql.DataSource; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.service.importer.ServiceInstanceImporter; import org.apache.zest.api.util.NullArgumentException; import org.apache.zest.bootstrap.Assemblers; @@ -47,7 +48,7 @@ public class DataSourceAssembler public DataSourceAssembler withDataSourceServiceIdentity( String dataSourceServiceId ) { - NullArgumentException.validateNotNull( "DataSourceService identity", dataSourceServiceId ); + NullArgumentException.validateNotNull( "DataSourceService reference", dataSourceServiceId ); this.dataSourceServiceId = dataSourceServiceId; return this; } @@ -71,7 +72,7 @@ public class DataSourceAssembler { module.importedServices( DataSource.class ). importedBy( ServiceInstanceImporter.class ). - setMetaInfo( dataSourceServiceId ). + setMetaInfo( new StringIdentity( dataSourceServiceId ) ). identifiedBy( identity() ). visibleIn( visibility() ); if( circuitBreaker != null ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/ExternalDataSourceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/ExternalDataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/ExternalDataSourceAssembler.java index ebba025..ffe530f 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/ExternalDataSourceAssembler.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/ExternalDataSourceAssembler.java @@ -20,6 +20,7 @@ package org.apache.zest.library.sql.assembly; import javax.sql.DataSource; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.util.NullArgumentException; import org.apache.zest.bootstrap.Assemblers; import org.apache.zest.bootstrap.AssemblyException; @@ -66,7 +67,7 @@ public class ExternalDataSourceAssembler { if( circuitBreaker != null ) { - externalDataSource = DataSources.wrapWithCircuitBreaker( identity(), externalDataSource, circuitBreaker ); + externalDataSource = DataSources.wrapWithCircuitBreaker( new StringIdentity(identity()), externalDataSource, circuitBreaker ); } module.importedServices( DataSource.class ). identifiedBy( identity() ). http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java index cb18e3c..41838e1 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java @@ -27,7 +27,8 @@ import java.util.Map; import javax.sql.DataSource; import org.apache.zest.api.composite.PropertyMapper; import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.injection.scope.Service; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.service.ImportedServiceDescriptor; import org.apache.zest.api.service.ServiceImporter; @@ -47,9 +48,9 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp protected static final Logger LOGGER = LoggerFactory.getLogger( AbstractDataSourceServiceImporterMixin.class ); - private final Map<String, DataSourceConfiguration> configs = new HashMap<>(); + private final Map<Identity, DataSourceConfiguration> configs = new HashMap<>(); - private final Map<String, PooledDataSourceType> pools = new HashMap<>(); + private final Map<Identity, PooledDataSourceType> pools = new HashMap<>(); private final Map<DataSource, CircuitBreaker> circuitBreakers = new HashMap<>(); @@ -122,7 +123,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp } } - private DataSourceConfiguration getConfiguration( String identity ) + private DataSourceConfiguration getConfiguration( Identity identity ) throws InstantiationException { DataSourceConfiguration config = configs.get( identity ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSourceConfiguration.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSourceConfiguration.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSourceConfiguration.java index 0c0cef1..2e099a9 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSourceConfiguration.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSourceConfiguration.java @@ -20,12 +20,12 @@ package org.apache.zest.library.sql.datasource; import org.apache.zest.api.composite.Composite; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; /** * Configuration Entity for a DataSource. */ public interface DataSourceConfiguration - extends Identity, Composite, DataSourceConfigurationState + extends HasIdentity, Composite, DataSourceConfigurationState { } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSources.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSources.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSources.java index f0b8e93..2dcee1c 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSources.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/DataSources.java @@ -26,6 +26,7 @@ import java.lang.reflect.Proxy; import java.net.ConnectException; import java.util.function.Predicate; import javax.sql.DataSource; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.service.ServiceImporterException; import org.apache.zest.library.circuitbreaker.CircuitBreaker; @@ -47,7 +48,7 @@ public class DataSources return new CircuitBreaker( threshold, timeout, rootCause( in ).negate() ); } - public static DataSource wrapWithCircuitBreaker( final String dataSourceIdentity, final DataSource pool, final CircuitBreaker circuitBreaker ) + public static DataSource wrapWithCircuitBreaker(final Identity dataSourceIdentity, final DataSource pool, final CircuitBreaker circuitBreaker ) { // Create wrapper InvocationHandler handler = new InvocationHandler() http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java index 067696a..f4e4885 100644 --- a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java +++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java @@ -48,6 +48,8 @@ import org.apache.zest.api.activation.Activators; import org.apache.zest.api.association.AssociationStateHolder; import org.apache.zest.api.entity.EntityComposite; import org.apache.zest.api.entity.EntityDescriptor; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -128,7 +130,6 @@ public interface DataSourceConfigurationManagerService throws MalformedObjectNameException, MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException { for ( ServiceReference<DataSource> dataSource : dataSources ) { - String name = dataSource.identity(); ModuleDescriptor module = spi.moduleOf( dataSource ); EntityDescriptor descriptor = module.entityDescriptor( DataSourceConfiguration.class.getName() ); List<MBeanAttributeInfo> attributes = new ArrayList<>(); @@ -145,9 +146,10 @@ public interface DataSourceConfigurationManagerService List<MBeanOperationInfo> operations = new ArrayList<>(); operations.add( new MBeanOperationInfo( "restart", "Restart DataSource", new MBeanParameterInfo[ 0 ], "void", MBeanOperationInfo.ACTION_INFO ) ); - MBeanInfo mbeanInfo = new MBeanInfo( DataSourceConfiguration.class.getName(), name, attributes.toArray( new MBeanAttributeInfo[ attributes.size() ] ), null, operations.toArray( new MBeanOperationInfo[ operations.size() ] ), null ); - Object mbean = new ConfigurableDataSource( dataSourceService, mbeanInfo, name, properties ); - ObjectName configurableDataSourceName = new ObjectName( "Zest:application=" + application.name() + ",class=Datasource,name=" + name ); + String mbeanName = dataSource.identity().toString(); + MBeanInfo mbeanInfo = new MBeanInfo( DataSourceConfiguration.class.getName(), mbeanName, attributes.toArray( new MBeanAttributeInfo[ attributes.size() ] ), null, operations.toArray( new MBeanOperationInfo[ operations.size() ] ), null ); + Object mbean = new ConfigurableDataSource( dataSourceService, mbeanInfo, mbeanName, properties ); + ObjectName configurableDataSourceName = new ObjectName( "Zest:application=" + application.name() + ",class=Datasource,name=" + mbeanName ); server.registerMBean( mbean, configurableDataSourceName ); configurationNames.add( configurableDataSourceName ); } @@ -168,14 +170,14 @@ public interface DataSourceConfigurationManagerService MBeanInfo info; - String identity; + Identity identity; Map<String, AccessibleObject> propertyNames; EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames ) { this.info = info; - this.identity = identity; + this.identity = new StringIdentity( identity ); this.propertyNames = propertyNames; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java ---------------------------------------------------------------------- diff --git a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java index b926d79..79dc1ad 100644 --- a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java +++ b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java @@ -91,7 +91,7 @@ public class DataSourceConfigurationManagerServiceTest new DBCPDataSourceServiceAssembler().identifiedBy( "datasource-service" ).visibleIn( Visibility.layer ).assemble( module ); { - ModuleAssembly testModule = module.layer().module( "TestDS" ).withDefaultUnitOfWorkFactory(); + ModuleAssembly testModule = module.layer().module( "TestDS" ); // Create a specific DataSource that uses the "datasource" service to do the main work new DataSourceAssembler(). @@ -109,7 +109,7 @@ public class DataSourceConfigurationManagerServiceTest } { - ModuleAssembly testModule2 = module.layer().module( "TestDS2" ).withDefaultUnitOfWorkFactory(); + ModuleAssembly testModule2 = module.layer().module( "TestDS2" ); // Create another specific DataSource that uses the "datasource" service to do the main work // Use DataSourceAssembler to assemble the DataSource. http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFile.java ---------------------------------------------------------------------- diff --git a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFile.java b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFile.java index 6ea74bc..0785d30 100644 --- a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFile.java +++ b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFile.java @@ -80,7 +80,7 @@ public class UoWFile { if( fileTag( original ) != originalIdentity ) { - LOGGER.info( "Concurrent modification, original creation identity is {} and original apply identity is {}", originalIdentity, fileTag( original ) ); + LOGGER.info( "Concurrent modification, original creation reference is {} and original apply reference is {}", originalIdentity, fileTag( original ) ); throw new ConcurrentUoWFileStateModificationException( this ); } if( original.exists() ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java ---------------------------------------------------------------------- diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java index 82c9510..11cf220 100644 --- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java +++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java @@ -24,12 +24,13 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.junit.Before; import org.junit.Test; import org.apache.zest.api.concern.Concerns; import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.entity.Identity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -67,7 +68,7 @@ public class HasUoWFileTest // START SNIPPET: uowfile public interface TestedEntity extends HasUoWFileLifecycle // END SNIPPET: entity - , Identity + , HasIdentity // START SNIPPET: entity { Property<String> name(); @@ -80,12 +81,12 @@ public class HasUoWFileTest implements UoWFileLocator { @This - private Identity meAsIdentity; + private HasIdentity meAsIdentity; @Override public File locateAttachedFile() { - return new File( baseTestDir, meAsIdentity.identity().get() ); + return new File( baseTestDir, meAsIdentity.identity().get().toString() ); } } // END SNIPPET: locator @@ -94,12 +95,12 @@ public class HasUoWFileTest @Concerns( UnitOfWorkConcern.class ) public interface TestService { - void modifyFile( String entityId ) + void modifyFile( Identity entityId ) throws IOException; @UnitOfWorkPropagation @UnitOfWorkRetry - void modifyFileWithRetry( String entityId, long sleepBefore, long sleepAfter ) + void modifyFileWithRetry( Identity entityId, long sleepBefore, long sleepAfter ) throws IOException; } @@ -110,14 +111,14 @@ public class HasUoWFileTest private UnitOfWorkFactory uowf; @Override - public void modifyFile( String entityId ) + public void modifyFile( Identity entityId ) throws IOException { modifyFileImmediatly( entityId ); } @Override - public void modifyFileWithRetry( String entityId, long sleepBefore, long sleepAfter ) + public void modifyFileWithRetry( Identity entityId, long sleepBefore, long sleepAfter ) throws IOException { LOGGER.info( "Waiting " + sleepBefore + "ms before file modification" ); @@ -147,7 +148,7 @@ public class HasUoWFileTest } } - private void modifyFileImmediatly( String entityId ) + private void modifyFileImmediatly( Identity entityId ) throws IOException { TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId ); @@ -214,7 +215,7 @@ public class HasUoWFileTest throws UnitOfWorkCompletionException, IOException { LOGGER.info( "# Test Modification ##########################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -247,7 +248,7 @@ public class HasUoWFileTest throws UnitOfWorkCompletionException, IOException { LOGGER.info( "# Test Deletion ##############################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -282,7 +283,7 @@ public class HasUoWFileTest throws IOException, UnitOfWorkCompletionException { LOGGER.info( "# Test Concurrent Modification ###############################################################" ); - final String entityId; + final Identity entityId; // Create new try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() ) @@ -321,7 +322,7 @@ public class HasUoWFileTest throws IOException, UnitOfWorkCompletionException, InterruptedException { LOGGER.info( "# Test Retry #################################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -334,34 +335,26 @@ public class HasUoWFileTest } final List<Exception> ex = new ArrayList<>(); - Thread t1 = new Thread( new Runnable() + Thread t1 = new Thread(() -> { - @Override - public void run() + try { - try - { - testService.modifyFileWithRetry( entityId, 0, 3000 ); - } - catch( Exception ex1 ) - { - ex.add( ex1 ); - } + testService.modifyFileWithRetry( entityId, 0, 3000 ); + } + catch( Exception ex1 ) + { + ex.add( ex1 ); } }, "job1" ); - Thread t2 = new Thread( new Runnable() + Thread t2 = new Thread(() -> { - @Override - public void run() + try { - try - { - testService.modifyFileWithRetry( entityId, 1000, 0 ); - } - catch( Exception ex1 ) - { - ex.add( ex1 ); - } + testService.modifyFileWithRetry( entityId, 1000, 0 ); + } + catch( Exception ex1 ) + { + ex.add( ex1 ); } }, "job2" ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java ---------------------------------------------------------------------- diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java index 4ea4927..ce0ece2 100644 --- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java +++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java @@ -24,12 +24,13 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.junit.Before; import org.junit.Test; import org.apache.zest.api.concern.Concerns; import org.apache.zest.api.entity.EntityBuilder; -import org.apache.zest.api.entity.Identity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -72,7 +73,7 @@ public class HasUoWFilesTest // START SNIPPET: entity public interface TestedEntity extends HasUoWFilesLifecycle<MyEnum> // END SNIPPET: entity - , Identity + , HasIdentity // START SNIPPET: entity { Property<String> name(); @@ -85,7 +86,7 @@ public class HasUoWFilesTest implements UoWFilesLocator<MyEnum> { @This - private Identity meAsIdentity; + private HasIdentity meAsIdentity; @Override public Iterable<File> locateAttachedFiles() @@ -110,12 +111,12 @@ public class HasUoWFilesTest @Concerns( UnitOfWorkConcern.class ) public interface TestService { - void modifyFile( String entityId ) + void modifyFile( Identity entityId ) throws IOException; @UnitOfWorkPropagation @UnitOfWorkRetry - void modifyFileWithRetry( String entityId, long sleepBefore, long sleepAfter ) + void modifyFileWithRetry( Identity entityId, long sleepBefore, long sleepAfter ) throws IOException; } @@ -126,14 +127,14 @@ public class HasUoWFilesTest private UnitOfWorkFactory uowf; @Override - public void modifyFile( String entityId ) + public void modifyFile( Identity entityId ) throws IOException { modifyFileImmediatly( entityId ); } @Override - public void modifyFileWithRetry( String entityId, long sleepBefore, long sleepAfter ) + public void modifyFileWithRetry( Identity entityId, long sleepBefore, long sleepAfter ) throws IOException { LOGGER.info( "Waiting " + sleepBefore + "ms before file modification" ); @@ -163,7 +164,7 @@ public class HasUoWFilesTest } } - private void modifyFileImmediatly( String entityId ) + private void modifyFileImmediatly( Identity entityId ) throws IOException { TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId ); @@ -229,7 +230,7 @@ public class HasUoWFilesTest throws UnitOfWorkCompletionException, IOException { LOGGER.info( "# Test Modification ##########################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -262,7 +263,7 @@ public class HasUoWFilesTest throws UnitOfWorkCompletionException, IOException { LOGGER.info( "# Test Deletion ##############################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -297,7 +298,7 @@ public class HasUoWFilesTest throws IOException, UnitOfWorkCompletionException { LOGGER.info( "# Test Concurrent Modification ###############################################################" ); - final String entityId; + final Identity entityId; // Create new try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() ) @@ -336,7 +337,7 @@ public class HasUoWFilesTest throws IOException, UnitOfWorkCompletionException, InterruptedException { LOGGER.info( "# Test Retry #################################################################################" ); - final String entityId; + final Identity entityId; File attachedFile; // Create new @@ -349,34 +350,26 @@ public class HasUoWFilesTest } final List<Exception> ex = new ArrayList<>(); - Thread t1 = new Thread( new Runnable() + Thread t1 = new Thread(() -> { - @Override - public void run() + try { - try - { - testService.modifyFileWithRetry( entityId, 0, 10000 ); - } - catch( Exception ex1 ) - { - ex.add( ex1 ); - } + testService.modifyFileWithRetry( entityId, 0, 10000 ); + } + catch( Exception ex1 ) + { + ex.add( ex1 ); } }, "job1" ); - Thread t2 = new Thread( new Runnable() + Thread t2 = new Thread(() -> { - @Override - public void run() + try { - try - { - testService.modifyFileWithRetry( entityId, 5000, 0 ); - } - catch( Exception ex1 ) - { - ex.add( ex1 ); - } + testService.modifyFileWithRetry( entityId, 5000, 0 ); + } + catch( Exception ex1 ) + { + ex.add( ex1 ); } }, "job2" ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepository.java ---------------------------------------------------------------------- diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepository.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepository.java index 8ac7320..2dbcbc2 100644 --- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepository.java +++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepository.java @@ -19,10 +19,12 @@ */ package org.apache.zest.manual.recipes.createEntity; +import org.apache.zest.api.identity.Identity; + // START SNIPPET: repo public interface ManufacturerRepository { - Manufacturer findByIdentity(String identity); + Manufacturer findByIdentity(Identity identity); Manufacturer findByName(String name); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepositoryMixin.java ---------------------------------------------------------------------- diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepositoryMixin.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepositoryMixin.java index d25b3bd..6ef893d 100644 --- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepositoryMixin.java +++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/ManufacturerRepositoryMixin.java @@ -19,6 +19,7 @@ */ package org.apache.zest.manual.recipes.createEntity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.query.Query; import org.apache.zest.api.query.QueryBuilder; @@ -39,10 +40,10 @@ public class ManufacturerRepositoryMixin @Structure private Module module; - public Manufacturer findByIdentity( String identity ) + public Manufacturer findByIdentity( Identity identity ) { UnitOfWork uow = uowf.currentUnitOfWork(); - return uow.get(Manufacturer.class, identity); + return uow.get(Manufacturer.class, identity ); } public Manufacturer findByName( String name ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/README.txt ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/README.txt b/samples/dci-cargo/README.txt deleted file mode 100644 index b588156..0000000 --- a/samples/dci-cargo/README.txt +++ /dev/null @@ -1,22 +0,0 @@ -DCI Sample -========== - -This is a port of the DDD Sample application to the DCI paradigm using Java, Zest⢠and Wicket. - -The code is licensed under the Apache Software License 2.0 and lastest revisions are -available from https://github.com/dci. - -See more information at http://marcgrue.com/dci/dci-sample - -Version A: -- Run com.marcgrue.dcisample_a.bootstrap.Start8081 (in test folder) -- Point browser to http://localhost:8081 - -Version B: -- Run com.marcgrue.dcisample_b.bootstrap.Start8082 (in test folder) -- Point browser to http://localhost:8082 - - -Marc Grue -marcgrue.com -October 2011 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/build.gradle ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/build.gradle b/samples/dci-cargo/dcisample_a/build.gradle deleted file mode 100644 index 2af8595..0000000 --- a/samples/dci-cargo/dcisample_a/build.gradle +++ /dev/null @@ -1,50 +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. - * - * - */ - -description = "Sample of how DCI (Data, Context & Interaction) pattern is implemented with Apache Zestâ¢, for Eric Evans DDD sample." - -jar { manifest { name = "Apache Zest⢠Sample DCI Cargo - Sample A" }} - -dependencies { - - compile project( ':org.apache.zest.core:org.apache.zest.core.bootstrap' ) - compile project( ':org.apache.zest.libraries:org.apache.zest.library.constraints' ) - compile project( ':org.apache.zest.extensions:org.apache.zest.extension.valueserialization-orgjson' ) - compile project( ':org.apache.zest.extensions:org.apache.zest.extension.indexing-rdf' ) - compile project( ':org.apache.zest.tools:org.apache.zest.tool.envisage' ) - compile libraries.jetty_webapp - compile libraries.wicket - compile libraries.wicket_devutils - compile libraries.wicket_stateless - compile libraries.slf4j_api - - runtime project( ':org.apache.zest.core:org.apache.zest.core.runtime' ) - - testCompile project( ':org.apache.zest.core:org.apache.zest.core.testsupport' ) - testCompile libraries.easymock - - testRuntime libraries.logback - -} - -task(runSample, dependsOn: 'testClasses', type: JavaExec) { - main = 'org.apache.zest.sample.dcicargo.sample_a.bootstrap.Start8081' - classpath = sourceSets.test.runtimeClasspath -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/GraphTraversalService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/GraphTraversalService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/GraphTraversalService.java deleted file mode 100644 index 4534bcd..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/GraphTraversalService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.sample.dcicargo.pathfinder_a.api; - -import java.rmi.Remote; -import java.rmi.RemoteException; -import java.util.List; - -/** - * Part of the external graph traversal API exposed by the routing team - * and used by us (booking and tracking team). - */ -public interface GraphTraversalService extends Remote -{ - - /** - * @param originUnLocode origin UN Locode - * @param destinationUnLocode destination UN Locode - * - * @return A list of transit paths - * - * @throws RemoteException RMI problem - */ - List<TransitPath> findShortestPath( String originUnLocode, String destinationUnLocode ) - throws RemoteException; -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java deleted file mode 100644 index f2a6adc..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.sample.dcicargo.pathfinder_a.api; - -import java.io.Serializable; -import java.time.LocalDate; - -/** - * Represents an edge in a path through a graph, - * describing the route of a cargo. - */ -public final class TransitEdge implements Serializable -{ - - private final String voyageNumber; - private final String fromUnLocode; - private final String toUnLocode; - private final LocalDate fromDate; - private final LocalDate toDate; - - /** - * Constructor. - * - * @param voyageNumber - * @param fromUnLocode - * @param toUnLocode - * @param fromDate - * @param toDate - */ - public TransitEdge( final String voyageNumber, - final String fromUnLocode, - final String toUnLocode, - final LocalDate fromDate, - final LocalDate toDate - ) - { - this.voyageNumber = voyageNumber; - this.fromUnLocode = fromUnLocode; - this.toUnLocode = toUnLocode; - this.fromDate = fromDate; - this.toDate = toDate; - } - - public String getVoyageNumber() - { - return voyageNumber; - } - - public String getFromUnLocode() - { - return fromUnLocode; - } - - public String getToUnLocode() - { - return toUnLocode; - } - - public LocalDate getFromDate() - { - return fromDate; - } - - public LocalDate getToDate() - { - return toDate; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitPath.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitPath.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitPath.java deleted file mode 100644 index 57225ba..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitPath.java +++ /dev/null @@ -1,51 +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.sample.dcicargo.pathfinder_a.api; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; - -/** - * - */ -public final class TransitPath implements Serializable -{ - - private final List<TransitEdge> transitEdges; - - /** - * Constructor. - * - * @param transitEdges The legs for this itinerary. - */ - public TransitPath( final List<TransitEdge> transitEdges ) - { - this.transitEdges = transitEdges; - } - - /** - * @return An unmodifiable list DTOs. - */ - public List<TransitEdge> getTransitEdges() - { - return Collections.unmodifiableList( transitEdges ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/package.html ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/package.html b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/package.html deleted file mode 100644 index 8829a5e..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/package.html +++ /dev/null @@ -1,26 +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> -<p> - Public API for the pathfinder application. -</p> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphDAO.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphDAO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphDAO.java deleted file mode 100644 index 9e32ebe..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphDAO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.sample.dcicargo.pathfinder_a.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - -public class GraphDAO -{ - - private static final Random random = new Random(); - - public List<String> listLocations() - { - return new ArrayList<String>( Arrays.asList( - "CNHKG", "AUMEL", "SESTO", "FIHEL", "USCHI", "JNTKO", "DEHAM", "CNSHA", "NLRTM", "SEGOT", "CNHGH", "USNYC", "USDAL" - ) ); - } - - public String getVoyageNumber( String from, String to ) - { - final int i = random.nextInt( 5 ); - if( i == 0 ) - { - return "V100S"; - } - if( i == 1 ) - { - return "V200T"; - } - if( i == 2 ) - { - return "V300A"; - } - if( i == 3 ) - { - return "V400S"; - } - return "V500S"; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java deleted file mode 100644 index 8d6de22..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java +++ /dev/null @@ -1,108 +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.sample.dcicargo.pathfinder_a.internal; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; -import org.apache.zest.sample.dcicargo.pathfinder_a.api.GraphTraversalService; -import org.apache.zest.sample.dcicargo.pathfinder_a.api.TransitEdge; -import org.apache.zest.sample.dcicargo.pathfinder_a.api.TransitPath; - -public class GraphTraversalServiceImpl - implements GraphTraversalService -{ - private GraphDAO dao; - private Random random; - - public GraphTraversalServiceImpl( GraphDAO dao ) - { - this.dao = dao; - this.random = new Random(); - } - - public List<TransitPath> findShortestPath( String originUnLocode, String destinationUnLocode ) - { - LocalDate date = nextDate( LocalDate.now()); - - List<String> allVertices = dao.listLocations(); - allVertices.remove( originUnLocode ); - allVertices.remove( destinationUnLocode ); - - final int candidateCount = getRandomNumberOfCandidates(); - final List<TransitPath> candidates = new ArrayList<>( candidateCount ); - - for( int i = 0; i < candidateCount; i++ ) - { - allVertices = getRandomChunkOfLocations( allVertices ); - final List<TransitEdge> transitEdges = new ArrayList<>( allVertices.size() - 1 ); - final String firstLegTo = allVertices.get( 0 ); - - LocalDate fromDate = nextDate( date ); - LocalDate toDate = nextDate( fromDate ); - date = nextDate( toDate ); - - transitEdges.add( new TransitEdge( - dao.getVoyageNumber( originUnLocode, firstLegTo ), - originUnLocode, firstLegTo, fromDate, toDate ) ); - - for( int j = 0; j < allVertices.size() - 1; j++ ) - { - final String curr = allVertices.get( j ); - final String next = allVertices.get( j + 1 ); - fromDate = nextDate( date ); - toDate = nextDate( fromDate ); - date = nextDate( toDate ); - transitEdges.add( new TransitEdge( dao.getVoyageNumber( curr, next ), curr, next, fromDate, toDate ) ); - } - - final String lastLegFrom = allVertices.get( allVertices.size() - 1 ); - fromDate = nextDate( date ); - toDate = nextDate( fromDate ); - transitEdges.add( new TransitEdge( - dao.getVoyageNumber( lastLegFrom, destinationUnLocode ), - lastLegFrom, destinationUnLocode, fromDate, toDate ) ); - - candidates.add( new TransitPath( transitEdges ) ); - } - - return candidates; - } - - private LocalDate nextDate( LocalDate date ) - { - return date.plusDays( 1 ); - } - - private int getRandomNumberOfCandidates() - { - return 3 + random.nextInt( 3 ); - } - - private List<String> getRandomChunkOfLocations( List<String> allLocations ) - { - Collections.shuffle( allLocations ); - final int total = allLocations.size(); - final int chunk = total > 4 ? 1 + new Random().nextInt( 5 ) : total; - return allLocations.subList( 0, chunk ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/package.html ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/package.html b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/package.html deleted file mode 100644 index 00de161..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/package.html +++ /dev/null @@ -1,26 +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> -<p> - Internal parts of the pathfinder application. -</p> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/package.html ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/package.html b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/package.html deleted file mode 100644 index 6329b87..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/package.html +++ /dev/null @@ -1,34 +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> -<p> - This is the pathfinder application context, which is separate from "our" application and context. - Our domain model with cargo, itinerary, handling event etc does not exist here. - The routing domain service implementation works against the API exposed by - this context. -</p> - -<p> - It is not related to the core application at all, and is only part of this source tree for - developer convenience. -</p> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java deleted file mode 100644 index acc980a..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package org.apache.zest.sample.dcicargo.sample_a.bootstrap; - -import org.apache.wicket.ConverterLocator; -import org.apache.wicket.Page; -import org.apache.wicket.datetime.PatternDateConverter; -import org.apache.wicket.devutils.stateless.StatelessChecker; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.booking.BookNewCargoPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.booking.CargoDetailsPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.booking.CargoListPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.booking.ChangeDestinationPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.booking.RouteCargoPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.handling.RegisterHandlingEventPage; -import org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking.TrackCargoPage; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.WicketZestApplication; -import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.tabs.TabsPanel; - -/** - * DCI Sample application instance - * - * A Wicket application backed by Zest. - */ -public class DCISampleApplication_a - extends WicketZestApplication -{ - public void wicketInit() - { - // Tabs and SEO urls. - mountPages(); - - // Show/hide Ajax debugging. - getDebugSettings().setDevelopmentUtilitiesEnabled( true ); - - // Check that components are stateless when required. - getComponentPostOnBeforeRenderListeners().add( new StatelessChecker() ); - - // Show/hide wicket tags in html code. - getMarkupSettings().setStripWicketTags( true ); - - // Default date format (we don't care for now about the hour of the day) - ( (ConverterLocator) getConverterLocator() ).set( java.util.Date.class, - new PatternDateConverter( "yyyy-MM-dd", true ) ); - } - - private void mountPages() - { - TabsPanel.registerTab( this, CargoListPage.class, "booking", "Booking and Routing" ); - TabsPanel.registerTab( this, TrackCargoPage.class, "tracking", "Tracking" ); - TabsPanel.registerTab( this, RegisterHandlingEventPage.class, "handling", "Handling" ); - - mountPage( "/booking", CargoListPage.class ); - mountPage( "/booking/book-new-cargo", BookNewCargoPage.class ); - mountPage( "/booking/cargo", CargoDetailsPage.class ); - mountPage( "/booking/change-destination", ChangeDestinationPage.class ); - mountPage( "/booking/route-cargo", RouteCargoPage.class ); - - mountPage( "/handling", RegisterHandlingEventPage.class ); - mountPage( "/tracking", TrackCargoPage.class ); - } - - public Class<? extends Page> getHomePage() - { - return CargoListPage.class; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/VisualizeApplicationStructure.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/VisualizeApplicationStructure.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/VisualizeApplicationStructure.java deleted file mode 100644 index ed8f977..0000000 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/VisualizeApplicationStructure.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.sample.dcicargo.sample_a.bootstrap; - -import org.apache.zest.api.structure.ApplicationDescriptor; -import org.apache.zest.bootstrap.Energy4Java; -import org.apache.zest.envisage.Envisage; -import org.apache.zest.sample.dcicargo.sample_a.bootstrap.assembly.Assembler; - -/** - * Visualize the application assemblage structure. - */ -public class VisualizeApplicationStructure -{ - public static void main( String[] args ) - throws Exception - { - Energy4Java zest = new Energy4Java(); - Assembler assembler = new Assembler(); - ApplicationDescriptor applicationModel = zest.newApplicationModel( assembler ); - applicationModel.newInstance( zest.spi() ); - - /* - * The Envisage Swing app visualizes the application assemblage structure. - * - * Tree view: - * - Click on elements to expand sub-elements. - * - Scroll to change font size. - * - Right click on viewer to re-size to fit window. - * - * Stacked view: - * - Scroll to zoom in/out of structure levels - might freeze though :-( - * - * Click on any element and see details of that element in the upper right pane. - * - * Pretty cool, eh? - * */ - new Envisage().run( applicationModel ); - int randomTimeoutMs = 18374140; - Thread.sleep( randomTimeoutMs ); - } -} \ No newline at end of file
