use of com.swiftmq.mgmt.Entity 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.Entity in project swiftmq-ce by iitsoftware.
the class Scheduler method visit.
public void visit(ScheduleAdded po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " ...");
Schedule schedule = po.getSchedule();
Entity entity = null;
if (po.isMessageSchedule()) {
entity = ctx.activeMessageScheduleList.createEntity();
entity.setName(schedule.getName());
entity.createCommands();
entity.setDynamic(true);
try {
entity.getProperty("state").setValue(STATE_NONE);
entity.getProperty("schedule-date-from").setValue(schedule.getDateFrom() == null ? ScheduleFactory.NOW : schedule.getDateFrom());
entity.getProperty("schedule-date-to").setValue(schedule.getDateTo() == null ? ScheduleFactory.FOREVER : schedule.getDateTo());
entity.getProperty("schedule-calendar").setValue(schedule.getCalendar());
entity.getProperty("schedule-logging-enabled").setValue(new Boolean(schedule.isLoggingEnabled()));
entity.getProperty("schedule-time-expression").setValue(schedule.getTimeExpression());
ctx.activeMessageScheduleList.addEntity(entity);
} catch (Exception e) {
}
} else {
entity = ctx.activeScheduleList.createEntity();
entity.setName(schedule.getName());
entity.createCommands();
entity.setDynamic(true);
try {
entity.getProperty("job-group").setValue(schedule.getJobGroup());
entity.getProperty("job-name").setValue(schedule.getJobName());
entity.getProperty("state").setValue(STATE_NONE);
ctx.activeScheduleList.addEntity(entity);
} catch (Exception e) {
}
}
Entry scheduleEntry = new Entry(schedule, entity);
scheduleEntry.messageSchedule = po.isMessageSchedule();
addHistory(scheduleEntry, STATE_NONE, null);
schedules.put(schedule.getName(), scheduleEntry);
calcSchedule(scheduleEntry);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " done");
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class AMQPHandler method visit.
public void visit(POSendOpen po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
Entity connectionTemplate = versionedConnection.getConnectionTemplate();
myIdleTimeout = ((Long) connectionTemplate.getProperty("idle-timeout").getValue()).longValue();
OpenFrame frame = new OpenFrame(0);
frame.setContainerId(new AMQPString(SwiftletManager.getInstance().getRouterName()));
frame.setChannelMax(new AMQPUnsignedShort(((Integer) connectionTemplate.getProperty("max-channel-number").getValue()).intValue()));
frame.setMaxFrameSize(new AMQPUnsignedInt(((Long) connectionTemplate.getProperty("max-frame-size").getValue()).longValue()));
try {
AMQPArray offeredCapas = new AMQPArray(AMQPTypeDecoder.SYM8, new AMQPSymbol[] { new AMQPSymbol(CAPABILITY_NO_LOCAL), new AMQPSymbol(CAPABILITY_SELECTOR) });
frame.setOfferedCapabilities(offeredCapas);
} catch (IOException e) {
e.printStackTrace();
}
if (myIdleTimeout > 0) {
frame.setIdleTimeOut(new Milliseconds(myIdleTimeout));
idleTimeoutChecker = new TimerListener() {
public void performTimeAction() {
dispatch(new POCheckIdleTimeout(null));
}
};
ctx.timerSwiftlet.addTimerListener(myIdleTimeout / 2, idleTimeoutChecker);
}
versionedConnection.send(AMQPHandlerFactory.AMQP_INIT);
versionedConnection.send(frame);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
use of com.swiftmq.mgmt.Entity in project swiftmq-ce by iitsoftware.
the class TransformerFactory method toMap.
private Map toMap(EntityList list) {
Map result = new HashMap();
Map entities = list.getEntities();
if (entities != null && entities.size() > 0) {
for (Iterator iter = entities.entrySet().iterator(); iter.hasNext(); ) {
Entity e = (Entity) ((Map.Entry) iter.next()).getValue();
result.put(e.getName(), e.getProperty("value").getValue());
}
}
return result;
}
use of com.swiftmq.mgmt.Entity 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;
}
Aggregations