-
Notifications
You must be signed in to change notification settings - Fork 45
/
ProductManagement.java
78 lines (65 loc) · 3.11 KB
/
ProductManagement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright 2017, Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.cdi.tck.tests.full.extensions.beanDiscovery.event.ordering;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
import jakarta.enterprise.inject.spi.Extension;
import jakarta.enterprise.inject.spi.ProcessBeanAttributes;
import jakarta.enterprise.inject.spi.ProcessInjectionPoint;
import jakarta.enterprise.inject.spi.ProcessInjectionTarget;
import jakarta.enterprise.inject.spi.ProcessManagedBean;
import jakarta.enterprise.inject.spi.ProcessProducer;
import jakarta.enterprise.inject.spi.ProcessProducerMethod;
import org.jboss.cdi.tck.util.ActionSequence;
/**
* CDI defines this order (see Bean Discovery chapter) for producers: PIP -> PP -> PBA -> PPM (e.g. ProcessBean for producer
* methods) And following order for managed beans: PIP -> PIT -> PBA -> PB
*
* Of course this can get a lot more complex, but let's cover this basic case.
*
* @author <a href="mailto:manovotn@redhat.com">Matej Novotny</a>
*/
public class ProductManagement implements Extension {
public static String PRODUCER_SEQ = "PRODUCER_EVENTS_ORDER_SEQ";
public static String BEAN_SEQ = "BEAN_EVENTS_ORDER_SEQ";
public void resetSequence(@Observes BeforeBeanDiscovery bbd) {
ActionSequence.reset();
}
// producer method observers
public void observePIP(@Observes ProcessInjectionPoint<PoorWorker, String> pip) {
ActionSequence.addAction(PRODUCER_SEQ, "PIP");
}
public void observePP(@Observes ProcessProducer<PoorWorker, HighQualityAndLowCostProduct> pp) {
ActionSequence.addAction(PRODUCER_SEQ, "PP");
}
public void observePBA(@Observes ProcessBeanAttributes<HighQualityAndLowCostProduct> pba) {
ActionSequence.addAction(PRODUCER_SEQ, "PBA");
}
public void observerPPM(@Observes ProcessProducerMethod<HighQualityAndLowCostProduct, PoorWorker> ppm) {
ActionSequence.addAction(PRODUCER_SEQ, "PPM");
}
// managed bean observers - PIP - PIT - PBA - PB
public void observePIPBean(@Observes ProcessInjectionPoint<PoorWorker, MassiveJugCoffee> pip) {
ActionSequence.addAction(BEAN_SEQ, "PIP");
}
public void observePIT(@Observes ProcessInjectionTarget<PoorWorker> pit) {
ActionSequence.addAction(BEAN_SEQ, "PIT");
}
public void observePBABean(@Observes ProcessBeanAttributes<PoorWorker> pba) {
ActionSequence.addAction(BEAN_SEQ, "PBA");
}
public void observerPB(@Observes ProcessManagedBean<PoorWorker> pb) {
ActionSequence.addAction(BEAN_SEQ, "PB");
}
}