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


Java RPCElement类代码示例

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


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

示例1: main

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	Server server = Server.createServerStoringMessages(2222);
	server.startServer();

	// read lines form input
	BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));

	while (true) {
		if (buffer.readLine().equalsIgnoreCase("EXIT")) {
			break;
		}

		log.info("Messages received(" + server.getStoredMessages().size() + "):");
		for (RPCElement rpcElement : server.getStoredMessages()) {
			log.info("#####  BEGIN message #####\n" +
					rpcElement.toXML() + '\n' +
					"#####   END message  #####");
		}
	}

	log.info("Exiting");
	System.exit(0);
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:24,代码来源:Server.java

示例2: createServerStoringMessages

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
/**
 * Creates a server listening in loopback interface and store all received messages
 * 
 * @param listeningPort
 *            where the server will listen for SSH connections
 * 
 */
public static Server createServerStoringMessages(int listeningPort) {
	Server server = new Server();
	server.messages = new ArrayList<RPCElement>();
	server.storeMessages = true;

	server.initializeServer("localhost", listeningPort);

	return server;
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:17,代码来源:Server.java

示例3: storeMessage

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Override
public void storeMessage(RPCElement message) {
	if (messages != null) {
		synchronized (messages) {
			log.info("Storing message");
			messages.add(message);
		}
	}
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:10,代码来源:Server.java

示例4: getStoredMessages

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Override
public List<RPCElement> getStoredMessages() {
	if (storeMessages) {
		synchronized (messages) {
			return Collections.unmodifiableList(messages);
		}
	} else {
		throw new ServerException(new UnsupportedOperationException("Server is configured to not store messages!"));
	}
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:11,代码来源:Server.java

示例5: asyncSend

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Override
public void asyncSend(Object requestMessage) throws ProtocolException {
	// Send a message to the device, and don't wait for the response
	RPCElement rpcReply = null;
	try {
		Query rpcQuery = (Query) requestMessage;
		netconfSession.sendAsyncQuery(rpcQuery);
	} catch (Exception ex) {
		throw new ProtocolException(ex);
	}

}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:13,代码来源:NetconfProtocolSession.java

示例6: sendReceive

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Override
public Object sendReceive(Object requestMessage) throws ProtocolException {
	// Send a message to the device, and wait for the response
	RPCElement rpcReply = null;
	try {
		Query rpcQuery = (Query) requestMessage;
		rpcReply = netconfSession.sendSyncQuery(rpcQuery);
	} catch (Exception ex) {
		throw new ProtocolException(ex);
	}
	return rpcReply;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:13,代码来源:NetconfProtocolSession.java

示例7: receiveRPCElement

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Override
public void receiveRPCElement(RPCElement element) {
	log.info("Message received");
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:5,代码来源:NetconfProcessor.java

示例8: storeMessage

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
/**
 * Store a Netconf message
 * 
 * @param message
 *            any Netconf message to store
 */
public void storeMessage(RPCElement message);
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:8,代码来源:MessageStore.java

示例9: getStoredMessages

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
/**
 * Get the full list of stored messages
 * 
 * @return a {@link List} of stored messages
 */
public List<RPCElement> getStoredMessages();
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:7,代码来源:MessageStore.java

示例10: testMessageStoring

import net.i2cat.netconf.rpc.RPCElement; //导入依赖的package包/类
@Test
public void testMessageStoring() {
	Server server = Server.createServerStoringMessages(2222);
	server.startServer();

	try {
		SessionContext sessionContext = new SessionContext();
		sessionContext.setURI(new URI("ssh://user:[email protected]:2222/"));

		INetconfSession session = new NetconfSession(sessionContext);

		session.connect();

		// send 3 messages
		Query query = QueryFactory.newGetConfig("running", null, null);
		session.sendSyncQuery(query);

		query = QueryFactory.newDeleteConfig("running");
		session.sendSyncQuery(query);

		query = QueryFactory.newCopyConfig("running", null);
		session.sendSyncQuery(query);

		// check stored messages
		List<RPCElement> messages = server.getStoredMessages();

		Assert.assertEquals("Message list must contain 4 messages", (3 + 1), messages.size());
		Assert.assertTrue("First message must be a Hello", messages.get(0) instanceof Hello);
		Assert.assertTrue("Second message must be a Query with GET-CONFIG operation",
				messages.get(1) instanceof Query && ((Query) messages.get(1)).getOperation().equals(Operation.GET_CONFIG));
		Assert.assertTrue("Third message must be a Query with DELETE-CONFIG operation",
				messages.get(2) instanceof Query && ((Query) messages.get(2)).getOperation().equals(Operation.DELETE_CONFIG));
		Assert.assertTrue("Fourth message must be a Query with COPY-CONFIG operation",
				messages.get(3) instanceof Query && ((Query) messages.get(3)).getOperation().equals(Operation.COPY_CONFIG));
	} catch (Exception e) {
		Assert.fail("Error creating session: " + e.getMessage());
	} finally {
		server.stopServer();
	}
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:41,代码来源:TestServer.java


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