Java Code Examples for org.apache.catalina.tribes.ChannelInterceptor#getNext()

The following examples show how to use org.apache.catalina.tribes.ChannelInterceptor#getNext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupChannel.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Adds an interceptor to the stack for message processing<br>
 * Interceptors are ordered in the way they are added.<br>
 * <code>channel.addInterceptor(A);</code><br>
 * <code>channel.addInterceptor(C);</code><br>
 * <code>channel.addInterceptor(B);</code><br>
 * Will result in an interceptor stack like this:<br>
 * <code>A -&gt; C -&gt; B</code><br>
 * The complete stack will look like this:<br>
 * <code>Channel -&gt; A -&gt; C -&gt; B -&gt; ChannelCoordinator</code><br>
 * @param interceptor ChannelInterceptorBase
 */
@Override
public void addInterceptor(ChannelInterceptor interceptor) {
    if ( interceptors == null ) {
        interceptors = interceptor;
        interceptors.setNext(coordinator);
        interceptors.setPrevious(null);
        coordinator.setPrevious(interceptors);
    } else {
        ChannelInterceptor last = interceptors;
        while ( last.getNext() != coordinator ) {
            last = last.getNext();
        }
        last.setNext(interceptor);
        interceptor.setNext(coordinator);
        interceptor.setPrevious(last);
        coordinator.setPrevious(interceptor);
    }
}
 
Example 2
Source File: TcpPingInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if ( thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel().getName() != null) channelName = "[" + getChannel().getName() + "]";
        thread.setName("TcpPingInterceptor.PingThread" + channelName +"-"+cnt.addAndGet(1));
        thread.start();
    }

    //acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while ( next != null ) {
        if ( next instanceof TcpFailureDetector )
            failureDetector = new WeakReference<>((TcpFailureDetector)next);
        if ( next instanceof StaticMembershipInterceptor )
            staticMembers = new WeakReference<>((StaticMembershipInterceptor)next);
        next = next.getNext();
    }

}
 
Example 3
Source File: GroupChannel.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Adds an interceptor to the stack for message processing<br>
 * Interceptors are ordered in the way they are added.<br>
 * <code>channel.addInterceptor(A);</code><br>
 * <code>channel.addInterceptor(C);</code><br>
 * <code>channel.addInterceptor(B);</code><br>
 * Will result in a interceptor stack like this:<br>
 * <code>A -> C -> B</code><br>
 * The complete stack will look like this:<br>
 * <code>Channel -> A -> C -> B -> ChannelCoordinator</code><br>
 * @param interceptor ChannelInterceptorBase
 */
@Override
public void addInterceptor(ChannelInterceptor interceptor) {
    if ( interceptors == null ) {
        interceptors = interceptor;
        interceptors.setNext(coordinator);
        interceptors.setPrevious(null);
        coordinator.setPrevious(interceptors);
    } else {
        ChannelInterceptor last = interceptors;
        while ( last.getNext() != coordinator ) {
            last = last.getNext();
        }
        last.setNext(interceptor);
        interceptor.setNext(coordinator);
        interceptor.setPrevious(last);
        coordinator.setPrevious(interceptor);
    }
}
 
Example 4
Source File: TcpPingInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if ( thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        thread.setName("TcpPingInterceptor.PingThread-"+cnt.addAndGet(1));
        thread.start();
    }
    
    //acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while ( next != null ) {
        if ( next instanceof TcpFailureDetector ) 
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector)next);
        if ( next instanceof StaticMembershipInterceptor ) 
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor)next);
        next = next.getNext();
    }
    
}
 
Example 5
Source File: GroupChannel.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Adds an interceptor to the stack for message processing<br>
 * Interceptors are ordered in the way they are added.<br>
 * <code>channel.addInterceptor(A);</code><br>
 * <code>channel.addInterceptor(C);</code><br>
 * <code>channel.addInterceptor(B);</code><br>
 * Will result in a interceptor stack like this:<br>
 * <code>A -> C -> B</code><br>
 * The complete stack will look like this:<br>
 * <code>Channel -> A -> C -> B -> ChannelCoordinator</code><br>
 * @param interceptor ChannelInterceptorBase
 */
@Override
public void addInterceptor(ChannelInterceptor interceptor) {
    if ( interceptors == null ) {
        interceptors = interceptor;
        interceptors.setNext(coordinator);
        interceptors.setPrevious(null);
        coordinator.setPrevious(interceptors);
    } else {
        ChannelInterceptor last = interceptors;
        while ( last.getNext() != coordinator ) {
            last = last.getNext();
        }
        last.setNext(interceptor);
        interceptor.setNext(coordinator);
        interceptor.setPrevious(last);
        coordinator.setPrevious(interceptor);
    }
}
 
Example 6
Source File: TcpPingInterceptor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void start(int svc) throws ChannelException {
    super.start(svc);
    running = true;
    if ( thread == null && useThread) {
        thread = new PingThread();
        thread.setDaemon(true);
        String channelName = "";
        if (getChannel() instanceof GroupChannel && ((GroupChannel)getChannel()).getName() != null) {
            channelName = "[" + ((GroupChannel)getChannel()).getName() + "]";
        }
        thread.setName("TcpPingInterceptor.PingThread" + channelName +"-"+cnt.addAndGet(1));
        thread.start();
    }
    
    //acquire the interceptors to invoke on send ping events
    ChannelInterceptor next = getNext();
    while ( next != null ) {
        if ( next instanceof TcpFailureDetector ) 
            failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector)next);
        if ( next instanceof StaticMembershipInterceptor ) 
            staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor)next);
        next = next.getNext();
    }
    
}
 
Example 7
Source File: GroupChannel.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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()));

}
 
Example 8
Source File: GroupChannel.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Validates the option flags that each interceptor is using and reports
 * an error if two interceptor share the same flag.
 * @throws ChannelException
 */
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("Interceptor option flag conflict: "+conflicts.toString());

}
 
Example 9
Source File: GroupChannel.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Validates the option flags that each interceptor is using and reports
 * an error if two interceptor share the same flag.
 * @throws ChannelException
 */
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("Interceptor option flag conflict: "+conflicts.toString());

}