-
Notifications
You must be signed in to change notification settings - Fork 13
/
SeamRestStartup.java
58 lines (48 loc) · 1.99 KB
/
SeamRestStartup.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
package org.jboss.seam.rest;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import org.jboss.seam.logging.Logger;
import org.jboss.seam.rest.client.RestClientExtension;
import org.jboss.seam.rest.exceptions.ExceptionMappingExtension;
import org.jboss.seam.rest.exceptions.RestResource;
import org.jboss.seam.rest.exceptions.SeamExceptionMapper;
import org.jboss.seam.rest.templating.TemplatingMessageBodyWriter;
/**
* TODO: This listener will be replaced with Seam Servlet. Do not observe the event fired by this listener as it will be removed
* in future releases.
*
* @author <a href="mailto:jharting@redhat.com">Jozef Hartinger</a>
*/
@ApplicationScoped
public class SeamRestStartup {
private static final Logger log = Logger.getLogger(SeamRestStartup.class);
@Inject
private RestClientExtension restClientExtension;
@Inject
private ExceptionMappingExtension exceptionMappingExtension;
@Inject
private SeamExceptionMapper exceptionMapper;
@Inject
private TemplatingMessageBodyWriter templating;
@Inject
@RestResource
private Event<ServletContext> event;
private boolean initialized = false;
public synchronized void init(ServletContext sc)
{
if (initialized)
{
return;
}
event.fire(sc);
log.infov(
"Seam REST {0} (Client integration: {1}, Catch integration: {2}, {3} exception mapping rules, Templating provider: {4})",
this.getClass().getPackage().getSpecificationVersion(),
restClientExtension.isClientIntegrationEnabled() ? "enabled" : "disabled", exceptionMappingExtension
.isCatchIntegrationEnabled() ? "enabled" : "disabled", exceptionMapper.getMappings().size(), templating
.getProvider() == null ? "null" : templating.getProvider().toString());
initialized = true;
}
}