Skip to content

Commit a7d6e84

Browse files
committed
[PAXCDI-188] formatting
1 parent fd78699 commit a7d6e84

File tree

3 files changed

+57
-92
lines changed

3 files changed

+57
-92
lines changed

pax-cdi-undertow-openwebbeans/src/main/java/org/ops4j/pax/cdi/undertow/openwebbeans/impl/OpenWebBeansListener.java

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,14 @@
5151
public class OpenWebBeansListener implements ServletContextListener, ServletRequestListener,
5252
HttpSessionListener {
5353

54-
5554
private static Logger log = LoggerFactory.getLogger(OpenWebBeansListener.class);
5655

5756
private static final String CDI_CONTAINER = "org.ops4j.pax.cdi.container";
5857

5958
private ContainerLifecycle lifecycle;
6059

6160
@Override
62-
public void contextInitialized(ServletContextEvent event)
63-
{
61+
public void contextInitialized(ServletContextEvent event) {
6462
ServletContext context = event.getServletContext();
6563
CdiContainer cdiContainer = (CdiContainer) context.getAttribute(CDI_CONTAINER);
6664
try {
@@ -84,50 +82,44 @@ public void contextInitialized(ServletContextEvent event)
8482
attributes.put("org.ops4j.pax.cdi.ClassIntrospecter", builder);
8583
log.info("registered CdiInstanceFactoryBuilder for Undertow");
8684
}
87-
context.setAttribute("org.ops4j.pax.cdi.BeanManager", cdiContainer.getBeanManager());
88-
85+
context.setAttribute("org.ops4j.pax.cdi.BeanManager", manager);
8986
context.setAttribute(BeanManager.class.getName(), manager);
9087
}
9188

92-
9389
@Override
94-
public void requestInitialized(ServletRequestEvent event)
95-
{
96-
try
97-
{
98-
log.debug("Starting a new request : [{}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
90+
public void requestInitialized(ServletRequestEvent event) {
91+
try {
92+
log.debug("Starting a new request : [{}]", event == null ? "null" : event
93+
.getServletRequest().getRemoteAddr());
9994

10095
this.lifecycle.getContextService().startContext(RequestScoped.class, event);
10196

10297
// we don't initialise the Session here but do it lazily if it gets requested
10398
// the first time. See OWB-457
10499
}
105-
catch (Exception e)
106-
{
107-
log.error(
108-
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0019, event == null ? "null" : event.getServletRequest()));
100+
catch (Exception e) {
101+
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0019,
102+
event == null ? "null" : event.getServletRequest()));
109103
WebBeansUtil.throwRuntimeExceptions(e);
110104
}
111105
}
112106

113107
@Override
114-
public void sessionCreated(HttpSessionEvent event)
115-
{
116-
try
117-
{
108+
public void sessionCreated(HttpSessionEvent event) {
109+
try {
118110
log.debug("Starting a session with session id : [{}]", event.getSession().getId());
119-
this.lifecycle.getContextService().startContext(SessionScoped.class, event.getSession());
111+
this.lifecycle.getContextService()
112+
.startContext(SessionScoped.class, event.getSession());
120113
}
121-
catch (Exception e)
122-
{
123-
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020, event.getSession()));
114+
catch (Exception e) {
115+
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020,
116+
event.getSession()));
124117
WebBeansUtil.throwRuntimeExceptions(e);
125118
}
126119
}
127120

128121
@Override
129-
public void contextDestroyed(ServletContextEvent event)
130-
{
122+
public void contextDestroyed(ServletContextEvent event) {
131123
ServletContext context = event.getServletContext();
132124
context.removeAttribute(CDI_CONTAINER);
133125

@@ -136,14 +128,13 @@ public void contextDestroyed(ServletContextEvent event)
136128
}
137129

138130
@Override
139-
public void requestDestroyed(ServletRequestEvent event)
140-
{
141-
log.debug("Destroying a request : [{}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
131+
public void requestDestroyed(ServletRequestEvent event) {
132+
log.debug("Destroying a request : [{}]", event == null ? "null" : event.getServletRequest()
133+
.getRemoteAddr());
142134

143135
// clean up the EL caches after each request
144136
ELContextStore elStore = ELContextStore.getInstance(false);
145-
if (elStore != null)
146-
{
137+
if (elStore != null) {
147138
elStore.destroyELContextStore();
148139
}
149140

@@ -152,42 +143,35 @@ public void requestDestroyed(ServletRequestEvent event)
152143
this.cleanupRequestThreadLocals();
153144
}
154145

155-
156146
@Override
157-
public void sessionDestroyed(HttpSessionEvent event)
158-
{
147+
public void sessionDestroyed(HttpSessionEvent event) {
159148
log.debug("Destroying a session with session id : [{}]", event.getSession().getId());
160149
boolean mustDestroy = ensureRequestScope();
161150

162151
this.lifecycle.getContextService().endContext(SessionScoped.class, event.getSession());
163152

164-
if (mustDestroy)
165-
{
153+
if (mustDestroy) {
166154
requestDestroyed(null);
167155
}
168156
}
169157

170-
private boolean ensureRequestScope()
171-
{
158+
private boolean ensureRequestScope() {
172159
Context context = this.lifecycle.getContextService().getCurrentContext(RequestScoped.class);
173160

174-
if (context == null || !context.isActive())
175-
{
161+
if (context == null || !context.isActive()) {
176162
requestInitialized(null);
177163
return true;
178164
}
179165
return false;
180166
}
181167

182168
/**
183-
* Ensures that all ThreadLocals, which could have been set in this
184-
* requests Thread, are removed in order to prevent memory leaks.
169+
* Ensures that all ThreadLocals, which could have been set in this requests Thread, are removed
170+
* in order to prevent memory leaks.
185171
*/
186-
private void cleanupRequestThreadLocals()
187-
{
172+
private void cleanupRequestThreadLocals() {
188173
ContextsService contextsService = this.lifecycle.getContextService();
189-
if (contextsService != null)
190-
{
174+
if (contextsService != null) {
191175
contextsService.removeThreadLocals();
192176
}
193177
}

pax-cdi-web-openwebbeans/src/main/java/org/ops4j/pax/cdi/web/openwebbeans/impl/BundleSingletonService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public WebBeansContext get(Object key) {
6363
String resource = "/META-INF/openwebbeans/standalone.properties";
6464
if (bundle.getHeaders().get("Web-ContextPath") != null) {
6565
resource = "/META-INF/openwebbeans/wab.properties";
66-
// initialServices.put(ContainerLifecycle.class, new WabContainerLifecycle());
67-
// initialServices.put(ContextsService.class, new WabContextsService());
6866
}
6967

7068
try {
@@ -77,9 +75,7 @@ public WebBeansContext get(Object key) {
7775
webBeansContext = new WebBeansContext(initialServices, props);
7876
singletonMap.put(bundleId, webBeansContext);
7977
}
80-
8178
return webBeansContext;
82-
8379
}
8480
}
8581

pax-cdi-web-openwebbeans/src/main/java/org/ops4j/pax/cdi/web/openwebbeans/impl/OpenWebBeansListener.java

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@
5050
public class OpenWebBeansListener implements ServletContextListener, ServletRequestListener,
5151
HttpSessionListener {
5252

53-
5453
private static Logger log = LoggerFactory.getLogger(OpenWebBeansListener.class);
5554

5655
private static final String CDI_CONTAINER = "org.ops4j.pax.cdi.container";
5756

5857
private ContainerLifecycle lifecycle;
5958

6059
@Override
61-
public void contextInitialized(ServletContextEvent event)
62-
{
60+
public void contextInitialized(ServletContextEvent event) {
6361
ServletContext context = event.getServletContext();
6462
CdiContainer cdiContainer = (CdiContainer) context.getAttribute(CDI_CONTAINER);
6563
cdiContainer.start(event);
@@ -75,45 +73,40 @@ public void contextInitialized(ServletContextEvent event)
7573
context.setAttribute(BeanManager.class.getName(), manager);
7674
}
7775

78-
7976
@Override
80-
public void requestInitialized(ServletRequestEvent event)
81-
{
82-
try
83-
{
84-
log.debug("Starting a new request : [{}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
77+
public void requestInitialized(ServletRequestEvent event) {
78+
try {
79+
log.debug("Starting a new request : [{}]", event == null ? "null" : event
80+
.getServletRequest().getRemoteAddr());
8581

8682
this.lifecycle.getContextService().startContext(RequestScoped.class, event);
8783

8884
// we don't initialise the Session here but do it lazily if it gets requested
8985
// the first time. See OWB-457
9086
}
91-
catch (Exception e)
92-
{
93-
log.error(
94-
WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0019, event == null ? "null" : event.getServletRequest()));
87+
catch (Exception e) {
88+
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0019,
89+
event == null ? "null" : event.getServletRequest()));
9590
WebBeansUtil.throwRuntimeExceptions(e);
9691
}
9792
}
9893

9994
@Override
100-
public void sessionCreated(HttpSessionEvent event)
101-
{
102-
try
103-
{
95+
public void sessionCreated(HttpSessionEvent event) {
96+
try {
10497
log.debug("Starting a session with session id : [{}]", event.getSession().getId());
105-
this.lifecycle.getContextService().startContext(SessionScoped.class, event.getSession());
98+
this.lifecycle.getContextService()
99+
.startContext(SessionScoped.class, event.getSession());
106100
}
107-
catch (Exception e)
108-
{
109-
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020, event.getSession()));
101+
catch (Exception e) {
102+
log.error(WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020,
103+
event.getSession()));
110104
WebBeansUtil.throwRuntimeExceptions(e);
111105
}
112106
}
113107

114108
@Override
115-
public void contextDestroyed(ServletContextEvent event)
116-
{
109+
public void contextDestroyed(ServletContextEvent event) {
117110
ServletContext context = event.getServletContext();
118111
context.removeAttribute(CDI_CONTAINER);
119112

@@ -122,14 +115,13 @@ public void contextDestroyed(ServletContextEvent event)
122115
}
123116

124117
@Override
125-
public void requestDestroyed(ServletRequestEvent event)
126-
{
127-
log.debug("Destroying a request : [{}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
118+
public void requestDestroyed(ServletRequestEvent event) {
119+
log.debug("Destroying a request : [{}]", event == null ? "null" : event.getServletRequest()
120+
.getRemoteAddr());
128121

129122
// clean up the EL caches after each request
130123
ELContextStore elStore = ELContextStore.getInstance(false);
131-
if (elStore != null)
132-
{
124+
if (elStore != null) {
133125
elStore.destroyELContextStore();
134126
}
135127

@@ -138,42 +130,35 @@ public void requestDestroyed(ServletRequestEvent event)
138130
this.cleanupRequestThreadLocals();
139131
}
140132

141-
142133
@Override
143-
public void sessionDestroyed(HttpSessionEvent event)
144-
{
134+
public void sessionDestroyed(HttpSessionEvent event) {
145135
log.debug("Destroying a session with session id : [{}]", event.getSession().getId());
146136
boolean mustDestroy = ensureRequestScope();
147137

148138
this.lifecycle.getContextService().endContext(SessionScoped.class, event.getSession());
149139

150-
if (mustDestroy)
151-
{
140+
if (mustDestroy) {
152141
requestDestroyed(null);
153142
}
154143
}
155144

156-
private boolean ensureRequestScope()
157-
{
145+
private boolean ensureRequestScope() {
158146
Context context = this.lifecycle.getContextService().getCurrentContext(RequestScoped.class);
159147

160-
if (context == null || !context.isActive())
161-
{
148+
if (context == null || !context.isActive()) {
162149
requestInitialized(null);
163150
return true;
164151
}
165152
return false;
166153
}
167154

168155
/**
169-
* Ensures that all ThreadLocals, which could have been set in this
170-
* requests Thread, are removed in order to prevent memory leaks.
156+
* Ensures that all ThreadLocals, which could have been set in this requests Thread, are removed
157+
* in order to prevent memory leaks.
171158
*/
172-
private void cleanupRequestThreadLocals()
173-
{
159+
private void cleanupRequestThreadLocals() {
174160
ContextsService contextsService = this.lifecycle.getContextService();
175-
if (contextsService != null)
176-
{
161+
if (contextsService != null) {
177162
contextsService.removeThreadLocals();
178163
}
179164
}

0 commit comments

Comments
 (0)