Add support for code resources in auxgroups.
Usage is as you might expect: auxgroups = foo foo.code = foo-code.jar foo.resource = foo-wontbeunpacked.jar foo.uresource = foo-willbeunpacked.jar
This commit is contained in:
@@ -225,6 +225,21 @@ public class Application
|
|||||||
public void updateStatus (String message);
|
public void updateStatus (String message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains metadata for an auxiliary resource group.
|
||||||
|
*/
|
||||||
|
public static class AuxGroup {
|
||||||
|
public final String name;
|
||||||
|
public final List<Resource> codes;
|
||||||
|
public final List<Resource> rsrcs;
|
||||||
|
|
||||||
|
public AuxGroup (String name, List<Resource> codes, List<Resource> rsrcs) {
|
||||||
|
this.name = name;
|
||||||
|
this.codes = Collections.unmodifiableList(codes);
|
||||||
|
this.rsrcs = Collections.unmodifiableList(rsrcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an application instance with no signers.
|
* Creates an application instance with no signers.
|
||||||
*
|
*
|
||||||
@@ -298,13 +313,21 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all auxiliary resource groups defined by the application. An auxiliary
|
* Returns the auxiliary resource group with the specified name, or null.
|
||||||
|
*/
|
||||||
|
public AuxGroup getAuxGroup (String name)
|
||||||
|
{
|
||||||
|
return _auxgroups.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the set of all auxiliary resource groups defined by the application. An auxiliary
|
||||||
* resource group is a collection of resource files that are not downloaded unless a group
|
* resource group is a collection of resource files that are not downloaded unless a group
|
||||||
* token file is present in the application directory.
|
* token file is present in the application directory.
|
||||||
*/
|
*/
|
||||||
public List<String> getAuxGroups ()
|
public Iterable<AuxGroup> getAuxGroups ()
|
||||||
{
|
{
|
||||||
return _auxgroups;
|
return _auxgroups.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,14 +348,18 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of the non-code {@link Resource} objects included in the specified auxiliary
|
* Returns all main code resources and all code resources from active auxiliary resource groups.
|
||||||
* resource group. If the group does not exist or has no resources, an empty list will be
|
|
||||||
* returned.
|
|
||||||
*/
|
*/
|
||||||
public List<Resource> getResources (String group)
|
public List<Resource> getActiveCodeResources ()
|
||||||
{
|
{
|
||||||
ArrayList<Resource> auxrsrcs = _auxrsrcs.get(group);
|
ArrayList<Resource> codes = new ArrayList<Resource>();
|
||||||
return (auxrsrcs == null) ? new ArrayList<Resource>() : auxrsrcs;
|
codes.addAll(getCodeResources());
|
||||||
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
|
if (isAuxGroupActive(aux.name)) {
|
||||||
|
codes.addAll(aux.codes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -342,9 +369,9 @@ public class Application
|
|||||||
{
|
{
|
||||||
ArrayList<Resource> rsrcs = new ArrayList<Resource>();
|
ArrayList<Resource> rsrcs = new ArrayList<Resource>();
|
||||||
rsrcs.addAll(getResources());
|
rsrcs.addAll(getResources());
|
||||||
for (String auxgroup : getAuxGroups()) {
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
if (isAuxGroupActive(auxgroup)) {
|
if (isAuxGroupActive(aux.name)) {
|
||||||
rsrcs.addAll(getResources(auxgroup));
|
rsrcs.addAll(aux.rsrcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rsrcs;
|
return rsrcs;
|
||||||
@@ -596,7 +623,6 @@ public class Application
|
|||||||
_codes.clear();
|
_codes.clear();
|
||||||
_resources.clear();
|
_resources.clear();
|
||||||
_auxgroups.clear();
|
_auxgroups.clear();
|
||||||
_auxrsrcs.clear();
|
|
||||||
_jvmargs.clear();
|
_jvmargs.clear();
|
||||||
_appargs.clear();
|
_appargs.clear();
|
||||||
_txtJvmArgs.clear();
|
_txtJvmArgs.clear();
|
||||||
@@ -613,11 +639,12 @@ public class Application
|
|||||||
|
|
||||||
// parse our auxiliary resource groups
|
// parse our auxiliary resource groups
|
||||||
for (String auxgroup : parseList(cdata, "auxgroups")) {
|
for (String auxgroup : parseList(cdata, "auxgroups")) {
|
||||||
|
ArrayList<Resource> codes = new ArrayList<Resource>();
|
||||||
|
parseResources(cdata, auxgroup + ".code", false, codes);
|
||||||
ArrayList<Resource> rsrcs = new ArrayList<Resource>();
|
ArrayList<Resource> rsrcs = new ArrayList<Resource>();
|
||||||
parseResources(cdata, auxgroup + ".resource", false, rsrcs);
|
parseResources(cdata, auxgroup + ".resource", false, rsrcs);
|
||||||
parseResources(cdata, auxgroup + ".uresource", true, rsrcs);
|
parseResources(cdata, auxgroup + ".uresource", true, rsrcs);
|
||||||
_auxrsrcs.put(auxgroup, rsrcs);
|
_auxgroups.put(auxgroup, new AuxGroup(auxgroup, codes, rsrcs));
|
||||||
_auxgroups.add(auxgroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer our JVM arguments
|
// transfer our JVM arguments
|
||||||
@@ -865,7 +892,7 @@ public class Application
|
|||||||
{
|
{
|
||||||
// create our classpath
|
// create our classpath
|
||||||
StringBuilder cpbuf = new StringBuilder();
|
StringBuilder cpbuf = new StringBuilder();
|
||||||
for (Resource rsrc : _codes) {
|
for (Resource rsrc : getActiveCodeResources()) {
|
||||||
if (cpbuf.length() > 0) {
|
if (cpbuf.length() > 0) {
|
||||||
cpbuf.append(File.pathSeparator);
|
cpbuf.append(File.pathSeparator);
|
||||||
}
|
}
|
||||||
@@ -972,7 +999,7 @@ public class Application
|
|||||||
{
|
{
|
||||||
// create a custom class loader
|
// create a custom class loader
|
||||||
ArrayList<URL> jars = new ArrayList<URL>();
|
ArrayList<URL> jars = new ArrayList<URL>();
|
||||||
for (Resource rsrc : _codes) {
|
for (Resource rsrc : getActiveCodeResources()) {
|
||||||
try {
|
try {
|
||||||
jars.add(new URL("file", "", rsrc.getLocal().getAbsolutePath()));
|
jars.add(new URL("file", "", rsrc.getLocal().getAbsolutePath()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1669,8 +1696,7 @@ public class Application
|
|||||||
protected List<Resource> _codes = new ArrayList<Resource>();
|
protected List<Resource> _codes = new ArrayList<Resource>();
|
||||||
protected List<Resource> _resources = new ArrayList<Resource>();
|
protected List<Resource> _resources = new ArrayList<Resource>();
|
||||||
|
|
||||||
protected List<String> _auxgroups = new ArrayList<String>();
|
protected Map<String,AuxGroup> _auxgroups = new HashMap<String,AuxGroup>();
|
||||||
protected Map<String,ArrayList<Resource>> _auxrsrcs = new HashMap<String,ArrayList<Resource>>();
|
|
||||||
protected Map<String,Boolean> _auxactive = new HashMap<String,Boolean>();
|
protected Map<String,Boolean> _auxactive = new HashMap<String,Boolean>();
|
||||||
|
|
||||||
protected List<String> _jvmargs = new ArrayList<String>();
|
protected List<String> _jvmargs = new ArrayList<String>();
|
||||||
@@ -1688,11 +1714,11 @@ public class Application
|
|||||||
/** If a warning has been issued about not being able to set modtimes. */
|
/** If a warning has been issued about not being able to set modtimes. */
|
||||||
protected boolean _warnedAboutSetLastModified;
|
protected boolean _warnedAboutSetLastModified;
|
||||||
|
|
||||||
protected static final String[] SA_PROTO = ArrayUtil.EMPTY_STRING;
|
|
||||||
|
|
||||||
/** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
|
/** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
|
||||||
protected FileLock _lock;
|
protected FileLock _lock;
|
||||||
|
|
||||||
/** Channel to the file underlying _lock. Kept around solely so the lock doesn't close. */
|
/** Channel to the file underlying _lock. Kept around solely so the lock doesn't close. */
|
||||||
protected FileChannel _lockChannel;
|
protected FileChannel _lockChannel;
|
||||||
|
|
||||||
|
protected static final String[] SA_PROTO = ArrayUtil.EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -654,9 +654,9 @@ public abstract class Getdown extends Thread
|
|||||||
list.add(patch);
|
list.add(patch);
|
||||||
|
|
||||||
// add the auxiliary group patch files for activated groups
|
// add the auxiliary group patch files for activated groups
|
||||||
for (String auxgroup : _app.getAuxGroups()) {
|
for (Application.AuxGroup aux : _app.getAuxGroups()) {
|
||||||
if (_app.isAuxGroupActive(auxgroup)) {
|
if (_app.isAuxGroupActive(aux.name)) {
|
||||||
patch = _app.getPatchResource(auxgroup);
|
patch = _app.getPatchResource(aux.name);
|
||||||
if (patch != null) {
|
if (patch != null) {
|
||||||
list.add(patch);
|
list.add(patch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,17 @@ public class Differ
|
|||||||
createPatch(patch, orsrcs, nrsrcs, verbose);
|
createPatch(patch, orsrcs, nrsrcs, verbose);
|
||||||
|
|
||||||
// next create patches for any auxiliary resource groups
|
// next create patches for any auxiliary resource groups
|
||||||
for (String auxgroup : napp.getAuxGroups()) {
|
for (Application.AuxGroup ag : napp.getAuxGroups()) {
|
||||||
orsrcs = new ArrayList<Resource>();
|
orsrcs = new ArrayList<Resource>();
|
||||||
orsrcs.addAll(oapp.getResources(auxgroup));
|
Application.AuxGroup oag = oapp.getAuxGroup(ag.name);
|
||||||
|
if (oag != null) {
|
||||||
|
orsrcs.addAll(oag.codes);
|
||||||
|
orsrcs.addAll(oag.rsrcs);
|
||||||
|
}
|
||||||
nrsrcs = new ArrayList<Resource>();
|
nrsrcs = new ArrayList<Resource>();
|
||||||
nrsrcs.addAll(napp.getResources(auxgroup));
|
nrsrcs.addAll(ag.codes);
|
||||||
patch = new File(nvdir, "patch-" + auxgroup + overs + ".dat");
|
nrsrcs.addAll(ag.rsrcs);
|
||||||
|
patch = new File(nvdir, "patch-" + ag.name + overs + ".dat");
|
||||||
createPatch(patch, orsrcs, nrsrcs, verbose);
|
createPatch(patch, orsrcs, nrsrcs, verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,8 +83,9 @@ public class Digester
|
|||||||
rsrcs.add(app.getConfigResource());
|
rsrcs.add(app.getConfigResource());
|
||||||
rsrcs.addAll(app.getCodeResources());
|
rsrcs.addAll(app.getCodeResources());
|
||||||
rsrcs.addAll(app.getResources());
|
rsrcs.addAll(app.getResources());
|
||||||
for (String auxgroup : app.getAuxGroups()) {
|
for (Application.AuxGroup ag : app.getAuxGroups()) {
|
||||||
rsrcs.addAll(app.getResources(auxgroup));
|
rsrcs.addAll(ag.codes);
|
||||||
|
rsrcs.addAll(ag.rsrcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now generate the digest file
|
// now generate the digest file
|
||||||
|
|||||||
Reference in New Issue
Block a user