本文整理汇总了Java中java.nio.channels.Pipe.SourceChannel类的典型用法代码示例。如果您正苦于以下问题:Java SourceChannel类的具体用法?Java SourceChannel怎么用?Java SourceChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceChannel类属于java.nio.channels.Pipe包,在下文中一共展示了SourceChannel类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
private void run() throws Exception
{
NioThread nt=new NioThread();
final Socket s=new Socket("localhost", 9999);
SourceChannel in=ConnectNio.inputStreamToPipe(s.getInputStream());
in.configureBlocking(false);
SinkChannel out=ConnectNio.outputStreamToPipe(s.getOutputStream(), s);
out.configureBlocking(false);
DualChannelProcessorMultiplexer multiplexer=new DualChannelProcessorMultiplexer(nt, in, out, false,
CoolRMINioRemoter.clientId, CoolRMINioRemoter.serverId);
CoolRMINioClient cli=new CoolRMINioClient(getClass().getClassLoader(), false);
cli.connect(multiplexer);
multiplexer.start();
nt.start();
Iremote r= (Iremote)cli.getService(Iremote.class, Iremote.class.getName());
System.out.println(""+r.getValue("Kitten"));
System.out.println(""+r.getValue("Kitten"));
System.out.println(""+r.getValue("Kitten"));
System.out.println(""+r.getValue("Kitten"));
cli.close();
nt.close();
}
开发者ID:rizsi,项目名称:rcom,代码行数:23,代码来源:CoolRMIHalfNioClientLauncher.java
示例2: onSelectableReadable
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
@Override
public void onSelectableReadable(Event event) {
Selectable selectable = event.getSelectable();
// The onSelectableReadable event tells us that there is data
// to be read, or the end of stream has been reached.
SourceChannel channel = (SourceChannel)selectable.getChannel();
ByteBuffer buffer = ByteBuffer.allocate(1024);
try {
while(true) {
int amount = channel.read(buffer);
if (amount < 0) {
selectable.terminate();
selectable.getReactor().update(selectable);
}
if (amount <= 0) break;
System.out.write(buffer.array(), 0, buffer.position());
buffer.clear();
}
} catch(IOException ioException) {
ioException.printStackTrace();
selectable.terminate();
selectable.getReactor().update(selectable);
}
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:26,代码来源:Echo.java
示例3: wrap
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
public static SourceChannel wrap(InputStream in) throws IOException {
Pipe pipe = Pipe.open();
new EchoInputStreamWrapper(in, pipe.sink()).start();
SourceChannel result = pipe.source();
result.configureBlocking(false);
return result;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:8,代码来源:EchoInputStreamWrapper.java
示例4: main
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println("Specify a file name as an argument.");
System.exit(1);
}
FileInputStream inFile = new FileInputStream(args[0]);
SourceChannel inChannel = EchoInputStreamWrapper.wrap(inFile);
Reactor reactor = Proton.reactor(new Cat(inChannel));
reactor.run();
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:11,代码来源:Cat.java
示例5: isOpen
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
private boolean isOpen(Object resource) {
if (resource instanceof SourceChannel) {
return ((SourceChannel)resource).isOpen();
} else if (resource instanceof SinkChannel) {
return ((SinkChannel)resource).isOpen();
} else if (resource instanceof Selector) {
return ((Selector)resource).isOpen();
} else if (resource instanceof ServerSocketChannel) {
return ((ServerSocketChannel)resource).isOpen();
} else if (resource instanceof SocketChannel) {
return ((SocketChannel)resource).isOpen();
} else {
throw new AssertionFailedError("Don't know how to check if this type is open: " + resource.getClass());
}
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:16,代码来源:LeakTestReactor.java
示例6: test_source
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
/**
* @tests java.nio.channels.Pipe#source()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "source",
args = {}
)
public void test_source() throws IOException {
Pipe pipe = Pipe.open();
SourceChannel source = pipe.source();
assertTrue(source.isBlocking());
}
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:PipeTest.java
示例7: testConstructor
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "SourceChannel",
args = {java.nio.channels.spi.SelectorProvider.class}
)
public void testConstructor() throws IOException {
SourceChannel channel =
SelectorProvider.provider().openPipe().source();
assertNotNull(channel);
assertSame(SelectorProvider.provider(),channel.provider());
channel = Pipe.open().source();
assertNotNull(channel);
assertSame(SelectorProvider.provider(),channel.provider());
}
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:SourceChannelTest.java
示例8: HandshakeHandler
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
HandshakeHandler(boolean clientMode, SourceChannel in, SinkChannel out)
throws SSLException {
this.in = in;
this.out = out;
engine = getEngine();
engine.setUseClientMode(clientMode);
String[] cipherSuites = engine.getSupportedCipherSuites();
Set<String> enabledSuites = new HashSet<String>();
for (String cipherSuite : cipherSuites) {
if (cipherSuite.contains("anon")) {
enabledSuites.add(cipherSuite);
}
}
engine.setEnabledCipherSuites((String[]) enabledSuites.toArray(
new String[enabledSuites.size()]));
engine.beginHandshake();
status = engine.getHandshakeStatus();
if (clientMode) {
LOGTAG = "CLIENT: ";
} else {
LOGTAG = "SERVER: ";
}
log("CipherSuites: " + Arrays.toString(engine.getEnabledCipherSuites()));
log(status);
readBuffer = ByteBuffer.allocate(200000);
writeBuffer = ByteBuffer.allocate(20000);
}
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:SSLEngineTest.java
示例9: prepareEngines
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
void prepareEngines() throws IOException {
Pipe clientSendPipe = Pipe.open();
Pipe serverSendPipe = Pipe.open();
SinkChannel clientSink = clientSendPipe.sink();
SourceChannel serverSource = clientSendPipe.source();
SinkChannel serverSink = serverSendPipe.sink();
SourceChannel clientSource = serverSendPipe.source();
clientEngine = new HandshakeHandler(true, clientSource, clientSink);
serverEngine = new HandshakeHandler(false, serverSource, serverSink);
}
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:13,代码来源:SSLEngineTest.java
示例10: PipeSelectableChannel
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
PipeSelectableChannel(final SinkChannel out, final SourceChannel in) {
if (out == null) {
throw new NullPointerException("out == null");
}
if (in == null) {
throw new NullPointerException("in == null");
}
if ((in.validOps() & out.validOps()) != 0) {
throw new IllegalArgumentException("sink and source have overlapping validOps");
}
this.out = out;
this.in = in;
}
开发者ID:ricardopadilha,项目名称:dsys-snio,代码行数:14,代码来源:PipeSelectableChannel.java
示例11: Echo
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
private Echo(SourceChannel channel) {
this.channel = channel;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:4,代码来源:Echo.java
示例12: main
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
SourceChannel inChannel = EchoInputStreamWrapper.wrap(System.in);
Reactor reactor = Proton.reactor(new Echo(inChannel));
reactor.run();
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:Echo.java
示例13: Cat
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
private Cat(SourceChannel channel) {
this.channel = channel;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:4,代码来源:Cat.java
示例14: test_source
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
/**
* @tests java.nio.channels.Pipe#source()
*/
public void test_source() throws IOException {
Pipe pipe = Pipe.open();
SourceChannel source = pipe.source();
assertTrue(source.isBlocking());
}
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:PipeTest.java
示例15: FASTInputSourceChannel
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
public FASTInputSourceChannel(SourceChannel channel) {
this.sourceChannel = channel;
assert(!channel.isBlocking()) : "Only non blocking SocketChannel is supported.";
}
开发者ID:nathantippy,项目名称:jFAST,代码行数:5,代码来源:FASTInputSourceChannel.java
示例16: DualChannelProcessorMultiplexer
import java.nio.channels.Pipe.SourceChannel; //导入依赖的package包/类
/**
*
* @param t
* @param c
* @param client
* @param thisId Identifier of this multiplexer endpoint. This is sent to the client on connection.
* @param remoteId Required identifier of the other endpoint. This is checked to be equal to the value received from the client.
*/
public DualChannelProcessorMultiplexer(NioThread t, SourceChannel source, SinkChannel sink, boolean client, byte[] thisId, byte[] remoteId) {
super(thisId, remoteId);
cpSink=new CPSink(t, sink, client);
cpSource=new CPSource(t, source, client);
}
开发者ID:rizsi,项目名称:rcom,代码行数:14,代码来源:DualChannelProcessorMultiplexer.java
注:本文中的java.nio.channels.Pipe.SourceChannel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论