blob: 9f5ef2e978fd6a432b0a93296d0c0be567f64040 [file] [log] [blame]
karthik1977bc5ea1e2023-01-02 19:25:14 +05301/*
2 * Copyright 2023-present Open Networking Foundation
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.onosproject.netflow.impl;
17
18import org.jboss.netty.channel.ChannelPipeline;
19import org.jboss.netty.channel.ChannelPipelineFactory;
20import org.jboss.netty.channel.Channels;
senthil7f2018e2023-06-21 22:00:44 +053021import org.onosproject.netflow.NetflowController;
karthik1977bc5ea1e2023-01-02 19:25:14 +053022
23/**
24 * Creates a ChannelPipeline for a server-side netflow message channel.
25 */
26public class NetflowPipelineFactory implements ChannelPipelineFactory {
27
senthil7f2018e2023-06-21 22:00:44 +053028 private NetflowController controller;
29
karthik1977bc5ea1e2023-01-02 19:25:14 +053030 /**
31 * Constructor to initialize the values.
senthil7f2018e2023-06-21 22:00:44 +053032 *
33 * @param controller netflow controller.
karthik1977bc5ea1e2023-01-02 19:25:14 +053034 */
senthil7f2018e2023-06-21 22:00:44 +053035 public NetflowPipelineFactory(NetflowController controller) {
karthik1977bc5ea1e2023-01-02 19:25:14 +053036 super();
senthil7f2018e2023-06-21 22:00:44 +053037 this.controller = controller;
karthik1977bc5ea1e2023-01-02 19:25:14 +053038 }
39
40 /**
41 * Get server-side pipe line channel.
42 *
43 * @return ChannelPipeline server-side pipe line channel
44 * @throws Exception on while getting pipe line
45 */
46 @Override
47 public ChannelPipeline getPipeline() throws Exception {
senthil7f2018e2023-06-21 22:00:44 +053048 NeflowChannelHandler handler = new NeflowChannelHandler(controller);
karthik1977bc5ea1e2023-01-02 19:25:14 +053049
50 ChannelPipeline pipeline = Channels.pipeline();
51 pipeline.addLast("netflowmessagedecoder", new NetflowMessageDecoder());
52 pipeline.addLast("ActiveHandler", handler);
53 return pipeline;
54 }
55
56}
57