root/kraken-filter/src/main/java/org/krakenapps/filter/impl/FilterChainImpl.java @ 302

Revision 302, 1.3 KB (checked in by xeraph, 15 months ago)

added stopFilter().
removed setDatabaseName().
replaced FilterInstanceDescription by ComponentDescription.
added some exception types and refactored.
moved some private classes to private package.
added ScriptUsage annotations to FilterScript.

Line 
1/*
2 * Copyright 2009 NCHOVY
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.krakenapps.filter.impl;
17
18import org.krakenapps.filter.Filter;
19import org.krakenapps.filter.FilterChain;
20import org.krakenapps.filter.Message;
21import org.slf4j.Logger;
22import org.slf4j.LoggerFactory;
23
24public class FilterChainImpl implements FilterChain {
25        final Logger logger = LoggerFactory.getLogger(FilterChainImpl.class.getName());
26        private Filter[] filters;
27
28        public FilterChainImpl(Filter[] filters) {
29                this.filters = filters;
30        }
31
32        @Override
33        public void process(Message message) {
34                for (Filter filter : filters) {
35                        try {
36                                filter.process(message);
37                        } catch (Exception e) {
38                                logger.warn("filter chain error: ", e);
39                        }
40                }
41        }
42}
Note: See TracBrowser for help on using the browser.