Skip to content

Commit eb93821

Browse files
committed
Updates
a
1 parent dfd961e commit eb93821

File tree

135 files changed

+1887
-1333
lines changed

Some content is hidden

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

135 files changed

+1887
-1333
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static void run(Assembly assembly, Wirelet... wirelets) {
4343

4444
static void run(Assembly assembly, String[] args, Wirelet... wirelets) {
4545
// Maybe checked run...
46+
// App.launcherOf(assembly, wirelets).args(args).
4647
App.run(assembly, Wirelets.argList(args).andThen(wirelets));
4748
}
4849
}

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/JobApp.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void verify(Class<?> resultType, Assembly assembly, Wirelet... wirelets)
7272

7373
// Kunne vi supportere en Callable????
7474
// Saa kan folk submitte den til en executor...
75-
interface Image<T> {
75+
interface Image<T> extends Launcher<T> {
7676

7777
// Mindfuck
7878
// Do we unwrap UnhandledApplicationExtension? Hmm
@@ -96,6 +96,10 @@ interface Image<T> {
9696

9797
JobApp<T> start();
9898
}
99+
100+
interface Launcher<T> {
101+
102+
}
99103
}
100104

101105
class TestIt extends BaseAssembly {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void onAnnotatedMethod(Annotation hook, BeanIntrospector.OnMethod method)
7575
OperationHandle<?> operation = method.newOperation(OT).install(OperationHandle::new);
7676

7777
InstanceBeanConfiguration<SchedulingBean> bean = extension().lifetimeRoot().base().installIfAbsent(SchedulingBean.class, handle -> {
78-
handle.bindServiceInstance(MethodHandle.class, operation.invokerAsMethodHandle());
78+
handle.bindServiceInstance(MethodHandle.class, operation.invoker().asMethodHandle());
7979
});
8080
// bean, add scheduling +
8181
// Manytons dur ikke direkte

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public final class DaemonOperationHandle extends ThreadedOperationHandle<DaemonJ
5050
}
5151

5252
public DaemonRuntimeOperationConfiguration runtimeConfiguration() {
53-
return new DaemonRuntimeOperationConfiguration(runtimeThreadFactory(), invokerAsMethodHandle());
53+
return new DaemonRuntimeOperationConfiguration(runtimeThreadFactory(), invoker().asMethodHandle());
5454
}
5555

5656
/** {@inheritDoc} */

modules/packed-incubator/packed-incubator-concurrent/src/main/java/internal/app/packed/concurrent/daemon/JobNamespaceHandle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import app.packed.bean.BeanConfiguration;
2020
import app.packed.bean.BeanHandle;
2121
import app.packed.bean.BeanInstaller;
22-
import app.packed.bean.BeanKind;
22+
import app.packed.bean.BeanLifetime;
2323
import app.packed.bean.BeanTemplate;
2424
import app.packed.component.ComponentRealm;
2525
import app.packed.concurrent.ThreadNamespaceConfiguration;
@@ -85,7 +85,7 @@ protected void onClose() {
8585

8686
// Install deamon manager if we have any operations.
8787
if (daemons.length > 0) {
88-
BeanConfiguration b = new ProvidableBeanConfiguration<>(newBeanBuilderSelf(BeanKind.CONTAINER.template()).install(Bean.of(DaemonRuntimeManager.class), BeanHandle::new));
88+
BeanConfiguration b = new ProvidableBeanConfiguration<>(newBeanBuilderSelf(BeanLifetime.SINGLETON.template()).install(Bean.of(DaemonRuntimeManager.class), BeanHandle::new));
8989
b.bindServiceInstance(DaemonRuntimeOperationConfiguration[].class, daemons);
9090
}
9191
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
ApplicationHandle fungere ikke super godt
2+
3+
XConfiguration is used for hooks... So we need 1Handle=1Configuration and we need to always construct it
4+
5+
Vi har reelt set 3 ting.
6+
7+
8+
ApplicationConfiguration
9+
ApplicationHandle
10+
ApplicationTemplate
11+
ApplicationInstaller
12+
13+
ApplicationInterface
14+
ApplicationImage
15+
ApplicationLauncher (Kun aktuelt hvis man vil launcher 1 gang, men så skal man ikke bruge Repo)
16+
17+
Handler<AppInterface, Image, Launcher>
18+
Launcher
19+
Image
20+
AppInterface
21+
22+
[ApplicationMirror] skal jo også castes
23+
24+
25+
OperationTemplate
26+
OperationInstaller
27+
OperationHandle
28+
InvokerFactory
29+
<Invoker>
30+
OperationConfiguration
31+
32+
33+
BeanTemplate -> Extension
34+
BeanInstaller -> Extension
35+
BeanHandle -> Extension
36+
InvokerFactory -> [Creates an Image, Launcher is args]
37+
<Invoker>
38+
BeanConfiguration -> User
39+
<BeanInstance>
40+
41+
// Runtime
42+
Invoker
43+
44+
Template->Installer->Handle -> BeanConfiguraiton
45+
46+
47+
48+
ApplicationImage ->
49+
50+
51+
52+
Vi vil gerne kunne lave
53+
A
54+
XApp.Image
55+
XApp.Launcher
56+
57+
58+
=== Fra
59+
BootStrap
60+
RepoKid (Altid kun images)

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import app.packed.application.App.Launcher;
66
import app.packed.assembly.Assembly;
7+
import app.packed.binding.Key;
78
import app.packed.container.Wirelet;
89
import app.packed.runtime.RunState;
910
import app.packed.runtime.StopOption;
@@ -105,14 +106,12 @@ public interface App extends AutoCloseable, ApplicationInterface {
105106
* optional wirelets for configuration
106107
* @return an image that can be used to launch the application
107108
*/
108-
// By default I think it is single launchable...
109-
// Mayb
110109
static Image imageOf(Assembly assembly, Wirelet... wirelets) {
111110
return new PackedApp.AppImage(PackedApp.BOOTSTRAP_APP.imageOf(assembly, wirelets));
112111
}
113112

114113
static Launcher launcherOf(Assembly assembly, Wirelet... wirelets) {
115-
throw new UnsupportedOperationException();
114+
return new PackedApp.AppLauncher(PackedApp.BOOTSTRAP_APP.launcher(assembly, wirelets));
116115
}
117116

118117
static void main(String[] args) {
@@ -229,6 +228,12 @@ interface Launcher extends ApplicationLauncher {
229228

230229
// Config also
231230

231+
232+
@Override
233+
default <T> Launcher provide(Key<? super T> key, T value) {
234+
return null;
235+
}
236+
232237
default Launcher alwaysRestart() {
233238
return this;
234239
}

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

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
import internal.app.packed.application.PackedApplicationInstaller;
2525
import internal.app.packed.application.PackedBootstrapImage.ImageEager;
2626
import internal.app.packed.application.PackedBootstrapImage.ImageNonReusable;
27+
import internal.app.packed.util.accesshelper.AccessHelper;
28+
import internal.app.packed.util.accesshelper.ApplicationAccessHandler;
2729

2830
/**
29-
* An application handle represents an installed application towards the person
30-
* An extendable handle for an application.
31+
* An application handle represents a fully built application.
3132
*/
3233
public non-sealed class ApplicationHandle<A, C extends ApplicationConfiguration> extends ComponentHandle implements ApplicationBuildLocal.Accessor {
3334

@@ -65,9 +66,27 @@ public ApplicationHandle(ApplicationInstaller<?> installer) {
6566
}
6667
}
6768
this.image = img;
68-
6969
}
7070

71+
// /**
72+
// * The image
73+
// *
74+
// * @return the base image for the application
75+
// * @throws IllegalStateException
76+
// * if the application was build with {@link BuildGoal#IMAGE}.
77+
// */
78+
// // Tror jeg fjerner den her... BaseImage er kun noget man bruger ved rødder tænker jeg???
79+
// public final BootstrapApp.Image<A> newImage() {
80+
// if (buildGoal() != BuildGoal.IMAGE) {
81+
// throw new IllegalStateException("The application must be installed with BuildImage, was " + application.goal);
82+
// }
83+
// BootstrapApp.Image<A> img = null;
84+
// img = new ImageEager<>(this);
85+
// if (!inst.optionBuildReusableImage) {
86+
// img = new ImageNonReusable<>(img);
87+
// }
88+
// }
89+
7190
/** {@return the build goal that was used to build the application} */
7291
public final BuildGoal buildGoal() {
7392
return application.goal;
@@ -110,7 +129,7 @@ public final C configuration() {
110129
* if the application was build with {@link BuildGoal#IMAGE}.
111130
*/
112131
// Tror jeg fjerner den her... BaseImage er kun noget man bruger ved rødder tænker jeg???
113-
public final BootstrapApp.Image<A> image() {
132+
final BootstrapApp.Image<A> image() {
114133
BootstrapApp.Image<A> i = image;
115134
if (i == null) {
116135
throw new IllegalStateException("The application must be installed with BuildImage, was " + application.goal);
@@ -173,4 +192,24 @@ protected ApplicationMirror newApplicationMirror() {
173192
// // We can have removeFromRepository();
174193
// return Optional.empty();
175194
// }
195+
196+
static {
197+
AccessHelper.initHandler(ApplicationAccessHandler.class, new ApplicationAccessHandler() {
198+
199+
@Override
200+
public ApplicationHandle<?, ?> getApplicationConfigurationHandle(ApplicationConfiguration configuration) {
201+
return configuration.handle();
202+
}
203+
204+
@Override
205+
public ApplicationSetup getApplicationHandleApplication(ApplicationHandle<?, ?> handle) {
206+
return handle.application;
207+
}
208+
209+
@Override
210+
public ApplicationHandle<?, ?> getApplicationMirrorHandle(ApplicationMirror mirror) {
211+
return mirror.handle;
212+
}
213+
});
214+
}
176215
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
public non-sealed class ApplicationMirror implements ComponentMirror, ApplicationBuildLocal.Accessor {
4747

4848
/** The application's handle. */
49-
private final ApplicationHandle<?, ?> handle;
49+
final ApplicationHandle<?, ?> handle;
5050

5151
/**
5252
* Create a new application mirror.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ default boolean isManaged() {
6868
*/
6969
ApplicationTemplate<H> withRootContainer(ContainerTemplate<?> template);
7070

71+
static <I> Builder<I> builder(Class<I> hostClass) {
72+
throw new UnsupportedOperationException();
73+
}
74+
75+
static <I> Builder<I> builder(Op<I> hostOp) {
76+
throw new UnsupportedOperationException();
77+
}
78+
79+
interface Builder<I> {
80+
81+
Builder<I> unmanaged();
82+
83+
ApplicationTemplate<ApplicationHandle<I, ApplicationConfiguration>> build();
84+
85+
<H extends ApplicationHandle<I, ?>> ApplicationTemplate<H> build(Class<? super H> handleClass,
86+
Function<? super ApplicationInstaller<H>, ? extends H> handleFactory);
87+
}
7188
// /**
7289
// * Create a new application template, that will use
7390
// *

0 commit comments

Comments
 (0)