當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。