river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: r724995 [2/6] - in /incubator/river/jtsk/skunk/niclas1/shared: ./ action/ action/src/ action/src/main/ action/src/main/java/ action/src/main/java/com/ action/src/main/java/com/sun/ action/src/main/java/com/sun/jini/ action/src/main/java/com...
Date Wed, 10 Dec 2008 05:25:04 GMT
Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLease.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLease.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLease.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLease.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import com.sun.jini.proxy.ConstrainableProxyUtil;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Method;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.core.lease.Lease;
+import net.jini.core.lease.LeaseMap;
+import net.jini.export.proxytrust.ProxyTrustIterator;
+import net.jini.export.proxytrust.SingletonProxyTrustIterator;
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+
+/**
+ * Constrainable sub-class of <code>LandlordLease</code>.
+ * Instances of this class can be verified using the
+ * <code>LandlordProxyVerifier</code> class.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see LandlordProxyVerifier
+ * @since 2.0
+ */
+final public class ConstrainableLandlordLease extends LandlordLease
+    implements RemoteMethodControl
+{
+    static final long serialVersionUID = 1L;
+
+    /**
+     * Returns the public method for the specified <code>Class</code> type,
+     * method name, and array of parameter types.
+     * <p>
+     * This method is typically used in place of {@link Class#getMethod
+     * Class.getMethod} to get a method that should definitely be defined;
+     * thus, this method throws an error instead of an exception if the
+     * given method is missing.
+     * <p>
+     * This method is convenient for the initialization of a static
+     * variable for use as the <code>mappings</code> argument to
+     * {@link com.sun.jini.proxy.ConstrainableProxyUtil#translateConstraints
+     * ConstrainableProxyUtil.translateConstraints}.
+     *
+     * @param type           the <code>Class</code> type that defines the
+     *                       method of interest
+     * @param name           <code>String</code> containing the name of the
+     *                       method of interest
+     * @param parameterTypes the <code>Class</code> types of the parameters
+     *                       to the method of interest
+     * @return a <code>Method</code> object that provides information about,
+     *         and access to, the method of interest
+     * @throws <code>NoSuchMethodError</code> if the method of interest
+     *                                        cannot be found
+     * @throws <code>NullPointerException</code>
+     *                                        if <code>type</code> or
+     *                                        <code>name</code> is <code>null</code>
+     */
+    private static Method getMethod( Class type, String name,
+                                     Class[] parameterTypes )
+    {
+        try
+        {
+            return type.getMethod( name, parameterTypes );
+        }
+        catch( NoSuchMethodException e )
+        {
+            throw (Error)
+                ( new NoSuchMethodError( e.getMessage() ).initCause( e ) );
+        }
+    }
+
+    /**
+     * Convenience field containing the <code>renew</code> method
+     * defined in the <code>Lease</code> interface. This field is used in the
+     * method mapping arrays and when retrieving method constraints
+     * for comparison in <code>canBatch</code>.
+     */
+    private static final Method renewMethod =
+        getMethod( Lease.class, "renew", new Class[]{ long.class } );
+
+    /**
+     * Convenience field containing the <code>cancel</code> method
+     * defined in the <code>Lease</code> interface. This field is used in the
+     * method mapping arrays and when retrieving method constraints
+     * for comparison in <code>canBatch</code>.
+     */
+    private static final Method cancelMethod =
+        getMethod( Lease.class, "cancel", new Class[]{ } );
+
+    /**
+     * Convenience field containing the <code>renewAll</code> method
+     * defined in the <code>Landlord</code> interface. This field is
+     * used in the method mapping arrays.
+     */
+    private static final Method renewAllMethod =
+        getMethod( Landlord.class, "renewAll",
+                   new Class[]{ Uuid[].class, long[].class } );
+
+    /**
+     * Convenience field containing the <code>cancelAll</code> method
+     * defined in the <code>Landlord</code> interface. This field is
+     * used in the method mapping arrays.
+     */
+    private static final Method cancelAllMethod =
+        getMethod( Landlord.class, "cancelAll", new Class[]{ Uuid[].class } );
+
+    /**
+     * Array containing element pairs in which each pair of elements
+     * represents a mapping between two methods having the following
+     * characteristics:
+     * <ul>
+     * <li> the first element in the pair is one of the public, remote
+     * methods that may be invoked by the client through
+     * <code>Lease</code>.
+     * <li> the second element in the pair is the method, implemented
+     * in the backend server class, that is ultimately executed in
+     * the server's backend when the client invokes the corresponding
+     * method in this proxy.
+     * </ul>
+     */
+    private static final Method[] methodMapArray = {
+        renewMethod,
+        getMethod( Landlord.class, "renew",
+                   new Class[]{ Uuid.class, long.class } ),
+
+        cancelMethod,
+        getMethod( Landlord.class, "cancel", new Class[]{ Uuid.class } )
+    };
+
+    /**
+     * When creating a <code>LeaseMap</code> we generate an implicit
+     * set of constraints based on the constraints found on the
+     * the initial lease, where <code>Lease.renew</code> maps to
+     * <code>Landlord.renewAll</code> and <code>Lease.cancel</code> maps to
+     * <code>Landlord.cancelAll</code>. This array holds this mapping.
+     * Mapping also used by <code>ConstrainableLandlordLeaseMap</code> in
+     * <code>canContainKey</code>.
+     */
+    static final Method[] leaseMapMethodMapArray = {
+        renewMethod, renewAllMethod,
+        cancelMethod, cancelAllMethod
+    };
+
+    /**
+     * <code>canBatch</code> needs to check if this lease and
+     * the passed in lease have compatible constraints, this
+     * is the set of methods to compare. Structured so we can
+     * use {@link ConstrainableProxyUtil.equivalentConstraints}.
+     */
+    private static final Method[] comparableMethodsMapArray = {
+        renewMethod, renewMethod,
+        cancelMethod, cancelMethod
+    };
+
+    /**
+     * Client constraints placed on this proxy (may be <code>null</code>)
+     *
+     * @serial
+     */
+    private final MethodConstraints methodConstraints;
+
+    /**
+     * Create a new <code>ConstrainableLandlordLease</code>.
+     *
+     * @param cookie            a <code>Uuid</code> that universally and uniquely
+     *                          identifies the lease this object is to be a proxy for
+     * @param landlord          <code>Landlord</code> object that will be used to
+     *                          communicate renew and cancel requests to the granter
+     *                          of the lease.
+     * @param landlordUuid      a universally unique id that has been
+     *                          assigned to the server granting of the lease.
+     *                          Ideally the <code>Uuid</code> {@link
+     *                          ReferentUuid#getReferentUuid landlord.getUuid} would
+     *                          return if <code>landlord</code> implemented
+     *                          {@link ReferentUuid}. Used to determine when
+     *                          two leases can be batched together.
+     * @param expiration        The initial expiration time of the lease in
+     *                          milliseconds since the beginning of the epoch.
+     * @param methodConstraints the client method constraints to place on
+     *                          this proxy (may be <code>null</code>).
+     * @throws NullPointerException if <code>landlord</code>,
+     *                              <code>landlordUuid</code>, or <code>cookie</code>
+     *                              is <code>null</code>.
+     * @throws ClassCastException   if <code>landlord</code>
+     *                              does not implement <code>RemoteMethodControl</code>.
+     */
+    public ConstrainableLandlordLease( Uuid cookie, Landlord landlord,
+                                       Uuid landlordUuid, long expiration,
+                                       MethodConstraints methodConstraints )
+    {
+        super( cookie, constrainServer( landlord, methodConstraints,
+                                        methodMapArray ),
+               landlordUuid, expiration );
+        this.methodConstraints = methodConstraints;
+    }
+
+    /**
+     * Returns a copy of the given {@link Landlord} proxy having the
+     * client method constraints that result after a specified mapping
+     * is applied to the given method constraints. For details on the
+     * mapping see {@link ConstrainableProxyUtil#translateConstraints
+     * ConstrainableProxyUtil.translateConstraints}.
+     *
+     * @param server      the proxy to attach constraints to
+     * @param constraints the source method constraints
+     * @param mapping     mapping of methods to methods
+     * @throws NullPointerException if <code>server</code> is
+     *                              <code>null</code>.
+     * @throws ClassCastException   if <code>server</code>
+     *                              does not implement <code>RemoteMethodControl</code>.
+     */
+    private static Landlord constrainServer( Landlord server,
+                                             MethodConstraints constraints, Method[] mapping )
+    {
+        final MethodConstraints serverRefConstraints
+            = ConstrainableProxyUtil.translateConstraints( constraints,
+                                                           mapping );
+        final RemoteMethodControl constrainedServer =
+            ( (RemoteMethodControl) server ).
+                setConstraints( serverRefConstraints );
+
+        return (Landlord) constrainedServer;
+    }
+
+    // doc inherited from super
+    public RemoteMethodControl setConstraints( MethodConstraints constraints )
+    {
+        return new ConstrainableLandlordLease( cookie(), landlord(),
+                                               landlordUuid(), expiration, constraints );
+    }
+
+    // doc inherited from super
+    public MethodConstraints getConstraints()
+    {
+        return methodConstraints;
+    }
+
+    /**
+     * Returns a proxy trust iterator that is used in
+     * <code>ProxyTrustVerifier</code> to retrieve this object's
+     * trust verifier.
+     */
+    private ProxyTrustIterator getProxyTrustIterator()
+    {
+        return new SingletonProxyTrustIterator( landlord() );
+    }
+
+    private void readObject( ObjectInputStream s )
+        throws IOException, ClassNotFoundException
+    {
+        s.defaultReadObject();
+
+        /* basic validation of landlord and cookie were performed by
+       * LandlordLease.readObject(), we just need to verify than
+       * landlord implements RemoteMethodControl and that it has
+       * appropriate constraints.
+       */
+        ConstrainableProxyUtil.verifyConsistentConstraints(
+            methodConstraints, landlord(), methodMapArray );
+    }
+
+    // doc inherited from super
+    public boolean canBatch( Lease lease )
+    {
+        if( !super.canBatch( lease ) )
+        {
+            return false;
+        }
+
+        // Same landlord, check to see if we have comparable constraints.
+        if( !( lease instanceof ConstrainableLandlordLease ) )
+        {
+            return false;
+        }
+
+        final MethodConstraints lmc =
+            ( (ConstrainableLandlordLease) lease ).methodConstraints;
+
+        return
+            ConstrainableProxyUtil.equivalentConstraints(
+                methodConstraints, lmc, comparableMethodsMapArray );
+    }
+
+    // doc inherited from super
+    public LeaseMap createLeaseMap( long duration )
+    {
+        return new ConstrainableLandlordLeaseMap(
+            constrainServer( landlord(), methodConstraints,
+                             leaseMapMethodMapArray ),
+            landlordUuid(), this, duration );
+    }
+}
+

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLeaseMap.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLeaseMap.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLeaseMap.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/ConstrainableLandlordLeaseMap.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import com.sun.jini.proxy.ConstrainableProxyUtil;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.core.lease.Lease;
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+
+/**
+ * Constrainable sub-class of <code>LandlordLeaseMap</code>.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+final public class ConstrainableLandlordLeaseMap extends LandlordLeaseMap
+{
+    /**
+     * Create a new <code>ConstrainableLandlordLeaseMap</code>.
+     *
+     * @param landlord     Reference to the entity that created
+     *                     <code>lease</code>.  Assumes that any
+     *                     necessary method constraints have been
+     *                     attached.
+     * @param landlordUuid a universally unique id that has been
+     *                     assigned to the server granting of the lease.
+     *                     Ideally the <code>Uuid</code> {@link
+     *                     ReferentUuid.getUuid landlord.getUuid} would
+     *                     return if <code>landlord</code> implemented
+     *                     {@link ReferentUuid}. Used to determine when
+     *                     leases can be added to this map.
+     * @param lease        First lease to be placed in the map.  It is
+     *                     assumed that <code>canContainKey(lease)</code>
+     *                     would be <code>true</code>.  Must work with the
+     *                     landlord protocol.
+     * @param duration     The duration the lease should be renewed for if
+     *                     <code>renewAll</code> is called.
+     * @throws ClassCastException   if <code>landlord</code>
+     *                              does not implement <code>RemoteMethodControl</code>.
+     * @throws NullPointerException if landlord is <code>null</code>.
+     */
+    ConstrainableLandlordLeaseMap( Landlord landlord, Uuid landlordUuid,
+                                   Lease lease, long duration )
+    {
+        super( landlord, landlordUuid, lease, duration );
+        if( !( landlord instanceof RemoteMethodControl ) )
+        {
+            throw new ClassCastException( "landlord must implement " +
+                                          "RemoteMethodControl" );
+        }
+    }
+
+    // doc inherited from super
+    public boolean canContainKey( Object key )
+    {
+        if( !super.canContainKey( key ) )
+        {
+            return false;
+        }
+
+        // Same landlord, check to see if we have comparable constraints.
+        if( !( key instanceof ConstrainableLandlordLease ) )
+        {
+            return false;
+        }
+
+        // The key's constraints
+        final MethodConstraints lmc =
+            ( (ConstrainableLandlordLease) key ).getConstraints();
+
+        // Our constraints
+        final MethodConstraints omc =
+            ( (RemoteMethodControl) landlord() ).getConstraints();
+
+        // Are they equivalent (after applying the map)?
+        return ConstrainableProxyUtil.equivalentConstraints(
+            lmc, omc, ConstrainableLandlordLease.leaseMapMethodMapArray );
+
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/FixedLeasePeriodPolicy.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/FixedLeasePeriodPolicy.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/FixedLeasePeriodPolicy.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/FixedLeasePeriodPolicy.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import net.jini.core.lease.Lease;
+import net.jini.core.lease.LeaseDeniedException;
+
+/**
+ * Simple implementation of <code>LeasePeriodPolicy</code> that grants
+ * lease times based on a fixed default and maximum lease. Will grant
+ * renewals longer than the maximum if the current lease and the
+ * request are both longer than the maximum.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public class FixedLeasePeriodPolicy implements LeasePeriodPolicy
+{
+    /**
+     * Under normal circumstances, the maximum lease or renewal to grant
+     */
+    final private long maximum;
+
+    /**
+     * The default lease length
+     */
+    final private long defaultLength;
+
+    /**
+     * Create a new <code>FixedLeasePeriodPolicy</code> with
+     * the specified values for the maxium and default lease
+     * lengths.
+     *
+     * @param maximum       the length in milliseconds of the longest lease
+     *                      this object should normally grant
+     * @param defaultLength the length in milliseconds of the
+     *                      default lease grants
+     * @throws IllegalArgumentException if either argument
+     *                                  is not positive.
+     */
+    public FixedLeasePeriodPolicy( long maximum, long defaultLength )
+    {
+        if( maximum <= 0 )
+        {
+            throw new IllegalArgumentException( "FixedLeasePeriodPolicy:" +
+                                                "maximum lease time must be larger than 0, " +
+                                                "passed:" + maximum );
+        }
+
+        if( defaultLength <= 0 )
+        {
+            throw new IllegalArgumentException( "FixedLeasePeriodPolicy:" +
+                                                "default lease time must be larger than 0, " +
+                                                "passed:" + defaultLength );
+        }
+
+        this.maximum = maximum;
+        this.defaultLength = defaultLength;
+    }
+
+
+    /**
+     * Returns the duration this policy is willing to grant for the
+     * passed resource at this time.  The duration actually granted
+     * will be shorter if the duration extends pass the end of the
+     * epoch.  Must return a positive number.
+     * <p>
+     * Note the duration returned by this method will be shorter than
+     * the final duration granted if the requested duration extends
+     * past the current expiration, and duration return by this
+     * method is before the current expiration.
+     *
+     * @param resource          the resource having a lease granted
+     *                          or renewed
+     * @param requestedDuration the duration the client wants
+     * @throws IllegalArgumentException thrown if requestedDuration
+     *                                  is less than 0 and not equal to
+     *                                  <code>Lease.ANYLENGTH</code> or
+     *                                  <code>Lease.FOREVER</code>.
+     */
+    protected long calculateDuration( LeasedResource resource,
+                                      long requestedDuration )
+    {
+        if( requestedDuration == Lease.FOREVER )
+        {
+            requestedDuration = Long.MAX_VALUE;
+        }
+        else if( requestedDuration == Lease.ANY )
+        {
+            requestedDuration = defaultLength;
+        }
+        else if( requestedDuration < 0 )
+        {
+            throw new
+                IllegalArgumentException( "Negative lease duration " +
+                                          "requested" );
+        }
+
+        return Math.min( requestedDuration, maximum );
+    }
+
+    /**
+     * Method that provides some notion of the current time in milliseconds
+     * since the beginning of the epoch. Default implementation
+     * calls System.currentTimeMillis()
+     */
+    protected long currentTime()
+    {
+        return System.currentTimeMillis();
+    }
+
+    /**
+     * Calculates an expiration based on the passed time and a requested
+     * duration. Will clip the expiration to the end of the epoch
+     *
+     * @param preferredDuration the duration the policy wants to grant
+     * @param now               the current time in milliseconds since
+     *                          the beginning of the epoch
+     * @return the new expiration time for the lease in milliseconds since
+     *         the beginning of the epoch
+     */
+    private long calcExpiration( long preferredDuration, long now )
+    {
+        long expiration = now + preferredDuration;
+        // Any addition of two positive longs is guaranteed to be
+        // negative if it overflowed
+        if( expiration < 0 )
+        {
+            // Not enough time for the duration we want, set to end of
+            // epoch
+            return Long.MAX_VALUE;
+        }
+
+        return expiration;
+    }
+
+
+    public Result grant( LeasedResource resource, long requestedDuration )
+        throws LeaseDeniedException
+    {
+        final long now = currentTime();
+        final long expiration =
+            calcExpiration( calculateDuration( resource, requestedDuration ),
+                            now );
+        final long duration = expiration - now;
+        return new Result( expiration, duration );
+    }
+
+    public Result renew( LeasedResource resource, long requestedDuration )
+        throws LeaseDeniedException
+    {
+        final long now = currentTime();
+
+        // The new expiration we would grant independent of the
+        // current expiration time
+        long newExpiration =
+            calcExpiration( calculateDuration( resource, requestedDuration ),
+                            now );
+
+        // Do not change the expiration time to be sooner that it is
+        // now unless the client explicitly asked for it.  If they did
+        // ask for a sooner expiration give them exactly what they
+        // asked for.
+
+        // The current expiration of the lease
+        final long oldExpiration = resource.getExpiration();
+
+        if( oldExpiration > newExpiration )
+        {
+            // need to make sure they asked for it
+
+            if( requestedDuration == Lease.ANY )
+            {
+                // they did not explicitly ask for a sooner
+                // expiration, give them at least what they had
+                newExpiration = oldExpiration;
+            }
+            else
+            {
+                // The new expiration time they are requesting
+                // (possibly clipped to the end of the epoch) this is
+                // not affected by what we are willing to grant.
+                // [Note we know at this point that requestedDuration
+                // is >= 0]
+                final long requestedExpiration = calcExpiration(
+                    requestedDuration, now );
+
+                if( requestedExpiration > oldExpiration )
+                {
+                    // they made a request for something longer, give
+                    // them at least what they had
+                    newExpiration = oldExpiration;
+                }
+                else
+                {
+                    // They made a request for something shorter,
+                    // give them what they at least what they want
+                    newExpiration = requestedExpiration;
+                }
+            }
+        }
+
+        // Now that we finally have decided on a new expiration,
+        // get the real duration and return the result.
+        return new Result( newExpiration, newExpiration - now );
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/Landlord.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/Landlord.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/Landlord.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/Landlord.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import net.jini.core.lease.Lease;
+import net.jini.core.lease.LeaseDeniedException;
+import net.jini.core.lease.LeaseMap;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.id.Uuid;
+
+/**
+ * Interface that granters of leases must implement in order to work
+ * with the <code>LandlordLease</code> implementation of the
+ * <code>Lease</code> interface.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see net.jini.core.lease.Lease
+ * @see LandlordLease
+ * @since 2.0
+ */
+public interface Landlord extends Remote
+{
+    /**
+     * Called by the lease when its {@link Lease#renew renew} method is called.
+     * Renews the lease that is associated with the given <code>cookie</code>.
+     *
+     * @param cookie   the <code>Uuid</code> associated with the lease who's
+     *                 <code>renew</code> method was called
+     * @param duration argument passed to the <code>renew</code> call
+     * @return The new duration the lease should have
+     * @throws LeaseDeniedException  if the landlord is unwilling to
+     *                               renew the lease
+     * @throws UnknownLeaseException if landlord does not know about
+     *                               a lease with the specified <code>cookie</code>
+     * @throws RemoteException       if a communications failure occurs
+     */
+    public long renew( Uuid cookie, long duration )
+        throws LeaseDeniedException, UnknownLeaseException, RemoteException;
+
+    /**
+     * Called by the lease when its {@link Lease#cancel cancel} method is
+     * called. Cancels the lease that is associated with the given
+     * <code>cookie</code>.
+     *
+     * @param cookie the <code>Uuid</code> associated with the lease who's
+     *               <code>renew</code> method was called
+     * @throws UnknownLeaseException if landlord does not know about
+     *                               a lease with the specified <code>cookie</code>
+     * @throws RemoteException       if a communications failure occurs
+     */
+    public void cancel( Uuid cookie )
+        throws UnknownLeaseException, RemoteException;
+
+    /**
+     * Called by the lease map when its {@link LeaseMap#renewAll
+     * renewAll} method is called.  Should renew the lease that is
+     * associated with each element of <code>cookies</code>
+     *
+     * @param cookies   an array of <code>Uuid</code>s, each universally and
+     *                  uniquely identifying a lease granted by this
+     *                  <code>Landlord</code>
+     * @param durations an array of longs, each representing an a
+     *                  duration in milliseconds that the client
+     *                  wants the lease associated with the <code>Uuid</code>
+     *                  from the corresponding element of
+     *                  <code>cookies</code> renewed for
+     * @return A RenewResults object that contains the new
+     *         duration of each lease that was successfully renewed or
+     *         the exception encountered for each lease that could not
+     *         be renewed
+     * @throws RemoteException if a communications failure occurs
+     */
+    public RenewResults renewAll( Uuid[] cookies, long[] durations )
+        throws RemoteException;
+
+    /**
+     * Called by the lease map when its {@link LeaseMap#cancelAll
+     * cancelAll} method is called.  Should cancel the lease that is
+     * associated with each element of <code>cookies</code>
+     *
+     * @param cookies an array of <code>Uuid</code>s, each universally and
+     *                uniquely identifying a lease granted by this
+     *                <code>Landlord</code>
+     * @return If all the leases specified in the <code>cookies</code>
+     *         could be cancelled return <code>null</code>.  Otherwise,
+     *         return a <code>Map</code> that for each failed cancel
+     *         attempt maps the corresponding cookie object to an
+     *         exception describing the failure.
+     * @throws RemoteException if a communications failure occurs
+     */
+    public java.util.Map cancelAll( Uuid[] cookies ) throws RemoteException;
+
+    /**
+     * Simple class that holds return values of
+     * the {@link Landlord#renewAll Landlord.renewAll} method.
+     */
+    public class RenewResults implements java.io.Serializable
+    {
+        static final long serialVersionUID = 2L;
+
+        /**
+         * For each cookie passed to {@link Landlord#renewAll renewAll},
+         * <code>granted[i]</code> is the granted lease time, or -1 if the
+         * renewal for that lease generated an exception.  If there was
+         * an exception, the exception is held in <code>denied</code>.
+         *
+         * @serial
+         * @see #denied
+         */
+        public long[] granted;
+
+        /**
+         * The <code>i</code><sup><i>th</i></sup> -1 in <code>granted</code>
+         * was denied because of <code>denied[i]</code>.  If nothing was
+         * denied, this field is <code>null</code>.
+         *
+         * @serial
+         */
+        public Exception[] denied;
+
+        /**
+         * Create a <code>RenewResults</code> object setting the field
+         * <code>granted</code> to the passed value, and <code>denied</code>
+         * to <code>null</code>.
+         *
+         * @param granted The value for the field <code>granted</code>
+         */
+        public RenewResults( long[] granted )
+        {
+            this( granted, null );
+        }
+
+        /**
+         * Create a <code>RenewResults</code> object setting the field
+         * <code>granted</code> and <code>denied</code> fields to the
+         * passed values.
+         *
+         * @param granted the value for the field <code>granted</code>
+         * @param denied  the value for the field <code>denied</code>
+         */
+        public RenewResults( long[] granted, Exception[] denied) {
+	    this.granted = granted;
+	    this.denied = denied;
+	}
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLease.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLease.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLease.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLease.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import com.sun.jini.lease.AbstractLease;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.rmi.RemoteException;
+import net.jini.core.lease.Lease;
+import net.jini.core.lease.LeaseDeniedException;
+import net.jini.core.lease.LeaseMap;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.id.ReferentUuid;
+import net.jini.id.ReferentUuids;
+import net.jini.id.Uuid;
+
+/**
+ * Basic implementation of <code>net.jini.core.lease.Lease</code> that works
+ * with the the Landlord protocol.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see Landlord
+ * @since 2.0
+ */
+public class LandlordLease extends AbstractLease implements ReferentUuid
+{
+    static final long serialVersionUID = 2L;
+
+    /**
+     * A universally unique ID that identifies the lease this object
+     * represents.
+     *
+     * @serial
+     */
+    final private Uuid cookie;
+
+    /**
+     * Owner of the resource associated with this lease.
+     *
+     * @serial
+     */
+    final private Landlord landlord;
+
+    /**
+     * The <code>Uuid</code> of the <code>landlord</code>. Used
+     * to determine if two leases can be batched together.
+     *
+     * @serial
+     */
+    final private Uuid landlordUuid;
+
+    /**
+     * Create a new <code>LandlordLease</code>.
+     *
+     * @param cookie       a <code>Uuid</code> that universally and uniquely
+     *                     identifies the lease this object is to be a proxy for
+     * @param landlord     <code>Landlord</code> object that will be used to
+     *                     communicate renew and cancel requests to the granter
+     *                     of the lease
+     * @param landlordUuid a universally unique id that has been
+     *                     assigned to the server granting of the lease.
+     *                     Ideally the <code>Uuid</code> {@link
+     *                     ReferentUuid#getReferentUuid landlord.getUuid} would
+     *                     return if <code>landlord</code> implemented
+     *                     {@link ReferentUuid}. Used to determine when
+     *                     two leases can be batched together.
+     * @param expiration   the initial expiration time of the lease in
+     *                     milliseconds since the beginning of the epoch
+     * @throws NullPointerException if <code>landlord</code>,
+     *                              <code>landlordUuid</code> or <code>cookie</code>
+     *                              is null
+     */
+    public LandlordLease( Uuid cookie, Landlord landlord, Uuid landlordUuid,
+                          long expiration )
+    {
+        super( expiration );
+
+        if( cookie == null )
+        {
+            throw new NullPointerException( "Can't create a LandlordLease " +
+                                            "with a null cookie" );
+        }
+
+        if( landlord == null )
+        {
+            throw new NullPointerException( "Can't create a LandlordLease " +
+                                            "with a null landlord" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new NullPointerException( "Can't create a LandlordLease " +
+                                            "with a null landlordUuid" );
+        }
+
+        this.cookie = cookie;
+        this.landlord = landlord;
+        this.landlordUuid = landlordUuid;
+    }
+
+    // Implementation of the Lease interface
+
+    // purposefully inherit doc comment from supertype
+
+    public void cancel() throws UnknownLeaseException, RemoteException
+    {
+        landlord.cancel( cookie );
+    }
+
+    // purposefully inherit doc comment from supertype
+    protected long doRenew( long renewDuration )
+        throws LeaseDeniedException, UnknownLeaseException, RemoteException
+    {
+        if( renewDuration < 0 && !( renewDuration == Lease.FOREVER ||
+                                    renewDuration == Lease.ANY ) )
+        {
+            throw new IllegalArgumentException( "Lease renewal: " +
+                                                "Asked for a negative duration" );
+        }
+        return landlord.renew( cookie, renewDuration );
+    }
+
+    // purposefully inherit doc comment from supertype
+    public Uuid getReferentUuid()
+    {
+        return cookie;
+    }
+
+    // purposefully inherit doc comment from supertype
+    public boolean equals( Object other )
+    {
+        return ReferentUuids.compare( this, other );
+
+        // Note, we do not include the expiration in the equality test.
+        // If the lease is copied and ether the copy or the original
+        // is renewed they are conceptually the same because they
+        // still represent the same claim on the same resource
+        // --however their expiration will be different
+    }
+
+    // inherit doc comment
+    public boolean canBatch( Lease lease )
+    {
+        if( lease instanceof LandlordLease )
+        {
+            return landlordUuid.equals( ( (LandlordLease) lease ).landlordUuid );
+        }
+
+        return false;
+    }
+
+    /**
+     * Return the landlord.
+     */
+    Landlord landlord()
+    {
+        return landlord;
+    }
+
+    /**
+     * Return the landlord's Uuid.
+     */
+    Uuid landlordUuid()
+    {
+        return landlordUuid;
+    }
+
+    /**
+     * Return the cookie.
+     */
+    Uuid cookie()
+    {
+        return cookie;
+    }
+
+    /**
+     * Set the expiration.
+     */
+    void setExpiration( long expiration )
+    {
+        this.expiration = expiration;
+    }
+
+    // inherit doc comment
+    public LeaseMap createLeaseMap( long duration )
+    {
+        return new LandlordLeaseMap( landlord, landlordUuid, this, duration );
+    }
+
+    // purposefully inherit doc comment from supertype
+    public int hashCode()
+    {
+        return cookie.hashCode();
+    }
+
+    // purposefully inherit doc comment from supertype
+    public String toString()
+    {
+        return "LandlordLease:" + cookie + " landlord:" + landlord +
+               " landlordUuid:" + landlordUuid + " " + super.toString();
+    }
+
+    /**
+     * Read this object back validating state.
+     */
+    private void readObject( ObjectInputStream in )
+        throws IOException, ClassNotFoundException
+    {
+        in.defaultReadObject();
+
+        if( cookie == null )
+        {
+            throw new InvalidObjectException( "null cookie reference" );
+        }
+
+        if( landlord == null )
+        {
+            throw new InvalidObjectException( "null landlord reference" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new InvalidObjectException( "null landlordUuid reference" );
+        }
+    }
+
+    /**
+     * We should always have data in the stream, if this method
+     * gets called there is something wrong.
+     */
+    private void readObjectNoData() throws InvalidObjectException
+    {
+        throw new
+            InvalidObjectException( "LandlordLease should always have data" );
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLeaseMap.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLeaseMap.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLeaseMap.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordLeaseMap.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import com.sun.jini.lease.AbstractLeaseMap;
+import java.rmi.RemoteException;
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import net.jini.core.lease.Lease;
+import net.jini.core.lease.LeaseMapException;
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+
+/**
+ * Implementation of <code>LeaseMap</code> for <code>LandlordLease</code>.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see LandlordLease
+ * @see net.jini.core.lease.LeaseMap
+ * @since 2.0
+ */
+public class LandlordLeaseMap extends AbstractLeaseMap
+{
+    /**
+     * The landlord which this map will talk to.
+     */
+    private final Landlord landlord;
+
+    /**
+     * The <code>Uuid</code> of the {@link #landlord}. Used
+     * to determine if a lease can be placed in this map.
+     */
+    private final Uuid landlordUuid;
+
+    /**
+     * Create a new <code>LandlordLeaseMap</code>.
+     *
+     * @param landlord     Owner of the resource <code>lease</code> is for.
+     * @param landlordUuid a universally unique id that has been
+     *                     assigned to the server granting of the lease.
+     *                     Ideally the <code>Uuid</code> {@link
+     *                     ReferentUuid.getUuid landlord.getUuid} would
+     *                     return if <code>landlord</code> implemented
+     *                     {@link ReferentUuid}. Used to determine when
+     *                     two leases can be batched together.
+     * @param lease        first lease to be placed in the map.  It is
+     *                     assumed that <code>canContainKey(lease)</code>
+     *                     would be <code>true</code>.  Must work with the
+     *                     landlord protocol.
+     * @param duration     the duration the lease should be renewed for if
+     *                     <code>renewAll</code> is called
+     * @throws NullPointerException if <code>landlord</code> or
+     *                              <code>landlordUuid</code> is <code>null</code>.
+     */
+    LandlordLeaseMap( Landlord landlord, Uuid landlordUuid, Lease lease,
+                      long duration )
+    {
+        super( lease, duration );
+        if( landlord == null )
+        {
+            throw new NullPointerException( "Landlord must be non-null" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new NullPointerException( "landlordUuid must be non-null" );
+        }
+
+        this.landlord = landlord;
+        this.landlordUuid = landlordUuid;
+    }
+
+    // inherit doc comment
+    public boolean canContainKey( Object key )
+    {
+        if( key instanceof LandlordLease )
+        {
+            return landlordUuid.equals( ( (LandlordLease) key ).landlordUuid() );
+        }
+
+        return false;
+    }
+
+    // inherit doc comment
+    public void cancelAll() throws LeaseMapException, RemoteException
+    {
+        Uuid[] cookies = new Uuid[size()];
+        LandlordLease[] leases = new LandlordLease[cookies.length];
+        Iterator it = keySet().iterator();
+        for( int i = 0; it.hasNext(); i++ )
+        {
+            LandlordLease lease = (LandlordLease) it.next();
+            leases[ i ] = lease;
+            cookies[ i ] = lease.cookie();
+        }
+
+        final Map rslt = landlord.cancelAll( cookies );
+
+        if( rslt == null )
+        {
+            // Everything worked out, normal return
+            return;
+        }
+        else
+        {
+            // Some the leases could not be canceled, generate a
+            // LeaseMapException
+
+            // translate the cookie->exception map into a
+            // lease->exception map
+
+            int origSize = rslt.size();
+            for( int i = 0; i < cookies.length; i++ )
+            {
+                Object exception = rslt.remove( cookies[ i ] );
+                // remove harmless if not in map
+
+                if( exception != null )
+                {         // if it was in map
+                    rslt.put( leases[ i ], exception );  // put back as lease
+                    remove( leases[ i ] );             // remove from this map
+                }
+            }
+
+            if( origSize != rslt.size() )    // some cookie wasn't found
+            {
+                throw new ConcurrentModificationException();
+            }
+
+            throw new LeaseMapException(
+                "Failure canceling one or more leases", rslt );
+        }
+    }
+
+
+    // inherit doc comment
+    public void renewAll() throws LeaseMapException, RemoteException
+    {
+        Uuid[] cookies = new Uuid[size()];
+        long[] extensions = new long[cookies.length];
+        LandlordLease[] leases = new LandlordLease[cookies.length];
+        Iterator it = keySet().iterator();
+        for( int i = 0; it.hasNext(); i++ )
+        {
+            LandlordLease lease = (LandlordLease) it.next();
+            leases[ i ] = lease;
+            cookies[ i ] = lease.cookie();
+            extensions[ i ] = ( (Long) get( lease ) ).longValue();
+        }
+
+        long now = System.currentTimeMillis();
+        Landlord.RenewResults results =
+            landlord.renewAll( cookies, extensions );
+
+        Map bad = null;
+        int d = 0;
+        for( int i = 0; i < cookies.length; i++ )
+        {
+            if( results.granted[ i ] != -1 )
+            {
+                long newExp = now + results.granted[ i ];
+                if( newExp < 0 ) // Overflow, set to Long.MAX_VALUE
+                {
+                    newExp = Long.MAX_VALUE;
+                }
+
+                leases[ i ].setExpiration( newExp );
+            }
+            else
+            {
+                if( bad == null )
+                {
+                    bad = new HashMap( results.denied.length +
+                                       results.denied.length / 2 );
+                }
+                Object badTime = remove( leases[ i ] );   // remove from this map
+                if( badTime == null )              // better be in there
+                {
+                    throw new ConcurrentModificationException();
+                }
+                bad.put( leases[ i ], results.denied[ d++ ] );// add to "bad" map
+            }
+        }
+
+        if( bad != null )
+        {
+            throw new LeaseMapException( "renewing", bad );
+        }
+    }
+
+    /**
+     * Return the landlord.
+     */
+    Landlord landlord()
+    {
+        return landlord;
+    }
+}
+

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordProxyVerifier.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordProxyVerifier.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordProxyVerifier.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordProxyVerifier.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.export.proxytrust.TrustEquivalence;
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+import net.jini.security.TrustVerifier;
+
+/**
+ * This class defines a trust verifier for the proxies defined
+ * in the landlord package.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see net.jini.security.TrustVerifier
+ * @since 2.0
+ */
+final public class LandlordProxyVerifier
+    implements Serializable, TrustVerifier
+{
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The canonical instance of the server reference. This
+     * instance will be used by the <code>isTrusted</code> method
+     * as the known trusted object used to determine whether or not a
+     * given proxy is equivalent in trust, content, and function.
+     *
+     * @serial
+     */
+    private final RemoteMethodControl landlord;
+
+    /**
+     * The <code>Uuid</code> associated <code>landlord</code>.
+     *
+     * @serial
+     */
+    private final Uuid landlordUuid;
+
+    /**
+     * Returns a verifier for the proxies defined in the landlord
+     * package with the specified server reference and server
+     * <code>Uuid</code>.
+     *
+     * @param landlord     the reference to the <code>Landlord</code>
+     *                     being used by the leases for communication
+     *                     back to the server.
+     * @param landlordUuid a universally unique id that has been
+     *                     assigned to the server granting of the lease.
+     *                     Ideally the <code>Uuid</code> {@link
+     *                     ReferentUuid#getReferentUuid landlord.getUuid} would
+     *                     return if <code>landlord</code> implemented
+     *                     {@link ReferentUuid}. Used to determine when
+     *                     two leases can be batched together.
+     * @throws UnsupportedOperationException if <code>landlord</code> does
+     *                                       not implement both {@link RemoteMethodControl} and {@link
+     *                                       TrustEquivalence}
+     * @throws NullPointerException          if either argument is
+     *                                       <code>null</code>.
+     */
+    public LandlordProxyVerifier( Landlord landlord, Uuid landlordUuid )
+    {
+        if( landlord == null )
+        {
+            throw new NullPointerException( "landlord must not be null" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new NullPointerException( "landlordUuid must not be null" );
+        }
+
+        if( !( landlord instanceof RemoteMethodControl ) )
+        {
+            throw new UnsupportedOperationException
+                ( "cannot construct verifier - server reference does not " +
+                  "implement RemoteMethodControl" );
+        }
+
+        if( !( landlord instanceof TrustEquivalence ) )
+        {
+            throw new UnsupportedOperationException
+                ( "cannot construct verifier - server reference does not " +
+                  "implement TrustEquivalence" );
+        }
+
+        this.landlord = (RemoteMethodControl) landlord;
+        this.landlordUuid = landlordUuid;
+    }
+
+    /**
+     * Returns <code>true</code> if the specified proxy object (that is
+     * not yet known to be trusted) is equivalent in trust, content, and
+     * function to the canonical server reference this object was
+     * constructed with; otherwise returns <code>false</code>.
+     *
+     * @param obj proxy object that will be compared to this class's stored
+     *            canonical proxy to determine whether or not the given
+     *            proxy object is equivalent in trust, content, and function.
+     * @return <code>true</code> if the specified object (that is not yet
+     *         known to be trusted) is equivalent in trust,
+     *         content, and function to the canonical inner
+     *         proxy object referenced in this class;
+     *         otherwise returns <code>false</code>.
+     * @throws NullPointerException if any argument is <code>null</code>
+     */
+    public boolean isTrustedObject( Object obj, TrustVerifier.Context ctx )
+        throws RemoteException
+    {
+        /* Validate the arguments */
+        if( obj == null || ctx == null )
+        {
+            throw new NullPointerException( "arguments must not be null" );
+        }
+
+        /* Prepare the input proxy object for trust verification. The types
+         * of proxies, specific to the service, that this method will
+         * handle are:
+         *  - ConstrainableLandlordLease
+         */
+
+        // Server reference from input proxy
+        final RemoteMethodControl inputProxyServer;
+        if( obj instanceof ConstrainableLandlordLease )
+        {
+            final ConstrainableLandlordLease cll =
+                (ConstrainableLandlordLease) obj;
+
+            // Check the landlordUuid of obj
+            if( !landlordUuid.equals( cll.landlordUuid() ) )
+            {
+                return false;
+            }
+
+            // Extract the landlord ref
+            inputProxyServer = (RemoteMethodControl) cll.landlord();
+        }
+        else
+        {
+            // A proxy type we don't know about
+            return false;
+        }
+
+        /* Get the client constraints currently set on the server reference
+	 * of contained in the input proxy 
+	 */
+        final MethodConstraints mConstraints =
+            inputProxyServer.getConstraints();
+
+        /* Create a copy of the canonical server reference with its method
+	 * constraints replaced with the method constraints on
+	 * server reference of the input proxy.
+         */
+        final TrustEquivalence constrainedServer =
+            (TrustEquivalence) landlord.setConstraints( mConstraints );
+
+        /* With respect to trust, content, and function, test whether
+       * the server reference from the input proxy is equivalent to
+       * the canonical server reference we have (once method
+       * constraints have been normalized.)
+       */
+        return constrainedServer.checkTrustEquivalence( inputProxyServer );
+    }
+
+    /**
+     * Verifies that the server reference implements
+     * <code>TrustEquivalence</code>.
+     */
+    private void readObject( ObjectInputStream in )
+        throws IOException, ClassNotFoundException
+    {
+        in.defaultReadObject();
+
+        if( landlord == null )
+        {
+            throw new InvalidObjectException( "null landlord reference" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new InvalidObjectException( "null landlordUuid reference" );
+        }
+
+        if( !( landlord instanceof TrustEquivalence ) )
+        {
+            throw new InvalidObjectException(
+                "server does not implement TrustEquivalence" );
+        }
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordUtil.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordUtil.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordUtil.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LandlordUtil.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import com.sun.jini.landlord.Landlord.RenewResults;
+import java.util.ArrayList;
+import java.util.Map;
+import net.jini.core.lease.LeaseException;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.id.Uuid;
+
+
+/**
+ * Static methods useful for implementing landlords.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public class LandlordUtil
+{
+    /**
+     * Call <code>landlord.renew()</code> for each object in
+     * <code>cookie[]</code>, passing <code>cookie[i]</code> and
+     * <code>durations[i]</code>.  Gather the results and
+     * exceptions into a <code>RenewResults</code> object.
+     *
+     * @param landlord  A grantor of leases.
+     * @param cookies   an array of <code>Uuid</code>s, each uniquely and
+     *                  universally identifying a lease
+     * @param durations an array of longs, each representing a
+     *                  duration in milliseconds that the client
+     *                  wants the lease associated with the object
+     *                  from the corresponding element of
+     *                  <code>cookies</code> renewed for.
+     * @return A <code>RenewResults</code> object that contains the new
+     *         duration of each lease that was successfully renewed or
+     *         the exception encountered for each lease that could not
+     *         be renewed.
+     */
+    public static RenewResults renewAll( LocalLandlord landlord,
+                                         Uuid[] cookies, long[] durations )
+    {
+        final int count = cookies.length;
+        final long[] granted = new long[count];
+        final ArrayList exceptions = new ArrayList( count );
+
+        for( int i = 0; i < count; i++ )
+        {
+            try
+            {
+                granted[ i ] = landlord.renew( cookies[ i ], durations[ i ] );
+            }
+            catch( LeaseException le )
+            {
+                // Set flag for client-side handling
+                granted[ i ] = -1;
+                exceptions.add( le );
+            }
+        }
+
+        if( exceptions.size() == 0 )
+        {
+            return new Landlord.RenewResults( granted );
+        }
+        else
+        {
+            // Note: Can't just cast exceptions.toArray() to Exception[]
+            final Exception[] es = new Exception[exceptions.size()];
+            return new RenewResults( granted,
+                                     (Exception[]) exceptions.toArray( es ) );
+        }
+    }
+
+    /**
+     * Call <code>landlord.cancel()</code> for each object in
+     * <code>cookies[]</code>, passing <code>cookies[i]</code>.
+     *
+     * @param landlord a grantor of leases
+     * @param cookies  an array of <code>Uuid</code>s, each uniquely and
+     *                 universally identifying a lease
+     * @return If no exceptions are encountered, return
+     *         <code>null</code>, otherwise, return a Map that
+     *         for each failed <code>cancel()</code> call maps
+     *         the passed cookie object to the exception that
+     *         was generated
+     */
+    public static Map cancelAll( LocalLandlord landlord, Uuid[] cookies )
+    {
+        final int count = cookies.length;
+
+        Map map = null;
+        for( int i = 0; i < count; i++ )
+        {
+            try
+            {
+                landlord.cancel( cookies[ i ] );
+            }
+            catch( UnknownLeaseException e )
+            {
+                if( map == null )
+                {
+                    map = new java.util.HashMap();
+                }
+                map.put( cookies[ i ], e );
+            }
+        }
+
+        return map;
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeaseFactory.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeaseFactory.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeaseFactory.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeaseFactory.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.export.proxytrust.TrustEquivalence;
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+import net.jini.security.TrustVerifier;
+
+/**
+ * Factory for {@link LandlordLease} instances.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public class LeaseFactory
+{
+    /**
+     * The inner proxy for the leases we create
+     */
+    final private Landlord landlord;
+
+    /**
+     * The <code>Uuid</code> of the server granting the leases
+     */
+    final private Uuid landlordUuid;
+
+    /**
+     * Create a new <code>LeaseFactory</code> that will create
+     * <code>LandlordLease</code>s with the specified
+     * <code>Landlord</code> and landlord <code>Uuid</code>.
+     *
+     * @param landlord     the inner proxy that the leases will
+     *                     use to communicate back to the server.
+     * @param landlordUuid a universally unique id that has
+     *                     been assigned to the server granting of the lease.
+     *                     Ideally the <code>Uuid</code> {@link
+     *                     ReferentUuid#getReferentUuid landlord.getUuid}
+     *                     would return if <code>landlord</code> implemented
+     *                     {@link ReferentUuid}. Used
+     *                     to determine when two leases can be batched together.
+     * @throws NullPointerException if either argument is
+     *                              <code>null</code>
+     */
+    public LeaseFactory( Landlord landlord, Uuid landlordUuid )
+    {
+        if( landlord == null )
+        {
+            throw new NullPointerException( "landlord must be non-null" );
+        }
+
+        if( landlordUuid == null )
+        {
+            throw new NullPointerException( "landlordUuid must be non-null" );
+        }
+
+        this.landlord = landlord;
+        this.landlordUuid = landlordUuid;
+    }
+
+    /**
+     * Return a new <code>LandlordLease</code> with the specified
+     * initial expiration and cookie using the inner proxy and
+     * <code>Uuid</code> the factory was created with. Will return
+     * a {@link ConstrainableLandlordLease} if inner proxy this
+     * factory was created with implements {@link RemoteMethodControl}.
+     *
+     * @param cookie     a <code>Uuid</code> that will universally and uniquely
+     *                   identify the lease
+     * @param expiration the initial expiration time of the lease.
+     * @return a new <code>LandlordLease</code>.
+     * @throws NullPointerException if the <code>cookie</code> argument is
+     *                              <code>null</code>.
+     */
+    public LandlordLease newLease( Uuid cookie, long expiration )
+    {
+        if( landlord instanceof RemoteMethodControl )
+        {
+            return new ConstrainableLandlordLease( cookie, landlord,
+                                                   landlordUuid, expiration, null );
+        }
+        return new LandlordLease( cookie, landlord, landlordUuid, expiration );
+    }
+
+    /**
+     * Return a <code>TrustVerifier</code> that will verify the
+     * proxies produced by this factory. Currently the verifier
+     * returned will be an instance of {@link LandlordProxyVerifier}.
+     *
+     * @return a new <code>TrustVerifier</code>.
+     * @throws UnsupportedOperationException if the {@link Landlord} this
+     *                                       factory was created with does not implement both
+     *                                       {@link RemoteMethodControl} and {@link TrustEquivalence}.
+     */
+    public TrustVerifier getVerifier()
+    {
+        return new LandlordProxyVerifier( landlord, landlordUuid );
+    }
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasePeriodPolicy.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasePeriodPolicy.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasePeriodPolicy.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasePeriodPolicy.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import net.jini.core.lease.LeaseDeniedException;
+
+/**
+ * Interface for objects that define what policy to use
+ * when calculating lease grants and renewals.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public interface LeasePeriodPolicy
+{
+    /**
+     * Simple class that holds a pair of times, the
+     * new expiration and duration for a lease.
+     */
+    public class Result
+    {
+        /**
+         * The expiration time.
+         */
+        final public long expiration;
+
+        /**
+         * The duration.
+         */
+        final public long duration;
+
+        /**
+         * Simple constructor to create a new <code>Result</code>
+         * object.
+         *
+         * @param expiration the value for the <code>expiration</code> field.
+         * @param duration   the value for the <code>duration</code> field.
+         */
+        public Result( long expiration, long duration )
+        {
+            this.expiration = expiration;
+            this.duration = duration;
+        }
+    }
+
+    /**
+     * Calculate the initial expiration and duration for
+     * a new lease.
+     *
+     * @param resource          the server side representation of the new lease that
+     *                          needs an initial expiration and duration
+     * @param requestedDuration the initial duration the
+     *                          requester of the resources would like. May be
+     *                          <code>Lease.ANY</code>
+     * @return A <code>Result</code> that holds
+     *         both the expiration and duration.
+     * @throws LeaseDeniedException     if the grant request
+     *                                  is denied.
+     * @throws IllegalArgumentException if the
+     *                                  requested duration is not <code>Lease.ANY</code>
+     *                                  and is negative.
+     */
+    public Result grant( LeasedResource resource, long requestedDuration )
+        throws LeaseDeniedException;
+
+    /**
+     * Calculate the expiration and duration for an
+     * existing lease that is being renewed.
+     *
+     * @param resource          the server side representation of the lease that is
+     *                          being renewed
+     * @param requestedDuration the duration the client is requesting. May be
+     *                          <code>Lease.ANY</code>.
+     * @return A <code>Result</code> that holds
+     *         both the expiration and duration.
+     * @throws LeaseDeniedException     if the renewal request
+     *                                  is denied.
+     * @throws IllegalArgumentException if the
+     *                                  requested duration is not <code>Lease.ANY</code>
+     *                                  and is negative.
+     */
+    public Result renew( LeasedResource resource, long requestedDuration )
+        throws LeaseDeniedException;
+}

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasedResource.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasedResource.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasedResource.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LeasedResource.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import net.jini.id.ReferentUuid;
+import net.jini.id.Uuid;
+
+/**
+ * Server side representation of a lease
+ *
+ * @author Sun Microsystems, Inc.
+ * @see LeasePeriodPolicy
+ * @since 2.0
+ */
+public interface LeasedResource
+{
+    /**
+     * Changes the expiration time of the lease.
+     *
+     * @param newExpiration The new expiration time in milliseconds
+     *                      since the beginning of the epoch
+     */
+    public void setExpiration( long newExpiration );
+
+    /**
+     * Returns the expiration time of the lease.
+     *
+     * @return The expiration time in milliseconds since the beginning
+     *         of the epoch
+     */
+    public long getExpiration();
+
+    /**
+     * Returns the universally unique identifier associated with this
+     * lease. Any proxies for this lease that implement {@link ReferentUuid}
+     * should return this object from their
+     * {@link ReferentUuid#getReferentUuid getReferentUuid}
+     * method and should base their implementation of <code>equals</code> on
+     * this object.
+     */
+    public Uuid getCookie();
+}
+

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LocalLandlord.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LocalLandlord.java?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LocalLandlord.java (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/LocalLandlord.java Tue Dec  9 21:25:00 2008
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.sun.jini.landlord;
+
+import net.jini.core.lease.LeaseDeniedException;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.id.Uuid;
+
+/**
+ * Interface that defines the basic landlord primitives (renew and
+ * cancel) as local methods.  Classes already implementing
+ * <code>Landlord</code> should be able to implement this interface
+ * simply by adding it the the <code>implements</code> clause of their
+ * class declaration.
+ * <p>
+ * Some users may want to implement this interface using an adaptor
+ * class. This could be useful in situations where the landlord's
+ * cancel and renew methods don't do quite the right thing for batch
+ * lease operations
+ * <p>
+ * This interface gives local landlord utilities access to the cancel
+ * and renew methods.
+ *
+ * @author Sun Microsystems, Inc.
+ * @see com.sun.jini.landlord.Landlord
+ * @since 2.0
+ */
+public interface LocalLandlord
+{
+    /**
+     * Renew the lease that is associated with the given cookie.
+     *
+     * @param cookie   an object that universally and uniquely identifies a
+     *                 lease granted by this <code>LocalLandlord</code>
+     * @param duration the duration in milliseconds the client
+     *                 wants the lease renewed for
+     * @return The new duration the lease should have
+     * @throws LeaseDeniedException  if the landlord is unwilling to
+     *                               renew the lease
+     * @throws UnknownLeaseException if landlord does not know about
+     *                               a lease with the specified <code>cookie</code>
+     */
+    public long renew( Uuid cookie, long duration )
+        throws LeaseDeniedException, UnknownLeaseException;
+
+    /**
+     * Cancel the lease that is associated with the given cookie.
+     *
+     * @param cookie an object that universally and uniquely identifies a
+     *               lease granted by this <code>LocalLandlord</code>
+     * @throws UnknownLeaseException if landlord does not know about
+     *                               a lease with the specified <code>cookie</code>
+     */
+    public void cancel( Uuid cookie ) throws UnknownLeaseException;
+}
+ 

Added: incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/package.html
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/package.html?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/package.html (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/landlord/src/main/java/com/sun/jini/landlord/package.html Tue Dec  9 21:25:00 2008
@@ -0,0 +1,58 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership. The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License. You may obtain a copy of the License at
+ ! 
+ !      http://www.apache.org/licenses/LICENSE-2.0
+ ! 
+ ! Unless required by applicable law or agreed to in writing, software
+ ! distributed under the License is distributed on an "AS IS" BASIS,
+ ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ! See the License for the specific language governing permissions and
+ ! limitations under the License.
+ !-->
+
+<HTML>
+<BODY BGCOLOR="white">
+
+<P>
+    This is a utility for services implementing leases. The {@link
+    com.sun.jini.landlord.Landlord} is the basic interface that defines the
+    utility. A service that exports leases implements the
+    <CODE>Landlord</CODE> interface, which is used for callbacks by the utility
+    classes when a lease's status changes. Each leased resource is identified
+    by a landlord-generated {@link net.jini.id.Uuid} called a cookie. The
+    {@link net.jini.core.lease.Lease} object handed to the client contains the
+    cookie, and that cookie is used when communicating with the landlord about
+    the lease.
+
+<P>
+    The utility classes define a lease object type {@link
+    com.sun.jini.landlord.LandlordLease}. The <CODE>Lease</CODE> objects
+    handed to clients will be of this type. <CODE>LandlordLease</CODE> objects
+    talk to the <CODE>Landlord</CODE> about the lease. A factory class, {@link
+    com.sun.jini.landlord.LeaseFactory}, can be used to generate new
+    leases. The package also contains a constrainable implementation of
+    <code>Lease</code>, {@link
+    com.sun.jini.landlord.ConstrainableLandlordLease}, that implements
+    {@link net.jini.core.constraint.RemoteMethodControl} and supports proxy
+    trust verification (when used with {@link
+    com.sun.jini.landlord.LandlordProxyVerifier}) and suitable implementations
+    of {@link net.jini.core.lease.LeaseMap}. It also contains utilities and
+    interfaces to assist you in implementing the <code>Landlord</code>
+    interfaces: {@link com.sun.jini.landlord.LandlordUtil}, {@link
+    com.sun.jini.landlord.LeasePeriodPolicy}, and {@link
+    com.sun.jini.landlord.FixedLeasePeriodPolicy}.
+
+<P>
+    Using the classes in this package, you can write services that export
+    leases and handle primarily those factors that are unique to your service,
+    letting the utility classes do generic lease-related work.
+
+</BODY>
+</HTML>
+

Added: incubator/river/jtsk/skunk/niclas1/shared/logging/pom.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/shared/logging/pom.xml?rev=724995&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/shared/logging/pom.xml (added)
+++ incubator/river/jtsk/skunk/niclas1/shared/logging/pom.xml Tue Dec  9 21:25:00 2008
@@ -0,0 +1,16 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.river.service</groupId>
+        <artifactId>master-services</artifactId>
+        <version>10.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.river.shared</groupId>
+    <artifactId>river-logging</artifactId>
+    <name>Apache River - Shared - Logging</name>
+    <packaging>jar</packaging>
+    <version>10.0-SNAPSHOT</version>
+
+</project>



Mime
View raw message