Skip to content

Commit 27c8683

Browse files
committed
e
s
1 parent e5036cb commit 27c8683

File tree

144 files changed

+2087
-1488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+2087
-1488
lines changed

modules/packed-incubator/packed-incubator-cli/src/main/java/app/packed/cli/other/CliApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static void verify(Assembly assembly, String[] args) {
6767
*/
6868
private static BootstrapApp<Void> bootstrap() {
6969
class ServiceLocatorBootstrap {
70-
private static final BootstrapApp<Void> APP = BootstrapApp.of(ApplicationTemplate.of(Void.class, c -> {}));
70+
private static final BootstrapApp<Void> APP = BootstrapApp.of(ApplicationTemplate.ofManaged(Void.class));
7171
}
7272
return ServiceLocatorBootstrap.APP;
7373
}

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/ScheduledOperationHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected ScheduledOperationMirror newOperationMirror() {
4545
}
4646

4747
@Override
48-
protected void onClose() {
48+
protected void onOperationClose() {
4949
/// Called from a code generation thread
5050
if (s == null) {
5151
throw new IllegalStateException("Operation " + this + " was never scheduled");

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/ThreadExtension.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ public class ThreadExtension extends FrameworkExtension<ThreadExtension> {
6969
}
7070

7171
/** A context template. */
72-
static final ContextTemplate SCHEDULING_CONTEXT_TEMPLATE = ContextTemplate.of(SchedulingContext.class, c -> {});
72+
static final ContextTemplate SCHEDULING_CONTEXT_TEMPLATE = ContextTemplate.of(SchedulingContext.class);
7373

74-
static final ContextTemplate DAEMON_CONTEXT_TEMPLATE = ContextTemplate.of(DaemonContext.class, c -> {});
74+
static final ContextTemplate DAEMON_CONTEXT_TEMPLATE = ContextTemplate.of(DaemonContext.class);
7575

76-
static final OperationTemplate SCHEDULING_OPERATION_TEMPLATE = OperationTemplate.defaults()
77-
.reconfigure(c -> c.inContext(SCHEDULING_CONTEXT_TEMPLATE).returnIgnore());
76+
static final OperationTemplate SCHEDULING_OPERATION_TEMPLATE = OperationTemplate.of(c -> c.inContext(SCHEDULING_CONTEXT_TEMPLATE).returnIgnore());
7877

79-
static final OperationTemplate DAEMON_OPERATION_TEMPLATE = OperationTemplate.defaults()
80-
.reconfigure(c -> c.inContext(DAEMON_CONTEXT_TEMPLATE).returnIgnore());
78+
static final OperationTemplate DAEMON_OPERATION_TEMPLATE = OperationTemplate.of(c -> c.inContext(DAEMON_CONTEXT_TEMPLATE).returnIgnore());
8179

8280
/** Creates a new thread extension. */
8381

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/ThreadNamespaceConfiguration.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public final class ThreadNamespaceConfiguration extends NamespaceConfiguration<T
4343
this.handle = handle;
4444
}
4545

46-
//Altssa Hvor brugbare er de her uden at man kan faa fat i andet en den context????
4746
public DaemonOperationConfiguration addDaemon(Consumer<DaemonContext> action) {
4847
throw new UnsupportedOperationException();
4948
}
@@ -58,13 +57,6 @@ public void register(ExecutorService scheduler, boolean shutdownOnExit) {
5857
handle.scheduler = new ExecutorConfiguration(scheduler, shutdownOnExit);
5958
}
6059

61-
// If ExecutorService a task will be executed with sleep. Don't use this unless
62-
// Otherwise the
63-
64-
public void setScheduling(ExecutorService scheduler, boolean shutdownOnExit) {
65-
handle.scheduler = new ExecutorConfiguration(scheduler, shutdownOnExit);
66-
}
67-
6860
Stream<ScheduledOperationConfiguration> scheduledOperations() {
6961
// All In Application -> No, that would break cross assembly conf
7062
// All In Assembly

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/ThreadNamespaceHandle.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import app.packed.namespace.NamespaceInstaller;
2222
import app.packed.namespace.NamespaceTemplate;
2323
import internal.app.packed.concurrent.ExecutorConfiguration;
24+
import internal.app.packed.concurrent.NewScheduledOperation;
2425
import internal.app.packed.concurrent.ScheduledDaemon;
2526
import internal.app.packed.concurrent.ScheduledOperation;
2627

@@ -56,16 +57,23 @@ protected ThreadNamespaceMirror newNamespaceMirror() {
5657
return new ThreadNamespaceMirror(this);
5758
}
5859

60+
/** {@inheritDoc} */
5961
@Override
6062
protected void onNamespaceClose() {
6163
// Find all scheduling operations in the namespace.
62-
ScheduledOperation[] so = operations(ScheduledOperationHandle.class).map(h -> new ScheduledOperation(h.s, h.methodHandle()))
64+
65+
@SuppressWarnings("unused")
66+
NewScheduledOperation[] newSo = operations(ScheduledOperationHandle.class).map(h -> h.invokerAs(NewScheduledOperation.class, h.s))
67+
.toArray(NewScheduledOperation[]::new);
68+
69+
ScheduledOperation[] so = operations(ScheduledOperationHandle.class).map(h -> new ScheduledOperation(h.s, h.invokerAsMethodHandle()))
6370
.toArray(ScheduledOperation[]::new);
71+
6472
// Find all daemon operations in the namespace.
65-
ScheduledDaemon[] sd = operations(DaemonOperationHandle.class).map(h -> new ScheduledDaemon(h.useVirtual, h.methodHandle()))
73+
ScheduledDaemon[] sd = operations(DaemonOperationHandle.class).map(h -> new ScheduledDaemon(h.useVirtual, h.invokerAsMethodHandle()))
6674
.toArray(ScheduledDaemon[]::new);
6775

68-
// Install a scheduling bean if we have any operations.
76+
// Install a scheduling bean if we have any scheduling or daemon operations.
6977
if (so.length > 0 || sd.length > 0) {
7078
BeanConfiguration b = rootExtension().newSchedulingBean();
7179
b.bindServiceInstance(ScheduledOperation[].class, so);

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/other/ScheduledJobExtension.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ protected ScheduledJobExtension(ExtensionHandle<ScheduledJobExtension> handle) {
6363
super(handle);
6464
}
6565

66-
private static final ContextTemplate CT = ContextTemplate.of(SchedulingContext.class, c -> c.implementationClass(PackedSchedulingContext.class));
66+
private static final ContextTemplate CT = ContextTemplate.of(SchedulingContext.class).withImplementation(PackedSchedulingContext.class);
6767

68-
private static final OperationTemplate OT = OperationTemplate.defaults().reconfigure(c -> c.inContext(CT));
68+
private static final OperationTemplate OT = OperationTemplate.of(c -> c.inContext(CT));
6969

7070
// Creates a new instance on every invocation
7171

@@ -81,7 +81,7 @@ public void onAnnotatedMethod(BeanMethod method, Annotation hook) {
8181
OperationHandle<?> operation = method.newOperation(OT).install(OperationHandle::new);
8282

8383
InstanceBeanConfiguration<SchedulingBean> bean = lifetimeRoot().base().installIfAbsent(SchedulingBean.class, handle -> {
84-
handle.bindServiceInstance(MethodHandle.class, operation.methodHandle());
84+
handle.bindServiceInstance(MethodHandle.class, operation.invokerAsMethodHandle());
8585
});
8686
// bean, add scheduling +
8787
// Manytons dur ikke direkte
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package internal.app.packed.concurrent;
2+
3+
import app.packed.extension.ExtensionContext;
4+
import internal.app.packed.ValueBased;
5+
6+
/**
7+
*
8+
*/
9+
@ValueBased
10+
public abstract class NewScheduledOperation {
11+
ScheduleImpl s;
12+
13+
public NewScheduledOperation(ScheduleImpl s) {
14+
this.s = s;
15+
}
16+
17+
public abstract void invoke(ExtensionContext context);
18+
}

modules/packed/src/main/java/app/packed/application/App.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.function.Consumer;
2121

2222
import app.packed.assembly.Assembly;
23+
import app.packed.build.MirrorPrinter;
2324
import app.packed.container.Wirelet;
2425
import app.packed.runtime.RunState;
2526
import app.packed.runtime.StopOption;
@@ -143,6 +144,10 @@ static void print(Assembly assembly, Wirelet... wirelets) {
143144
mirrorOf(assembly, wirelets).print();
144145
}
145146

147+
static MirrorPrinter printer(Assembly assembly, Wirelet... wirelets) {
148+
return mirrorOf(assembly, wirelets).printer();
149+
}
150+
146151
/**
147152
* Builds and executes an application from the specified assembly and optional wirelets.
148153
* <p>

modules/packed/src/main/java/app/packed/application/ApplicationInstaller.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public sealed interface ApplicationInstaller<H extends ApplicationHandle<?, ?>>
3939
* @see ApplicationHandle#componentTag(String...)
4040
* @see ApplicationHandle#componentTags()
4141
*/
42+
// Still useful for Application Repository where the template is fixed
4243
ApplicationInstaller<H> componentTag(String... tags);
4344

4445
/**

modules/packed/src/main/java/app/packed/application/ApplicationMirror.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import app.packed.assembly.AssemblyMirror;
1111
import app.packed.bean.BeanMirror;
1212
import app.packed.build.BuildGoal;
13+
import app.packed.build.Mirror;
14+
import app.packed.build.MirrorPrinter;
1315
import app.packed.component.ComponentMirror;
1416
import app.packed.component.ComponentPath;
1517
import app.packed.container.ContainerMirror;
@@ -117,10 +119,6 @@ public ComponentPath componentPath() {
117119
return handle.application.componentPath();
118120
}
119121

120-
// All mirrors "owned" by the user
121-
public Stream<ComponentMirror> components() {
122-
throw new UnsupportedOperationException();
123-
}
124122

125123
/**
126124
* {@return an immutable set of tags that have been set on the application}
@@ -236,6 +234,10 @@ public <T extends OperationMirror> Stream<T> operations(Class<T> operationType)
236234
return (Stream<T>) operations().filter(f -> operationType.isAssignableFrom(f.getClass()));
237235
}
238236

237+
public final void print(@SuppressWarnings("unchecked") Class<? extends Mirror>... mirrorTypes) {
238+
239+
}
240+
239241
public void print() {
240242
// Maybe return ApplicationPrinter???
241243
// to(PrintStream ps);
@@ -293,8 +295,20 @@ public <E extends ExtensionMirror<?>> E use(Class<E> type) {
293295
public <E extends ExtensionMirror<?>> void useIfPresent(Class<E> type, Consumer<? super E> action) {
294296
throw new UnsupportedOperationException();
295297
}
298+
299+
/**
300+
*
301+
*/
302+
public MirrorPrinter printer() {
303+
throw new UnsupportedOperationException();
304+
}
296305
}
297306

307+
//
308+
//// All mirrors "owned" by the user
309+
//public Stream<ComponentMirror> components() {
310+
// throw new UnsupportedOperationException();
311+
//}
298312
//
299313
///** {@return a mirror of the root assembly that defines the application.} */
300314
//// IDK if we want this or only assemblies

0 commit comments

Comments
 (0)