1 11 package org.eclipse.core.internal.filesystem; 12 13 import java.io.File ; 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.osgi.service.datalocation.Location; 16 import org.osgi.framework.*; 17 18 25 public class Activator implements BundleActivator { 26 private static Activator instance; 27 private BundleContext context; 28 29 33 public static IPath getCacheLocation() { 34 try { 36 if (instance != null) { 37 BundleContext ctx = instance.context; 38 if (ctx != null) { 39 ServiceReference[] refs = ctx.getServiceReferences(Location.class.getName(), Location.INSTANCE_FILTER); 40 if (refs != null && refs.length == 1) { 41 Location location = (Location) ctx.getService(refs[0]); 42 if (location != null) { 43 IPath instancePath = new Path(new File (location.getURL().getFile()).toString()); 44 ctx.ungetService(refs[0]); 45 return instancePath.append(".metadata/.plugins").append(Policy.PI_FILE_SYSTEM); } 47 } 48 } 49 } 50 } catch (InvalidSyntaxException e) { 51 Policy.log(IStatus.INFO, null, e); 52 } 54 return Path.fromOSString(System.getProperty("user.home")); } 58 59 public Activator() { 60 instance = this; 61 } 62 63 public void start(BundleContext aContext) throws Exception { 64 this.context = aContext; 65 } 66 67 public void stop(BundleContext aContext) throws Exception { 68 } 70 71 } 72 | Popular Tags |