Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 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 | package org.onosproject.ospf.controller.impl; |
| 17 | |
| 18 | import org.jboss.netty.channel.ChannelPipeline; |
| 19 | import org.jboss.netty.channel.ChannelPipelineFactory; |
| 20 | import org.jboss.netty.channel.Channels; |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 21 | |
| 22 | /** |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 23 | * Creates a ChannelPipeline for a client-side OSPF channel. |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 24 | */ |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 25 | public class OspfPipelineFactory implements ChannelPipelineFactory { |
| 26 | private OspfInterfaceChannelHandler ospfChannelHandler; |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 27 | |
| 28 | /** |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 29 | * Creates an instance of OSPF channel pipeline factory. |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 30 | * |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 31 | * @param ospfChannelHandler OSPF channel handler instance |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 32 | */ |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 33 | public OspfPipelineFactory(OspfInterfaceChannelHandler ospfChannelHandler) { |
| 34 | this.ospfChannelHandler = ospfChannelHandler; |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public ChannelPipeline getPipeline() throws Exception { |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 39 | ChannelPipeline pipeline = Channels.pipeline(); |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 40 | pipeline.addLast("encoder", new OspfMessageDecoder()); |
| 41 | pipeline.addLast("decoder", new OspfMessageEncoder()); |
| 42 | pipeline.addLast("handler", ospfChannelHandler); |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 43 | |
| 44 | return pipeline; |
| 45 | } |
Dhruv Dhody | 4d8943a | 2016-02-17 16:36:08 +0530 | [diff] [blame] | 46 | } |