* Replaced callout-bug with simple co tags

* Stylesheet update
This commit is contained in:
Trustin Lee 2008-09-20 09:11:54 +00:00
parent 0f3edc8cd8
commit ea7c7e769c
3 changed files with 113 additions and 100 deletions

View File

@ -90,10 +90,16 @@ pre a:link * {color:#0066cc !important;}
pre a:visited * {color:#6699cc !important;}
.programlistingco pre {
.programlisting, .programlistingco pre {
line-height: 160%;
}
.programlisting img {
margin: 0;
padding: 0;
vertical-align: middle;
}
span.co {
position: relative;
left: 0;

View File

@ -46,13 +46,6 @@
the received data, and that's all. Let's start straight from the handler
implementation, which handles I/O events generated by Netty.
</para>
<programlistingco>
<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;;
@ -61,15 +54,15 @@ import org.jboss.netty.channel.&ExceptionEvent;;
import org.jboss.netty.channel.&MessageEvent;;
import org.jboss.netty.channel.&SimpleChannelHandler;;
@&ChannelPipelineCoverage;("all")
public class DiscardServerHandler extends &SimpleChannelHandler; {
@&ChannelPipelineCoverage;("all")<co id="example.discard.co1"/>
public class DiscardServerHandler extends &SimpleChannelHandler; {<co id="example.discard.co2"/>
@Override
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; e) {
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; e) {<co id="example.discard.co3"/>
}
@Override
public void exceptionCaught(&ChannelHandlerContext; ctx, &ExceptionEvent; e) {
public void exceptionCaught(&ChannelHandlerContext; ctx, &ExceptionEvent; e) {<co id="example.discard.co4"/>
e.getCause().printStackTrace();
&Channel; ch = e.getChannel();
@ -77,7 +70,7 @@ public class DiscardServerHandler extends &SimpleChannelHandler; {
}
}</programlisting>
<calloutlist>
<callout arearefs="example.discard.c1">
<callout arearefs="example.discard.co1">
<para>
&ChannelPipelineCoverage; annotates a handler type to tell if the
handler instance of the annotated type can be shared by more than
@ -88,7 +81,7 @@ public class DiscardServerHandler extends &SimpleChannelHandler; {
this yet. We will revisit it soon.
</para>
</callout>
<callout arearefs="example.discard.c2">
<callout arearefs="example.discard.co2">
<para>
<classname>DiscardServerHandler</classname> extends
&SimpleChannelHandler;, which is an implementation of
@ -98,7 +91,7 @@ public class DiscardServerHandler extends &SimpleChannelHandler; {
handler interfaces.
</para>
</callout>
<callout arearefs="example.discard.c3">
<callout arearefs="example.discard.co3">
<para>
We override the <methodname>messageReceived</methodname> event
handler method here. This method is called with a &MessageEvent;,
@ -107,7 +100,7 @@ public class DiscardServerHandler extends &SimpleChannelHandler; {
by doing nothing to implement the DISCARD protocol.
</para>
</callout>
<callout arearefs="example.discard.c4">
<callout arearefs="example.discard.co4">
<para>
<methodname>exceptionCaught</methodname> event handler method is
called with an &ExceptionEvent; when an exception was raised by
@ -121,20 +114,11 @@ public class DiscardServerHandler extends &SimpleChannelHandler; {
</para>
</callout>
</calloutlist>
</programlistingco>
<para>
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
which starts the server up with the <classname>DiscardServerHandler</classname>.
</para>
<programlistingco>
<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;
@ -147,46 +131,49 @@ import org.jboss.netty.channel.socket.nio.&NioServerSocketChannelFactory;;
public class DiscardServer {
public static void main(String[] args) throws Exception {
&ChannelFactory; factory =
new &NioServerSocketChannelFactory;(
&ChannelFactory;<co id="example.discard2.co1" /> factory =
new &NioServerSocketChannelFactory;<co id="example.discard2.co2" />(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
&ServerBootstrap; bootstrap = new &ServerBootstrap;(factory);
&ServerBootstrap; bootstrap = new &ServerBootstrap;<co id="example.discard2.co3" />(factory);
DiscardServerHandler handler = new DiscardServerHandler();
&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.bind(new InetSocketAddress(8080));
bootstrap.bind(new InetSocketAddress(8080));<co id="example.discard2.co6" />
}
}</programlisting>
<calloutlist>
<callout arearefs="example.discard2.c1">
<callout arearefs="example.discard2.co1">
<para>
&ChannelFactory; is a factory which creates a &Channel;
</para>
</callout>
<callout arearefs="example.discard2.c2">
<callout arearefs="example.discard2.co2">
<para>
</para>
</callout>
<callout arearefs="example.discard2.c3">
<callout arearefs="example.discard2.co3">
<para>
</para>
</callout>
<callout arearefs="example.discard2.c4">
<callout arearefs="example.discard2.co4">
<para>
</para>
</callout>
<callout arearefs="example.discard2.c5">
<callout arearefs="example.discard2.co5">
<para>
</para>
</callout>
<callout arearefs="example.discard2.co6">
<para>
</para>
</callout>
</calloutlist>
</programlistingco>
</section>
</chapter>

View File

@ -1,8 +1,28 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<?xml version="1.0" encoding="UTF-8"?>
<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: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.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 name="font-style">normal</xsl:attribute>
</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>