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:48 UTC
[3/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/application/factory/UnitOfWorkApplicationEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/UnitOfWorkApplicationEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/UnitOfWorkApplicationEvents.java
deleted file mode 100644
index 642b911..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/UnitOfWorkApplicationEvents.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.application.factory;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-
-/**
- * List of events for the current UnitOfWork. This will be updated by the DomainEventFactory.
- */
-public class UnitOfWorkApplicationEvents
-{
- private List<ApplicationEvent> events = new ArrayList<ApplicationEvent>();
-
- public void add( ApplicationEvent event )
- {
- events.add( event );
- }
-
- public List<ApplicationEvent> getEvents()
- {
- return events;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/package.html
deleted file mode 100644
index fd91648..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/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 Application 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/application/replay/ApplicationEventPlayer.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayer.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayer.java
deleted file mode 100644
index 6d33fd7..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.application.replay;
-
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-
-/**
- * Service that can replay ApplicationEvents.
- */
-public interface ApplicationEventPlayer
-{
- /**
- * 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 applicationEvent Application event
- * @param object target
- * @throws ApplicationEventReplayException if unable to play event
- */
- public void playEvent( ApplicationEvent applicationEvent, Object object )
- throws ApplicationEventReplayException;
-}
\ 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/application/replay/ApplicationEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
deleted file mode 100644
index cca1d01..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.application.replay;
-
-import java.lang.reflect.Method;
-import java.text.ParseException;
-import java.time.Instant;
-import java.time.format.DateTimeFormatter;
-import org.apache.zest.api.ZestAPI;
-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.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ApplicationEvent player
- */
-@Mixins(ApplicationEventPlayerService.Mixin.class)
-public interface ApplicationEventPlayerService
- extends ApplicationEventPlayer, ServiceComposite
-{
- class Mixin
- implements ApplicationEventPlayer
- {
- final Logger logger = LoggerFactory.getLogger( ApplicationEventPlayer.class );
- @Structure
- UnitOfWorkFactory uowf;
-
- @Structure
- Module module;
-
- @Structure
- ZestAPI api;
-
- DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
-
- @Override
- public void playEvent( ApplicationEvent applicationEvent, Object object )
- throws ApplicationEventReplayException
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- Class handlerType = object.getClass();
-
- // Get method
- Method eventMethod = getEventMethod( handlerType, applicationEvent.name().get() );
-
- if (eventMethod == null)
- {
- logger.warn( "Could not find event method " + applicationEvent.name().get() + " in entity of type " + handlerType.getName() );
- return;
- }
-
- // Build parameters
- try
- {
- String jsonParameters = applicationEvent.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] = applicationEvent;
-
- // Invoke method
- logger.debug( "Replay:" + applicationEvent + " on:" + object );
-
- eventMethod.invoke( object, args );
- } catch (Exception e)
- {
- throw new ApplicationEventReplayException( applicationEvent, 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( ApplicationEvent.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/application/replay/ApplicationEventReplayException.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventReplayException.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventReplayException.java
deleted file mode 100644
index 0eafa14..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventReplayException.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.application.replay;
-
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-
-/**
- * An event replay failed.
- */
-public class ApplicationEventReplayException
- extends RuntimeException
-{
- private ApplicationEvent event;
-
- public ApplicationEventReplayException( ApplicationEvent event, Throwable cause )
- {
- super( cause );
- this.event = event;
- }
-
- @Override
- public String getMessage()
- {
- return "Could not replay event:" + event + ", 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/application/replay/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/package.html
deleted file mode 100644
index d8f137e..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/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 Application 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/application/source/AbstractApplicationEventStoreMixin.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
deleted file mode 100644
index c25bb5d..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/AbstractApplicationEventStoreMixin.java
+++ /dev/null
@@ -1,197 +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.application.source;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-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.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Output;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Collections.synchronizedList;
-
-/**
- * Base implementation for ApplicationEventStores.
- */
-public abstract class AbstractApplicationEventStoreMixin
- implements ApplicationEventStore, ApplicationEventStream, ApplicationEventStoreActivation
-{
- @This
- protected Identity identity;
-
- protected Logger logger;
- protected ValueType domainEventType;
- protected ValueType transactionEventsType;
-
- protected Lock lock = new ReentrantLock();
-
- @Structure
- protected ModuleDescriptor module;
-
- @Structure
- private ValueBuilderFactory vbf;
-
- private ExecutorService transactionNotifier;
-
- final private List<Output<TransactionApplicationEvents, ? extends Throwable>> listeners = synchronizedList( new ArrayList<Output<TransactionApplicationEvents, ? extends Throwable>>() );
-
- private long lastTimestamp = 0;
-
- @Override
- public void activateApplicationEventStore()
- throws Exception
- {
- logger = LoggerFactory.getLogger( identity.identity().get() );
-
- domainEventType = module.valueDescriptor( ApplicationEvent.class.getName() ).valueType();
- transactionEventsType = module.valueDescriptor( TransactionApplicationEvents.class.getName() ).valueType();
-
- transactionNotifier = Executors.newSingleThreadExecutor();
- }
-
- @Override
- public void passivateApplicationEventStore()
- throws Exception
- {
- transactionNotifier.shutdown();
- transactionNotifier.awaitTermination( 10000, TimeUnit.MILLISECONDS );
- }
-
- // This is how transactions are put into the store
- @Override
- public TransactionApplicationEvents storeEvents( Iterable<ApplicationEvent> events ) throws IOException
- {
- // Create new TransactionApplicationEvents
- ValueBuilder<TransactionApplicationEvents> builder = vbf.newValueBuilder( TransactionApplicationEvents.class );
- Iterables.addAll( builder.prototype().events().get(), events );
- builder.prototype().timestamp().set( getCurrentTimestamp() );
-
- final TransactionApplicationEvents transactionDomain = builder.newInstance();
-
- // Lock store so noone else can interrupt
- lock();
- try
- {
- storeEvents( transactionDomain );
- } finally
- {
- lock.unlock();
- }
-
- // Notify listeners
- transactionNotifier.submit( new Runnable()
- {
- @Override
- public void run()
- {
- synchronized (listeners)
- {
- Input<TransactionApplicationEvents, RuntimeException> input = Inputs.iterable( Collections.singleton( transactionDomain ) );
- for (Output<TransactionApplicationEvents, ? extends Throwable> listener : listeners)
- {
- try
- {
- input.transferTo( listener );
- } catch (Throwable e)
- {
- logger.warn( "Could not notify event listener", e );
- }
- }
- }
- }
- } );
-
- return transactionDomain;
- }
-
- // EventStream implementation
-
-
- @Override
- public void registerListener( Output<TransactionApplicationEvents, ? extends Throwable> listener )
- {
- listeners.add( listener );
- }
-
-
- @Override
- public void unregisterListener( Output<TransactionApplicationEvents, ? extends Throwable> listener )
- {
- listeners.remove( listener );
- }
-
- abstract protected void rollback()
- throws IOException;
-
- abstract protected void commit()
- throws IOException;
-
- abstract protected void storeEvents( TransactionApplicationEvents transactionDomain )
- throws IOException;
-
- /**
- * 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
- }
- }
- }
-
- private synchronized long getCurrentTimestamp()
- {
- long timestamp = System.currentTimeMillis();
- if (timestamp <= lastTimestamp)
- timestamp = lastTimestamp + 1; // Increase by one to ensure uniqueness
- lastTimestamp = timestamp;
- return timestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventSource.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventSource.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventSource.java
deleted file mode 100644
index 275dfa0..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventSource.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.library.eventsourcing.application.source;
-
-import java.io.IOException;
-import org.apache.zest.io.Input;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-
-/**
- * An ApplicationEventSource is a source of application events that can be pulled in chunks. Events are grouped in the transactions in which they were created.
- */
-public interface ApplicationEventSource
-{
- /**
- * Get list of event transactions after the given timestamp.
- * <p>
- * If they are on the exact same timestamp, they will not be included.
- * <p>
- * The method uses the visitor pattern, so a visitor is sent in which is given each transaction, one at a time.
- *
- * @param afterTimestamp timestamp of transactions
- * @param maxTransactions maximum transactions
- * @return list of event transactions
- */
- Input<TransactionApplicationEvents, IOException> transactionsAfter( long afterTimestamp, long maxTransactions );
-
- /**
- * Get list of event transactions before the given timestamp.
- * <p>
- * If they are on the exact same timestamp, they will not be included.
- * <p>
- * The method uses the visitor pattern, so a visitor is sent in which is given each transaction, one at a time.
- * <p>
- * The transactions are sent to the visitor with the latest transaction first, i.e. walking backwards in the stream.
- *
- * @param beforeTimestamp timestamp of transactions
- * @param maxTransactions maximum transactions
- * @return list of event transactions
- */
- Input<TransactionApplicationEvents, IOException> transactionsBefore( long beforeTimestamp, long maxTransactions );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStore.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStore.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStore.java
deleted file mode 100644
index 3b74ac3..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStore.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.application.source;
-
-import java.io.IOException;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-
-/**
- * Store of application-events.
- */
-public interface ApplicationEventStore
-{
- TransactionApplicationEvents storeEvents( Iterable<ApplicationEvent> events ) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStoreActivation.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStoreActivation.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStoreActivation.java
deleted file mode 100644
index 7847a78..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStoreActivation.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.application.source;
-
-import org.apache.zest.api.activation.ActivatorAdapter;
-import org.apache.zest.api.service.ServiceReference;
-
-public interface ApplicationEventStoreActivation
-{
-
- void activateApplicationEventStore()
- throws Exception;
-
- void passivateApplicationEventStore()
- throws Exception;
-
- public static class Activator
- extends ActivatorAdapter<ServiceReference<ApplicationEventStoreActivation>>
- {
-
- @Override
- public void afterActivation( ServiceReference<ApplicationEventStoreActivation> activated )
- throws Exception
- {
- activated.get().activateApplicationEventStore();
- }
-
- @Override
- public void beforePassivation( ServiceReference<ApplicationEventStoreActivation> passivating )
- throws Exception
- {
- passivating.get().passivateApplicationEventStore();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStream.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStream.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStream.java
deleted file mode 100644
index 0cd003d..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/ApplicationEventStream.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.application.source;
-
-import org.apache.zest.io.Output;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-
-/**
- * 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 ApplicationEventStream
-{
- void registerListener( Output<TransactionApplicationEvents, ? extends Throwable> listener );
-
- void unregisterListener( Output<TransactionApplicationEvents, ? extends Throwable> listener );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEventParameters.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEventParameters.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEventParameters.java
deleted file mode 100644
index ad62582..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEventParameters.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.application.source.helper;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-
-/**
- * Utility class to pick out parameters by name or index as strings from a ApplicationEvent
- */
-public class ApplicationEventParameters
-{
- /**
- * Get the named parameter from an event.
- *
- * @param event event with parameters
- * @param name name of parameter
- * @return the parameter with the given name or null
- */
- public static String getParameter( ApplicationEvent event, String name )
- {
- String parametersJson = event.parameters().get();
- try
- {
- JSONObject jsonObject = new JSONObject( parametersJson );
- return jsonObject.get( name ).toString();
- } catch (JSONException e)
- {
- return null;
- }
- }
-
- /**
- * Get parameter with given index.
- *
- * @param event event with parameters
- * @param idx index of parameter
- * @return the parameter with the given index or null
- */
- public static String getParameter( ApplicationEvent event, int idx )
- {
- try
- {
- String parametersJson = event.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/application/source/helper/ApplicationEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
deleted file mode 100644
index edd5c8f..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
+++ /dev/null
@@ -1,191 +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.application.source.helper;
-
-import java.lang.reflect.Method;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Predicate;
-import org.apache.zest.api.util.Methods;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import org.apache.zest.library.eventsourcing.application.replay.ApplicationEventPlayer;
-import org.apache.zest.library.eventsourcing.application.replay.ApplicationEventReplayException;
-
-/**
- * Helper methods for working with Iterables of DomainEvents and UnitOfWorkDomainEventsValue.
- */
-public class ApplicationEvents
-{
- public static Iterable<ApplicationEvent> events( Iterable<TransactionApplicationEvents> transactions )
- {
- List<Iterable<ApplicationEvent>> events = new ArrayList<>();
- for (TransactionApplicationEvents transactionDomain : transactions)
- {
- events.add( transactionDomain.events().get() );
- }
-
- Iterable<ApplicationEvent>[] iterables = (Iterable<ApplicationEvent>[]) new Iterable[events.size()];
- return Iterables.flatten( events.toArray( iterables ) );
- }
-
- public static Iterable<ApplicationEvent> events( TransactionApplicationEvents... transactionDomains )
- {
- List<Iterable<ApplicationEvent>> events = new ArrayList<Iterable<ApplicationEvent>>();
- for (TransactionApplicationEvents transactionDomain : transactionDomains)
- {
- events.add( transactionDomain.events().get() );
- }
-
- Iterable<ApplicationEvent>[] iterables = (Iterable<ApplicationEvent>[]) new Iterable[events.size()];
- return Iterables.flatten( events.<Iterable<ApplicationEvent>>toArray( iterables ) );
- }
-
- public static boolean matches( Predicate<ApplicationEvent> specification, Iterable<TransactionApplicationEvents> transactions )
- {
- return Iterables.filter( specification, events( transactions ) ).iterator().hasNext();
- }
-
- // Common specifications
-
-// public static Predicate<ApplicationEvent> withNames( final Iterable<String> names )
-// {
-// return new Predicate<ApplicationEvent>()
-// {
-// @Override
-// public boolean test( ApplicationEvent event )
-// {
-// for (String name : names)
-// {
-// if (event.name().get().equals( name ))
-// return true;
-// }
-// return false;
-// }
-// };
-// }
-//
-// public static Predicate<ApplicationEvent> withNames( final String... names )
-// {
-// return new Predicate<ApplicationEvent>()
-// {
-// @Override
-// public boolean test( ApplicationEvent event )
-// {
-// for (String name : names)
-// {
-// if (event.name().get().equals( name ))
-// return true;
-// }
-// return false;
-// }
-// };
-// }
-//
- public static Predicate<ApplicationEvent> withNames( final Class eventClass )
- {
- return new WithNamesPredicate(eventClass );
-
-// ApplicationEvents.withNames( Iterables.map( new Function<Method, String>()
-// {
-// @Override
-// public String apply( Method method )
-// {
-// return method.getName();
-// }
-// }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) ));
- }
-
- public static Predicate<ApplicationEvent> afterDate( final Instant afterDate )
- {
- return event -> event.on().get().isAfter( afterDate );
- }
-
- public static Predicate<ApplicationEvent> beforeDate( final Instant beforeDate )
- {
- return event -> event.on().get().isBefore( beforeDate );
- }
-
- public static Predicate<ApplicationEvent> withUsecases( final String... names )
- {
- return event -> {
- for (String name : names)
- {
- if (event.usecase().get().equals( name ))
- return true;
- }
- return false;
- };
- }
-
- public static Predicate<ApplicationEvent> paramIs( final String name, final String value )
- {
- return event -> ApplicationEventParameters.getParameter( event, name ).equals( value );
- }
-
- public static Output<TransactionApplicationEvents, ApplicationEventReplayException> playEvents( final ApplicationEventPlayer player, final Object eventHandler )
- {
- final Predicate<ApplicationEvent> specification = ApplicationEvents.withNames( eventHandler.getClass() );
-
- return new Output<TransactionApplicationEvents, ApplicationEventReplayException>()
- {
- @Override
- public <SenderThrowableType extends Throwable> void receiveFrom(Sender<? extends TransactionApplicationEvents, SenderThrowableType> sender) throws ApplicationEventReplayException, SenderThrowableType
- {
- sender.sendTo( new Receiver<TransactionApplicationEvents, ApplicationEventReplayException>()
- {
- @Override
- public void receive( TransactionApplicationEvents item ) throws ApplicationEventReplayException
- {
- for (ApplicationEvent applicationEvent : events( item ))
- {
- if (specification.test( applicationEvent ))
- player.playEvent( applicationEvent, eventHandler );
- }
- }
- } );
- }
- };
- }
-
- private static class WithNamesPredicate implements Predicate<ApplicationEvent>
- {
- private final Class eventClass;
-
- public WithNamesPredicate( Class eventClass )
- {
- this.eventClass = eventClass;
- }
-
- @Override
- public boolean test( ApplicationEvent 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/application/source/helper/ApplicationTransactionTracker.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationTransactionTracker.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationTransactionTracker.java
deleted file mode 100644
index 112a62a..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationTransactionTracker.java
+++ /dev/null
@@ -1,155 +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.application.source.helper;
-
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import org.apache.zest.library.eventsourcing.application.source.ApplicationEventSource;
-import org.apache.zest.library.eventsourcing.application.source.ApplicationEventStream;
-import org.apache.zest.library.eventsourcing.domain.source.helper.DomainEventTrackerConfiguration;
-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 ApplicationTransactionTracker<ReceiverThrowableType extends Throwable>
-{
- private Configuration<? extends DomainEventTrackerConfiguration> configuration;
- private Output<TransactionApplicationEvents, ReceiverThrowableType> output;
- private ApplicationEventStream stream;
- private ApplicationEventSource source;
- private boolean started = false;
- private boolean upToSpeed = false;
- private Logger logger;
- private Output<TransactionApplicationEvents, ReceiverThrowableType> trackerOutput;
-
- public ApplicationTransactionTracker( ApplicationEventStream stream, ApplicationEventSource source,
- Configuration<? extends DomainEventTrackerConfiguration> configuration,
- Output<TransactionApplicationEvents, ReceiverThrowableType> output )
- {
- this.stream = stream;
- this.configuration = configuration;
- this.source = source;
- this.output = output;
-
- logger = LoggerFactory.getLogger( output.getClass() );
- }
-
- public void start()
- {
- if (!started)
- {
- started = true;
-
- // Get events since last check
- upToSpeed = true; // Pretend that we are up to speed from now on
- trackerOutput = output();
- try
- {
- source.transactionsAfter( configuration.get().lastOffset().get(), Long.MAX_VALUE ).transferTo( trackerOutput );
- } catch (Throwable receiverThrowableType)
- {
- upToSpeed = false;
- }
-
- stream.registerListener( trackerOutput );
- }
- }
-
- public void stop()
- {
- if (started)
- {
- started = false;
- stream.unregisterListener( trackerOutput );
- upToSpeed = false;
- }
- }
-
- private Output<TransactionApplicationEvents, ReceiverThrowableType> output()
- {
- return new Output<TransactionApplicationEvents, ReceiverThrowableType>()
- {
- @Override
- public <SenderThrowableType extends Throwable> void receiveFrom(final Sender<? extends TransactionApplicationEvents, SenderThrowableType> sender) throws ReceiverThrowableType, SenderThrowableType
- {
- if (!upToSpeed)
- {
- // The tracker has not handled successfully all transactions before,
- // so it needs to get the backlog first
-
- upToSpeed = true; // Pretend that we are up to speed from now on
-
- // Get all transactions from last timestamp, including the one in this call
- try
- {
- source.transactionsAfter( configuration.get().lastOffset().get(), Long.MAX_VALUE ).transferTo( trackerOutput );
- } catch (Throwable e)
- {
- upToSpeed = false;
- throw (SenderThrowableType) e;
- }
- }
-
- try
- {
- output.receiveFrom( new Sender<TransactionApplicationEvents, SenderThrowableType>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void sendTo(final Receiver<? super TransactionApplicationEvents, ReceiverThrowableType> receiver) throws ReceiverThrowableType, SenderThrowableType
- {
- sender.sendTo( new Receiver<TransactionApplicationEvents, ReceiverThrowableType>()
- {
- @Override
- public void receive( TransactionApplicationEvents item ) throws ReceiverThrowableType
- {
- receiver.receive( item );
-
- // Events in this transactionDomain were handled successfully so store new marker
- configuration.get().lastOffset().set( item.timestamp().get() );
- configuration.save();
- }
- } );
- }
- } );
- } catch (Throwable receiverThrowableType)
- {
- upToSpeed = false;
- throw (ReceiverThrowableType) receiverThrowableType;
- }
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/package.html
deleted file mode 100644
index 931b401..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/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 Application Source Helpers.</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/application/source/memory/MemoryApplicationEventStoreService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
deleted file mode 100644
index cde4af5..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
+++ /dev/null
@@ -1,142 +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.application.source.memory;
-
-import org.apache.zest.api.activation.Activators;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import org.apache.zest.library.eventsourcing.application.source.*;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * In-Memory ApplicationEventStore. Mainly used for testing.
- */
-@Mixins( MemoryApplicationEventStoreService.MemoryStoreMixin.class )
-@Activators( ApplicationEventStoreActivation.Activator.class )
-public interface MemoryApplicationEventStoreService
- extends ApplicationEventSource, ApplicationEventStore, ApplicationEventStream, ApplicationEventStoreActivation, ServiceComposite
-{
- abstract class MemoryStoreMixin
- extends AbstractApplicationEventStoreMixin
- implements ApplicationEventSource, ApplicationEventStoreActivation
- {
- // This list holds all transactions
- private LinkedList<TransactionApplicationEvents> store = new LinkedList<TransactionApplicationEvents>();
-
- @Override
- public Input<TransactionApplicationEvents, IOException> transactionsAfter( final long afterTimestamp, final long maxTransactions )
- {
- return new Input<TransactionApplicationEvents, IOException>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super TransactionApplicationEvents, ReceiverThrowableType> output )
- throws IOException, ReceiverThrowableType
- {
- // Lock store first
- lock.lock();
- try
- {
- output.receiveFrom( new Sender<TransactionApplicationEvents, IOException>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super TransactionApplicationEvents, ReceiverThrowableType> receiver )
- throws ReceiverThrowableType, IOException
- {
- Iterator<TransactionApplicationEvents> iterator = store.iterator();
-
- long count = 0;
-
- while( iterator.hasNext() && count < maxTransactions )
- {
- TransactionApplicationEvents next = iterator.next();
- if( next.timestamp().get() > afterTimestamp )
- {
- receiver.receive( next );
- count++;
- }
- }
- }
- });
- }
- finally
- {
- lock.unlock();
- }
- }
- };
- }
-
- @Override
- public Input<TransactionApplicationEvents, IOException> transactionsBefore( final long beforeTimestamp, final long maxTransactions )
- {
- return new Input<TransactionApplicationEvents, IOException>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super TransactionApplicationEvents, ReceiverThrowableType> output )
- throws IOException, ReceiverThrowableType
- {
- // Lock store first
- lock.lock();
- try
- {
- output.receiveFrom( new Sender<TransactionApplicationEvents, IOException>()
- {
- @Override
- public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super TransactionApplicationEvents, ReceiverThrowableType> receiver )
- throws ReceiverThrowableType, IOException
- {
- Iterator<TransactionApplicationEvents> iterator = store.descendingIterator();
-
- long count = 0;
-
- while( iterator.hasNext() && count < maxTransactions )
- {
- TransactionApplicationEvents next = iterator.next();
- if( next.timestamp().get() < beforeTimestamp )
- {
- receiver.receive( next );
- count++;
- }
- }
- }
- });
- }
- finally
- {
- lock.unlock();
- }
- }
- };
- }
-
- @Override
- protected void storeEvents( TransactionApplicationEvents transactionDomain ) throws IOException
- {
- store.add( transactionDomain );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/package.html
deleted file mode 100644
index 0b74afe..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/memory/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 in-memory EventStore.</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/application/source/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/package.html
deleted file mode 100644
index 6ac248d..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/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 Application Source.</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/bootstrap/EventsourcingAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/EventsourcingAssembler.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/EventsourcingAssembler.java
deleted file mode 100644
index 7976d4b..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/EventsourcingAssembler.java
+++ /dev/null
@@ -1,82 +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.bootstrap;
-
-import org.apache.zest.bootstrap.Assemblers;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ImportedServiceDeclaration;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import org.apache.zest.library.eventsourcing.application.factory.ApplicationEventFactoryService;
-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.factory.CurrentUserUoWPrincipal;
-import org.apache.zest.library.eventsourcing.domain.factory.DomainEventFactoryService;
-
-public class EventsourcingAssembler
- extends Assemblers.Visibility<EventsourcingAssembler>
-{
- private boolean domainEvents;
- private boolean applicationEvents;
-
- private boolean uowPrincipal;
-
- public EventsourcingAssembler withDomainEvents()
- {
- domainEvents = true;
- return this;
- }
-
- public EventsourcingAssembler withApplicationEvents()
- {
- applicationEvents = true;
- return this;
- }
-
- public EventsourcingAssembler withCurrentUserFromUOWPrincipal()
- {
- uowPrincipal = true;
- return this;
- }
-
- @Override
- public void assemble(ModuleAssembly module) throws AssemblyException
- {
- if( domainEvents )
- {
- module.values( DomainEventValue.class, UnitOfWorkDomainEventsValue.class );
- module.services( DomainEventFactoryService.class).visibleIn(visibility() );
- }
-
- if( applicationEvents )
- {
- module.values( ApplicationEvent.class, TransactionApplicationEvents.class );
- module.services( ApplicationEventFactoryService.class ).visibleIn( visibility() );
- }
-
- if( uowPrincipal )
- {
- module.importedServices( CurrentUserUoWPrincipal.class )
- .importedBy( ImportedServiceDeclaration.NEW_OBJECT );
- module.objects( CurrentUserUoWPrincipal.class );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/package.html
deleted file mode 100644
index 89a0dce..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/bootstrap/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 Assembly.</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/api/DomainEvent.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvent.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvent.java
deleted file mode 100644
index d6813f8..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.api;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Annotate methods that should trigger domain events with this annotation. Example:
- * <pre>
- * @DomainEvent
- * void changedDescription(String newDescription);
- * </pre>
- * Event methods may only change state. They may not fail or thrown exceptions. The name of the
- * method should be in past tense, as in something HAS already occurred, and the method is merely
- * reacting to it.
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DomainEvent
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEventValue.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEventValue.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEventValue.java
deleted file mode 100644
index 9f52ae1..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEventValue.java
+++ /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.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.api;
-
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- * Representation of a domain-event.
- * <p>An event is triggered by calling a method that is of the form:
- * </p>
- * <pre><code>
- * @DomainEvent
- * void someName(SomeParam param, AnotherParam param2);
- * </code></pre>
- *
- */
-public interface DomainEventValue
- extends ValueComposite
-{
- // Type of the entity being invoked
- Property<String> entityType();
-
- // Id of the entity that generated the event
- Property<String> entityId();
-
- // Name of method/event
- Property<String> name();
-
- // Method parameters as JSON
- Property<String> parameters();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvents.java
deleted file mode 100644
index 14af4c6..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/DomainEvents.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.eventsourcing.domain.api;
-
-/**
- * This gives access to the current domain event. This is only usable within methods
- * marked with @DomainEvent annotation.
- */
-public class DomainEvents
-{
- private static ThreadLocal<DomainEventValue> event = new ThreadLocal<DomainEventValue>();
-
- public static DomainEventValue currentEvent()
- {
- return event.get();
- }
-
- /**
- * This is called by the EventSourcing library, either during creation or replay.
- * Don't use in application code.
- *
- * @param currentEvent new current event
- */
- public static void setCurrentEvent(DomainEventValue currentEvent)
- {
- event.set( currentEvent );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
deleted file mode 100644
index 4cec265..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
+++ /dev/null
@@ -1,57 +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.api;
-
-import java.time.Instant;
-import java.util.List;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- * List of events for a single UnitOfWork. Events must always be consumed
- * in UoW units, in order to ensure that the result is consistent
- * with what happened in that UoW.
- *
- * Context that is common to all events in the UoW is stored here rather than
- * in the individual event.
- */
-public interface UnitOfWorkDomainEventsValue
- extends ValueComposite
-{
- // Version of the application that created these events
- Property<String> version();
-
- // Usecase name
- Property<String> usecase();
-
- // When the event occurred
- Property<Instant> timestamp();
-
- // Who performed the event. Taken from CurrentUser service.
- @Optional
- Property<String> user();
-
- // List of events for this transaction
- @UseDefaults
- Property<List<DomainEventValue>> events();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/package.html
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/package.html b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/package.html
deleted file mode 100644
index f54ea77..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/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 API.</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/factory/CurrentUserSubject.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserSubject.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserSubject.java
deleted file mode 100644
index a35dbf9..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserSubject.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.factory;
-
-import java.security.AccessController;
-import javax.security.auth.Subject;
-import org.apache.zest.library.eventsourcing.domain.spi.CurrentUser;
-
-/**
- * Uses thread-associated Subject to get the current user name. Default to "unknown".
- */
-public class CurrentUserSubject
- implements CurrentUser
-{
- @Override
- public String getCurrentUser()
- {
- try
- {
- return Subject.getSubject( AccessController.getContext() ).getPrincipals().iterator().next().getName();
- } catch (Exception e)
- {
- return "unknown";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserUoWPrincipal.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserUoWPrincipal.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserUoWPrincipal.java
deleted file mode 100644
index a21a626..0000000
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/CurrentUserUoWPrincipal.java
+++ /dev/null
@@ -1,48 +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.security.Principal;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.library.eventsourcing.domain.spi.CurrentUser;
-
-/**
- * CurrentUser implementation that gets a Principal object from the meta-info of the current UnitOfWork. Default to "unknown".
- */
-public class CurrentUserUoWPrincipal
- implements CurrentUser
-{
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Override
- public String getCurrentUser()
- {
- try
- {
- return uowf.currentUnitOfWork().metaInfo( Principal.class ).getName();
- } catch (Exception e)
- {
- return "unknown";
- }
- }
-}