1 | package de.uka.ipd.sdq.codegen.ejb; |
2 | |
3 | import java.util.ArrayList; |
4 | |
5 | import org.apache.log4j.Level; |
6 | import org.eclipse.core.runtime.CoreException; |
7 | import org.eclipse.debug.core.ILaunch; |
8 | import org.eclipse.debug.core.ILaunchConfiguration; |
9 | |
10 | import de.uka.ipd.sdq.codegen.simucontroller.debug.IDebugListener; |
11 | import de.uka.ipd.sdq.codegen.simucontroller.debug.SimulationDebugListener; |
12 | import de.uka.ipd.sdq.workflow.IJob; |
13 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder; |
14 | import de.uka.ipd.sdq.workflow.launchconfig.LoggerAppenderStruct; |
15 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMLaunchConfigurationDelegate; |
16 | import de.uka.ipd.sdq.workflow.pcm.configurations.PCMWorkflowConfigurationBuilder; |
17 | |
18 | /** |
19 | * The class adapts defined functionality in the AbstractMDSDLaunchConfigurationDelegate for |
20 | * SimuCom Framework. |
21 | * |
22 | */ |
23 | public class EJBCodegenWorkflowLauncher extends |
24 | AbstractPCMLaunchConfigurationDelegate<EjbCodeGenerationConfiguration> { |
25 | |
26 | /* |
27 | * (non-Javadoc) |
28 | * |
29 | * @seede.uka.ipd.sdq.codegen.runconfig.LaunchConfigurationDelegate# |
30 | * creataAttributesGetMethods(org.eclipse.debug.core.ILaunchConfiguration) |
31 | */ |
32 | @Override |
33 | protected EjbCodeGenerationConfiguration deriveConfiguration( |
34 | ILaunchConfiguration configuration, String mode) |
35 | throws CoreException { |
36 | EjbCodeGenerationConfiguration config = new EjbCodeGenerationConfiguration(); |
37 | |
38 | AbstractWorkflowConfigurationBuilder builder; |
39 | builder = new PCMWorkflowConfigurationBuilder(configuration, mode); |
40 | builder.fillConfiguration(config); |
41 | |
42 | builder = new EjbCodeGenerationLaunchConfigurationBasedConfigBuilder( |
43 | configuration, mode); |
44 | builder.fillConfiguration(config); |
45 | |
46 | return config; |
47 | } |
48 | |
49 | /* (non-Javadoc) |
50 | * @see de.uka.ipd.sdq.codegen.simucontroller.runconfig.AbstractMDSDLaunchConfigurationDelegate#setupLogging(org.apache.log4j.Level) |
51 | */ |
52 | @Override |
53 | protected ArrayList<LoggerAppenderStruct> setupLogging(Level logLevel) throws CoreException { |
54 | ArrayList<LoggerAppenderStruct> loggerList = super.setupLogging(logLevel); |
55 | loggerList.add(setupLogger("de.uka.ipd.sdq.codegen", logLevel, Level.DEBUG == logLevel ? DETAILED_LOG_PATTERN : SHORT_LOG_PATTERN)); |
56 | loggerList.add(setupLogger("de.uka.ipd.sdq.simucomframework", logLevel, Level.DEBUG == logLevel ? DETAILED_LOG_PATTERN : SHORT_LOG_PATTERN)); |
57 | loggerList.add(setupLogger("de.uka.ipd.sdq.workflow.mdsd.emf.qvtr", logLevel, Level.DEBUG == logLevel ? DETAILED_LOG_PATTERN : SHORT_LOG_PATTERN)); |
58 | loggerList.add(setupLogger("de.uka.ipd.sdq.statistics", logLevel, Level.DEBUG == logLevel ? DETAILED_LOG_PATTERN : SHORT_LOG_PATTERN)); |
59 | |
60 | return loggerList; |
61 | } |
62 | |
63 | /* |
64 | * (non-Javadoc) |
65 | * |
66 | * @seede.uka.ipd.sdq.codegen.runconfig.LaunchConfigurationDelegate# |
67 | * createRunCompositeJob |
68 | * (de.uka.ipd.sdq.codegen.runconfig.AttributesGetMethods) |
69 | */ |
70 | @Override |
71 | protected IJob createWorkflowJob(EjbCodeGenerationConfiguration config, |
72 | final ILaunch launch) throws CoreException { |
73 | IDebugListener listener = null; |
74 | |
75 | if (config.isDebug()) { |
76 | listener = new SimulationDebugListener(launch); |
77 | /*listener = new IDebugListener() { |
78 | |
79 | private SimulationDebugTarget target = null; |
80 | |
81 | public void simulationStartsInDock(DockModel dock) { |
82 | target = new SimulationDebugTarget(launch,dock); |
83 | launch.addDebugTarget(target); |
84 | } |
85 | |
86 | public void simulationStoppedInDock() { |
87 | if (target != null) { |
88 | // Wait for termination, needed as termination is reported via async events by the dock |
89 | while (!target.isTerminated()) { |
90 | try { |
91 | Thread.sleep(100); |
92 | } catch (InterruptedException e) { |
93 | } |
94 | } |
95 | launch.removeDebugTarget(target); |
96 | target.dispose(); |
97 | } |
98 | } |
99 | |
100 | };*/ |
101 | } |
102 | return new EJBCodeGenerationJob(config,listener); |
103 | } |
104 | } |