Search in sources :

Example 1 with CustomAction

use of io.atlasmap.v2.CustomAction in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionService method findActionProcessor.

@Override
public ActionProcessor findActionProcessor(Action action, FieldType sourceType) throws AtlasException {
    CustomAction customAction = null;
    if (action instanceof CustomAction) {
        customAction = (CustomAction) action;
        if (customAction.getClassName() == null || customAction.getMethodName() == null) {
            throw new AtlasException("The class name and method name must be specified for custom FieldAction: " + customAction.getName());
        }
    }
    List<ActionProcessor> matches = new ArrayList<>();
    Lock readLock = actionProcessorsLock.readLock();
    try {
        readLock.lock();
        for (ActionProcessor processor : actionProcessors) {
            if (customAction != null) {
                ActionDetail detail = processor.getActionDetail();
                if (customAction.getClassName().equals(detail.getClassName()) && customAction.getMethodName().equals(detail.getMethod())) {
                    matches.add(processor);
                    break;
                }
            } else if (processor.getActionClass() == action.getClass()) {
                matches.add(processor);
            }
        }
    } finally {
        readLock.unlock();
    }
    return findBestActionProcessor(matches, sourceType);
}
Also used : ActionDetail(io.atlasmap.v2.ActionDetail) CustomAction(io.atlasmap.v2.CustomAction) ArrayList(java.util.ArrayList) AtlasException(io.atlasmap.api.AtlasException) ActionProcessor(io.atlasmap.spi.ActionProcessor) AtlasActionProcessor(io.atlasmap.spi.AtlasActionProcessor) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

AtlasException (io.atlasmap.api.AtlasException)1 ActionProcessor (io.atlasmap.spi.ActionProcessor)1 AtlasActionProcessor (io.atlasmap.spi.AtlasActionProcessor)1 ActionDetail (io.atlasmap.v2.ActionDetail)1 CustomAction (io.atlasmap.v2.CustomAction)1 ArrayList (java.util.ArrayList)1 Lock (java.util.concurrent.locks.Lock)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1