Reorganized so that we notice bundle unpack failure and report the failure
to our bundle download observer. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2765 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ResourceManager.java,v 1.33 2003/08/09 00:31:14 mdb Exp $
|
// $Id: ResourceManager.java,v 1.34 2003/08/09 05:51:12 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.resource;
|
package com.threerings.resource;
|
||||||
|
|
||||||
@@ -353,8 +353,12 @@ public class ResourceManager
|
|||||||
final ResourceBundle bundle = createResourceBundle(
|
final ResourceBundle bundle = createResourceBundle(
|
||||||
DYNAMIC_BUNDLE_SET, path);
|
DYNAMIC_BUNDLE_SET, path);
|
||||||
if (bundle.isUnpacked()) {
|
if (bundle.isUnpacked()) {
|
||||||
bundle.sourceIsReady();
|
if (bundle.sourceIsReady()) {
|
||||||
listener.requestCompleted(bundle);
|
listener.requestCompleted(bundle);
|
||||||
|
} else {
|
||||||
|
String errmsg = "Bundle initialization failed.";
|
||||||
|
listener.requestFailed(new IOException(errmsg));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,10 +388,15 @@ public class ResourceManager
|
|||||||
|
|
||||||
public void downloadComplete ()
|
public void downloadComplete ()
|
||||||
{
|
{
|
||||||
bundle.sourceIsReady();
|
final boolean unpacked = bundle.sourceIsReady();
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
public void run () {
|
public void run () {
|
||||||
listener.requestCompleted(bundle);
|
if (unpacked) {
|
||||||
|
listener.requestCompleted(bundle);
|
||||||
|
} else {
|
||||||
|
String errmsg = "Bundle initialization failed.";
|
||||||
|
listener.requestFailed(new IOException(errmsg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -500,33 +509,45 @@ public class ResourceManager
|
|||||||
|
|
||||||
public void postDownloadHook () {
|
public void postDownloadHook () {
|
||||||
obs.unpacking();
|
obs.unpacking();
|
||||||
bundlesDownloaded();
|
_unpacked = bundlesDownloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadComplete () {
|
public void downloadComplete () {
|
||||||
obs.downloadComplete();
|
if (_unpacked) {
|
||||||
|
obs.downloadComplete();
|
||||||
|
} else {
|
||||||
|
String errmsg = "Bundle(s) failed initialization.";
|
||||||
|
obs.downloadFailed(new IOException(errmsg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadFailed (DownloadDescriptor desc, Exception e) {
|
public void downloadFailed (DownloadDescriptor desc, Exception e) {
|
||||||
obs.downloadFailed(e);
|
obs.downloadFailed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean _unpacked;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when our resource bundle downloads have completed.
|
* Called when our resource bundle downloads have completed.
|
||||||
|
*
|
||||||
|
* @return true if we are fully operational, false if one or more
|
||||||
|
* bundles failed to initialize.
|
||||||
*/
|
*/
|
||||||
protected void bundlesDownloaded ()
|
protected boolean bundlesDownloaded ()
|
||||||
{
|
{
|
||||||
// let our bundles know that it's ok for them to access their
|
// let our bundles know that it's ok for them to access their
|
||||||
// resource files
|
// resource files
|
||||||
Iterator iter = _sets.values().iterator();
|
Iterator iter = _sets.values().iterator();
|
||||||
|
boolean unpacked = true;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
ResourceBundle[] bundles = (ResourceBundle[])iter.next();
|
ResourceBundle[] bundles = (ResourceBundle[])iter.next();
|
||||||
for (int ii = 0; ii < bundles.length; ii++) {
|
for (int ii = 0; ii < bundles.length; ii++) {
|
||||||
bundles[ii].sourceIsReady();
|
unpacked = bundles[ii].sourceIsReady() && unpacked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user