Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/remote/ProxyFactory.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.remote; | |
2 | |
3 import net.jini.id.Uuid; | |
4 | |
5 import net.jini.core.constraint.RemoteMethodControl; | |
6 | |
7 import org.dancres.blitz.lease.SpaceUID; | |
8 | |
9 /** | |
10 This class instantiates appropriate proxy instances of the given types | |
11 based on whether we are running in secure mode or not (secure mode is | |
12 defined to be active when our exported stub reference supports | |
13 RemoteMethodControl which will be the result of config file containing | |
14 an appropriate Exporter setup). | |
15 */ | |
16 public class ProxyFactory { | |
17 private static boolean isSecure(BlitzServer aStub) { | |
18 return (aStub instanceof RemoteMethodControl); | |
19 } | |
20 | |
21 public static BlitzProxy newBlitzProxy(BlitzServer aStub, Uuid aUuid) { | |
22 if (isSecure(aStub)) | |
23 return new ConstrainableBlitzProxy(aStub, aUuid); | |
24 else | |
25 return new BlitzProxy(aStub, aUuid); | |
26 } | |
27 | |
28 static AdminProxy newAdminProxy(BlitzServer aStub, Uuid aUuid) { | |
29 if (isSecure(aStub)) | |
30 return new ConstrainableAdminProxy(aStub, aUuid); | |
31 else | |
32 return new AdminProxy(aStub, aUuid); | |
33 } | |
34 | |
35 static TxnParticipantProxy newTxnParticipantProxy(BlitzServer aStub, | |
36 Uuid aUuid) { | |
37 if (isSecure(aStub)) | |
38 return new ConstrainableTxnParticipantProxy(aStub, aUuid); | |
39 else | |
40 return new TxnParticipantProxy(aStub, aUuid); | |
41 } | |
42 | |
43 public static LeaseImpl newLeaseImpl(BlitzServer aStub, Uuid aUuid, | |
44 SpaceUID aUID, long anExpiration) { | |
45 if (isSecure(aStub)) | |
46 return new ConstrainableLeaseImpl(aStub, aUuid, aUID, | |
47 anExpiration); | |
48 else | |
49 return new LeaseImpl(aStub, aUuid, aUID, anExpiration); | |
50 } | |
51 | |
52 /** | |
53 * @return a lease with no stub set. This will be done by the <code> | |
54 * BlitzProxy</code> on receipt. This saves the transfer of a stub which | |
55 * is a significant serialization cost. | |
56 */ | |
57 public static LeaseImpl newEntryLeaseImpl(BlitzServer aStub, | |
58 Uuid aUuid, SpaceUID aUID, long anExpiration) { | |
59 if (isSecure(aStub)) | |
60 return new ConstrainableLeaseImpl(null, null, aUID, | |
61 anExpiration); | |
62 else | |
63 return new LeaseImpl(null, null, aUID, anExpiration); | |
64 } | |
65 } |