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/10/22 07:18:47 UTC
[2/7] zest-java git commit: ZEST-183 : Removing library-eventsourcing.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventCreationConcern.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventCreationConcern.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventCreationConcern.java
deleted file mode 100644
index 8490112..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventCreationConcern.java
+++ /dev/null
@@ -1,68 +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.library.eventsourcing.domain.factory;
-
-import java.lang.reflect.Method;
-import org.apache.zest.api.common.AppliesTo;
-import org.apache.zest.api.concern.GenericConcern;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEvent;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEvents;
-
-/**
- * Generate event for event method
- */
-@AppliesTo(DomainEvent.class)
-public class DomainEventCreationConcern
- extends GenericConcern
-{
- @This
- private EntityComposite entity;
-
- @Service
- private DomainEventFactory domainEventFactory;
-
- @Override
- public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
- {
- if (DomainEvents.currentEvent() == null)
- {
- // Create eventValue
- DomainEventValue eventValue = domainEventFactory.createEvent( entity, method.getName(), args );
- DomainEvents.setCurrentEvent( eventValue );
- try
- {
- return next.invoke( proxy, method, args );
- } finally
- {
- DomainEvents.setCurrentEvent( null );
- }
-
- } else
- {
- // This is probably a replay call
- return next.invoke( proxy, method, args );
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactory.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactory.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactory.java
deleted file mode 100644
index 2b7be4a..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.factory;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-
-/**
- * Factory for DomainEvents
- */
-public interface DomainEventFactory
-{
- DomainEventValue createEvent( EntityComposite entity, String name, Object[] args );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactoryService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactoryService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactoryService.java
deleted file mode 100644
index cdfd1a6..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/DomainEventFactoryService.java
+++ /dev/null
@@ -1,92 +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.library.eventsourcing.domain.factory;
-
-import org.apache.zest.api.ZestAPI;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONStringer;
-import org.json.JSONWriter;
-
-/**
- * DomainEventValue factory
- */
-@Concerns( UnitOfWorkNotificationConcern.class )
-@Mixins( DomainEventFactoryService.DomainEventFactoryMixin.class )
-public interface DomainEventFactoryService
- extends DomainEventFactory, ServiceComposite
-{
- class DomainEventFactoryMixin
- implements DomainEventFactory
- {
- @Structure
- private ValueBuilderFactory vbf;
-
- @Override
- public DomainEventValue createEvent( EntityComposite entity, String name, Object[] args )
- {
- ValueBuilder<DomainEventValue> builder = vbf.newValueBuilder( DomainEventValue.class );
-
- DomainEventValue prototype = builder.prototype();
- prototype.name().set( name );
- prototype.entityType().set( ZestAPI.FUNCTION_DESCRIPTOR_FOR.apply( entity )
- .types()
- .findFirst()
- .get()
- .getName() );
- prototype.entityId().set( entity.identity().get() );
-
- // JSON-ify parameters
- JSONStringer json = new JSONStringer();
- try
- {
- JSONWriter params = json.object();
- for( int i = 0; i < args.length; i++ )
- {
- params.key( "param" + i );
- if( args[ i ] == null )
- {
- params.value( JSONObject.NULL );
- }
- else
- {
- params.value( args[ i ] );
- }
- }
- json.endObject();
- }
- catch( JSONException e )
- {
- throw new IllegalArgumentException( "Could not create eventValue", e );
- }
- prototype.parameters().set( json.toString() );
- return builder.newInstance();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkEvents.java
deleted file mode 100644
index 70f0b37..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkEvents.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.library.eventsourcing.domain.factory;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-
-/**
- * List of eventValues for the current UnitOfWork. This will be updated by the DomainEventFactory.
- */
-class UnitOfWorkEvents
-{
- private List<DomainEventValue> eventValues = new ArrayList<DomainEventValue>();
-
- public void add( DomainEventValue eventValue )
- {
- eventValues.add( eventValue );
- }
-
- public List<DomainEventValue> getEventValues()
- {
- return eventValues;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
deleted file mode 100644
index 7ac8f2a..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
+++ /dev/null
@@ -1,153 +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.library.eventsourcing.domain.factory;
-
-import java.io.IOException;
-import java.time.Instant;
-import org.apache.zest.api.ZestAPI;
-import org.apache.zest.api.concern.ConcernOf;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Output;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import org.apache.zest.library.eventsourcing.domain.source.EventStore;
-import org.apache.zest.library.eventsourcing.domain.source.UnitOfWorkEventsVisitor;
-import org.apache.zest.library.eventsourcing.domain.spi.CurrentUser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Notify event listeners when a complete UoW of domain events is available.
- */
-public class UnitOfWorkNotificationConcern
- extends ConcernOf<DomainEventFactory>
- implements DomainEventFactory
-{
- @Service
- EventStore eventStore;
-
- @Service
- Iterable<UnitOfWorkEventsVisitor> transactionVisitors;
-
- @Service
- CurrentUser currentUser;
-
- @Structure
- ValueBuilderFactory vbf;
-
- @Structure
- UnitOfWorkFactory uowf;
-
- @Structure
- ZestAPI api;
-
- String version;
-
- Logger logger = LoggerFactory.getLogger( DomainEventFactory.class );
-
- Output<UnitOfWorkDomainEventsValue, IOException> eventOutput;
-
- public void init( @Structure Application application )
- {
- version = application.version();
- eventOutput = eventStore.storeEvents();
- }
-
- @Override
- public DomainEventValue createEvent( EntityComposite entity, String name, Object[] args )
- {
- final UnitOfWork unitOfWork = uowf.currentUnitOfWork();
-
- DomainEventValue eventValue = next.createEvent( api.dereference( entity ), name, args );
-
- // Add eventValue to list in UoW
- UnitOfWorkEvents events = unitOfWork.metaInfo(UnitOfWorkEvents.class );
- if (events == null)
- {
- events = new UnitOfWorkEvents();
- unitOfWork.setMetaInfo( events );
-
- unitOfWork.addUnitOfWorkCallback( new UnitOfWorkCallback()
- {
- String user;
-
- @Override
- public void beforeCompletion() throws UnitOfWorkCompletionException
- {
- user = currentUser.getCurrentUser();
- }
-
- @Override
- public void afterCompletion( UnitOfWorkStatus status )
- {
- if (status.equals( UnitOfWorkStatus.COMPLETED ))
- {
- UnitOfWorkEvents events = unitOfWork.metaInfo( UnitOfWorkEvents.class );
-
- ValueBuilder<UnitOfWorkDomainEventsValue> builder = vbf.newValueBuilder( UnitOfWorkDomainEventsValue.class );
- builder.prototype().user().set( user );
- builder.prototype().timestamp().set( Instant.now() );
- builder.prototype().usecase().set( unitOfWork.usecase().name() );
- builder.prototype().version().set( version );
- builder.prototype().events().get().addAll( events.getEventValues() );
-
- try
- {
- final UnitOfWorkDomainEventsValue unitOfWorkDomainValue = builder.newInstance();
- Inputs.iterable( Iterables.iterable( unitOfWorkDomainValue ) ).transferTo( eventOutput );
-
- for (UnitOfWorkEventsVisitor unitOfWorkEventsVisitor : transactionVisitors)
- {
- try
- {
- unitOfWorkEventsVisitor.visit( unitOfWorkDomainValue );
- } catch (Exception e)
- {
- logger.warn( "Could not deliver events", e );
-
- }
- }
- } catch (IOException e)
- {
- logger.error( "Could not store events", e );
- // How do we handle this? This is a major error!
- }
- }
- }
- } );
- }
-
- events.add( eventValue );
-
- return eventValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/package.html
deleted file mode 100644
index 8d7cf64..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>EventSourcing Domain Factory.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayer.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayer.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayer.java
deleted file mode 100644
index d264b52..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayer.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.library.eventsourcing.domain.replay;
-
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * Service that can replay transactions and individual domain events.
- */
-public interface DomainEventPlayer
-{
- public void playTransaction( UnitOfWorkDomainEventsValue unitOfWorkDomainValue )
- throws EventReplayException;
-
- /**
- * Invoke a domain event on a particular object. The object could
- * be the original object, but could also be a service that wants
- * to be invoked to handle the event.
- *
- * @param domainEventValue Domain event value
- * @param object target
- * @throws EventReplayException if unable to play event
- */
- public void playEvent( DomainEventValue domainEventValue, Object object )
- throws EventReplayException;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
deleted file mode 100644
index 890fea9..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
+++ /dev/null
@@ -1,226 +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.library.eventsourcing.domain.replay;
-
-import java.lang.reflect.Method;
-import java.text.ParseException;
-import java.time.Instant;
-import java.time.format.DateTimeFormatter;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import org.apache.zest.spi.ZestSPI;
-import org.apache.zest.spi.entity.EntityState;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * DomainEventValue player
- */
-@Mixins( DomainEventPlayerService.Mixin.class )
-public interface DomainEventPlayerService
- extends DomainEventPlayer, ServiceComposite
-{
- class Mixin
- implements DomainEventPlayer
- {
- final Logger logger = LoggerFactory.getLogger( DomainEventPlayer.class );
-
- @Structure
- UnitOfWorkFactory uowf;
-
- @Structure
- Module module;
-
- @Structure
- ZestSPI spi;
-
- DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
-
- @Override
- public void playTransaction( UnitOfWorkDomainEventsValue unitOfWorkDomainValue )
- throws EventReplayException
- {
- UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Event replay" ) );
- DomainEventValue currentEventValue = null;
- try
- {
- for( DomainEventValue domainEventValue : unitOfWorkDomainValue.events().get() )
- {
- currentEventValue = domainEventValue;
- // Get the entity
- Class entityType = module.descriptor()
- .classLoader()
- .loadClass( domainEventValue.entityType().get() );
- String id = domainEventValue.entityId().get();
- Object entity = null;
- try
- {
- entity = uow.get( entityType, id );
- }
- catch( NoSuchEntityException e )
- {
- // Event to play for an entity that doesn't yet exist - create a default instance
- entity = uow.newEntity( entityType, id );
- }
-
- // check if the event has already occured
- EntityState state = spi.entityStateOf( (EntityComposite) entity );
- if( state.lastModified() > unitOfWorkDomainValue.timestamp().get().toEpochMilli() )
- {
- break; // don't rerun event in this unitOfWorkDomainValue
- }
-
- playEvent( domainEventValue, entity );
- }
- uow.complete();
- }
- catch( Exception e )
- {
- uow.discard();
- if( e instanceof EventReplayException )
- {
- throw ( (EventReplayException) e );
- }
- else
- {
- throw new EventReplayException( currentEventValue, e );
- }
- }
- }
-
- @Override
- public void playEvent( DomainEventValue domainEventValue, Object object )
- throws EventReplayException
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- Class entityType = object.getClass();
-
- // Get method
- Method eventMethod = getEventMethod( entityType, domainEventValue.name().get() );
-
- if( eventMethod == null )
- {
- logger.warn( "Could not find event method " + domainEventValue.name()
- .get() + " in entity of type " + entityType.getName() );
- return;
- }
-
- // Build parameters
- try
- {
- String jsonParameters = domainEventValue.parameters().get();
- JSONObject parameters = (JSONObject) new JSONTokener( jsonParameters ).nextValue();
- Object[] args = new Object[ eventMethod.getParameterTypes().length ];
- for( int i = 1; i < eventMethod.getParameterTypes().length; i++ )
- {
- Class<?> parameterType = eventMethod.getParameterTypes()[ i ];
- String paramName = "param" + i;
- Object value = parameters.get( paramName );
- args[ i ] = getParameterArgument( parameterType, value, uow );
- }
- args[ 0 ] = domainEventValue;
-
- // Invoke method
- logger.debug( "Replay:" + domainEventValue + " on:" + object );
-
- eventMethod.invoke( object, args );
- }
- catch( Exception e )
- {
- throw new EventReplayException( domainEventValue, e );
- }
- }
-
- private Object getParameterArgument( Class<?> parameterType, Object value, UnitOfWork uow )
- throws ParseException
- {
- if( value.equals( JSONObject.NULL ) )
- {
- return null;
- }
-
- if( parameterType.equals( String.class ) )
- {
- return (String) value;
- }
- else if( parameterType.equals( Boolean.class ) || parameterType.equals( Boolean.TYPE ) )
- {
- return (Boolean) value;
- }
- else if( parameterType.equals( Long.class ) || parameterType.equals( Long.TYPE ) )
- {
- return ( (Number) value ).longValue();
- }
- else if( parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ) )
- {
- return ( (Number) value ).intValue();
- }
- else if( parameterType.equals( Instant.class ) )
- {
- return dateFormat.parse( (String) value );
- }
- else if( ValueComposite.class.isAssignableFrom( parameterType ) )
- {
- return module.newValueFromSerializedState( parameterType, (String) value );
- }
- else if( parameterType.isInterface() )
- {
- return uow.get( parameterType, (String) value );
- }
- else if( parameterType.isEnum() )
- {
- return Enum.valueOf( (Class<? extends Enum>) parameterType, value.toString() );
- }
- else
- {
- throw new IllegalArgumentException( "Unknown parameter type:" + parameterType.getName() );
- }
- }
-
- private Method getEventMethod( Class<?> aClass, String eventName )
- {
- for( Method method : aClass.getMethods() )
- {
- if( method.getName().equals( eventName ) )
- {
- Class[] parameterTypes = method.getParameterTypes();
- if( parameterTypes.length > 0 && parameterTypes[ 0 ].equals( DomainEventValue.class ) )
- {
- return method;
- }
- }
- }
- return null;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/EventReplayException.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/EventReplayException.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/EventReplayException.java
deleted file mode 100644
index ba36dfa..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/EventReplayException.java
+++ /dev/null
@@ -1,44 +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.library.eventsourcing.domain.replay;
-
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-
-/**
- * An eventValue replay failed.
- */
-public class EventReplayException
- extends RuntimeException
-{
- private DomainEventValue eventValue;
-
- public EventReplayException( DomainEventValue eventValue, Throwable cause )
- {
- super( cause );
- this.eventValue = eventValue;
- }
-
- @Override
- public String getMessage()
- {
- return "Could not replay event:" + eventValue + ", caused by:" + getCause();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/package.html
deleted file mode 100644
index 855d4b5..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>EventSourcing Domain Replay.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
deleted file mode 100644
index bc55d7b..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/AbstractEventStoreMixin.java
+++ /dev/null
@@ -1,185 +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.library.eventsourcing.domain.source;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-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.structure.Module;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Collections.synchronizedList;
-
-/**
- * Base implementation for EventStores.
- */
-public abstract class AbstractEventStoreMixin
- implements EventStore, EventStream, EventStoreActivation
-{
- @This
- protected Identity identity;
-
- protected Logger logger;
- protected ValueType domainEventType;
- protected ValueType eventsType;
-
- protected Lock lock = new ReentrantLock();
-
- @Structure
- protected ModuleDescriptor module;
-
- private ExecutorService transactionNotifier;
-
- final private List<UnitOfWorkEventsListener> listeners = synchronizedList( new ArrayList<UnitOfWorkEventsListener>() );
-
- @Override
- public void activateEventStore() throws Exception
- {
- logger = LoggerFactory.getLogger( identity.identity().get() );
-
- domainEventType = module.valueDescriptor( DomainEventValue.class.getName() ).valueType();
- eventsType = module.valueDescriptor( UnitOfWorkDomainEventsValue.class.getName() ).valueType();
-
- transactionNotifier = Executors.newSingleThreadExecutor();
- }
-
- @Override
- public void passivateEventStore() throws Exception
- {
- transactionNotifier.shutdown();
- transactionNotifier.awaitTermination( 10000, TimeUnit.MILLISECONDS );
- }
-
- // UnitOfWorkEventsVisitor implementation
- // This is how transactions are put into the store
-
-
- @Override
- public Output<UnitOfWorkDomainEventsValue, IOException> storeEvents()
- {
- final Output<UnitOfWorkDomainEventsValue, IOException> storeOutput = storeEvents0();
-
- return new Output<UnitOfWorkDomainEventsValue, IOException>()
- {
- @Override
- public <SenderThrowableType extends Throwable> void receiveFrom( final Sender<? extends UnitOfWorkDomainEventsValue, SenderThrowableType> sender ) throws IOException, SenderThrowableType
- {
- final List<UnitOfWorkDomainEventsValue> events = new ArrayList<UnitOfWorkDomainEventsValue>( );
- lock();
- try
- {
- storeOutput.receiveFrom(new Sender<UnitOfWorkDomainEventsValue, SenderThrowableType>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super UnitOfWorkDomainEventsValue, ReceiverThrowableType> receiver ) throws ReceiverThrowableType, SenderThrowableType
- {
- sender.sendTo( new Receiver<UnitOfWorkDomainEventsValue, ReceiverThrowableType>()
- {
- @Override
- public void receive( UnitOfWorkDomainEventsValue item ) throws ReceiverThrowableType
- {
- receiver.receive( item );
- events.add( item );
- }
- });
- }
- });
-
- } finally
- {
- lock.unlock();
- }
-
- // Notify listeners
- transactionNotifier.submit( new Runnable()
- {
- @Override
- public void run()
- {
- synchronized(listeners)
- {
- for( UnitOfWorkEventsListener listener : listeners )
- {
- try
- {
- listener.notifyTransactions( events );
- } catch( Exception e )
- {
- logger.warn( "Could not notify event listener", e );
- }
- }
- }
- }
- } );
- }
- };
- }
-
- // EventStream implementation
- @Override
- public void registerListener( UnitOfWorkEventsListener subscriber )
- {
- listeners.add( subscriber );
- }
-
- @Override
- public void unregisterListener( UnitOfWorkEventsListener subscriber )
- {
- listeners.remove( subscriber );
- }
-
- abstract protected Output<UnitOfWorkDomainEventsValue, IOException> storeEvents0();
-
- /**
- * Fix for this bug:
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370
- */
- protected void lock()
- {
- while (true)
- {
- try
- {
- lock.tryLock( 1000, TimeUnit.MILLISECONDS );
- break;
- } catch (InterruptedException e)
- {
- // Try again
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventManagement.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventManagement.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventManagement.java
deleted file mode 100644
index ee4b456..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventManagement.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.source;
-
-import java.io.IOException;
-import org.apache.zest.io.Output;
-
-/**
- * Management interface for EventStores.
- */
-public interface EventManagement
-{
- /**
- * Output used to restore events from a backup
- *
- * @return The Output function to restore events from a backup.
- */
- Output<String, IOException> restore();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventSource.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventSource.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventSource.java
deleted file mode 100644
index b307359..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventSource.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.library.eventsourcing.domain.source;
-
-import java.io.IOException;
-import org.apache.zest.io.Input;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * An EventSource is a source of events. Events are grouped in the UnitOfWork in which they were created.
- */
-public interface EventSource
-{
- /**
- * Get list of UnitOfWorkDomainEventsValue after the given offset.
- * <p>
- * To get the first set of events, use 0 as offset parameter to get events from the start.
- * </p>
- *
- * @param offset where in the list of events to start
- * @param limit maximum number of events returned
- * @return list of UnitOfWorkDomainEventsValue after the given offset
- */
- Input<UnitOfWorkDomainEventsValue, IOException> events( long offset, long limit );
-
- long count();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStore.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStore.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStore.java
deleted file mode 100644
index a89bffb..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStore.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.source;
-
-import java.io.IOException;
-import org.apache.zest.io.Output;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * Store of domain-events.
- */
-public interface EventStore
-{
- Output<UnitOfWorkDomainEventsValue, IOException> storeEvents();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStoreActivation.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStoreActivation.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStoreActivation.java
deleted file mode 100644
index 07eeff5..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStoreActivation.java
+++ /dev/null
@@ -1,54 +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.library.eventsourcing.domain.source;
-
-import org.apache.zest.api.activation.ActivatorAdapter;
-import org.apache.zest.api.service.ServiceReference;
-
-public interface EventStoreActivation
-{
-
- void activateEventStore()
- throws Exception;
-
- void passivateEventStore()
- throws Exception;
-
- public static class Activator
- extends ActivatorAdapter<ServiceReference<EventStoreActivation>>
- {
-
- @Override
- public void afterActivation( ServiceReference<EventStoreActivation> activated )
- throws Exception
- {
- activated.get().activateEventStore();
- }
-
- @Override
- public void beforePassivation( ServiceReference<EventStoreActivation> passivating )
- throws Exception
- {
- passivating.get().passivateEventStore();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStream.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStream.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStream.java
deleted file mode 100644
index 59b9620..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/EventStream.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.source;
-
-/**
- * Stream of event transactions. Registering with a stream will
- * allow the subscriber to get callbacks when new transactions
- * are available. The callbacks are done asynchronously.
- */
-public interface EventStream
-{
- void registerListener( UnitOfWorkEventsListener listener );
-
- void unregisterListener( UnitOfWorkEventsListener listener );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsListener.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsListener.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsListener.java
deleted file mode 100644
index 41ac8d3..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.source;
-
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * JAVADOC
- */
-public interface UnitOfWorkEventsListener
-{
- void notifyTransactions( Iterable<UnitOfWorkDomainEventsValue> transactions );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsVisitor.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsVisitor.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsVisitor.java
deleted file mode 100644
index 746362b..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/UnitOfWorkEventsVisitor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.source;
-
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * JAVADOC
- */
-public interface UnitOfWorkEventsVisitor
-{
- boolean visit( UnitOfWorkDomainEventsValue unitOfWorkDomainValue );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTracker.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTracker.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTracker.java
deleted file mode 100644
index cb30911..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTracker.java
+++ /dev/null
@@ -1,117 +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.library.eventsourcing.domain.source.helper;
-
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Transforms;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import org.apache.zest.library.eventsourcing.domain.source.EventSource;
-import org.apache.zest.library.eventsourcing.domain.source.EventStream;
-import org.apache.zest.library.eventsourcing.domain.source.UnitOfWorkEventsListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Helper that enables a service to easily track transactions.
- * <p>
- * Upon startup
- * the tracker will get all the transactions from the store since the last
- * check, and delegate them to the given Output. It will also register itself
- * with the store so that it can get continuous updates.
- * </p>
- * <p>
- * Then, as transactions come in from the store, they will be processed in real-time.
- * If a transaction is successfully handled the configuration of the service, which must
- * extend DomainEventTrackerConfiguration, will update the marker for the last successfully handled transaction.
- * </p>
- */
-public class DomainEventTracker
- implements Runnable, UnitOfWorkEventsListener
-{
- private Configuration<? extends DomainEventTrackerConfiguration> configuration;
- private final Output<UnitOfWorkDomainEventsValue, ? extends Throwable> output;
- private EventStream stream;
- private EventSource source;
- private boolean started = false;
- private Logger logger;
-
- public DomainEventTracker( EventStream stream, EventSource source,
- Configuration<? extends DomainEventTrackerConfiguration> configuration,
- Output<UnitOfWorkDomainEventsValue, ? extends Throwable> output )
- {
- this.stream = stream;
- this.configuration = configuration;
- this.output = output;
- this.source = source;
-
- logger = LoggerFactory.getLogger( configuration.get().identity().get() );
- }
-
- public synchronized void start()
- {
- if (!started)
- {
- started = true;
-
- run();
-
- stream.registerListener( this );
- }
- }
-
- public synchronized void stop()
- {
- if (started)
- {
- started = false;
- stream.unregisterListener( this );
- }
- }
-
- @Override
- public synchronized void run()
- {
- // TODO This should optionally use a CircuitBreaker
- if (started && configuration.get().enabled().get())
- {
- Transforms.Counter counter = new Transforms.Counter();
- try
- {
- long currentOffset = configuration.get().lastOffset().get();
- source.events( currentOffset, Long.MAX_VALUE ).transferTo( Transforms.map( counter, output ) );
-
- // Save new offset, to be used in next round
- configuration.get().lastOffset().set( currentOffset+counter.count() );
- configuration.save();
- } catch (Throwable throwable)
- {
- logger.warn( "Event handling failed", throwable );
- }
- }
- }
-
- @Override
- public void notifyTransactions( Iterable<UnitOfWorkDomainEventsValue> transactions )
- {
- run();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerConfiguration.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerConfiguration.java
deleted file mode 100644
index b10396c..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerConfiguration.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.library.eventsourcing.domain.source.helper;
-
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.configuration.ConfigurationComposite;
-import org.apache.zest.api.configuration.Enabled;
-import org.apache.zest.api.property.Property;
-
-/**
- * Configuration that a service doing event tracking must have. Let the configuration
- * of the service extend this one.
- */
-public interface DomainEventTrackerConfiguration
- extends ConfigurationComposite, Enabled
-{
- /**
- * A count of how many events have been read already. Call EventStore.events(lastOffset,{limit}) to get
- * the next set of events.
- *
- * @return count of how many events have been read already.
- */
- @UseDefaults
- Property<Long> lastOffset();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventParameters.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventParameters.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventParameters.java
deleted file mode 100644
index 678e829..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventParameters.java
+++ /dev/null
@@ -1,71 +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.library.eventsourcing.domain.source.helper;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-
-/**
- * Utility class to pick out parameters by name or index as strings from a DomainEventValue
- */
-public class EventParameters
-{
- /**
- * Get the named parameter from an eventValue.
- *
- * @param eventValue eventValue with parameters
- * @param name name of parameter
- * @return the parameter with the given name or null
- */
- public static String getParameter( DomainEventValue eventValue, String name )
- {
- String parametersJson = eventValue.parameters().get();
- try
- {
- JSONObject jsonObject = new JSONObject( parametersJson );
- return jsonObject.get( name ).toString();
- } catch (JSONException e)
- {
- return null;
- }
- }
-
- /**
- * Get parameter with given index.
- *
- * @param eventValue eventValue with parameters
- * @param idx index of parameter
- * @return the parameter with the given index or null
- */
- public static String getParameter( DomainEventValue eventValue, int idx )
- {
- try
- {
- String parametersJson = eventValue.parameters().get();
- JSONObject jsonObject = new JSONObject( parametersJson );
- return jsonObject.get( "param" + idx ).toString();
- } catch (JSONException e)
- {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java
deleted file mode 100644
index f7c20ff..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouter.java
+++ /dev/null
@@ -1,104 +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.library.eventsourcing.domain.source.helper;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.Predicate;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * Event handling router. Add specification->receiver routes. When an event comes in
- * the router will ask each specification if it matches, and if so, delegate to the
- * receiver and return whether it successfully handled it or not. If no routes match,
- * delegate to the default receiver
- */
-public class EventRouter<T extends Throwable>
- implements Output<DomainEventValue, T>, Receiver<UnitOfWorkDomainEventsValue, T>
-{
- private Map<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>> routeEvent = new LinkedHashMap<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>>();
-
- private Receiver<DomainEventValue, T> defaultReceiver = new Receiver<DomainEventValue, T>()
- {
- @Override
- public void receive( DomainEventValue item ) throws T
- {
- // Do nothing;
- }
- };
-
- public EventRouter route( Predicate<DomainEventValue> specification, Receiver<DomainEventValue, T> receiver )
- {
- routeEvent.put( specification, receiver );
-
- return this;
- }
-
- public EventRouter defaultReceiver( Receiver<DomainEventValue, T> defaultReceiver )
- {
- this.defaultReceiver = defaultReceiver;
- return this;
- }
-
- @Override
- public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends DomainEventValue, SenderThrowableType> sender ) throws T, SenderThrowableType
- {
- sender.sendTo( new Receiver<DomainEventValue, T>()
- {
- @Override
- public void receive( DomainEventValue item ) throws T
- {
- for( Map.Entry<Predicate<DomainEventValue>, Receiver<DomainEventValue, T>> specificationReceiverEntry : routeEvent.entrySet() )
- {
- if( specificationReceiverEntry.getKey().test( item ) )
- {
- specificationReceiverEntry.getValue().receive( item );
- return;
- }
- }
-
- // No match, use default
- defaultReceiver.receive( item );
- }
- } );
- }
-
- @Override
- public void receive( final UnitOfWorkDomainEventsValue item ) throws T
- {
- receiveFrom( new Sender<DomainEventValue, T>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super DomainEventValue, ReceiverThrowableType> receiver ) throws ReceiverThrowableType, T
- {
-
- for( DomainEventValue domainEventValue : item.events().get() )
- {
- receiver.receive( domainEventValue );
- }
- }
- } );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
deleted file mode 100644
index 6662621..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
+++ /dev/null
@@ -1,175 +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.library.eventsourcing.domain.source.helper;
-
-import java.lang.reflect.Method;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import org.apache.zest.api.util.Methods;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * Helper methods for working with Iterables of DomainEvents and UnitOfWorkDomainEventsValue.
- */
-public class Events
-{
- public static Iterable<DomainEventValue> events( Iterable<UnitOfWorkDomainEventsValue> transactions )
- {
- return Iterables.flattenIterables( Iterables.map( new Function<UnitOfWorkDomainEventsValue, Iterable<DomainEventValue>>()
- {
- @Override
- public Iterable<DomainEventValue> apply( UnitOfWorkDomainEventsValue unitOfWorkDomainEventsValue )
- {
- return unitOfWorkDomainEventsValue.events().get();
- }
- }, transactions ) );
- }
-
- public static Iterable<DomainEventValue> events( UnitOfWorkDomainEventsValue... unitOfWorkDomainValues )
- {
- return events( Iterables.iterable( unitOfWorkDomainValues ) );
- }
-
- public static Predicate<UnitOfWorkDomainEventsValue> withUsecases( final String... names )
- {
- return eventValue -> {
- for( String name : names )
- {
- if( eventValue.usecase().get().equals( name ) )
- {
- return true;
- }
- }
- return false;
- };
- }
-
- public static Predicate<UnitOfWorkDomainEventsValue> byUser( final String... by )
- {
- return eventValue -> {
- for( String user : by )
- {
- if( eventValue.user().get().equals( user ) )
- {
- return true;
- }
- }
- return false;
- };
- }
-
- // public static Predicate<DomainEventValue> withNames( final Iterable<String> names )
-// {
-// return new Predicate<DomainEventValue>()
-// {
-// @Override
-// public boolean test( DomainEventValue eventValue )
-// {
-// for (String name : names)
-// {
-// if (eventValue.name().get().equals( name ))
-// return true;
-// }
-// return false;
-// }
-// };
-// }
-//
- public static Predicate<DomainEventValue> withNames( final String... names )
- {
- return eventValue -> {
- for( String name : names )
- {
- if( eventValue.name().get().equals( name ) )
- {
- return true;
- }
- }
- return false;
- };
- }
-
- public static Predicate<DomainEventValue> withNames( final Class eventClass )
- {
- return new WithNamesPredicate( eventClass );
-// return Events.withNames( map( new Function<Method, String>()
-// {
-// @Override
-// public String apply( Method method )
-// {
-// return method.getName();
-// }
-// }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) ));
- }
-
- public static Predicate<DomainEventValue> onEntities( final String... entities )
- {
- return eventValue -> {
- for( String entity : entities )
- {
- if( eventValue.entityId().get().equals( entity ) )
- {
- return true;
- }
- }
- return false;
- };
- }
-
- public static Predicate<DomainEventValue> onEntityTypes( final String... entityTypes )
- {
- return eventValue -> {
- for( String entityType : entityTypes )
- {
- if( eventValue.entityType().get().equals( entityType ) )
- {
- return true;
- }
- }
- return false;
- };
- }
-
- public static Predicate<DomainEventValue> paramIs( final String name, final String value )
- {
- return eventValue -> EventParameters.getParameter( eventValue, name ).equals( value );
- }
-
- private static class WithNamesPredicate implements Predicate<DomainEventValue>
- {
- private final Class eventClass;
-
- public WithNamesPredicate( Class eventClass )
- {
- this.eventClass = eventClass;
- }
-
- @Override
- public boolean test( DomainEventValue event )
- {
- return Methods.METHODS_OF.apply( eventClass )
- .map( Method::getName )
- .anyMatch( name -> event.name().get().equals( name ) );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.java
deleted file mode 100644
index 4aaaaeb..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouter.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.library.eventsourcing.domain.source.helper;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.Predicate;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-/**
- * UnitOfWork handling router. Add specification->receiver routes. When a UnitOfWorkEDomainEventsValue comes in
- * the router will ask each specification if it matches, and if so, delegate to the
- * receiver. If no routes match, delegate to the default receiver.
- */
-public class UnitOfWorkRouter<T extends Throwable>
- implements Output<UnitOfWorkDomainEventsValue, T>
-{
- private Map<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> routes = new LinkedHashMap<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>>( );
-
- private Receiver<UnitOfWorkDomainEventsValue, T> defaultReceiver = new Receiver<UnitOfWorkDomainEventsValue, T>()
- {
- @Override
- public void receive( UnitOfWorkDomainEventsValue item ) throws T
- {
- // Do nothing;
- }
- };
-
- public UnitOfWorkRouter route( Predicate<UnitOfWorkDomainEventsValue> specification, Receiver<UnitOfWorkDomainEventsValue, T> receiver)
- {
- routes.put(specification, receiver);
-
- return this;
- }
-
- public UnitOfWorkRouter defaultReceiver(Receiver<UnitOfWorkDomainEventsValue, T> defaultReceiver)
- {
- this.defaultReceiver = defaultReceiver;
- return this;
- }
-
- @Override
- public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends UnitOfWorkDomainEventsValue, SenderThrowableType> sender ) throws T, SenderThrowableType
- {
- sender.sendTo( new Receiver<UnitOfWorkDomainEventsValue, T>()
- {
- @Override
- public void receive( UnitOfWorkDomainEventsValue item ) throws T
- {
- for( Map.Entry<Predicate<UnitOfWorkDomainEventsValue>, Receiver<UnitOfWorkDomainEventsValue, T>> specificationReceiverEntry : routes.entrySet() )
- {
- if (specificationReceiverEntry.getKey().test( item ))
- {
- specificationReceiverEntry.getValue().receive( item );
- return;
- }
- }
-
- // No match, use default
- defaultReceiver.receive( item );
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/package.html
deleted file mode 100644
index d603f61..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>EventSourcing Domain Source Helpers.</h2>
- </body>
-</html>
\ No newline at end of file