Skip to content

Commit 0c606b0

Browse files
committed
updates
1 parent af9a3de commit 0c606b0

File tree

29 files changed

+472
-216
lines changed

29 files changed

+472
-216
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import app.packed.application.App;
1919
import app.packed.application.ApplicationTemplate;
2020
import app.packed.application.BootstrapApp;
21-
import app.packed.application.BootstrapImage;
2221
import app.packed.assembly.Assembly;
2322
import app.packed.container.Wirelet;
2423
import app.packed.runtime.RunState;
@@ -89,9 +88,9 @@ class ServiceLocatorBootstrap {
8988
public static final class Image {
9089

9190
/** The bootstrap image we are delegating to */
92-
private final BootstrapImage<?> image;
91+
private final BootstrapApp.Image<?> image;
9392

94-
private Image(BootstrapImage<?> image) {
93+
private Image(BootstrapApp.Image<?> image) {
9594
this.image = image;
9695
}
9796

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import app.packed.application.ApplicationTemplate;
2222
import app.packed.application.BootstrapApp;
23-
import app.packed.application.BootstrapImage;
2423
import app.packed.component.guest.ComponentHostContext;
2524
import app.packed.component.guest.FromGuest;
2625
import app.packed.runtime.ManagedLifecycle;
@@ -67,7 +66,7 @@ public String toString() {
6766
}
6867

6968
/** Implementation of {@link app.packed.application.App.Image}. */
70-
record AppImage(BootstrapImage<PackedJobApp> image) implements JobApp.Image {
69+
record AppImage(BootstrapApp.Image<PackedJobApp> image) implements JobApp.Image {
7170

7271
/** {@inheritDoc} */
7372
@Override

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

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

55
import app.packed.application.App.Launcher;
66
import app.packed.assembly.Assembly;
7-
import app.packed.binding.Key;
87
import app.packed.container.Wirelet;
98
import app.packed.runtime.RunState;
109
import app.packed.runtime.StopOption;
@@ -108,14 +107,19 @@ public interface App extends AutoCloseable, ApplicationInterface {
108107
*/
109108
// By default I think it is single launchable...
110109
// Mayb
111-
static App.Image imageOf(Assembly assembly, Wirelet... wirelets) {
110+
static Image imageOf(Assembly assembly, Wirelet... wirelets) {
112111
return new PackedApp.AppImage(PackedApp.BOOTSTRAP_APP.imageOf(assembly, wirelets));
113112
}
114113

115-
static App.Launcher launcherOf(Assembly assembly, Wirelet... wirelets) {
114+
static Launcher launcherOf(Assembly assembly, Wirelet... wirelets) {
116115
throw new UnsupportedOperationException();
117116
}
118117

118+
static void main(String[] args) {
119+
// launcher(
120+
CliLaunchers.mainArgs(App.launcherOf(null), args).start();
121+
}
122+
119123
/**
120124
* Creates a mirror representation of the application for analysis purposes.
121125
*
@@ -164,23 +168,6 @@ static void run(Assembly assembly, Wirelet... wirelets) {
164168
PackedApp.BOOTSTRAP_APP.launch(RunState.TERMINATED, assembly, wirelets);
165169
}
166170

167-
/**
168-
* Builds and starts an application, returning when it reaches the {@link RunState#RUNNING} state.
169-
*
170-
* @param assembly
171-
* the application's assembly
172-
* @param wirelets
173-
* optional wirelets for configuration
174-
* @return the running application instance
175-
* @throws app.packed.build.BuildException
176-
* if the application failed to build
177-
* @throws UnhandledApplicationException
178-
* if the application failed to start
179-
*/
180-
static App start(Assembly assembly, Wirelet... wirelets) {
181-
return PackedApp.BOOTSTRAP_APP.launch(RunState.RUNNING, assembly, wirelets);
182-
}
183-
184171
/**
185172
* Tests an application using the provided test consumer.
186173
*
@@ -199,6 +186,23 @@ static App start(Assembly assembly, Wirelet... wirelets) {
199186
// throw new UnsupportedOperationException();
200187
// }
201188

189+
/**
190+
* Builds and starts an application, returning when it reaches the {@link RunState#RUNNING} state.
191+
*
192+
* @param assembly
193+
* the application's assembly
194+
* @param wirelets
195+
* optional wirelets for configuration
196+
* @return the running application instance
197+
* @throws app.packed.build.BuildException
198+
* if the application failed to build
199+
* @throws UnhandledApplicationException
200+
* if the application failed to start
201+
*/
202+
static App start(Assembly assembly, Wirelet... wirelets) {
203+
return PackedApp.BOOTSTRAP_APP.launch(RunState.RUNNING, assembly, wirelets);
204+
}
205+
202206
/**
203207
* Builds and verifies an application without running it.
204208
*
@@ -219,50 +223,9 @@ static void verify(Assembly assembly, Wirelet... wirelets) {
219223
/**
220224
* Represents a pre-built application image that can be used to launch application instances.
221225
*/
222-
interface Image extends App.Launcher {
226+
interface Image extends ApplicationImage, App.Launcher {}
223227

224-
/**
225-
* @return an application
226-
* @throws IllegalStateException
227-
* the image is single usage, and has already been used.
228-
*/
229-
// Virker ikke med Containers....
230-
default ApplicationMirror mirror() {
231-
throw new UnsupportedOperationException();
232-
}
233-
234-
/**
235-
* Builds an application and prints its structure to {@code System.out}.
236-
*
237-
* <p>
238-
* This is a convenience method for debugging and analysis purposes.
239-
*
240-
* @param assembly
241-
* the application's assembly
242-
* @param wirelets
243-
* optional wirelets for configuration
244-
*/
245-
default void print() {
246-
mirror().printer().print();
247-
}
248-
}
249-
250-
interface Launcher {
251-
default <T> Launcher provide(Class<T> key, T value) {
252-
return this;
253-
}
254-
255-
default <T> Launcher provide(Key<T> key, T value) {
256-
return this;
257-
}
258-
259-
default Launcher provide(Object object) {
260-
return this;
261-
}
262-
263-
default Launcher args(String... args) {
264-
return this;
265-
}
228+
interface Launcher extends ApplicationLauncher {
266229

267230
// Config also
268231

@@ -299,11 +262,6 @@ default Launcher ignoreAllExceptions() {
299262
*/
300263
App start();
301264
}
302-
303-
static void main(String[] args) {
304-
// launcher(
305-
CliLaunchers.mainArgs(App.launcherOf(null), args).start();
306-
}
307265
}
308266

309267
// Det er jo kun images der er problemet...

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package app.packed.application;
1717

18+
import app.packed.application.BootstrapApp.Image;
1819
import app.packed.build.BuildGoal;
1920
import app.packed.component.ComponentHandle;
2021
import app.packed.component.ComponentPath;
@@ -39,7 +40,7 @@ public non-sealed class ApplicationHandle<A, C extends ApplicationConfiguration>
3940

4041
/** An image if the application has been constructed using {@link BuildGoal#IMAGE}. */
4142
@Nullable
42-
private final BootstrapImage<A> image;
43+
private final Image<A> image;
4344

4445
/** The lazy generated application mirror. */
4546
@Nullable
@@ -56,7 +57,7 @@ public ApplicationHandle(ApplicationInstaller<?> installer) {
5657
this.application = inst.toSetup();
5758

5859
// Build an image if that is the target.
59-
BootstrapImage<A> img = null;
60+
BootstrapApp.Image<A> img = null;
6061
if (inst.buildProcess.goal() == BuildGoal.IMAGE) {
6162
img = new ImageEager<>(this);
6263
if (!inst.optionBuildReusableImage) {
@@ -109,8 +110,8 @@ public final C configuration() {
109110
* if the application was build with {@link BuildGoal#IMAGE}.
110111
*/
111112
// Tror jeg fjerner den her... BaseImage er kun noget man bruger ved rødder tænker jeg???
112-
public final BootstrapImage<A> image() {
113-
BootstrapImage<A> i = image;
113+
public final BootstrapApp.Image<A> image() {
114+
BootstrapApp.Image<A> i = image;
114115
if (i == null) {
115116
throw new IllegalStateException("The application must be installed with BuildImage, was " + application.goal);
116117
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2008 Kasper Nielsen.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package app.packed.application;
17+
18+
/**
19+
* A
20+
*/
21+
public interface ApplicationImage extends ApplicationLauncher {
22+
23+
/** {@return a mirror of the application} */
24+
ApplicationMirror mirror();
25+
26+
/** {@return the name of the application} */
27+
String name();
28+
29+
/**
30+
* Prints the structure of the application to {@code System.out}.
31+
* <p>
32+
* This is a convenience method for debugging and analysis purposes.
33+
*/
34+
default void print() {
35+
mirror().printer().print();
36+
}
37+
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
*
2020
*/
2121
// Temporary Marker interface.
22-
public interface ApplicationInterface {
23-
24-
}
22+
public interface ApplicationInterface {}
2523

2624
//App (void)
2725
//JobApp (Noget med et <T> result)
2826
//CliApp (Noget med exit codes, default install shutdown handler)
2927
//TestApp
3028
//ServiceLocator (Unmanaged)
31-
// Kan vel baade vaere App og Pod
29+
// Kan vel baade vaere App og Pod
3230

3331
//DaemonApp <-- App, Job or CliApp, med restart?
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2008 Kasper Nielsen.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package app.packed.application;
17+
18+
import app.packed.binding.Key;
19+
20+
/**
21+
*
22+
*/
23+
public interface ApplicationLauncher {
24+
25+
default ApplicationLauncher args(String... args) {
26+
throw new UnsupportedOperationException();
27+
}
28+
29+
// Kan vi vel smide på imaged
30+
default ApplicationLauncher named(String name) {
31+
throw new UnsupportedOperationException();
32+
}
33+
34+
default <T> ApplicationLauncher provide(Class<? super T> key, T value) {
35+
return provide(Key.of(key), value);
36+
}
37+
38+
<T> ApplicationLauncher provide(Key<? super T> key, T value);
39+
40+
@SuppressWarnings({ "unchecked", "rawtypes" })
41+
default ApplicationLauncher provide(Object object) {
42+
return provide((Class) object.getClass(), object);
43+
}
44+
}

0 commit comments

Comments
 (0)