If we encounter an error with a bundle while initializing the bundled
component repository, instruct the bundle to delete itself so that we will redownload it next time the application is initialized. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3043 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: BundleUtil.java,v 1.7 2004/02/25 14:39:34 mdb Exp $
|
||||
// $Id: BundleUtil.java,v 1.8 2004/07/03 03:25:48 mdb Exp $
|
||||
|
||||
package com.threerings.cast.bundle;
|
||||
|
||||
@@ -44,12 +44,19 @@ public class BundleUtil
|
||||
* Attempts to load an object from the supplied resource bundle with
|
||||
* the specified path.
|
||||
*
|
||||
* @param wipeBundleOnFailure if there is an error reading the object
|
||||
* from the bundle and this parameter is true, we will instruct the
|
||||
* bundle to delete its underlying jar file before propagating the
|
||||
* exception with the expectation that it will be redownloaded and
|
||||
* repaired the next time the application is run.
|
||||
*
|
||||
* @return the unserialized object in question.
|
||||
*
|
||||
* @exception IOException thrown if an I/O error occurs while reading
|
||||
* the object from the bundle.
|
||||
*/
|
||||
public static Object loadObject (ResourceBundle bundle, String path)
|
||||
public static Object loadObject (ResourceBundle bundle, String path,
|
||||
boolean wipeBundleOnFailure)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
InputStream bin = null;
|
||||
@@ -67,6 +74,17 @@ public class BundleUtil
|
||||
", error=" + ice.getMessage() + "].");
|
||||
return null;
|
||||
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Error reading resource from bundle " +
|
||||
"[bundle=" + bundle + ", path=" + path +
|
||||
", wiping?=" + wipeBundleOnFailure + "].");
|
||||
if (wipeBundleOnFailure) {
|
||||
StreamUtil.close(bin);
|
||||
bin = null;
|
||||
bundle.wipeBundle();
|
||||
}
|
||||
throw ioe;
|
||||
|
||||
} finally {
|
||||
StreamUtil.close(bin);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: BundledComponentRepository.java,v 1.30 2004/02/25 14:39:34 mdb Exp $
|
||||
// $Id: BundledComponentRepository.java,v 1.31 2004/07/03 03:25:48 mdb Exp $
|
||||
|
||||
package com.threerings.cast.bundle;
|
||||
|
||||
@@ -87,15 +87,15 @@ public class BundledComponentRepository
|
||||
for (int i = 0; i < rcount; i++) {
|
||||
if (_actions == null) {
|
||||
_actions = (HashMap)BundleUtil.loadObject(
|
||||
rbundles[i], BundleUtil.ACTIONS_PATH);
|
||||
rbundles[i], BundleUtil.ACTIONS_PATH, true);
|
||||
}
|
||||
if (_actionSets == null) {
|
||||
_actionSets = (HashMap)BundleUtil.loadObject(
|
||||
rbundles[i], BundleUtil.ACTION_SETS_PATH);
|
||||
rbundles[i], BundleUtil.ACTION_SETS_PATH, true);
|
||||
}
|
||||
if (_classes == null) {
|
||||
_classes = (HashMap)BundleUtil.loadObject(
|
||||
rbundles[i], BundleUtil.CLASSES_PATH);
|
||||
rbundles[i], BundleUtil.CLASSES_PATH, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class BundledComponentRepository
|
||||
for (int i = 0; i < rbundles.length; i++) {
|
||||
HashIntMap comps = null;
|
||||
comps = (HashIntMap)BundleUtil.loadObject(
|
||||
rbundles[i], BundleUtil.COMPONENTS_PATH);
|
||||
rbundles[i], BundleUtil.COMPONENTS_PATH, true);
|
||||
if (comps == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -299,12 +299,14 @@ public class BundledComponentRepository
|
||||
try {
|
||||
// then try loading up a tileset customized for this action
|
||||
if (aset == null) {
|
||||
aset = (TileSet)BundleUtil.loadObject(_bundle, cpath);
|
||||
aset = (TileSet)BundleUtil.loadObject(
|
||||
_bundle, cpath, false);
|
||||
}
|
||||
|
||||
// if that failed, try loading the default tileset
|
||||
if (aset == null) {
|
||||
aset = (TileSet)BundleUtil.loadObject(_bundle, dpath);
|
||||
aset = (TileSet)BundleUtil.loadObject(
|
||||
_bundle, dpath, false);
|
||||
_setcache.put(dpath, aset);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DumpBundle.java,v 1.2 2002/02/05 20:29:09 mdb Exp $
|
||||
// $Id: DumpBundle.java,v 1.3 2004/07/03 03:25:48 mdb Exp $
|
||||
|
||||
package com.threerings.cast.bundle.tools;
|
||||
|
||||
@@ -33,19 +33,19 @@ public class DumpBundle
|
||||
ResourceBundle bundle = new ResourceBundle(file);
|
||||
|
||||
HashMap actions = (HashMap)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.ACTIONS_PATH);
|
||||
bundle, BundleUtil.ACTIONS_PATH, false);
|
||||
dumpTable("actions: ", actions);
|
||||
|
||||
HashMap actionSets = (HashMap)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.ACTION_SETS_PATH);
|
||||
bundle, BundleUtil.ACTION_SETS_PATH, false);
|
||||
dumpTable("actionSets: ", actionSets);
|
||||
|
||||
HashMap classes = (HashMap)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.CLASSES_PATH);
|
||||
bundle, BundleUtil.CLASSES_PATH, false);
|
||||
dumpTable("classes: ", classes);
|
||||
|
||||
HashIntMap comps = (HashIntMap)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.COMPONENTS_PATH);
|
||||
bundle, BundleUtil.COMPONENTS_PATH, false);
|
||||
dumpTable("components: ", comps);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user