* Replaced callout-bug with simple co tags
* Stylesheet update
This commit is contained in:
parent
0f3edc8cd8
commit
ea7c7e769c
@ -90,10 +90,16 @@ pre a:link * {color:#0066cc !important;}
|
|||||||
|
|
||||||
pre a:visited * {color:#6699cc !important;}
|
pre a:visited * {color:#6699cc !important;}
|
||||||
|
|
||||||
.programlistingco pre {
|
.programlisting, .programlistingco pre {
|
||||||
line-height: 160%;
|
line-height: 160%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.programlisting img {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
span.co {
|
span.co {
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -46,14 +46,7 @@
|
|||||||
the received data, and that's all. Let's start straight from the handler
|
the received data, and that's all. Let's start straight from the handler
|
||||||
implementation, which handles I/O events generated by Netty.
|
implementation, which handles I/O events generated by Netty.
|
||||||
</para>
|
</para>
|
||||||
<programlistingco>
|
<programlisting>package org.jboss.netty.example.discard;
|
||||||
<areaspec>
|
|
||||||
<area id="example.discard.c1" coords="9" />
|
|
||||||
<area id="example.discard.c2" coords="10" />
|
|
||||||
<area id="example.discard.c3" coords="13" />
|
|
||||||
<area id="example.discard.c4" coords="17" />
|
|
||||||
</areaspec>
|
|
||||||
<programlisting>package org.jboss.netty.example.discard;
|
|
||||||
|
|
||||||
import org.jboss.netty.channel.&ChannelHandlerContext;;
|
import org.jboss.netty.channel.&ChannelHandlerContext;;
|
||||||
import org.jboss.netty.channel.&ChannelPipelineCoverage;;
|
import org.jboss.netty.channel.&ChannelPipelineCoverage;;
|
||||||
@ -61,81 +54,72 @@ import org.jboss.netty.channel.&ExceptionEvent;;
|
|||||||
import org.jboss.netty.channel.&MessageEvent;;
|
import org.jboss.netty.channel.&MessageEvent;;
|
||||||
import org.jboss.netty.channel.&SimpleChannelHandler;;
|
import org.jboss.netty.channel.&SimpleChannelHandler;;
|
||||||
|
|
||||||
@&ChannelPipelineCoverage;("all")
|
@&ChannelPipelineCoverage;("all")<co id="example.discard.co1"/>
|
||||||
public class DiscardServerHandler extends &SimpleChannelHandler; {
|
public class DiscardServerHandler extends &SimpleChannelHandler; {<co id="example.discard.co2"/>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; e) {
|
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; e) {<co id="example.discard.co3"/>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(&ChannelHandlerContext; ctx, &ExceptionEvent; e) {
|
public void exceptionCaught(&ChannelHandlerContext; ctx, &ExceptionEvent; e) {<co id="example.discard.co4"/>
|
||||||
e.getCause().printStackTrace();
|
e.getCause().printStackTrace();
|
||||||
|
|
||||||
&Channel; ch = e.getChannel();
|
&Channel; ch = e.getChannel();
|
||||||
ch.close();
|
ch.close();
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
<calloutlist>
|
<calloutlist>
|
||||||
<callout arearefs="example.discard.c1">
|
<callout arearefs="example.discard.co1">
|
||||||
<para>
|
<para>
|
||||||
&ChannelPipelineCoverage; annotates a handler type to tell if the
|
&ChannelPipelineCoverage; annotates a handler type to tell if the
|
||||||
handler instance of the annotated type can be shared by more than
|
handler instance of the annotated type can be shared by more than
|
||||||
one &Channel; (and its associated &ChannelPipeline;).
|
one &Channel; (and its associated &ChannelPipeline;).
|
||||||
<classname>DiscardServerHandler</classname> doesn't manage any
|
<classname>DiscardServerHandler</classname> doesn't manage any
|
||||||
stateful information, and therefore it's annotated with the value
|
stateful information, and therefore it's annotated with the value
|
||||||
<literal>"all"</literal>. It's OK even if you are confused with
|
<literal>"all"</literal>. It's OK even if you are confused with
|
||||||
this yet. We will revisit it soon.
|
this yet. We will revisit it soon.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard.c2">
|
<callout arearefs="example.discard.co2">
|
||||||
<para>
|
<para>
|
||||||
<classname>DiscardServerHandler</classname> extends
|
<classname>DiscardServerHandler</classname> extends
|
||||||
&SimpleChannelHandler;, which is an implementation of
|
&SimpleChannelHandler;, which is an implementation of
|
||||||
&ChannelUpstreamHandler;. &SimpleChannelHandler; provides various
|
&ChannelUpstreamHandler;. &SimpleChannelHandler; provides various
|
||||||
event handler methods that you can override. For now, it's just
|
event handler methods that you can override. For now, it's just
|
||||||
enough to extend &SimpleChannelHandler; rather than to implement
|
enough to extend &SimpleChannelHandler; rather than to implement
|
||||||
handler interfaces.
|
handler interfaces.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard.c3">
|
<callout arearefs="example.discard.co3">
|
||||||
<para>
|
<para>
|
||||||
We override the <methodname>messageReceived</methodname> event
|
We override the <methodname>messageReceived</methodname> event
|
||||||
handler method here. This method is called with a &MessageEvent;,
|
handler method here. This method is called with a &MessageEvent;,
|
||||||
which contains the received data, whenever new data is received
|
which contains the received data, whenever new data is received
|
||||||
from a client. In this example, we just ignore the received data
|
from a client. In this example, we just ignore the received data
|
||||||
by doing nothing to implement the DISCARD protocol.
|
by doing nothing to implement the DISCARD protocol.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard.c4">
|
<callout arearefs="example.discard.co4">
|
||||||
<para>
|
<para>
|
||||||
<methodname>exceptionCaught</methodname> event handler method is
|
<methodname>exceptionCaught</methodname> event handler method is
|
||||||
called with an &ExceptionEvent; when an exception was raised by
|
called with an &ExceptionEvent; when an exception was raised by
|
||||||
Netty due to I/O error or by a handler implementation due to the
|
Netty due to I/O error or by a handler implementation due to the
|
||||||
exception thrown while processing events. In most cases, the
|
exception thrown while processing events. In most cases, the
|
||||||
caught exception should be logged and its associated channel
|
caught exception should be logged and its associated channel
|
||||||
should be closed here, although the implementation of this method
|
should be closed here, although the implementation of this method
|
||||||
can be different depending on what you want to do to deal with an
|
can be different depending on what you want to do to deal with an
|
||||||
exceptional situation. For example, you might want to send a
|
exceptional situation. For example, you might want to send a
|
||||||
response message with an error code before closing the connection.
|
response message with an error code before closing the connection.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
</calloutlist>
|
</calloutlist>
|
||||||
</programlistingco>
|
|
||||||
<para>
|
<para>
|
||||||
So far so good. We have implemented the half of the DISCARD server.
|
So far so good. We have implemented the half of the DISCARD server.
|
||||||
What's left now is to write the <methodname>main</methodname> method
|
What's left now is to write the <methodname>main</methodname> method
|
||||||
which starts the server up with the <classname>DiscardServerHandler</classname>.
|
which starts the server up with the <classname>DiscardServerHandler</classname>.
|
||||||
</para>
|
</para>
|
||||||
<programlistingco>
|
<programlisting>package org.jboss.netty.example.discard;
|
||||||
<areaspec>
|
|
||||||
<area id="example.discard2.c1" coords="13" />
|
|
||||||
<area id="example.discard2.c2" coords="18" />
|
|
||||||
<area id="example.discard2.c3" coords="21" />
|
|
||||||
<area id="example.discard2.c4" coords="23" />
|
|
||||||
<area id="example.discard2.c5" coords="26" />
|
|
||||||
</areaspec>
|
|
||||||
<programlisting>package org.jboss.netty.example.discard;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -147,46 +131,49 @@ import org.jboss.netty.channel.socket.nio.&NioServerSocketChannelFactory;;
|
|||||||
public class DiscardServer {
|
public class DiscardServer {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
&ChannelFactory; factory =
|
&ChannelFactory;<co id="example.discard2.co1" /> factory =
|
||||||
new &NioServerSocketChannelFactory;(
|
new &NioServerSocketChannelFactory;<co id="example.discard2.co2" />(
|
||||||
Executors.newCachedThreadPool(),
|
Executors.newCachedThreadPool(),
|
||||||
Executors.newCachedThreadPool());
|
Executors.newCachedThreadPool());
|
||||||
|
|
||||||
&ServerBootstrap; bootstrap = new &ServerBootstrap;(factory);
|
&ServerBootstrap; bootstrap = new &ServerBootstrap;<co id="example.discard2.co3" />(factory);
|
||||||
|
|
||||||
DiscardServerHandler handler = new DiscardServerHandler();
|
DiscardServerHandler handler = new DiscardServerHandler();
|
||||||
&ChannelPipeline; pipeline = bootstrap.getPipeline();
|
&ChannelPipeline; pipeline = bootstrap.getPipeline();
|
||||||
pipeline.addLast("handler", handler);
|
pipeline.addLast("handler", handler);<co id="example.discard2.co4" />
|
||||||
|
|
||||||
bootstrap.setOption("child.tcpNoDelay", true);
|
bootstrap.setOption("child.tcpNoDelay", true);<co id="example.discard2.co5" />
|
||||||
bootstrap.setOption("child.keepAlive", true);
|
bootstrap.setOption("child.keepAlive", true);
|
||||||
|
|
||||||
bootstrap.bind(new InetSocketAddress(8080));
|
bootstrap.bind(new InetSocketAddress(8080));<co id="example.discard2.co6" />
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
<calloutlist>
|
<calloutlist>
|
||||||
<callout arearefs="example.discard2.c1">
|
<callout arearefs="example.discard2.co1">
|
||||||
<para>
|
<para>
|
||||||
&ChannelFactory; is a factory which creates a &Channel;
|
&ChannelFactory; is a factory which creates a &Channel;
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard2.c2">
|
<callout arearefs="example.discard2.co2">
|
||||||
<para>
|
<para>
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard2.c3">
|
<callout arearefs="example.discard2.co3">
|
||||||
<para>
|
<para>
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard2.c4">
|
<callout arearefs="example.discard2.co4">
|
||||||
<para>
|
<para>
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs="example.discard2.c5">
|
<callout arearefs="example.discard2.co5">
|
||||||
<para>
|
<para>
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
</calloutlist>
|
<callout arearefs="example.discard2.co6">
|
||||||
</programlistingco>
|
<para>
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
</calloutlist>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@ -1,8 +1,28 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
||||||
|
version="1.0">
|
||||||
|
|
||||||
|
<xsl:import href="http://docbook.sourceforge.net/release/xsl/1.72.0/fo/docbook.xsl" />
|
||||||
<xsl:import href="classpath:/xslt/org/jboss/pdf.xsl" />
|
<xsl:import href="classpath:/xslt/org/jboss/pdf.xsl" />
|
||||||
|
|
||||||
|
<xsl:param name="body.font.family" select="'Times New Roman, serif'" />
|
||||||
|
<xsl:param name="monospace.font.family" select="'DejaVu Sans Mono, monospace'" />
|
||||||
|
<xsl:param name="sans.font.family" select="'Arial, sans-serif'" />
|
||||||
|
<xsl:param name="title.font.family" select="$body.font.family" />
|
||||||
<xsl:param name="programlisting.font" select="$monospace.font.family" />
|
<xsl:param name="programlisting.font" select="$monospace.font.family" />
|
||||||
|
<xsl:param name="programlisting.font.size" select="'75%'" />
|
||||||
|
<xsl:param name="callout.graphics" select="1" />
|
||||||
|
<xsl:param name="callout.unicode" select="0" />
|
||||||
|
<xsl:param name="callout.unicode.font" select="'Malgun Gothic, sans-serif'" />
|
||||||
|
|
||||||
|
<xsl:param name="ulink.show" select="0"/>
|
||||||
<xsl:attribute-set name="xref.properties">
|
<xsl:attribute-set name="xref.properties">
|
||||||
<xsl:attribute name="font-style">normal</xsl:attribute>
|
<xsl:attribute name="font-style">normal</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
<xsl:template match="//programlisting/*/text()|//programlisting/*/*/text()">
|
||||||
|
<fo:inline font-size="75%">
|
||||||
|
<xsl:value-of select="." />
|
||||||
|
</fo:inline>
|
||||||
|
</xsl:template>
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
Loading…
Reference in New Issue
Block a user