use of org.jboss.narayana.blacktie.jatmibroker.core.server.ServiceData in project narayana by jbosstm.
the class BlackTieServer method tpadvertise.
/**
* Advertise a blacktie service with the specified name
*
* @param serviceName The name of the service
* @throws ConnectionException If the service cannot be advertised
*/
public void tpadvertise(String serviceName, String serviceClassName) throws ConnectionException {
int min = Math.min(Connection.XATMI_SERVICE_NAME_LENGTH, serviceName.length());
serviceName = serviceName.substring(0, min);
log.debug("Advertising: " + serviceName);
ServiceData serviceData = this.serviceData.get(serviceName);
if (serviceData == null) {
try {
ServiceData data = new ServiceData(transportFactory, properties, serviceName, serviceClassName);
this.serviceData.put(serviceName, data);
log.info("Advertised: " + serviceName);
} catch (ConnectionException e) {
throw e;
} catch (Throwable t) {
throw new ConnectionException(Connection.TPESYSTEM, "Could not create service factory for: " + serviceName, t);
}
} else if (!serviceData.getServiceClassName().equals(serviceClassName)) {
throw new ConnectionException(Connection.TPEMATCH, "Service already registered");
} else {
log.trace("This is a duplicate advertise");
}
}
use of org.jboss.narayana.blacktie.jatmibroker.core.server.ServiceData in project narayana by jbosstm.
the class BlackTieServer method tpunadvertise.
/**
* Unadvertise the service by name.
*
* @param serviceName The name of the service to unadverise.
* @throws ConnectionException If the service cannot be unadvertised.
*/
public void tpunadvertise(String serviceName) throws ConnectionException {
serviceName = serviceName.substring(0, Math.min(Connection.XATMI_SERVICE_NAME_LENGTH, serviceName.length()));
ServiceData data = serviceData.remove(serviceName);
if (data == null) {
throw new ConnectionException(Connection.TPENOENT, "Service did not exist: " + serviceName);
}
data.close();
}
Aggregations