use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class BackupProcessor method scanSaveSet.
private void scanSaveSet(File dir) {
File completed = new File(dir, COMPLETED_FILE);
if (completed.exists()) {
// Create Usage Entry
Entity entity = ctx.backupList.createEntity();
entity.setName(dir.getName());
entity.createCommands();
try {
ctx.backupList.addEntity(entity);
} catch (EntityAddException e) {
}
EntityList fileList = (EntityList) entity.getEntity("files");
File[] files = dir.listFiles(new FilenameFilter() {
public boolean accept(File d, String name) {
return !name.equals(COMPLETED_FILE);
}
});
if (files != null) {
for (int i = 0; i < files.length; i++) {
Entity fileEntity = fileList.createEntity();
fileEntity.setName(files[i].getName());
fileEntity.createCommands();
try {
fileEntity.getProperty("filesize").setValue(Long.valueOf(files[i].length()));
fileList.addEntity(fileEntity);
} catch (Exception e) {
}
}
}
} else {
// Delete Folder
deleteSaveSet(dir);
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class JobGroupImpl method addJobFactory.
public synchronized void addJobFactory(String jobName, JobFactory jobFactory) {
if (!hasJobFactory(jobName)) {
Entity entity = jobList.createEntity();
entity.setName(jobFactory.getName());
entity.createCommands();
entity.setDynamic(true);
entity.setDynamicObject(jobFactory);
try {
Property prop = entity.getProperty("description");
prop.setReadOnly(false);
prop.setValue(jobFactory.getDescription());
prop.setReadOnly(true);
Map parmMap = jobFactory.getJobParameters();
if (parmMap != null) {
EntityList parmList = (EntityList) entity.getEntity("parameters");
for (Iterator iter = parmMap.entrySet().iterator(); iter.hasNext(); ) {
JobParameter parm = (JobParameter) ((Map.Entry) iter.next()).getValue();
Entity pe = parmList.createEntity();
pe.setName(parm.getName());
pe.setDynamic(true);
pe.createCommands();
pe.setDynamicObject(parm);
prop = pe.getProperty("description");
prop.setReadOnly(false);
prop.setValue(parm.getDescription());
prop.setReadOnly(true);
prop = pe.getProperty("default");
prop.setReadOnly(false);
prop.setValue(parm.getDefaultValue());
prop.setReadOnly(true);
prop = pe.getProperty("mandatory");
prop.setReadOnly(false);
prop.setValue(new Boolean(parm.isMandatory()));
prop.setReadOnly(true);
parmList.addEntity(pe);
}
}
jobList.addEntity(entity);
ctx.scheduler.enqueue(new JobFactoryAdded(name, jobName, jobFactory));
} catch (Exception e) {
}
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class ManagementInput method start.
@Override
public void start() throws Exception {
if (started)
return;
try {
EntityList inputList = (EntityList) ctx.usage.getEntity("inputs");
usage = inputList.createEntity();
usage.setName(name.replace('/', '_'));
usage.createCommands();
inputList.addEntity(usage);
usage.getProperty("atype").setValue("Management");
} catch (Exception e) {
e.printStackTrace();
}
managementProcessor = new ManagementProcessor(ctx, this);
managementProcessor.register();
started = true;
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class MQTTSession method createConnectionUsage.
private void createConnectionUsage(Subscription subscription) {
try {
Entity subUsage = ((EntityList) connectionUsage.getEntity("subscriptions")).createEntity();
subUsage.setName(subscription.getTopicName());
subscription.fillConnectionUsage(subUsage);
subUsage.createCommands();
connectionUsage.getEntity("subscriptions").addEntity(subUsage);
} catch (EntityAddException e) {
}
}
use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.
the class XARecoveryContextImpl method _addTransaction.
synchronized void _addTransaction(AbstractQueue queue, Object transactionId) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/_addTransaction, queue=" + queue + ", transactionId: " + transactionId);
try {
if (transactions.size() == 0) {
Entity entity = ctx.preparedUsageList.createEntity();
entity.setName(Integer.toString(incCount()));
entity.setDynamicObject(xid);
entity.createCommands();
ctx.preparedUsageList.addEntity(entity);
try {
entity.getProperty("xid").setValue(signature);
} catch (Exception e) {
}
EntityList queues = (EntityList) entity.getEntity("queues");
Entity queueEntity = queues.createEntity();
queueEntity.setName(queue.getQueueName());
queueEntity.createCommands();
queues.addEntity(queueEntity);
} else {
Map entities = ctx.preparedUsageList.getEntities();
for (Iterator iter = entities.entrySet().iterator(); iter.hasNext(); ) {
Entity xidEntity = (Entity) ((Map.Entry) iter.next()).getValue();
EntityList queueList = (EntityList) xidEntity.getEntity("queues");
if ((xidEntity.getProperty("xid").getValue()).equals(signature) && queueList.getEntity(queue.getQueueName()) == null) {
Entity queueEntity = queueList.createEntity();
queueEntity.setName(queue.getQueueName());
queueEntity.createCommands();
queueList.addEntity(queueEntity);
break;
}
}
}
} catch (EntityAddException e) {
}
transactions.add(new Object[] { queue, transactionId });
}
Aggregations