|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractEJBProxy.java | - | 100% | 100% | 100% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.hivemind.lib.impl;
|
|
16 |
|
|
17 |
import java.rmi.RemoteException;
|
|
18 |
|
|
19 |
import org.apache.hivemind.lib.NameLookup;
|
|
20 |
import org.apache.hivemind.lib.RemoteExceptionCoordinator;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* Generic EJB proxy for stateless session beans. Acts as an InvocationHandler
|
|
24 |
* for a dynamic proxy.
|
|
25 |
*
|
|
26 |
* @author Howard Lewis Ship
|
|
27 |
*/
|
|
28 |
public abstract class AbstractEJBProxy |
|
29 |
{ |
|
30 |
private NameLookup _nameLookup;
|
|
31 |
private RemoteExceptionCoordinator _coordinator;
|
|
32 |
|
|
33 | 3 |
protected AbstractEJBProxy(NameLookup nameLookup, RemoteExceptionCoordinator coordinator)
|
34 |
{ |
|
35 | 3 |
_nameLookup = nameLookup; |
36 | 3 |
_coordinator = coordinator; |
37 |
} |
|
38 |
|
|
39 | 4 |
protected Object _lookup(String name)
|
40 |
{ |
|
41 | 4 |
return _nameLookup.lookup(name, Object.class); |
42 |
} |
|
43 |
|
|
44 |
/**
|
|
45 |
* Clears the home and remote objects after any remote exception.
|
|
46 |
*/
|
|
47 |
|
|
48 |
protected abstract void _clearCachedReferences(); |
|
49 |
|
|
50 |
/**
|
|
51 |
* Invoked by the fabricated subclass when a remote exception occurs.
|
|
52 |
* This notifies the {@link RemoteExceptionCoordinator} (which, indirectly,
|
|
53 |
* allows the {@link NameLookup} service to release its JNDI context).
|
|
54 |
* In addition, {@link #_clearCachedReferences()} is invoked.
|
|
55 |
*/
|
|
56 | 1 |
protected void _handleRemoteException(RemoteException ex) |
57 |
{ |
|
58 | 1 |
_clearCachedReferences(); |
59 | 1 |
_coordinator.fireRemoteExceptionDidOccur(this, ex);
|
60 |
} |
|
61 |
} |
|
62 |
|
|