summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/models
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-10 17:33:19 -0400
committerJames Moger <james.moger@gitblit.com>2014-04-10 19:01:30 -0400
commitb2fec20f1f1081607b54b3e7dd20b12d03cef113 (patch)
tree4979033daec189d6a56c983b73478e782b7e91c9 /src/main/java/com/gitblit/models
parentd433fd3ab6185c2fb5eab998d1fcab4dd0940e5f (diff)
downloadgitblit-b2fec20f1f1081607b54b3e7dd20b12d03cef113.tar.gz
gitblit-b2fec20f1f1081607b54b3e7dd20b12d03cef113.zip
Improve plugin manager based on upstreamed contributions to pf4j
Diffstat (limited to 'src/main/java/com/gitblit/models')
-rw-r--r--src/main/java/com/gitblit/models/PluginRegistry.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/models/PluginRegistry.java b/src/main/java/com/gitblit/models/PluginRegistry.java
index c81a0f23..b5cf0ee1 100644
--- a/src/main/java/com/gitblit/models/PluginRegistry.java
+++ b/src/main/java/com/gitblit/models/PluginRegistry.java
@@ -19,6 +19,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.parboiled.common.StringUtils;
@@ -37,7 +38,13 @@ public class PluginRegistry implements Serializable {
public PluginRegistry(String name) {
this.name = name;
- registrations = new ArrayList<PluginRegistration>();
+ registrations = new CopyOnWriteArrayList<PluginRegistration>();
+ }
+
+ public void setup() {
+ for (PluginRegistration reg : registrations) {
+ reg.registry = name;
+ }
}
public PluginRegistration lookup(String idOrName) {
@@ -80,6 +87,8 @@ public class PluginRegistry implements Serializable {
public transient String installedRelease;
+ public transient String registry;
+
public List<PluginRelease> releases;
public PluginRegistration(String id) {
@@ -90,10 +99,12 @@ public class PluginRegistry implements Serializable {
public PluginRelease getCurrentRelease() {
PluginRelease current = null;
if (!StringUtils.isEmpty(currentRelease)) {
+ // find specified
current = getRelease(currentRelease);
}
if (current == null) {
+ // find by date
Date date = new Date(0);
for (PluginRelease pv : releases) {
if (pv.date.after(date)) {
@@ -135,9 +146,15 @@ public class PluginRegistry implements Serializable {
}
}
- public static class PluginRelease {
+ public static class PluginRelease implements Comparable<PluginRelease> {
public String version;
public Date date;
+ public String requires;
public String url;
+
+ @Override
+ public int compareTo(PluginRelease o) {
+ return PluginVersion.createVersion(version).compareTo(PluginVersion.createVersion(o.version));
+ }
}
}