Skip to content

Commit

Permalink
DomainObject
Browse files Browse the repository at this point in the history
  • Loading branch information
xlorne committed Feb 7, 2020
1 parent dc00ad5 commit a98058d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 144 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,51 +1,25 @@
package com.alibaba.cola.domain;

import com.alibaba.cola.common.ApplicationContextHelper;
import com.alibaba.cola.event.EventBus;
import com.alibaba.cola.repository.RepositoryBus;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

/**
* @author lorne
* @date 2020/1/23
* @description
*/
public abstract class DomainObject extends EntityObject {

protected EventBus eventBus;

protected RepositoryBus repositoryBus;
protected static EventBus eventBus;

public final void initEventBus(EventBus eventBus){
this.eventBus = eventBus;
}
protected static RepositoryBus repositoryBus;

public final void initPresentationBus(RepositoryBus repositoryBus){
this.repositoryBus = repositoryBus;
static {
eventBus = ApplicationContextHelper.getBean(EventBus.class);
repositoryBus = ApplicationContextHelper.getBean(RepositoryBus.class);
}

public void execute(){}

public final <T extends DomainObject> T createDomain(Class<T> clazz, Object ... initargs) {
List<Class<?>> list =null;
if(initargs!=null){
list = new ArrayList<>();
for (Object obj:initargs){
list.add(obj.getClass());
}
}
Class<?>[] parameterTypes = list!=null?list.toArray(new Class[]{}):null;
try {
DomainObject domain = clazz.getDeclaredConstructor(parameterTypes).newInstance(initargs);
domain.initEventBus(eventBus);
domain.initPresentationBus(repositoryBus);
return (T)domain;
} catch (InstantiationException | IllegalAccessException |
InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

}

This file was deleted.

This file was deleted.

0 comments on commit a98058d

Please sign in to comment.