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: 2010-07-18 21:28:21 +0200 (So, 18 Jul 2010) $
20 * $LastChangedRevision: 187 $
21 */
22 package org.jcr_blog.persistence;
23
24 import javax.annotation.Resource;
25 import javax.enterprise.context.ApplicationScoped;
26 import javax.enterprise.inject.Produces;
27 import javax.inject.Named;
28 import javax.jcr.Repository;
29 import javax.naming.NamingException;
30
31 /**
32 * Service to provide access to the application scoped repository.
33 * This implementation performs a jndi lookup for "jcr/repository".
34 *
35 * @author Sebastian Prehn <sebastian.prehn@planetswebdesign.de>
36 */
37 public class RepositoryProvider {
38
39 @Resource(name = "jcr/repository")
40 private Repository repository;
41
42 @Produces
43 @Named
44 @ApplicationScoped
45 public Repository getRepository() throws NamingException {
46 return repository;
47 }
48 }