FELIX-2647 : Implement Coordinator Service - update to official 4.3 version

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1550595 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/coordinator/pom.xml b/coordinator/pom.xml
index 6ee2f58..2fcf1fb 100644
--- a/coordinator/pom.xml
+++ b/coordinator/pom.xml
@@ -32,7 +32,6 @@
     <name>Apache Felix Coordinator Service</name>
     <description>
         Implementation of the OSGi Coordinator Service Specification 1.0
-        (Based on OSGi R 4.3 Draft 2 (31 Aug. 2010))
     </description>
     <version>0.0.1-SNAPSHOT</version>
 
@@ -100,17 +99,17 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.2.0</version>
+            <version>4.3.0</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
-            <version>4.2.0</version>
+            <version>4.3.0</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.enterprise</artifactId>
-            <version>4.2.0</version>
+            <version>5.0.0</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/coordinator/src/main/java/org/apache/felix/coordinator/impl/Activator.java b/coordinator/src/main/java/org/apache/felix/coordinator/impl/Activator.java
index 0efb92d..f6ea23c 100644
--- a/coordinator/src/main/java/org/apache/felix/coordinator/impl/Activator.java
+++ b/coordinator/src/main/java/org/apache/felix/coordinator/impl/Activator.java
@@ -25,7 +25,6 @@
 import javax.management.ObjectName;
 
 import org.apache.felix.jmx.service.coordinator.CoordinatorMBean;
-import org.apache.felix.service.coordinator.Coordinator;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -33,6 +32,7 @@
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.coordinator.Coordinator;
 import org.osgi.util.tracker.ServiceTracker;
 
 @SuppressWarnings("deprecation")
diff --git a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
index ac222e7..92aedfa 100644
--- a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
+++ b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
@@ -19,17 +19,17 @@
 package org.apache.felix.coordinator.impl;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.TimerTask;
 
-import org.apache.felix.service.coordinator.Coordination;
-import org.apache.felix.service.coordinator.CoordinationException;
-import org.apache.felix.service.coordinator.Participant;
+import org.osgi.framework.Bundle;
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
+import org.osgi.service.coordinator.Participant;
 
-@SuppressWarnings("deprecation")
 public class CoordinationImpl implements Coordination
 {
 
@@ -69,7 +69,7 @@
 
     private Thread initiatorThread;
 
-    public CoordinationImpl(final CoordinatorImpl owner, final long id, final String name, final int timeOutInMs)
+    public CoordinationImpl(final CoordinatorImpl owner, final long id, final String name, final long timeOutInMs)
     {
         // TODO: validate name against Bundle Symbolic Name pattern
 
@@ -172,7 +172,7 @@
     }
 
 
-    public Collection<Participant> getParticipants()
+    public List<Participant> getParticipants()
     {
         // synchronize access to the state to prevent it from being changed
         // while we create a copy of the participant list
@@ -233,7 +233,7 @@
         }
     }
 
-    public Map<Class<?>, ?> getVariables()
+    public Map<Class<?>, Object> getVariables()
     {
         return variables;
     }
@@ -367,4 +367,14 @@
             owner.schedule(timeoutTask, deadLine);
         }
     }
+
+    public Bundle getBundle() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Coordination getEnclosingCoordination() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }
diff --git a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
index 7faa675..7de4ad5 100644
--- a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
+++ b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
@@ -37,9 +37,9 @@
 import javax.management.openmbean.TabularDataSupport;
 
 import org.apache.felix.jmx.service.coordinator.CoordinatorMBean;
-import org.apache.felix.service.coordinator.Coordination;
-import org.apache.felix.service.coordinator.CoordinationException;
-import org.apache.felix.service.coordinator.Participant;
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
+import org.osgi.service.coordinator.Participant;
 
 /**
  * The <code>CoordinationMgr</code> is the actual backend manager of all
@@ -53,7 +53,6 @@
  * <li>Management support to timeout and cleanup coordinations</li>
  * </ul>
  */
-@SuppressWarnings("deprecation")
 public class CoordinationMgr implements CoordinatorMBean
 {
 
@@ -185,7 +184,7 @@
 
     // ---------- Coordinator back end implementation
 
-    Coordination create(final CoordinatorImpl owner, final String name, final int timeout)
+    Coordination create(final CoordinatorImpl owner, final String name, final long timeout)
     {
         long id = ctr.incrementAndGet();
         CoordinationImpl c = new CoordinationImpl(owner, id, name, timeout);
diff --git a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
index 9fd74c3..fa1cfea 100644
--- a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
+++ b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
@@ -22,14 +22,13 @@
 import java.util.HashSet;
 import java.util.TimerTask;
 
-import org.apache.felix.service.coordinator.Coordination;
-import org.apache.felix.service.coordinator.CoordinationException;
-import org.apache.felix.service.coordinator.Coordinator;
-import org.apache.felix.service.coordinator.Participant;
 import org.osgi.framework.Bundle;
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
+import org.osgi.service.coordinator.Participant;
 
 @SuppressWarnings("deprecation")
-public class CoordinatorImpl implements Coordinator
+public class CoordinatorImpl implements org.osgi.service.coordinator.Coordinator
 {
 
     private final Bundle owner;
@@ -80,7 +79,7 @@
         }
     }
 
-    public Coordination create(final String name, final int timeout)
+    public Coordination create(final String name, final long timeout)
     {
         // TODO: check permission
         Coordination c = mgr.create(this, name, timeout);
@@ -114,7 +113,7 @@
         return mgr.peek();
     }
 
-    public Coordination begin(final String name, final int timeoutInMillis)
+    public Coordination begin(final String name, final long timeoutInMillis)
     {
         // TODO: check permission
         return push(create(name, timeoutInMillis));
diff --git a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CrdCommand.java b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CrdCommand.java
index d5687a6..65e6e19 100644
--- a/coordinator/src/main/java/org/apache/felix/coordinator/impl/CrdCommand.java
+++ b/coordinator/src/main/java/org/apache/felix/coordinator/impl/CrdCommand.java
@@ -21,12 +21,12 @@
 import java.util.Collection;
 import java.util.Hashtable;
 
-import org.apache.felix.service.coordinator.Coordination;
-import org.apache.felix.service.coordinator.Participant;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.Participant;
 
 /**
  * The <code>CrdCommand</code> class implements the required Command Line
@@ -50,14 +50,14 @@
      *
      *    crd list [ -f, --full ] [ <regex filter on name> ]
      *    crd fail [ -r, --reason <reason> ] [-b,--bundle <bundle>] <coordination> ...
-     *    crd participants <coordination> …
-     *    crd details <coordination> …
+     *    crd participants <coordination> ���
+     *    crd details <coordination> ���
      *
      * A Coordinator must provide a converter to a Coordination based on the
      * following inputs:
-     *    id – the Coordination id
-     *    name – the Coordination name. Must be unique
-     *    bundle – Must translate to all coordinations of a specific bundle
+     *    id ��� the Coordination id
+     *    name ��� the Coordination name. Must be unique
+     *    bundle ��� Must translate to all coordinations of a specific bundle
      */
 
     static ServiceRegistration create(final BundleContext context, final CoordinationMgr mgr)
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordination.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordination.java
deleted file mode 100644
index 0857feb..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordination.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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 org.apache.felix.service.coordinator;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * A Coordination object is used to coordinate a number of independent
- * participants. Once a Coordination is created, it can be used to add
- * Participant objects. When the Coordination is ended, the participants are
- * called back. A Coordination can also fail for various reasons, in that case
- * the participants are informed of this failure.
- *
- * @ThreadSafe
- * @Provisional
- */
-@Deprecated
-public interface Coordination
-{
-
-    /**
-     * The TIMEOUT exception is a singleton exception that will the reason for
-     * the failure when the Coordination times out.
-     */
-    public static final Exception TIMEOUT = new Exception();
-
-    /**
-     * A system assigned ID unique for a specific registered Coordinator. This
-     * id must not be reused as long as the Coordinator is registered and must
-     * be monotonically increasing for each Coordination and always be positive.
-     *
-     * @return an id
-     */
-    long getId();
-
-    /**
-     * Return the name of this Coordination. The name is given in the
-     * {@link Coordinator#begin(String, int)} or
-     * {@link Coordinator#create(String, int)} method. The name should follow
-     * the same naming pattern as a Bundle Symbolc Name.
-     *
-     * @return the name of this Coordination
-     */
-    String getName();
-
-    /**
-     * Fail this Coordination. If this Coordination is not terminated, fail it
-     * and call the {@link Participant#failed(Coordination)} method on all
-     * participant on the current thread. Participants must assume that the
-     * Coordination failed and should discard and cleanup any work that was
-     * processed during this Coordination. The {@link #fail(Throwable)} method
-     * will return <code>true</code> if it caused the termination. A fail method
-     * must return silently when the Coordination has already finished and
-     * return <code>false</code>. The fail method must terminate the current
-     * Coordination before any of the failed methods are called. That is, the
-     * {@link Participant#failed(Coordination)} methods must be running outside
-     * the current coordination, adding participants during this phase will
-     * cause a Configuration Exception to be thrown. If the Coordination is
-     * pushed on the Coordinator stack it is associated with a specific thread.
-     *
-     * @param reason The reason of the failure, must not be <code>null</code>
-     * @return true if the Coordination was active and this coordination was
-     *         terminated due to this call, otherwise false
-     */
-    boolean fail(Throwable reason);
-
-    /**
-     * End the current Coordination.
-     *
-     * <pre>
-     * void foo() throws CoordinationException
-     * {
-     *     Coordination c = coordinator.begin(&quot;work&quot;, 0);
-     *     try
-     *     {
-     *         doWork();
-     *     }
-     *     catch (Exception e)
-     *     {
-     *         c.fail(e);
-     *     }
-     *     finally
-     *     {
-     *         c.end();
-     *     }
-     * }
-     * </pre>
-     *
-     * If the coordination was terminated this method throws a Configuration
-     * Exception. Otherwise, any participants will be called on their
-     * {@link Participant#ended(Coordination)} method. A successful return of
-     * this {@link #end()} method indicates that the Coordination has properly
-     * terminated and any participants have been informed of the positive
-     * outcome. It is possible that one of the participants throws an exception
-     * during the callback. If this happens, the coordination fails partially
-     * and this is reported with an exception. This method must terminate the
-     * current Coordination before any of the
-     * {@link Participant#ended(Coordination)} methods are called. That is, the
-     * {@link Participant#ended(Coordination)} methods must be running outside
-     * the current coordination, no participants can be added during the
-     * termination phase. If the Coordination is on a thread local stack then it
-     * must be removed from this stack during termination.
-     *
-     * @throws CoordinationException when the Coordination has (partially)
-     *             failed or timed out.
-     *             <ol>
-     *             <li>{@link CoordinationException#PARTIALLY_ENDED}</li>
-     *             <li>{@link CoordinationException#ALREADY_ENDED}</li>
-     *             <li>{@link CoordinationException#FAILED}</li>
-     *             <li>{@link CoordinationException#UNKNOWN}</li>
-     *             </ol>
-     */
-    void end() throws CoordinationException;
-
-    /**
-     * Return a mutable snapshot of the participants that joined the
-     * Coordination. Each unique Participant object as defined by its identity
-     * occurs only once in this list.
-     *
-     * @return list of participants.
-     * @throws SecurityException This method requires the
-     *             {@link CoordinationPermission#ADMIN} action for the
-     *             {@link CoordinationPermission}.
-     */
-    Collection<Participant> getParticipants();
-
-    /**
-     * If the coordination has failed because {@link #fail(Throwable)} was
-     * called then this method can provide the Throwable that was given as
-     * argument to the {@link #fail(Throwable)} method. A timeout on this
-     * Coordination will set the failure to a TimeoutException.
-     *
-     * @return a Throwable if this Coordination has failed, otherwise
-     *         <code>null</code> if no failure occurred.
-     */
-    Throwable getFailure();
-
-    /**
-     * Add a Participant to this Coordination. Once a Participant is
-     * participating it is guaranteed to receive a call back on either the
-     * {@link Participant#ended(Coordination)} or
-     * {@link Participant#failed(Coordination)} method when the Coordination is
-     * terminated. A participant can be added to the Coordination multiple times
-     * but it must only be called back once when the Coordination is terminated.
-     * A Participant can only participate at a single Coordination, if it
-     * attempts to block at another Coordination, then it will block until prior
-     * Coordinations are finished. Notice that in edge cases the call back can
-     * happen before this method returns. The ordering of the call-backs must
-     * follow the order of participation. If participant is participating
-     * multiple times the first time it participates defines this order.
-     * *@param participant The participant of the Coordination
-     *
-     * @throws CoordinationException This exception should normally not be
-     *             caught by the caller but allowed to bubble up to the
-     *             initiator of the coordination, it is therefore a
-     *             <code>RuntimeException</code>. It signals that this
-     *             participant could not
-     *             participate the current coordination. This can be cause by
-     *             the following reasons:
-     *             <ol>
-     *             <li>{@link CoordinationException#DEADLOCK_DETECTED}</li>
-     *             <li>{@link CoordinationException#ALREADY_ENDED}</li>
-     *             <li>{@link CoordinationException#LOCK_INTERRUPTED}</li>
-     *             <li>{@link CoordinationException#FAILED}</li>
-     *             <li>{@link CoordinationException#UNKNOWN}</li>
-     *             </ol>
-     * @throws SecurityException This method requires the
-     *             {@link CoordinationPermission#PARTICIPATE} action for the
-     *             current Coordination, if any.
-     */
-    void addParticipant(Participant participant);
-
-    /**
-     * A utility map associated with the current Coordination. Each coordination
-     * carries a map that can be used for communicating between different
-     * participants. To namespace of the map is a class, allowing for private
-     * date to be stored in the map by using implementation classes or shared
-     * data by interfaces. The returned map is does not have to not
-     * synchronized. Users of this map must synchronize on the Map object while
-     * making changes.
-     *
-     * @return The map
-     */
-    Map<Class<?>, ?> getVariables();
-
-    /**
-     * Extend the time out. Allows participants to extend the timeout of the
-     * coordination with at least the given amount. This can be done by
-     * participants when they know a task will take more than normal time. This
-     * method returns the new deadline. Passing 0 will return the existing
-     * deadline.
-     *
-     * @param timeInMillis Add this timeout to the current timeout. If the
-     *            current timeout was set to 0, no extension must take place. A
-     *            zero or negative value must have no effect.
-     * @return the new deadline in the format of
-     *         <code>System.currentTimeMillis()</code> or 0 if no timeout was
-     *         set.
-     * @throws CoordinationException Can throw
-     *             <ol>
-     *             <li>{@link CoordinationException#ALREADY_ENDED}</li>
-     *             <li>{@link CoordinationException#FAILED}</li>
-     *             <li>{@link CoordinationException#UNKNOWN}</li>
-     *             </ol>
-     */
-    long extendTimeout(long timeInMs) throws CoordinationException;
-
-    /**
-     * @return true if this Coordination has terminated otherwise false.
-     */
-    boolean isTerminated();
-
-    /**
-     * Answer the associated thread or null.
-     *
-     * @return Associated thread or null
-     */
-    Thread getThread();
-
-    /**
-     * Wait until the Coordination is terminated and all Participant objects
-     * have been called.
-     *
-     * @param timeoutInMillis Maximum time to wait, 0 is forever
-     * @throws InterruptedException If the wait is interrupted
-     */
-    void join(long timeoutInMillis) throws InterruptedException;
-
-    /**
-     * Associate the given Coordination object with a thread local stack of its
-     * Coordinator. The top of the thread local stack is returned with the
-     * {@link Coordinator#peek()} method. To remove the Coordination from the
-     * top call {@link Coordinator#pop()}.
-     *
-     * @return this (for the builder pattern purpose)
-     * @throws CoordinationException Can throw the
-     *             <ol>
-     *             <li>{@link CoordinationException#ALREADY_PUSHED}</li>
-     *             <li>{@link CoordinationException#UNKNOWN}</li>
-     *             </ol>
-     */
-    Coordination push() throws CoordinationException;
-}
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationException.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationException.java
deleted file mode 100644
index 663ace4..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationException.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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 org.apache.felix.service.coordinator;
-
-/**
- * Thrown when an implementation detects a potential deadlock situation that it
- * cannot solve. The name of the current coordination is given as argument.
- *
- * @Provisional
- */
-@Deprecated
-public class CoordinationException extends RuntimeException
-{
-
-    private static final long serialVersionUID = -4466063711012717361L;
-
-    /**
-     * Unknown reason fot this exception.
-     */
-    public static final int UNKNOWN = 0;
-
-    /**
-     * Adding a participant caused a deadlock.
-     */
-    public static final int DEADLOCK_DETECTED = 1;
-
-    /**
-     * The Coordination was failed with {@link Coordination#fail(Throwable)}.
-     * When this exception type is used, the {@link Coordination#getFailure()}
-     * method must return a non-null value.
-     */
-    public static final int FAILED = 3;
-
-    /**
-     * The Coordination was partially ended.
-     */
-    public static final int PARTIALLY_ENDED = 4;
-
-    /**
-     * The Coordination was already ended.
-     */
-    public static final int ALREADY_ENDED = 5;
-
-    /**
-     * A Coordination was pushed on the stack that was already pushed.
-     */
-    public static final int ALREADY_PUSHED = 6;
-
-    /**
-     * Interrupted while trying to lock the participant.
-     */
-    public static final int LOCK_INTERRUPTED = 7;
-
-    /**
-     * The Coordination timed out.
-     */
-    public static final int TIMEOUT = 9;
-
-    private final Coordination coordination;
-
-    private final int type;
-
-    /**
-     * Create a new Coordination Exception.
-     *
-     * @param message The message
-     * @param coordination The coordination that failed
-     * @param type The reason for the exception
-     * @param exception The exception
-     */
-    public CoordinationException(String message, Coordination coordination, int type, Throwable exception)
-    {
-        super(message, exception);
-        this.coordination = coordination;
-        this.type = type;
-    }
-
-    /**
-     * Create a new Coordination Exception.
-     *
-     * @param message The message
-     * @param coordination The coordination that failed
-     * @param type The reason for the exception
-     */
-    public CoordinationException(String message, Coordination coordination, int type)
-    {
-        super(message);
-        this.coordination = coordination;
-        this.type = type;
-    }
-
-    /**
-     * Answer the name of the Coordination associated with this exception.
-     *
-     * @return the Coordination name
-     */
-    public String getName()
-    {
-        return coordination.getName();
-    }
-
-    /**
-     * Answer the reason.
-     *
-     * @return the reason
-     */
-    public int getType()
-    {
-        return type;
-    }
-
-    /**
-     * Must be set if to the exception type is {@link #FAILED}
-     *
-     * @return If exception is {@link #FAILED} a Throwable
-     */
-    public Throwable getFailure()
-    {
-        return getCause();
-    }
-
-    /**
-     * @return Answer the id
-     */
-    public long getId()
-    {
-        return coordination.getId();
-    }
-}
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationPermission.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationPermission.java
deleted file mode 100644
index a65966d..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/CoordinationPermission.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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 org.apache.felix.service.coordinator;
-
-import java.security.BasicPermission;
-
-/**
- * The name parameter of the Permission is a filter expression. It asserts the
- * bundle that is associated with the coordination. Additionally, the following
- * attributes can be asserted:
- * <ol>
- * <li>coordination.name - The name of the coordination
- * <table>
- * <tr>
- * <td>Coordinator</td>
- * <td>INITIATE</td>
- * <td>PARTICIPATE</td>
- * <td>ADMIN</td>
- * <td>NONE</td>
- * </tr>
- * <tr>
- * <td>alwaysFail(String)</td>
- * <td></td>
- * <td></td>
- * <td>-</td>
- * </tr>
- * <tr>
- * <td>begin(String) + -</td>
- * </tr>
- * <tr>
- * <td>getCoordinations() + -</td>
- * </tr>
- * <tr>
- * <td>isActive() + + + -</td>
- * </tr>
- * <tr>
- * <td>isFailed() + + + -</td>
- * </tr>
- * <tr>
- * <td>participate(Participant) + -</td>
- * </tr>
- * <tr>
- * <td>participateOrBegin(Participant) + and + -</td>
- * </tr>
- * <tr>
- * <td>Coordination</td>
- * </tr>
- * <tr>
- * <td>end() +</td>
- * </tr>
- * <tr>
- * <td>fail(String) +</td>
- * </tr>
- * <tr>
- * <td>getName() +</td>
- * </tr>
- * <tr>
- * <td>getParticipants() + -</td>
- * </tr>
- * <tr>
- * <td>isFailed() +</td>
- * </tr>
- * <tr>
- * <td>setTimeout(long) + + -</td>
- * </tr>
- * <tr>
- * <td>terminate() +</td>
- * </tr>
- * </table>
- * </li>
- * </ol>
- *
- * @Provisional
- */
-@Deprecated
-public class CoordinationPermission extends BasicPermission
-{
-
-    private static final long serialVersionUID = 1566605398519619478L;
-
-    /**
-     * Initiate a Coordination. An owner of this permission can initiate, end,
-     * fail, and terminate a Coordination.
-     */
-    public static final String INITIATE = "initiate";
-
-    /**
-     * The action string admin.
-     */
-    public static final String ADMIN = "admin";
-
-    /**
-     * The action string participate.
-     */
-    public static final String PARTICIPATE = "participate";
-
-    /**
-     * The name parameter specifies a filter condition. The filter asserts the
-     * bundle that initiated the Coordination. An implicit grant is made for a
-     * bundle's own coordinations.
-     *
-     * @param filterExpression A filter expression asserting the bundle
-     *            associated with the coordination.
-     * @param actions A comma separated combination of {@link #INITIATE},
-     *            {@link #ADMIN}, {@link #PARTICIPATE}.
-     */
-    public CoordinationPermission(String filterExpression, String actions)
-    {
-        super(filterExpression, actions);
-    }
-
-    /**
-     * The verification permission
-     *
-     * @param bundle The bundle that will be the target of the filter
-     *            expression.
-     * @param coordinationName The name of the coordination or <code>null</code>
-     * @param actions The set of actions required, which is a combination of
-     *            {@link #INITIATE}, {@link #ADMIN}, {@link #PARTICIPATE}.
-     */
-    public CoordinationPermission(org.osgi.framework.Bundle bundle, String coordinationName, String actions)
-    {
-        super(coordinationName, actions);
-    }
-}
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordinator.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordinator.java
deleted file mode 100644
index d91b2dd..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/Coordinator.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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 org.apache.felix.service.coordinator;
-
-import java.util.Collection;
-
-/**
-A Coordinator service coordinates activities between different parties. The Coordinator can create Coordination
-objects. Once a Coordination object is created, it can be pushed on a thread local stack {@link Coordination#push()} as
-an implicit parameter for calls to other parties, or it can be passed as an argument. The current top of the thread
-local stack can be obtained with #peek(). The addParticipant(Participant) method on this service or the
-Coordination.addParticipant(Participant) method can be used to participate in a Coordination. Participants
-participate only in a single Coordination, if a Participant object is added to a second Coordination the
-Coordination.addParticipant(Participant) method is blocked until the first Coordination is terminated. A
-Coordination ends correctly when the Coordination.end() method is called before termination or when the
-Coordination fails due to a timeout or a failure. If the Coordination ends correctly, all its participants are called on
-the Participant.ended(Coordination) method, in all other cases the Participant.failed(Coordination) is
-called. The typical usage of the Coordinator service is as follows:
-<pre>
-Coordination coordination = coordinator.begin("mycoordination",0);
-try {
-doWork();
-}
-finally {
-coordination.end();
-}
-</pre>
-In the doWork() method, code can be called that requires a callback at the end of the Coordination. The doWork
-method can then add a Participant to the coordination. This code is for a Participant.
-<pre>
-void doWork() {
-if (coordinator.addParticipant(this)) {
-beginWork();
-}
-else {
-beginWork();
-finishWork();
-}
-}
-void ended() {
-finishWork();
-}
-void failed() {
-undoWork();
-}
-</pre>
-Life cycle. All Coordinations that are begun through this service must automatically fail before this service is
-ungotten.
- *
- * @ThreadSafe
- * @Provisional
- */
-@Deprecated
-public interface Coordinator
-{
-
-    /**
-     * Create a new Coordination that is not associated with the current thread.
-     * Parameters:
-     *
-     * @param name The name of this coordination, a name does not have to be
-     *            unique.
-     * @param timeout Timeout in milliseconds, less or equal than 0 means no
-     *            timeout
-     * @return The new Coordination object, never <code>null</code>
-     * @throws SecurityException This method requires the
-     *             {@link CoordinationPermission#INITIATE} action, no bundle
-     *             check is done.
-     * @throws IllegalArgumentException when the name does not match the Bundle
-     *             Symbolic Name pattern
-     */
-    Coordination create(String name, int timeout);
-
-    /**
-     * Provide a mutable snapshot collection of all Coordination objects
-     * currently not terminated. Coordinations in
-     * this list can have terminated before this list is returned or any time
-     * thereafter. The returned collection must
-     * only contain the Coordinations for which the caller has
-     * {@link CoordinationPermission#ADMIN}, without this
-     * permission an empty list must be returned.
-     *
-     * @return a list of Coordination objects filtered by
-     *         {@link CoordinationPermission#ADMIN}
-     */
-    Collection<Coordination> getCoordinations();
-
-    /**
-     * Always fail the current Coordination, if it exists. If this is no current
-     * Coordination return <code>false</code>. Otherwise return the result of
-     * {@link Coordination#fail(Throwable)}, which is <code>true</code> in the
-     * case this call terminates the Coordination and <code>false</code>
-     * otherwise.
-     *
-     * <pre>
-     * false - No current Coordination
-     * false - Current Coordination was already terminated
-     * true - Current Coordination got terminated due to this call
-     * </pre>
-     *
-     * @param reason The reason for failure, must not be <code>null</code>.
-     * @return <code>true</code> if there was a current Coordination and it was
-     *         terminated, otherwise <code>false</code>.
-     */
-    boolean fail(Throwable reason);
-
-    /**
-     * Return the current Coordination or <code>null</code>. The current
-     * Coordination is the top of the thread local stack of Coordinations. If
-     * the stack is empty, there is no current Coordination.
-     *
-     * @return <code>null</code> when the thread local stack is empty, otherwise
-     *         the top of the thread local stack of
-     *         Coordinations.
-     */
-    Coordination peek();
-
-    /**
-     * Begin a new Coordination and push it on the thread local stack with
-     * {@link Coordination#push()}.
-     *
-     * @param name The name of this coordination, a name does not have to be
-     *            unique.
-     * @param timeoutInMillis Timeout in milliseconds, less or equal than 0
-     *            means no timeout
-     * @return A new Coordination object
-     * @throws SecurityException This method requires the
-     *             {@link CoordinationPermission#INITIATE} action, no bundle
-     *             check is done.
-     * @throws IllegalArgumentException when the name does not match the Bundle
-     *             Symbolic Name pattern
-     */
-    Coordination begin(String name, int timeoutInMillis);
-
-    /**
-     * Pop the top of the thread local stack of Coordinations. If no current
-     * Coordination is present, return <code>null</code>.
-     *
-     * @return The top of the stack or <code>null</code>
-     */
-    Coordination pop();
-
-    /**
-     * Participate in the current Coordination and return <code>true</code> or
-     * return <code>false</code> if there is none. This method calls
-     * {@link #peek()}, if it is <code>null</code>, it will return
-     * <code>false</code>. Otherwise it will call
-     * {@link Coordination#addParticipant(Participant)}.
-     *
-     * @param participant The participant of the Coordination
-     * @return <code>true</code> if there was a current Coordination that could
-     *         be successfully used to participate, otherwise <code>false</code>
-     *         .
-     * @throws CoordinationException This exception should normally not be
-     *             caught by the caller but allowed to bubble up to the
-     *             initiator of the coordination, it is therefore a
-     *             <code>RuntimeException</code>. It signals that this
-     *             participant could not participate the current coordination.
-     *             This can be cause by the following reasons:
-     *             <ol>
-     *             <li>{@link CoordinationException#DEADLOCK_DETECTED}</li>
-     *             <li>{@link CoordinationException#ALREADY_ENDED}</li>
-     *             <li>{@link CoordinationException#TIMEOUT}</li>
-     *             <li>{@link CoordinationException#UNKNOWN}</li>
-     *             </ol>
-     * @throws SecurityException This method requires the
-     *             {@link CoordinationPermission#PARTICIPATE} action for the
-     *             current
-     *             Coordination, if any.
-     */
-    boolean addParticipant(Participant participant) throws CoordinationException;
-
-    /**
-     * Answer the coordination associated with the given id if it exists.
-     *
-     * @param id The id of the requested Coordination
-     * @return a Coordination with the given ID or <code>null</code> when
-     *         Coordination cannot be found because it never existed or had
-     *         terminated before this call.
-     * @throws SecurityException if the caller has no
-     *             {@link CoordinationPermission#ADMIN} for the requested
-     *             Coordination.
-     */
-    Coordination getCoordination(long id);
-}
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/Participant.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/Participant.java
deleted file mode 100644
index f83138c..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/Participant.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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 org.apache.felix.service.coordinator;
-
-/**
- * A Participant participates in a Coordination. A Participant can participate
- * in a Coordination by calling {@link Coordinator#addParticipant(Participant)}.
- * After successfully initiating the participation, the Participant is called
- * back when the Coordination is terminated. If a Coordination ends with the
- * {@link Coordination#end()} method, then all the participants are called back
- * on their {@link #ended(Coordination)} method. If the Coordination is failed
- * (someone has called {@link Coordination#fail(Throwable)} then the
- * {@link #failed(Coordination)} method is called back. Participants are
- * required to be thread safe for the {@link #ended(Coordination)} method and
- * the {@link #failed(Coordination)} method. Both methods can be called on
- * another thread.
- *
- * @ThreadSafe
- * @Provisional
- */
-@Deprecated
-public interface Participant
-{
-
-    /**
-     * The Coordination has failed and the participant is informed. A
-     * participant should properly discard any work it has done during the
-     * active coordination.
-     *
-     * @param c The Coordination that does the callback
-     * @throws Exception Any exception thrown should be logged but is further
-     *             ignored and does not influence the outcome of the
-     *             Coordination.
-     */
-    void failed(Coordination c) throws Exception;
-
-    /**
-     * The Coordination is being ended.
-     *
-     * @param c The Coordination that does the callback
-     * @throws Exception If an exception is thrown it should be logged and the
-     *             return of the {@link Coordination#end()} method must throw
-     *             {@link CoordinationException#PARTIALLY_ENDED}.
-     */
-    void ended(Coordination c) throws Exception;
-}
diff --git a/coordinator/src/main/java/org/apache/felix/service/coordinator/package-info.java b/coordinator/src/main/java/org/apache/felix/service/coordinator/package-info.java
deleted file mode 100644
index a7c33ec..0000000
--- a/coordinator/src/main/java/org/apache/felix/service/coordinator/package-info.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
- *
- * Licensed 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.
- */
-/**
- * Coordinator Package Version 1.0.
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest.
- * <p>
- * This package has two types of users: the consumers that use the API in this
- * package and the providers that implement the API in this package.
- * <p>
- * Example import for consumers using the API in this package: <blockquote>
- * <code>Import-Package: org.apache.felix.service.coordinator; version="[1.0,2.0)"; status="provisional"</code>
- * </blockquote>
- * <p>
- * Example import for providers implementing the API in this package:
- * <blockquote>
- * <code>Import-Package: org.apache.felix.service.coordinator; version="[1.0,1.1)"; status="provisional"</code>
- * </blockquote>
- *
- * @Provisional
- */
-@Deprecated
-package org.apache.felix.service.coordinator;
\ No newline at end of file
diff --git a/coordinator/src/test/java/org/apache/felix/coordinator/impl/CoordinatorImplTest.java b/coordinator/src/test/java/org/apache/felix/coordinator/impl/CoordinatorImplTest.java
index 5b0e321..1aea579 100644
--- a/coordinator/src/test/java/org/apache/felix/coordinator/impl/CoordinatorImplTest.java
+++ b/coordinator/src/test/java/org/apache/felix/coordinator/impl/CoordinatorImplTest.java
@@ -18,14 +18,12 @@
  */
 package org.apache.felix.coordinator.impl;
 
-import org.apache.felix.coordinator.impl.CoordinationMgr;
-import org.apache.felix.coordinator.impl.CoordinatorImpl;
-import org.apache.felix.service.coordinator.Coordination;
-import org.apache.felix.service.coordinator.CoordinationException;
-import org.apache.felix.service.coordinator.Participant;
-
 import junit.framework.TestCase;
 
+import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
+import org.osgi.service.coordinator.Participant;
+
 @SuppressWarnings("deprecation")
 public class CoordinatorImplTest extends TestCase
 {
@@ -306,6 +304,7 @@
 
         Thread c2Thread = new Thread()
         {
+            @Override
             public void run()
             {
                 final Coordination c2 = coordinator.create(name2, 0);