blob: a0f070926db08d14ae65987d8c12704ceeb9ca03 [file] [log] [blame]
senthil389bca62024-03-22 20:46:30 +05301/*
2 * Copyright 2024-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 */
16
17package org.onosproject.bgpmonitoring.impl;
18
19import org.jboss.netty.channel.ChannelPipeline;
20import org.jboss.netty.channel.ChannelPipelineFactory;
21import org.jboss.netty.channel.Channels;
22import org.jboss.netty.util.ExternalResourceReleasable;
23import org.onosproject.bgpmonitoring.BmpController;
24import org.onosproject.bgpmonitoring.type.BmpMessageDecoder;
25
26/**
27 * Creates a ChannelPipeline for a server-side bmp channel.
28 */
29public class BmpPipelineFactory implements ChannelPipelineFactory, ExternalResourceReleasable {
30
31 private BmpController bmpController;
32
33 /**
34 * Constructor to initialize the values.
35 *
36 * @param bmpController bmp controller
37 */
38 public BmpPipelineFactory(BmpController bmpController) {
39 super();
40 this.bmpController = bmpController;
41 }
42
43 /**
44 * Get server-side pipe line channel.
45 *
46 * @return ChannelPipeline server-side pipe line channel
47 * @throws Exception on while getting pipe line
48 */
49 @Override
50 public ChannelPipeline getPipeline() throws Exception {
51
52 BmpChannelHandler handler = new BmpChannelHandler(bmpController);
53
54 ChannelPipeline pipeline = Channels.pipeline();
55 pipeline.addLast("bmpmessagedecoder", new BmpMessageDecoder());
56 pipeline.addLast("ActiveHandler", handler);
57 return pipeline;
58 }
59
60 @Override
61 public void releaseExternalResources() {
62 throw new UnsupportedOperationException("Not supported yet.");
63 }
64
65}