@Send to @Consumer 沒測試成功,請benq百忙之中指點一下

javaGhost發表於2013-12-23
今天下載了jdonframework-6.8進行試用。
首先, 建了一個Model

@[author]Model[/author]
@[author]Introduce[/author]("message")
public class My[author]Model[/author]{

	private String id;
	private String name;
	
	@[author]Send[/author]("myMethod.has.done")
	public DomainMessage myMethod(){
		System.out.println("myMethod are doing...");
		DomainMessage dm = new DomainMessage(this.name);
		return dm;
	}
}
<p class="indent">



第二, 建了一個Consumer

@[author]Consumer[/author]("myMethod.has.done")
public class MyDomainEventHandler implements DomainEventHandler {
	@[author][author]Override[/author][/author]
	public void onEvent(EventDisruptor arg0, boolean arg1) throws Exception {
		System.out.println("I just received a message: 'myMethod.has.done'");
	}
}
<p class="indent">


第三,建了一個Service介面,並實現

public interface MyService {
	public void doit();
}
<p class="indent">


@[author]Component[/author]("myService")
public class MyServiceImpl implements MyService {

	@[author][author]Override[/author][/author]
	public void doit() {
		My[author]Model[/author] mm = new My[author]Model[/author]();
		mm.myMethod();
	}
}
<p class="indent">


第四,建了一個client,

public class Client {
	public static void main(String[] args){
		AppUtil appUtil = new AppUtil();
		MyService ms = (MyService)appUtil.get[author]Component[/author]Instance("myService");
		ms.doit();
	}
}
<p class="indent">


最後,執行client,發現MyDomainEventHandler.onEvent()沒有執行。
請大家幫我看看,是我哪兒沒做對?



[該貼被javaGhost於2013-12-23 21:56修改過]

[該貼被javaGhost於2013-12-23 21:59修改過]

[該貼被javaGhost於2013-12-23 22:02修改過]

[該貼被javaGhost於2013-12-23 22:03修改過]

[該貼被javaGhost於2013-12-23 22:07修改過]

相關文章