Search in sources :

Example 1 with JobFactoryAdded

use of com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded 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)

Aggregations

JobFactoryAdded (com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded)1 Entity (com.swiftmq.mgmt.Entity)1 EntityList (com.swiftmq.mgmt.EntityList)1 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)1 Property (com.swiftmq.mgmt.Property)1 JobParameter (com.swiftmq.swiftlet.scheduler.JobParameter)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1