Skip to content

Commit a8914af

Browse files
committed
qwe
1 parent 4a39c77 commit a8914af

File tree

291 files changed

+6562
-2568
lines changed

Some content is hidden

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

291 files changed

+6562
-2568
lines changed

TODO.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ Cleanup bindings
1414
Figure out how binding-handles work
1515

1616

17-
----- app.packed.namespace -----
17+
----- app.packed.namespace -----
18+
19+
20+
21+
22+
---- Modules
23+
packed-base
24+
packed-base-devtools <---- Testing
25+
packed-base-devops <---- What went wrong, Observability

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
@Retention(RetentionPolicy.RUNTIME)
3232
@Documented
3333
@NamespaceOperation
34-
@OnAnnotatedMethod(extension = CliExtension.class)
34+
@OnAnnotatedMethod(introspector = CliExtension.MyI.class)
3535
public @interface CliCommand {
3636

37-
/**w
38-
* The name(s) of the command. If no name is specified. The name of the annotated method is used. Method names starting
39-
* with underscores will automaticalOsly be renamed to hyphens.
37+
/**
38+
* w The name(s) of the command. If no name is specified. The name of the annotated method is used. Method names
39+
* starting with underscores will automaticalOsly be renamed to hyphens.
4040
*
4141
* @return the name(s) of the command
4242
*/

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
/**
3535
* An extension that
3636
*/
37+
38+
// Det er faktisk kun CliCommand der stjaeler execution
39+
// CliOption er ikke noget problem
3740
public class CliExtension extends FrameworkExtension<CliExtension> {
3841

3942
/**
@@ -71,21 +74,17 @@ CliNamespaceHandle ns() {
7174
return applicationRoot().namespaceLazy(CliNamespaceHandle.TEMPLATE, "main");
7275
}
7376

74-
/** {@inheritDoc} */
75-
@Override
76-
protected BeanIntrospector newBeanIntrospector() {
77-
return new BeanIntrospector() {
78-
79-
/** {@inheritDoc} */
80-
@Override
81-
public void onAnnotatedMethod(Annotation hook, BeanIntrospector.OnMethod method) {
82-
if (hook instanceof CliCommand c) {
83-
ns().process(CliExtension.this, c, method);
84-
} else {
85-
super.onAnnotatedMethod(hook, method);
86-
}
77+
static class MyI extends BeanIntrospector<CliExtension> {
78+
79+
/** {@inheritDoc} */
80+
@Override
81+
public void onAnnotatedMethod(Annotation hook, BeanIntrospector.OnMethod method) {
82+
if (hook instanceof CliCommand c) {
83+
extension().ns().process(extension(), c, method);
84+
} else {
85+
super.onAnnotatedMethod(hook, method);
8786
}
88-
};
87+
}
8988
}
9089

9190
public CliNamespaceConfiguration namespace() {
@@ -113,9 +112,9 @@ public ContainerConfiguration newContainer(Wirelet... wirelets) {
113112
}
114113

115114
@Override
116-
protected void onApplicationClose() {
115+
protected void onClose() {
117116
System.out.println("Have commands for " + ns().oldCommands.keySet());
118117

119-
super.onApplicationClose();
118+
super.onClose();
120119
}
121120
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import java.util.function.Consumer;
1919

20-
import app.packed.build.BuildActor;
20+
import app.packed.component.ComponentRealm;
2121
import app.packed.namespace.NamespaceBuildHook;
2222
import app.packed.namespace.NamespaceConfiguration;
2323

@@ -28,7 +28,7 @@ public final class CliNamespaceConfiguration extends NamespaceConfiguration<CliE
2828

2929
final CliNamespaceHandle handle;
3030

31-
public CliNamespaceConfiguration(CliNamespaceHandle o, CliExtension cli, BuildActor actor) {
31+
public CliNamespaceConfiguration(CliNamespaceHandle o, CliExtension cli, ComponentRealm actor) {
3232
super(o, cli, actor);
3333
this.handle = o;
3434
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import app.packed.bean.BeanInstallationException;
2121
import app.packed.bean.scanning.BeanIntrospector;
22-
import app.packed.build.BuildActor;
22+
import app.packed.component.ComponentRealm;
2323
import app.packed.namespace.NamespaceHandle;
2424
import app.packed.namespace.NamespaceInstaller;
2525
import app.packed.namespace.NamespaceTemplate;
@@ -47,7 +47,7 @@ protected CliNamespaceMirror newNamespaceMirror() {
4747
}
4848

4949
@Override
50-
protected CliNamespaceConfiguration newNamespaceConfiguration(CliExtension e, BuildActor actor) {
50+
protected CliNamespaceConfiguration newNamespaceConfiguration(CliExtension e, ComponentRealm actor) {
5151
return new CliNamespaceConfiguration(this, e, actor);
5252
}
5353

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.stream.Stream;
1919

2020
import app.packed.namespace.NamespaceMirror;
21+
import app.packed.operation.OperationMirror;
2122

2223
/**
2324
* Represents a CLI namespace where {@link CliCommandMirror commands} and global {@link CliOption options} are unique.
@@ -33,8 +34,9 @@ public final class CliNamespaceMirror extends NamespaceMirror<CliExtension> {
3334
}
3435

3536
/** {@return all commands within the namespace.} */
36-
public Stream<CliCommandMirror> commands() {
37-
return operations(CliCommandMirror.class);
37+
// Hmm this includes operations owned by extensions
38+
public OperationMirror.OfStream<CliCommandMirror> commands() {
39+
return operations().ofType(CliCommandMirror.class);
3840
}
3941

4042
/** {@return all commands within the namespace.} */

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

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -16,99 +16,28 @@
1616
package app.packed.cli.other;
1717

1818
import app.packed.application.App;
19-
import app.packed.application.ApplicationTemplate;
20-
import app.packed.application.BaseImage;
21-
import app.packed.application.BootstrapApp;
2219
import app.packed.assembly.Assembly;
2320
import app.packed.container.Wirelet;
2421
import app.packed.container.Wirelets;
25-
import app.packed.runtime.RunState;
2622

2723
/**
2824
*
2925
*/
30-
//Like App but calls system exit and prints stack
31-
//traces to system.err
26+
// Maybe it is just a thin wrapper for App
27+
public interface CliApp {
3228

33-
// CliApp er maaske i virkeligheden mere noget der har praecist mest 1 entrypoint.
29+
// But isn't this normally in the code???
30+
// Maybe a StopOption?
31+
// ObjectToInt(ApplicationException->int errorCode)
3432

35-
// Er ikke noedvendigvis managed. Eller det kan den jo ligesaa godt eftersom vi ikke
36-
// har start/stop. Alt koere indefor en operation
3733

38-
public final class CliApp {
39-
40-
/** Nope. */
41-
private CliApp() {}
42-
43-
public static void run(Assembly assembly, String[] args, Wirelet... wirelets) {
44-
App.run(assembly);
45-
}
46-
47-
public static void run(Assembly assembly, Wirelet... wirelets) {
48-
App.run(assembly);
49-
}
50-
51-
public static void mirrorOf(Assembly assembly, String[] args, Wirelet... wirelets) {
52-
bootstrap().mirrorOf(assembly, Wirelets.argList(args).andThen(wirelets));
53-
}
54-
55-
public static int runWithExitCode(Assembly assembly, String[] args) {
56-
App.run(assembly);
57-
return 0;
58-
}
59-
60-
public static void verify(Assembly assembly, String[] args) {
61-
bootstrap().verify(assembly);
34+
static void run(Assembly assembly, Wirelet... wirelets) {
35+
// Maybe checked run...
36+
App.run(assembly, wirelets);
6237
}
6338

64-
/**
65-
* Returns the bootstrap app. If interfaces allowed non-public fields we would have stored it in a field instead of this
66-
* method.
67-
*/
68-
private static BootstrapApp<Void> bootstrap() {
69-
class ServiceLocatorBootstrap {
70-
private static final BootstrapApp<Void> APP = BootstrapApp.of(ApplicationTemplate.ofManaged(Void.class));
71-
}
72-
return ServiceLocatorBootstrap.APP;
73-
}
74-
//
75-
// public static final class Result {
76-
//
77-
// }
78-
79-
/** An application image for App. */
80-
public static final class Image {
81-
82-
/** The bootstrap image we are delegating to */
83-
private final BaseImage<?> image;
84-
85-
private Image(BaseImage<?> image) {
86-
this.image = image;
87-
}
88-
89-
/** Runs the application represented by this image. */
90-
public void run() {
91-
image.launch(RunState.TERMINATED);
92-
}
93-
94-
/**
95-
* Runs the application represented by this image.
96-
*
97-
* @param wirelets
98-
* optional wirelets
99-
*/
100-
public void run(Wirelet... wirelets) {
101-
image.launch(RunState.TERMINATED, wirelets);
102-
}
103-
}
104-
105-
public class Launcher {
106-
// Tror faktisk vi er chatty som default
107-
// Sgu da ikke hvis vi er en CLI. Det vil jeg da vaere ret traet af.
108-
// CliApp.launcher().silent().run();
109-
Launcher silent() {
110-
return this;
111-
}
39+
static void run(Assembly assembly, String[] args, Wirelet... wirelets) {
40+
// Maybe checked run...
41+
App.run(assembly, Wirelets.argList(args).andThen(wirelets));
11242
}
11343
}
114-
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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.cli.other;
17+
18+
import app.packed.application.App;
19+
import app.packed.application.ApplicationTemplate;
20+
import app.packed.application.BaseImage;
21+
import app.packed.application.BootstrapApp;
22+
import app.packed.assembly.Assembly;
23+
import app.packed.container.Wirelet;
24+
import app.packed.runtime.RunState;
25+
26+
/**
27+
*
28+
*/
29+
//Like App but calls system exit and prints stack
30+
//traces to system.err
31+
32+
// CliApp er maaske i virkeligheden mere noget der har praecist mest 1 entrypoint.
33+
34+
// Er ikke noedvendigvis managed. Eller det kan den jo ligesaa godt eftersom vi ikke
35+
// har start/stop. Alt koere indefor en operation
36+
37+
// CliApp
38+
//// Always takes String[] (Why cli otherwise?) when launching (Not mirrors ect)
39+
//// Calls system exit on failure
40+
//// Install a shutdown hook if managed.
41+
42+
// Vs App
43+
//// I don't it is Closable. Actually I think it may only have static methods?
44+
/////// Or maybe return a (manual) cliApp with system. and system.exit();
45+
//// I think these are two main differences
46+
47+
public final class PackedCliApp {
48+
49+
/** Nope. */
50+
private PackedCliApp() {}
51+
52+
public static void run(Assembly assembly, String[] args, Wirelet... wirelets) {
53+
App.run(assembly);
54+
}
55+
//
56+
// public static void run(Assembly assembly, Wirelet... wirelets) {
57+
// App.run(assembly);
58+
// }
59+
60+
public static void mirrorOf(Assembly assembly, Wirelet... wirelets) {
61+
bootstrap().mirrorOf(assembly, wirelets);
62+
}
63+
64+
public static int runNoSystemExit(Assembly assembly, String[] args) {
65+
App.run(assembly);
66+
return 0;
67+
}
68+
69+
public static void verify(Assembly assembly) {
70+
bootstrap().verify(assembly);
71+
}
72+
73+
/**
74+
* Returns the bootstrap app. If interfaces allowed non-public fields we would have stored it in a field instead of this
75+
* method.
76+
*/
77+
private static BootstrapApp<Void> bootstrap() {
78+
class ServiceLocatorBootstrap {
79+
private static final BootstrapApp<Void> APP = BootstrapApp.of(ApplicationTemplate.ofManaged(Void.class));
80+
}
81+
return ServiceLocatorBootstrap.APP;
82+
}
83+
//
84+
// public static final class Result {
85+
//
86+
// }
87+
88+
/** An application image for App. */
89+
public static final class Image {
90+
91+
/** The bootstrap image we are delegating to */
92+
private final BaseImage<?> image;
93+
94+
private Image(BaseImage<?> image) {
95+
this.image = image;
96+
}
97+
98+
/** Runs the application represented by this image. */
99+
public void run(String[] args) {
100+
image.launch(RunState.TERMINATED);
101+
}
102+
103+
/**
104+
* Runs the application represented by this image.
105+
*
106+
* @param wirelets
107+
* optional wirelets
108+
*/
109+
public void run(String[] args, Wirelet... wirelets) {
110+
image.launch(RunState.TERMINATED, wirelets);
111+
}
112+
}
113+
114+
public class Launcher {
115+
// Tror faktisk vi er chatty som default
116+
// Sgu da ikke hvis vi er en CLI. Det vil jeg da vaere ret traet af.
117+
// CliApp.launcher().silent().run();
118+
Launcher silent() {
119+
return this;
120+
}
121+
}
122+
}
123+

0 commit comments

Comments
 (0)