Examples of DomainEventValue


Examples of org.qi4j.library.eventsourcing.domain.api.DomainEventValue

    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
View Full Code Here

Examples of org.qi4j.library.eventsourcing.domain.api.DomainEventValue

    @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)
        {
View Full Code Here

Examples of org.qi4j.library.eventsourcing.domain.api.DomainEventValue

        @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( first(Qi4j.FUNCTION_DESCRIPTOR_FOR.map( entity ).types()).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() );

            DomainEventValue eventValue = builder.newInstance();

            return eventValue;
        }
View Full Code Here

Examples of org.qi4j.library.eventsourcing.domain.api.DomainEventValue

        @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;
View Full Code Here

Examples of org.qi4j.samples.forum.domainevent.DomainEventValue

            throws Throwable
        {
            UnitOfWork unitOfWork = module.currentUnitOfWork();

            ValueBuilder<DomainEventValue> builder = module.newValueBuilder( DomainEventValue.class );
            DomainEventValue prototype = builder.prototype();
            prototype.version().set( application.version() );
            prototype.timestamp().set( unitOfWork.currentTime() );
            prototype.context().set( proxy.getClass().getSuperclass().getName().split( "\\$" )[ 0 ] );
            prototype.name().set( method.getName() );

            int idx = 0;
            for( Object arg : args )
            {
                idx++;
                String name = "param" + idx;
                ValueBuilder<ParameterValue> parameterBuilder = module.newValueBuilder( ParameterValue.class );
                parameterBuilder.prototype().name().set( name );
                parameterBuilder.prototype().value().set( arg );
                prototype.parameters().get().add( parameterBuilder.newInstance() );
            }

            Iterables.addAll( prototype.selection().get(), Iterables.map( new Function<Object, String>()
            {
                @Override
                public String map( Object o )
                {
                    return o.toString();
                }
            }, ObjectSelection.current().selection() ) );

            final DomainEventValue domainEvent = builder.newInstance();

            // Send event to all interested parties in the ObjectSelection
            for( Object selectedObject : ObjectSelection.current().selection() )
            {
                if( selectedObject instanceof Events )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.