Mercurial > hg > blitz_condensed
view src/org/dancres/blitz/remote/ConstrainableAdminProxy.java @ 33:0b9265358617
Added tag 2.1.1 for changeset a77f0a9ed93c
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 12 Jun 2010 10:52:10 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz.remote; import java.io.IOException; import java.io.ObjectInputStream; import java.io.InvalidObjectException; import java.lang.reflect.Method; import net.jini.id.Uuid; import net.jini.core.constraint.RemoteMethodControl; import net.jini.core.constraint.MethodConstraints; import net.jini.security.proxytrust.ProxyTrustIterator; import net.jini.security.proxytrust.SingletonProxyTrustIterator; import net.jini.core.transaction.Transaction; import net.jini.core.entry.Entry; import com.sun.jini.outrigger.JavaSpaceAdmin; import com.sun.jini.proxy.ConstrainableProxyUtil; import org.dancres.blitz.mangler.MangledEntry; import org.dancres.util.ReflectUtil; /** When the remote stub generated by the exporter implements RemoteMethodControl, Blitz exports this proxy for Admin duties to support appropriate constraints etc. */ public final class ConstrainableAdminProxy extends AdminProxy implements RemoteMethodControl { private static final Method[] theMethodMapping = { ReflectUtil.findMethod(JavaSpaceAdmin.class, "space", new Class[] {}), ReflectUtil.findMethod(EntryViewAdmin.class, "getJavaSpaceProxy", new Class[] {}), ReflectUtil.findMethod(JavaSpaceAdmin.class, "contents", new Class[] {Entry.class, Transaction.class}), ReflectUtil.findMethod(EntryViewAdmin.class, "newView", new Class[] {MangledEntry[].class, Transaction.class, long.class, boolean.class, long.class, int.class}), ReflectUtil.findMethod(JavaSpaceAdmin.class, "contents", new Class[] {Entry.class, Transaction.class, int.class}), ReflectUtil.findMethod(EntryViewAdmin.class, "newView", new Class[] {MangledEntry[].class, Transaction.class, long.class, boolean.class, long.class, int.class}) }; private static AdminServer constrainStub(AdminServer aServer, MethodConstraints aConstraints) { RemoteMethodControl myServer = (RemoteMethodControl) aServer; MethodConstraints myStubConstraints = ConstrainableProxyUtil.translateConstraints(aConstraints, theMethodMapping); myServer.setConstraints(myStubConstraints); return (AdminServer) myServer; } private MethodConstraints theConstraints; ConstrainableAdminProxy(AdminServer aAdmin, Uuid aUuid) { super(aAdmin, aUuid); } private ConstrainableAdminProxy(AdminServer anAdmin, Uuid aUuid, MethodConstraints aConstraints) { super(constrainStub(anAdmin, aConstraints), aUuid); theConstraints = aConstraints; } private ProxyTrustIterator getProxyTrustIterator() { return new SingletonProxyTrustIterator(theStub); } public RemoteMethodControl setConstraints(MethodConstraints aConstraints) { return new ConstrainableAdminProxy(theStub, theUuid, aConstraints); } public MethodConstraints getConstraints() { return theConstraints; } private void readObject(ObjectInputStream anOIS) throws IOException, ClassNotFoundException { anOIS.defaultReadObject(); if(! (theStub instanceof RemoteMethodControl) ) { throw new InvalidObjectException("space does not implement RemoteMethodControl"); } } }