diff options
author | John Ross | 2013-03-20 18:54:53 +0000 |
---|---|---|
committer | John Ross | 2013-03-20 18:54:53 +0000 |
commit | 97a854baa9fac1824d9dddbb83843691ec7414a8 (patch) | |
tree | 7da65fd2dcc73f2c96c7d87192218b4faf7ab41a | |
parent | 7cae7b4bd358af4838e063d1b7830195573aa679 (diff) | |
download | rt.equinox.bundles-97a854baa9fac1824d9dddbb83843691ec7414a8.tar.gz rt.equinox.bundles-97a854baa9fac1824d9dddbb83843691ec7414a8.tar.xz rt.equinox.bundles-97a854baa9fac1824d9dddbb83843691ec7414a8.zip |
Bug 403934 - [coordinator] Update the exported OSGi API.
8 files changed, 166 insertions, 187 deletions
diff --git a/bundles/org.eclipse.equinox.coordinator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.coordinator/META-INF/MANIFEST.MF index f59ca229d..0b27e5d9e 100644 --- a/bundles/org.eclipse.equinox.coordinator/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.coordinator/META-INF/MANIFEST.MF @@ -14,5 +14,5 @@ Import-Package: org.eclipse.osgi.util;version="[1.1,2.0)", Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Localization: plugin Bundle-ActivationPolicy: lazy -Export-Package: org.osgi.service.coordinator;version="1.0.0" +Export-Package: org.osgi.service.coordinator;version="1.0.1" Service-Component: OSGI-INF/component.xml diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordination.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordination.java index 6547f729f..67f67b526 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordination.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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. @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.osgi.service.coordinator; import java.util.List; import java.util.Map; - import org.osgi.framework.Bundle; /** * A Coordination object is used to coordinate a number of independent * Participants. - * + * * <p> * Once a Coordination is {@link Coordinator#create(String, long) created}, it * can be used to add {@link Participant} objects. When the Coordination is @@ -31,39 +31,39 @@ import org.osgi.framework.Bundle; * A Coordination can also fail for various reasons. When this occurs, the * participants are {@link Participant#failed(Coordination) notified} of the * failure. - * + * * <p> * A Coordination must be in one of two states, either ACTIVE or TERMINATED. The * transition between ACTIVE and TERMINATED must be atomic, ensuring that a * Participant can be guaranteed of either receiving an exception when adding * itself to a Coordination or of receiving notification the Coordination has * terminated. - * + * * <p> * A Coordination object is thread safe and can be passed as a parameter to * other parties regardless of the threads these parties use. - * + * * <p> * The following example code shows how a Coordination should be used. - * + * * <pre> * void foo() { * Coordination c = coordinator.create("work", 0); - * try { - * doWork(c); - * } - * catch (Exception e) { + * try { + * doWork(c); + * } + * catch (Exception e) { * c.fail(e); - * } - * finally { - * c.end(); - * } + * } + * finally { + * c.end(); + * } * } * </pre> - * + * * @ThreadSafe * @noimplement - * @version $Id$ + * @author $Id$ */ public interface Coordination { @@ -89,36 +89,36 @@ public interface Coordination { /** * Returns the id assigned to this Coordination. - * + * * The id is assigned by the {@link Coordinator} service which created this * Coordination and is unique among all the Coordinations created by the * Coordinator service and must not be reused as long as the Coordinator * service remains registered. The id must be positive and monotonically * increases for each Coordination created by the Coordinator service. - * + * * @return The id assigned to this Coordination. */ long getId(); /** * Returns the name of this Coordination. - * + * * The name is specified when this Coordination was created. - * + * * @return The name of this Coordination. - * + * */ String getName(); /** * Terminate this Coordination normally. - * + * * <p> * If this Coordination has been {@link #push() pushed} on the thread local * Coordination stack of another thread, this method does nothing except * throw a CoordinationException of type * {@link CoordinationException#WRONG_THREAD}. - * + * * <p> * If this Coordination has been {@link #push() pushed} on the thread local * Coordination stack of this thread but is not the @@ -134,18 +134,18 @@ public interface Coordination { * Coordination will be the current Coordination and will have been * terminated as a failure if any of the terminated Coordinations threw a * CoordinationException - * + * * <p> * If this Coordination is the {@link Coordinator#peek() current * Coordination}, then it will be {@link Coordinator#pop() removed} from the * thread local Coordination stack. - * + * * <p> * If this Coordination is already terminated, a CoordinationException is * thrown. If this Coordination was terminated as a failure, the * {@link #getFailure() failure cause} will be the cause of the thrown * CoordinationException. - * + * * <p> * Otherwise, this Coordination is terminated normally and then all * registered {@link #getParticipants() Participants} are @@ -154,30 +154,30 @@ public interface Coordination { * return of this method indicates that the Coordination has terminated * normally and all registered Participants have been notified of the normal * termination. - * + * * <p> * It is possible that one of the Participants throws an exception during * notification. If this happens, this Coordination is considered to have * partially failed and this method must throw a CoordinationException of * type {@link CoordinationException#PARTIALLY_ENDED} after all the * registered Participants have been notified. - * + * * @throws CoordinationException If this Coordination has failed, including * timed out, or partially failed or this Coordination is on the * thread local Coordination stack of another thread. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[INITIATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[INITIATE]} for this Coordination. */ void end(); /** * Terminate this Coordination as a failure with the specified failure * cause. - * + * * <p> * If this Coordination is already {@link #isTerminated() terminated}, this * method does nothing and returns {@code false}. - * + * * <p> * Otherwise, this Coordination is terminated as a failure with the * specified failure cause and then all registered @@ -185,20 +185,21 @@ public interface Coordination { * {@link Participant#failed(Coordination) notified}. Participants should * discard any work associated with this Coordination. This method will * return {@code true}. - * + * * <p> * If this Coordination has been {@link #push() pushed} onto a thread local * Coordination stack, this Coordination is not removed from the stack. The * creator of this Coordination must still call {@link #end()} on this * Coordination to cause it to be removed from the thread local Coordination * stack. - * + * * @param cause The failure cause. The failure cause must not be * {@code null}. * @return {@code true} if this Coordination was active and was terminated * by this method, otherwise {@code false}. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[PARTICIPATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[PARTICIPATE]} for this + * Coordination. */ boolean fail(Throwable cause); @@ -226,7 +227,7 @@ public interface Coordination { /** * Returns whether this Coordination is terminated. - * + * * @return {@code true} if this Coordination is terminated, otherwise * {@code false} if this Coordination is active. */ @@ -234,20 +235,20 @@ public interface Coordination { /** * Register a Participant with this Coordination. - * + * * <p> * Once a Participant is registered with this Coordination, it is guaranteed * to receive a notification for either * {@link Participant#ended(Coordination) normal} or * {@link Participant#failed(Coordination) failure} termination when this * Coordination is terminated. - * + * * <p> * Participants are registered using their object identity. Once a * Participant is registered with this Coordination, subsequent attempts to * register the Participant again with this Coordination are ignored and the * Participant is only notified once when this Coordination is terminated. - * + * * <p> * A Participant can only be registered with a single active Coordination at * a time. If a Participant is already registered with an active @@ -256,16 +257,16 @@ public interface Coordination { * registered with terminates. Notice that in edge cases the notification to * the Participant that this Coordination has terminated can happen before * this method returns. - * + * * <p> * Attempting to register a Participant with a {@link #isTerminated() * terminated} Coordination will result in a CoordinationException being * thrown. - * + * * <p> * The ordering of notifying Participants must follow the reverse order in * which the Participants were registered. - * + * * @param participant The Participant to register with this Coordination. * The participant must not be {@code null}. * @throws CoordinationException If the Participant could not be registered @@ -280,45 +281,51 @@ public interface Coordination { /** * Returns a snapshot of the Participants registered with this Coordination. - * + * * @return A snapshot of the Participants registered with this Coordination. * If no Participants are registered with this Coordination, the * returned list will be empty. The list is ordered in the order the * Participants were registered. The returned list is the property * of the caller and can be modified by the caller. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[INITIATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[INITIATE]} for this Coordination. */ List<Participant> getParticipants(); /** * Returns the variable map associated with this Coordination. - * + * * Each Coordination has a map that can be used for communicating between * different Participants. The key of the map is a class, allowing for * private data to be stored in the map by using implementation classes or * shared data by using shared interfaces. - * + * * The returned map is not synchronized. Users of the map must synchronize * on the Map object while making changes. - * + * * @return The variable map associated with this Coordination. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[PARTICIPANT]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[PARTICIPANT]} for this + * Coordination. */ - Map<Class< ? >, Object> getVariables(); + Map<Class<?>, Object> getVariables(); /** * Extend the time out of this Coordination. - * + * * <p> * Participants can call this method to extend the timeout of this * Coordination with at least the specified time. This can be done by * Participants when they know a task will take more than normal time. - * - * This method returns the new deadline. Specifying a timeout extension of 0 - * will return the existing deadline. - * + * + * <p> + * This method will return the new deadline if an extension took place or + * the current deadline if, for whatever reason, no extension takes place. + * Note that if a maximum timeout is in effect, the deadline may not be + * extended by as much as was requested, if at all. If there is no deadline, + * zero is returned. Specifying a timeout extension of 0 will return the + * existing deadline. + * * @param timeMillis The time in milliseconds to extend the current timeout. * If the initial timeout was specified as 0, no extension must take * place. A zero must have no effect. @@ -329,21 +336,23 @@ public interface Coordination { * @throws CoordinationException If this Coordination * {@link #isTerminated() is terminated}. * @throws IllegalArgumentException If the specified time is negative. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[PARTICIPATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[PARTICIPATE]} for this + * Coordination. */ long extendTimeout(long timeMillis); /** * Wait until this Coordination is terminated and all registered * Participants have been notified. - * + * * @param timeMillis Maximum time in milliseconds to wait. Specifying a time * of 0 will wait until this Coordination is terminated. * @throws InterruptedException If the wait is interrupted. * @throws IllegalArgumentException If the specified time is negative. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[PARTICIPATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[PARTICIPATE]} for this + * Coordination. */ void join(long timeMillis) throws InterruptedException; @@ -351,25 +360,25 @@ public interface Coordination { /** * Push this Coordination object onto the thread local Coordination stack to * make it the {@link Coordinator#peek() current Coordination}. - * + * * @return This Coordination. * @throws CoordinationException If this Coordination is already on the any * thread's thread local Coordination stack or this Coordination * {@link #isTerminated() is terminated}. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[INITIATE]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[INITIATE]} for this Coordination. */ Coordination push(); /** * Returns the thread in whose thread local Coordination stack this * Coordination has been {@link #push() pushed}. - * + * * @return The thread in whose thread local Coordination stack this * Coordination has been pushed or {@code null} if this Coordination * is not in any thread local Coordination stack. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[ADMIN]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[ADMIN]} for this Coordination. */ Thread getThread(); @@ -377,17 +386,17 @@ public interface Coordination { * Returns the bundle that created this Coordination. This is the bundle * that obtained the {@link Coordinator} service that was used to create * this Coordination. - * + * * @return The bundle that created this Coordination. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[ADMIN]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[ADMIN]} for this Coordination. */ Bundle getBundle(); /** * Returns the Coordination enclosing this Coordination if this Coordination * is on the thread local Coordination stack. - * + * * <p> * When a Coordination is {@link #push() pushed} onto the thread local * Coordination stack, the former {@link Coordinator#peek() current @@ -395,13 +404,13 @@ public interface Coordination { * Coordination. When this Coordination is {@link Coordinator#pop() removed} * from the thread local Coordination stack, this Coordination no longer has * an enclosing Coordination. - * + * * @return The Coordination enclosing this Coordination if this Coordination * is on the thread local Coordination stack or {@code null} if this * Coordination is not on the thread local Coordination stack or has * no enclosing Coordination. - * @throws SecurityException If the caller does not have {@code - * CoordinationPermission[ADMIN]} for this Coordination. + * @throws SecurityException If the caller does not have + * {@code CoordinationPermission[ADMIN]} for this Coordination. */ Coordination getEnclosingCoordination(); } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationException.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationException.java index 9813b5b25..cb7e25af0 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationException.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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. @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.osgi.service.coordinator; /** * Unchecked exception which may be thrown by a Coordinator implementation. * - * @version $Id$ + * @author $Id$ */ public class CoordinationException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -80,22 +81,21 @@ public class CoordinationException extends RuntimeException { * @param coordination The Coordination associated with this exception. * @param cause The cause associated with this exception. * @param type The type of this exception. + * @throws IllegalArgumentException If the specified type is {@link #FAILED} + * and the specified cause is {@code null}. */ - public CoordinationException(String message, Coordination coordination, - int type, Throwable cause) { + public CoordinationException(String message, Coordination coordination, int type, Throwable cause) { super(message, cause); this.type = type; if (coordination == null) { this.id = -1L; this.name = "<>"; - } - else { + } else { this.id = coordination.getId(); this.name = coordination.getName(); } if ((type == FAILED) && (cause == null)) { - throw new IllegalArgumentException( - "A cause must be specified for type FAILED"); + throw new IllegalArgumentException("A cause must be specified for type FAILED"); } } @@ -105,22 +105,21 @@ public class CoordinationException extends RuntimeException { * @param message The detail message for this exception. * @param coordination The Coordination associated with this exception. * @param type The type of this exception. + * @throws IllegalArgumentException If the specified type is {@link #FAILED} + * . */ - public CoordinationException(String message, Coordination coordination, - int type) { + public CoordinationException(String message, Coordination coordination, int type) { super(message); this.type = type; if (coordination == null) { this.id = -1L; this.name = "<>"; - } - else { + } else { this.id = coordination.getId(); this.name = coordination.getName(); } if (type == FAILED) { - throw new IllegalArgumentException( - "A cause must be specified for type FAILED"); + throw new IllegalArgumentException("A cause must be specified for type FAILED"); } } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationPermission.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationPermission.java index 5c0e011ab..13aa34eae 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationPermission.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/CoordinationPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.osgi.service.coordinator; import java.io.IOException; @@ -33,7 +34,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.osgi.framework.Bundle; import org.osgi.framework.Filter; import org.osgi.framework.FrameworkUtil; @@ -47,31 +47,29 @@ import org.osgi.framework.InvalidSyntaxException; * {@code participate} and {@code admin}. * * @ThreadSafe - * @version $Id$ + * @author $Id$ */ -public class CoordinationPermission extends BasicPermission { +public final class CoordinationPermission extends BasicPermission { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * The action string {@code initiate}. */ - public final static String INITIATE = "initiate"; + public final static String INITIATE = "initiate"; /** * The action string {@code participate}. */ - public final static String PARTICIPATE = "participate"; + public final static String PARTICIPATE = "participate"; /** * The action string {@code admin}. */ - public final static String ADMIN = "admin"; + public final static String ADMIN = "admin"; private final static int ACTION_INITIATE = 0x00000001; private final static int ACTION_PARTICIPATE = 0x00000002; private final static int ACTION_ADMIN = 0x00000004; - private final static int ACTION_ALL = ACTION_INITIATE - | ACTION_PARTICIPATE - | ACTION_ADMIN; + private final static int ACTION_ALL = ACTION_INITIATE | ACTION_PARTICIPATE | ACTION_ADMIN; final static int ACTION_NONE = 0; /** @@ -160,8 +158,7 @@ public class CoordinationPermission extends BasicPermission { * @param actions {@code admin}, {@code initiate} or {@code participate} * (canonical order). */ - public CoordinationPermission(String coordinationName, - Bundle coordinationBundle, String actions) { + public CoordinationPermission(String coordinationName, Bundle coordinationBundle, String actions) { super(coordinationName); setTransients(null, parseActions(actions)); this.bundle = coordinationBundle; @@ -169,8 +166,7 @@ public class CoordinationPermission extends BasicPermission { throw new NullPointerException("coordinationName must not be null"); } if (coordinationBundle == null) { - throw new NullPointerException( - "coordinationBundle must not be null"); + throw new NullPointerException("coordinationBundle must not be null"); } } @@ -225,9 +221,7 @@ public class CoordinationPermission extends BasicPermission { char c; // skip whitespace - while ((i != -1) - && ((c = a[i]) == ' ' || c == '\r' || c == '\n' - || c == '\f' || c == '\t')) + while ((i != -1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t')) i--; // check for the known strings @@ -270,11 +264,9 @@ public class CoordinationPermission extends BasicPermission { matchlen = 11; mask |= ACTION_PARTICIPATE; - } - else { + } else { // parse error - throw new IllegalArgumentException( - "invalid permission: " + actions); + throw new IllegalArgumentException("invalid permission: " + actions); } } @@ -293,8 +285,7 @@ public class CoordinationPermission extends BasicPermission { case '\t' : break; default : - throw new IllegalArgumentException( - "invalid permission: " + actions); + throw new IllegalArgumentException("invalid permission: " + actions); } i--; } @@ -324,10 +315,8 @@ public class CoordinationPermission extends BasicPermission { } try { return FrameworkUtil.createFilter(filterString); - } - catch (InvalidSyntaxException e) { - IllegalArgumentException iae = new IllegalArgumentException( - "invalid filter"); + } catch (InvalidSyntaxException e) { + IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } @@ -466,10 +455,7 @@ public class CoordinationPermission extends BasicPermission { CoordinationPermission cp = (CoordinationPermission) obj; - return (action_mask == cp.action_mask) - && getName().equals(cp.getName()) - && ((bundle == cp.bundle) || ((bundle != null) && bundle - .equals(cp.bundle))); + return (action_mask == cp.action_mask) && getName().equals(cp.getName()) && ((bundle == cp.bundle) || ((bundle != null) && bundle.equals(cp.bundle))); } /** @@ -491,8 +477,7 @@ public class CoordinationPermission extends BasicPermission { * stream. The actions are serialized, and the superclass takes care of the * name. */ - private synchronized void writeObject(java.io.ObjectOutputStream s) - throws IOException { + private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException { if (bundle != null) { throw new NotSerializableException("cannot serialize"); } @@ -507,17 +492,15 @@ public class CoordinationPermission extends BasicPermission { * readObject is called to restore the state of this permission from a * stream. */ - private synchronized void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { + private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); setTransients(parseFilter(getName()), parseActions(actions)); } /** - * Called by {@code <@link CoordinationPermission#implies(Permission)>}. - * This method is only called on a requested permission which cannot have a - * filter set. + * Called by {@link CoordinationPermission#implies(Permission)}. This method + * is only called on a requested permission which cannot have a filter set. * * @return a map of properties for this permission. */ @@ -560,8 +543,8 @@ final class SignerProperty { private final String pattern; /** - * String constructor used by the filter matching algorithm to construct - * a SignerProperty from the attribute value in a filter expression. + * String constructor used by the filter matching algorithm to construct a + * SignerProperty from the attribute value in a filter expression. * * @param pattern Attribute value in the filter expression. */ @@ -582,11 +565,11 @@ final class SignerProperty { } /** - * Used by the filter matching algorithm. This methods does NOT satisfy - * the normal equals contract. Since the class is only used in filter - * expression evaluations, it only needs to support comparing an - * instance created with a Bundle to an instance created with a pattern - * string from the filter expression. + * Used by the filter matching algorithm. This methods does NOT satisfy the + * normal equals contract. Since the class is only used in filter expression + * evaluations, it only needs to support comparing an instance created with + * a Bundle to an instance created with a pattern string from the filter + * expression. * * @param o SignerProperty to compare against. * @return true if the DN name chain matches the pattern. @@ -597,20 +580,17 @@ final class SignerProperty { SignerProperty other = (SignerProperty) o; Bundle matchBundle = bundle != null ? bundle : other.bundle; String matchPattern = bundle != null ? other.pattern : pattern; - Map<X509Certificate, List<X509Certificate>> signers = matchBundle - .getSignerCertificates(Bundle.SIGNERS_TRUSTED); + Map<X509Certificate, List<X509Certificate>> signers = matchBundle.getSignerCertificates(Bundle.SIGNERS_TRUSTED); for (List<X509Certificate> signerCerts : signers.values()) { List<String> dnChain = new ArrayList<String>(signerCerts.size()); for (X509Certificate signerCert : signerCerts) { dnChain.add(signerCert.getSubjectDN().getName()); } try { - if (FrameworkUtil.matchDistinguishedNameChain(matchPattern, - dnChain)) { + if (FrameworkUtil.matchDistinguishedNameChain(matchPattern, dnChain)) { return true; } - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { continue; // bad pattern } } @@ -618,9 +598,8 @@ final class SignerProperty { } /** - * Since the equals method does not obey the general equals contract, - * this method cannot generate hash codes which obey the equals - * contract. + * Since the equals method does not obey the general equals contract, this + * method cannot generate hash codes which obey the equals contract. */ public int hashCode() { return 31; @@ -635,8 +614,7 @@ final class SignerProperty { if (bundle == null) { return false; } - Map<X509Certificate, List<X509Certificate>> signers = bundle - .getSignerCertificates(Bundle.SIGNERS_TRUSTED); + Map<X509Certificate, List<X509Certificate>> signers = bundle.getSignerCertificates(Bundle.SIGNERS_TRUSTED); return !signers.isEmpty(); } } @@ -650,7 +628,7 @@ final class SignerProperty { */ final class CoordinationPermissionCollection extends PermissionCollection { - static final long serialVersionUID = -3350758995234427603L; + static final long serialVersionUID = -3350758995234427603L; /** * Collection of permissions. * @@ -688,18 +666,15 @@ final class CoordinationPermissionCollection extends PermissionCollection { */ public void add(final Permission permission) { if (!(permission instanceof CoordinationPermission)) { - throw new IllegalArgumentException("invalid permission: " - + permission); + throw new IllegalArgumentException("invalid permission: " + permission); } if (isReadOnly()) { - throw new SecurityException("attempt to add a Permission to a " - + "readonly PermissionCollection"); + throw new SecurityException("attempt to add a Permission to a " + "readonly PermissionCollection"); } final CoordinationPermission cp = (CoordinationPermission) permission; if (cp.bundle != null) { - throw new IllegalArgumentException("cannot add to collection: " - + cp); + throw new IllegalArgumentException("cannot add to collection: " + cp); } final String name = cp.getName(); @@ -710,13 +685,10 @@ final class CoordinationPermissionCollection extends PermissionCollection { final int oldMask = existing.action_mask; final int newMask = cp.action_mask; if (oldMask != newMask) { - pc.put(name, new CoordinationPermission(existing.filter, - oldMask - | newMask)); + pc.put(name, new CoordinationPermission(existing.filter, oldMask | newMask)); } - } - else { + } else { pc.put(name, cp); } @@ -786,23 +758,18 @@ final class CoordinationPermissionCollection extends PermissionCollection { } /* serialization logic */ - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("permissions", HashMap.class), - new ObjectStreamField("all_allowed", Boolean.TYPE) }; + private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("permissions", HashMap.class), new ObjectStreamField("all_allowed", Boolean.TYPE)}; - private synchronized void writeObject(ObjectOutputStream out) - throws IOException { + private synchronized void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("permissions", permissions); pfields.put("all_allowed", all_allowed); out.writeFields(); } - private synchronized void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException { + private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField gfields = in.readFields(); - permissions = (HashMap<String, CoordinationPermission>) gfields.get( - "permissions", null); + permissions = (HashMap<String, CoordinationPermission>) gfields.get("permissions", null); all_allowed = gfields.get("all_allowed", false); } } diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordinator.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordinator.java index 0de5b2dd3..e2e1850c6 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordinator.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Coordinator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.osgi.service.coordinator; import java.util.Collection; @@ -63,7 +64,7 @@ import java.util.Collection; * <pre> * void doWork() { * if (coordinator.addParticipant(this)) { - * beginWork(); + * beginWork(); * } else { * beginWork(); * finishWork(); @@ -81,7 +82,7 @@ import java.util.Collection; * * @ThreadSafe * @noimplement - * @version $Id$ + * @author $Id$ */ public interface Coordinator { @@ -91,11 +92,11 @@ public interface Coordinator { * @param name The name of this coordination. The name does not have to be * unique but must follow the {@code symbolic-name} syntax from the * Core specification. - * @param timeMillis Timeout in milliseconds. A value of 0 means no timeout. - * If the Coordination is not terminated within the timeout, the - * Coordinator service will {@link Coordination#fail(Throwable) fail} - * the Coordination with a {@link Coordination#TIMEOUT TIMEOUT} - * exception. + * @param timeMillis Timeout in milliseconds. A value of 0 means no timeout + * is required. If the Coordination is not terminated within the + * timeout, the Coordinator service will + * {@link Coordination#fail(Throwable) fail} the Coordination with a + * {@link Coordination#TIMEOUT TIMEOUT} exception. * @return The new Coordination object. * @throws IllegalArgumentException If the specified name does not follow * the {@code symbolic-name} syntax or the specified time is @@ -117,11 +118,11 @@ public interface Coordinator { * @param name The name of this coordination. The name does not have to be * unique but must follow the {@code symbolic-name} syntax from the * Core specification. - * @param timeMillis Timeout in milliseconds. A value of 0 means no timeout. - * If the Coordination is not terminated within the timeout, the - * Coordinator service will {@link Coordination#fail(Throwable) fail} - * the Coordination with a {@link Coordination#TIMEOUT TIMEOUT} - * exception. + * @param timeMillis Timeout in milliseconds. A value of 0 means no timeout + * is required. If the Coordination is not terminated within the + * timeout, the Coordinator service will + * {@link Coordination#fail(Throwable) fail} the Coordination with a + * {@link Coordination#TIMEOUT TIMEOUT} exception. * @return A new Coordination object * @throws IllegalArgumentException If the specified name does not follow * the {@code symbolic-name} syntax or the specified time is diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Participant.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Participant.java index 52e3d84eb..6bef92f85 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Participant.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/Participant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.osgi.service.coordinator; /** @@ -45,7 +46,7 @@ package org.osgi.service.coordinator; * returns. * * @ThreadSafe - * @version $Id$ + * @author $Id$ */ public interface Participant { /** diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/package-info.java b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/package-info.java index a48f965a7..a38600288 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/package-info.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2012). 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. @@ -32,7 +32,9 @@ * <p> * {@code Import-Package: org.osgi.service.coordinator; version="[1.0,1.1)"} * - * @version $Id$ + * @version 1.0 + * @author $Id$ */ package org.osgi.service.coordinator; + diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/packageinfo b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/packageinfo index 7c8de0324..b3d1f97f7 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/packageinfo +++ b/bundles/org.eclipse.equinox.coordinator/src/org/osgi/service/coordinator/packageinfo @@ -1 +1 @@ -version 1.0 +version 1.0.1 |