Skip to content

Commit fd62902

Browse files
committed
asd
a
1 parent 01acafc commit fd62902

File tree

60 files changed

+593
-430
lines changed

Some content is hidden

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

60 files changed

+593
-430
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.List;
2222

2323
import app.packed.operation.OperationHandle;
24-
import app.packed.operation.OperationTemplate.Installer;
24+
import app.packed.operation.OperationInstaller;
2525

2626
/**
2727
*
@@ -36,7 +36,7 @@ final class CliCommandHandle extends OperationHandle<CliCommandConfiguration> {
3636
/**
3737
* @param installer
3838
*/
39-
CliCommandHandle(Installer installer, CliNamespaceHandle namespace) {
39+
CliCommandHandle(OperationInstaller installer, CliNamespaceHandle namespace) {
4040
super(installer);
4141
this.namespace = requireNonNull(namespace);
4242
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import app.packed.container.ContainerBuildLocal;
2727
import app.packed.container.ContainerConfiguration;
2828
import app.packed.container.ContainerHandle;
29+
import app.packed.container.ContainerInstaller;
2930
import app.packed.container.ContainerTemplate;
3031
import app.packed.container.Wirelet;
3132
import app.packed.extension.ExtensionHandle;
@@ -92,11 +93,11 @@ public CliNamespaceConfiguration namespace() {
9293
return ns().configuration(this);
9394
}
9495

95-
private ContainerTemplate.Installer<?> newContainer() {
96+
private ContainerInstaller<?> newContainer() {
9697
if (isInApplicationLifetime()) {
9798
throw new UnsupportedOperationException("This method must be called from an extension in the application lifetime");
9899
}
99-
ContainerTemplate.Installer<?> cb = base().newContainer(ContainerTemplate.GATEWAY);
100+
ContainerInstaller<?> cb = base().newContainer(ContainerTemplate.GATEWAY);
100101
// CT.addEntryPointErrorMessage("Lifetime must container at least one entry point with CliCommand")
101102

102103
return cb;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import app.packed.bean.BeanInstallationException;
2222
import app.packed.build.BuildActor;
2323
import app.packed.namespace.NamespaceHandle;
24+
import app.packed.namespace.NamespaceInstaller;
2425
import app.packed.namespace.NamespaceTemplate;
2526
import app.packed.operation.OperationTemplate;
2627

@@ -35,7 +36,7 @@ final class CliNamespaceHandle extends NamespaceHandle<CliExtension, CliNamespac
3536
/** All the commands within the namespace. */
3637
final LinkedHashMap<String, CliCommandHandle> oldCommands = new LinkedHashMap<>();
3738

38-
CliNamespaceHandle(NamespaceTemplate.Installer installer) {
39+
CliNamespaceHandle(NamespaceInstaller installer) {
3940
super(installer);
4041
}
4142

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

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

18-
import app.packed.operation.OperationTemplate.Installer;
18+
import app.packed.operation.OperationInstaller;
1919
import internal.app.packed.concurrent.ScheduledDaemon;
2020

2121
/** An operation handle for a daemon operation. */
@@ -27,7 +27,7 @@ final class DaemonOperationHandle extends ThreadedOperationHandle<DaemonOperatio
2727

2828
boolean useVirtual;
2929

30-
DaemonOperationHandle(Installer installer, ThreadNamespaceHandle namespace) {
30+
DaemonOperationHandle(OperationInstaller installer, ThreadNamespaceHandle namespace) {
3131
super(installer, namespace);
3232
}
3333

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

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

18-
import app.packed.operation.OperationTemplate.Installer;
18+
import app.packed.operation.OperationInstaller;
1919
import app.packed.util.Nullable;
2020
import internal.app.packed.concurrent.ScheduleImpl;
2121
import internal.app.packed.concurrent.ScheduledOperation;
@@ -31,7 +31,7 @@ public final class ScheduledOperationHandle extends ThreadedOperationHandle<Sche
3131
/**
3232
* @param installer
3333
*/
34-
public ScheduledOperationHandle(Installer installer, ThreadNamespaceHandle namespace) {
34+
public ScheduledOperationHandle(OperationInstaller installer, ThreadNamespaceHandle namespace) {
3535
super(installer, namespace);
3636
}
3737

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import app.packed.bean.BeanConfiguration;
2121
import app.packed.build.BuildActor;
2222
import app.packed.namespace.NamespaceHandle;
23+
import app.packed.namespace.NamespaceInstaller;
2324
import app.packed.namespace.NamespaceTemplate;
2425
import internal.app.packed.concurrent.ExecutorConfiguration;
2526
import internal.app.packed.concurrent.ScheduledDaemon;
@@ -41,7 +42,7 @@ final class ThreadNamespaceHandle extends NamespaceHandle<ThreadExtension, Threa
4142
* @param installer
4243
* the namespace installer
4344
*/
44-
protected ThreadNamespaceHandle(NamespaceTemplate.Installer installer) {
45+
protected ThreadNamespaceHandle(NamespaceInstaller installer) {
4546
super(installer);
4647
}
4748

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

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

2020
import app.packed.operation.OperationConfiguration;
2121
import app.packed.operation.OperationHandle;
22-
import app.packed.operation.OperationTemplate.Installer;
22+
import app.packed.operation.OperationInstaller;
2323

2424
/**
2525
*
@@ -31,7 +31,7 @@ public class ThreadedOperationHandle<C extends OperationConfiguration> extends O
3131
/**
3232
* @param installer
3333
*/
34-
public ThreadedOperationHandle(Installer installer, ThreadNamespaceHandle namespace) {
34+
public ThreadedOperationHandle(OperationInstaller installer, ThreadNamespaceHandle namespace) {
3535
super(installer);
3636
this.namespace = requireNonNull(namespace);
3737
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public non-sealed class ApplicationHandle<A, C extends ApplicationConfiguration>
6060
* @param installer
6161
* the installer for the application
6262
*/
63-
public ApplicationHandle(ApplicationTemplate.Installer<?> installer) {
63+
public ApplicationHandle(ApplicationInstaller<?> installer) {
6464
PackedApplicationInstaller<?> inst = (PackedApplicationInstaller<?>) installer;
6565
this.application = inst.toHandle();
6666

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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.application.repository.ApplicationLauncher;
19+
import app.packed.assembly.Assembly;
20+
import app.packed.container.Wirelet;
21+
import internal.app.packed.application.PackedApplicationInstaller;
22+
23+
/** An installer for applications. */
24+
public sealed interface ApplicationInstaller<H extends ApplicationHandle<?, ?>> permits PackedApplicationInstaller {
25+
26+
/**
27+
* Add the specified tags to the application.
28+
*
29+
* @param tags
30+
* the tags to add
31+
* @return this configurator
32+
* @see ApplicationMirror#componentTags()
33+
* @see ApplicationHandle#componentTag(String...)
34+
* @see ApplicationConfiguration#componentTag(String...)
35+
*/
36+
ApplicationInstaller<H> componentTag(String... tags);
37+
38+
/**
39+
* <p>
40+
* The handle that is returned will be non-configurable.
41+
*
42+
* @param assembly
43+
* @param wirelets
44+
* @return
45+
*/
46+
H install(Assembly assembly, Wirelet... wirelets);
47+
48+
default ApplicationLauncher<?> installAtRuntime(Assembly assembly, Wirelet... wirelets) {
49+
throw new UnsupportedOperationException();
50+
}
51+
52+
ApplicationInstaller<H> named(String name);
53+
54+
<T> ApplicationInstaller<H> setLocal(ApplicationBuildLocal<T> local, T value);
55+
}

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,43 @@
1616
package app.packed.application;
1717

1818
import java.util.Optional;
19+
import java.util.function.Consumer;
1920
import java.util.stream.Stream;
2021

2122
import app.packed.application.repository.ApplicationLauncher;
2223
import app.packed.application.repository.ManagedInstance;
2324
import app.packed.extension.BaseExtension;
2425
import app.packed.extension.BaseExtensionPoint;
26+
import internal.app.packed.application.PackedApplicationTemplate;
2527
import internal.app.packed.extension.ExtensionSetup;
2628

2729
/**
2830
* An application repository that can be used to install applications at runtime or retrieve applications that were
2931
* installed at build-time.
3032
* <p>
31-
* This interface only supported unmanaged applications.
32-
* If you need to create managed applications uses {@link app.packed.application.guestmanager.ManagedApplicationRepository}.
33+
* This interface only supported unmanaged applications. If you need to create managed applications uses
34+
* {@link app.packed.application.guestmanager.ManagedApplicationRepository}.
3335
*/
3436
public interface ApplicationRepository<I, H extends ApplicationHandle<I, ?>> {
3537

36-
Optional<H> handle(String name);
37-
38-
/**
39-
* {@return a stream of all applications (represented by their application handle} that have been installed into the
40-
* repository}
41-
*/
42-
Stream<H> handles();
43-
4438
Optional<ManagedInstance<I>> instance(String name);
4539

4640
Stream<ManagedInstance<I>> instances();
4741

4842
Optional<ApplicationLauncher<I>> launcher(String name);
4943

44+
/**
45+
* {@return a stream of all applications (represented by their application handle} that have been installed into the
46+
* repository}
47+
*/
5048
Stream<ApplicationLauncher<I>> launchers();
5149

5250
/**
5351
* Creates an installer for a new application based on {@link #template()}.
5452
*
5553
* @return an installer for a new application
5654
*/
57-
ApplicationTemplate.Installer<H> newApplication();
55+
ApplicationLauncher<I> install(Consumer<? super ApplicationInstaller<H>> installer);
5856

5957
/** {@return the template that is used for all applications in this repository} */
6058
ApplicationTemplate<H> template();
@@ -64,19 +62,23 @@ public interface ApplicationRepository<I, H extends ApplicationHandle<I, ?>> {
6462
}
6563

6664
// Syntes maaske vi skal tage H med.. Saa kan vi lave en god default key
67-
static <A, H extends ApplicationHandle<A, ?>> ApplicationRepositoryConfiguration<A, H> install(Class<H> handleKind, ApplicationTemplate<H> template,
68-
BaseExtension extension) {
69-
return ApplicationRepositoryHandle.install(handleKind, template, ExtensionSetup.crack(extension), ExtensionSetup.crack(extension).container.assembly);
65+
static <A, H extends ApplicationHandle<A, ?>> ApplicationRepositoryConfiguration<A, H> install(ApplicationTemplate<H> template, BaseExtension extension) {
66+
// Hmm, maaske flyt tilbage til config, skal lave de samme checks for extension der laver det
67+
PackedApplicationTemplate<H> t = (PackedApplicationTemplate<H>) template;
68+
if (t.guestClass() == Void.class) {
69+
throw new UnsupportedOperationException("Does not support application templates of Void.class guest type");
70+
}
71+
return ApplicationRepositoryHandle.install(t, ExtensionSetup.crack(extension), ExtensionSetup.crack(extension).container.assembly);
7072
}
7173

72-
static <A, H extends ApplicationHandle<A, ?>> ApplicationRepositoryConfiguration<A, H> provide(Class<H> handleKind, ApplicationTemplate<H> template,
73-
BaseExtension extension) {
74-
return install(handleKind, template, extension).provide();
74+
static <A, H extends ApplicationHandle<A, ?>> ApplicationRepositoryConfiguration<A, H> provide(ApplicationTemplate<H> template, BaseExtension extension) {
75+
return install(template, extension).provide();
7576
}
7677

7778
// Shared with ContainerRepository
7879
interface Entry {
7980
boolean isBuild();
81+
8082
boolean isLazy(); // Built on first usage
8183

8284
// An application can be, NA, INSTALLING, AVAILABLE

0 commit comments

Comments
 (0)