Skip to content
Snippets Groups Projects
Commit 3e40e522 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Services: Remove the generic from the exploration service.


* The generic parameter was intended to specify the extension types
  (modules) of an exploration services.
* This information is used nowhere, so remove it.

Signed-off-by: default avatarAlexander Diewald <diewald@fortiss.org>
parent fc0bf727
No related branches found
No related tags found
1 merge request!2Dependency injection
Showing
with 33 additions and 41 deletions
ConstraintGenerationException.java ea88d94abb652ec0c5788cb9f9856b866e7abf09 RED
ExplorationException.java 62ce085f34132afc32eaf8ca579ae8926a3d3b70 RED
ExplorationServiceException.java 0d93a35ea1b510d199866b9d847ae2bfa92c48cd RED
ExplorationServiceException.java 94202232e25ac039ebcad0ee977e37c5a317111a RED
InvalidModelException.java f5ef624ea79418ee5f6bc6acea9126094ec27c49 RED
InvalidPlatformModelException.java b0e93b8e9b703dc33825c71d7bc542abda83a2ef RED
InvalidTimingModelException.java 014945b26fffef745844be500ef4c2efe0bc9a27 RED
......
......@@ -28,8 +28,7 @@ public class ExplorationServiceException extends ExplorationException {
* Constructs an {@link ExplorationServiceException} with information about the failed
* {@link IExplorationService} and the given message.
*/
public ExplorationServiceException(Class<? extends IExplorationService<?>> serviceType,
String msg) {
public ExplorationServiceException(Class<? extends IExplorationService> serviceType, String msg) {
super(serviceType.getSimpleName() + " failed: " + msg);
}
......@@ -37,7 +36,7 @@ public class ExplorationServiceException extends ExplorationException {
* Constructs a {@link ExplorationServiceException} with information about the failed
* {@link IExplorationService} and the given message and the given {@link Exception}.
*/
public ExplorationServiceException(Class<? extends IExplorationService<?>> serviceType,
public ExplorationServiceException(Class<? extends IExplorationService> serviceType,
String msg, Exception e) {
super(serviceType.getSimpleName() + " failed: " + msg, e);
}
......
ExplorationEncodingMap.java aaea06f5731018d159a04266c92f1a701e461323 RED
ExplorationService.java 013434bf2fd9ae6d97b2540874b2fa7d75e280e2 RED
ExplorationService.java 888656711c0e8930757acd4b25d89c77bd3e4b82 RED
ExplorationTransformationInputs.java 3374ce609b50e69c3c29f1eb79bee25cd06b181d RED
IExplorationConstraintTransformationService.java 06c5e34e4c9e5b752b7747f5ac853f7b8f756867 RED
IExplorationConstraintTransformationService.java 48b673e1fb69c05e35c4e60ecf73b8f708cfcf0e RED
IExplorationContraintTransformationModule.java 1d3560401275f719e2b9901d1639a6be6bd7c169 RED
IExplorationEncoding.java f58adbcf840af521333c2777f50041a60548bff3 RED
IExplorationEvaluatationService.java b4d242fb3d16796e98db31dd8db50aa4d003d49f RED
IExplorationEvaluatationService.java c79cd47a3eac58d56071e51bb5465efefa226fc5 RED
IExplorationExtension.java c2a148e18c580d2432357e93da45e7bf7df8eb0c RED
IExplorationModuleService.java 9280ae46ce9918c3b58e2f8189535707ac232c1c RED
IExplorationRepairService.java 9fdbc6c62436e32f1ebc7f3e6c43517199271f32 RED
IExplorationService.java 29252f52f28fcd036272bbb05dcd48897ee33dfd RED
IExplorationRepairService.java 879d73fce129cd3c4c6fd2819a5c4ed0a625c55b RED
IExplorationService.java 5aaf2b75e88e4ee1b1a206c00e77dd173a5cdeb5 RED
IExplorationTargetEvaluator.java 99c27a053a123462b8a4faadc9c3530fe6bc0c67 RED
IExplorationTransformationService.java b16fb771873374a3cfd31b8e942af030e689774e RED
IExplorationTransformationService.java eed8f4a86eda433c2fc0af00fbef31dbd942c9f0 RED
IRepairModule.java 0cca5fea3835e4fccc151eec42232ad0e6c88e66 RED
......@@ -45,7 +45,7 @@ public class ExplorationService {
private volatile static ExplorationService INSTANCE;
/** Associates {@link IExplorationService} types with their singleton instances. */
private Map<Class<? extends IExplorationService<?>>, IExplorationService<?>> services =
private Map<Class<? extends IExplorationService>, IExplorationService> services =
new HashMap<>();
/** Constructor. */
......@@ -68,7 +68,7 @@ public class ExplorationService {
* Type of the service.
* @return The service's instance registered for the given service type.
*/
public static <T extends IExplorationService<?>> T getService(Class<T> serviceType) {
public static <T extends IExplorationService> T getService(Class<T> serviceType) {
@SuppressWarnings("unchecked") T service = (T)getInstance().services.get(serviceType);
if(service == null) {
BundleContext ctx =
......@@ -92,7 +92,7 @@ public class ExplorationService {
* @throws ExplorationServiceException
* If the OSGI service holder throws an exception.
*/
public static <T extends IExplorationService<?>, S extends T, U extends T> S replaceService(
public static <T extends IExplorationService, S extends T, U extends T> S replaceService(
Class<T> serviceType, U serviceInstance) throws ExplorationServiceException {
@SuppressWarnings("unchecked") S oldInstance = (S)getInstance().services.get(serviceType);
// Decrease the service use by ungetting again.
......
......@@ -17,6 +17,7 @@ package org.fortiss.af3.exploration.alg.service;
import java.util.Collection;
import org.eclipse.osgi.internal.module.GenericConstraint;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter;
import org.fortiss.af3.exploration.alg.exception.ExplorationException;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
......@@ -30,8 +31,7 @@ import org.fortiss.af3.exploration.model.ExplorationConstraint;
*
* @author diewald
*/
public interface IExplorationConstraintTransformationService
extends IExplorationService<IExplorationContraintTransformationModule<?>> {
public interface IExplorationConstraintTransformationService extends IExplorationService {
// TODO: Should we use a separate marker for external Constrains?
/**
......
......@@ -27,8 +27,8 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegen
*
* @author diewald
*/
public interface IExplorationEvaluatationService<T extends IExplorationExtension>
extends IExplorationService<T> {
public interface IExplorationEvaluatationService<T extends IExplorationExtension> extends
IExplorationService {
/**
* Returns the collection of input model types that are required to execute the given set of
......@@ -40,6 +40,6 @@ public interface IExplorationEvaluatationService<T extends IExplorationExtension
* @return collection of model element types which must be provided through the transformation
* service (or directly) such that evaluator gets all the required inputs.
*/
Collection<Class<?>>
getRequiredTransformedModels(Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators);
Collection<Class<?>> getRequiredTransformedModels(
Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators);
}
......@@ -25,7 +25,7 @@ import org.opt4j.core.Genotype;
*
* @author diewald
*/
public interface IExplorationRepairService extends IExplorationService<IRepairModule<?>> {
public interface IExplorationRepairService extends IExplorationService {
/**
* Returns the collection of {@link IRepairModule} instances that shall be applied to the given
......
......@@ -24,8 +24,7 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
*
* @author diewald
*/
public interface IExplorationService<T extends IExplorationExtension> extends
IIntrospectiveKernelService {
public interface IExplorationService extends IIntrospectiveKernelService {
/**
* Initialization routine of {@link IExplorationService}s which is the first method to be
......
......@@ -30,12 +30,9 @@ import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
* {@link IExplorationService} interface of the {@link IExplorationTransformationService}.
* It enables users to obtain transformed EMF models of a given type from a provided (candidate)
* solution calculated by the DSE and the respective base models.
* A transformed model is returned if:
* <li>The provided input (base models and candidate solution
* encodings) match the required ones.</li>
* <li>All required {@link ITransformationModule}s are
* present.</li>
* <li>None of the executed {@link ITransformationModule}s fails.</li>
* A transformed model is returned if: <li>The provided input (base models and candidate solution
* encodings) match the required ones.</li> <li>All required {@link ITransformationModule}s are
* present.</li> <li>None of the executed {@link ITransformationModule}s fails.</li>
* <p>
* The {@link IExplorationTransformationService} is organized by {@link ITransformationStrategy}s
* and {@link ITransformationModule}s. The modules encapsulate isolated steps in a transformation
......@@ -55,8 +52,7 @@ import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
*
* @author diewald
*/
public interface IExplorationTransformationService
extends IExplorationService<ITransformationModule<?>> {
public interface IExplorationTransformationService extends IExplorationService {
/**
* Enum describing the context from which the transformation is requested. It is used to limit
* the number of transformations to the required minimum to obtain a better DSE performance.
......
ExplorationConstraintTransformationService.java 5e7117398827ae129b3c9a8a16457d816ba665a7 RED
ExplorationEvaluationService.java 96fdc6ba227cb73af2073589557364d64d93b7af RED
ExplorationEvaluationService.java c701675e13e3b2c4725822aa80f791aa36e11b24 RED
ExplorationRepairService.java 940ceda7c8c48f282132355249af1fe0a005c0f5 RED
ExplorationTransformationService.java 36e2368dd6098e1f3aa210a6defd4f269628e28a RED
......@@ -24,7 +24,6 @@ import java.util.Set;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter;
import org.fortiss.af3.exploration.alg.exception.ExplorationServiceException;
......@@ -47,8 +46,8 @@ import com.google.common.collect.Multimap;
*
* @author diewald
*/
public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<?, ?, ?>>
extends EObjectAwareServiceBase<T> implements IExplorationEvaluatationService<T> {
public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<?, ?, ?>> extends
EObjectAwareServiceBase<T> implements IExplorationEvaluatationService<T> {
/** The evaluator provider extension point ID. */
private static final String EXTENSION_POINT_NAME = "org.fortiss.af3.exploration.alg.evaluator";
......@@ -135,8 +134,8 @@ public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public Collection<Class<?>>
getRequiredTransformedModels(Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators) {
public Collection<Class<?>> getRequiredTransformedModels(
Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators) {
Set<Class<?>> retVal = new HashSet<>();
evaluators.forEach(e -> retVal.addAll(requiredTransformedModels
.get((Class<IExplorationTargetEvaluator<?, ?, ?>>)e.getClass())));
......@@ -182,10 +181,10 @@ public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<
private void checkInputConsistency(Collection<Class<?>> requiredNonPhenoInputs)
throws ExplorationServiceException {
for(Class<?> curInputType : requiredNonPhenoInputs) {
if(!getService(IExplorationTransformationService.class)
.canTransformOutputType(curInputType)) {
if(!getService(IExplorationTransformationService.class).canTransformOutputType(
curInputType)) {
throw new ExplorationServiceException(
(Class<? extends IExplorationService<?>>)IExplorationEvaluatationService.class,
(Class<? extends IExplorationService>)IExplorationEvaluatationService.class,
"The required input type " + curInputType.getSimpleName() +
" is not a Phenotype, nor can it be produced by the" +
" IExplorationTransformationService. Please check the required" +
......@@ -230,8 +229,7 @@ public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<
@SuppressWarnings("unchecked") Class<P> primaryInputType =
(Class<P>)evaluatorHandler.getPrimaryInputType();
assert (Phenotype.class.isAssignableFrom(
primaryInputType)) : "The primary input type is not a genotype. Only Genotypes are currently supported.";
assert (Phenotype.class.isAssignableFrom(primaryInputType)) : "The primary input type is not a genotype. Only Genotypes are currently supported.";
int priority = 9999;
if(explorationTarget instanceof MOExplorationObjective<?>) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment