1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.myfaces.config.annotation;
19
20 import javax.annotation.PostConstruct;
21 import javax.annotation.PreDestroy;
22
23
24
25
26
27 public class AnnotatedManagedBean2 {
28
29 private boolean postConstructCalled = false;
30
31 private boolean preDestroyCalled = false;
32
33 boolean throwExcetion;
34
35 private String managedProperty;
36
37 public AnnotatedManagedBean2()
38 {
39 }
40
41 public AnnotatedManagedBean2(boolean throwExcetion) {
42 this.throwExcetion = throwExcetion;
43 }
44
45 @PostConstruct
46 public void postConstruct() {
47
48 if (managedProperty == null)
49 {
50 throw new RuntimeException("managedProperty must be initialized before call of postConstruct() method");
51 }
52
53 postConstructCalled = true;
54
55 if (throwExcetion) {
56 throw new RuntimeException();
57 }
58 }
59
60 @PreDestroy
61 public void preDestroy() {
62 preDestroyCalled = true;
63
64 if (throwExcetion) {
65 throw new RuntimeException();
66 }
67 }
68
69 boolean isPostConstructCalled() {
70 return postConstructCalled;
71 }
72
73 boolean isPreDestroyCalled() {
74 return preDestroyCalled;
75 }
76
77 public String getManagedProperty() {
78 return managedProperty;
79 }
80
81 public void setManagedProperty(String managedProperty) {
82
83 if (postConstructCalled)
84 {
85 throw new RuntimeException();
86 }
87
88 this.managedProperty = managedProperty;
89 }
90
91 }