本文整理匯總了Java中org.simpleframework.transport.Channel類的典型用法代碼示例。如果您正苦於以下問題:Java Channel類的具體用法?Java Channel怎麽用?Java Channel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Channel類屬於org.simpleframework.transport包,在下文中一共展示了Channel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testHandler
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void testHandler(int dribble) throws Exception {
StreamCursor cursor = new StreamCursor(SOURCE);
Channel channel = new TestChannel(cursor, dribble);
start(channel);
assertEquals(cursor.ready(), -1);
}
示例2: testHandler
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void testHandler(Initiator handler, String payload, int dribble) throws Exception {
StreamCursor cursor = new StreamCursor(payload);
Channel channel = new TestChannel(cursor, dribble);
handler.start(channel);
}
示例3: getChannel
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public Channel getChannel() {
return null;
}
示例4: testPayload
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void testPayload(int dribble) throws Exception {
Cursor cursor = new DribbleCursor(new StreamCursor(PAYLOAD), 10);
Channel channel = new MockChannel(cursor);
MockSelector selector = new MockSelector();
Collector body = new Collector(new ArrayAllocator(), channel);
long time = System.currentTimeMillis();
while(!selector.isReady()) {
body.collect(selector);
}
System.err.println("Time taken to parse payload "+(System.currentTimeMillis() - time)+" ms");
Header header = body.getHeader();
List<Part> list = body.getBody().getParts();
assertEquals(header.getTarget(), "/index.html");
assertEquals(header.getMethod(), "POST");
assertEquals(header.getMajor(), 1);
assertEquals(header.getMinor(), 0);
assertEquals(header.getContentType().getPrimary(), "multipart");
assertEquals(header.getContentType().getSecondary(), "form-data");
assertEquals(header.getValue("Host"), "some.host.com");
assertEquals(header.getValues("Accept").size(), 4);
assertEquals(header.getValues("Accept").get(0), "image/gif");
assertEquals(header.getValues("Accept").get(1), "image/png");
assertEquals(header.getValues("Accept").get(2), "image/jpeg");
assertEquals(header.getValues("Accept").get(3), "*");
assertEquals(list.size(), 4);
assertEquals(list.get(0).getContentType().getPrimary(), "text");
assertEquals(list.get(0).getContentType().getSecondary(), "plain");
assertEquals(list.get(0).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getContentType().getSecondary(), "plain");
assertEquals(list.get(1).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file2.txt'");
assertEquals(list.get(2).getContentType().getPrimary(), "text");
assertEquals(list.get(2).getContentType().getSecondary(), "plain");
assertEquals(list.get(2).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file3.txt'");
assertEquals(list.get(3).getContentType().getPrimary(), "text");
assertEquals(list.get(3).getContentType().getSecondary(), "plain");
assertEquals(list.get(3).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file4.txt'");
assertEquals(cursor.ready(), -1);
}
示例5: start
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void start(Channel channel) throws IOException {
initiated = true;
}
示例6: start
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void start(Channel channel) throws IOException {
start(new Collector(new ArrayAllocator(), channel));
}
示例7: ready
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void ready(Collector collector) throws IOException {
Entity entity = collector;
Channel channel = entity.getChannel();
Cursor cursor = channel.getCursor();
Header header = entity.getHeader();
Body body = entity.getBody();
List<Part> list = body.getParts();
assertEquals(header.getTarget(), "/index.html");
assertEquals(header.getMethod(), "POST");
assertEquals(header.getMajor(), 1);
assertEquals(header.getMinor(), 0);
assertEquals(header.getContentType().getPrimary(), "multipart");
assertEquals(header.getContentType().getSecondary(), "form-data");
assertEquals(header.getValue("Host"), "some.host.com");
assertEquals(header.getValues("Accept").size(), 4);
assertEquals(header.getValues("Accept").get(0), "image/gif");
assertEquals(header.getValues("Accept").get(1), "image/png");
assertEquals(header.getValues("Accept").get(2), "image/jpeg");
assertEquals(header.getValues("Accept").get(3), "*");
assertEquals(list.size(), 4);
assertEquals(list.get(0).getContentType().getPrimary(), "text");
assertEquals(list.get(0).getContentType().getSecondary(), "plain");
assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
assertEquals(list.get(0).getName(), "pics");
assertEquals(list.get(0).getFileName(), "file1.txt");
assertEquals(list.get(0).isFile(), true);
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getContentType().getSecondary(), "plain");
assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file2.txt\"");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getName(), "pics");
assertEquals(list.get(1).getFileName(), "file2.txt");
assertEquals(list.get(1).isFile(), true);
assertEquals(list.get(2).getContentType().getSecondary(), "plain");
assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file3.txt\"");
assertEquals(list.get(2).getName(), "pics");
assertEquals(list.get(2).getFileName(), "file3.txt");
assertEquals(list.get(2).isFile(), true);
assertEquals(list.get(3).getContentType().getPrimary(), "text");
assertEquals(list.get(3).getContentType().getSecondary(), "plain");
assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file4.txt\"");
assertEquals(list.get(3).getName(), "pics");
assertEquals(list.get(3).getFileName(), "file4.txt");
assertEquals(list.get(3).isFile(), true);
assertEquals(cursor.ready(), -1);
}
示例8: testPayload
import org.simpleframework.transport.Channel; //導入依賴的package包/類
public void testPayload(int dribble) throws Exception {
System.out.println("Testing dribbling cursor of "+dribble+" ...");
Cursor cursor = new StreamCursor(PAYLOAD);
if(dribble < PAYLOAD.length) {
cursor = new DribbleCursor(cursor, dribble);
}
Channel channel = new MockChannel(cursor);
MockSelector selector = new MockSelector();
Collector body = new Collector(new ArrayAllocator(), channel);
while(!selector.isReady()) {
body.collect(selector);
}
Request request = new RequestEntity(body, null);
List<Part> list = request.getParts();
assertEquals(request.getParameter("a"), "b");
assertEquals(request.getParameter("c"), "d");
assertEquals(request.getParameter("e"), "f");
assertEquals(request.getParameter("g"), "h");
assertEquals(request.getTarget(), "/index.html?a=b&c=d&e=f&g=h&a=1");
assertEquals(request.getMethod(), "POST");
assertEquals(request.getMajor(), 1);
assertEquals(request.getMinor(), 0);
assertEquals(request.getContentType().getPrimary(), "multipart");
assertEquals(request.getContentType().getSecondary(), "form-data");
assertEquals(request.getValue("Host"), "some.host.com");
assertEquals(request.getValues("Accept").size(), 4);
assertEquals(request.getValues("Accept").get(0), "image/gif");
assertEquals(request.getValues("Accept").get(1), "image/png");
assertEquals(request.getValues("Accept").get(2), "image/jpeg");
assertEquals(request.getValues("Accept").get(3), "*");
assertEquals(request.getCookie("UID").getValue(), "1234-5678");
assertEquals(request.getCookie("UID").getPath(), "/");
assertEquals(request.getCookie("UID").getDomain(), ".host.com");
assertEquals(request.getCookie("NAME").getValue(), "Niall Gallagher");
assertEquals(request.getCookie("NAME").getPath(), "/");
assertEquals(request.getCookie("NAME").getDomain(), null);
assertEquals(list.size(), 4);
assertEquals(list.get(0).getContentType().getPrimary(), "text");
assertEquals(list.get(0).getContentType().getSecondary(), "plain");
assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"file1\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
assertEquals(list.get(0).getName(), "file1");
assertEquals(list.get(0).getFileName(), "file1.txt");
assertEquals(list.get(0).isFile(), true);
assertEquals(list.get(0).getContent(), "example contents of file1.txt");
assertEquals(request.getPart("file1").getContent(), "example contents of file1.txt");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getContentType().getSecondary(), "plain");
assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"file2\"; filename=\"file2.txt\"");
assertEquals(list.get(1).getContentType().getPrimary(), "text");
assertEquals(list.get(1).getName(), "file2");
assertEquals(list.get(1).getFileName(), "file2.txt");
assertEquals(list.get(1).isFile(), true);
assertEquals(list.get(1).getContent(), "example contents of file2.txt ...");
assertEquals(request.getPart("file2").getContent(), "example contents of file2.txt ...");
assertEquals(list.get(2).getContentType().getSecondary(), "plain");
assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"file3\"; filename=\"file3.txt\"");
assertEquals(list.get(2).getName(), "file3");
assertEquals(list.get(2).getFileName(), "file3.txt");
assertEquals(list.get(2).isFile(), true);
assertEquals(list.get(2).getContent(), "example contents of file3.txt ...");
assertEquals(request.getPart("file3").getContent(), "example contents of file3.txt ...");
assertEquals(list.get(3).getContentType().getPrimary(), "text");
assertEquals(list.get(3).getContentType().getSecondary(), "plain");
assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"file4\"; filename=\"file4.txt\"");
assertEquals(list.get(3).getName(), "file4");
assertEquals(list.get(3).getFileName(), "file4.txt");
assertEquals(list.get(3).isFile(), true);
assertEquals(list.get(3).getContent(), "example contents of file4.txt ...");
assertEquals(request.getPart("file4").getContent(), "example contents of file4.txt ...");
assertEquals(cursor.ready(), -1);
assertEquals(request.getContent(), BODY);
}
示例9: EntityConsumer
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* Constructor for the <code>EntityConsumer</code> object. This
* is used to build an entity from the constituent parts. Once
* all of the parts have been consumed they are available from
* the exposed methods of this consumed instance.
*
* @param allocator this is used to allocate the memory used
* @param channel this is the channel used to send a response
*/
public EntityConsumer(Allocator allocator, Channel channel) {
this.header = new RequestConsumer();
this.expect = new Expectation(channel);
this.factory = new ConsumerFactory(allocator, header);
this.sequence = header.getHeader();
this.trace = channel.getTrace();
}
示例10: Collector
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* The <code>Collector</code> object used to collect the data from
* the underlying transport. In order to collect a body this must
* be given an <code>Allocator</code> which is used to create an
* internal buffer to store the consumed body.
*
* @param allocator this is the allocator used to buffer data
* @param tracker this is the tracker used to create sessions
* @param channel this is the channel used to read the data
*/
public Collector(Allocator allocator, Channel channel) {
this.entity = new EntityConsumer(allocator, channel);
this.timer = new Timer(MILLISECONDS);
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.channel = channel;
}
示例11: Transfer
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* Constructor for the <code>Transfer</code> object, this is used
* to create an object used to transfer a response body. This must
* be given a <code>Conversation</code> that can be used to set
* and get information regarding the type of transfer required.
*
* @param support this is used to determine the semantics
* @param sender this is used to send data over the transport
* @param monitor this is used to signal I/O events to the kernel
*/
public Transfer(Response response, Conversation support, Channel channel, Monitor monitor) {
this.factory = new ProducerFactory(support, channel, monitor);
this.trace = channel.getTrace();
this.response = response;
this.support = support;
}
示例12: EntityConsumer
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* Constructor for the <code>EntityConsumer</code> object. This is used to
* build an entity from the constituent parts. Once all of the parts have
* been consumed they are available from the exposed methods of this
* consumed instance.
*
* @param allocator
* this is used to allocate the memory used
* @param channel
* this is the channel used to send a response
*/
public EntityConsumer(Allocator allocator, Channel channel) {
this.header = new RequestConsumer();
this.expect = new Expectation(channel);
this.factory = new ConsumerFactory(allocator, this.header);
this.sequence = this.header.getHeader();
this.trace = channel.getTrace();
}
示例13: Collector
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* The <code>Collector</code> object used to collect the data from the
* underlying transport. In order to collect a body this must be given an
* <code>Allocator</code> which is used to create an internal buffer to
* store the consumed body.
*
* @param allocator
* this is the allocator used to buffer data
* @param tracker
* this is the tracker used to create sessions
* @param channel
* this is the channel used to read the data
*/
public Collector(Allocator allocator, Channel channel) {
this.entity = new EntityConsumer(allocator, channel);
this.timer = new Timer(MILLISECONDS);
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.channel = channel;
}
示例14: ProducerFactory
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* Constructor for the <code>ProducerFactory</code> object. This is used to
* create producers that can encode data in a HTTP compliant format. Each
* producer created will produce its data and deliver it to the specified
* sender, should an I/O events occur such as an error, or completion of the
* response then the monitor is notified and the server kernel takes action.
*
* @param support
* this contains details regarding the semantics
* @param sender
* this is used to send to the underlying transport
* @param monitor
* this is used to deliver signals to the kernel
*/
public ProducerFactory(Conversation support, Channel channel,
Monitor monitor) {
this.sender = channel.getSender();
this.support = support;
this.monitor = monitor;
}
示例15: Transfer
import org.simpleframework.transport.Channel; //導入依賴的package包/類
/**
* Constructor for the <code>Transfer</code> object, this is used to create
* an object used to transfer a response body. This must be given a
* <code>Conversation</code> that can be used to set and get information
* regarding the type of transfer required.
*
* @param support
* this is used to determine the semantics
* @param sender
* this is used to send data over the transport
* @param monitor
* this is used to signal I/O events to the kernel
*/
public Transfer(Response response, Conversation support, Channel channel,
Monitor monitor) {
this.factory = new ProducerFactory(support, channel, monitor);
this.trace = channel.getTrace();
this.response = response;
this.support = support;
}