- small synchronization cleanups in ProjectAssetManager

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10113 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 3a809e61f5
commit 02964b1c0d
  1. 20
      sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java

@ -73,15 +73,16 @@ import org.openide.util.lookup.Lookups;
*/
@SuppressWarnings("unchecked")
public class ProjectAssetManager extends DesktopAssetManager {
private static final Logger logger = Logger.getLogger(ProjectAssetManager.class.getName());
private Project project;
private URLClassLoader loader;
private List<String> folderNames = new LinkedList<String>();
private LinkedList<FileObject> jarItems = new LinkedList<FileObject>();
private final List<AssetEventListener> assetEventListeners = Collections.synchronizedList(new LinkedList<AssetEventListener>());
private final List<ClassPathChangeListener> classPathListeners = Collections.synchronizedList(new LinkedList<ClassPathChangeListener>());
private URLClassLoader loader;
private final List<ClassPath> classPaths = Collections.synchronizedList(new LinkedList<ClassPath>());
private final List<ClassPathItem> classPathItems = Collections.synchronizedList(new LinkedList<ClassPathItem>());
private LinkedList<FileObject> jarItems = new LinkedList<FileObject>();
private final Mutex mutex = new Mutex();
public ProjectAssetManager(Project prj, String folderName) {
@ -137,7 +138,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
classPaths.clear();
}
private synchronized void loadClassLoader() {
private void loadClassLoader() {
Sources sources = ProjectUtils.getSources(project);
if (sources != null) {
if (loader != null) {
@ -215,7 +216,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
}
};
private synchronized void updateClassLoader() {
private void updateClassLoader() {
ProjectManager.mutex().postWriteRequest(new Runnable() {
public void run() {
synchronized (classPathItems) {
@ -328,12 +329,12 @@ public class ProjectAssetManager extends DesktopAssetManager {
return filesWithSuffix("j3md");
}
public String[] getAssetsWithSuffix(String string){
public String[] getAssetsWithSuffix(String string) {
return filesWithSuffix(string);
}
private String[] filesWithSuffix(String string){
List<String> list=collectFilesWithSuffix(string);
private String[] filesWithSuffix(String string) {
List<String> list = collectFilesWithSuffix(string);
return list.toArray(new String[list.size()]);
}
@ -356,7 +357,6 @@ public class ProjectAssetManager extends DesktopAssetManager {
}
}
if (classPathItems != null) {
synchronized (classPathItems) {
// TODO I need to find out if classPathItems contains all jars added to a project
Iterator<ClassPathItem> classPathItemsIter = classPathItems.iterator();
@ -373,8 +373,6 @@ public class ProjectAssetManager extends DesktopAssetManager {
}
}
}
}
}
}
@ -384,7 +382,6 @@ public class ProjectAssetManager extends DesktopAssetManager {
public InputStream getResourceAsStream(String name) {
InputStream in = null;//JmeSystem.getResourceAsStream(name);
synchronized (classPathItems) {
if (in == null && classPathItems != null) {
// TODO I need to find out if classPathItems contains all jars added to a project
Iterator<ClassPathItem> classPathItemsIter = classPathItems.iterator();
while (classPathItemsIter.hasNext()) {
@ -405,7 +402,6 @@ public class ProjectAssetManager extends DesktopAssetManager {
}
}
}
}
return in;
}

Loading…
Cancel
Save