use of org.teiid.Replicated in project teiid by teiid.
the class AbstractEventDistributorFactoryService method start.
public void start() {
final EventDistributor ed = new EventDistributorImpl() {
@Override
public VDBRepository getVdbRepository() {
return AbstractEventDistributorFactoryService.this.getVdbRepository();
}
@Override
public DQPCore getDQPCore() {
return AbstractEventDistributorFactoryService.this.getDQPCore();
}
};
ObjectReplicator objectReplicator = getObjectReplicator();
// this instance is by use of teiid internally; only invokes the remote instances
if (objectReplicator != null) {
try {
// $NON-NLS-1$
this.replicatableEventDistributor = objectReplicator.replicate("$TEIID_ED$", EventDistributor.class, ed, 0);
} catch (Exception e) {
LogManager.logError(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40088, this));
}
}
// for external client to call. invokes local instance and remote ones too.
this.eventDistributorProxy = (EventDistributor) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { EventDistributor.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Replicated annotation = method.getAnnotation(Replicated.class);
Object result = null;
try {
if (replicatableEventDistributor == null || (annotation != null && annotation.remoteOnly())) {
result = method.invoke(ed, args);
}
if (replicatableEventDistributor != null) {
result = method.invoke(replicatableEventDistributor, args);
}
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
return result;
}
});
}
Aggregations