use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class TopicBroker method addRemoteSubscriptionUsage.
private void addRemoteSubscriptionUsage(String routerName, String topicName) {
if (ctx.remoteSubscriberList == null)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "addRemoteSubscriptionUsage, routerName=" + routerName + ", topicName=" + topicName);
try {
Entity rEntity = ctx.remoteSubscriberList.getEntity(routerName);
if (rEntity == null) {
rEntity = ctx.remoteSubscriberList.createEntity();
rEntity.setName(routerName);
rEntity.createCommands();
ctx.remoteSubscriberList.addEntity(rEntity);
}
EntityList tEntityList = (EntityList) rEntity.getEntity("topics");
if (tEntityList.getEntity(topicName) == null) {
Entity entity = tEntityList.createEntity();
entity.setName(topicName);
entity.createCommands();
tEntityList.addEntity(entity);
}
} catch (Exception e) {
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class TopicBroker method removeRemoteSubscriptionUsage.
private void removeRemoteSubscriptionUsage(String routerName, String topicName) {
if (ctx.remoteSubscriberList == null)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "removeRemoteSubscriptionUsage, routerName=" + routerName + ", topicName=" + topicName);
try {
Entity rEntity = ctx.remoteSubscriberList.getEntity(routerName);
if (rEntity != null) {
EntityList tEntityList = (EntityList) rEntity.getEntity("topics");
Entity entity = tEntityList.getEntity(topicName);
if (entity != null)
tEntityList.removeEntity(entity);
Map map = tEntityList.getEntities();
if (map == null || map.size() == 0)
ctx.remoteSubscriberList.removeEntity(rEntity);
}
} catch (Exception e) {
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class Scheduler method addHistory.
private void addHistory(Entry entry, String state, String exception) {
try {
EntityList histList = (EntityList) entry.entity.getEntity("history");
if (entry.histNo == 999) {
entry.histNo = 0;
Map map = histList.getEntities();
if (map != null) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
histList.removeEntity((Entity) ((Map.Entry) iter.next()).getValue());
}
}
}
String[] names = histList.getEntityNames();
if (names != null && names.length == 20) {
String min = null;
for (int i = 0; i < names.length; i++) {
if (min == null || min.compareTo(names[i]) > 0)
min = names[i];
}
histList.removeEntity(histList.getEntity(min));
}
Entity entity = histList.createEntity();
entity.setName(dfmt.format(++entry.histNo));
entity.createCommands();
entity.getProperty("logtime").setValue(fmt.format(new Date()));
entity.getProperty("state").setValue(state);
if (exception != null)
entity.getProperty("xception").setValue(exception);
histList.addEntity(entity);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class TransformerFactory method createInboundTransformer.
public InboundTransformer createInboundTransformer(long messageFormat, String destination) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + " ...");
Entity result = null;
Entity dest = destinationTransformerList.getEntity(destination);
if (dest != null) {
EntityList inboundList = (EntityList) dest.getEntity("inbound-transformers");
if (inboundList != null)
result = inboundList.getEntity(String.valueOf(messageFormat));
}
if (result == null) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + ", no destination transformer found, using default");
result = defaultInboundTransformerList.getEntity(String.valueOf(messageFormat));
}
InboundTransformer inboundTransformer = null;
if (result != null) {
inboundTransformer = (InboundTransformer) Class.forName((String) result.getProperty("class-name").getValue()).newInstance();
inboundTransformer.setConfiguration(toMap((EntityList) result.getEntity("properties")));
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + " returns " + inboundTransformer);
return inboundTransformer;
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class RouteTable method addUsageEntity.
private void addUsageEntity(Route route) {
try {
Entity destEntity = dynRoutes.getEntity(route.getDestinationRouter());
if (destEntity == null) {
destEntity = dynRoutes.createEntity();
destEntity.setName(route.getDestinationRouter());
destEntity.createCommands();
dynRoutes.addEntity(destEntity);
}
EntityList routes = (EntityList) destEntity.getEntity("dynamic-routes");
Entity dr = routes.createEntity();
dr.setName(route.getKey());
dr.createCommands();
routes.addEntity(dr);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations