Java Code Examples for org.apache.mina.core.filterchain.IoFilterChain#contains()
The following examples show how to use
org.apache.mina.core.filterchain.IoFilterChain#contains() .
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: SslFilter.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * Executed just before the filter is added into the chain, we do : * <ul> * <li>check that we don't have a SSL filter already present * <li>we update the next filter * <li>we create the SSL handler helper class * <li>and we store it into the session's Attributes * </ul> */ @Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws SSLException { // Check that we don't have a SSL filter already present in the chain if (parent.contains(SslFilter.class)) { String msg = "Only one SSL filter is permitted in a chain."; LOGGER.error(msg); throw new IllegalStateException(msg); } LOGGER.debug("Adding the SSL Filter {} to the chain", name); IoSession session = parent.getSession(); session.setAttribute(NEXT_FILTER, nextFilter); // Create a SSL handler and start handshake. SslHandler handler = new SslHandler(this, session); handler.init(); session.setAttribute(SSL_HANDLER, handler); }
Example 2
Source File: HackedProtocolCodecFilter.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(this)) { throw new IllegalArgumentException( "You can't add the same filter instance more than once. Create another instance and add it."); } }
Example 3
Source File: CompressionFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(CompressionFilter.class)) { throw new IllegalStateException("Only one " + CompressionFilter.class + " is permitted."); } Zlib deflater = new Zlib(compressionLevel, Zlib.MODE_DEFLATER); Zlib inflater = new Zlib(compressionLevel, Zlib.MODE_INFLATER); IoSession session = parent.getSession(); session.setAttribute(DEFLATER, deflater); session.setAttribute(INFLATER, inflater); }
Example 4
Source File: AbstractStreamWriteFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { Class<? extends IoFilterAdapter> clazz = getClass(); if (parent.contains(clazz)) { throw new IllegalStateException("Only one " + clazz.getName() + " is permitted."); } }
Example 5
Source File: KeepAliveFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(this)) { throw new IllegalArgumentException("You can't add the same filter instance more than once. " + "Create another instance and add it."); } }
Example 6
Source File: RequestResponseFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(this)) { throw new IllegalArgumentException( "You can't add the same filter instance more than once. Create another instance and add it."); } IoSession session = parent.getSession(); session.setAttribute(RESPONSE_INSPECTOR, responseInspectorFactory.getResponseInspector()); session.setAttribute(REQUEST_STORE, createRequestStore(session)); session.setAttribute(UNRESPONDED_REQUEST_STORE, createUnrespondedRequestStore(session)); }
Example 7
Source File: ProtocolCodecFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(this)) { throw new IllegalArgumentException( "You can't add the same filter instance more than once. Create another instance and add it."); } }
Example 8
Source File: ExecutorFilter.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception { if (parent.contains(this)) { throw new IllegalArgumentException( "You can't add the same filter instance more than once. Create another instance and add it."); } }
Example 9
Source File: NIOConnection.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void addCompression() { IoFilterChain chain = ioSession.getFilterChain(); String baseFilter = EXECUTOR_FILTER_NAME; if (chain.contains(TLS_FILTER_NAME)) { baseFilter = TLS_FILTER_NAME; } chain.addAfter(baseFilter, COMPRESSION_FILTER_NAME, new CompressionFilter(true, false, CompressionFilter.COMPRESSION_MAX)); }
Example 10
Source File: ProxyFilter.java From neoscada with Eclipse Public License 1.0 | 3 votes |
/** * Called before the filter is added into the filter chain. * Checks if chain already holds an {@link ProxyFilter} instance. * * @param chain the filter chain * @param name the name assigned to this filter * @param nextFilter the next filter * @throws IllegalStateException if chain already contains an instance of * {@link ProxyFilter} */ @Override public void onPreAdd(final IoFilterChain chain, final String name, final NextFilter nextFilter) { if (chain.contains(ProxyFilter.class)) { throw new IllegalStateException("A filter chain cannot contain more than one ProxyFilter."); } }