--- /dev/null
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.netconf.impl.mapping;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.channel.ChannelHandlerContext;\r
+import io.netty.handler.codec.MessageToByteEncoder;\r
+\r
+import org.opendaylight.controller.netconf.util.xml.ExiParameters;\r
+import org.opendaylight.controller.netconf.util.xml.ExiUtil;\r
+\r
+public class ExiEncoderHandler extends MessageToByteEncoder<Object> {\r
+\r
+ public static final String HANDLER_NAME;\r
+ static {\r
+ HANDLER_NAME = "exiEncoder";\r
+ }\r
+\r
+ private ExiParameters parameters;\r
+\r
+ public ExiEncoderHandler(ExiParameters parameters) {\r
+ this.parameters = parameters;\r
+ }\r
+\r
+ @Override\r
+ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out)\r
+ throws Exception {\r
+ try {\r
+ ExiUtil.encode(msg, out, this.parameters);\r
+ } catch (Exception e) {\r
+ throw new IllegalStateException("Unable to encode exi message.");\r
+ }\r
+ }\r
+}\r