Search in sources :

Example 1 with ChannelInterceptor

use of org.apache.catalina.tribes.ChannelInterceptor in project tomcat by apache.

the class InterceptorSF method storeChildren.

/**
     * Store the specified Interceptor child.
     *
     * @param aWriter
     *            PrintWriter to which we are storing
     * @param indent
     *            Number of spaces to indent this element
     * @param aInterceptor
     *            Channel whose properties are being stored
     *
     * @exception Exception
     *                if an exception occurs while storing
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aInterceptor, StoreDescription parentDesc) throws Exception {
    if (aInterceptor instanceof StaticMembershipInterceptor) {
        ChannelInterceptor interceptor = (ChannelInterceptor) aInterceptor;
        // Store nested <Member> elements
        storeElementArray(aWriter, indent + 2, interceptor.getMembers());
    }
}
Also used : StaticMembershipInterceptor(org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor) ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor)

Example 2 with ChannelInterceptor

use of org.apache.catalina.tribes.ChannelInterceptor in project tomcat by apache.

the class GroupChannel method setupDefaultStack.

/**
     * Sets up the default implementation interceptor stack
     * if no interceptors have been added
     * @throws ChannelException Cluster error
     */
protected synchronized void setupDefaultStack() throws ChannelException {
    if (getFirstInterceptor() != null && ((getFirstInterceptor().getNext() instanceof ChannelCoordinator))) {
        addInterceptor(new MessageDispatchInterceptor());
    }
    Iterator<ChannelInterceptor> interceptors = getInterceptors();
    while (interceptors.hasNext()) {
        ChannelInterceptor channelInterceptor = interceptors.next();
        channelInterceptor.setChannel(this);
    }
    coordinator.setChannel(this);
}
Also used : MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor)

Example 3 with ChannelInterceptor

use of org.apache.catalina.tribes.ChannelInterceptor in project tomcat by apache.

the class StaticMembershipInterceptor method getfirstInterceptor.

protected ChannelInterceptor getfirstInterceptor() {
    ChannelInterceptor result = null;
    ChannelInterceptor now = this;
    do {
        result = now;
        now = now.getPrevious();
    } while (now.getPrevious() != null);
    return result;
}
Also used : ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor)

Example 4 with ChannelInterceptor

use of org.apache.catalina.tribes.ChannelInterceptor in project tomcat by apache.

the class GroupChannel method checkOptionFlags.

/**
     * Validates the option flags that each interceptor is using and reports
     * an error if two interceptor share the same flag.
     * @throws ChannelException Error with option flag
     */
protected void checkOptionFlags() throws ChannelException {
    StringBuilder conflicts = new StringBuilder();
    ChannelInterceptor first = interceptors;
    while (first != null) {
        int flag = first.getOptionFlag();
        if (flag != 0) {
            ChannelInterceptor next = first.getNext();
            while (next != null) {
                int nflag = next.getOptionFlag();
                if (nflag != 0 && (((flag & nflag) == flag) || ((flag & nflag) == nflag))) {
                    conflicts.append("[");
                    conflicts.append(first.getClass().getName());
                    conflicts.append(":");
                    conflicts.append(flag);
                    conflicts.append(" == ");
                    conflicts.append(next.getClass().getName());
                    conflicts.append(":");
                    conflicts.append(nflag);
                    conflicts.append("] ");
                }
                //end if
                next = next.getNext();
            }
        //while
        }
        //end if
        first = first.getNext();
    }
    //while
    if (conflicts.length() > 0)
        throw new ChannelException(sm.getString("groupChannel.optionFlag.conflict", conflicts.toString()));
}
Also used : ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor) ChannelException(org.apache.catalina.tribes.ChannelException)

Example 5 with ChannelInterceptor

use of org.apache.catalina.tribes.ChannelInterceptor in project tomcat by apache.

the class TestGroupChannelOptionFlag method testOptionNoConflict.

@Test
public void testOptionNoConflict() throws Exception {
    boolean error = false;
    channel.setOptionCheck(true);
    ChannelInterceptor i = new TestInterceptor();
    i.setOptionFlag(128);
    channel.addInterceptor(i);
    i = new TestInterceptor();
    i.setOptionFlag(64);
    channel.addInterceptor(i);
    i = new TestInterceptor();
    i.setOptionFlag(256);
    channel.addInterceptor(i);
    try {
        channel.start(Channel.DEFAULT);
    } catch (ChannelException x) {
        if (x.getMessage().indexOf("option flag conflict") >= 0)
            error = true;
    }
    assertFalse(error);
}
Also used : ChannelInterceptor(org.apache.catalina.tribes.ChannelInterceptor) ChannelException(org.apache.catalina.tribes.ChannelException) Test(org.junit.Test)

Aggregations

ChannelInterceptor (org.apache.catalina.tribes.ChannelInterceptor)10 ChannelException (org.apache.catalina.tribes.ChannelException)3 Test (org.junit.Test)2 WeakReference (java.lang.ref.WeakReference)1 Channel (org.apache.catalina.tribes.Channel)1 ChannelReceiver (org.apache.catalina.tribes.ChannelReceiver)1 ChannelSender (org.apache.catalina.tribes.ChannelSender)1 ManagedChannel (org.apache.catalina.tribes.ManagedChannel)1 Member (org.apache.catalina.tribes.Member)1 MembershipService (org.apache.catalina.tribes.MembershipService)1 ChannelInterceptorBase (org.apache.catalina.tribes.group.ChannelInterceptorBase)1 MessageDispatchInterceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor)1 StaticMembershipInterceptor (org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor)1