Mercurial > lada > lada-server
annotate src/main/java/de/intevation/utils/Resources.java @ 22:c19770952a6e
DO not provide a transaction type
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 26 Apr 2013 15:00:56 +0200 |
parents | ad22a59aa5d7 |
children |
rev | line source |
---|---|
10
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 /* |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 * JBoss, Home of Professional Open Source |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
4 * contributors by the @authors tag. See the copyright.txt in the |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
5 * distribution for a full listing of individual contributors. |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 * |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
7 * Licensed under the Apache License, Version 2.0 (the "License"); |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
8 * you may not use this file except in compliance with the License. |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 * You may obtain a copy of the License at |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 * http://www.apache.org/licenses/LICENSE-2.0 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 * Unless required by applicable law or agreed to in writing, software |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 * distributed under the License is distributed on an "AS IS" BASIS, |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
14 * See the License for the specific language governing permissions and |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 * limitations under the License. |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 */ |
11
ad22a59aa5d7
Fix package name
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
10
diff
changeset
|
17 package de.intevation.utils; |
10
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
18 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
19 import java.util.logging.Logger; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
20 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
21 import javax.enterprise.context.RequestScoped; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
22 import javax.enterprise.inject.Produces; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
23 import javax.enterprise.inject.spi.InjectionPoint; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
24 import javax.faces.context.FacesContext; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
25 import javax.persistence.EntityManager; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
26 import javax.persistence.PersistenceContext; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
27 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
28 /** |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
29 * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
30 * |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
31 * <p> |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
32 * Example injection on a managed bean field: |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
33 * </p> |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
34 * |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
35 * <pre> |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
36 * @Inject |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
37 * private EntityManager em; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
38 * </pre> |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
39 */ |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
40 public class Resources { |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
41 // use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
42 @SuppressWarnings("unused") |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
43 @Produces |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
44 @PersistenceContext |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
45 private EntityManager em; |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
46 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
47 @Produces |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
48 public Logger produceLog(InjectionPoint injectionPoint) { |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
49 return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
50 } |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
51 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
52 @Produces |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
53 @RequestScoped |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
54 public FacesContext produceFacesContext() { |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
55 return FacesContext.getCurrentInstance(); |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
56 } |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
57 |
eb093385ff7e
Added Resources.java. This file is important as it make the EntitManager
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
58 } |