use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class TestNBF method test_nbf.
public void test_nbf() throws ConnectionException, ConfigurationException {
log.info("test_nbf");
server.tpadvertiseTestNBF();
try {
BT_NBF buffer = (BT_NBF) connection.tpalloc("BT_NBF", "employee");
assertTrue(buffer.btaddattribute("name", "zhfeng"));
assertTrue(buffer.btaddattribute("id", new Long(1001)));
Response resp = connection.tpcall(RunServer.getServiceNameNBF(), buffer, 0);
assertTrue(resp != null);
BT_NBF rcvbuf = (BT_NBF) resp.getBuffer();
assertTrue(rcvbuf != null);
log.info(rcvbuf);
Long id = (Long) rcvbuf.btgetattribute("id", 0);
assertTrue(id.longValue() == 1234);
String name = (String) rcvbuf.btgetattribute("name", 0);
assertTrue(name == null);
} catch (ConnectionException e) {
log.warn("call service faild with " + e);
throw e;
}
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class TransportImpl method createSender.
public Sender createSender(Object destination) throws ConnectionException {
if (closed) {
log.error("Already closed");
throw new ConnectionException(Connection.TPEPROTO, "Already closed");
}
Sender sender;
String callback_ior = (String) destination;
log.debug("Creating a sender for: " + callback_ior);
if (callback_ior.contains("IOR:")) {
log.debug(callback_ior + " is for corba");
throw new ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM, "Could not create a Corba sender");
} else {
log.debug(callback_ior + " is for socket");
sender = new SocketSenderImpl(callback_ior);
}
log.debug("Created sender");
return sender;
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class TransportImpl method getSender.
public Sender getSender(String serviceName, boolean conversational) throws ConnectionException {
if (closed) {
log.error("Already closed");
throw new ConnectionException(Connection.TPEPROTO, "Already closed");
}
log.debug("Get sender: " + serviceName);
Map<String, Sender> conversationalMap = senders.get(conversational);
if (conversationalMap == null) {
conversationalMap = new HashMap<String, Sender>();
senders.put(conversational, conversationalMap);
}
Sender toReturn = conversationalMap.get(serviceName);
if (toReturn == null) {
try {
String type = (String) properties.get("blacktie." + serviceName + ".type");
toReturn = new StompSenderImpl(serviceName, conversational, type, conversationalMap, properties);
conversationalMap.put(serviceName, toReturn);
} catch (ConnectionException e) {
throw e;
} catch (Throwable t) {
throw new ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM, "Could not create a service sender: " + t.getMessage(), t);
}
}
return toReturn;
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class StompSenderImpl method close.
/**
* Don't want send and close at the same time
*/
public synchronized void close() throws ConnectionException {
log.debug("Sender closing: " + destinationName);
if (closed) {
throw new ConnectionException(Connection.TPEPROTO, "Sender already closed");
}
closed = true;
try {
log.debug("closing socket: " + socket);
StompManagement.close(socket, outputStream, inputStream);
socket.close();
log.debug("closed socket: " + socket);
conversationalMap.remove(serviceName);
} catch (Throwable t) {
throw new ConnectionException(Connection.TPESYSTEM, "Could not send the message", t);
}
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException in project narayana by jbosstm.
the class BufferImpl method setAttributeValue.
/**
* Set the value.
*
* @param key The key to set
* @param type The type of the value.
* @param value The value to use
* @throws ConnectionException In case the message is not formatted.
*/
protected void setAttributeValue(String key, Class type, Object value) throws ConnectionException {
if (!formatted) {
throw new ConnectionException(ConnectionImpl.TPEPROTO, "Message not formatted");
}
int position = -1;
for (int i = 0; i < keys.length; i++) {
if (keys[i].equals(key)) {
position = i;
}
}
if (position == -1) {
throw new ConnectionException(ConnectionImpl.TPEITYPE, "Key is not part of the structure: " + key);
} else if (types[position] != type) {
throw new ConnectionException(ConnectionImpl.TPEITYPE, "Key is not request type, it is a: " + types[position]);
}
structure.put(key, value);
}
Aggregations