Skip to content

Commit e5036cb

Browse files
committed
ea
a
1 parent fd62902 commit e5036cb

File tree

258 files changed

+3387
-2411
lines changed

Some content is hidden

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

258 files changed

+3387
-2411
lines changed

modules/packed-incubator/packed-incubator-cli/src/main/java/app/packed/cli/CliCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
2323

24-
import app.packed.bean.BeanTrigger.AnnotatedMethodBeanTrigger;
24+
import app.packed.bean.scanning.BeanTrigger.AnnotatedMethodBeanTrigger;
2525
import app.packed.namespace.sandbox.NamespaceOperation;
2626

2727
/**

modules/packed-incubator/packed-incubator-cli/src/main/java/app/packed/cli/CliExtension.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import java.util.function.Consumer;
2121

2222
import app.packed.assembly.Assembly;
23-
import app.packed.bean.BeanElement.BeanMethod;
24-
import app.packed.bean.BeanIntrospector;
23+
import app.packed.bean.scanning.BeanIntrospector;
24+
import app.packed.bean.scanning.BeanElement.BeanMethod;
2525
import app.packed.bean.InstanceBeanConfiguration;
2626
import app.packed.container.ContainerBuildLocal;
2727
import app.packed.container.ContainerConfiguration;
@@ -69,7 +69,7 @@ public <T> InstanceBeanConfiguration<T> newBean(Class<T> beanClass) {
6969
}
7070

7171
CliNamespaceHandle ns() {
72-
return applicationRoot().namespaceLazy(CliNamespaceHandle.TEMPLATE, "main", c -> c.install(CliNamespaceHandle::new));
72+
return applicationRoot().namespaceLazy(CliNamespaceHandle.TEMPLATE, "main");
7373
}
7474

7575
/** {@inheritDoc} */
@@ -79,11 +79,11 @@ protected BeanIntrospector newBeanIntrospector() {
7979

8080
/** {@inheritDoc} */
8181
@Override
82-
public void onAnnotatedMethod(Annotation hook, BeanMethod method) {
82+
public void onAnnotatedMethod(BeanMethod method, Annotation hook) {
8383
if (hook instanceof CliCommand c) {
8484
ns().process(CliExtension.this, c, method);
8585
} else {
86-
super.onAnnotatedMethod(hook, method);
86+
super.onAnnotatedMethod(method, hook);
8787
}
8888
}
8989
};

modules/packed-incubator/packed-incubator-cli/src/main/java/app/packed/cli/CliNamespaceConfiguration.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.function.Consumer;
1919

2020
import app.packed.build.BuildActor;
21+
import app.packed.namespace.NamespaceBuildHook;
2122
import app.packed.namespace.NamespaceConfiguration;
2223

2324
/**
@@ -40,4 +41,9 @@ public CliCommandConfiguration addCliCommand(Consumer<CliCommandContext> action)
4041
throw new UnsupportedOperationException();
4142
}
4243

44+
public static NamespaceBuildHook<CliNamespaceConfiguration> pushToNewApplication(boolean inheritExistingConfiguration, Consumer<? super CliNamespaceConfiguration> c) {
45+
throw new UnsupportedOperationException();
46+
}
47+
48+
4349
}

modules/packed-incubator/packed-incubator-cli/src/main/java/app/packed/cli/CliNamespaceHandle.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import java.util.LinkedHashMap;
1919

20-
import app.packed.bean.BeanElement.BeanMethod;
2120
import app.packed.bean.BeanInstallationException;
21+
import app.packed.bean.scanning.BeanElement.BeanMethod;
2222
import app.packed.build.BuildActor;
2323
import app.packed.namespace.NamespaceHandle;
2424
import app.packed.namespace.NamespaceInstaller;
@@ -31,12 +31,12 @@
3131
final class CliNamespaceHandle extends NamespaceHandle<CliExtension, CliNamespaceConfiguration> {
3232

3333
/** The default namespace template. */
34-
static final NamespaceTemplate TEMPLATE = NamespaceTemplate.of(CliNamespaceHandle.class, c -> {});
34+
static final NamespaceTemplate<CliNamespaceHandle> TEMPLATE = NamespaceTemplate.of(CliNamespaceHandle.class, CliNamespaceHandle::new, c -> {});
3535

3636
/** All the commands within the namespace. */
3737
final LinkedHashMap<String, CliCommandHandle> oldCommands = new LinkedHashMap<>();
3838

39-
CliNamespaceHandle(NamespaceInstaller installer) {
39+
CliNamespaceHandle(NamespaceInstaller<?> installer) {
4040
super(installer);
4141
}
4242

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23-
import app.packed.bean.BeanTrigger.AnnotatedMethodBeanTrigger;
23+
import app.packed.bean.scanning.BeanTrigger.AnnotatedMethodBeanTrigger;
2424

2525
/**
2626
* Will have a dedicated thread.

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

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package app.packed.concurrent;
1717

1818
import app.packed.operation.OperationInstaller;
19-
import internal.app.packed.concurrent.ScheduledDaemon;
2019

2120
/** An operation handle for a daemon operation. */
2221
final class DaemonOperationHandle extends ThreadedOperationHandle<DaemonOperationConfiguration> {
@@ -40,8 +39,4 @@ protected DaemonOperationConfiguration newOperationConfiguration() {
4039
public DaemonOperationMirror newOperationMirror() {
4140
return new DaemonOperationMirror(this);
4241
}
43-
44-
ScheduledDaemon schedule() {
45-
return new ScheduledDaemon(useVirtual, generateMethodHandle());
46-
}
4742
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23-
import app.packed.bean.BeanTrigger.AnnotatedMethodBeanTrigger;
23+
import app.packed.bean.scanning.BeanTrigger.AnnotatedMethodBeanTrigger;
2424

2525
/**
2626
*

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import app.packed.operation.OperationInstaller;
1919
import app.packed.util.Nullable;
2020
import internal.app.packed.concurrent.ScheduleImpl;
21-
import internal.app.packed.concurrent.ScheduledOperation;
2221

2322
/**
2423
*
@@ -45,12 +44,11 @@ protected ScheduledOperationMirror newOperationMirror() {
4544
return new ScheduledOperationMirror(this);
4645
}
4746

48-
ScheduledOperation schedule() {
47+
@Override
48+
protected void onClose() {
4949
/// Called from a code generation thread
5050
if (s == null) {
5151
throw new IllegalStateException("Operation " + this + " was never scheduled");
5252
}
53-
return new ScheduledOperation(s, generateMethodHandle());
5453
}
55-
5654
}

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

+8-13
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.util.function.Consumer;
2222

2323
import app.packed.bean.BeanConfiguration;
24-
import app.packed.bean.BeanElement.BeanMethod;
25-
import app.packed.bean.BeanIntrospector;
24+
import app.packed.bean.scanning.BeanElement.BeanMethod;
25+
import app.packed.bean.scanning.BeanIntrospector;
2626
import app.packed.binding.Key;
2727
import app.packed.binding.UnwrappedBindableVariable;
2828
import app.packed.context.Context;
@@ -79,16 +79,11 @@ public class ThreadExtension extends FrameworkExtension<ThreadExtension> {
7979
static final OperationTemplate DAEMON_OPERATION_TEMPLATE = OperationTemplate.defaults()
8080
.reconfigure(c -> c.inContext(DAEMON_CONTEXT_TEMPLATE).returnIgnore());
8181

82-
private BeanConfiguration schedulingBean;
83-
8482
/** Creates a new thread extension. */
8583

86-
BeanConfiguration initSchedulingBean() {
87-
BeanConfiguration b = schedulingBean;
88-
if (b == null) {
89-
b = schedulingBean = provide(SchedulingTaskManager.class);
90-
b.bindServiceInstance(ExecutorConfiguration.class, main().scheduler);
91-
}
84+
BeanConfiguration newSchedulingBean() {
85+
BeanConfiguration b = provide(SchedulingTaskManager.class);
86+
b.bindServiceInstance(ExecutorConfiguration.class, main().scheduler);
9287
return b;
9388
}
9489

@@ -118,7 +113,7 @@ public void onContextualServiceProvision(Key<?> key, Class<?> actualHook, Set<Cl
118113
}
119114

120115
@Override
121-
public void onAnnotatedMethod(Annotation hook, BeanMethod on) {
116+
public void onAnnotatedMethod(BeanMethod on, Annotation hook) {
122117
if (hook instanceof ScheduleRecurrent schedule) {
123118
// Parse the schedule
124119
ScheduleImpl s = new ScheduleImpl(Duration.ofMillis(schedule.millies()));
@@ -141,7 +136,7 @@ public void onAnnotatedMethod(Annotation hook, BeanMethod on) {
141136
// Configure the handle
142137
h.useVirtual = daemon.useVirtual();
143138
} else {
144-
super.onAnnotatedMethod(hook, on);
139+
super.onAnnotatedMethod(on, hook);
145140
}
146141
}
147142
};
@@ -157,7 +152,7 @@ public ThreadNamespaceConfiguration namespace() {
157152
}
158153

159154
private ThreadNamespaceHandle main() {
160-
return namespaceLazy(ThreadNamespaceHandle.TEMPLATE, "main", c -> c.install(ThreadNamespaceHandle::new));
155+
return namespaceLazy(ThreadNamespaceHandle.TEMPLATE, "main");
161156
}
162157

163158
/** {@inheritDoc} */

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

-41
This file was deleted.

modules/packed/src/main/java/app/packed/lifetime/LaunchMode.java renamed to modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/ThreadNamespaceBridge.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package app.packed.lifetime;
16+
package app.packed.concurrent;
17+
18+
import app.packed.namespace.bridge.NamespaceBridge;
1719

1820
/**
1921
*
2022
*/
21-
class LaunchMode {
2223

23-
// Starting, Initializing
24-
// Can throw
24+
public class ThreadNamespaceBridge extends NamespaceBridge<ThreadExtension> {
25+
2526
}

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

+13-16
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package app.packed.concurrent;
1717

18-
import java.util.List;
19-
2018
import app.packed.bean.BeanConfiguration;
2119
import app.packed.build.BuildActor;
2220
import app.packed.namespace.NamespaceHandle;
@@ -32,7 +30,7 @@
3230
final class ThreadNamespaceHandle extends NamespaceHandle<ThreadExtension, ThreadNamespaceConfiguration> {
3331

3432
/** The default thread namespace template. */
35-
static final NamespaceTemplate TEMPLATE = NamespaceTemplate.of(ThreadNamespaceHandle.class, c -> {});
33+
static final NamespaceTemplate<ThreadNamespaceHandle> TEMPLATE = NamespaceTemplate.of(ThreadNamespaceHandle.class, ThreadNamespaceHandle::new, c -> {});
3634

3735
ExecutorConfiguration scheduler;
3836

@@ -42,7 +40,7 @@ final class ThreadNamespaceHandle extends NamespaceHandle<ThreadExtension, Threa
4240
* @param installer
4341
* the namespace installer
4442
*/
45-
protected ThreadNamespaceHandle(NamespaceInstaller installer) {
43+
protected ThreadNamespaceHandle(NamespaceInstaller<?> installer) {
4644
super(installer);
4745
}
4846

@@ -60,19 +58,18 @@ protected ThreadNamespaceMirror newNamespaceMirror() {
6058

6159
@Override
6260
protected void onNamespaceClose() {
63-
// Get all t
64-
List<ScheduledOperationHandle> l = operations(ScheduledOperationHandle.class).toList();
65-
List<DaemonOperationHandle> daemons = operations(DaemonOperationHandle.class).toList();
66-
67-
if (l.size() > 0) {
68-
BeanConfiguration b = rootExtension().initSchedulingBean();
69-
70-
b.bindCodeGenerator(ScheduledOperation[].class,
71-
() -> operations(ScheduledOperationHandle.class).map(ScheduledOperationHandle::schedule).toArray(ScheduledOperation[]::new));
61+
// Find all scheduling operations in the namespace.
62+
ScheduledOperation[] so = operations(ScheduledOperationHandle.class).map(h -> new ScheduledOperation(h.s, h.methodHandle()))
63+
.toArray(ScheduledOperation[]::new);
64+
// Find all daemon operations in the namespace.
65+
ScheduledDaemon[] sd = operations(DaemonOperationHandle.class).map(h -> new ScheduledDaemon(h.useVirtual, h.methodHandle()))
66+
.toArray(ScheduledDaemon[]::new);
7267

73-
b.bindCodeGenerator(ScheduledDaemon[].class,
74-
() -> operations(DaemonOperationHandle.class).map(DaemonOperationHandle::schedule).toArray(ScheduledDaemon[]::new));
68+
// Install a scheduling bean if we have any operations.
69+
if (so.length > 0 || sd.length > 0) {
70+
BeanConfiguration b = rootExtension().newSchedulingBean();
71+
b.bindServiceInstance(ScheduledOperation[].class, so);
72+
b.bindServiceInstance(ScheduledDaemon[].class, sd);
7573
}
76-
System.out.println("CLosing " + daemons.size());
7774
}
7875
}

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import java.util.Set;
66

77
import app.packed.assembly.Assembly;
8-
import app.packed.bean.BeanElement.BeanMethod;
9-
import app.packed.bean.BeanIntrospector;
108
import app.packed.bean.InstanceBeanConfiguration;
9+
import app.packed.bean.scanning.BeanElement.BeanMethod;
10+
import app.packed.bean.scanning.BeanIntrospector;
1111
import app.packed.binding.Key;
1212
import app.packed.binding.UnwrappedBindableVariable;
1313
import app.packed.context.Context;
@@ -63,7 +63,7 @@ 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, c -> c.implementationClass(PackedSchedulingContext.class));
6767

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

@@ -75,13 +75,13 @@ protected BeanIntrospector newBeanIntrospector() {
7575

7676
@SuppressWarnings("unused")
7777
@Override
78-
public void onAnnotatedMethod(Annotation hook, BeanMethod method) {
78+
public void onAnnotatedMethod(BeanMethod method, Annotation hook) {
7979
Cron c = method.annotations().readRequired(Cron.class);
8080

8181
OperationHandle<?> operation = method.newOperation(OT).install(OperationHandle::new);
8282

8383
InstanceBeanConfiguration<SchedulingBean> bean = lifetimeRoot().base().installIfAbsent(SchedulingBean.class, handle -> {
84-
handle.bindCodeGenerator(MethodHandle.class, () -> operation.generateMethodHandle());
84+
handle.bindServiceInstance(MethodHandle.class, operation.methodHandle());
8585
});
8686
// bean, add scheduling +
8787
// Manytons dur ikke direkte
@@ -93,7 +93,8 @@ public void onAnnotatedMethod(Annotation hook, BeanMethod method) {
9393
}
9494

9595
@Override
96-
public void onContextualServiceProvision(Key<?> key, Class<?> actualHook, Set<Class<? extends Context<?>>> contexts,UnwrappedBindableVariable binding) {
96+
public void onContextualServiceProvision(Key<?> key, Class<?> actualHook, Set<Class<? extends Context<?>>> contexts,
97+
UnwrappedBindableVariable binding) {
9798
Class<?> hook = key.rawType();
9899
if (hook == SchedulingContext.class) {
99100
binding.bindContext(SchedulingContext.class);

0 commit comments

Comments
 (0)