当前位置: 首页>>代码示例>>Java>>正文


Java Channel类代码示例

本文整理汇总了Java中com.sun.squawk.io.mailboxes.Channel的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Channel类属于com.sun.squawk.io.mailboxes包,在下文中一共展示了Channel类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startApp

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
protected void startApp() throws MIDletStateChangeException {
       Isolate.currentIsolate().addLifecycleListener(new Isolate.LifecycleListener() {
               public void handleLifecycleListenerEvent(Isolate iso, int event) {
                   System.out.println("Exiting " + iso);
                   System.out.flush();
               }
           },
                   Isolate.SHUTDOWN_EVENT_MASK);
           
	try {
		ServerChannel serverChannel = ServerChannel.create(CHANNEL_NAME);
		Isolate isolate = new Isolate(ChildServer.class.getName(), new String[] {}, Isolate.currentIsolate().getClassPath(), Isolate.currentIsolate()
				.getParentSuiteSourceURI());
		isolate.start();
           try {
               Channel privateChannel = serverChannel.accept();
           } catch (MailboxClosedException ex) {
               ex.printStackTrace();
           }
		isolate.join();
		System.out.println("Isolate name: " + isolate);
	} catch (MailboxInUseException e) {
		e.printStackTrace();
	}
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:26,代码来源:DeadlocksOnDesktop.java

示例2: run

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public void run() {
	try {
		clientChannel = Channel.lookup(MAILBOX_NAME);
		while (true) {
			ByteArrayEnvelope replyEnv = (ByteArrayEnvelope) clientChannel
					.receive();
			byte[] replyData = replyEnv.getData();
			switch (replyData[0]) {
			case ChannelFrameType.START_SIGNAL:
				break;
			case ChannelFrameType.STOP_SIGNAL:
				break;
			case ChannelFrameType.INT_VALUE_TRANSMIT:
				break;
			default:
				System.out.println("Error: Wrong channel frame type");
			}
		}

	} catch (IOException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:24,代码来源:PlugInComponent.java

示例3: write

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public void write(int value) {
	// 1: type, 4:id, 4: intValue
	int totalSize = 9;
	byte dataBytes[] = new byte[totalSize];
	dataBytes[0] = ChannelFrameType.INT_VALUE_TRANSMIT;
	dataBytes[1] = (byte) (id >> 24);
	dataBytes[2] = (byte) (id >> 16);
	dataBytes[3] = (byte) (id >> 8);
	dataBytes[4] = (byte) (id);
	dataBytes[5] = (byte) (value >> 24);
	dataBytes[6] = (byte) (value >> 16);
	dataBytes[7] = (byte) (value >> 8);
	dataBytes[8] = (byte) (value);
	Envelope dataEnv = new ByteArrayEnvelope(dataBytes);
	try {
		Channel clientChannel = plugin.getClientChannel();
		clientChannel.send(dataEnv);
	} catch (IOException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:22,代码来源:PluginPPort.java

示例4: send

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public void send(String value) {
	// 1: type, 4:id, 4: value size(M), M: bytes
	byte[] valueBytes = value.getBytes();
	int valueBytesSize = valueBytes.length;
	int totalSize = 9 + valueBytesSize;
	byte dataBytes[] = new byte[totalSize];
	dataBytes[0] = ChannelFrameType.STRING_VALUE_SEND;
	dataBytes[1] = (byte) (id >> 24);
	dataBytes[2] = (byte) (id >> 16);
	dataBytes[3] = (byte) (id >> 8);
	dataBytes[4] = (byte) (id);
	dataBytes[5] = (byte) (valueBytesSize >> 24);
	dataBytes[6] = (byte) (valueBytesSize >> 16);
	dataBytes[7] = (byte) (valueBytesSize >> 8);
	dataBytes[8] = (byte) (valueBytesSize);
	for (int i = 0; i < valueBytesSize; i++) {
		dataBytes[i + 9] = valueBytes[i];
	}
	Envelope dataEnv = new ByteArrayEnvelope(dataBytes);
	try {
		Channel clientChannel = plugin.getClientChannel();
		clientChannel.send(dataEnv);
	} catch (IOException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:27,代码来源:PluginPPort.java

示例5: readInt

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public int readInt() {
	// 1: type, 4:id
	int totalSize = 5;
	byte dataBytes[] = new byte[totalSize];
	dataBytes[0] = ChannelFrameType.INT_VALUE_RQ;
	dataBytes[1] = (byte) (id >> 24);
	dataBytes[2] = (byte) (id >> 16);
	dataBytes[3] = (byte) (id >> 8);
	dataBytes[4] = (byte) (id);
	Envelope dataEnv = new ByteArrayEnvelope(dataBytes);
	try {
		Channel clientChannel = plugin.getClientChannel();
		clientChannel.send(dataEnv);
		Envelope msg = clientChannel.receive();
		ByteArrayEnvelope replyDataEnv = (ByteArrayEnvelope) msg;
		byte[] replyDataBytes = replyDataEnv.getData();
		byte frameType = replyDataBytes[0];
		switch (frameType) {
		case ChannelFrameType.INT_VALUE_TRANSMIT:
			byte resultBytes[] = new byte[4];
			for (int r = 0; r < 4; r++) {
				resultBytes[r] = replyDataBytes[r + 1];
			}
			int result = new Integer(byteArrayToInt(resultBytes));
			return result;
		default:
			VM.println("Error: channel type");
		}
	} catch (IOException ex) {
		ex.printStackTrace();
	}
	return 0;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:34,代码来源:PluginRPort.java

示例6: readLong

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public long readLong() {
	long result = 0;
	// 1: type, 4:id
	int totalSize = 5;
	byte dataBytes[] = new byte[totalSize];
	dataBytes[0] = ChannelFrameType.LONG_VALUE_RQ;
	dataBytes[1] = (byte) (id >> 24);
	dataBytes[2] = (byte) (id >> 16);
	dataBytes[3] = (byte) (id >> 8);
	dataBytes[4] = (byte) (id);
	Envelope dataEnv = new ByteArrayEnvelope(dataBytes);
	try {
		Channel clientChannel = plugin.getClientChannel();
		clientChannel.send(dataEnv);
		Envelope msg = clientChannel.receive();
		ByteArrayEnvelope replyDataEnv = (ByteArrayEnvelope) msg;
		byte[] replyDataBytes = replyDataEnv.getData();
		byte frameType = replyDataBytes[0];
		switch (frameType) {
		case ChannelFrameType.LONG_VALUE_TRANSMIT:
			byte resultBytes[] = new byte[8];
			for (int r = 0; r < 8; r++) {
				resultBytes[r] = replyDataBytes[r + 1];
			}
			result = new Long(byteArrayToLong(resultBytes));
			return result;
		default:
			VM.println("Error: channel type");
		}
	} catch (IOException ex) {
		ex.printStackTrace();
	}
	return result;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:35,代码来源:PluginRPort.java

示例7: readString

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public String readString() {
	// 1: type, 4:id
	int totalSize = 5;
	byte dataBytes[] = new byte[totalSize];
	dataBytes[0] = ChannelFrameType.STRING_VALUE_RQ;
	dataBytes[1] = (byte) (id >> 24);
	dataBytes[2] = (byte) (id >> 16);
	dataBytes[3] = (byte) (id >> 8);
	dataBytes[4] = (byte) (id);
	Envelope dataEnv = new ByteArrayEnvelope(dataBytes);
	try {
		Channel clientChannel = plugin.getClientChannel();
		clientChannel.send(dataEnv);
		Envelope msg = clientChannel.receive();
		ByteArrayEnvelope replyDataEnv = (ByteArrayEnvelope) msg;
		byte[] replyDataBytes = replyDataEnv.getData();
		byte frameType = replyDataBytes[0];
		switch (frameType) {
		case ChannelFrameType.STRING_VALUE_TRANSMIT:
			int length = replyDataBytes.length;
			byte[] resultBytes = new byte[length - 1];
			for (int r = 0; r < length - 1; r++) {
				resultBytes[r] = replyDataBytes[r + 1];
			}
			String result = new String(resultBytes);
			return result;
		default:
			VM.println("Error: channel type");
		}
	} catch (IOException ex) {
		ex.printStackTrace();
	}
	return null;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:35,代码来源:PluginRPort.java

示例8: ServerChannelHandler

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public ServerChannelHandler(Channel channel) {
	this.channel = channel;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:4,代码来源:PIRTE.java

示例9: getClientChannel

import com.sun.squawk.io.mailboxes.Channel; //导入依赖的package包/类
public Channel getClientChannel() {
	return clientChannel;
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:4,代码来源:PlugInComponent.java


注:本文中的com.sun.squawk.io.mailboxes.Channel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。