Search in sources :

Example 1 with PubSubMethodListenerBase

use of com.ociweb.gl.impl.PubSubMethodListenerBase in project GreenLightning by oci-pronghorn.

the class ReactiveListenerStage method addSubscription.

public final <T extends Behavior> ListenerFilter addSubscription(CharSequence topic, CallableStaticMethod<T> method) {
    if (null == methods) {
        methodLookup = new TrieParser(16, 1, false, false, false);
        methodReader = new TrieParserReader(0, true);
        methods = new CallableStaticMethod[0];
    }
    if (!startupCompleted && listener instanceof PubSubMethodListenerBase) {
        builder.addStartupSubscription(topic, System.identityHashCode(listener), parallelInstance);
        toStringDetails = toStringDetails + "sub:'" + topic + "'\n";
    } else {
        if (startupCompleted) {
            throw new UnsupportedOperationException("Method dispatch subscritpions may not be modified at runtime.");
        }
    }
    int id = methods.length;
    methodLookup.setUTF8Value(topic, id);
    // grow the array of methods to be called
    CallableStaticMethod[] newArray = new CallableStaticMethod[id + 1];
    System.arraycopy(methods, 0, newArray, 0, id);
    newArray[id] = method;
    methods = newArray;
    // 
    return this;
}
Also used : PubSubMethodListenerBase(com.ociweb.gl.impl.PubSubMethodListenerBase) TrieParser(com.ociweb.pronghorn.util.TrieParser) TrieParserReader(com.ociweb.pronghorn.util.TrieParserReader)

Aggregations

PubSubMethodListenerBase (com.ociweb.gl.impl.PubSubMethodListenerBase)1 TrieParser (com.ociweb.pronghorn.util.TrieParser)1 TrieParserReader (com.ociweb.pronghorn.util.TrieParserReader)1