1 11 package org.eclipse.core.runtime.spi; 12 13 import java.io.File ; 14 import java.util.Map ; 15 import java.util.ResourceBundle ; 16 import javax.xml.parsers.SAXParserFactory ; 17 import org.eclipse.core.internal.registry.*; 18 import org.eclipse.core.runtime.*; 19 import org.eclipse.osgi.util.NLS; 20 21 45 public class RegistryStrategy { 46 47 private SAXParserFactory theXMLParserFactory = null; 48 49 52 private final File [] storageDirs; 53 54 57 private final boolean[] cacheReadOnly; 58 59 78 public RegistryStrategy(File [] storageDirs, boolean[] cacheReadOnly) { 79 this.storageDirs = storageDirs; 80 this.cacheReadOnly = cacheReadOnly; 81 } 82 83 88 public final int getLocationsLength() { 89 if (storageDirs == null) 90 return 0; 91 return storageDirs.length; 92 } 93 94 100 public final File getStorage(int index) { 101 if (storageDirs != null) 102 return storageDirs[index]; 103 return null; 104 } 105 106 113 public final boolean isCacheReadOnly(int index) { 114 if (cacheReadOnly != null) 115 return cacheReadOnly[index]; 116 return true; 117 } 118 119 134 public void log(IStatus status) { 135 RegistrySupport.log(status, null); 136 } 137 138 151 public String translate(String key, ResourceBundle resources) { 152 return RegistrySupport.translate(key, resources); 153 } 154 155 162 public void onStart(IExtensionRegistry registry) { 163 } 165 166 172 public void onStop(IExtensionRegistry registry) { 173 } 175 176 197 public Object createExecutableExtension(RegistryContributor contributor, String className, String overridenContributorName) throws CoreException { 198 Object result = null; 199 Class classInstance = null; 200 try { 201 classInstance = Class.forName(className); 202 } catch (ClassNotFoundException e1) { 203 String message = NLS.bind(RegistryMessages.exExt_findClassError, contributor.getActualName(), className); 204 throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, e1)); 205 } 206 207 try { 208 result = classInstance.newInstance(); 209 } catch (Exception e) { 210 String message = NLS.bind(RegistryMessages.exExt_instantiateClassError, contributor.getActualName(), className); 211 throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, e)); 212 } 213 return result; 214 } 215 216 230 public void scheduleChangeEvent(Object [] listeners, Map deltas, Object registry) { 231 ((ExtensionRegistry) registry).scheduleChangeEvent(listeners, deltas); 232 } 233 234 244 public final static IStatus processChangeEvent(Object [] listeners, Map deltas, Object registry) { 245 if (registry instanceof ExtensionRegistry) 246 return ((ExtensionRegistry) registry).processChangeEvent(listeners, deltas); 247 return null; 248 } 249 250 262 public boolean debug() { 263 return false; 264 } 265 266 278 public boolean debugRegistryEvents() { 279 return false; 280 } 281 282 291 public boolean cacheUse() { 292 return true; 293 } 294 295 304 public boolean cacheLazyLoading() { 305 return true; 306 } 307 308 332 public long getContainerTimestamp() { 333 return 0; 334 } 335 336 355 public long getContributionsTimestamp() { 356 return 0; 357 } 358 359 366 public SAXParserFactory getXMLParser() { 367 if (theXMLParserFactory == null) 368 theXMLParserFactory = SAXParserFactory.newInstance(); 369 return theXMLParserFactory; 370 } 371 } 372 | Popular Tags |