Skip to content

Commit 4a39c77

Browse files
committed
ewr
1 parent c35fbff commit 4a39c77

File tree

6 files changed

+79
-22
lines changed

6 files changed

+79
-22
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.bean;
17+
18+
import app.packed.operation.OperationConfiguration;
19+
import app.packed.operation.OperationHandle;
20+
21+
/**
22+
*
23+
*/
24+
public class BeanAttachmentConfiguration<T> extends OperationConfiguration {
25+
26+
/**
27+
* @param handle
28+
*/
29+
public BeanAttachmentConfiguration(OperationHandle<?> handle) {
30+
super(handle);
31+
}
32+
33+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.bean;
17+
18+
/**
19+
*
20+
*/
21+
public class BeanAttachmentMirror {
22+
23+
}

modules/packed/src/main/java/app/packed/component/guest/FromAttachment.java renamed to modules/packed/src/main/java/app/packed/bean/FromBeanAttachment.java

Lines changed: 2 additions & 2 deletions
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.component.guest;
16+
package app.packed.bean;
1717

1818
import java.lang.annotation.ElementType;
1919
import java.lang.annotation.Retention;
@@ -32,4 +32,4 @@
3232
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE_USE })
3333
@Retention(RetentionPolicy.RUNTIME)
3434
@OnAnnotatedVariable(extension = BaseExtension.class)
35-
public @interface FromAttachment {}
35+
public @interface FromBeanAttachment {}

modules/packed/src/main/java/app/packed/bean/scanning/BeanIntrospector.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.function.Consumer;
3030
import java.util.function.Supplier;
3131

32+
import app.packed.bean.BeanAttachmentConfiguration;
3233
import app.packed.bean.BeanBuildLocal.Accessor;
3334
import app.packed.bean.BeanHandle;
3435
import app.packed.bean.BeanInstallationException;
@@ -79,6 +80,14 @@ BeanSetup bean() {
7980
return requireNonNull(introspector().scanner.bean);
8081
}
8182

83+
public final <T> BeanAttachmentConfiguration<T> attachToBean(Op<T> op) {
84+
throw new UnsupportedOperationException();
85+
}
86+
87+
public final <T> BeanAttachmentConfiguration<T> attachToBeanIfAbsent(Op<T> op) {
88+
throw new UnsupportedOperationException();
89+
}
90+
8291
/** {@return an annotation reader for the bean class.} */
8392
public final AnnotationList beanAnnotations() {
8493
return new PackedAnnotationList(beanClass().getAnnotations());

modules/packed/src/main/java/internal/app/packed/lifecycle/lifetime/ContainerLifetimeSetup.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@
2222
import java.util.List;
2323
import java.util.Set;
2424

25-
import app.packed.bean.BeanKind;
26-
import app.packed.bean.BeanSourceKind;
2725
import app.packed.extension.ExtensionContext;
2826
import app.packed.lifetime.ContainerLifetimeMirror;
2927
import app.packed.util.Nullable;
3028
import internal.app.packed.bean.BeanSetup;
3129
import internal.app.packed.container.ContainerSetup;
3230
import internal.app.packed.container.PackedContainerInstaller;
3331
import internal.app.packed.lifecycle.BeanLifecycleOperationHandle;
34-
import internal.app.packed.lifecycle.BeanLifecycleOperationHandle.LifecycleOperationInitializeHandle;
3532
import internal.app.packed.lifecycle.BeanLifecycleOperationHandle.LifecycleOnStartHandle;
33+
import internal.app.packed.lifecycle.BeanLifecycleOperationHandle.LifecycleOperationInitializeHandle;
3634
import internal.app.packed.lifecycle.BeanLifecycleOperationHandle.LifecycleOperationStopHandle;
3735
import internal.app.packed.lifecycle.lifetime.entrypoint.EntryPointManager;
3836
import internal.app.packed.lifecycle.lifetime.runtime.PackedExtensionContext;
@@ -67,7 +65,6 @@ public final class ContainerLifetimeSetup extends AbstractTreeNode<ContainerLife
6765

6866
public final List<LifecycleOperationInitializeHandle> initializationPre = new ArrayList<>();
6967

70-
7168
// Er ikke noedvendigvis fra et entrypoint, kan ogsaa vaere en completer
7269
public final Class<?> resultType;
7370

@@ -82,6 +79,8 @@ public final class ContainerLifetimeSetup extends AbstractTreeNode<ContainerLife
8279

8380
public final List<LifecycleOperationStopHandle> stoppersPre = new ArrayList<>();
8481

82+
private final LifetimeStoreSetup store = new LifetimeStoreSetup();
83+
8584
/**
8685
* @param origin
8786
* @param parent
@@ -93,16 +92,13 @@ public ContainerLifetimeSetup(PackedContainerInstaller<?> installer, ContainerSe
9392
this.resultType = installer.template.resultType();
9493

9594
if (newContainer.isApplicationRoot()) {
96-
reserve(ManagedLifetime.class);
95+
store.addOther(ManagedLifetime.class);
9796
}
9897
}
9998

10099
public int addBean(BeanSetup bean) {
101100
beans.add(bean);
102-
if (bean.beanKind == BeanKind.CONTAINER && bean.beanSourceKind != BeanSourceKind.INSTANCE) {
103-
return reserve(bean.beanClass);
104-
}
105-
return -1;
101+
return store.addBean(bean);
106102
}
107103

108104
public void initialize(ExtensionContext pool) {
@@ -130,7 +126,7 @@ public ContainerLifetimeMirror mirror() {
130126
}
131127

132128
public ExtensionContext newRuntimePool() {
133-
return PackedExtensionContext.create(size);
129+
return store.newRuntimePool();
134130
}
135131

136132
public void orderDependencies() {
@@ -176,15 +172,6 @@ private void orderDependenciesBeans0(BeanSetup bean) {
176172
return treeParent;
177173
}
178174

179-
/**
180-
* Reserves room for a single object.
181-
*
182-
* @return the index to store the object in at runtime
183-
*/
184-
private int reserve(Class<?> cls) {
185-
return size++;
186-
}
187-
188175
/** {@inheritDoc} */
189176
@Override
190177
public Class<?> resultType() {

modules/packed/src/main/java/internal/app/packed/lifecycle/lifetime/LifetimeStoreSetup.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@
2929
*/
3030
public final class LifetimeStoreSetup {
3131

32-
final ArrayList<BeanSetup> entries = new ArrayList<>();
32+
final ArrayList<Object> entries = new ArrayList<>();
3333

3434
public int addBean(BeanSetup bean) {
3535
if (bean.beanKind == BeanKind.CONTAINER && bean.beanSourceKind != BeanSourceKind.INSTANCE) {
3636
entries.add(bean);
37+
return entries.size()-1;
3738
}
3839
return -1;
3940
}
4041

42+
public void addOther(Class<?> other) {
43+
entries.add(other);
44+
}
45+
4146
public ExtensionContext newRuntimePool() {
4247
return PackedExtensionContext.create(entries.size());
4348
}

0 commit comments

Comments
 (0)