Skip to content

Commit 927f680

Browse files
committed
r
1 parent 9926a69 commit 927f680

9 files changed

Lines changed: 103 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Optional;
1919
import java.util.stream.Stream;
2020

21-
import app.packed.namespaceold.OverviewMirror;
21+
import app.packed.namespace.OverviewMirror;
2222
import app.packed.operation.OperationMirror;
2323

2424
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import app.packed.component.ComponentRealm;
2121
import app.packed.extension.BaseExtension;
22-
import app.packed.namespaceold.OverviewMirror;
22+
import app.packed.namespace.OverviewMirror;
2323

2424
/**
2525
* A mirror for a job namespace. All jobs within a

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import app.packed.container.ContainerMirror;
1818
import app.packed.extension.Extension;
1919
import app.packed.namespace.NamespaceMirror;
20-
import app.packed.namespaceold.OverviewMirror;
20+
import app.packed.namespace.OverviewMirror;
2121
import app.packed.operation.OperationMirror;
2222
import app.packed.service.ServiceContract;
2323
import app.packed.util.TreeView;

modules/packed/src/main/java/app/packed/concurrent/ThreadOverviewMirror.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package app.packed.concurrent;
1717

1818
import app.packed.extension.BaseExtension;
19-
import app.packed.namespaceold.OverviewMirror;
19+
import app.packed.namespace.OverviewMirror;
2020

2121
/**
2222
* A mirror for a thread namespace.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2026 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.extension;
17+
18+
import app.packed.component.ComponentRealm;
19+
import app.packed.extension.Ugly.SomeN;
20+
21+
/**
22+
*
23+
*/
24+
abstract class Ugly<N extends SomeN, E extends Extension<E>> {
25+
26+
protected void onNewApplication() {}
27+
protected void onNewNamespace(N namespace) {}
28+
protected void onNewContainer(E extension) {}
29+
30+
protected void newOverview(Object overviewConfig) {}
31+
32+
static class SomeN {
33+
ComponentRealm realm;
34+
}
35+
}

modules/packed/src/main/java/app/packed/namespace/NamespaceMirror.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,24 @@
3131
import internal.app.packed.extension.base.BaseExtensionBeanIntrospector;
3232
import internal.app.packed.namespace.NamespaceSetup;
3333
import internal.app.packed.util.PackedTreeView;
34+
import internal.app.packed.util.accesshelper.AccessHelper;
35+
import internal.app.packed.util.accesshelper.NamespaceMirrorAccessHandler;
3436

3537
/**
3638
* A mirror representing a namespace.
3739
*/
3840
@AutoService(introspector = NamespaceMirrorBeanIntrospector.class)
3941
public final class NamespaceMirror {
4042

43+
static {
44+
AccessHelper.initHandler(NamespaceMirrorAccessHandler.class, new NamespaceMirrorAccessHandler() {
45+
@Override
46+
public NamespaceMirror newNamespaceMirror(NamespaceSetup namespace) {
47+
return new NamespaceMirror(namespace);
48+
}
49+
});
50+
}
51+
4152
private final NamespaceSetup namespace;
4253

4354
NamespaceMirror(NamespaceSetup namespace) {
@@ -54,6 +65,11 @@ public AssemblyMirror assembly() {
5465
}
5566

5667

68+
/** {@return a stream of all of the bean declared by the user in the application.} */
69+
public Stream<BeanMirror> beans() {
70+
return containers().stream().flatMap(ContainerMirror::beans);
71+
}
72+
5773
/** {@return a mirror of the root container in the application.} */
5874
public ContainerMirror container() {
5975
return namespace.container.mirror();
@@ -64,11 +80,6 @@ public TreeView<ContainerMirror> containers() {
6480
return new PackedTreeView<>(namespace.container, c -> c.namespace == namespace, c -> c.mirror());
6581
}
6682

67-
/** {@return a stream of all of the bean declared by the user in the application.} */
68-
public Stream<BeanMirror> beans() {
69-
return containers().stream().flatMap(ContainerMirror::beans);
70-
}
71-
7283
/** {@return a stream of all of the operations on beans owned by the user in the application.} */
7384
// I think non-synthetic should also be filtered
7485
public OperationMirror.OfStream<OperationMirror> operations() {

modules/packed/src/main/java/app/packed/namespaceold/OverviewMirror.java renamed to modules/packed/src/main/java/app/packed/namespace/OverviewMirror.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package app.packed.namespaceold;
16+
package app.packed.namespace;
1717

1818
import app.packed.extension.Extension;
1919
import app.packed.operation.OperationMirror;

modules/packed/src/main/java/internal/app/packed/namespace/NamespaceSetup.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import java.util.ArrayList;
2121
import java.util.Collections;
2222
import java.util.List;
23+
import java.util.function.Supplier;
2324

2425
import app.packed.component.ComponentKind;
2526
import app.packed.component.ComponentPath;
2627
import app.packed.namespace.NamespaceMirror;
2728
import internal.app.packed.container.ContainerSetup;
2829
import internal.app.packed.util.AbstractNamedTreeNode;
30+
import internal.app.packed.util.accesshelper.NamespaceMirrorAccessHandler;
2931

3032
/**
3133
*
@@ -34,6 +36,9 @@ public final class NamespaceSetup extends AbstractNamedTreeNode<NamespaceSetup>
3436

3537
public final ContainerSetup container;
3638

39+
/** The lazy generated namespace mirror. */
40+
private final Supplier<NamespaceMirror> mirror = StableValue.supplier(() -> NamespaceMirrorAccessHandler.instance().newNamespaceMirror(this));
41+
3742
NamespaceSetup(ContainerSetup container, PackedNamespaceInstaller installer) {
3843
super(null);
3944
this.container = requireNonNull(container);
@@ -60,6 +65,6 @@ public ComponentPath componentPath() {
6065
* @return
6166
*/
6267
public NamespaceMirror mirror() {
63-
throw new UnsupportedOperationException();
68+
return mirror.get();
6469
}
6570
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2026 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 internal.app.packed.util.accesshelper;
17+
18+
import java.util.function.Supplier;
19+
20+
import app.packed.namespace.NamespaceMirror;
21+
import internal.app.packed.namespace.NamespaceSetup;
22+
23+
/**
24+
* Access helper for NamespaceMirror.
25+
*/
26+
public abstract class NamespaceMirrorAccessHandler extends AccessHelper {
27+
28+
private static final Supplier<NamespaceMirrorAccessHandler> CONSTANT = StableValue.supplier(() -> init(NamespaceMirrorAccessHandler.class, NamespaceMirror.class));
29+
30+
public static NamespaceMirrorAccessHandler instance() {
31+
return CONSTANT.get();
32+
}
33+
34+
/**
35+
* Creates a new NamespaceMirror from a NamespaceSetup.
36+
*
37+
* @param namespace the namespace setup
38+
* @return the namespace mirror
39+
*/
40+
public abstract NamespaceMirror newNamespaceMirror(NamespaceSetup namespace);
41+
}

0 commit comments

Comments
 (0)