Skip to content

Commit 0e8765a

Browse files
committed
e
1 parent 1be24c8 commit 0e8765a

File tree

7 files changed

+72
-130
lines changed

7 files changed

+72
-130
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
final class CliNamespaceHandle extends NamespaceHandle<CliExtension, CliNamespaceConfiguration> {
3232

3333
/** The default namespace template. */
34-
static final NamespaceTemplate<CliNamespaceHandle> TEMPLATE = NamespaceTemplate.of(CliNamespaceHandle.class, CliNamespaceHandle::new, c -> {});
34+
static final NamespaceTemplate<CliNamespaceHandle> TEMPLATE = NamespaceTemplate.of(CliNamespaceHandle.class, CliNamespaceHandle::new);
3535

3636
/** All the commands within the namespace. */
3737
final LinkedHashMap<String, CliCommandHandle> oldCommands = new LinkedHashMap<>();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
final class ThreadNamespaceHandle extends NamespaceHandle<ThreadExtension, ThreadNamespaceConfiguration> {
3232

3333
/** The default thread namespace template. */
34-
static final NamespaceTemplate<ThreadNamespaceHandle> TEMPLATE = NamespaceTemplate.of(ThreadNamespaceHandle.class, ThreadNamespaceHandle::new, c -> {});
34+
static final NamespaceTemplate<ThreadNamespaceHandle> TEMPLATE = NamespaceTemplate.of(ThreadNamespaceHandle.class, ThreadNamespaceHandle::new);
3535

3636
ExecutorConfiguration scheduler;
3737

modules/packed/src/main/java/app/packed/bean/BeanTemplate.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ public sealed interface BeanTemplate permits PackedBeanTemplate {
7676
// /** {@return a list of the various lifetime operations for the descriptor's template.} */
7777
// List<OperationTemplate> lifecycleOperations();
7878

79-
80-
/** {@return the bean contexts} */
79+
/** {@return contexts that the bean are in} */
8180
Map<Class<?>, ContextTemplate> contexts();
8281

8382
/**

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

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

18-
import java.util.function.Consumer;
1918
import java.util.function.Function;
2019

2120
import app.packed.namespace.sandbox.BuildPermission;
@@ -33,36 +32,34 @@ public sealed interface NamespaceTemplate<H extends NamespaceHandle<?, ?>> permi
3332
Class<? extends NamespaceHandle<?, ?>> handleClass();
3433

3534
static <H extends NamespaceHandle<?, ?>> NamespaceTemplate<H> of(Class<? extends NamespaceHandle<?, ?>> handleClass,
36-
Function<? super NamespaceInstaller<?>, H> newHandle, Consumer<? super Configurator> configure) {
35+
Function<? super NamespaceInstaller<?>, H> newHandle) {
3736
return new PackedNamespaceTemplate<>(handleClass, newHandle);
3837
}
3938

40-
interface Configurator {
39+
// Logging/Config er manuelt enabled
40+
// Forstaaet paa den maade at annoteringerne stadig kan bruges af extensions.
41+
// Men hvis namespaces ikke bliver enabled er det ikke aktivt...
42+
// IDK maaske er det okay.
43+
// Logging og Config er ihvertfald en del af BaseExtension... ellers biver det weird med used extensions
44+
// Maaske ogsaa metrics. Men metrics er > 1.0
4145

42-
// Logging/Config er manuelt enabled
43-
// Forstaaet paa den maade at annoteringerne stadig kan bruges af extensions.
44-
// Men hvis namespaces ikke bliver enabled er det ikke aktivt...
45-
// IDK maaske er det okay.
46-
// Logging og Config er ihvertfald en del af BaseExtension... ellers biver det weird med used extensions
47-
// Maaske ogsaa metrics. Men metrics er > 1.0
48-
49-
// IDK maaske er namespaces der stadig.. Men er bare ikke enabled
50-
Configurator manualEnabled();
51-
52-
// Taenker maaske man skal kunne foersporge paa det.
53-
// Give me all domains of typeX
46+
// IDK maaske er namespaces der stadig.. Men er bare ikke enabled
47+
default NamespaceTemplate<H> manualEnabled() {
48+
return this;
49+
}
50+
// Taenker maaske man skal kunne foersporge paa det.
51+
// Give me all domains of typeX
5452

55-
// Magic Initializer for Extension + Authority
53+
// Magic Initializer for Extension + Authority
5654

57-
// Igen man skal kunne iterere over dem
58-
// Or directly on the operator...
59-
// NamespaceConfiguration<?> Extension.newNamespace(Operator a, Class<? extends NamespaceConfiguration<?>> c, Authority
60-
// a)
61-
// void addConfigure(Function<Object, NamespaceConfiguration<?>> a);
55+
// Igen man skal kunne iterere over dem
56+
// Or directly on the operator...
57+
// NamespaceConfiguration<?> Extension.newNamespace(Operator a, Class<? extends NamespaceConfiguration<?>> c, Authority
58+
// a)
59+
// void addConfigure(Function<Object, NamespaceConfiguration<?>> a);
6260

63-
@SuppressWarnings("exports")
64-
default void addPermission(BuildPermission permissions) {
65-
// Default values??? for example, root only
66-
}
61+
@SuppressWarnings("exports")
62+
default void addPermission(BuildPermission permissions) {
63+
// Default values??? for example, root only
6764
}
6865
}

modules/packed/src/main/java/app/packed/operation/OperationTemplate.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,35 +90,6 @@ default OperationTemplate withAppendBeanInstance() {
9090
// The operation template will be re-adjusted before being used
9191
OperationTemplate withReturnTypeDynamic();
9292

93-
94-
/**
95-
* An immutable descriptor for an {@link OperationTemplate}. Acquired by calling {@link OperationTemplate#descriptor()}.
96-
*/
97-
interface Descriptor {
98-
99-
// Skal hellere vaere BeanPackaging
100-
int beanInstanceIndex();
101-
102-
// InvocationContexts? Or all contexts
103-
// SessionContext kan f.eks. komme fra en ExtensionContext
104-
// Men det er ikke et argument noget sted
105-
106-
// Replace With ContextTemplate.Descriptor
107-
Map<Class<?>, ContextTemplate> contexts();
108-
109-
/**
110-
*
111-
* @return the method type representing the invocation
112-
*/
113-
MethodType invocationType();
114-
115-
default boolean newLifetime() {
116-
return false;
117-
}
118-
119-
// Contexts
120-
}
121-
12293
/**
12394
*
12495
*/

modules/packed/src/main/java/internal/app/packed/operation/PackedOperationTemplate.java

Lines changed: 46 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,6 @@ public final class PackedOperationTemplate implements OperationTemplate {
3333
// Where it doesn't really make sense to talk about the position
3434
public final List<Class<?>> args;
3535

36-
/** {@inheritDoc} */
37-
@Override
38-
public int beanInstanceIndex() {
39-
throw new UnsupportedOperationException();
40-
// return 0 pot.beanInstanceIndex;
41-
}
42-
43-
/** {@inheritDoc} */
44-
@Override
45-
public Map<Class<?>, ContextTemplate> contexts() {
46-
HashMap<Class<?>, ContextTemplate> m = new HashMap<>();
47-
contexts.forEach(k -> m.put(k.contextClass(), k));
48-
return Map.copyOf(m);
49-
}
50-
51-
/** {@inheritDoc} */
52-
@Override
53-
public MethodType invocationType() {
54-
return methodType;
55-
}
56-
5736
/** Of the operation takes a bean instance. What type of instance does it take */
5837
@Nullable
5938
public final Class<?> beanClass;
@@ -102,6 +81,27 @@ PackedOperationTemplate appendBeanInstance(Class<?> beanClass) {
10281
throw new UnsupportedOperationException();
10382
}
10483

84+
/** {@inheritDoc} */
85+
@Override
86+
public int beanInstanceIndex() {
87+
throw new UnsupportedOperationException();
88+
// return 0 pot.beanInstanceIndex;
89+
}
90+
91+
/** {@inheritDoc} */
92+
@Override
93+
public Map<Class<?>, ContextTemplate> contexts() {
94+
HashMap<Class<?>, ContextTemplate> m = new HashMap<>();
95+
contexts.forEach(k -> m.put(k.contextClass(), k));
96+
return Map.copyOf(m);
97+
}
98+
99+
/** {@inheritDoc} */
100+
@Override
101+
public MethodType invocationType() {
102+
return methodType;
103+
}
104+
105105
public PackedOperationInstaller newInstaller(BeanIntrospectorSetup extension, MethodHandle methodHandle, OperationMemberTarget<?> target,
106106
OperationType operationType) {
107107
return new PackedOperationInstaller(this, operationType, extension.scanner.bean, extension.extension) {
@@ -120,6 +120,31 @@ public PackedOperationInstaller newInstaller(OperationType operationType, BeanSe
120120
return new PackedOperationInstaller(this, operationType, bean, operator);
121121
}
122122

123+
/** {@inheritDoc} */
124+
@Override
125+
public OperationTemplate withAppendBeanInstance(Class<?> beanClass) {
126+
return null;
127+
}
128+
129+
public PackedOperationTemplate withArg(Class<?> type) {
130+
requireNonNull(type, "type is null");
131+
return new PackedOperationTemplate(returnKind, returnClass, extensionContextFlag, beanClass, contexts, args);
132+
}
133+
134+
/** {@inheritDoc} */
135+
@Override
136+
public PackedOperationTemplate withContext(ContextTemplate context) {
137+
PackedContextTemplate c = (PackedContextTemplate) context;
138+
ArrayList<PackedContextTemplate> m = new ArrayList<>(contexts);
139+
for (PackedContextTemplate pct : m) {
140+
if (pct.contextClass() == c.contextClass()) {
141+
throw new IllegalArgumentException("This template already contains the context " + context.contextClass());
142+
}
143+
}
144+
m.add(c);
145+
return new PackedOperationTemplate(returnKind, returnClass, extensionContextFlag, beanClass, List.copyOf(m), args);
146+
}
147+
123148
/**
124149
* @return
125150
*/
@@ -148,58 +173,8 @@ public PackedOperationTemplate withReturnTypeDynamic() {
148173
return new PackedOperationTemplate(ReturnKind.DYNAMIC, Object.class, extensionContextFlag, beanClass, contexts, args);
149174
}
150175

151-
public PackedOperationTemplate withArg(Class<?> type) {
152-
requireNonNull(type, "type is null");
153-
return new PackedOperationTemplate(returnKind, returnClass, extensionContextFlag, beanClass, contexts, args);
154-
}
155-
156-
/** {@inheritDoc} */
157-
@Override
158-
public PackedOperationTemplate withContext(ContextTemplate context) {
159-
PackedContextTemplate c = (PackedContextTemplate) context;
160-
ArrayList<PackedContextTemplate> m = new ArrayList<>(contexts);
161-
for (PackedContextTemplate pct : m) {
162-
if (pct.contextClass() == c.contextClass()) {
163-
throw new IllegalArgumentException("This template already contains the context " + context.contextClass());
164-
}
165-
}
166-
m.add(c);
167-
return new PackedOperationTemplate(returnKind, returnClass, extensionContextFlag, beanClass, List.copyOf(m), args);
168-
}
169-
170-
171176
public enum ReturnKind {
172177
CLASS, DYNAMIC, IGNORE;
173178
}
174179

175-
public record PackedOperationTemplateDescriptor(PackedOperationTemplate pot) implements OperationTemplate.Descriptor {
176-
177-
/** {@inheritDoc} */
178-
@Override
179-
public int beanInstanceIndex() {
180-
throw new UnsupportedOperationException();
181-
// return 0 pot.beanInstanceIndex;
182-
}
183-
184-
/** {@inheritDoc} */
185-
@Override
186-
public Map<Class<?>, ContextTemplate> contexts() {
187-
HashMap<Class<?>, ContextTemplate> m = new HashMap<>();
188-
pot.contexts.forEach(k -> m.put(k.contextClass(), k));
189-
return Map.copyOf(m);
190-
}
191-
192-
/** {@inheritDoc} */
193-
@Override
194-
public MethodType invocationType() {
195-
return pot.methodType;
196-
}
197-
}
198-
199-
/** {@inheritDoc} */
200-
@Override
201-
public OperationTemplate withAppendBeanInstance(Class<?> beanClass) {
202-
return null;
203-
}
204-
205180
}

modules/packed/src/main/java/internal/app/packed/service/MainServiceNamespaceHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class MainServiceNamespaceHandle extends ServiceNamespaceHandle {
4646

4747
/** The default namespace template used for the service namespace. */
4848
public static NamespaceTemplate<MainServiceNamespaceHandle> TEMPLATE = NamespaceTemplate.of(MainServiceNamespaceHandle.class,
49-
MainServiceNamespaceHandle::new, c -> {});
49+
MainServiceNamespaceHandle::new);
5050

5151
// All provided services are automatically exported
5252
public boolean exportAll;

0 commit comments

Comments
 (0)