tejeshwer degala | 3fe1ed5 | 2016-04-22 17:04:01 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.isis.controller.impl; |
| 17 | |
| 18 | import org.jboss.netty.channel.ChannelPipeline; |
| 19 | import org.jboss.netty.channel.ChannelPipelineFactory; |
| 20 | import org.jboss.netty.channel.Channels; |
| 21 | |
| 22 | /** |
| 23 | * Creates a ChannelPipeline for a client-side ISIS channel. |
| 24 | */ |
| 25 | public class IsisPipelineFactory implements ChannelPipelineFactory { |
| 26 | private IsisChannelHandler isisChannelHandler; |
| 27 | |
| 28 | /** |
| 29 | * Creates an instance of ISIS channel pipeline factory. |
| 30 | * |
| 31 | * @param isisChannelHandler ISIS channel handler instance |
| 32 | */ |
| 33 | public IsisPipelineFactory(IsisChannelHandler isisChannelHandler) { |
| 34 | this.isisChannelHandler = isisChannelHandler; |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public ChannelPipeline getPipeline() throws Exception { |
| 39 | ChannelPipeline pipeline = Channels.pipeline(); |
| 40 | pipeline.addLast("encoder", new IsisMessageDecoder()); |
| 41 | pipeline.addLast("decoder", new IsisMessageEncoder()); |
| 42 | pipeline.addLast("handler", isisChannelHandler); |
| 43 | |
| 44 | return pipeline; |
| 45 | } |
| 46 | } |