1 /* Copyright 2009, Sebastian Prehn
2 *
3 * This file is part of JCR Blog
4 *
5 * JCR Blog is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * JCR Blog is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with JCR Blog. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Versioning:
19 * $LastChangedDate$
20 * $LastChangedRevision$
21 */
22 package org.jcr_blog.commons.jsf2cdi.scope;
23
24 import javax.enterprise.event.Observes;
25 import javax.enterprise.inject.spi.AfterBeanDiscovery;
26 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
27 import javax.enterprise.inject.spi.Extension;
28
29 /**
30 *
31 * @author Sebastian Prehn <sebastian.prehn@planetswebdesign.de>
32 */
33 public class ViewContextExtension implements Extension {
34
35 public void addScope(@Observes final BeforeBeanDiscovery event) {
36 event.addScope(ViewScoped.class, true, true);
37 }
38
39 public void registerContext(@Observes final AfterBeanDiscovery event) {
40 event.addContext(new ViewContext());
41 }
42 }