KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > internal > adaptor > EclipseBundleInstaller


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.runtime.internal.adaptor;
12
13 import org.eclipse.osgi.framework.adaptor.core.BundleInstaller;
14 import org.eclipse.osgi.service.resolver.BundleDescription;
15 import org.osgi.framework.*;
16
17 /**
18  * Internal class.
19  */

20 //TODO: minimal implementation for now. This could be smarter
21
public class EclipseBundleInstaller implements BundleInstaller {
22     BundleContext context;
23     public EclipseBundleInstaller(BundleContext context) {
24         this.context = context;
25     }
26
27     public void installBundle(BundleDescription toInstall) throws BundleException {
28         context.installBundle(toInstall.getLocation());
29     }
30
31     public void uninstallBundle(BundleDescription toUninstallId) throws BundleException {
32         Bundle toUninstall = context.getBundle(toUninstallId.getBundleId());
33         if (toUninstall != null)
34             toUninstall.uninstall();
35     }
36
37     public void updateBundle(BundleDescription toUpdateId) throws BundleException {
38         Bundle toUpdate = context.getBundle(toUpdateId.getBundleId());
39         if (toUpdate != null)
40             toUpdate.update();
41     }
42 }
43
Popular Tags