
package ibis.ipl;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * This class describes the capabilities of an ibis instance.
 * Combined with a list of {@link PortType} it is
 * used to select a particular Ibis implementation.
 * See the {@link IbisFactory#createIbis(IbisCapabilities, Properties, boolean,
 * RegistryEventHandler, PortType...) createIbis} method from
 * {@link IbisFactory}.       
 */
public final class IbisCapabilities extends CapabilitySet {

    /**
     * Capability, set when the Ibises that can join the pool are
     * determined at the start of the run. This enables the methods
     * {@link Registry#getPoolSize()} and {@link Registry#waitUntilPoolClosed()}.
     */
    public final static String CLOSEDWORLD = "closedWorld";
    
    /** Capability, indicating that signals are supported. */
    public final static String SIGNALS = "signals";

    /**
     * Capability, indicating that elections are supported
     * but don't have to be reliable, always give the same result, etc.
     */
    public final static String ELECTIONS_UNRELIABLE = "elections.unreliable";

    /**
     * Capability, indicating that elections are supported, reliable,
     * and give consistent results.
     */
    public final static String ELECTIONS_STRICT = "elections.strict";
    
    /**
     * Capability indicating that joins/leaves don't have to be reliable,
     * in order, etc.
     */
    public final static String MEMBERSHIP_UNRELIABLE
            = "membership.unreliable";
    
    /**
     * Capability indicating that joins/leaves are totally ordered.
     * This means that all Ibis instances receive the joins/leaves upcalls
     * in the same order.
     */
    public final static String MEMBERSHIP_TOTALLY_ORDERED
            = "membership.totally.ordered";
    
    /** Capability indicating an Ibis that can deal with malleability. */
    public final static String MALLEABLE = "malleable";
    
    /** 
     * Constructor for an IbisCapabilities object.
     * @param capabilities
     *          the capabilities.
     */
    public IbisCapabilities(String... capabilities) {
        super(capabilities);
    }
    
    /**
     * Constructs an IbisCapabilities object from the specified properties.
     * @param properties
     *          the properties.
     */
    protected IbisCapabilities(Properties properties) {
        super(properties);
    }

    /**
     * Constructs an IbisCapabilities from the specified capabilityset.
     * @param capabilitySet
     *          the capabilityset.
     */
    protected IbisCapabilities(CapabilitySet capabilitySet) {
         super(capabilitySet);
    }
    
    /**
     * Reads and returns the capabilities from the specified file name, which is
     * searched for in the classpath.
     * @param capabilityFileName
     *          the file name.
     * @exception IOException
     *          is thrown when an IO error occurs.
     */
    public static IbisCapabilities load(String capabilityFileName)
            throws IOException {
        InputStream input = ClassLoader.getSystemClassLoader()
                .getResourceAsStream(capabilityFileName);
        if (input == null) {
            throw new IOException("Could not open " + capabilityFileName);
        }
        return load(input);
    }

    /**
     * Reads and returns the capabilities from the specified input stream.
     * @param input
     *          the input stream.
     * @exception IOException
     *          is thrown when an IO error occurs.
     */
    public static IbisCapabilities load(InputStream input) throws IOException {
        Properties properties = new Properties();
        properties.load(input);
        input.close();
        return new IbisCapabilities(properties);
    }
}

@@ -688,16 +688,23 @@
 e()%7D and
+%0A     *
  %7B@link 
@@ -736,16 +736,323 @@
 sed()%7D.%0A
+     * When this capability is requested, the Ibis property %0A     * %3Ccode%3Eibis.pool.size%3C/code%3E must be set to the number of Ibis instances%0A     * that can join the run. When %3Ccode%3Eibis.pool.size%3C/code%3E instances have%0A     * joined, the pool is closed: no more instances are allowed to join the%0A     * run.%0A
      */%0A
@@ -1115,32 +1115,39 @@
 d%22;%0A    %0A    /**
+%0A     *
  Capability, ind
@@ -1180,17 +1180,143 @@
 upported
-.
+,%0A     * see %7B@link RegistryEventHandler#gotSignal(String)%7D and%0A     * %7B@link Registry#signal(String, IbisIdentifier...)%7D.%0A    
  */%0A    
@@ -1816,35 +1816,61 @@
 lity indicating 
-tha
+membership administration, bu
 t joins/leaves d
@@ -1869,24 +1869,31 @@
 leaves don't
+%0A     *
  have to be 
@@ -1901,23 +1901,16 @@
 eliable,
-%0A     *
  in orde
@@ -2059,20 +2059,46 @@
 icating 
-that
+membership administration, and
  joins/l
@@ -2106,16 +2106,23 @@
 aves are
+%0A     *
  totally
@@ -2354,16 +2354,23 @@
 %0A    /**
+%0A     *
  Capabil
@@ -2424,16 +2424,107 @@
 ability.
+%0A     * This means that Ibis instances can join and/or leave a run at any%0A     * time.%0A    
  */%0A    

Clarified some javadocs