Skip to content

Commit

Permalink
add Disruptor(http://code.google.com/p/disruptor/) to DomainEvents, s…
Browse files Browse the repository at this point in the history
…upports Producer-Consumer mode of Domain Events.
  • Loading branch information
banq committed Sep 6, 2011
1 parent 72cf8ec commit 3098cdd
Show file tree
Hide file tree
Showing 58 changed files with 1,476 additions and 641 deletions.
69 changes: 35 additions & 34 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="examples/remote_javafx/ext/hessian-3.1.6.jar"/>
<classpathentry kind="lib" path="examples/remote_javafx/lib_client/javafxrt.jar"/>
<classpathentry kind="lib" path="examples/remote_javafx/web/hello.jar"/>
<classpathentry kind="lib" path="j2eelib/hibernate/hibernate-annotations.jar"/>
<classpathentry kind="lib" path="j2eelib/hibernate/hibernate3.jar"/>
<classpathentry kind="lib" path="j2eelib/jboss-j2ee.jar"/>
<classpathentry kind="lib" path="j2eelib/jbosssx.jar"/>
<classpathentry kind="lib" path="j2eelib/jsp-api.jar"/>
<classpathentry kind="lib" path="j2eelib/servlet-api.jar"/>
<classpathentry kind="lib" path="lib/cglib.jar"/>
<classpathentry kind="lib" path="lib/commons-pool-1.5.1.jar"/>
<classpathentry kind="lib" path="lib/ehcache-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/hessian-3.1.6.jar"/>
<classpathentry kind="lib" path="lib/jakarta-regexp-1.1.jar"/>
<classpathentry kind="lib" path="lib/jdom.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/log4j.jar"/>
<classpathentry kind="lib" path="strutslib/commons-beanutils.jar"/>
<classpathentry kind="lib" path="strutslib/commons-collections.jar"/>
<classpathentry kind="lib" path="strutslib/commons-digester.jar"/>
<classpathentry kind="lib" path="strutslib/commons-fileupload.jar"/>
<classpathentry kind="lib" path="strutslib/commons-logging.jar"/>
<classpathentry kind="lib" path="strutslib/commons-pool-1.4.jar"/>
<classpathentry kind="lib" path="strutslib/commons-validator.jar"/>
<classpathentry kind="lib" path="strutslib/jakarta-oro.jar"/>
<classpathentry kind="lib" path="strutslib/struts.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/picocontainer-1.1.jar"/>
<classpathentry kind="lib" path="lib/scannotation-1.0.2.jar" sourcepath="F:/opensource/scanannotation/scannotation/src/main"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="examples/remote_javafx/ext/hessian-3.1.6.jar"/>
<classpathentry kind="lib" path="examples/remote_javafx/lib_client/javafxrt.jar"/>
<classpathentry kind="lib" path="examples/remote_javafx/web/hello.jar"/>
<classpathentry kind="lib" path="j2eelib/hibernate/hibernate-annotations.jar"/>
<classpathentry kind="lib" path="j2eelib/hibernate/hibernate3.jar"/>
<classpathentry kind="lib" path="j2eelib/jboss-j2ee.jar"/>
<classpathentry kind="lib" path="j2eelib/jbosssx.jar"/>
<classpathentry kind="lib" path="j2eelib/jsp-api.jar"/>
<classpathentry kind="lib" path="j2eelib/servlet-api.jar"/>
<classpathentry kind="lib" path="lib/cglib.jar"/>
<classpathentry kind="lib" path="lib/commons-pool-1.5.1.jar"/>
<classpathentry kind="lib" path="lib/ehcache-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/hessian-3.1.6.jar"/>
<classpathentry kind="lib" path="lib/jakarta-regexp-1.1.jar"/>
<classpathentry kind="lib" path="lib/jdom.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/log4j.jar"/>
<classpathentry kind="lib" path="strutslib/commons-beanutils.jar"/>
<classpathentry kind="lib" path="strutslib/commons-collections.jar"/>
<classpathentry kind="lib" path="strutslib/commons-digester.jar"/>
<classpathentry kind="lib" path="strutslib/commons-fileupload.jar"/>
<classpathentry kind="lib" path="strutslib/commons-logging.jar"/>
<classpathentry kind="lib" path="strutslib/commons-pool-1.4.jar"/>
<classpathentry kind="lib" path="strutslib/commons-validator.jar"/>
<classpathentry kind="lib" path="strutslib/jakarta-oro.jar"/>
<classpathentry kind="lib" path="strutslib/struts.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/picocontainer-1.1.jar"/>
<classpathentry kind="lib" path="lib/scannotation-1.0.2.jar" sourcepath="F:/opensource/scanannotation/scannotation/src/main"/>
<classpathentry kind="lib" path="lib/disruptor-2.0.2.jar" sourcepath="/disruptor"/>
<classpathentry kind="output" path="classes"/>
</classpath>
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>

<project name="Jdon Framework 6.2.1" default="all" basedir=".">
<project name="Jdon Framework 6.4" default="all" basedir=".">

<!-- properies -->

Expand Down
Binary file added dist/disruptor-2.0.2.jar
Binary file not shown.
Binary file modified dist/jdon-hibernate3x.jar
Binary file not shown.
Binary file modified dist/jdon-remote-hessian.jar
Binary file not shown.
Binary file modified dist/jdon-struts1x.jar
Binary file not shown.
Binary file modified dist/jdonFramework.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions doc/site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3 align="left">Latest News</h3>
<P><a href="https://sourceforge.net/projects/jdon/files/">JiveJdon4.2 with JdonFramework</a> <STRONG>released!(like Quora Forum or BBS or Blog software)</STRONG> <strong> </strong>2011-3-16</P>
<P><STRONG><a href="http://sourceforge.net/projects/jdon/files/">JdonFramework_6.2.3 (DDD Framework) </a>released!</STRONG> <strong> 2010-5-5</strong></P>
<P><br>
<a href="https://sourceforge.net/projects/jdon/files/all-in-one/jivejdon_tomcat_mysql/xampp.rar/download" target="_blank">JiveJdon4.1 + Tomcat 6 + MySQL 5 + PHP all-in-one </a>download, quickly start jivejdon 2010-5-5</P>
<a href="https://sourceforge.net/projects/jdon/files/all-in-one/jivejdon_tomcat_mysql/xampp.rar/download" target="_blank">JiveJdon4.1 + Tomcat 6 + MySQL 5 all-in-one </a>download, quickly start jivejdon 2010-5-5</P>
<P><a href="https://sourceforge.net/projects/jdon/files/JdonFramework-App/dddsample.war/download">Evans DDD Cargo Sample with JdonFramework</a> <STRONG>released!</STRONG> <strong> </strong>2009-11-14</P>

<P>Sample DEMO: <a href="http://www.jdon.com/testWeb/" target="_blank">http://www.jdon.com/testWeb/</a><br>
Expand All @@ -60,7 +60,8 @@ <H3>Introduction to JdonFramework : a DDD Framework </H3>
style="BORDER-TOP-WIDTH: 2px; BORDER-LEFT-WIDTH: 2px; BORDER-BOTTOM-WIDTH: 2px; MARGIN-LEFT: 0px; BORDER-RIGHT-WIDTH: 2px">
<P><span class="STYLE1">Simply the Best</span>! <br>
JdonFramework is a light-weight framework for developing Domain-Driven Design applications
in the spirit of Evans and Vens, it combines with <strong>rapidity</strong> and <strong>agility</strong> for your web application architecture.</P>
in the spirit of Evans and Vens, it combines with <strong>rapidity</strong> and <strong>agility</strong> for your web application architecture. </P>
<P>JdonFramework is a Domain Model + In -memeory Cache + Event Sourcing(CQRS) framework, it is a simple version like <a href="http://martinfowler.com/articles/lmax.html">LMAX Architecture</a> wriiten by Martin Fowler.</P>
<P><strong>Domain Events for Evans DDD </strong>:</P>
<P>Real domain logic is in the Domain Model,
Outside the domain are these adapters, that listen to messages sent by
Expand Down
Binary file added lib/disruptor-2.0.2.jar
Binary file not shown.
22 changes: 12 additions & 10 deletions report/TEST-com.jdon.SampleAppTest.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Testsuite: com.jdon.SampleAppTest
Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 11.091 sec
Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 11.636 sec
------------- Standard Output ---------------
call A.myMethod1

Expand Down Expand Up @@ -49,21 +49,23 @@ this is D.myMethod3 is active!!!!
this is AroundAdvice after

name=helloeventMessage=hello
CDomainEventHandler Actionhello
DomainEventHandler action hello
sayHelloeventMessage=100
------------- ---------------- ---------------
------------- Standard Error -----------------
2011-7-31 17:13:36 net.sf.ehcache.CacheManager detectAndFixDiskStorePathConflict
2011-9-5 17:01:34 net.sf.ehcache.CacheManager detectAndFixDiskStorePathConflict
����: Creating a new instance of CacheManager using the diskStorePath "C:\Users\ADMINI~1\AppData\Local\Temp\" which is already used by an existing CacheManager.
The source of the configuration was InputStream java.io.BufferedInputStream@174219d.
The diskStore path for this CacheManager will be set to C:\Users\ADMINI~1\AppData\Local\Temp\\ehcache_auto_created_1312103616675.
The source of the configuration was InputStream java.io.BufferedInputStream@6355dc.
The diskStore path for this CacheManager will be set to C:\Users\ADMINI~1\AppData\Local\Temp\\ehcache_auto_created_1315213294045.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
2011-7-31 17:13:40 net.sf.ehcache.CacheManager detectAndFixDiskStorePathConflict
2011-9-5 17:01:37 net.sf.ehcache.CacheManager detectAndFixDiskStorePathConflict
����: Creating a new instance of CacheManager using the diskStorePath "C:\Users\ADMINI~1\AppData\Local\Temp\" which is already used by an existing CacheManager.
The source of the configuration was InputStream java.io.BufferedInputStream@139e351.
The diskStore path for this CacheManager will be set to C:\Users\ADMINI~1\AppData\Local\Temp\\ehcache_auto_created_1312103620044.
The source of the configuration was InputStream java.io.BufferedInputStream@502819.
The diskStore path for this CacheManager will be set to C:\Users\ADMINI~1\AppData\Local\Temp\\ehcache_auto_created_1315213297619.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
------------- ---------------- ---------------

Testcase: testGetService took 4.369 sec
Testcase: testDomainEvent took 3.357 sec
Testcase: testDomainEventSimple took 3.356 sec
Testcase: testGetService took 4.444 sec
Testcase: testDomainEvent took 3.776 sec
Testcase: testDomainEventSimple took 3.4 sec
4 changes: 2 additions & 2 deletions report/TEST-com.jdon.container.ContainerDirectorTest.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Testsuite: com.jdon.container.ContainerDirectorTest
Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 3.5 sec
Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 3.091 sec

Testcase: testStartup took 3.495 sec
Testcase: testStartup took 3.085 sec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Testsuite: com.jdon.container.config.ContainerComponentsXmlLoaderTest
Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.123 sec
Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.124 sec

Testcase: testLoad took 0.119 sec
Testcase: testLoad took 0.118 sec
2 changes: 1 addition & 1 deletion src/META-INF/aspect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<interceptor name="modelCache" class="com.jdon.domain.DomainCacheInterceptor" pointcut="domain" />

<interceptor name="message" class="com.jdon.domain.message.MessageInterceptor" pointcut="model" />



</aspect>
17 changes: 14 additions & 3 deletions src/META-INF/container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@

<component name="modelProxyInjection" class="com.jdon.domain.model.injection.ModelProxyInjection"></component>

<!-- asnc start -->
<component name="disruptorParams" class="com.jdon.async.disruptor.DisruptorParams">
<constructor value="8" />
</component>

<component name="disruptorFactory" class="com.jdon.async.disruptor.DisruptorFactory"></component>


<component name="messageMediator" class="com.jdon.async.message.MessageMediatorImpl">
<component name="futureDirector" class="com.jdon.async.future.FutureDirector">
<constructor value="50" />
</component>

<component name="eventMessageFirer" class="com.jdon.async.EventMessageFirer"></component>



<!-- asnc end -->



</components>
24 changes: 0 additions & 24 deletions src/com/jdon/annotation/Channel.java

This file was deleted.

82 changes: 82 additions & 0 deletions src/com/jdon/annotation/Consumer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2003-2009 the original author or authors.
* Licensed 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 com.jdon.annotation;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Consumer of the producer annotated with @send(topic) of the method;
*
* * Topic/queue(1:N or 1:1):
*
* if a class annotated with @Consumer(XX); it must implements
* com.jdon.domain.message.DomainEventHandler
*
* @Send(topicName) ==> @Consumer(topicName);
*
* if there are many consumers, execution order will be
* alphabetical list by Name of @Consumer class.
*
* Domain Model producer /Consumer:
*
* 1. annotate the producer class with @Model and @Introduce("message")
*@Model
*@Introduce("message")
*public class DomainEvent {}
*
*
* 2. annotate the method with @Send("mytopic") of the producer class;
* * @Send("mytopic")
* public DomainMessage myMethod() {
* DomainMessage em = new DomainMessage(this.name);
* return em;
* }
*
* 3. the "mytopic" value in @Send("mytopic") is equals to the "mytopic" value
* in @Consumer("mytopic");
*
* 4. annotate the consumer class with @Consumer("mytopic");
*
* 5. the consumer class must implements
* com.jdon.domain.message.DomainEventHandler
*
* @Consumer("mychannel")
*public class MyDomainEventHandler implements DomainEventHandler {}
*
*
*
* @author banq
* @see @Send
*/
@Target(TYPE)
@Retention(RUNTIME)
@Documented
public @interface Consumer {
/**
* topic name
*
* @Send(topicName) ==> @Consumer(topicName);
*
* @return topic name
*/
String value();

}
54 changes: 54 additions & 0 deletions src/com/jdon/annotation/model/Send.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,57 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;


/**
*
* Domain Model should normal live in memory not in database. so cache in memory
* is very important for domain model life cycle.
*
* Example producer: com.jdon.sample.test.domain.onecase.DomainEvent
* Consumer:com.jdon.sample.test.domain.onecase.DomainListener
*
* Domain Model producer /Consumer:
*
* 1. annotate the producer class with @Model and @Introduce("message")
*@Model
*@Introduce("message")
*public class DomainEvent {}
*
* the value "message" of @@Introduce("message") is the om.jdon.domain.message.MessageInterceptor
* configured in aspect.xml
*
* 2. annotate the method with @Send("mytopic") of the producer class;
* * @Send("mytopic")
* public DomainMessage myMethod() {
* DomainMessage em = new DomainMessage(this.name);
* return em;
* }
*
* 3. the "mytopic" value in @Send("mytopic") is equals to the "mytopic" value
* in @Consumer("mytopic");
*
* 4. annotate the consumer class with @Consumer("mytopic");
*
* 5. the consumer class must implements
* com.jdon.domain.message.DomainEventHandler
*
* @Consumer("mychannel")
*public class MyDomainEventHandler implements DomainEventHandler {}
*
*
* Topic/queue(1:N or 1:1):
*
* @Send(topicName) ==> @Consumer(topicName);
*
*
*
* under version 6.3 there is a Older queue(1:1):
*
* @Send(topicName) ==> @Component(topicName);
*
* The message accepter class annotated with
* @Component(topicName) must implements com.jdon.domain.message.MessageListener
*
*
* @see com.jdon.controller.model.ModelIF
* @author banQ
Expand All @@ -20,6 +67,13 @@
@Retention(RUNTIME)
@Documented
public @interface Send {
/**
* topic/queue name
*
* @Send(topicName) ==> @Consumer(topicName);
*
* @return topic/queue name
*/
String value();

boolean asyn() default true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
* limitations under the License.
*
*/
package com.jdon.domain.message;
package com.jdon.async;


public interface MessageMediator {
public interface EventMessage {

public abstract void sendMessage(DomainMessage em);
Object getEventResult();

}
void setEventResult(Object eventResult);

}
Loading

0 comments on commit 3098cdd

Please sign in to comment.