本文整理匯總了Java中com.jme3.asset.AssetManager.addClassLoader方法的典型用法代碼示例。如果您正苦於以下問題:Java AssetManager.addClassLoader方法的具體用法?Java AssetManager.addClassLoader怎麽用?Java AssetManager.addClassLoader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.asset.AssetManager
的用法示例。
在下文中一共展示了AssetManager.addClassLoader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateLibraries
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Update libraries loader.
*/
@FromAnyThread
private void updateLibraries() {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final URLClassLoader currentClassLoader = getLibrariesLoader();
if (currentClassLoader != null) {
assetManager.removeClassLoader(currentClassLoader);
setLibrariesLoader(null);
}
final Path path = EDITOR_CONFIG.getLibrariesPath();
if (path == null) return;
final Array<Path> jars = FileUtils.getFiles(path, false, JAR_EXTENSIONS);
final URL[] urls = jars.stream()
.map(FileUtils::toUrl)
.toArray(URL[]::new);
final URLClassLoader classLoader = new URLClassLoader(urls, getClass().getClassLoader());
assetManager.addClassLoader(classLoader);
setLibrariesLoader(classLoader);
}
示例2: updateClasses
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Update compiled classes loader.
*/
@FromAnyThread
private void updateClasses() {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final URLClassLoader currentClassLoader = getClassesLoader();
if (currentClassLoader != null) {
assetManager.removeClassLoader(currentClassLoader);
setClassesLoader(null);
}
final Path path = EDITOR_CONFIG.getClassesPath();
if (path == null) return;
final Array<Path> folders = ArrayFactory.newArray(Path.class);
Utils.run(path, folders, (dir, toStore) -> {
final DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
stream.forEach(subFile -> {
if (Files.isDirectory(subFile)) {
toStore.add(subFile);
}
});
});
final URL[] urls = folders.stream()
.map(FileUtils::toUrl)
.toArray(URL[]::new);
final ClassLoader librariesLoader = getLibrariesLoader();
final ClassLoader parent = librariesLoader == null? getClass().getClassLoader() : librariesLoader;
final URLClassLoader classLoader = new URLClassLoader(urls, parent);
assetManager.addClassLoader(classLoader);
setClassesLoader(classLoader);
}
示例3: loadLocalLibraries
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Load local libraries.
*/
@FromAnyThread
public synchronized void loadLocalLibraries(@NotNull final Array<Path> libraries) {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final URLClassLoader currentClassLoader = getLocalLibrariesLoader();
if (currentClassLoader != null) {
assetManager.removeClassLoader(currentClassLoader);
setLocalLibrariesLoader(null);
}
if (libraries.isEmpty()) {
this.localLibrariesScanner = null;
return;
}
final URL[] urlArray = libraries.stream()
.map(FileUtils::toUrl)
.toArray(URL[]::new);
final URLClassLoader classLoader = new URLClassLoader(urlArray, getClass().getClassLoader());
assetManager.addClassLoader(classLoader);
setLocalLibrariesLoader(classLoader);
final ClassPathScanner scanner = ClassPathScannerFactory.newDefaultScanner(classLoader);
final Array<URL> urls = ArrayFactory.asArray(classLoader.getURLs());
final String[] paths = urls.stream().map(url -> Utils.get(url, URL::toURI))
.map(Paths::get)
.map(Path::toString)
.toArray(String[]::new);
scanner.addAdditionalPaths(paths);
scanner.setUseSystemClasspath(false);
scanner.scan();
this.localLibrariesScanner = scanner;
}
示例4: handleFile
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Handle a file event in an asset folder.
*/
@FromAnyThread
private synchronized void handleFile(@NotNull final Path file) {
if (Files.isDirectory(file)) return;
final String extension = FileUtils.getExtension(file);
final ObjectDictionary<String, Array<String>> interestedResources = getInterestedResources();
final Array<String> toStore = interestedResources.get(extension);
if (toStore != null) {
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
toStore.add(toAssetPath(assetFile));
}
if (extension.endsWith(FileExtensions.JAVA_LIBRARY)) {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final URL url = get(file, FileUtils::toUrl);
final Array<URLClassLoader> classLoaders = getClassLoaders();
final URLClassLoader oldLoader = classLoaders.search(url, (loader, toCheck) -> contains(loader.getURLs(), toCheck));
if (oldLoader != null) return;
final URLClassLoader newLoader = new URLClassLoader(toArray(url), getClass().getClassLoader());
classLoaders.add(newLoader);
assetManager.addClassLoader(newLoader);
}
}
示例5: loadLocalClasses
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Load local classes.
*/
@FromAnyThread
public synchronized void loadLocalClasses(@Nullable final Path output) {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final URLClassLoader currentClassLoader = getLocalClassesLoader();
if (currentClassLoader != null) {
assetManager.removeClassLoader(currentClassLoader);
setLocalClassesLoader(null);
}
if (output == null || !Files.exists(output)) {
this.localClassesScanner = null;
return;
}
final Array<Path> folders = ArrayFactory.newArray(Path.class);
Utils.run(output, folders, (dir, toStore) -> {
final DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
stream.forEach(subFile -> {
if (Files.isDirectory(subFile)) {
toStore.add(subFile);
}
});
});
final URL[] urlArray = folders.stream()
.map(FileUtils::toUrl)
.toArray(URL[]::new);
final ClassLoader librariesLoader = getLocalLibrariesLoader();
final ClassLoader parent = librariesLoader == null? getClass().getClassLoader() : librariesLoader;
final URLClassLoader classLoader = new URLClassLoader(urlArray, parent);
assetManager.addClassLoader(classLoader);
setLocalClassesLoader(classLoader);
final ClassPathScanner scanner = ClassPathScannerFactory.newDefaultScanner(classLoader);
final Array<URL> urls = ArrayFactory.asArray(classLoader.getURLs());
final String[] paths = urls.stream().map(url -> Utils.get(url, URL::toURI))
.map(Paths::get)
.map(Path::toString)
.toArray(String[]::new);
scanner.addAdditionalPaths(paths);
scanner.setUseSystemClasspath(false);
scanner.scan();
this.localClassesScanner = scanner;
}