| 1 | package de.uka.ipd.sdq.workflow.pcm.jobs; |
| 2 | |
| 3 | import org.apache.log4j.Logger; |
| 4 | import org.eclipse.core.runtime.IProgressMonitor; |
| 5 | |
| 6 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
| 7 | import de.uka.ipd.sdq.workflow.IJob; |
| 8 | import de.uka.ipd.sdq.workflow.OrderPreservingBlackboardCompositeJob; |
| 9 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
| 10 | import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException; |
| 11 | import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException; |
| 12 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
| 13 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.ResourceSetPartition; |
| 14 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration; |
| 15 | |
| 16 | /**Loads the PCM models given in the configuration into a MDSD blackboard and store the models in a temporary eclipse project. |
| 17 | * The temporary storage allows to transform and modify input PCM models without a modification of the source models and |
| 18 | * can be accessed after the analysis to check the model used in the analysis. |
| 19 | * @author groenda |
| 20 | * |
| 21 | */ |
| 22 | public class LoadPCMModelsJob extends OrderPreservingBlackboardCompositeJob<MDSDBlackboard> |
| 23 | implements IJob, IBlackboardInteractingJob<MDSDBlackboard> { |
| 24 | private static final Logger logger = Logger.getLogger(LoadPCMModelsJob.class); |
| 25 | private MDSDBlackboard blackboard; |
| 26 | private AbstractPCMWorkflowRunConfiguration configuration = null; |
| 27 | |
| 28 | public LoadPCMModelsJob(AbstractPCMWorkflowRunConfiguration configuration) { |
| 29 | super(); |
| 30 | this.configuration = configuration; |
| 31 | } |
| 32 | |
| 33 | /* (non-Javadoc) |
| 34 | * @see de.uka.ipd.sdq.workflow.IBlackboardInteractingJob#setBlackboard(de.uka.ipd.sdq.workflow.Blackboard) |
| 35 | */ |
| 36 | public void setBlackboard(MDSDBlackboard blackboard) { |
| 37 | this.blackboard = blackboard; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void execute(IProgressMonitor monitor) throws JobFailedException, |
| 42 | UserCanceledException { |
| 43 | ResourceSetPartition pcmPartition = this.blackboard.getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID); |
| 44 | ResourceSetPartition middlewarePartition = this.blackboard.getPartition(LoadPCMModelsIntoBlackboardJob.MIDDLEWARE_PARTITION_ID); |
| 45 | ResourceSetPartition eventMiddlewarePartition = this.blackboard.getPartition(LoadPCMModelsIntoBlackboardJob.EVENT_MIDDLEWARE_PARTITION_ID); |
| 46 | |
| 47 | // Load the PCM model itself |
| 48 | logger.info("Loading PCM models"); |
| 49 | for (String modelFile : configuration.getPCMModelFiles()) { |
| 50 | pcmPartition.loadModel(modelFile); |
| 51 | } |
| 52 | pcmPartition.resolveAllProxies(); |
| 53 | |
| 54 | // load the middleware completion |
| 55 | logger.info("Loading middleware completion models"); |
| 56 | middlewarePartition.loadModel(configuration.getMiddlewareFile()); |
| 57 | middlewarePartition.resolveAllProxies(); |
| 58 | |
| 59 | // load the event middleware repository |
| 60 | logger.info("Loading event middleware models"); |
| 61 | eventMiddlewarePartition.loadModel(configuration.getEventMiddlewareFile()); |
| 62 | eventMiddlewarePartition.resolveAllProxies(); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public String getName() { |
| 67 | return "Perform PCM Model Load"; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void rollback(IProgressMonitor monitor) |
| 72 | throws RollbackFailedException { |
| 73 | } |
| 74 | } |