本文整理汇总了Java中net.ssehub.easy.basics.progress.ProgressObserver类的典型用法代码示例。如果您正苦于以下问题:Java ProgressObserver类的具体用法?Java ProgressObserver怎么用?Java ProgressObserver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProgressObserver类属于net.ssehub.easy.basics.progress包,在下文中一共展示了ProgressObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearModels
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Clears the models and rereads them if requested.
*
* @param rereadModels reread the models or just clear
*/
public static void clearModels(boolean rereadModels) {
if (null != modelsLocation) {
try {
ModelInitializer.removeLocation(modelsLocation, ProgressObserver.NO_OBSERVER);
} catch (ModelManagementException e) {
getLogger().error("Clearing models: " + e.getMessage());
}
FileUtils.deleteQuietly(modelsLocation);
modelsLocation = null;
}
models.clear();
if (rereadModels) {
readModels();
}
}
示例2: instantiateSelf
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Instantiates the given project.
* The project must:
* <ul>
* <li>be a valid EASy project with the usual configuration files and folders.</li>
* <li>contain a frozen configuration</li>
* <li>contain VIL script which can be applied to itself</li>
* </ul>
*
* @param project The toplevel absolute folder of the project (must have a valid EASy structure)
* @param arguments a name-element mapping specifying the top-level parameter of a VIL instantiation (may
* be <b>null</b>)
*
* @throws PersistenceException Will be thrown if the project could not be loaded, e.g. if the project has no
* valid EASy structure.
* @throws VilException In case that artifact operations or script execution fails
*/
public static void instantiateSelf(File project, Map<String, Object> arguments)
throws PersistenceException, VilException {
// This is the usual way:
VilArgumentProvider provider = createArgumentProvider(arguments);
LowlevelCommands.loadProject(project);
String projectName = ProjectNameMapper.getInstance().getName(project);
PLPInfo plp = LowlevelCommands.getProject(projectName);
if (null != plp) {
InstantiationListener listener = new InstantiationListener();
plp.addVilExecutionListener(listener);
plp.instantiate(ProgressObserver.NO_OBSERVER, true);
if (null != listener.exc) {
throw listener.exc;
}
} else {
throw new PersistenceException("Project \"" + projectName + "\" could not be loaded.");
}
VilArgumentProvider.remove(provider); // works with null as argument
}
示例3: instantiateEASyProjects
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Instantiates the project <tt>projectTarget</tt>, while using source files (and IVML/VIL information) provided
* by <tt>projectSource</tt>.
* The following conditions must be hold:
* <ul>
* <li>Both projects must exist and have a valid EASy project structure with the usual configuration files, IDs,
* and folders.</li>
* <li><tt>projectTarget</tt> must contain a contain a frozen configuration.</li>
* <li><tt>projectTarget</tt> must contain VIL script.</li>
* <li><tt>projectSource</tt> must contain a infrastructure, which cen be instantiated, e.g. annotated source files.
* </li>
* </ul>
*
* @param projectSource The toplevel absolute folder of an EASy project (must have a valid EASy structure), which
* serves as a basis for instantiation.
* @param projectTarget The toplevel absolute folder of an EASy project (must have a valid EASy structure), which
* should be instantiated.
* @param arguments a name-element mapping specifying the top-level parameter of a VIL instantiation (may
* be <b>null</b>)
*
* @throws PersistenceException Will be thrown if one of the projects could not be loaded,
* e.g. if the project has no valid EASy structure.
* @throws VilException In case that artifact operations or script execution fails
*/
private static void instantiateEASyProjects(File projectSource, File projectTarget, Map<String, Object> arguments)
throws PersistenceException, VilException {
VilArgumentProvider provider = createArgumentProvider(arguments);
// This is the usual way:
LowlevelCommands.loadProject(projectSource);
LowlevelCommands.loadProject(projectTarget);
String projectName = ProjectNameMapper.getInstance().getName(projectTarget);
PLPInfo plp = LowlevelCommands.getProject(projectName);
if (null != plp) {
InstantiationListener listener = new InstantiationListener();
plp.addVilExecutionListener(listener);
plp.instantiate(ProgressObserver.NO_OBSERVER, true);
if (null != listener.exc) {
throw listener.exc;
}
} else {
throw new PersistenceException("Project \"" + projectName + "\" could not be loaded.");
}
VilArgumentProvider.remove(provider); // works with null as argument
}
示例4: scanAll
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Scans the entire environment starting at <code>root</code>.
*
* @param observer the observer to be notified in case of progress, use
* {@link ProgressObserver#NO_OBSERVER} if progress shall not be monitored
* @throws VilException in case that creating / obtaining artifacts fails
*/
public void scanAll(ProgressObserver observer) throws VilException {
if (null != base) {
ITask task = observer.registerTask("creating complete artifact model for " + base.getAbsolutePath());
int count = 0;
if (ProgressObserver.NO_OBSERVER != observer) {
count = scanAll(base, 0, null, null, null);
}
observer.notifyProgress(task, 0, count);
List<VilException> errors = new ArrayList<VilException>();
scanAll(base, 0, observer, task, errors);
observer.notifyEnd(task);
if (errors.size() > 0) {
throw new VilException(errors);
}
}
}
示例5: runReasoner
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Runs the reasoner for the specified project.
* @param projectP1 Project to reason on.
* @return number of failed constraints.
*/
private int runReasoner(Project projectP1) {
Configuration config = new Configuration(projectP1, false);
ReasonerConfiguration rConfig = new ReasonerConfiguration();
// Perform reasoning
Engine engine = new Engine(projectP1, config, rConfig, ProgressObserver.NO_OBSERVER);
ReasoningResult result = engine.reason();
// Test whether reasoning detected correct result
int failedConstraints = 0;
for (int i = 0; i < result.getMessageCount(); i++) {
if (result.getMessage(i).getStatus() == Status.ERROR) {
failedConstraints = failedConstraints + result.getMessage(i).getConflicts().size();
}
}
return failedConstraints;
}
示例6: testUnloading
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Tries unloading <code>projectName</code> and tests for <code>expectedUnloaded</code>.
*
* @param loader the model loader
* @param projectName the project to be unloaded
* @param expectedUnloaded the names of the models to be unloaded with <code>projectName</code>
* @throws ModelManagementException in case of VarModel errors
*/
private static void testUnloading(UnloadTestModelLoader loader, String projectName,
String... expectedUnloaded) throws ModelManagementException {
//System.out.println("unloading " + projectName + " expecting " + Arrays.toString(expectedUnloaded));
ModelInfo<Project> info = loader.getProjectInfo(projectName);
Assert.assertNotNull("project information object for '" + projectName + "' does not exist", info);
Assert.assertNotNull("project '" + projectName + "' is not resolved" + info.getResolved());
int count = VarModel.INSTANCE.getModelCount();
HashSet<String> pNames = new HashSet<String>(count);
for (int i = 0; i < count; i++) {
pNames.add(VarModel.INSTANCE.getModel(i).getName());
}
Assert.assertEquals("expected number of unloaded projects is not met", expectedUnloaded.length,
VarModel.INSTANCE.unload(info.getResolved(), ProgressObserver.NO_OBSERVER));
for (int i = 0; i < expectedUnloaded.length; i++) {
Assert.assertNotNull(loader.getProjectInfo(expectedUnloaded[i]));
Assert.assertNull("project '" + expectedUnloaded[i] + "' is still resolved",
loader.getProjectInfo(expectedUnloaded[i]).getResolved());
Assert.assertNotNull("project '" + expectedUnloaded[i] + "' does not exist",
pNames.remove(expectedUnloaded[i]));
}
for (int i = 0; i < VarModel.INSTANCE.getModelCount(); i++) { // varModel may have changed
pNames.remove(VarModel.INSTANCE.getModel(i).getName());
}
Assert.assertTrue("model name mismatch", pNames.isEmpty());
}
示例7: startInstantiation
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Starts the execution of the underlying VIL script ({@link PLPInfo#getBuildScript()}) in an own thread.
* @param observer The observer to inform about the current progress (in case of <tt>null</tt>
* {@link ProgressObserver#NO_OBSERVER} will be used).
* @param waitFor <tt>true</tt> This method will wait until the script was processed completely (blocking method),
* <tt>false</tt> script will be processed in an asynchronous manner (usually used in an GUI environment).
* @see #abortInstantiation()
*/
public void startInstantiation(ProgressObserver observer, boolean waitFor) {
if (null == executor) {
successful = true;
this.observer = (observer != null) ? observer : ProgressObserver.NO_OBSERVER;
executor = createExecutor();
Thread executionThread = new Thread(this);
executionThread.start();
if (waitFor) {
try {
executionThread.join();
} catch (InterruptedException e) {
Activator.getLogger(VilExecutionThread.class).exception(e);
}
}
}
}
示例8: resultHandler
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Method for handling reasoning result.
* @param expectedFailedConstraints Number of constraints that are expected to fa
* @param projectP1 Project to reason on.
*/
private void resultHandler(int expectedFailedConstraints, Project projectP1) {
Configuration config = new Configuration(projectP1, false);
ReasonerConfiguration rConfig = new ReasonerConfiguration();
rConfig.setRuntimeMode(true);
// Perform reasoning
Engine engine = new Engine(projectP1, config, rConfig, ProgressObserver.NO_OBSERVER);
ReasoningResult result = engine.reason();
// Test whether reasoning detected correct result
int failedConstraints = 0;
for (int i = 0; i < result.getMessageCount(); i++) {
if (result.getMessage(i).getStatus() == Status.ERROR) {
failedConstraints = failedConstraints + result.getMessage(i).getConflicts().size();
}
}
Assert.assertEquals("Failed constraints: ", expectedFailedConstraints, failedConstraints);
}
示例9: testResolveOfIntegers
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Tests whether integer variables are resolved correctly.
* This tests includes:
* <ul>
* <li>Imports</li>
* <li>Assignments</li>
* <li>Defaults</li>
* <li>Re-Assignments</li>
* </ul>
*/
@Test
public void testResolveOfIntegers() {
createProjectP0();
createProjectP1();
createProjectP2();
Configuration config = new Configuration(projectP2, false);
ReasonerConfiguration rConfig = new ReasonerConfiguration();
Engine engine = new Engine(projectP2, config, rConfig, ProgressObserver.NO_OBSERVER);
engine.reason();
assertVariable(config, declA, 2, AssignmentState.DERIVED);
assertVariable(config, declB, 2, AssignmentState.DERIVED);
assertVariable(config, declC, 3, AssignmentState.DERIVED);
assertVariable(config, declD, 5, AssignmentState.DERIVED);
}
示例10: resultComparer
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Method for comparing reasoning result.
* @param expectedFailedConstraints Number of expected failed constraints.
* @param expectedReevaluationCount Number of expected reevaluations.
* @param projectP1 Project to reason on.
*/
public static void resultComparer(int expectedFailedConstraints, int expectedReevaluationCount, Project projectP1) {
Configuration config = new Configuration(projectP1, false);
ReasonerConfiguration rConfig = new ReasonerConfiguration();
// Perform reasoning
Engine engine = new Engine(projectP1, config, rConfig, ProgressObserver.NO_OBSERVER);
ReasoningResult result = engine.reason();
// Test whether reasoning detected correct result
int failedConstraints = 0;
for (int i = 0; i < result.getMessageCount(); i++) {
if (result.getMessage(i).getStatus() == Status.ERROR) {
failedConstraints = failedConstraints + result.getMessage(i).getConflicts().size();
}
}
Assert.assertEquals("Failed constraints: ", expectedFailedConstraints, failedConstraints);
// Test whether reasoning is done in correct reevalustion steps
Assert.assertTrue("Reevaluation count mismatch. Result: " + engine.getReevaluationCount()
+ " Expected: " + expectedReevaluationCount, engine.getReevaluationCount() == expectedReevaluationCount);
}
示例11: tearDown
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Executed after a single test.
*
* @throws ModelManagementException shall not occur
*/
@After
public void tearDown() throws ModelManagementException {
AlgorithmProfilePredictionManager.stop();
VolumePredictionManager.stop();
FileUtils.deleteQuietly(tmp);
ModelInitializer.unregisterLoader(ProgressObserver.NO_OBSERVER);
EventManager.stop();
}
示例12: main
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Executes the test.
*
* @param args the first argument shall be the model location
* @throws ModelManagementException in case that obtaining the models fails
* @throws IOException if file operations fail
*/
public static void main(String[] args) throws ModelManagementException, IOException {
if (0 == args.length) {
System.out.println("qualimaster.profile: <model location>");
System.exit(0);
} else {
Properties prop = new Properties();
prop.put(CoordinationConfiguration.PIPELINE_ELEMENTS_REPOSITORY,
"https://projects.sse.uni-hildesheim.de/qm/maven/");
CoordinationConfiguration.configure(prop, false);
File tmp = new File(FileUtils.getTempDirectory(), "qmDebugProfile");
FileUtils.deleteDirectory(tmp);
tmp.mkdirs();
File modelLocation = new File(args[0]);
if (!modelLocation.exists()) {
System.out.println("model location " + modelLocation + " does not exist");
System.exit(0);
}
initialize();
ModelInitializer.registerLoader(ProgressObserver.NO_OBSERVER);
ModelInitializer.addLocation(modelLocation, ProgressObserver.NO_OBSERVER);
Project project = RepositoryHelper.obtainModel(VarModel.INSTANCE, "QM", null);
// create descriptor before clearing the location - in infrastructure pass vil directly/resolve VIL
Configuration monConfig = RepositoryHelper.createConfiguration(project, "MONITORING");
QmProjectDescriptor source = new QmProjectDescriptor(tmp);
try {
ProfileData data = AlgorithmProfileHelper.createProfilePipeline(monConfig, "ProfileTestPip",
"fCorrelationFinancial", "TopoSoftwareCorrelationFinancial", source);
// "fPreprocessor", "Preprocessor", source);
System.out.println("Creation successful. " + data.getPipeline());
} catch (VilException e) {
e.printStackTrace();
}
ModelInitializer.removeLocation(modelLocation, ProgressObserver.NO_OBSERVER);
}
}
示例13: main
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Executes the test in sequence. Please adjust your model location and the files to be analyzed.
*
* @param args location of the model, requested functionality (none: just load the model, monitor: process
* file/monitoring_ in sequence, adapt: process file/adaptation_ in sequence)
* @throws ModelManagementException shall not occur
*/
public static void main(String[] args) throws ModelManagementException {
if (0 == args.length) {
System.out.println("qualimaster.debug: <model location> [monitor|adapt]");
System.exit(0);
} else {
File modelLocation = new File(args[0]);
if (!modelLocation.exists()) {
System.out.println("model location " + modelLocation + " does not exist");
System.exit(0);
}
String prefix = null;
if (args.length > 1) {
if ("monitor".equals(args[1])) {
prefix = "monitoring_";
} else if ("adapt".equals(args[1])) {
prefix = "adaptation_";
}
}
initialize();
ModelInitializer.registerLoader(ProgressObserver.NO_OBSERVER);
ModelInitializer.addLocation(modelLocation, ProgressObserver.NO_OBSERVER);
Project project = RepositoryHelper.obtainModel(VarModel.INSTANCE, "QM", null);
Script rtVilModel = RepositoryHelper.obtainModel(RtVilModel.INSTANCE, "QM", null);
Configuration config = RepositoryHelper.createConfiguration(project, "TESTING");
System.out.println("Model loaded...");
if (null != prefix) {
process(prefix, config, rtVilModel);
}
}
}
示例14: run
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
@Override
public void run() {
while (count.getAndDecrement() > 0) {
System.out.println("> " + name);
try {
ReasonerFrontend.getInstance().propagate(cfg.getProject(), cfg, RCFG,
ProgressObserver.NO_OBSERVER);
} catch (Throwable t) {
t.printStackTrace();
}
System.out.println("< " + name);
sleep(5);
}
}
示例15: main
import net.ssehub.easy.basics.progress.ProgressObserver; //导入依赖的package包/类
/**
* Executes the test.
*
* @param args the first argument shall be the model location
* @throws ModelManagementException in case that obtaining the models fails
*/
public static void main(String[] args) throws ModelManagementException {
if (0 == args.length) {
System.out.println("qualimaster.debug: <model location> [monitor|adapt]");
System.exit(0);
} else {
File modelLocation = new File(args[0]);
if (!modelLocation.exists()) {
System.out.println("model location " + modelLocation + " does not exist");
System.exit(0);
}
initialize();
ModelInitializer.registerLoader(ProgressObserver.NO_OBSERVER);
ModelInitializer.addLocation(modelLocation, ProgressObserver.NO_OBSERVER);
Project project = RepositoryHelper.obtainModel(VarModel.INSTANCE, "QM", null);
Configuration monConfig = RepositoryHelper.createConfiguration(project, "MONITORING");
ModelInitializer.removeLocation(modelLocation, ProgressObserver.NO_OBSERVER);
ModelInitializer.addLocation(modelLocation, ProgressObserver.NO_OBSERVER);
project = RepositoryHelper.obtainModel(VarModel.INSTANCE, "QM", null);
//Script rtVilModel = RepositoryHelper.obtainModel(RtVilModel.INSTANCE, "QM", null);
Configuration adaptConfig = RepositoryHelper.createConfiguration(project, "ADAPTATION");
ModelInitializer.removeLocation(modelLocation, ProgressObserver.NO_OBSERVER);
ReasoningRunnable r1 = new ReasoningRunnable("Monitoring", monConfig);
ReasoningRunnable r2 = new ReasoningRunnable("Adaptation", adaptConfig);
Thread t1 = new Thread(r1);
Thread t2 = new Thread(r2);
t1.start();
t2.start();
while (count.get() > 0) {
sleep(500);
}
}
}