Search in sources :

Example 1 with EntityAddException

use of com.swiftmq.mgmt.EntityAddException in project swiftmq-ce by iitsoftware.

the class MQTTSession method createRegistryUsage.

private void createRegistryUsage(Subscription subscription) {
    try {
        Entity subUsage = ((EntityList) registryUsage.getEntity("subscriptions")).createEntity();
        subUsage.setName(subscription.getTopicName());
        subscription.fillRegistryUsage(subUsage);
        subUsage.createCommands();
        registryUsage.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 2 with EntityAddException

use of com.swiftmq.mgmt.EntityAddException 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 3 with EntityAddException

use of com.swiftmq.mgmt.EntityAddException 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 4 with EntityAddException

use of com.swiftmq.mgmt.EntityAddException 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)

Example 5 with EntityAddException

use of com.swiftmq.mgmt.EntityAddException in project swiftmq-ce by iitsoftware.

the class TransformerFactory method createDefaultTransformer.

private void createDefaultTransformer(String key, EntityList list) {
    Map entities = list.getEntities();
    if (entities == null || entities.size() == 0) {
        Entity newEntity = list.createEntity();
        newEntity.setName(key);
        newEntity.createCommands();
        try {
            list.addEntity(newEntity);
        } catch (EntityAddException e) {
            e.printStackTrace();
        }
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityAddException(com.swiftmq.mgmt.EntityAddException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Entity (com.swiftmq.mgmt.Entity)5 EntityAddException (com.swiftmq.mgmt.EntityAddException)5 EntityList (com.swiftmq.mgmt.EntityList)4 Map (java.util.Map)2 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)1 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 XAException (javax.transaction.xa.XAException)1