Skip to content

Commit

Permalink
#21: Fix for problem with CompatibilityDao not being wired into the a…
Browse files Browse the repository at this point in the history
…picomp service. Empty fields in CompatibilityCheckResult initialized.
  • Loading branch information
Zdenek Vales committed Feb 9, 2020
1 parent 0f6837e commit b36930a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cz.zcu.kiv.crce.compatibility.dao.CompatibilityDao;
import cz.zcu.kiv.crce.metadata.Resource;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.ServiceDependency;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
Expand Down Expand Up @@ -36,7 +37,8 @@ public class ApiCompatibilityCheckerServiceImpl implements ApiCompatibilityCheck

private List<ApiCompatibilityChecker> availableCheckers;

// @ServiceDependency
// todo: find out why this doesn't work
@ServiceDependency(required = false)
private volatile CompatibilityDao compatibilityDao;

public ApiCompatibilityCheckerServiceImpl() {
Expand All @@ -63,7 +65,7 @@ public CompatibilityCheckResult compareApis(Resource api1, Resource api2) {
@Override
public Compatibility findExistingCompatibility(Resource api1, Resource api2) {
if (compatibilityDao == null) {
logger.warn("Compatibility dao not set.");
logger.warn("Compatibility dao not available, can't find existing compatibility object.");
return null;
}
List<Compatibility> compatibilities = compatibilityDao.findCompatibility(api1, api2);
Expand All @@ -73,9 +75,10 @@ public Compatibility findExistingCompatibility(Resource api1, Resource api2) {
@Override
public Compatibility saveCompatibility(Compatibility compatibilityCheckResult) {
if (compatibilityDao == null) {
logger.warn("Compatibility dao not set.");
logger.warn("Compatibility dao not available, can't save compatibility object.");
return compatibilityCheckResult;
}

return compatibilityDao.saveCompatibility(compatibilityCheckResult);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public CompatibilityCheckResult(Resource baseResource, Resource resource) {
this();
baseResourceName = baseResource.getId();
resourceName = resource.getId();

baseResourceVersion = new Version(0,0,0);
resourceVersion = new Version(0,0,0);
}

@Override
Expand Down Expand Up @@ -116,6 +119,6 @@ public void setDiffDetails(List<Diff> diffDetails) {
@Nonnull
@Override
public Contract getContract() {
return null;
return Contract.INTERACTION;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package cz.zcu.kiv.crce.compatibility.dao.internal;

import java.util.Dictionary;
import java.util.Hashtable;

import cz.zcu.kiv.crce.compatibility.dao.CompatibilityDao;
import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ManagedService;

import cz.zcu.kiv.crce.compatibility.CompatibilityFactory;
import cz.zcu.kiv.crce.compatibility.dao.CompatibilityDao;
import java.util.Dictionary;
import java.util.Hashtable;

/**
* Date: 17.11.13
Expand Down Expand Up @@ -39,8 +37,9 @@ public void init(BundleContext context, DependencyManager manager) throws Except
.setInterface(s, compatibilityProps)
.setFactory(new CompatibilityDaoMongoFactory(), "get")
//requires CompatibilityFactory for proper mapping
.add(createServiceDependency().setRequired(true)
.setService(CompatibilityFactory.class))
// .add(createServiceDependency().setRequired(false)
// .setService(CompatibilityFactory.class)
// )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cz.zcu.kiv.crce.compatibility.Difference;
import cz.zcu.kiv.crce.compatibility.dao.CompatibilityDao;
import cz.zcu.kiv.crce.compatibility.dao.internal.mapping.MongoCompatibilityMapper;
import cz.zcu.kiv.crce.compatibility.impl.DefaultCompatibilityFactoryImpl;
import cz.zcu.kiv.crce.metadata.Resource;
import cz.zcu.kiv.crce.metadata.dao.mongodb.BaseMongoDao;
import cz.zcu.kiv.crce.metadata.type.Version;
Expand Down Expand Up @@ -42,6 +43,9 @@ public class CompatibilityDaoMongoImpl extends BaseMongoDao implements Compatibi
public CompatibilityDaoMongoImpl(MongoClient client) {
super(client);
this.col = getCollection("compatibility");

// todo: service or just like this? probably should be service
factory = new DefaultCompatibilityFactoryImpl();
}

@Override
Expand Down

0 comments on commit b36930a

Please sign in to comment.