Skip to content

Commit

Permalink
fix: update ci process
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Jan 8, 2024
1 parent 1f43305 commit 7d19b13
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 128 deletions.
Empty file removed build.gradl.kts
Empty file.
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ install: |
else
version=$(curl -SsL https://git.io/stable-bee)
curl -SsL -o bee-${version}.jar https://jitpack.io/com/github/teletha/bee/${version}/bee-${version}.jar
java -javaagent:bee-${version}.jar -cp bee-${version}.jar bee.Bee install pom
java -javaagent:bee-${version}.jar -cp bee-${version}.jar bee.Bee install maven
fi
71 changes: 24 additions & 47 deletions src/main/java/bee/api/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.net.HttpRetryException;
import java.net.URI;
import java.net.http.HttpHeaders;
Expand Down Expand Up @@ -187,7 +186,6 @@
import kiss.I;
import kiss.Lifestyle;
import kiss.Managed;
import kiss.Model;
import kiss.Singleton;
import kiss.Storable;
import kiss.WiseConsumer;
Expand Down Expand Up @@ -902,15 +900,32 @@ public Lifestyle create(Class key) {
*/
private static class LazySingleton<M, N> implements Lifestyle<M> {

private final Class<? extends M> type;

private final Class<N>[] names;
private final Lifestyle<M> lifestyle;

private M instance;

private LazySingleton(Class<? extends M> type, Class<N>... names) {
this.type = type;
this.names = names;
private LazySingleton(Class<M> type, Class<N>... subs) {
this.lifestyle = I.prototype(type, paramType -> {
if (paramType == Map.class) {
Map map = new HashMap();

for (Class<N> sub : subs) {
Named named = sub.getAnnotation(Named.class);
if (named != null) {
map.put(named.value(), I.make(sub));
} else {
N impl = I.make(sub);
named = impl.getClass().getAnnotation(Named.class);
if (named != null) {
map.put(named.value(), impl);
}
}
}
return map;
} else {
return I.make(paramType);
}
});
}

/**
Expand All @@ -919,45 +934,7 @@ private LazySingleton(Class<? extends M> type, Class<N>... names) {
@Override
public synchronized M call() throws Exception {
if (instance == null) {
// find default constructor as instantiator
Constructor constructor = Model.collectConstructors(type)[0];
constructor.setAccessible(true);

Class[] types = constructor.getParameterTypes();

// constructor injection
Object[] params = null;

// We should use lazy initialization of parameter array to avoid that the
// constructor
// without parameters doesn't create futile array instance.
if (types.length != 0) {
params = new Object[types.length];

for (int i = 0; i < params.length; i++) {
if (types[i] == Map.class) {
Map map = new HashMap();

for (Class<N> name : names) {
Named named = name.getAnnotation(Named.class);
if (named != null) {
map.put(named.value(), I.make(name));
} else {
N impl = I.make(name);
named = impl.getClass().getAnnotation(Named.class);
if (named != null) {
map.put(named.value(), impl);
}
}
}
params[i] = map;
} else {
params[i] = I.make(types[i]);
}
}
}
// create new instance
instance = (M) constructor.newInstance(params);
instance = lifestyle.call();
}
return instance;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bee/task/CI.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void jitpack() {
else
version=$(curl -SsL https://git.io/stable-bee)
curl -SsL -o bee-${version}.jar https://jitpack.io/com/github/teletha/bee/${version}/bee-${version}.jar
java -javaagent:bee-${version}.jar -cp bee-${version}.jar bee.Bee install pom
java -javaagent:bee-${version}.jar -cp bee-${version}.jar bee.Bee install maven
fi
""", sourceVersion, sourceVersion));
}
Expand Down
79 changes: 0 additions & 79 deletions src/main/java/bee/task/Gradle.java

This file was deleted.

0 comments on commit 7d19b13

Please sign in to comment.