Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EJBDAOLocator |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright 2008 WebPhotos | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | /** | |
17 | * | |
18 | */ | |
19 | package net.sf.webphotos.locator; | |
20 | ||
21 | /** | |
22 | * @author Guilhe | |
23 | * | |
24 | */ | |
25 | public class EJBDAOLocator extends BasicEJBLocator { | |
26 | 0 | private static EJBDAOLocator instance = new EJBDAOLocator(); |
27 | ||
28 | public static EJBDAOLocator getInstance() { | |
29 | 0 | return instance; |
30 | } | |
31 | ||
32 | /*private static final String REMOTE_TURMASDAO = "java:comp/env/ejb/remote/TurmasDAO"; | |
33 | private static final String REMOTE_MATRICULASDAO = "java:comp/env/ejb/remote/MatriculasDAO"; | |
34 | private static final String REMOTE_MEMBERSHIPDAO = "java:comp/env/ejb/remote/MembershipDAO"; | |
35 | private static final String REMOTE_CURSOSDAO = "java:comp/env/ejb/remote/CursosDAO";*/ | |
36 | ||
37 | 0 | private EJBDAOLocator() { |
38 | 0 | initEJBContext(); |
39 | 0 | } |
40 | ||
41 | /* | |
42 | ||
43 | public CursosDAO getRemoteCursosDAO() throws WebfotosException { | |
44 | InitialContext initCtx = getEJBContext(); | |
45 | Object ref = null; | |
46 | CursosDAO ejb = null; | |
47 | try { | |
48 | ref = initCtx.lookup(REMOTE_CURSOSDAO); | |
49 | CursosDAOHome cursosDAOHome = (CursosDAOHome) PortableRemoteObject | |
50 | .narrow(ref, CursosDAOHome.class); | |
51 | ejb = cursosDAOHome.create(); | |
52 | } catch (Exception ex) { | |
53 | Debug.log( | |
54 | "Erro ao tentar localizar o EJB CursosDAO via remote interface" | |
55 | + ex.getMessage(), 9); | |
56 | throw new WebfotosException( | |
57 | "Erro ao tentar localizar o EJB CursosDAO via remote interface" | |
58 | + ex.getMessage(), ex); | |
59 | } | |
60 | return ejb; | |
61 | } | |
62 | ||
63 | public MatriculasDAO getRemoteMatriculasDAO() throws WebfotosException { | |
64 | InitialContext initCtx = getEJBContext(); | |
65 | Object ref = null; | |
66 | MatriculasDAO ejb = null; | |
67 | try { | |
68 | ref = initCtx.lookup(REMOTE_MATRICULASDAO); | |
69 | MatriculasDAOHome matriculasDAOHome = (MatriculasDAOHome) PortableRemoteObject | |
70 | .narrow(ref, MatriculasDAOHome.class); | |
71 | ejb = matriculasDAOHome.create(); | |
72 | } catch (Exception ex) { | |
73 | Debug.log( | |
74 | "Erro ao tentar localizar o EJB MatriculasDAO via remote interface" | |
75 | + ex.getMessage(), 9); | |
76 | throw new WebfotosException( | |
77 | "Erro ao tentar localizar o EJB MatriculasDAO via remote interface" | |
78 | + ex.getMessage(), ex); | |
79 | } | |
80 | return ejb; | |
81 | } | |
82 | ||
83 | public TurmasDAO getRemoteTurmasDAO() throws WebfotosException { | |
84 | InitialContext initCtx = getEJBContext(); | |
85 | Object ref = null; | |
86 | TurmasDAO ejb = null; | |
87 | try { | |
88 | ref = initCtx.lookup(REMOTE_TURMASDAO); | |
89 | TurmasDAOHome turmasDAOHome = (TurmasDAOHome) PortableRemoteObject | |
90 | .narrow(ref, TurmasDAOHome.class); | |
91 | ejb = turmasDAOHome.create(); | |
92 | } catch (Exception ex) { | |
93 | Debug.log( | |
94 | "Erro ao tentar localizar o EJB TurmasDAO via remote interface" | |
95 | + ex.getMessage(), 9); | |
96 | throw new WebfotosException( | |
97 | "Erro ao tentar localizar o EJB TurmasDAO via remote interface" | |
98 | + ex.getMessage(), ex); | |
99 | } | |
100 | return ejb; | |
101 | } | |
102 | ||
103 | public MembershipDAO getRemoteMembershipDAO() throws WebfotosException { | |
104 | InitialContext initCtx = getEJBContext(); | |
105 | Object ref = null; | |
106 | MembershipDAO ejb = null; | |
107 | try { | |
108 | ref = initCtx.lookup(REMOTE_MEMBERSHIPDAO); | |
109 | MembershipDAOHome membershipDAOHome = (MembershipDAOHome) PortableRemoteObject | |
110 | .narrow(ref, MembershipDAOHome.class); | |
111 | ejb = membershipDAOHome.create(); | |
112 | } catch (Exception ex) { | |
113 | Debug.log( | |
114 | "Erro ao tentar localizar o EJB MembershipDAO via remote interface" | |
115 | + ex.getMessage(), 9); | |
116 | throw new WebfotosException( | |
117 | "Erro ao tentar localizar o EJB MembershipDAO via remote interface" | |
118 | + ex.getMessage(), ex); | |
119 | } | |
120 | return ejb; | |
121 | } | |
122 | */ | |
123 | } |