Skip to content
Snippets Groups Projects
Commit 888c5194 authored by Shanshan Jiang's avatar Shanshan Jiang
Browse files

update to version 2.0.0 to work with MW2.0; integrate with ucc.core.installer

parent cb5a2357
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,11 @@
<artifactId>ucc.deploymanagerservice</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.tools.ucc</groupId>
<artifactId>ucc.api</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<description>deploy manager service implementation for uStore</description>
......
......@@ -6,13 +6,22 @@ import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.universAAL.ucc.api.core.IConfigurator;
import org.universAAL.ucc.api.core.IDeinstaller;
import org.universAAL.ucc.api.core.IInformation;
import org.universAAL.ucc.api.core.IInstaller;
import org.universAAL.ucc.api.model.IModel;
import org.universAAL.ucc.deploymanagerservice.DeployManagerService;
public class Activator implements BundleActivator {
private ServiceRegistration registration;
private static IInstaller installer = null;
private static BundleContext context;
public void start(BundleContext bc) throws Exception {
context = bc;
Dictionary props = new Hashtable();
props.put("service.exported.interfaces", "*");
......@@ -21,9 +30,26 @@ public class Activator implements BundleActivator {
registration = bc.registerService(DeployManagerService.class.getName(),
new DeployManagerServiceImpl(), props);
getServices(context);
}
public void stop(BundleContext bc) throws Exception {
registration.unregister();
}
private static void getServices(BundleContext bc) {
if (installer == null) {
ServiceReference sr = bc.getServiceReference(IInstaller.class
.getName());
if (sr != null)
installer = (IInstaller) bc.getService(sr);
}
}
public static IInstaller getInstaller() {
if (installer==null) getServices(context);
return installer;
}
}
......@@ -5,6 +5,7 @@ import java.net.URL;
import java.util.List;
import java.util.Map;
import org.universAAL.ucc.api.core.IInstaller;
import org.universAAL.ucc.deploymanagerservice.DeployManagerService;
/**
......@@ -16,16 +17,23 @@ import org.universAAL.ucc.deploymanagerservice.DeployManagerService;
public class DeployManagerServiceImpl implements DeployManagerService {
private IInstaller installer;
public void install(String sessionKey, String usrvfile) {
System.out.println("[DeployManagerService] Install with sessionKey: " + sessionKey + " for URL: " + usrvfile);
try {
URL usrvURL = new URL(usrvfile);
//TODO download the files and call Installer.install(usrvURL)
}
System.out.println("[DeployManagerServiceImpl] Install with sessionKey: " + sessionKey + " for URL: " + usrvfile);
//try {
// For testing only - use a local file
//URL usrvURL = new URL(usrvfile); // TODO: do we need to convert to URL first or check it when parse the URL in downloader?
//FileDownloader downloader = new FileDownloader();
//String fileOnHardDrive = downloader.download(usrvfile); // TODO: do we use usrvURL???
String fileOnHardDrive = "C:/universAAL/tutorials/Test.usrv";
fileOnHardDrive = fileOnHardDrive.replace("/", "\\");
System.out.println("[DeployManagerServiceImpl] the file on the hard drive: " + fileOnHardDrive);
Activator.getInstaller().installServiceFromOnlineStore(fileOnHardDrive);
/* }
catch(MalformedURLException e)
{
System.out.println("[ERROR] Malformed URL Exception for " + usrvfile);
}
} */
// TODO what check should be done with the sessionKey?
}
......
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