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());
}
}
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);
}
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;
}
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()));
}
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);
}
Aggregations