Compare commits
162 Commits
Author | SHA1 | Date |
---|---|---|
jbertram | 1808046061 | |
Norman Maurer | a4a3e8c5b6 | |
Norman Maurer | 4ec4abe2e7 | |
Norman Maurer | 8680c01ba4 | |
Norman Maurer | b8de307b0d | |
Norman Maurer | 4a5c21b2e1 | |
Norman Maurer | 3b5550e16b | |
Aaron | 011ef5dae8 | |
Norman Maurer | 974d47f3c4 | |
Norman Maurer | f0044891ee | |
Norman Maurer | cffd158c1a | |
Norman Maurer | c30486d43b | |
Norman Maurer | 82b040bb53 | |
Norman Maurer | 2b88ab01a9 | |
Norman Maurer | b99f442cf1 | |
Trustin Lee | 0b5abecc00 | |
Trustin Lee | 4334161526 | |
Trustin Lee | 4be4e583c7 | |
Trustin Lee | 84fd044eb4 | |
Trustin Lee | 359417358e | |
norman | e6ef89263b | |
norman | 9424c26caf | |
norman | 8d40487ff7 | |
Trustin Lee | dcaf6c8645 | |
Trustin Lee | 249ab1b5b4 | |
Trustin Lee | c3240a1ded | |
Trustin Lee | 2a9c5efe8f | |
Norman Maurer | 82c852fc5e | |
Trustin Lee | 0da39901c8 | |
Trustin Lee | 0d4dfefeb0 | |
norman | 13d0d84852 | |
norman | 852e0a1ed8 | |
norman | 91ea9028f4 | |
norman | 16792a22be | |
norman | 6231030f2b | |
Norman Maurer | db5d74748b | |
Norman Maurer | 582b25eaf5 | |
Jeff Pinner | 5b46cb4cfe | |
Norman Maurer | 9c1950606b | |
Norman Maurer | dd8ec0ea30 | |
Norman Maurer | a555949cb5 | |
Norman Maurer | e4bd678846 | |
Norman Maurer | a91c56c84d | |
Norman Maurer | 24e0b01e8d | |
Trustin Lee | 5860ce337d | |
Trustin Lee | 0f8cecc907 | |
Norman Maurer | d742a11c25 | |
norman | b1c27063a2 | |
norman | 6728766158 | |
Trustin Lee | 322f0ccae4 | |
Trustin Lee | 20df06911e | |
Trustin Lee | e3386736c0 | |
Trustin Lee | a67cdaeb48 | |
Norman Maurer | dbccc9e52b | |
Norman Maurer | 2a4b91b59b | |
Trustin Lee | 4b9b421af2 | |
Trustin Lee | beadadecf7 | |
Norman Maurer | ce1643c187 | |
norman | 48c6793d30 | |
norman | 4be22a42ef | |
norman | 35401caac4 | |
norman | fd1d11ec39 | |
norman | 2d25998eb4 | |
norman | fb408778d1 | |
norman | cb2e047f1d | |
norman | bbdc2032f0 | |
norman | 28120aa778 | |
norman | 203a104889 | |
Trustin Lee | ba72bf7235 | |
Norman Maurer | b89487c445 | |
Evan Meagher | 256621246c | |
Evan Meagher | f0b30aa8e1 | |
Evan Meagher | 95b127748e | |
Evan Meagher | 56d6217b53 | |
Evan Meagher | d1a15c9aff | |
Norman Maurer | ed30037098 | |
Trustin Lee | a78d37460c | |
Trustin Lee | b0d0502413 | |
Trustin Lee | 3effb0d1b0 | |
Trustin Lee | 58cc6aec86 | |
Trustin Lee | 1345a00a1a | |
Trustin Lee | 7eb39aaf93 | |
Trustin Lee | b969706832 | |
Trustin Lee | 5f19f4c0b6 | |
Trustin Lee | 0b36aa6270 | |
Trustin Lee | a96d88c251 | |
Trustin Lee | dc33e99872 | |
Trustin Lee | e0eb72618a | |
Trustin Lee | 654da6d02a | |
Trustin Lee | 8f30a11c67 | |
Trustin Lee | 4321135452 | |
Trustin Lee | 5cdcc67086 | |
Trustin Lee | 99daeebe4a | |
Trustin Lee | 07e9378423 | |
Trustin Lee | caf8b39172 | |
Felix Trepanier | 7e50bd5160 | |
Trustin Lee | 483f093036 | |
Trustin Lee | a804c3495e | |
Trustin Lee | 2d35bf2155 | |
Trustin Lee | fba8c7b7a4 | |
Trustin Lee | bf41f4b099 | |
Trustin Lee | d1b40a3c8b | |
Trustin Lee | 8f659833c6 | |
Trustin Lee | 7338267221 | |
Trustin Lee | b2bf5e60af | |
Trustin Lee | 189567322f | |
nibin | bc8b92e1f7 | |
Trustin Lee | 349b03b467 | |
Trustin Lee | 8f7efa0548 | |
Trustin Lee | 098ca0342c | |
Trustin Lee | 8458c289e2 | |
Trustin Lee | c3d97acd03 | |
Trustin Lee | d7700f25b0 | |
Bruce Mitchener | 2a2e57f618 | |
Will | 1734f5fd01 | |
Daniel Bevenius | 66566a1acd | |
Trustin Lee | 841043006c | |
Trustin Lee | 2351797a43 | |
Trustin Lee | 370160d0a5 | |
Trustin Lee | 77f79c3ea6 | |
Trustin Lee | df656bf139 | |
Trustin Lee | 2d7e9cab6d | |
Trustin Lee | 522bfc4664 | |
Trustin Lee | bf043937af | |
Trustin Lee | 8763c0b858 | |
Trustin Lee | 0859ff782e | |
Trustin Lee | 31b257f6f2 | |
Trustin Lee | 0b47c34036 | |
Trustin Lee | ab2cb4386f | |
Trustin Lee | 4a1c1e97f3 | |
Trustin Lee | 65a445014c | |
Trustin Lee | ad1f698cf1 | |
Trustin Lee | 00e24ce0bb | |
Trustin Lee | 78104cbd28 | |
Trustin Lee | a8f3353d7c | |
Trustin Lee | 5276a92e71 | |
Trustin Lee | ae6a5ca82d | |
Trustin Lee | 5c75915f4c | |
Trustin Lee | be6cdb4a11 | |
Trustin Lee | 339c2a6641 | |
Trustin Lee | 31df7fa9b1 | |
Trustin Lee | d1f05ea4e7 | |
Trustin Lee | 5af93c2753 | |
Trustin Lee | 55f9597c0f | |
Trustin Lee | b4fe592a53 | |
Trustin Lee | 5a3f8aeb82 | |
Trustin Lee | ed23803a87 | |
Trustin Lee | 4861e39a74 | |
Trustin Lee | 966b894aa3 | |
Trustin Lee | 3bb28f13e5 | |
Trustin Lee | 00056f585f | |
Trustin Lee | 95ac54ea90 | |
Trustin Lee | 1481cee81a | |
iainmcgin | fa28d2824f | |
Bruce Mitchener | 2d00f07d6c | |
Trustin Lee | 122db6fd21 | |
Trustin Lee | 276626221d | |
Trustin Lee | 957793304b | |
Trustin Lee | 914c9da8cc | |
Trustin Lee | e102647d65 | |
Trustin Lee | 91d0ce74bb | |
Trustin Lee | e395aacbd4 |
|
@ -1,7 +1,10 @@
|
|||
|
||||
# /
|
||||
/.project
|
||||
/.classpath
|
||||
/.settings
|
||||
/.idea
|
||||
/target
|
||||
/reports
|
||||
/src/main/java/org/jboss/netty/util/Version.java
|
||||
/*.iml
|
||||
/*.ipr
|
||||
/*.iws
|
||||
|
|
148
pom.xml
148
pom.xml
|
@ -20,13 +20,13 @@
|
|||
<parent>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jboss-parent</artifactId>
|
||||
<version>5</version>
|
||||
<version>9</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
<version>3.2.11.Final-SNAPSHOT</version>
|
||||
|
||||
<name>The Netty Project</name>
|
||||
<url>http://www.jboss.org/netty/</url>
|
||||
|
@ -49,9 +49,9 @@
|
|||
<inceptionYear>2008</inceptionYear>
|
||||
|
||||
<scm>
|
||||
<url>http://fisheye.jboss.org/browse/Netty</url>
|
||||
<connection>scm:svn:http://anonsvn.jboss.org/repos/netty/trunk</connection>
|
||||
<developerConnection>scm:svn:https://svn.jboss.org/repos/netty/trunk</developerConnection>
|
||||
<url>https://github.com/netty/netty</url>
|
||||
<connection>scm:git:git://github.com/netty/netty.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/netty/netty.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
@ -59,7 +59,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>2.4.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
@ -104,7 +104,7 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.5.11</version>
|
||||
<version>1.6.4</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
@ -118,7 +118,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging-spi</artifactId>
|
||||
<version>2.1.1.GA</version>
|
||||
<version>2.1.2.GA</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
@ -152,30 +152,32 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymockclassextension</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.5.11</version>
|
||||
<version>1.6.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<jdk.min.version>1.5</jdk.min.version>
|
||||
<maven.min.version>2.2.1</maven.min.version>
|
||||
<attach-distribution>false</attach-distribution>
|
||||
</properties>
|
||||
|
||||
|
@ -190,9 +192,14 @@
|
|||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<!-- See org.jboss:jboss-parent -->
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>1.5</source>
|
||||
|
@ -202,27 +209,9 @@
|
|||
<showDeprecations>true</showDeprecations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<version>1.0-beta-4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>create</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<doCheck>false</doCheck>
|
||||
<doUpdate>true</doUpdate>
|
||||
<revisionOnScmFailure>-1</revisionOnScmFailure>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
|
@ -253,7 +242,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.10</version>
|
||||
<configuration>
|
||||
<forkMode>never</forkMode>
|
||||
<excludes>
|
||||
|
@ -265,11 +254,10 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.3.4</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<SCM-Revision>${buildNumber}</SCM-Revision>
|
||||
<Bundle-SymbolicName>${project.groupId}</Bundle-SymbolicName>
|
||||
<Bundle-DocURL>${project.url}</Bundle-DocURL>
|
||||
<Bundle-Activator>
|
||||
|
@ -287,12 +275,15 @@
|
|||
<Import-Package>
|
||||
*;resolution:=optional
|
||||
</Import-Package>
|
||||
<Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
|
||||
<Bundle-BuddyPolicy>registered</Bundle-BuddyPolicy>
|
||||
<Main-Class>${project.groupId}.util.Version</Main-Class>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-source</id>
|
||||
|
@ -308,7 +299,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>write-version</id>
|
||||
|
@ -318,9 +309,25 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml" />
|
||||
<exec executable="git" outputproperty="gitOutput" resultproperty="gitExitCode" failonerror="false" failifexecutionfails="false">
|
||||
<arg value="log" />
|
||||
<arg value="-1" />
|
||||
<arg value="--format=format:%h" />
|
||||
</exec>
|
||||
<if>
|
||||
<equals arg2="0" arg1="${gitExitCode}" />
|
||||
<then>
|
||||
<property name="buildNumber" value="${gitOutput}" />
|
||||
</then>
|
||||
<else>
|
||||
<property name="buildNumber" value="unknown" />
|
||||
</else>
|
||||
</if>
|
||||
<echo>Build number: ${buildNumber}</echo>
|
||||
<mkdir dir="${project.build.directory}" />
|
||||
<echo message="${project.version}, r${buildNumber}" file="${project.build.directory}/version.txt" />
|
||||
<echo message="// DO NOT MODIFY - WILL BE OVERWRITTEN DURING THE BUILD PROCESS${line.separator}package org.jboss.netty.util;${line.separator}/**${line.separator} * Provides the version information of Netty.${line.separator} * @apiviz.landmark${line.separator} */${line.separator}public final class Version {${line.separator} /** The version identifier. */${line.separator} public static final String ID = "${project.version}-r${buildNumber}";${line.separator} /** Prints out the version identifier to stdout. */${line.separator} public static void main(String[] args) { System.out.println(ID); }${line.separator} private Version() { super(); }${line.separator}}${line.separator}" file="${basedir}/src/main/java/org/jboss/netty/util/Version.java" />
|
||||
<echo message="${project.version}" file="${project.build.directory}/version.txt" />
|
||||
<echo message="// DO NOT MODIFY - WILL BE OVERWRITTEN DURING THE BUILD PROCESS${line.separator}package org.jboss.netty.util;${line.separator}/**${line.separator} * Provides the version information of Netty.${line.separator} * @apiviz.landmark${line.separator} */${line.separator}public final class Version {${line.separator} /** The version identifier. */${line.separator} public static final String ID = "${project.version}-${buildNumber}";${line.separator} /** Prints out the version identifier to stdout. */${line.separator} public static void main(String[] args) { System.out.println(ID); }${line.separator} private Version() { super(); }${line.separator}}${line.separator}" file="${basedir}/src/main/java/org/jboss/netty/util/Version.java" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -342,6 +349,10 @@
|
|||
<move file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/${project.build.finalName}.orig.jar" />
|
||||
<zip destfile="${project.build.directory}/${project.build.finalName}.jar">
|
||||
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
|
||||
<include name="META-INF/MANIFEST.MF" />
|
||||
</zipfileset>
|
||||
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
|
||||
<exclude name="META-INF/MANIFEST.MF" />
|
||||
<exclude name="*/*/*/example/**" />
|
||||
</zipfileset>
|
||||
</zip>
|
||||
|
@ -351,6 +362,10 @@
|
|||
<move file="${project.build.directory}/${project.build.finalName}-sources.jar" tofile="${project.build.directory}/${project.build.finalName}-sources.orig.jar" />
|
||||
<zip destfile="${project.build.directory}/${project.build.finalName}-sources.jar">
|
||||
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
|
||||
<include name="META-INF/MANIFEST.MF" />
|
||||
</zipfileset>
|
||||
<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
|
||||
<exclude name="META-INF/MANIFEST.MF" />
|
||||
<exclude name="*/*/*/example/**" />
|
||||
</zipfileset>
|
||||
</zip>
|
||||
|
@ -367,12 +382,12 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant-launcher</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ant-contrib</groupId>
|
||||
|
@ -389,7 +404,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<version>2.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-javadoc</id>
|
||||
|
@ -404,7 +419,7 @@
|
|||
<docletArtifact>
|
||||
<groupId>org.jboss.apiviz</groupId>
|
||||
<artifactId>apiviz</artifactId>
|
||||
<version>1.3.1.GA</version>
|
||||
<version>1.3.2.GA</version>
|
||||
</docletArtifact>
|
||||
<attach>false</attach>
|
||||
<stylesheetfile>${basedir}/src/javadoc/stylesheet.css</stylesheetfile>
|
||||
|
@ -421,8 +436,8 @@
|
|||
<author>true</author>
|
||||
<keywords>true</keywords>
|
||||
<overview>${basedir}/src/javadoc/overview.html</overview>
|
||||
<doctitle>${project.name} API Reference (${project.version}, r${buildNumber})</doctitle>
|
||||
<windowtitle>${project.name} API Reference (${project.version}, r${buildNumber})</windowtitle>
|
||||
<doctitle>${project.name} API Reference (${project.version})</doctitle>
|
||||
<windowtitle>${project.name} API Reference (${project.version})</windowtitle>
|
||||
<additionalparam>
|
||||
-link http://java.sun.com/javase/6/docs/api/
|
||||
-link http://code.google.com/apis/protocolbuffers/docs/reference/java/
|
||||
|
@ -448,7 +463,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-xref</id>
|
||||
|
@ -465,10 +480,11 @@
|
|||
<destDir>${project.build.directory}/xref</destDir>
|
||||
<javadocDir>${project.build.directory}/api</javadocDir>
|
||||
<stylesheet>${basedir}/src/xref/stylesheet.css</stylesheet>
|
||||
<docTitle>${project.name} Source Xref (${project.version}, r${buildNumber})</docTitle>
|
||||
<windowTitle>${project.name} Source Xref (${project.version}, r${buildNumber})</windowTitle>
|
||||
<docTitle>${project.name} Source Xref (${project.version})</docTitle>
|
||||
<windowTitle>${project.name} Source Xref (${project.version})</windowTitle>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.jboss.maven.plugins</groupId>
|
||||
<artifactId>maven-jdocbook-plugin</artifactId>
|
||||
|
@ -484,6 +500,36 @@
|
|||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.wst.css</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.1.101-v200705302225</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.ibm</groupId>
|
||||
<artifactId>icu</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.wst.sse</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.1.202-v200709061102</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.ibm</groupId>
|
||||
<artifactId>icu</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jbossorg-docbook-xslt</artifactId>
|
||||
|
@ -568,9 +614,10 @@
|
|||
</options>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-5</version>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-distribution</id>
|
||||
|
@ -591,9 +638,8 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.2.1</version>
|
||||
<configuration>
|
||||
<tagBase>https://svn.jboss.org/repos/netty/tags</tagBase>
|
||||
<!-- We don't want to use the default release profile because it
|
||||
causes the JavaDoc and source jars to be deployed twice. -->
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
|
|
|
@ -41,20 +41,20 @@
|
|||
<title>Rich Buffer Data Structure</title>
|
||||
<para>
|
||||
Netty uses its own buffer API instead of NIO <classname>ByteBuffer</classname>
|
||||
to represent a sequence of bytes. This approach has significant advantage
|
||||
to represent a sequence of bytes. This approach has significant advantages
|
||||
over using <classname>ByteBuffer</classname>. Netty's new buffer type,
|
||||
&ChannelBuffer; has been designed from ground up to address the problems
|
||||
&ChannelBuffer; has been designed from the ground up to address the problems
|
||||
of <classname>ByteBuffer</classname> and to meet the daily needs of
|
||||
network application developers. To list a few cool features:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
You can define your buffer type if necessary.
|
||||
You can define your own buffer type if necessary.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Transparent zero copy is achieved by built-in composite buffer type.
|
||||
Transparent zero copy is achieved by a built-in composite buffer type.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<section>
|
||||
<title>Universal Asynchronous I/O API</title>
|
||||
<para>
|
||||
Traditional I/O APIs in Java provided different types and methods for
|
||||
Traditional I/O APIs in Java provide different types and methods for
|
||||
different transport types. For example,
|
||||
<classname>java.net.Socket</classname> and
|
||||
<classname>java.net.DatagramSocket</classname> do not have any common
|
||||
|
@ -93,32 +93,33 @@
|
|||
</para>
|
||||
<para>
|
||||
This mismatch makes porting a network application from one transport to
|
||||
the other tedious and difficult. The lack of portability between
|
||||
transports becomes a problem when you need to support more transports not
|
||||
rewriting the network layer of the application. Logically, many protocols
|
||||
can run on more than one transport such as TCP/IP, UDP/IP, SCTP, and
|
||||
serial port communication.
|
||||
another tedious and difficult. The lack of portability between
|
||||
transports becomes a problem when you need to support additional
|
||||
transports, as this often entails rewriting the network layer of the
|
||||
application. Logically, many protocols can run on more than one
|
||||
transport such as TCP/IP, UDP/IP, SCTP, and serial port communication.
|
||||
</para>
|
||||
<para>
|
||||
To make the matter worse, Java New I/O (NIO) API introduced the
|
||||
incompatibility with the old blocking I/O (OIO) API, and so will NIO.2
|
||||
(AIO). Because all these APIs are different from each other in design
|
||||
and performance characteristics, you are often forced to determine which
|
||||
API your application will depend on before you even begin the
|
||||
implementation phase.
|
||||
To make matters worse, Java's New I/O (NIO) API introduced
|
||||
incompatibilities with the old blocking I/O (OIO) API and will continue
|
||||
to do so in the next release, NIO.2 (AIO). Because all these APIs are
|
||||
different from each other in design and performance characteristics, you
|
||||
are often forced to determine which API your application will depend on
|
||||
before you even begin the implementation phase.
|
||||
</para>
|
||||
<para>
|
||||
For instance, you might want to start with OIO because the number of
|
||||
clients you are going to serve will be very small and writing a socket
|
||||
server using OIO is much easier than using NIO. However, you are going
|
||||
to be in trouble when your business grows up exponentially and your server
|
||||
starts to serve tens of thousand clients simultaneously. You could
|
||||
start with NIO, but it might take much longer time to implement due to
|
||||
the complexity of the NIO Selector API, hindering rapid development.
|
||||
to be in trouble when your business grows exponentially and your server
|
||||
needs to serve tens of thousands of clients simultaneously. You could
|
||||
start with NIO, but doing so may hinder rapid development by greatly
|
||||
increasing development time due to the complexity of the NIO Selector
|
||||
API.
|
||||
</para>
|
||||
<para>
|
||||
Netty has a universal asynchronous I/O interface called &Channel;, which
|
||||
abstracts away all operations required to point-to-point communication.
|
||||
Netty has a universal asynchronous I/O interface called a &Channel;, which
|
||||
abstracts away all operations required for point-to-point communication.
|
||||
That is, once you wrote your application on one Netty transport, your
|
||||
application can run on other Netty transports. Netty provides a number
|
||||
of essential transports via one universal API:
|
||||
|
@ -144,30 +145,29 @@
|
|||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
Switching from one transport to the other usually takes just a couple
|
||||
Switching from one transport to another usually takes just a couple
|
||||
lines of changes such as choosing a different &ChannelFactory;
|
||||
implementation.
|
||||
</para>
|
||||
<para>
|
||||
Also, you are even able to take advantage of a new transport which is
|
||||
not written yet, serial port communication transport for instance, again
|
||||
Also, you are even able to take advantage of new transports which aren't
|
||||
yet written (such as serial port communication transport), again
|
||||
by replacing just a couple lines of constructor calls. Moreover, you can
|
||||
write your own transport by extending the core API because it is highly
|
||||
extensible.
|
||||
write your own transport by extending the core API.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Event Model based on the Interceptor Chain Pattern</title>
|
||||
<para>
|
||||
Well-defined and extensible event model is a must for an event-driven
|
||||
application. Netty does have a well-defined event model focused on I/O.
|
||||
It also allows you to implement your own event type without breaking the
|
||||
existing code at all because each event type is distinguished from
|
||||
each other by strict type hierarchy. This is another differentiator
|
||||
against other frameworks. Many NIO frameworks have no or very limited
|
||||
notion of event model; they often break the existing code when you try
|
||||
to add a new custom event type, or just do not allow extension.
|
||||
A well-defined and extensible event model is a must for an event-driven
|
||||
application. Netty has a well-defined event model focused on I/O. It
|
||||
also allows you to implement your own event type without breaking the
|
||||
existing code because each event type is distinguished from another by
|
||||
a strict type hierarchy. This is another differentiator against other
|
||||
frameworks. Many NIO frameworks have no or a very limited notion of an
|
||||
event model. If they offer extension at all, they often break the
|
||||
existing code when you try to add custom event types
|
||||
</para>
|
||||
<para>
|
||||
A &ChannelEvent; is handled by a list of &ChannelHandler;s in a
|
||||
|
@ -175,7 +175,7 @@
|
|||
<ulink url="http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html">Intercepting Filter</ulink>
|
||||
pattern to give a user full control over how an event is handled and how
|
||||
the handlers in the pipeline interact with each other. For example,
|
||||
you can define what to do when a data is read from a socket:
|
||||
you can define what to do when data is read from a socket:
|
||||
</para>
|
||||
<programlisting>public class MyReadHandler implements &SimpleChannelHandler; {
|
||||
public void messageReceived(&ChannelHandlerContext; ctx, &MessageEvent; evt) {
|
||||
|
@ -188,8 +188,7 @@
|
|||
}
|
||||
}</programlisting>
|
||||
<para>
|
||||
You can also define what to do when other handler requested a write
|
||||
operation:
|
||||
You can also define what to do when a handler receives a write request:
|
||||
</para>
|
||||
<programlisting>public class MyWriteHandler implements &SimpleChannelHandler; {
|
||||
public void writeRequested(&ChannelHandlerContext; ctx, &MessageEvent; evt) {
|
||||
|
@ -202,7 +201,7 @@
|
|||
}
|
||||
}</programlisting>
|
||||
<para>
|
||||
For more information about the event model, please refer to the
|
||||
For more information on the event model, please refer to the
|
||||
API documentation of &ChannelEvent; and &ChannelPipeline;.
|
||||
</para>
|
||||
</section>
|
||||
|
@ -212,29 +211,28 @@
|
|||
<para>
|
||||
On top of the core components mentioned above, that already enable the
|
||||
implementation of all types of network applications, Netty provides a set
|
||||
of advanced features to accelerate the development pace even more.
|
||||
of advanced features to accelerate the page of development even more.
|
||||
</para>
|
||||
|
||||
<section>
|
||||
<title>Codec framework</title>
|
||||
<para>
|
||||
As demonstrated in <xref linkend="start.pojo"/>, it is always a good
|
||||
idea to separate a protocol codec from a business logic. However, there
|
||||
idea to separate a protocol codec from business logic. However, there
|
||||
are some complications when implementing this idea from scratch. You
|
||||
have to deal with the fragmentation of messages. Some protocols are
|
||||
multi-layered (i.e. built on top of other lower level protocol). Some
|
||||
multi-layered (i.e. built on top of other lower level protocols). Some
|
||||
are too complicated to be implemented in a single state machine.
|
||||
</para>
|
||||
<para>
|
||||
Consequently, a good network application framework should provide an
|
||||
extensible, reusable, unit-testable, and multi-layered codec framework
|
||||
that generates maintainable user codec.
|
||||
that generates maintainable user codecs.
|
||||
</para>
|
||||
<para>
|
||||
Netty provides a number of basic and advanced codecs built on top of
|
||||
its core to address most issues you will encounter when you write a
|
||||
protocol codec regardless if it is simple or not, binary or text -
|
||||
simply whatever.
|
||||
Netty provides a number of basic and advanced codecs to address most
|
||||
issues you will encounter when you write a protocol codec regardless
|
||||
if it is simple or not, binary or text - simply whatever.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
@ -245,16 +243,16 @@
|
|||
You can't simply wrap a stream to encrypt or decrypt data but you have
|
||||
to use <classname>javax.net.ssl.SSLEngine</classname>.
|
||||
<classname>SSLEngine</classname> is a state machine which is as complex
|
||||
as SSL is. You have to manage all possible states such as cipher suite
|
||||
and encryption key negotiation (or re-negotiation), certificate
|
||||
exchange and validation. Moreover, <classname>SSLEngine</classname> is
|
||||
not even completely thread-safe unlike usual expectation.
|
||||
as SSL itself. You have to manage all possible states such as cipher
|
||||
suite and encryption key negotiation (or re-negotiation), certificate
|
||||
exchange, and validation. Moreover, <classname>SSLEngine</classname> is
|
||||
not even completely thread-safe, as one would expect.
|
||||
</para>
|
||||
<para>
|
||||
In Netty, &SslHandler; takes care of all the gory details and pitfalls
|
||||
of <classname>SSLEngine</classname>. All you need to do is to configure
|
||||
and insert the &SslHandler; to your &ChannelPipeline;. It also allows
|
||||
you to implement advanced features like
|
||||
the &SslHandler; and insert it into your &ChannelPipeline;. It also
|
||||
allows you to implement advanced features like
|
||||
<ulink url="http://en.wikipedia.org/wiki/Starttls">StartTLS</ulink>
|
||||
very easily.
|
||||
</para>
|
||||
|
@ -269,13 +267,13 @@
|
|||
</para>
|
||||
<para>
|
||||
Netty's HTTP support is very different from the existing HTTP libraries.
|
||||
It gives you complete control over how HTTP messages are exchanged in a
|
||||
low level. Because it is basically the combination of HTTP codec and
|
||||
HTTP message classes, there is no restriction such as enforced thread
|
||||
It gives you complete control over how HTTP messages are exchanged at a
|
||||
low level. Because it is basically the combination of an HTTP codec and
|
||||
HTTP message classes, there is no restriction such as an enforced thread
|
||||
model. That is, you can write your own HTTP client or server that works
|
||||
exactly the way you want. You have full control over thread model,
|
||||
connection life cycle, chunked encoding, and as much as what HTTP
|
||||
specification allows you to do.
|
||||
exactly the way you want. You have full control over everything that's
|
||||
in the HTTP specification, including the thread model, connection life
|
||||
cycle, and chunked encoding.
|
||||
</para>
|
||||
<para>
|
||||
Thanks to its highly customizable nature, you can write a very efficient
|
||||
|
@ -291,18 +289,18 @@
|
|||
<listitem>
|
||||
<para>
|
||||
Media streaming server that needs to keep the connection open
|
||||
until the whole media is streamed (e.g. 2 hours of movie)
|
||||
until the whole media is streamed (e.g. 2 hours of video)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
File server that allows the upload of large files without memory
|
||||
pressure (e.g. uploading 1GB per request)
|
||||
File server that allows the uploading of large files without
|
||||
memory pressure (e.g. uploading 1GB per request)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Scalable mash-up client that connects to tens of thousand 3rd
|
||||
Scalable mash-up client that connects to tens of thousands of 3rd
|
||||
party web services asynchronously
|
||||
</para>
|
||||
</listitem>
|
||||
|
@ -315,10 +313,11 @@
|
|||
<para>
|
||||
<ulink url="http://code.google.com/apis/protocolbuffers/docs/overview.html">Google Protocol Buffers</ulink>
|
||||
are an ideal solution for the rapid implementation of a highly efficient
|
||||
binary protocol that evolves over time. With &ProtobufEncoder; and
|
||||
&ProtobufDecoder;, you can turn the message classes generated by Google
|
||||
Protocol Buffers Compiler (protoc) into Netty codec. Please take a look
|
||||
into the <ulink url="&XRef;example/localtime/package-summary.html">'LocalTime' example</ulink>
|
||||
binary protocols that evolve over time. With &ProtobufEncoder; and
|
||||
&ProtobufDecoder;, you can turn the message classes generated by the
|
||||
Google Protocol Buffers Compiler (protoc) into Netty codec. Please take
|
||||
a look into the
|
||||
<ulink url="&XRef;example/localtime/package-summary.html">'LocalTime' example</ulink>
|
||||
that shows how easily you can create a high-performing binary protocol
|
||||
client and server from the
|
||||
<ulink url="http://anonsvn.jboss.org/repos/netty/trunk/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.proto">sample protocol definition</ulink>.
|
||||
|
@ -330,18 +329,18 @@
|
|||
<title>Summary</title>
|
||||
<para>
|
||||
In this chapter, we reviewed the overall architecture of Netty from the
|
||||
feature-wise standpoint. Netty has simple yet powerful architecture.
|
||||
feature standpoint. Netty has a simple, yet powerful architecture.
|
||||
It is composed of three components - buffer, channel, and event model -
|
||||
and all advanced features are built on top of the three core components.
|
||||
Once you understood how these three work together, it should not be
|
||||
difficult to understand more advanced features which were covered briefly
|
||||
in this chapter.
|
||||
difficult to understand the more advanced features which were covered
|
||||
briefly in this chapter.
|
||||
</para>
|
||||
<para>
|
||||
You might still have an unanswered question about what the overall
|
||||
architecture looks exactly like and how each feature work together.
|
||||
If so, it is a good idea to <ulink url="&Community;">talk to us</ulink>
|
||||
to improve this guide.
|
||||
You might still have unanswered questions about what the overall
|
||||
architecture looks like exactly and how each of the features work
|
||||
together. If so, it is a good idea to
|
||||
<ulink url="&Community;">talk to us</ulink> to improve this guide.
|
||||
</para>
|
||||
</section>
|
||||
</chapter>
|
||||
|
|
|
@ -337,7 +337,7 @@ public class TimeServerHandler extends &SimpleChannelHandler; {
|
|||
&Channel; ch = e.getChannel();
|
||||
|
||||
&ChannelBuffer; time = &ChannelBuffers;.buffer(4);<co id="example.time.co2"/>
|
||||
time.writeInt(System.currentTimeMillis() / 1000);
|
||||
time.writeInt((int) (System.currentTimeMillis() / 1000));
|
||||
|
||||
&ChannelFuture; f = ch.write(time);<co id="example.time.co3"/>
|
||||
|
||||
|
@ -692,35 +692,41 @@ public class TimeClientHandler extends &SimpleChannelHandler; {
|
|||
</para>
|
||||
<programlisting>package org.jboss.netty.example.time;
|
||||
|
||||
public class TimeDecoder extends &FrameDecoder; {
|
||||
public class TimeDecoder extends &FrameDecoder;<co id="example.time4.co1"/> {
|
||||
|
||||
@Override
|
||||
protected Object decode(
|
||||
&ChannelHandlerContext; ctx, &Channel; channel, &ChannelBuffer; buffer)<co id="example.time4.co1"/> {
|
||||
&ChannelHandlerContext; ctx, &Channel; channel, &ChannelBuffer; buffer)<co id="example.time4.co2"/> {
|
||||
|
||||
if (buffer.readableBytes() < 4) {
|
||||
return null; <co id="example.time4.co2"/>
|
||||
return null; <co id="example.time4.co3"/>
|
||||
}
|
||||
|
||||
return buffer.readBytes(4);<co id="example.time4.co3"/>
|
||||
return buffer.readBytes(4);<co id="example.time4.co4"/>
|
||||
}
|
||||
}</programlisting>
|
||||
<calloutlist>
|
||||
<callout arearefs="example.time4.co1">
|
||||
<para>
|
||||
&FrameDecoder; is an implementation of &ChannelHandler; which
|
||||
makes it easy to which deals with the fragmentation issue.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="example.time4.co2">
|
||||
<para>
|
||||
&FrameDecoder; calls <methodname>decode</methodname> method with
|
||||
an internally maintained cumulative buffer whenever new data is
|
||||
received.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="example.time4.co2">
|
||||
<callout arearefs="example.time4.co3">
|
||||
<para>
|
||||
If <literal>null</literal> is returned, it means there's not
|
||||
enough data yet. &FrameDecoder; will call again when there is a
|
||||
sufficient amount of data.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="example.time4.co3">
|
||||
<callout arearefs="example.time4.co4">
|
||||
<para>
|
||||
If non-<literal>null</literal> is returned, it means the
|
||||
<methodname>decode</methodname> method has decoded a message
|
||||
|
@ -873,10 +879,11 @@ public void channelConnected(&ChannelHandlerContext; ctx, &ChannelStateEvent; e)
|
|||
f.addListener(&ChannelFutureListener;.CLOSE);
|
||||
}</programlisting>
|
||||
<para>
|
||||
Now, the only missing piece is the &ChannelHandler; which translates a
|
||||
<classname>UnixTime</classname> back into a &ChannelBuffer;. It's much
|
||||
simpler than writing a decoder because there's no need to deal with
|
||||
packet fragmentation and assembly when encoding a message.
|
||||
Now, the only missing piece is an encoder, which is an implementation of
|
||||
&ChannelHandler; that translates a <classname>UnixTime</classname> back
|
||||
into a &ChannelBuffer;. It's much simpler than writing a decoder because
|
||||
there's no need to deal with packet fragmentation and assembly when
|
||||
encoding a message.
|
||||
</para>
|
||||
<programlisting>package org.jboss.netty.example.time;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.jboss.netty.util.ExternalResourceReleasable;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2371 $, $Date: 2010-10-19 15:00:42 +0900 (Tue, 19 Oct 2010) $
|
||||
*
|
||||
* @apiviz.uses org.jboss.netty.channel.ChannelFactory
|
||||
*/
|
||||
|
|
|
@ -106,7 +106,7 @@ import org.jboss.netty.channel.Channels;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2337 $, $Date: 2010-07-07 13:32:10 +0900 (Wed, 07 Jul 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
@ -182,7 +182,7 @@ public class ClientBootstrap extends Bootstrap {
|
|||
*/
|
||||
public ChannelFuture connect(SocketAddress remoteAddress) {
|
||||
if (remoteAddress == null) {
|
||||
throw new NullPointerException("remotedAddress");
|
||||
throw new NullPointerException("remoteAddress");
|
||||
}
|
||||
SocketAddress localAddress = (SocketAddress) getOption("localAddress");
|
||||
return connect(remoteAddress, localAddress);
|
||||
|
|
|
@ -115,7 +115,7 @@ import org.jboss.netty.channel.Channels;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2338 $, $Date: 2010-07-07 13:33:47 +0900 (Wed, 07 Jul 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
|
|
@ -156,7 +156,7 @@ import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2344 $, $Date: 2010-07-07 16:55:37 +0900 (Wed, 07 Jul 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.ScatteringByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -30,7 +31,7 @@ import java.nio.charset.Charset;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2211 $, $Date: 2010-03-04 15:34:00 +0900 (Thu, 04 Mar 2010) $
|
||||
*/
|
||||
public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
|
||||
|
@ -308,12 +309,30 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
return buf;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readBytes(ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readBytes(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
ChannelBuffer slice = slice(readerIndex, length);
|
||||
readerIndex += length;
|
||||
return slice;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readSlice(ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readSlice(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public void readBytes(byte[] dst, int dstIndex, int length) {
|
||||
checkReadableBytes(length);
|
||||
getBytes(readerIndex, dst, dstIndex, length);
|
||||
|
@ -371,6 +390,17 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
readerIndex = newReaderIndex;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int skipBytes(ChannelBufferIndexFinder firstIndexFinder) {
|
||||
int oldReaderIndex = readerIndex;
|
||||
int newReaderIndex = indexOf(oldReaderIndex, writerIndex, firstIndexFinder);
|
||||
if (newReaderIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
readerIndex(newReaderIndex);
|
||||
return newReaderIndex - oldReaderIndex;
|
||||
}
|
||||
|
||||
public void writeByte(int value) {
|
||||
setByte(writerIndex ++, value);
|
||||
}
|
||||
|
@ -517,6 +547,37 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
toByteBuffer(index, length), charset);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(int index, int length, String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder) {
|
||||
if (terminatorFinder == null) {
|
||||
return toString(index, length, charsetName);
|
||||
}
|
||||
|
||||
int terminatorIndex = indexOf(index, index + length, terminatorFinder);
|
||||
if (terminatorIndex < 0) {
|
||||
return toString(index, length, charsetName);
|
||||
}
|
||||
|
||||
return toString(index, terminatorIndex - index, charsetName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(int index, int length, String charsetName) {
|
||||
return toString(index, length, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder) {
|
||||
return toString(readerIndex, readableBytes(), charsetName, terminatorFinder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(String charsetName) {
|
||||
return toString(Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
public int indexOf(int fromIndex, int toIndex, byte value) {
|
||||
return ChannelBuffers.indexOf(this, fromIndex, toIndex, value);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.ByteOrder;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public abstract class AbstractChannelBufferFactory implements ChannelBufferFactory {
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.nio.ByteOrder;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*/
|
||||
public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2309 $, $Date: 2010-06-21 16:00:03 +0900 (Mon, 21 Jun 2010) $
|
||||
*
|
||||
*/
|
||||
public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
|||
* <pre>
|
||||
* {@link ChannelBuffer} buffer = ...;
|
||||
* for (int i = 0; i < buffer.capacity(); i ++</strong>) {
|
||||
* byte b = array.getByte(i);
|
||||
* byte b = buffer.getByte(i);
|
||||
* System.out.println((char) b);
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -220,7 +220,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
|||
*
|
||||
* <h4>Strings</h4>
|
||||
*
|
||||
* Various {@link #toString(Charset)} methods convert a {@link ChannelBuffer}
|
||||
* Various {@link #toString(String)} methods convert a {@link ChannelBuffer}
|
||||
* into a {@link String}. Please note that {@link #toString()} is not a
|
||||
* conversion method.
|
||||
*
|
||||
|
@ -232,7 +232,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2268 $, $Date: 2010-05-06 16:33:26 +0900 (Thu, 06 May 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
@ -1094,6 +1094,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
ChannelBuffer readBytes(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readBytes(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ChannelBuffer readBytes(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Returns a new slice of this buffer's sub-region starting at the current
|
||||
* {@code readerIndex} and increases the {@code readerIndex} by the size
|
||||
|
@ -1108,6 +1114,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
ChannelBuffer readSlice(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readSlice(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ChannelBuffer readSlice(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Transfers this buffer's data to the specified destination starting at
|
||||
* the current {@code readerIndex} until the destination becomes
|
||||
|
@ -1229,6 +1241,12 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
void skipBytes(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #skipBytes(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
int skipBytes(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Sets the specified byte at the current {@code writerIndex}
|
||||
* and increases the {@code writerIndex} by {@code 1} in this buffer.
|
||||
|
@ -1699,6 +1717,33 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
String toString(int index, int length, Charset charset);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #toString(Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(String charsetName);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(
|
||||
String charsetName, ChannelBufferIndexFinder terminatorFinder);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(int index, int length, String charsetName);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(
|
||||
int index, int length, String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder);
|
||||
|
||||
/**
|
||||
* Returns a hash code which was calculated from the content of this
|
||||
* buffer. If there's a byte array which is
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.ByteOrder;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface ChannelBufferFactory {
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ package org.jboss.netty.buffer;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer
|
||||
*/
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.io.InputStream;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @see ChannelBufferOutputStream
|
||||
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.io.OutputStream;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @see ChannelBufferInputStream
|
||||
* @apiviz.uses org.jboss.netty.buffer.ChannelBuffer
|
||||
|
|
|
@ -85,7 +85,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2269 $, $Date: 2010-05-06 16:37:27 +0900 (Thu, 06 May 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.has org.jboss.netty.buffer.ChannelBuffer oneway - - creates
|
||||
|
@ -313,7 +313,7 @@ public class ChannelBuffers {
|
|||
return EMPTY_BUFFER;
|
||||
}
|
||||
if (buffer.hasArray()) {
|
||||
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset(),buffer.remaining());
|
||||
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(),buffer.remaining());
|
||||
} else {
|
||||
return new ByteBufferBackedChannelBuffer(buffer);
|
||||
}
|
||||
|
@ -811,6 +811,22 @@ public class ChannelBuffers {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #copiedBuffer(CharSequence, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ChannelBuffer copiedBuffer(String string, String charsetName) {
|
||||
return copiedBuffer(string, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #copiedBuffer(ByteOrder, CharSequence, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ChannelBuffer copiedBuffer(ByteOrder endianness, String string, String charsetName) {
|
||||
return copiedBuffer(endianness, string, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a read-only buffer which disallows any modification operations
|
||||
* on the specified {@code buffer}. The new buffer has the same
|
||||
|
@ -979,8 +995,8 @@ public class ChannelBuffers {
|
|||
}
|
||||
|
||||
for (int i = byteCount; i > 0; i --) {
|
||||
byte va = bufferA.getByte(aIndex);
|
||||
byte vb = bufferB.getByte(bIndex);
|
||||
short va = bufferA.getUnsignedByte(aIndex);
|
||||
short vb = bufferB.getUnsignedByte(bIndex);
|
||||
if (va > vb) {
|
||||
return 1;
|
||||
} else if (va < vb) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @author Frederic Bregier (fredbregier@free.fr)
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*
|
||||
*/
|
||||
public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.nio.ByteOrder;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2293 $, $Date: 2010-06-01 17:38:51 +0900 (Tue, 01 Jun 2010) $
|
||||
*/
|
||||
public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*
|
||||
*/
|
||||
public class DuplicatedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206M $, $Date: 2010-11-09 15:04:10 +0900 (Tue, 09 Nov 2010) $
|
||||
*
|
||||
*/
|
||||
public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2309 $, $Date: 2010-06-21 16:00:03 +0900 (Mon, 21 Jun 2010) $
|
||||
*/
|
||||
public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.nio.ByteOrder;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2197 $, $Date: 2010-02-23 09:43:15 +0900 (Tue, 23 Feb 2010) $
|
||||
*/
|
||||
public class HeapChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.nio.ByteOrder;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*/
|
||||
public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*
|
||||
*/
|
||||
public class ReadOnlyChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*
|
||||
*/
|
||||
public class SlicedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2206 $, $Date: 2010-03-03 14:35:01 +0900 (Wed, 03 Mar 2010) $
|
||||
*
|
||||
*/
|
||||
public class TruncatedChannelBuffer extends AbstractChannelBuffer implements WrappedChannelBuffer {
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.jboss.netty.buffer;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public interface WrappedChannelBuffer extends ChannelBuffer {
|
||||
|
|
|
@ -26,13 +26,12 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2339 $, $Date: 2010-07-07 13:36:25 +0900 (Wed, 07 Jul 2010) $
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractChannel implements Channel {
|
||||
|
||||
static final ConcurrentMap<Integer, Channel> allChannels = new ConcurrentHashMap<Integer, Channel>();
|
||||
private static final IdDeallocator ID_DEALLOCATOR = new IdDeallocator();
|
||||
|
||||
private static Integer allocateId(Channel channel) {
|
||||
Integer id = Integer.valueOf(System.identityHashCode(channel));
|
||||
|
@ -49,16 +48,6 @@ public abstract class AbstractChannel implements Channel {
|
|||
}
|
||||
}
|
||||
|
||||
private static final class IdDeallocator implements ChannelFutureListener {
|
||||
IdDeallocator() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
allChannels.remove(future.getChannel().getId());
|
||||
}
|
||||
}
|
||||
|
||||
private final Integer id;
|
||||
private final Channel parent;
|
||||
private final ChannelFactory factory;
|
||||
|
@ -93,7 +82,6 @@ public abstract class AbstractChannel implements Channel {
|
|||
this.pipeline = pipeline;
|
||||
|
||||
id = allocateId(this);
|
||||
closeFuture.addListener(ID_DEALLOCATOR);
|
||||
|
||||
pipeline.attach(this, sink);
|
||||
}
|
||||
|
@ -193,6 +181,10 @@ public abstract class AbstractChannel implements Channel {
|
|||
* closed yet
|
||||
*/
|
||||
protected boolean setClosed() {
|
||||
// Deallocate the current channel's ID from allChannels so that other
|
||||
// new channels can use it.
|
||||
allChannels.remove(id);
|
||||
|
||||
return closeFuture.setClosed();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public abstract class AbstractChannelSink implements ChannelSink {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.net.SocketAddress;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel {
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class AdaptiveReceiveBufferSizePredictor implements
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class AdaptiveReceiveBufferSizePredictorFactory implements
|
||||
ReceiveBufferSizePredictorFactory {
|
||||
|
|
|
@ -103,7 +103,7 @@ import org.jboss.netty.channel.socket.nio.NioSocketChannelConfig;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2244 $, $Date: 2010-04-16 14:07:37 +0900 (Fri, 16 Apr 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.composedOf org.jboss.netty.channel.ChannelConfig
|
||||
|
|
|
@ -63,7 +63,7 @@ import org.jboss.netty.channel.socket.nio.NioSocketChannelConfig;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.has org.jboss.netty.channel.ChannelPipelineFactory
|
||||
* @apiviz.composedOf org.jboss.netty.channel.ReceiveBufferSizePredictor
|
||||
|
|
|
@ -71,7 +71,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
|
||||
*/
|
||||
|
|
|
@ -71,6 +71,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||
* <td>{@code "channelOpen"}</td>
|
||||
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#OPEN OPEN}, value = {@code true})</td>
|
||||
* <td>a {@link Channel} is open, but not bound nor connected</td>
|
||||
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code "channelClosed"}</td>
|
||||
|
@ -80,7 +81,8 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||
* <tr>
|
||||
* <td>{@code "channelBound"}</td>
|
||||
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#BOUND BOUND}, value = {@link SocketAddress})</td>
|
||||
* <td>a {@link Channel} is open and bound to a local address, but not connected</td>
|
||||
* <td>a {@link Channel} is open and bound to a local address, but not connected.</td>
|
||||
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code "channelUnbound"}</td>
|
||||
|
@ -91,6 +93,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||
* <td>{@code "channelConnected"}</td>
|
||||
* <td>{@link ChannelStateEvent}<br/>(state = {@link ChannelState#CONNECTED CONNECTED}, value = {@link SocketAddress})</td>
|
||||
* <td>a {@link Channel} is open, bound to a local address, and connected to a remote address</td>
|
||||
* <td><strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code "writeComplete"}</td>
|
||||
|
@ -179,7 +182,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.composedOf org.jboss.netty.channel.ChannelFuture
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.hidden
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.jboss.netty.util.ExternalResourceReleasable;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.has org.jboss.netty.channel.Channel oneway - - creates
|
||||
|
|
|
@ -167,7 +167,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2192 $, $Date: 2010-02-19 18:58:38 +0900 (Fri, 19 Feb 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.owns org.jboss.netty.channel.ChannelFutureListener - - notifies
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.EventListener;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2185 $, $Date: 2010-02-19 14:13:48 +0900 (Fri, 19 Feb 2010) $
|
||||
*/
|
||||
public interface ChannelFutureListener extends EventListener {
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ import org.jboss.netty.channel.group.ChannelGroup;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2152 $, $Date: 2010-02-17 17:22:45 +0900 (Wed, 17 Feb 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
|
||||
|
@ -227,7 +227,7 @@ public interface ChannelHandler {
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2152 $, $Date: 2010-02-17 17:22:45 +0900 (Wed, 17 Feb 2010) $
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
|
|
|
@ -51,7 +51,7 @@ package org.jboss.netty.channel;
|
|||
* public void login(String username, password) {
|
||||
* {@link Channels}.write(
|
||||
* <b>this.ctx</b>,
|
||||
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()),
|
||||
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()</b>),
|
||||
* new LoginMessage(username, password));
|
||||
* }
|
||||
* ...
|
||||
|
@ -120,7 +120,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2157 $, $Date: 2010-02-17 17:37:38 +0900 (Wed, 17 Feb 2010) $
|
||||
*
|
||||
* @apiviz.owns org.jboss.netty.channel.ChannelHandler
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.hidden
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.stereotype utility
|
||||
*/
|
||||
|
@ -40,18 +40,36 @@ public class ChannelLocal<T> {
|
|||
private final ConcurrentMap<Channel, T> map =
|
||||
new ConcurrentIdentityWeakKeyHashMap<Channel, T>();
|
||||
|
||||
|
||||
private final ChannelFutureListener remover = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
remove(future.getChannel());
|
||||
}
|
||||
};
|
||||
|
||||
private final boolean removeOnClose;
|
||||
|
||||
/**
|
||||
* Creates a {@link Channel} local variable.
|
||||
* Creates a {@link Channel} local variable by calling {@link #ChannelLocal(boolean)} with <code>false</code> as parameter
|
||||
*/
|
||||
public ChannelLocal() {
|
||||
super();
|
||||
this(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Channel} local variable.
|
||||
*
|
||||
* @param removeOnClose if <code>true</code> the {@link ChannelLocal} will remove a {@link Channel} from it own once the {@link Channel} was closed.
|
||||
*/
|
||||
public ChannelLocal(boolean removeOnClose) {
|
||||
this.removeOnClose = removeOnClose;
|
||||
}
|
||||
/**
|
||||
* Returns the initial value of the variable. By default, it returns
|
||||
* {@code null}. Override it to change the initial value.
|
||||
*/
|
||||
protected T initialValue(@SuppressWarnings("unused") Channel channel) {
|
||||
protected T initialValue(Channel channel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -88,7 +106,11 @@ public class ChannelLocal<T> {
|
|||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
return map.put(channel, value);
|
||||
T old = map.put(channel, value);
|
||||
if (removeOnClose) {
|
||||
channel.getCloseFuture().addListener(remover);
|
||||
}
|
||||
return old;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,19 +127,36 @@ public class ChannelLocal<T> {
|
|||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
return map.putIfAbsent(channel, value);
|
||||
T mapping = map.putIfAbsent(channel, value);
|
||||
|
||||
if (removeOnClose && mapping == null) {
|
||||
channel.getCloseFuture().addListener(remover);
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the variable.
|
||||
* Removes the variable and returns the removed value. If no value was set,
|
||||
* this method returns the return value of {@link #initialValue(Channel)},
|
||||
* which is {@code null} by default.
|
||||
*
|
||||
* @return the removed value. {@code null} if no value was set.
|
||||
* @return the removed value.
|
||||
* {@linkplain #initialValue(Channel) an initial value} (by default
|
||||
* {@code null}) if no value was set.
|
||||
*/
|
||||
public T remove(Channel channel) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
return map.remove(channel);
|
||||
T removed = map.remove(channel);
|
||||
if (removed == null) {
|
||||
return initialValue(channel);
|
||||
} else {
|
||||
if (removeOnClose) {
|
||||
channel.getCloseFuture().removeListener(remover);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.jboss.netty.channel;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -203,7 +204,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2153 $, $Date: 2010-02-17 17:24:25 +0900 (Wed, 17 Feb 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.composedOf org.jboss.netty.channel.ChannelHandlerContext
|
||||
|
@ -488,6 +489,11 @@ public interface ChannelPipeline {
|
|||
*/
|
||||
boolean isAttached();
|
||||
|
||||
/**
|
||||
* Returns the {@link List} of the handler names.
|
||||
*/
|
||||
List<String> getNames();
|
||||
|
||||
/**
|
||||
* Converts this pipeline into an ordered {@link Map} whose keys are
|
||||
* handler names and whose values are handlers.
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2009 Red Hat, Inc.
|
||||
*
|
||||
* Red Hat licenses this file to you under the Apache License, version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
|
||||
/**
|
||||
* @deprecated Use the {@link Sharable} annotation instead.
|
||||
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev: 2124 $, $Date: 2010-02-02 11:13:06 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.exclude
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Deprecated
|
||||
public @interface ChannelPipelineCoverage {
|
||||
|
||||
/**
|
||||
* {@code "all"}
|
||||
*/
|
||||
public static final String ALL = "all";
|
||||
|
||||
/**
|
||||
* {@code "one"}
|
||||
*/
|
||||
public static final String ONE = "one";
|
||||
|
||||
/**
|
||||
* The value of this annotation
|
||||
*/
|
||||
String value();
|
||||
}
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.hidden
|
||||
*/
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2145 $, $Date: 2010-02-09 12:56:29 +0900 (Tue, 09 Feb 2010) $
|
||||
*
|
||||
* @apiviz.has org.jboss.netty.channel.ChannelPipeline oneway - - creates
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.uses org.jboss.netty.channel.ChannelPipeline - - sends events upstream
|
||||
*/
|
||||
|
|
|
@ -77,7 +77,7 @@ import java.net.SocketAddress;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public enum ChannelState {
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.has org.jboss.netty.channel.ChannelState
|
||||
*/
|
||||
|
|
|
@ -87,7 +87,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.exclude ^org\.jboss\.netty\.handler\..*$
|
||||
*/
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
|
|||
*
|
||||
* @apiviz.landmark
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2210 $, $Date: 2010-03-04 08:11:39 +0900 (Thu, 04 Mar 2010) $
|
||||
*/
|
||||
public class Channels {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface ChildChannelStateEvent extends ChannelEvent {
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2192 $, $Date: 2010-02-19 18:58:38 +0900 (Fri, 19 Feb 2010) $
|
||||
*/
|
||||
public abstract class CompleteChannelFuture implements ChannelFuture {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class DefaultChannelConfig implements ChannelConfig {
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.IoWorkerRunnable;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
|
||||
/**
|
||||
* The default {@link ChannelFuture} implementation. It is recommended to
|
||||
|
@ -35,7 +35,7 @@ import org.jboss.netty.util.internal.IoWorkerRunnable;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2201 $, $Date: 2010-02-23 14:45:53 +0900 (Tue, 23 Feb 2010) $
|
||||
*/
|
||||
public class DefaultChannelFuture implements ChannelFuture {
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||
}
|
||||
|
||||
private void checkDeadLock() {
|
||||
if (isUseDeadLockChecker() && IoWorkerRunnable.IN_IO_THREAD.get()) {
|
||||
if (isUseDeadLockChecker() && DeadLockProofWorker.PARENT.get() != null) {
|
||||
throw new IllegalStateException(
|
||||
"await*() in I/O thread causes a dead lock or " +
|
||||
"sudden performance drop. Use addListener() instead or " +
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -31,7 +33,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2119 $, $Date: 2010-02-01 20:46:09 +0900 (Mon, 01 Feb 2010) $
|
||||
*
|
||||
*/
|
||||
public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
@ -487,6 +489,23 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<String> getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (name2ctx.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
DefaultChannelHandlerContext ctx = head;
|
||||
for (;;) {
|
||||
list.add(ctx.getName());
|
||||
ctx = ctx.next;
|
||||
if (ctx == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
if (name2ctx.isEmpty()) {
|
||||
|
@ -564,9 +583,19 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||
}
|
||||
|
||||
void sendDownstream(DefaultChannelHandlerContext ctx, ChannelEvent e) {
|
||||
if (e instanceof UpstreamMessageEvent) {
|
||||
throw new IllegalArgumentException("cannot send an upstream event to downstream");
|
||||
}
|
||||
|
||||
try {
|
||||
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
|
||||
} catch (Throwable t) {
|
||||
// Unlike an upstream event, a downstream event usually has an
|
||||
// incomplete future which is supposed to be updated by ChannelSink.
|
||||
// However, if an exception is raised before the event reaches at
|
||||
// ChannelSink, the future is not going to be updated, so we update
|
||||
// here.
|
||||
e.getFuture().setFailure(t);
|
||||
notifyHandlerException(e, t);
|
||||
}
|
||||
}
|
||||
|
@ -636,7 +665,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||
|
||||
private void checkDuplicateName(String name) {
|
||||
if (name2ctx.containsKey(name)) {
|
||||
throw new IllegalArgumentException("Duplicate handler name.");
|
||||
throw new IllegalArgumentException("Duplicate handler name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class DefaultChildChannelStateEvent implements ChildChannelStateEvent {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.jboss.netty.util.internal.StackTraceSimplifier;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class DefaultExceptionEvent implements ExceptionEvent {
|
||||
|
|
|
@ -14,11 +14,17 @@ public class DefaultFileRegion implements FileRegion {
|
|||
private final FileChannel file;
|
||||
private final long position;
|
||||
private final long count;
|
||||
private final boolean releaseAfterTransfer;
|
||||
|
||||
public DefaultFileRegion(FileChannel file, long position, long count) {
|
||||
this(file, position, count, false);
|
||||
}
|
||||
|
||||
public DefaultFileRegion(FileChannel file, long position, long count, boolean releaseAfterTransfer) {
|
||||
this.file = file;
|
||||
this.position = position;
|
||||
this.count = count;
|
||||
this.releaseAfterTransfer = releaseAfterTransfer;
|
||||
}
|
||||
|
||||
public long getPosition() {
|
||||
|
@ -29,6 +35,10 @@ public class DefaultFileRegion implements FileRegion {
|
|||
return count;
|
||||
}
|
||||
|
||||
public boolean releaseAfterTransfer() {
|
||||
return releaseAfterTransfer;
|
||||
}
|
||||
|
||||
public long transferTo(WritableByteChannel target, long position) throws IOException {
|
||||
long count = this.count - position;
|
||||
if (count < 0 || position < 0) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannelConfig;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2210 $, $Date: 2010-03-04 08:11:39 +0900 (Thu, 04 Mar 2010) $
|
||||
*/
|
||||
public class DefaultWriteCompletionEvent implements WriteCompletionEvent {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class DownstreamChannelStateEvent implements ChannelStateEvent {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class DownstreamMessageEvent implements MessageEvent {
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface ExceptionEvent extends ChannelEvent {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class FailedChannelFuture extends CompleteChannelFuture {
|
||||
|
||||
|
|
|
@ -48,12 +48,21 @@ import org.jboss.netty.util.ExternalResourceReleasable;
|
|||
* transfer, sending a file with {@link FileRegion} might fail or yield worse
|
||||
* performance. For example, sending a large file doesn't work well in Windows.
|
||||
*
|
||||
* <h3>Not all transports support it</h3>
|
||||
*
|
||||
* Currently, the NIO transport is the only transport that supports {@link FileRegion}.
|
||||
* Attempting to write a {@link FileRegion} to non-NIO {@link Channel} will trigger
|
||||
* a {@link ClassCastException} or a similar exception.
|
||||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface FileRegion extends ExternalResourceReleasable {
|
||||
|
||||
// FIXME Make sure all transports support writing a FileRegion
|
||||
// Even if zero copy cannot be achieved, all transports should emulate it.
|
||||
|
||||
/**
|
||||
* Returns the offset in the file where the transfer began.
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class FixedReceiveBufferSizePredictor implements
|
||||
ReceiveBufferSizePredictor {
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class FixedReceiveBufferSizePredictorFactory implements
|
||||
ReceiveBufferSizePredictorFactory {
|
||||
|
|
|
@ -30,7 +30,7 @@ package org.jboss.netty.channel;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface LifeCycleAwareChannelHandler extends ChannelHandler {
|
||||
void beforeAdd(ChannelHandlerContext ctx) throws Exception;
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.net.SocketAddress;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface MessageEvent extends ChannelEvent {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public interface ReceiveBufferSizePredictor {
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2124 $, $Date: 2010-02-02 11:13:06 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.has org.jboss.netty.channel.ReceiveBufferSizePredictor oneway - - creates
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface ServerChannel extends Channel {
|
||||
// This is a tag interface.
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.has org.jboss.netty.channel.ServerChannel oneway - - creates
|
||||
*/
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.net.SocketAddress;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*/
|
||||
public class SimpleChannelDownstreamHandler implements ChannelDownstreamHandler {
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*/
|
||||
public class SimpleChannelHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler {
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*/
|
||||
public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
|
||||
|
||||
|
@ -150,6 +150,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
|
|||
|
||||
/**
|
||||
* Invoked when a {@link Channel} is open, but not bound nor connected.
|
||||
* <br/>
|
||||
*
|
||||
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
|
||||
*/
|
||||
public void channelOpen(
|
||||
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
||||
|
@ -159,6 +162,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
|
|||
/**
|
||||
* Invoked when a {@link Channel} is open and bound to a local address,
|
||||
* but not connected.
|
||||
* <br/>
|
||||
*
|
||||
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
|
||||
*/
|
||||
public void channelBound(
|
||||
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
||||
|
@ -168,6 +174,9 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler {
|
|||
/**
|
||||
* Invoked when a {@link Channel} is open, bound to a local address, and
|
||||
* connected to a remote address.
|
||||
* <br/>
|
||||
*
|
||||
* <strong>Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers!</strong>
|
||||
*/
|
||||
public void channelConnected(
|
||||
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
|
@ -32,7 +34,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2267 $, $Date: 2010-05-06 16:00:52 +0900 (Thu, 06 May 2010) $
|
||||
*
|
||||
*/
|
||||
public class StaticChannelPipeline implements ChannelPipeline {
|
||||
|
@ -317,6 +319,14 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<String> getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
list.add(ctx.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
|
@ -381,9 +391,19 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
|||
}
|
||||
|
||||
void sendDownstream(StaticChannelHandlerContext ctx, ChannelEvent e) {
|
||||
if (e instanceof UpstreamMessageEvent) {
|
||||
throw new IllegalArgumentException("cannot send an upstream event to downstream");
|
||||
}
|
||||
|
||||
try {
|
||||
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
|
||||
} catch (Throwable t) {
|
||||
// Unlike an upstream event, a downstream event usually has an
|
||||
// incomplete future which is supposed to be updated by ChannelSink.
|
||||
// However, if an exception is raised before the event reaches at
|
||||
// ChannelSink, the future is not going to be updated, so we update
|
||||
// here.
|
||||
e.getFuture().setFailure(t);
|
||||
notifyHandlerException(e, t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public class SucceededChannelFuture extends CompleteChannelFuture {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.jboss.netty.channel.Channels.*;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class UpstreamChannelStateEvent implements ChannelStateEvent {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jboss.netty.util.internal.StringUtil;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
*/
|
||||
public class UpstreamMessageEvent implements MessageEvent {
|
||||
|
|
|
@ -25,7 +25,7 @@ package org.jboss.netty.channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2202 $, $Date: 2010-02-23 16:18:58 +0900 (Tue, 23 Feb 2010) $
|
||||
*/
|
||||
public interface WriteCompletionEvent extends ChannelEvent {
|
||||
/**
|
||||
|
|
|
@ -90,7 +90,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
* @apiviz.has org.jboss.netty.channel.group.ChannelGroupFuture oneway - - returns
|
||||
|
|
|
@ -110,7 +110,7 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
|
||||
*
|
||||
* @apiviz.owns org.jboss.netty.channel.group.ChannelGroupFutureListener - - notifies
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.EventListener;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface ChannelGroupFutureListener extends EventListener {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.NoSuchElementException;
|
|||
/**
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
final class CombinedIterator<E> implements Iterator<E> {
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
@ -253,11 +253,11 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
if (message instanceof ChannelBuffer) {
|
||||
ChannelBuffer buf = (ChannelBuffer) message;
|
||||
for (Channel c: this) {
|
||||
for (Channel c: nonServerChannels.values()) {
|
||||
futures.put(c.getId(), c.write(buf.duplicate()));
|
||||
}
|
||||
} else {
|
||||
for (Channel c: this) {
|
||||
for (Channel c: nonServerChannels.values()) {
|
||||
futures.put(c.getId(), c.write(message));
|
||||
}
|
||||
}
|
||||
|
@ -269,11 +269,11 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||
if (message instanceof ChannelBuffer) {
|
||||
ChannelBuffer buf = (ChannelBuffer) message;
|
||||
for (Channel c: this) {
|
||||
for (Channel c: nonServerChannels.values()) {
|
||||
futures.put(c.getId(), c.write(buf.duplicate(), remoteAddress));
|
||||
}
|
||||
} else {
|
||||
for (Channel c: this) {
|
||||
for (Channel c: nonServerChannels.values()) {
|
||||
futures.put(c.getId(), c.write(message, remoteAddress));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jboss.netty.channel.ChannelFuture;
|
|||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.IoWorkerRunnable;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
|
||||
/**
|
||||
* The default {@link ChannelGroupFuture} implementation.
|
||||
|
@ -39,7 +39,7 @@ import org.jboss.netty.util.internal.IoWorkerRunnable;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2191 $, $Date: 2010-02-19 18:18:10 +0900 (Fri, 19 Feb 2010) $
|
||||
*/
|
||||
public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
|
||||
|
@ -144,15 +144,16 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||
}
|
||||
|
||||
public synchronized boolean isPartialSuccess() {
|
||||
return !futures.isEmpty() && successCount != 0;
|
||||
return successCount != 0 && successCount != futures.size();
|
||||
}
|
||||
|
||||
public synchronized boolean isPartialFailure() {
|
||||
return !futures.isEmpty() && failureCount != 0;
|
||||
return failureCount != 0 && failureCount != futures.size();
|
||||
}
|
||||
|
||||
public synchronized boolean isCompleteFailure() {
|
||||
return failureCount == futures.size();
|
||||
int futureCnt = futures.size();
|
||||
return futureCnt != 0 && failureCount == futureCnt;
|
||||
}
|
||||
|
||||
public void addListener(ChannelGroupFutureListener listener) {
|
||||
|
@ -320,7 +321,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||
}
|
||||
|
||||
private void checkDeadLock() {
|
||||
if (IoWorkerRunnable.IN_IO_THREAD.get()) {
|
||||
if (DeadLockProofWorker.PARENT.get() != null) {
|
||||
throw new IllegalStateException(
|
||||
"await*() in I/O thread causes a dead lock or " +
|
||||
"sudden performance drop. Use addListener() instead or " +
|
||||
|
|
|
@ -20,12 +20,14 @@ import static org.jboss.netty.channel.Channels.*;
|
|||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.NotYetConnectedException;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jboss.netty.channel.AbstractChannel;
|
||||
import org.jboss.netty.channel.ChannelConfig;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.DefaultChannelConfig;
|
||||
|
@ -37,13 +39,20 @@ import org.jboss.netty.util.internal.ThreadLocalBoolean;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
final class DefaultLocalChannel extends AbstractChannel implements LocalChannel {
|
||||
|
||||
// TODO Move the state management up to AbstractChannel to remove duplication.
|
||||
private static final int ST_OPEN = 0;
|
||||
private static final int ST_BOUND = 1;
|
||||
private static final int ST_CONNECTED = 2;
|
||||
private static final int ST_CLOSED = -1;
|
||||
final AtomicInteger state = new AtomicInteger(ST_OPEN);
|
||||
|
||||
private final ChannelConfig config;
|
||||
private final ThreadLocalBoolean delivering = new ThreadLocalBoolean();
|
||||
final AtomicBoolean bound = new AtomicBoolean();
|
||||
|
||||
final Queue<MessageEvent> writeBuffer = new LinkedTransferQueue<MessageEvent>();
|
||||
|
||||
volatile DefaultLocalChannel pairedChannel;
|
||||
|
@ -54,6 +63,15 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||
super(parent, factory, pipeline, sink);
|
||||
this.pairedChannel = pairedChannel;
|
||||
config = new DefaultChannelConfig();
|
||||
|
||||
// TODO Move the state variable to AbstractChannel so that we don't need
|
||||
// to add many listeners.
|
||||
getCloseFuture().addListener(new ChannelFutureListener() {
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
state.set(ST_CLOSED);
|
||||
}
|
||||
});
|
||||
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
|
@ -61,12 +79,39 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return state.get() >= ST_OPEN;
|
||||
}
|
||||
|
||||
public boolean isBound() {
|
||||
return bound.get() && isOpen();
|
||||
return state.get() >= ST_BOUND;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return pairedChannel != null && isOpen();
|
||||
return state.get() == ST_CONNECTED;
|
||||
}
|
||||
|
||||
final void setBound() throws ClosedChannelException {
|
||||
if (!state.compareAndSet(ST_OPEN, ST_BOUND)) {
|
||||
switch (state.get()) {
|
||||
case ST_CLOSED:
|
||||
throw new ClosedChannelException();
|
||||
default:
|
||||
throw new ChannelException("already bound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void setConnected() {
|
||||
if (state.get() != ST_CLOSED) {
|
||||
state.set(ST_CONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setClosed() {
|
||||
return super.setClosed();
|
||||
}
|
||||
|
||||
public LocalAddress getLocalAddress() {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelSink;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jboss.netty.channel.DefaultServerChannelConfig;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
final class DefaultLocalServerChannel extends AbstractServerChannel
|
||||
implements LocalServerChannel {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelSink;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.net.SocketAddress;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
|
||||
*
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
|
@ -114,7 +114,7 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
|
|||
}
|
||||
|
||||
int a = System.identityHashCode(this);
|
||||
int b = System.identityHashCode(this);
|
||||
int b = System.identityHashCode(o);
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a > b) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.jboss.netty.channel.Channel;
|
|||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface LocalChannel extends Channel {
|
||||
LocalAddress getLocalAddress();
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.jboss.netty.util.internal.ConcurrentHashMap;
|
|||
/**
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
final class LocalChannelRegistry {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.jboss.netty.channel.ChannelPipeline;
|
|||
*
|
||||
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
|
||||
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
|
||||
* @version $Rev$, $Date$
|
||||
* @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
|
||||
*/
|
||||
public interface LocalClientChannelFactory extends ChannelFactory {
|
||||
LocalChannel newChannel(ChannelPipeline pipeline);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue