1 19 package org.netbeans.modules.ruby.railsprojects.classpath; 20 21 import java.beans.PropertyChangeEvent ; 22 import org.netbeans.modules.ruby.rubyproject.RubyProjectUtil; 23 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation; 24 import org.netbeans.spi.java.classpath.ClassPathImplementation; 25 import org.netbeans.spi.java.classpath.PathResourceImplementation; 26 import org.netbeans.spi.java.classpath.support.ClassPathSupport; 27 import org.netbeans.api.java.classpath.ClassPath; 28 import java.beans.PropertyChangeListener ; 29 import java.beans.PropertyChangeSupport ; 30 import java.util.List ; 31 import java.util.ArrayList ; 32 import java.util.Collections ; 33 import org.netbeans.modules.ruby.spi.project.support.rake.PropertyEvaluator; 34 import org.openide.util.WeakListeners; 35 36 final class BootClassPathImplementation implements ClassPathImplementation, PropertyChangeListener { 37 38 42 private final PropertyEvaluator evaluator; 43 private String activePlatformName; 46 private boolean isActivePlatformValid; 48 private List <PathResourceImplementation> resourcesCache; 49 private PropertyChangeSupport support = new PropertyChangeSupport (this); 50 51 public BootClassPathImplementation(PropertyEvaluator evaluator) { 52 assert evaluator != null; 53 this.evaluator = evaluator; 54 evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator)); 55 } 56 57 public synchronized List <PathResourceImplementation> getResources() { 58 if (this.resourcesCache == null) { 59 List <PathResourceImplementation> result = new ArrayList <PathResourceImplementation>(); 63 for (ClassPath.Entry entry : RubyInstallation.getInstance().getClassPathEntries()) { 65 result.add(ClassPathSupport.createResource(entry.getURL())); 66 } 67 resourcesCache = Collections.unmodifiableList (result); 68 } 73 return this.resourcesCache; 74 } 75 76 public void addPropertyChangeListener(PropertyChangeListener listener) { 77 this.support.addPropertyChangeListener (listener); 78 } 79 80 public void removePropertyChangeListener(PropertyChangeListener listener) { 81 this.support.removePropertyChangeListener (listener); 82 } 83 84 public void propertyChange(PropertyChangeEvent evt) { 96 } 115 116 119 private void resetCache () { 120 synchronized (this) { 121 resourcesCache = null; 122 } 123 support.firePropertyChange(PROP_RESOURCES, null, null); 124 } 125 126 } 127 | Popular Tags |