if ( delegate.isRemote() ) {
RemoteAnalysisEngineType draet = dt.addNewRemoteAnalysisEngine();
draet.setKey(delegate.getKey());
containingAggregate.addDelegate( new RemoteDelegateEngineImpl( draet, (RemoteDelegateConfiguration)delegate, context) );
} else {
AnalysisEngineType dcaet = dt.addNewAnalysisEngine();
dcaet.setKey(delegate.getKey());
// colocated delegate, either nested aggregate or primitive
if ( ((ColocatedDelegateConfiguration)delegate).isAggregate() ) {
AggregateDelegateEngine a1 = new AggregateDelegateEngineImpl( dcaet, delegate.getKey(), context, (ColocatedDelegateConfiguration)delegate);
containingAggregate.addDelegate( a1 );
// recursive call to handle nested aggregate delegates
addDelegateEngine(a1, ((ColocatedDelegateConfiguration)delegate).getDelegates(), dcaet.addNewDelegates(), context);
} else {
// primitive
containingAggregate.addDelegate( new ColocatedDelegateEngineImpl( dcaet, (ColocatedDelegateConfiguration)delegate, context) );
}
}