Package org.qi4j.library.eventsourcing.application.api

Examples of org.qi4j.library.eventsourcing.application.api.ApplicationEvent


        @Override
        public ApplicationEvent createEvent( String name, Object[] args )
        {
            ValueBuilder<ApplicationEvent> builder = vbf.newValueBuilder( ApplicationEvent.class );

            ApplicationEvent prototype = builder.prototype();
            prototype.name().set( name );
            prototype.on().set( new Date() );

            prototype.identity().set( idGenerator.generate( ApplicationEvent.class ) );

            UnitOfWork uow = uowf.currentUnitOfWork();
            prototype.usecase().set( uow.usecase().name() );
            prototype.version().set( version );

            // JSON-ify parameters
            JSONStringer json = new JSONStringer();
            try
            {
                JSONWriter params = json.object();
                for (int i = 1; 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 event", e );
            }

            prototype.parameters().set( json.toString() );

            ApplicationEvent event = builder.newInstance();

            return event;
        }
View Full Code Here


    public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
    {
        if (args[0] == null)
        {
            // Create application event
            ApplicationEvent event = eventFactory.createEvent( method.getName(), args );
            args[0] = event;
        }

        return next.invoke( proxy, method, args );
    }
View Full Code Here

    @Override
    public ApplicationEvent createEvent( String name, Object[] args )
    {
        final UnitOfWork unitOfWork = uowf.currentUnitOfWork();

        ApplicationEvent event = next.createEvent( name, args );

        // Add event to list in UoW
        UnitOfWorkApplicationEvents events = unitOfWork.metaInfo( UnitOfWorkApplicationEvents.class );
        if( events == null )
        {
View Full Code Here

TOP

Related Classes of org.qi4j.library.eventsourcing.application.api.ApplicationEvent

Copyright © 2018 www.massapicom. 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.