Search in sources :

Example 11 with EntityList

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);
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) FilenameFilter(java.io.FilenameFilter) EntityAddException(com.swiftmq.mgmt.EntityAddException) EntityList(com.swiftmq.mgmt.EntityList) File(java.io.File) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) EntityAddException(com.swiftmq.mgmt.EntityAddException)

Example 12 with EntityList

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) {
        }
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) JobFactoryAdded(com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded) Property(com.swiftmq.mgmt.Property) Map(java.util.Map) JobParameter(com.swiftmq.swiftlet.scheduler.JobParameter) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 13 with EntityList

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;
}
Also used : ManagementProcessor(com.swiftmq.impl.streams.processor.ManagementProcessor) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 14 with EntityList

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) {
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityAddException(com.swiftmq.mgmt.EntityAddException) EntityList(com.swiftmq.mgmt.EntityList)

Example 15 with EntityList

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 });
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityAddException(com.swiftmq.mgmt.EntityAddException) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) XAException(javax.transaction.xa.XAException) EntityAddException(com.swiftmq.mgmt.EntityAddException)

Aggregations

EntityList (com.swiftmq.mgmt.EntityList)17 Entity (com.swiftmq.mgmt.Entity)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)8 Iterator (java.util.Iterator)5 Map (java.util.Map)5 EntityAddException (com.swiftmq.mgmt.EntityAddException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JMSException (javax.jms.JMSException)2 JobFactoryAdded (com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded)1 ManagementProcessor (com.swiftmq.impl.streams.processor.ManagementProcessor)1 Property (com.swiftmq.mgmt.Property)1 JobParameter (com.swiftmq.swiftlet.scheduler.JobParameter)1 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 Properties (java.util.Properties)1 XAException (javax.transaction.xa.XAException)1