comparison src/org/dancres/blitz/remote/ConstrainableTxnParticipantProxy.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 java.io.IOException;
4 import java.io.ObjectInputStream;
5 import java.io.InvalidObjectException;
6
7 import net.jini.id.Uuid;
8
9 import net.jini.core.transaction.server.TransactionParticipant;
10
11 import net.jini.core.constraint.RemoteMethodControl;
12 import net.jini.core.constraint.MethodConstraints;
13
14 import net.jini.security.proxytrust.ProxyTrustIterator;
15 import net.jini.security.proxytrust.SingletonProxyTrustIterator;
16
17 /**
18 When the remote stub generated by the exporter implements
19 RemoteMethodControl, Blitz exports this proxy for participant duties to
20 support appropriate constraints etc.
21 */
22 public final class ConstrainableTxnParticipantProxy extends
23 TxnParticipantProxy implements RemoteMethodControl {
24
25 private static TransactionParticipant constrainStub(TransactionParticipant aServer, MethodConstraints aConstraints) {
26 RemoteMethodControl myServer = (RemoteMethodControl) aServer;
27
28 myServer.setConstraints(aConstraints);
29 return (TransactionParticipant) myServer;
30 }
31
32 private final MethodConstraints theConstraints;
33
34 ConstrainableTxnParticipantProxy(TransactionParticipant aPart,
35 Uuid aUuid) {
36 super(aPart, aUuid);
37 theConstraints = null;
38 }
39
40 private ConstrainableTxnParticipantProxy(TransactionParticipant aPart,
41 Uuid aUuid,
42 MethodConstraints aConstraints) {
43 super(constrainStub(aPart, aConstraints), aUuid);
44 theConstraints = aConstraints;
45 }
46
47 private ProxyTrustIterator getProxyTrustIterator() {
48 return new SingletonProxyTrustIterator(theStub);
49 }
50
51 public RemoteMethodControl setConstraints(MethodConstraints aConstraints) {
52 return new ConstrainableTxnParticipantProxy(theStub, theUuid,
53 aConstraints);
54
55 }
56
57 public MethodConstraints getConstraints() {
58 return theConstraints;
59 }
60
61 private void readObject(ObjectInputStream anOIS)
62 throws IOException, ClassNotFoundException {
63
64 anOIS.defaultReadObject();
65
66 if(! (theStub instanceof RemoteMethodControl) ) {
67 throw new InvalidObjectException("space does not implement RemoteMethodControl");
68 }
69 }
70 }