You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/05 12:02:43 UTC
svn commit: r544459 [6/36] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Tue Jun 5 05:02:27 2007
@@ -33,131 +33,144 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.util.Message;
-
/**
*/
public class IvyPatternHelper {
public static final String CONF_KEY = "conf";
+
public static final String TYPE_KEY = "type";
+
public static final String EXT_KEY = "ext";
+
public static final String ARTIFACT_KEY = "artifact";
+
public static final String BRANCH_KEY = "branch";
+
public static final String REVISION_KEY = "revision";
+
public static final String MODULE_KEY = "module";
+
public static final String ORGANISATION_KEY = "organisation";
+
public static final String ORGANISATION_KEY2 = "organization";
+
public static final String ORIGINAL_ARTIFACTNAME_KEY = "originalname";
-
+
private static final Pattern PARAM_PATTERN = Pattern.compile("\\@\\{(.*?)\\}");
+
private static final Pattern VAR_PATTERN = Pattern.compile("\\$\\{(.*?)\\}");
-
+
public static String substitute(String pattern, ModuleRevisionId moduleRevision) {
- return substitute(pattern,
- moduleRevision.getOrganisation(),
- moduleRevision.getName(),
- moduleRevision.getRevision(),
- "ivy",
- "ivy",
- "xml",
- null,
- moduleRevision.getAttributes());
- }
- public static String substitute(String pattern, ModuleRevisionId moduleRevision, String artifact, String type, String ext) {
- return substitute(pattern,
- moduleRevision,
- new DefaultArtifact(moduleRevision, null, artifact, type, ext),
- null);
+ return substitute(pattern, moduleRevision.getOrganisation(), moduleRevision.getName(),
+ moduleRevision.getRevision(), "ivy", "ivy", "xml", null, moduleRevision.getAttributes());
+ }
+
+ public static String substitute(String pattern, ModuleRevisionId moduleRevision,
+ String artifact, String type, String ext) {
+ return substitute(pattern, moduleRevision, new DefaultArtifact(moduleRevision, null,
+ artifact, type, ext), null);
}
+
public static String substitute(String pattern, Artifact artifact) {
return substitute(pattern, artifact, (String) null);
}
+
public static String substitute(String pattern, Artifact artifact, ArtifactOrigin origin) {
return substitute(pattern, artifact.getModuleRevisionId(), artifact, null, origin);
}
+
public static String substitute(String pattern, Artifact artifact, String conf) {
return substitute(pattern, artifact.getModuleRevisionId(), artifact, conf);
}
+
public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact) {
return substitute(pattern, mrid, artifact, null);
}
- public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact, String conf) {
- return substitute(pattern, mrid, artifact, conf, null);
+
+ public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact,
+ String conf) {
+ return substitute(pattern, mrid, artifact, conf, null);
}
-
- public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact, String conf, ArtifactOrigin origin) {
+
+ public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact,
+ String conf, ArtifactOrigin origin) {
Map attributes = new HashMap();
attributes.putAll(mrid.getAttributes());
attributes.putAll(artifact.getAttributes());
- return substitute(pattern,
- mrid.getOrganisation(),
- mrid.getName(),
- mrid.getBranch(),
- mrid.getRevision(),
- artifact.getName(),
- artifact.getType(),
- artifact.getExt(),
- conf,
- origin,
- attributes);
+ return substitute(pattern, mrid.getOrganisation(), mrid.getName(), mrid.getBranch(), mrid
+ .getRevision(), artifact.getName(), artifact.getType(), artifact.getExt(), conf,
+ origin, attributes);
}
-
- public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext) {
+ public static String substitute(String pattern, String org, String module, String revision,
+ String artifact, String type, String ext) {
return substitute(pattern, org, module, revision, artifact, type, ext, null);
}
-
- public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext, String conf) {
+
+ public static String substitute(String pattern, String org, String module, String revision,
+ String artifact, String type, String ext, String conf) {
return substitute(pattern, org, module, revision, artifact, type, ext, conf, null);
}
-
- public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext, String conf, Map extraAttributes) {
- return substitute(pattern, org, module, revision, artifact, type, ext, conf, null, extraAttributes);
- }
-
- public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext, String conf, ArtifactOrigin origin, Map extraAttributes) {
- return substitute(pattern, org, module, null, revision, artifact, type, ext, conf, origin, extraAttributes);
- }
- public static String substitute(String pattern, String org, String module, String branch, String revision, String artifact, String type, String ext, String conf, ArtifactOrigin origin, Map extraAttributes) {
- Map tokens = new HashMap(extraAttributes == null ? Collections.EMPTY_MAP : extraAttributes);
- tokens.put(ORGANISATION_KEY, org==null?"":org);
- tokens.put(ORGANISATION_KEY2, org==null?"":org);
- tokens.put(MODULE_KEY, module==null?"":module);
- tokens.put(BRANCH_KEY, branch==null?"":branch);
- tokens.put(REVISION_KEY, revision==null?"":revision);
- tokens.put(ARTIFACT_KEY, artifact==null?module:artifact);
- tokens.put(TYPE_KEY, type==null?"jar":type);
- tokens.put(EXT_KEY, ext==null?"jar":ext);
- tokens.put(CONF_KEY, conf==null?"default":conf);
- tokens.put(ORIGINAL_ARTIFACTNAME_KEY, origin==null?new OriginalArtifactNameValue(org, module, branch, revision, artifact, type, ext):new OriginalArtifactNameValue(origin));
+
+ public static String substitute(String pattern, String org, String module, String revision,
+ String artifact, String type, String ext, String conf, Map extraAttributes) {
+ return substitute(pattern, org, module, revision, artifact, type, ext, conf, null,
+ extraAttributes);
+ }
+
+ public static String substitute(String pattern, String org, String module, String revision,
+ String artifact, String type, String ext, String conf, ArtifactOrigin origin,
+ Map extraAttributes) {
+ return substitute(pattern, org, module, null, revision, artifact, type, ext, conf, origin,
+ extraAttributes);
+ }
+
+ public static String substitute(String pattern, String org, String module, String branch,
+ String revision, String artifact, String type, String ext, String conf,
+ ArtifactOrigin origin, Map extraAttributes) {
+ Map tokens = new HashMap(extraAttributes == null ? Collections.EMPTY_MAP : extraAttributes);
+ tokens.put(ORGANISATION_KEY, org == null ? "" : org);
+ tokens.put(ORGANISATION_KEY2, org == null ? "" : org);
+ tokens.put(MODULE_KEY, module == null ? "" : module);
+ tokens.put(BRANCH_KEY, branch == null ? "" : branch);
+ tokens.put(REVISION_KEY, revision == null ? "" : revision);
+ tokens.put(ARTIFACT_KEY, artifact == null ? module : artifact);
+ tokens.put(TYPE_KEY, type == null ? "jar" : type);
+ tokens.put(EXT_KEY, ext == null ? "jar" : ext);
+ tokens.put(CONF_KEY, conf == null ? "default" : conf);
+ tokens.put(ORIGINAL_ARTIFACTNAME_KEY, origin == null ? new OriginalArtifactNameValue(org,
+ module, branch, revision, artifact, type, ext) : new OriginalArtifactNameValue(
+ origin));
return substituteTokens(pattern, tokens);
}
-
+
public static String substitute(String pattern, Map variables, Map tokens) {
return substituteTokens(substituteVariables(pattern, variables), tokens);
}
-
+
public static String substituteVariables(String pattern, Map variables) {
return substituteVariables(pattern, variables, new Stack());
}
-
+
private static String substituteVariables(String pattern, Map variables, Stack substituting) {
// if you supply null, null is what you get
if (pattern == null) {
return null;
}
-
+
Matcher m = VAR_PATTERN.matcher(pattern);
-
+
StringBuffer sb = new StringBuffer();
while (m.find()) {
String var = m.group(1);
- String val = (String)variables.get(var);
+ String val = (String) variables.get(var);
if (val != null) {
int index;
if ((index = substituting.indexOf(var)) != -1) {
List cycle = new ArrayList(substituting.subList(index, substituting.size()));
cycle.add(var);
- throw new IllegalArgumentException("cyclic variable definition: cycle = "+cycle);
+ throw new IllegalArgumentException("cyclic variable definition: cycle = "
+ + cycle);
}
substituting.push(var);
val = substituteVariables(val, variables, substituting);
@@ -165,123 +178,133 @@
} else {
val = m.group();
}
- m.appendReplacement(sb, val.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\$", "\\\\\\$"));
+ m
+ .appendReplacement(sb, val.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\$",
+ "\\\\\\$"));
}
m.appendTail(sb);
return sb.toString();
}
-
+
public static String substituteTokens(String pattern, Map tokens) {
StringBuffer buffer = new StringBuffer();
-
+
char[] chars = pattern.toCharArray();
-
+
StringBuffer optionalPart = null;
StringBuffer tokenBuffer = null;
boolean insideOptionalPart = false;
boolean insideToken = false;
boolean tokenHadValue = false;
-
+
for (int i = 0; i < chars.length; i++) {
switch (chars[i]) {
- case '(':
- if (insideOptionalPart) {
- throw new IllegalArgumentException("invalid start of optional part at position " + i + " in pattern " + pattern);
- }
+ case '(':
+ if (insideOptionalPart) {
+ throw new IllegalArgumentException(
+ "invalid start of optional part at position " + i + " in pattern "
+ + pattern);
+ }
- optionalPart = new StringBuffer();
- insideOptionalPart = true;
- tokenHadValue = false;
- break;
-
- case ')':
- if (!insideOptionalPart || insideToken) {
- throw new IllegalArgumentException("invalid end of optional part at position " + i + " in pattern " + pattern);
- }
+ optionalPart = new StringBuffer();
+ insideOptionalPart = true;
+ tokenHadValue = false;
+ break;
+
+ case ')':
+ if (!insideOptionalPart || insideToken) {
+ throw new IllegalArgumentException(
+ "invalid end of optional part at position " + i + " in pattern "
+ + pattern);
+ }
- if (tokenHadValue) {
- buffer.append(optionalPart.toString());
- }
+ if (tokenHadValue) {
+ buffer.append(optionalPart.toString());
+ }
- insideOptionalPart = false;
- break;
-
- case '[':
- if (insideToken) {
- throw new IllegalArgumentException("invalid start of token at position " + i + " in pattern " + pattern);
- }
-
- tokenBuffer = new StringBuffer();
- insideToken = true;
- break;
-
- case ']':
- if (!insideToken) {
- throw new IllegalArgumentException("invalid end of token at position " + i + " in pattern " + pattern);
- }
-
- String token = tokenBuffer.toString();
- Object tokenValue = tokens.get(token);
- String value = (tokenValue == null) ? null : tokenValue.toString();
-
- if (insideOptionalPart) {
- tokenHadValue = (value != null) && (value.length() > 0);
- optionalPart.append(value);
- } else {
- if (value == null) { // the token wasn't set, it's kept as is
- value = "["+token+"]";
+ insideOptionalPart = false;
+ break;
+
+ case '[':
+ if (insideToken) {
+ throw new IllegalArgumentException("invalid start of token at position "
+ + i + " in pattern " + pattern);
}
- buffer.append(value);
- }
-
- insideToken = false;
- break;
-
- default:
- if (insideToken) {
- tokenBuffer.append(chars[i]);
- } else if (insideOptionalPart) {
- optionalPart.append(chars[i]);
- } else {
- buffer.append(chars[i]);
- }
-
- break;
+
+ tokenBuffer = new StringBuffer();
+ insideToken = true;
+ break;
+
+ case ']':
+ if (!insideToken) {
+ throw new IllegalArgumentException("invalid end of token at position " + i
+ + " in pattern " + pattern);
+ }
+
+ String token = tokenBuffer.toString();
+ Object tokenValue = tokens.get(token);
+ String value = (tokenValue == null) ? null : tokenValue.toString();
+
+ if (insideOptionalPart) {
+ tokenHadValue = (value != null) && (value.length() > 0);
+ optionalPart.append(value);
+ } else {
+ if (value == null) { // the token wasn't set, it's kept as is
+ value = "[" + token + "]";
+ }
+ buffer.append(value);
+ }
+
+ insideToken = false;
+ break;
+
+ default:
+ if (insideToken) {
+ tokenBuffer.append(chars[i]);
+ } else if (insideOptionalPart) {
+ optionalPart.append(chars[i]);
+ } else {
+ buffer.append(chars[i]);
+ }
+
+ break;
}
}
-
+
if (insideToken) {
- throw new IllegalArgumentException("last token hasn't been closed in pattern " + pattern);
+ throw new IllegalArgumentException("last token hasn't been closed in pattern "
+ + pattern);
}
-
+
if (insideOptionalPart) {
- throw new IllegalArgumentException("optional part hasn't been closed in pattern " + pattern);
+ throw new IllegalArgumentException("optional part hasn't been closed in pattern "
+ + pattern);
}
-
+
return buffer.toString();
}
-
+
public static String substituteVariable(String pattern, String variable, String value) {
StringBuffer buf = new StringBuffer(pattern);
substituteVariable(buf, variable, value);
return buf.toString();
}
-
+
public static void substituteVariable(StringBuffer buf, String variable, String value) {
- String from = "${"+variable+"}";
+ String from = "${" + variable + "}";
int fromLength = from.length();
for (int index = buf.indexOf(from); index != -1; index = buf.indexOf(from, index)) {
buf.replace(index, index + fromLength, value);
}
}
-
+
public static String substituteToken(String pattern, String token, String value) {
StringBuffer buf = new StringBuffer(pattern);
substituteToken(buf, token, value);
return buf.toString();
}
-
+
public static void substituteToken(StringBuffer buf, String token, String value) {
String from = getTokenString(token);
int fromLength = from.length();
@@ -289,33 +312,34 @@
buf.replace(index, index + fromLength, value);
}
}
+
public static String getTokenString(String token) {
- return "["+token+"]";
+ return "[" + token + "]";
}
-
+
public static String substituteParams(String pattern, Map params) {
return substituteParams(pattern, params, new Stack());
}
-
+
private static String substituteParams(String pattern, Map params, Stack substituting) {
- //TODO : refactor this with substituteVariables
+ // TODO : refactor this with substituteVariables
// if you supply null, null is what you get
if (pattern == null) {
return null;
}
-
+
Matcher m = PARAM_PATTERN.matcher(pattern);
-
+
StringBuffer sb = new StringBuffer();
while (m.find()) {
String var = m.group(1);
- String val = (String)params.get(var);
+ String val = (String) params.get(var);
if (val != null) {
int index;
if ((index = substituting.indexOf(var)) != -1) {
List cycle = new ArrayList(substituting.subList(index, substituting.size()));
cycle.add(var);
- throw new IllegalArgumentException("cyclic param definition: cycle = "+cycle);
+ throw new IllegalArgumentException("cyclic param definition: cycle = " + cycle);
}
substituting.push(var);
val = substituteVariables(val, params, substituting);
@@ -323,98 +347,109 @@
} else {
val = m.group();
}
- m.appendReplacement(sb, val.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\@", "\\\\\\@"));
+ m
+ .appendReplacement(sb, val.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\@",
+ "\\\\\\@"));
}
m.appendTail(sb);
return sb.toString();
}
-
+
public static void main(String[] args) {
String pattern = "[organisation]/[module]/build/archives/[type]s/[artifact]-[revision].[ext]";
- System.out.println("pattern= "+pattern);
- System.out.println("resolved= "+substitute(pattern, "apache", "Test", "1.0", "test", "jar", "jar"));
-
+ System.out.println("pattern= " + pattern);
+ System.out.println("resolved= "
+ + substitute(pattern, "apache", "Test", "1.0", "test", "jar", "jar"));
+
Map variables = new HashMap();
variables.put("test", "mytest");
variables.put("test2", "${test}2");
pattern = "${test} ${test2} ${nothing}";
- System.out.println("pattern= "+pattern);
- System.out.println("resolved= "+substituteVariables(pattern, variables));
+ System.out.println("pattern= " + pattern);
+ System.out.println("resolved= " + substituteVariables(pattern, variables));
}
-
+
/**
* This class returns the original name of the artifact 'on demand'. This is done to avoid
* having to read the cached datafile containing the original location of the artifact if we
* don't need it.
*/
private static class OriginalArtifactNameValue {
- // module properties
- private String org;
- private String moduleName;
- private String branch;
- private String revision;
-
- // artifact properties
- private String artifactName;
- private String artifactType;
- private String artifactExt;
-
- // cached origin;
- private ArtifactOrigin origin;
-
- public OriginalArtifactNameValue(String org, String moduleName, String branch, String revision, String artifactName, String artifactType, String artifactExt) {
- this.org = org;
- this.moduleName = moduleName;
- this.branch = branch;
- this.revision = revision;
- this.artifactName = artifactName;
- this.artifactType = artifactType;
- this.artifactExt = artifactExt;
- }
-
-
- /**
- * @param origin
- */
- public OriginalArtifactNameValue(ArtifactOrigin origin) {
- this.origin = origin;
- }
-
- // Called by substituteTokens only if the original artifact name is needed
- public String toString() {
- if (origin == null) {
- ModuleRevisionId revId = ModuleRevisionId.newInstance(org, moduleName, branch, revision);
- Artifact artifact = new DefaultArtifact(revId, null, artifactName, artifactType, artifactExt);
-
- CacheManager cacheManager = IvyContext.getContext().getCacheManager();
-
- origin = cacheManager.getSavedArtifactOrigin(artifact);
+ // module properties
+ private String org;
+
+ private String moduleName;
+
+ private String branch;
+
+ private String revision;
+
+ // artifact properties
+ private String artifactName;
+
+ private String artifactType;
+
+ private String artifactExt;
+
+ // cached origin;
+ private ArtifactOrigin origin;
+
+ public OriginalArtifactNameValue(String org, String moduleName, String branch,
+ String revision, String artifactName, String artifactType, String artifactExt) {
+ this.org = org;
+ this.moduleName = moduleName;
+ this.branch = branch;
+ this.revision = revision;
+ this.artifactName = artifactName;
+ this.artifactType = artifactType;
+ this.artifactExt = artifactExt;
+ }
+
+ /**
+ * @param origin
+ */
+ public OriginalArtifactNameValue(ArtifactOrigin origin) {
+ this.origin = origin;
+ }
+
+ // Called by substituteTokens only if the original artifact name is needed
+ public String toString() {
+ if (origin == null) {
+ ModuleRevisionId revId = ModuleRevisionId.newInstance(org, moduleName, branch,
+ revision);
+ Artifact artifact = new DefaultArtifact(revId, null, artifactName, artifactType,
+ artifactExt);
+
+ CacheManager cacheManager = IvyContext.getContext().getCacheManager();
+
+ origin = cacheManager.getSavedArtifactOrigin(artifact);
if (origin == null) {
- Message.debug("no artifact origin found for "+artifact+" in "+cacheManager);
- return null;
- }
- }
-
- // we assume that the original filename is the last part of the original file location
- String location = origin.getLocation();
- int lastPathIndex = location.lastIndexOf('/');
- if (lastPathIndex == -1) {
- lastPathIndex = location.lastIndexOf('\\');
- }
- int lastColonIndex = location.lastIndexOf('.');
-
- return location.substring(lastPathIndex + 1, lastColonIndex);
- }
- }
-
- public static String getTokenRoot(String pattern) {
- int index = pattern.indexOf('[');
- if (index == -1) {
- return pattern;
- } else {
- return pattern.substring(0, index);
- }
- }
+ Message.debug("no artifact origin found for " + artifact + " in "
+ + cacheManager);
+ return null;
+ }
+ }
+
+ // we assume that the original filename is the last part of the original file location
+ String location = origin.getLocation();
+ int lastPathIndex = location.lastIndexOf('/');
+ if (lastPathIndex == -1) {
+ lastPathIndex = location.lastIndexOf('\\');
+ }
+ int lastColonIndex = location.lastIndexOf('.');
+
+ return location.substring(lastPathIndex + 1, lastColonIndex);
+ }
+ }
+
+ public static String getTokenRoot(String pattern) {
+ int index = pattern.indexOf('[');
+ if (index == -1) {
+ return pattern;
+ } else {
+ return pattern.substring(0, index);
+ }
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyThread.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyThread.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyThread.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyThread.java Tue Jun 5 05:02:27 2007
@@ -17,56 +17,54 @@
*/
package org.apache.ivy.core;
-
/**
- * A simple thread subclass associated the same IvyContext as the thread in which it is instanciated.
- *
- * If you override the run target, then you will have to call initContext() to do the association
- * with the original IvyContext.
+ * A simple thread subclass associated the same IvyContext as the thread in which it is
+ * instanciated. If you override the run target, then you will have to call initContext() to do the
+ * association with the original IvyContext.
*
* @see IvyContext
*/
public class IvyThread extends Thread {
- private IvyContext context = IvyContext.getContext();
+ private IvyContext context = IvyContext.getContext();
- public IvyThread() {
- super();
- }
-
- public IvyThread(Runnable target, String name) {
- super(target, name);
- }
-
- public IvyThread(Runnable target) {
- super(target);
- }
-
- public IvyThread(String name) {
- super(name);
- }
-
- public IvyThread(ThreadGroup group, Runnable target, String name, long stackSize) {
- super(group, target, name, stackSize);
- }
-
- public IvyThread(ThreadGroup group, Runnable target, String name) {
- super(group, target, name);
- }
-
- public IvyThread(ThreadGroup group, Runnable target) {
- super(group, target);
- }
-
- public IvyThread(ThreadGroup group, String name) {
- super(group, name);
- }
-
- public void run() {
- initContext();
- super.run();
- }
-
- protected void initContext() {
- IvyContext.setContext(context);
- }
+ public IvyThread() {
+ super();
+ }
+
+ public IvyThread(Runnable target, String name) {
+ super(target, name);
+ }
+
+ public IvyThread(Runnable target) {
+ super(target);
+ }
+
+ public IvyThread(String name) {
+ super(name);
+ }
+
+ public IvyThread(ThreadGroup group, Runnable target, String name, long stackSize) {
+ super(group, target, name, stackSize);
+ }
+
+ public IvyThread(ThreadGroup group, Runnable target, String name) {
+ super(group, target, name);
+ }
+
+ public IvyThread(ThreadGroup group, Runnable target) {
+ super(group, target);
+ }
+
+ public IvyThread(ThreadGroup group, String name) {
+ super(group, name);
+ }
+
+ public void run() {
+ initContext();
+ super.run();
+ }
+
+ protected void initContext() {
+ IvyContext.setContext(context);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java Tue Jun 5 05:02:27 2007
@@ -19,54 +19,63 @@
/**
* This class contains information about the origin of an artifact.
+ *
* @see org.apache.ivy.plugins.resolver.BasicResolver
* @see org.apache.ivy.plugins.resolver.util.ResolvedResource
*/
-public class ArtifactOrigin {
+public class ArtifactOrigin {
private boolean isLocal;
- private String location;
+
+ private String location;
/**
- * Create a new instance
+ * Create a new instance
*
- * @param isLocal <code>boolean</code> value indicating if the resource is local (on the filesystem).
- * @param location the location of the resource (normally a url)
+ * @param isLocal
+ * <code>boolean</code> value indicating if the resource is local (on the
+ * filesystem).
+ * @param location
+ * the location of the resource (normally a url)
*/
public ArtifactOrigin(boolean isLocal, String location) {
- this.isLocal = isLocal;
- this.location = location;
- }
+ this.isLocal = isLocal;
+ this.location = location;
+ }
/**
* Is this resource local to this host, i.e. is it on the file system?
- *
+ *
* @return <code>boolean</code> value indicating if the resource is local.
*/
public boolean isLocal() {
- return isLocal;
- }
+ return isLocal;
+ }
/**
* Return the location of the resource (normally a url)
- *
+ *
* @return the location of the resource
*/
public String getLocation() {
- return location;
- }
+ return location;
+ }
public String toString() {
return "ArtifactOrigin { isLocal=" + isLocal + ", location=" + location + "}";
}
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
ArtifactOrigin that = (ArtifactOrigin) o;
- if (isLocal != that.isLocal) return false;
- if (!location.equals(that.location)) return false;
+ if (isLocal != that.isLocal)
+ return false;
+ if (!location.equals(that.location))
+ return false;
return true;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java Tue Jun 5 05:02:27 2007
@@ -34,95 +34,95 @@
import org.apache.ivy.util.PropertiesFile;
public class CacheManager {
- public static CacheManager getInstance(IvySettings settings, File cache) {
- return new CacheManager(settings, cache);
- }
-
- public static CacheManager getInstance(IvySettings settings) {
- return getInstance(settings, settings.getDefaultCache());
- }
-
- private IvySettings settings;
- private File cache;
+ public static CacheManager getInstance(IvySettings settings, File cache) {
+ return new CacheManager(settings, cache);
+ }
+
+ public static CacheManager getInstance(IvySettings settings) {
+ return getInstance(settings, settings.getDefaultCache());
+ }
+
+ private IvySettings settings;
+
+ private File cache;
public CacheManager(IvySettings settings, File cache) {
- this.settings = settings;
- this.cache = cache;
- }
+ this.settings = settings;
+ this.cache = cache;
+ }
- public File getResolvedIvyFileInCache(ModuleRevisionId mrid) {
- String file = IvyPatternHelper.substitute(settings.getCacheResolvedIvyPattern(), mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml");
+ public File getResolvedIvyFileInCache(ModuleRevisionId mrid) {
+ String file = IvyPatternHelper.substitute(settings.getCacheResolvedIvyPattern(), mrid
+ .getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml");
return new File(cache, file);
}
public File getResolvedIvyPropertiesInCache(ModuleRevisionId mrid) {
- String file = IvyPatternHelper.substitute(settings.getCacheResolvedIvyPropertiesPattern(), mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml");
+ String file = IvyPatternHelper.substitute(settings.getCacheResolvedIvyPropertiesPattern(),
+ mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml");
return new File(cache, file);
}
public File getIvyFileInCache(ModuleRevisionId mrid) {
- String file = IvyPatternHelper.substitute(settings.getCacheIvyPattern(), DefaultArtifact.newIvyArtifact(mrid, null));
+ String file = IvyPatternHelper.substitute(settings.getCacheIvyPattern(), DefaultArtifact
+ .newIvyArtifact(mrid, null));
return new File(cache, file);
}
-
+
public File getConfigurationResolveReportInCache(String resolveId, String conf) {
- return new File(cache, resolveId + "-" + conf + ".xml");
+ return new File(cache, resolveId + "-" + conf + ".xml");
}
-
+
public File[] getConfigurationResolveReportsInCache(final String resolveId) {
- final String prefix = resolveId + "-";
- final String suffix = ".xml";
- return cache.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return (name.startsWith(prefix) && name.endsWith(suffix));
- }
- });
+ final String prefix = resolveId + "-";
+ final String suffix = ".xml";
+ return cache.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return (name.startsWith(prefix) && name.endsWith(suffix));
+ }
+ });
}
/**
* Returns a File object pointing to where the artifact can be found on the local file system.
- * This is usually in the cache, but it can be directly in the repository if it is local
- * and if the resolve has been done with useOrigin = true
- *
+ * This is usually in the cache, but it can be directly in the repository if it is local and if
+ * the resolve has been done with useOrigin = true
*/
public File getArchiveFileInCache(Artifact artifact) {
- ArtifactOrigin origin = getSavedArtifactOrigin(artifact);
- return getArchiveFileInCache(artifact, origin);
+ ArtifactOrigin origin = getSavedArtifactOrigin(artifact);
+ return getArchiveFileInCache(artifact, origin);
}
-
+
/**
* Returns a File object pointing to where the artifact can be found on the local file system.
- * This is usually in the cache, but it can be directly in the repository if it is local
- * and if the resolve has been done with useOrigin = true
- *
+ * This is usually in the cache, but it can be directly in the repository if it is local and if
+ * the resolve has been done with useOrigin = true
*/
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin) {
- File archive = new File(cache, getArchivePathInCache(artifact, origin));
- if (!archive.exists() && origin != null && origin.isLocal()) {
- File original = new File(origin.getLocation());
- if (original.exists()) {
- return original;
- }
- }
- return archive;
+ File archive = new File(cache, getArchivePathInCache(artifact, origin));
+ if (!archive.exists() && origin != null && origin.isLocal()) {
+ File original = new File(origin.getLocation());
+ if (original.exists()) {
+ return original;
+ }
+ }
+ return archive;
}
+
/**
* Returns a File object pointing to where the artifact can be found on the local file system,
- * using or not the original location depending on the availability of origin information provided
- * as parameter and the setting of useOrigin.
- *
- * If useOrigin is false, this method will always return the file in the cache.
- *
+ * using or not the original location depending on the availability of origin information
+ * provided as parameter and the setting of useOrigin. If useOrigin is false, this method will
+ * always return the file in the cache.
*/
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
- if (useOrigin && origin != null && origin.isLocal()) {
- return new File(origin.getLocation());
- } else {
- return new File(cache, getArchivePathInCache(artifact, origin));
- }
+ if (useOrigin && origin != null && origin.isLocal()) {
+ return new File(origin.getLocation());
+ } else {
+ return new File(cache, getArchivePathInCache(artifact, origin));
+ }
}
-
-
+
public String getArchivePathInCache(Artifact artifact) {
return IvyPatternHelper.substitute(settings.getCacheArtifactPattern(), artifact);
}
@@ -132,11 +132,13 @@
}
/**
- * Saves the information of which resolver was used to resolve a md,
- * so that this info can be retrieve later (even after a jvm restart)
- * by getSavedResolverName(ModuleDescriptor md)
- * @param md the module descriptor resolved
- * @param name resolver name
+ * Saves the information of which resolver was used to resolve a md, so that this info can be
+ * retrieve later (even after a jvm restart) by getSavedResolverName(ModuleDescriptor md)
+ *
+ * @param md
+ * the module descriptor resolved
+ * @param name
+ * resolver name
*/
public void saveResolver(ModuleDescriptor md, String name) {
PropertiesFile cdf = getCachedDataFile(md);
@@ -145,39 +147,41 @@
}
/**
- * Saves the information of which resolver was used to resolve a md,
- * so that this info can be retrieve later (even after a jvm restart)
- * by getSavedArtResolverName(ModuleDescriptor md)
- * @param md the module descriptor resolved
- * @param name artifact resolver name
+ * Saves the information of which resolver was used to resolve a md, so that this info can be
+ * retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md)
+ *
+ * @param md
+ * the module descriptor resolved
+ * @param name
+ * artifact resolver name
*/
public void saveArtResolver(ModuleDescriptor md, String name) {
PropertiesFile cdf = getCachedDataFile(md);
cdf.setProperty("artifact.resolver", name);
cdf.save();
}
-
+
public void saveArtifactOrigin(Artifact artifact, ArtifactOrigin origin) {
- PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
- cdf.setProperty(getIsLocalKey(artifact), String.valueOf(origin.isLocal()));
- cdf.setProperty(getLocationKey(artifact), origin.getLocation());
- cdf.save();
+ PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
+ cdf.setProperty(getIsLocalKey(artifact), String.valueOf(origin.isLocal()));
+ cdf.setProperty(getLocationKey(artifact), origin.getLocation());
+ cdf.save();
}
-
+
public ArtifactOrigin getSavedArtifactOrigin(Artifact artifact) {
PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
String location = cdf.getProperty(getLocationKey(artifact));
String local = cdf.getProperty(getIsLocalKey(artifact));
boolean isLocal = Boolean.valueOf(local).booleanValue();
-
+
if (location == null) {
- // origin has not been specified, return null
- return null;
+ // origin has not been specified, return null
+ return null;
}
-
+
return new ArtifactOrigin(isLocal, location);
}
-
+
public void removeSavedArtifactOrigin(Artifact artifact) {
PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
cdf.remove(getLocationKey(artifact));
@@ -187,19 +191,24 @@
/**
* Creates the unique prefix key that will reference the artifact within the properties.
- * @param artifact the artifact to create the unique key from. Cannot be null.
+ *
+ * @param artifact
+ * the artifact to create the unique key from. Cannot be null.
* @return the unique prefix key as a string.
*/
private String getPrefixKey(Artifact artifact) {
- // use the hashcode as a uuid for the artifact (fingers crossed)
+ // use the hashcode as a uuid for the artifact (fingers crossed)
int hashCode = artifact.getId().hashCode();
// use just some visual cue
- return "artifact:" + artifact.getName() + "#" + artifact.getType() + "#" + artifact.getExt() + "#" + hashCode;
+ return "artifact:" + artifact.getName() + "#" + artifact.getType() + "#"
+ + artifact.getExt() + "#" + hashCode;
}
/**
* Returns the key used to identify the location of the artifact.
- * @param artifact the artifact to generate the key from. Cannot be null.
+ *
+ * @param artifact
+ * the artifact to generate the key from. Cannot be null.
* @return the key to be used to reference the artifact location.
*/
private String getLocationKey(Artifact artifact) {
@@ -209,7 +218,9 @@
/**
* Returns the key used to identify if the artifact is local.
- * @param artifact the artifact to generate the key from. Cannot be null.
+ *
+ * @param artifact
+ * the artifact to generate the key from. Cannot be null.
* @return the key to be used to reference the artifact location.
*/
private String getIsLocalKey(Artifact artifact) {
@@ -228,11 +239,12 @@
}
private PropertiesFile getCachedDataFile(ModuleDescriptor md) {
- return getCachedDataFile(md.getResolvedModuleRevisionId());
+ return getCachedDataFile(md.getResolvedModuleRevisionId());
}
-
+
private PropertiesFile getCachedDataFile(ModuleRevisionId mRevId) {
- return new PropertiesFile(new File(cache, IvyPatternHelper.substitute(settings.getCacheDataFilePattern(),mRevId)), "ivy cached data file for "+mRevId);
+ return new PropertiesFile(new File(cache, IvyPatternHelper.substitute(settings
+ .getCacheDataFilePattern(), mRevId)), "ivy cached data file for " + mRevId);
}
public ResolvedModuleRevision findModuleInCache(ModuleRevisionId mrid, boolean validate) {
@@ -242,15 +254,20 @@
if (ivyFile.exists()) {
// found in cache !
try {
- ModuleDescriptor depMD = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFile.toURL(), validate);
+ ModuleDescriptor depMD = XmlModuleDescriptorParser.getInstance()
+ .parseDescriptor(settings, ivyFile.toURL(), validate);
String resolverName = getSavedResolverName(depMD);
String artResolverName = getSavedArtResolverName(depMD);
DependencyResolver resolver = settings.getResolver(resolverName);
if (resolver == null) {
- Message.debug("\tresolver not found: "+resolverName+" => trying to use the one configured for "+mrid);
- resolver = settings.getResolver(depMD.getResolvedModuleRevisionId().getModuleId());
+ Message.debug("\tresolver not found: " + resolverName
+ + " => trying to use the one configured for " + mrid);
+ resolver = settings.getResolver(depMD.getResolvedModuleRevisionId()
+ .getModuleId());
if (resolver != null) {
- Message.debug("\tconfigured resolver found for "+depMD.getResolvedModuleRevisionId()+": "+resolver.getName()+": saving this data");
+ Message.debug("\tconfigured resolver found for "
+ + depMD.getResolvedModuleRevisionId() + ": "
+ + resolver.getName() + ": saving this data");
saveResolver(depMD, resolver.getName());
}
}
@@ -259,29 +276,32 @@
artResolver = resolver;
}
if (resolver != null) {
- Message.debug("\tfound ivy file in cache for "+mrid+" (resolved by "+resolver.getName()+"): "+ivyFile);
- return new DefaultModuleRevision(resolver, artResolver, depMD, false, false, ivyFile.toURL());
+ Message.debug("\tfound ivy file in cache for " + mrid + " (resolved by "
+ + resolver.getName() + "): " + ivyFile);
+ return new DefaultModuleRevision(resolver, artResolver, depMD, false,
+ false, ivyFile.toURL());
} else {
- Message.debug("\tresolver not found: "+resolverName+" => cannot use cached ivy file for "+mrid);
+ Message.debug("\tresolver not found: " + resolverName
+ + " => cannot use cached ivy file for " + mrid);
}
} catch (Exception e) {
// will try with resolver
- Message.debug("\tproblem while parsing cached ivy file for: "+mrid+": "+e.getMessage());
+ Message.debug("\tproblem while parsing cached ivy file for: " + mrid + ": "
+ + e.getMessage());
}
} else {
- Message.debug("\tno ivy file in cache for "+mrid+": tried "+ivyFile);
+ Message.debug("\tno ivy file in cache for " + mrid + ": tried " + ivyFile);
}
}
return null;
}
-
public String toString() {
- return "cache: "+String.valueOf(cache);
+ return "cache: " + String.valueOf(cache);
}
- public File getCache() {
- return cache;
- }
+ public File getCache() {
+ return cache;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java Tue Jun 5 05:02:27 2007
@@ -39,30 +39,29 @@
import org.apache.ivy.util.Message;
public class CheckEngine {
- private IvySettings settings;
- private ResolveEngine resolveEngine;
-
-
- public CheckEngine(IvySettings settings, ResolveEngine resolveEngine) {
- this.settings = settings;
- this.resolveEngine = resolveEngine;
- }
+ private IvySettings settings;
+ private ResolveEngine resolveEngine;
+ public CheckEngine(IvySettings settings, ResolveEngine resolveEngine) {
+ this.settings = settings;
+ this.resolveEngine = resolveEngine;
+ }
- /**
- * Checks the given ivy file using current settings to see if all dependencies
- * are available, with good confs. If a resolver name is given, it also checks that the declared
- * publications are available in the corresponding resolver.
- * Note that the check is not performed recursively, i.e. if a dependency has itself dependencies
- * badly described or not available, this check will not discover it.
+ /**
+ * Checks the given ivy file using current settings to see if all dependencies are available,
+ * with good confs. If a resolver name is given, it also checks that the declared publications
+ * are available in the corresponding resolver. Note that the check is not performed
+ * recursively, i.e. if a dependency has itself dependencies badly described or not available,
+ * this check will not discover it.
*/
public boolean check(URL ivyFile, String resolvername) {
try {
boolean result = true;
// parse ivy file
- ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(settings, ivyFile, settings.doValidate());
-
+ ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
+ settings, ivyFile, settings.doValidate());
+
// check publications if possible
if (resolvername != null) {
DependencyResolver resolver = settings.getResolver(resolvername);
@@ -72,23 +71,27 @@
artifacts.addAll(Arrays.asList(md.getArtifacts(confs[i])));
}
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact art = (Artifact)iter.next();
+ Artifact art = (Artifact) iter.next();
if (!resolver.exists(art)) {
- Message.info("declared publication not found: "+art);
+ Message.info("declared publication not found: " + art);
result = false;
}
}
}
-
+
// check dependencies
DependencyDescriptor[] dds = md.getDependencies();
- ResolveData data = new ResolveData(resolveEngine, new ResolveOptions().setCache(CacheManager.getInstance(settings)));
+ ResolveData data = new ResolveData(resolveEngine, new ResolveOptions()
+ .setCache(CacheManager.getInstance(settings)));
for (int i = 0; i < dds.length; i++) {
// check master confs
String[] masterConfs = dds[i].getModuleConfigurations();
for (int j = 0; j < masterConfs.length; j++) {
- if (!"*".equals(masterConfs[j].trim()) && md.getConfiguration(masterConfs[j]) == null) {
- Message.info("dependency required in non existing conf for "+ivyFile+" \n\tin "+dds[i].getDependencyRevisionId()+": "+masterConfs[j]);
+ if (!"*".equals(masterConfs[j].trim())
+ && md.getConfiguration(masterConfs[j]) == null) {
+ Message.info("dependency required in non existing conf for " + ivyFile
+ + " \n\tin " + dds[i].getDependencyRevisionId() + ": "
+ + masterConfs[j]);
result = false;
}
}
@@ -96,19 +99,25 @@
DependencyResolver resolver = settings.getResolver(dds[i].getDependencyId());
ResolvedModuleRevision rmr = resolver.getDependency(dds[i], data);
if (rmr == null) {
- Message.info("dependency not found in "+ivyFile+":\n\t"+dds[i]);
+ Message.info("dependency not found in " + ivyFile + ":\n\t" + dds[i]);
result = false;
} else {
- String[] depConfs = dds[i].getDependencyConfigurations(md.getConfigurationsNames());
+ String[] depConfs = dds[i].getDependencyConfigurations(md
+ .getConfigurationsNames());
for (int j = 0; j < depConfs.length; j++) {
- if (!Arrays.asList(rmr.getDescriptor().getConfigurationsNames()).contains(depConfs[j])) {
- Message.info("dependency configuration is missing for "+ivyFile+"\n\tin "+dds[i].getDependencyRevisionId()+": "+depConfs[j]);
+ if (!Arrays.asList(rmr.getDescriptor().getConfigurationsNames()).contains(
+ depConfs[j])) {
+ Message.info("dependency configuration is missing for " + ivyFile
+ + "\n\tin " + dds[i].getDependencyRevisionId() + ": "
+ + depConfs[j]);
result = false;
}
Artifact[] arts = rmr.getDescriptor().getArtifacts(depConfs[j]);
for (int k = 0; k < arts.length; k++) {
if (!resolver.exists(arts[k])) {
- Message.info("dependency artifact is missing for "+ivyFile+"\n\t in "+dds[i].getDependencyRevisionId()+": "+arts[k]);
+ Message.info("dependency artifact is missing for " + ivyFile
+ + "\n\t in " + dds[i].getDependencyRevisionId() + ": "
+ + arts[k]);
result = false;
}
}
@@ -117,13 +126,13 @@
}
return result;
} catch (ParseException e) {
- Message.info("parse problem on "+ivyFile+": "+e);
+ Message.info("parse problem on " + ivyFile + ": " + e);
return false;
} catch (IOException e) {
- Message.info("io problem on "+ivyFile+": "+e);
+ Message.info("io problem on " + ivyFile + ": " + e);
return false;
} catch (Exception e) {
- Message.info("problem on "+ivyFile+": "+e);
+ Message.info("problem on " + ivyFile + ": " + e);
return false;
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DefaultPublishingDRResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DefaultPublishingDRResolver.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DefaultPublishingDRResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DefaultPublishingDRResolver.java Tue Jun 5 05:02:27 2007
@@ -20,9 +20,9 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
-
public class DefaultPublishingDRResolver implements PublishingDependencyRevisionResolver {
- public String resolve(ModuleDescriptor published, String publishedStatus, ModuleRevisionId depMrid, String status) {
+ public String resolve(ModuleDescriptor published, String publishedStatus,
+ ModuleRevisionId depMrid, String status) {
return depMrid.getRevision();
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java Tue Jun 5 05:02:27 2007
@@ -44,87 +44,99 @@
import org.xml.sax.SAXException;
public class DeliverEngine {
- private IvySettings settings;
-
+ private IvySettings settings;
+
public DeliverEngine(IvySettings settings) {
- this.settings = settings;
- }
+ this.settings = settings;
+ }
/**
- * Delivers a resolved ivy file based upon last resolve call status.
+ * Delivers a resolved ivy file based upon last resolve call status. If resolve report file
+ * cannot be found in cache, then it throws an IllegalStateException (maybe resolve has not been
+ * called before ?).
*
- * If resolve report file cannot be found in cache, then it throws
- * an IllegalStateException (maybe resolve has not been called before ?).
- *
- * @param revision the revision to which the module should be delivered
- * @param destIvyPattern the pattern to which the delivered ivy file should be written
- * @param options the options with which deliver should be done
+ * @param revision
+ * the revision to which the module should be delivered
+ * @param destIvyPattern
+ * the pattern to which the delivered ivy file should be written
+ * @param options
+ * the options with which deliver should be done
*/
- public void deliver(String revision, String destIvyPattern, DeliverOptions options) throws IOException, ParseException {
- String resolveId = options.getResolveId();
- if (resolveId == null) {
+ public void deliver(String revision, String destIvyPattern, DeliverOptions options)
+ throws IOException, ParseException {
+ String resolveId = options.getResolveId();
+ if (resolveId == null) {
throw new IllegalArgumentException("A resolveId must be specified for delivering.");
- }
- File[] files = options.getCache().getConfigurationResolveReportsInCache(resolveId);
- if (files.length == 0) {
- throw new IllegalStateException("No previous resolve found for id '" + resolveId + "' Please resolve dependencies before delivering.");
- }
- XmlReportParser parser = new XmlReportParser();
- parser.parse(files[0]);
- ModuleRevisionId mrid = parser.getResolvedModule();
- deliver(mrid, revision, destIvyPattern, options);
+ }
+ File[] files = options.getCache().getConfigurationResolveReportsInCache(resolveId);
+ if (files.length == 0) {
+ throw new IllegalStateException("No previous resolve found for id '" + resolveId
+ + "' Please resolve dependencies before delivering.");
+ }
+ XmlReportParser parser = new XmlReportParser();
+ parser.parse(files[0]);
+ ModuleRevisionId mrid = parser.getResolvedModule();
+ deliver(mrid, revision, destIvyPattern, options);
}
/**
- * Delivers a resolved ivy file based upon last resolve call status.
+ * Delivers a resolved ivy file based upon last resolve call status. If resolve report file
+ * cannot be found in cache, then it throws an IllegalStateException (maybe resolve has not been
+ * called before ?).
*
- * If resolve report file cannot be found in cache, then it throws
- * an IllegalStateException (maybe resolve has not been called before ?).
- *
- * @param mrid the module revision id of the module to deliver
- * @param revision the revision to which the module should be delivered
- * @param destIvyPattern the pattern to which the delivered ivy file should be written
- * @param options the options with which deliver should be done
+ * @param mrid
+ * the module revision id of the module to deliver
+ * @param revision
+ * the revision to which the module should be delivered
+ * @param destIvyPattern
+ * the pattern to which the delivered ivy file should be written
+ * @param options
+ * the options with which deliver should be done
*/
- public void deliver(ModuleRevisionId mrid, String revision,
- String destIvyPattern, DeliverOptions options) throws IOException, ParseException {
- Message.info(":: delivering :: "+mrid+" :: "+revision+" :: "+options.getStatus()+" :: "+options.getPubdate());
- Message.verbose("\toptions = "+options);
+ public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern,
+ DeliverOptions options) throws IOException, ParseException {
+ Message.info(":: delivering :: " + mrid + " :: " + revision + " :: " + options.getStatus()
+ + " :: " + options.getPubdate());
+ Message.verbose("\toptions = " + options);
long start = System.currentTimeMillis();
destIvyPattern = settings.substitute(destIvyPattern);
-
+
// 1) find the resolved module descriptor in cache
File ivyFile = options.getCache().getResolvedIvyFileInCache(mrid);
if (!ivyFile.exists()) {
- throw new IllegalStateException("ivy file not found in cache for "+mrid+": please resolve dependencies before delivering ("+ivyFile+")");
+ throw new IllegalStateException("ivy file not found in cache for " + mrid
+ + ": please resolve dependencies before delivering (" + ivyFile + ")");
}
ModuleDescriptor md = null;
URL ivyFileURL = null;
try {
ivyFileURL = ivyFile.toURL();
- md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFileURL, options.isValidate());
+ md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFileURL,
+ options.isValidate());
md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid, revision));
md.setResolvedPublicationDate(options.getPubdate());
} catch (MalformedURLException e) {
- throw new RuntimeException("malformed url obtained for file "+ivyFile , e);
+ throw new RuntimeException("malformed url obtained for file " + ivyFile, e);
} catch (ParseException e) {
- throw new RuntimeException("bad ivy file in cache for "+mrid+": please clean and resolve again" , e);
+ throw new RuntimeException("bad ivy file in cache for " + mrid
+ + ": please clean and resolve again", e);
}
-
+
// 2) parse resolvedRevisions From properties file
Map resolvedRevisions = new HashMap(); // Map (ModuleId -> String revision)
Map dependenciesStatus = new HashMap(); // Map (ModuleId -> String status)
File ivyProperties = options.getCache().getResolvedIvyPropertiesInCache(mrid);
if (!ivyProperties.exists()) {
- throw new IllegalStateException("ivy properties not found in cache for "+mrid+": please resolve dependencies before delivering ("+ivyFile+")");
+ throw new IllegalStateException("ivy properties not found in cache for " + mrid
+ + ": please resolve dependencies before delivering (" + ivyFile + ")");
}
Properties props = new Properties();
FileInputStream in = new FileInputStream(ivyProperties);
props.load(in);
in.close();
-
+
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
- String depMridStr = (String)iter.next();
+ String depMridStr = (String) iter.next();
String[] parts = props.getProperty(depMridStr).split(" ");
ModuleRevisionId decodedMrid = ModuleRevisionId.decode(depMridStr);
if (options.isResolveDynamicRevisions()) {
@@ -132,41 +144,46 @@
}
dependenciesStatus.put(decodedMrid, parts[1]);
}
-
+
// 3) use pdrResolver to resolve dependencies info
Map resolvedDependencies = new HashMap(); // Map (ModuleRevisionId -> String revision)
DependencyDescriptor[] dependencies = md.getDependencies();
for (int i = 0; i < dependencies.length; i++) {
- String rev = (String)resolvedRevisions.get(dependencies[i].getDependencyRevisionId());
+ String rev = (String) resolvedRevisions.get(dependencies[i].getDependencyRevisionId());
if (rev == null) {
rev = dependencies[i].getDependencyRevisionId().getRevision();
}
- String depStatus = (String)dependenciesStatus.get(dependencies[i].getDependencyRevisionId());
- resolvedDependencies.put(dependencies[i].getDependencyRevisionId(),
- options.getPdrResolver().resolve(md, options.getStatus(),
- ModuleRevisionId.newInstance(dependencies[i].getDependencyRevisionId(), rev),
- depStatus));
- }
-
- // 4) copy the source resolved ivy to the destination specified,
- // updating status, revision and dependency revisions obtained by
- // PublishingDependencyRevisionResolver
- String publishedIvy = IvyPatternHelper.substitute(destIvyPattern, md.getResolvedModuleRevisionId());
- Message.info("\tdelivering ivy file to "+publishedIvy);
-
- String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
- Set confsToRemove = new HashSet(Arrays.asList(md.getConfigurationsNames()));
- confsToRemove.removeAll(Arrays.asList(confs));
+ String depStatus = (String) dependenciesStatus.get(dependencies[i]
+ .getDependencyRevisionId());
+ resolvedDependencies.put(dependencies[i].getDependencyRevisionId(), options
+ .getPdrResolver().resolve(
+ md,
+ options.getStatus(),
+ ModuleRevisionId
+ .newInstance(dependencies[i].getDependencyRevisionId(), rev),
+ depStatus));
+ }
+
+ // 4) copy the source resolved ivy to the destination specified,
+ // updating status, revision and dependency revisions obtained by
+ // PublishingDependencyRevisionResolver
+ String publishedIvy = IvyPatternHelper.substitute(destIvyPattern, md
+ .getResolvedModuleRevisionId());
+ Message.info("\tdelivering ivy file to " + publishedIvy);
+
+ String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
+ Set confsToRemove = new HashSet(Arrays.asList(md.getConfigurationsNames()));
+ confsToRemove.removeAll(Arrays.asList(confs));
try {
- XmlModuleDescriptorUpdater.update(settings, ivyFileURL,
- new File(publishedIvy),
- resolvedDependencies, options.getStatus(), revision, options.getPubdate(), null, true, (
- String[]) confsToRemove.toArray(new String[confsToRemove.size()]));
+ XmlModuleDescriptorUpdater.update(settings, ivyFileURL, new File(publishedIvy),
+ resolvedDependencies, options.getStatus(), revision, options.getPubdate(), null,
+ true, (String[]) confsToRemove.toArray(new String[confsToRemove.size()]));
} catch (SAXException ex) {
- throw new RuntimeException("bad ivy file in cache for "+mrid+": please clean and resolve again" , ex);
+ throw new RuntimeException("bad ivy file in cache for " + mrid
+ + ": please clean and resolve again", ex);
}
-
- Message.verbose("\tdeliver done ("+(System.currentTimeMillis()-start)+"ms)");
+
+ Message.verbose("\tdeliver done (" + (System.currentTimeMillis() - start) + "ms)");
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java Tue Jun 5 05:02:27 2007
@@ -26,179 +26,195 @@
* A set of options used to do a deliver.
*/
public class DeliverOptions {
- private String status;
- private Date pubdate;
- private CacheManager cache;
- private PublishingDependencyRevisionResolver pdrResolver = new DefaultPublishingDRResolver();
- private boolean validate = true;
- private boolean resolveDynamicRevisions = true;
- private String resolveId;
- private String[] confs;
-
- /**
- * Returns an instance of DeliverOptions with options corresponding to default values
- * taken from the given settings.
- *
- * @param settings The settings to use to get default option values
- * @return a DeliverOptions instance ready to be used or customized
- */
- public static DeliverOptions newInstance(IvySettings settings) {
- return new DeliverOptions(null, new Date(), CacheManager.getInstance(settings),
- new DefaultPublishingDRResolver(),
- settings.doValidate(),
- true, null);
- }
-
- /**
- * Creates an instance of DeliverOptions which require to be configured
- * using the appropriate setters.
- */
- public DeliverOptions() {
- }
-
- /**
- * Creates an instance of DeliverOptions with all options explicitly set.
- */
- public DeliverOptions(String status, Date pubDate, CacheManager cache, PublishingDependencyRevisionResolver pdrResolver, boolean validate, boolean resolveDynamicRevisions, String[] confs) {
- this.status = status;
- this.pubdate = pubDate;
- this.cache = cache;
- this.pdrResolver = pdrResolver;
- this.validate = validate;
- this.resolveDynamicRevisions = resolveDynamicRevisions;
- this.confs = confs;
- }
-
- public CacheManager getCache() {
- return cache;
- }
-
- public DeliverOptions setCache(CacheManager cache) {
- this.cache = cache;
- return this;
- }
-
- /**
- * Return the pdrResolver that will be used during deliver for each
- * dependency to get its published information.
- * This can particularly useful
- * when the deliver is made for a release, and when we wish to deliver each
- * dependency which is still in integration. The PublishingDependencyRevisionResolver
- * can then do the delivering work for the dependency and return the new (delivered)
- * dependency info (with the delivered revision). Note that
- * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
- * @return the pdrResolver that will be used during deliver
- */
- public PublishingDependencyRevisionResolver getPdrResolver() {
- return pdrResolver;
- }
-
- /**
- * Sets the pdrResolver that will be used during deliver for each
- * dependency to get its published information.
- * This can particularly useful
- * when the deliver is made for a release, and when we wish to deliver each
- * dependency which is still in integration. The PublishingDependencyRevisionResolver
- * can then do the delivering work for the dependency and return the new (delivered)
- * dependency info (with the delivered revision). Note that
- * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
- * @return the instance of DeliverOptions on which the method has been called,
- * for easy method chaining
- */
- public DeliverOptions setPdrResolver(PublishingDependencyRevisionResolver pdrResolver) {
- this.pdrResolver = pdrResolver;
- return this;
- }
-
- public boolean isResolveDynamicRevisions() {
- return resolveDynamicRevisions;
- }
-
- public DeliverOptions setResolveDynamicRevisions(boolean resolveDynamicRevisions) {
- this.resolveDynamicRevisions = resolveDynamicRevisions;
- return this;
- }
-
- public boolean isValidate() {
- return validate;
- }
-
- public DeliverOptions setValidate(boolean validate) {
- this.validate = validate;
- return this;
- }
-
- public Date getPubdate() {
- return pubdate;
- }
-
- public DeliverOptions setPubdate(Date pubdate) {
- this.pubdate = pubdate;
- return this;
- }
-
- /**
- * Returns the status to which the module should be delivered,
- * or null if the current status should be kept.
- * @return the status to which the module should be delivered
- */
- public String getStatus() {
- return status;
- }
-
- /**
- * Sets the status to which the module should be delivered,
- * use null if the current status should be kept.
- * @return the instance of DeliverOptions on which the method has been called,
- * for easy method chaining
- */
- public DeliverOptions setStatus(String status) {
- this.status = status;
- return this;
- }
-
- /**
- * Returns the id of a previous resolve to use for delivering.
- * @return the id of a previous resolve
- */
- public String getResolveId() {
- return resolveId;
- }
-
- /**
- * Sets the id of a previous resolve to use for delivering.
- * @param resolveId the id of a previous resolve
- * @return the instance of DeliverOptions on which the method has been called,
- * for easy method chaining
- */
- public DeliverOptions setResolveId(String resolveId) {
- this.resolveId = resolveId;
- return this;
- }
-
- /**
- * Return the configurations which must be deliverd. Returns <tt>null</tt> if all
- * configurations has to be deliverd. Attention: the returned array can contain wildcards!
- * @return the configurations to deliver
- */
- public String[] getConfs() {
- return confs;
- }
-
- /**
- * Sets the configurations to deliver.
- * @param confs the configurations to deliver
- * @return the instance of DeliverOptions on which the method has been called,
- * for easy method chaining
- */
- public DeliverOptions setConfs(String[] confs) {
- this.confs = confs;
- return this;
- }
-
- public String toString() {
- return "status="+ status +" pubdate="+ pubdate +" validate="+ validate +" resolveDynamicRevisions="+ resolveDynamicRevisions +" cache="+ cache +" resolveId="+ resolveId;
-
- }
-
+ private String status;
+
+ private Date pubdate;
+
+ private CacheManager cache;
+
+ private PublishingDependencyRevisionResolver pdrResolver = new DefaultPublishingDRResolver();
+
+ private boolean validate = true;
+
+ private boolean resolveDynamicRevisions = true;
+
+ private String resolveId;
+
+ private String[] confs;
+
+ /**
+ * Returns an instance of DeliverOptions with options corresponding to default values taken from
+ * the given settings.
+ *
+ * @param settings
+ * The settings to use to get default option values
+ * @return a DeliverOptions instance ready to be used or customized
+ */
+ public static DeliverOptions newInstance(IvySettings settings) {
+ return new DeliverOptions(null, new Date(), CacheManager.getInstance(settings),
+ new DefaultPublishingDRResolver(), settings.doValidate(), true, null);
+ }
+
+ /**
+ * Creates an instance of DeliverOptions which require to be configured using the appropriate
+ * setters.
+ */
+ public DeliverOptions() {
+ }
+
+ /**
+ * Creates an instance of DeliverOptions with all options explicitly set.
+ */
+ public DeliverOptions(String status, Date pubDate, CacheManager cache,
+ PublishingDependencyRevisionResolver pdrResolver, boolean validate,
+ boolean resolveDynamicRevisions, String[] confs) {
+ this.status = status;
+ this.pubdate = pubDate;
+ this.cache = cache;
+ this.pdrResolver = pdrResolver;
+ this.validate = validate;
+ this.resolveDynamicRevisions = resolveDynamicRevisions;
+ this.confs = confs;
+ }
+
+ public CacheManager getCache() {
+ return cache;
+ }
+
+ public DeliverOptions setCache(CacheManager cache) {
+ this.cache = cache;
+ return this;
+ }
+
+ /**
+ * Return the pdrResolver that will be used during deliver for each dependency to get its
+ * published information. This can particularly useful when the deliver is made for a release,
+ * and when we wish to deliver each dependency which is still in integration. The
+ * PublishingDependencyRevisionResolver can then do the delivering work for the dependency and
+ * return the new (delivered) dependency info (with the delivered revision). Note that
+ * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
+ *
+ * @return the pdrResolver that will be used during deliver
+ */
+ public PublishingDependencyRevisionResolver getPdrResolver() {
+ return pdrResolver;
+ }
+
+ /**
+ * Sets the pdrResolver that will be used during deliver for each dependency to get its
+ * published information. This can particularly useful when the deliver is made for a release,
+ * and when we wish to deliver each dependency which is still in integration. The
+ * PublishingDependencyRevisionResolver can then do the delivering work for the dependency and
+ * return the new (delivered) dependency info (with the delivered revision). Note that
+ * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
+ *
+ * @return the instance of DeliverOptions on which the method has been called, for easy method
+ * chaining
+ */
+ public DeliverOptions setPdrResolver(PublishingDependencyRevisionResolver pdrResolver) {
+ this.pdrResolver = pdrResolver;
+ return this;
+ }
+
+ public boolean isResolveDynamicRevisions() {
+ return resolveDynamicRevisions;
+ }
+
+ public DeliverOptions setResolveDynamicRevisions(boolean resolveDynamicRevisions) {
+ this.resolveDynamicRevisions = resolveDynamicRevisions;
+ return this;
+ }
+
+ public boolean isValidate() {
+ return validate;
+ }
+
+ public DeliverOptions setValidate(boolean validate) {
+ this.validate = validate;
+ return this;
+ }
+
+ public Date getPubdate() {
+ return pubdate;
+ }
+
+ public DeliverOptions setPubdate(Date pubdate) {
+ this.pubdate = pubdate;
+ return this;
+ }
+
+ /**
+ * Returns the status to which the module should be delivered, or null if the current status
+ * should be kept.
+ *
+ * @return the status to which the module should be delivered
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status to which the module should be delivered, use null if the current status
+ * should be kept.
+ *
+ * @return the instance of DeliverOptions on which the method has been called, for easy method
+ * chaining
+ */
+ public DeliverOptions setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * Returns the id of a previous resolve to use for delivering.
+ *
+ * @return the id of a previous resolve
+ */
+ public String getResolveId() {
+ return resolveId;
+ }
+
+ /**
+ * Sets the id of a previous resolve to use for delivering.
+ *
+ * @param resolveId
+ * the id of a previous resolve
+ * @return the instance of DeliverOptions on which the method has been called, for easy method
+ * chaining
+ */
+ public DeliverOptions setResolveId(String resolveId) {
+ this.resolveId = resolveId;
+ return this;
+ }
+
+ /**
+ * Return the configurations which must be deliverd. Returns <tt>null</tt> if all
+ * configurations has to be deliverd. Attention: the returned array can contain wildcards!
+ *
+ * @return the configurations to deliver
+ */
+ public String[] getConfs() {
+ return confs;
+ }
+
+ /**
+ * Sets the configurations to deliver.
+ *
+ * @param confs
+ * the configurations to deliver
+ * @return the instance of DeliverOptions on which the method has been called, for easy method
+ * chaining
+ */
+ public DeliverOptions setConfs(String[] confs) {
+ this.confs = confs;
+ return this;
+ }
+
+ public String toString() {
+ return "status=" + status + " pubdate=" + pubdate + " validate=" + validate
+ + " resolveDynamicRevisions=" + resolveDynamicRevisions + " cache=" + cache
+ + " resolveId=" + resolveId;
+
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/PublishingDependencyRevisionResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/PublishingDependencyRevisionResolver.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/PublishingDependencyRevisionResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/PublishingDependencyRevisionResolver.java Tue Jun 5 05:02:27 2007
@@ -26,13 +26,15 @@
public interface PublishingDependencyRevisionResolver {
/**
- * Returns the revision of the dependency for the publishing of the 'published' module
- * in 'publishedStatus' status.
+ * Returns the revision of the dependency for the publishing of the 'published' module in
+ * 'publishedStatus' status.
+ *
* @param published
* @param publishedStatus
* @param dependency
* @return the revision of the dependency
*/
- String resolve(ModuleDescriptor published, String publishedStatus, ModuleRevisionId depMrid, String status);
+ String resolve(ModuleDescriptor published, String publishedStatus, ModuleRevisionId depMrid,
+ String status);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java Tue Jun 5 05:02:27 2007
@@ -28,7 +28,7 @@
public class EventManager implements TransferListener {
private EventListenerList listeners = new EventListenerList();
-
+
public void addIvyListener(IvyListener listener) {
listeners.add(IvyListener.class, listener);
}
@@ -45,22 +45,23 @@
listeners.remove(IvyListener.class, listener);
IvyListener[] listeners = (IvyListener[]) this.listeners.getListeners(IvyListener.class);
for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] instanceof FilteredIvyListener) {
- if (listener.equals(((FilteredIvyListener)listeners[i]).getIvyListener())) {
- this.listeners.remove(IvyListener.class, listeners[i]);
- }
- }
- }
+ if (listeners[i] instanceof FilteredIvyListener) {
+ if (listener.equals(((FilteredIvyListener) listeners[i]).getIvyListener())) {
+ this.listeners.remove(IvyListener.class, listeners[i]);
+ }
+ }
+ }
}
public boolean hasIvyListener(IvyListener listener) {
return Arrays.asList(listeners.getListeners(IvyListener.class)).contains(listener);
}
+
public void fireIvyEvent(IvyEvent evt) {
Object[] listeners = this.listeners.getListenerList();
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==IvyListener.class) {
- ((IvyListener)listeners[i+1]).progress(evt);
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == IvyListener.class) {
+ ((IvyListener) listeners[i + 1]).progress(evt);
}
}
}
@@ -76,21 +77,19 @@
public boolean hasTransferListener(TransferListener listener) {
return Arrays.asList(listeners.getListeners(TransferListener.class)).contains(listener);
}
+
protected void fireTransferEvent(TransferEvent evt) {
Object[] listeners = this.listeners.getListenerList();
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TransferListener.class) {
- ((TransferListener)listeners[i+1]).transferProgress(evt);
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TransferListener.class) {
+ ((TransferListener) listeners[i + 1]).transferProgress(evt);
}
}
}
-
-
public void transferProgress(TransferEvent evt) {
fireTransferEvent(evt);
fireIvyEvent(evt);
}
-
}