felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r389891 [2/9] - in /incubator/felix/trunk/org.osgi.compendium: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/osgi/ src/main/java/org/osgi/service/ src/main/java/org/osgi/service/cm/ src/main/java/org/osgi/service/com...
Date Wed, 29 Mar 2006 21:05:18 GMT
Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentContext.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentContext.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentContext.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentContext.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,198 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/ComponentContext.java,v 1.19 2006/03/14 01:20:50 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.osgi.service.component;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.*;
+
+/**
+ * A Component Context object is used by a component instance to interact with
+ * its execution context including locating services by reference name. Each
+ * component instance has a unique Component Context.
+ * 
+ * <p>
+ * A component's implementation class may optionaly implement an activate
+ * method:
+ * 
+ * <pre>
+ * protected void activate(ComponentContext context);
+ * </pre>
+ * 
+ * If a component implements this method, this method will be called when a
+ * component configuration is activated to provide the component instance's
+ * Component Context object.
+ * 
+ * <p>
+ * A component's implementation class may optionaly implement a deactivate
+ * method:
+ * 
+ * <pre>
+ * protected void deactivate(ComponentContext context);
+ * </pre>
+ * 
+ * If a component implements this method, this method will be called when the
+ * component configuration is deactivated.
+ * 
+ * <p>
+ * The activate and deactivate methods will be called using reflection and must
+ * be protected or public accessible. These methods should not be public methods
+ * so that they do not appear as public methods on the component instance when
+ * used as a service object. These methods will be located by looking through
+ * the component's implementation class hierarchy for the first declaration of
+ * the method. If the method is found, if it is declared protected or public,
+ * the method will be called. Otherwise, the method will not be called.
+ * 
+ * @version $Revision: 1.19 $
+ */
+public interface ComponentContext {
+	/**
+	 * Returns the component properties for this Component Context.
+	 * 
+	 * @return The properties for this Component Context. The Dictionary is read
+	 *         only and cannot be modified.
+	 */
+	public Dictionary getProperties();
+
+	/**
+	 * Returns the service object for the specified reference name.
+	 * 
+	 * <p>
+	 * If the cardinality of the reference is <code>0..n</code> or
+	 * <code>1..n</code> and multiple services are bound to the reference, the
+	 * service with the highest ranking (as specified in its
+	 * <code>Constants.SERVICE_RANKING</code> property) is returned. If there
+	 * is a tie in ranking, the service with the lowest service ID (as specified
+	 * in its <code>Constants.SERVICE_ID</code> property); that is, the
+	 * service that was registered first is returned.
+	 * 
+	 * @param name The name of a reference as specified in a
+	 *        <code>reference</code> element in this component's description.
+	 * @return A service object for the referenced service or <code>null</code>
+	 *         if the reference cardinality is <code>0..1</code> or
+	 *         <code>0..n</code> and no bound service is available.
+	 * @throws ComponentException If the Service Component Runtime catches an
+	 *         exception while activating the bound service.
+	 */
+	public Object locateService(String name);
+
+	/**
+	 * Returns the service object for the specified reference name and
+	 * <code>ServiceReference</code>.
+	 * 
+	 * @param name The name of a reference as specified in a
+	 *        <code>reference</code> element in this component's description.
+	 * @param reference The <code>ServiceReference</code> to a bound service.
+	 *        This must be a <code>ServiceReference</code> provided to the
+	 *        component via the bind or unbind method for the specified
+	 *        reference name.
+	 * @return A service object for the referenced service or <code>null</code>
+	 *         if the specified <code>ServiceReference</code> is not a bound
+	 *         service for the specified reference name.
+	 * @throws ComponentException If the Service Component Runtime catches an
+	 *         exception while activating the bound service.
+	 */
+	public Object locateService(String name, ServiceReference reference);
+
+	/**
+	 * Returns the service objects for the specified reference name.
+	 * 
+	 * @param name The name of a reference as specified in a
+	 *        <code>reference</code> element in this component's description.
+	 * @return An array of service objects for the referenced service or
+	 *         <code>null</code> if the reference cardinality is
+	 *         <code>0..1</code> or <code>0..n</code> and no bound service
+	 *         is available.
+	 * @throws ComponentException If the Service Component Runtime catches an
+	 *         exception while activating a bound service.
+	 */
+	public Object[] locateServices(String name);
+
+	/**
+	 * Returns the <code>BundleContext</code> of the bundle which contains
+	 * this component.
+	 * 
+	 * @return The <code>BundleContext</code> of the bundle containing this
+	 *         component.
+	 */
+	public BundleContext getBundleContext();
+
+	/**
+	 * If the component instance is registered as a service using the
+	 * <code>servicefactory=&quot;true&quot;</code> attribute, then this
+	 * method returns the bundle using the service provided by the component
+	 * instance.
+	 * <p>
+	 * This method will return <code>null</code> if:
+	 * <ul>
+	 * <li>The component instance is not a service, then no bundle can be using
+	 * it as a service.
+	 * <li>The component instance is a service but did not specify the
+	 * <code>servicefactory=&quot;true&quot;</code> attribute, then all
+	 * bundles using the service provided by the component instance will share
+	 * the same component instance.
+	 * <li>The service provided by the component instance is not currently
+	 * being used by any bundle.
+	 * </ul>
+	 * 
+	 * @return The bundle using the component instance as a service or
+	 *         <code>null</code>.
+	 */
+	public Bundle getUsingBundle();
+
+	/**
+	 * Returns the Component Instance object for the component instance
+	 * associated with this Component Context.
+	 * 
+	 * @return The Component Instance object for the component instance.
+	 */
+	public ComponentInstance getComponentInstance();
+
+	/**
+	 * Enables the specified component name. The specified component name must
+	 * be in the same bundle as this component.
+	 * 
+	 * @param name The name of a component or <code>null</code> to indicate
+	 *        all components in the bundle.
+	 */
+	public void enableComponent(String name);
+
+	/**
+	 * Disables the specified component name. The specified component name must
+	 * be in the same bundle as this component.
+	 * 
+	 * @param name The name of a component.
+	 */
+	public void disableComponent(String name);
+
+	/**
+	 * If the component instance is registered as a service using the
+	 * <code>service</code> element, then this method returns the service
+	 * reference of the service provided by this component instance.
+	 * <p>
+	 * This method will return <code>null</code> if the component instance is
+	 * not registered as a service.
+	 * 
+	 * @return The <code>ServiceReference</code> object for the component
+	 *         instance or <code>null</code> if the component instance is not
+	 *         registered as a service.
+	 */
+	public ServiceReference getServiceReference();
+
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentException.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentException.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentException.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentException.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,87 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/ComponentException.java,v 1.11 2006/03/14 01:20:50 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.osgi.service.component;
+
+/**
+ * Unchecked exception which may be thrown by the Service Component Runtime.
+ * 
+ * @version $Revision: 1.11 $
+ */
+public class ComponentException extends RuntimeException {
+	static final long	serialVersionUID	= -7438212656298726924L;
+	/**
+	 * Nested exception.
+	 */
+	private Throwable	cause;
+
+	/**
+	 * Construct a new ComponentException with the specified message and cause.
+	 * 
+	 * @param message The message for the exception.
+	 * @param cause The cause of the exception. May be <code>null</code>.
+	 */
+	public ComponentException(String message, Throwable cause) {
+		super(message);
+		this.cause = cause;
+	}
+
+	/**
+	 * Construct a new ComponentException with the specified message.
+	 * 
+	 * @param message The message for the exception.
+	 */
+	public ComponentException(String message) {
+		super(message);
+		this.cause = null;
+	}
+
+	/**
+	 * Construct a new ComponentException with the specified cause.
+	 * 
+	 * @param cause The cause of the exception. May be <code>null</code>.
+	 */
+	public ComponentException(Throwable cause) {
+		super();
+		this.cause = cause;
+	}
+
+	/**
+	 * Returns the cause of this exception or <code>null</code> if no cause
+	 * was specified when this exception was created.
+	 * 
+	 * @return The cause of this exception or <code>null</code> if no cause
+	 *         was specified.
+	 */
+	public Throwable getCause() {
+		return cause;
+	}
+
+	/**
+	 * The cause of this exception can only be set when constructed.
+	 * 
+	 * @param cause Cause of the exception.
+	 * @return This object.
+	 * @throws java.lang.IllegalStateException This method will always throw an
+	 *         <code>IllegalStateException</code> since the cause of this
+	 *         exception can only be set when constructed.
+	 */
+	public Throwable initCause(Throwable cause) {
+		throw new IllegalStateException();
+	}
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentFactory.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentFactory.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentFactory.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentFactory.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,47 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/ComponentFactory.java,v 1.17 2006/03/14 01:20:50 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.osgi.service.component;
+
+import java.util.Dictionary;
+
+/**
+ * When a component is declared with the <code>factory</code> attribute on its
+ * <code>component</code> element, the Service Component Runtime will register
+ * a Component Factory service to allow new component configurations to be
+ * created and activated rather than automatically creating and activating
+ * component configuration as necessary.
+ * 
+ * @version $Revision: 1.17 $
+ */
+public interface ComponentFactory {
+	/**
+	 * Create and activate a new component configuration. Additional properties
+	 * may be provided for the component configuration.
+	 * 
+	 * @param properties Additional properties for the component configuration.
+	 * @return A <code>ComponentInstance</code> object encapsulating the
+	 *         component instance of the component configuration. The component
+	 *         configuration has been activated and, if the component specifies
+	 *         a <code>service</code> element, the component instance has been
+	 *         registered as a service.
+	 * @throws ComponentException If the Service Component Runtime is unable to
+	 *         activate the component configuration.
+	 */
+	public ComponentInstance newInstance(Dictionary properties);
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentInstance.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentInstance.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentInstance.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentInstance.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,47 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/ComponentInstance.java,v 1.12 2006/03/14 01:20:50 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.osgi.service.component;
+
+/**
+ * A ComponentInstance encapsulates a component instance of an activated
+ * component configuration. ComponentInstances are created whenever a component
+ * configuration is activated.
+ * 
+ * <p>
+ * ComponentInstances are never reused. A new ComponentInstance object will be
+ * created when the component configuration is activated again.
+ * 
+ * @version $Revision: 1.12 $
+ */
+public interface ComponentInstance {
+	/**
+	 * Dispose of the component configuration for this component instance. The
+	 * component configuration will be deactivated. If the component
+	 * configuration has already been deactivated, this method does nothing.
+	 */
+	public void dispose();
+
+	/**
+	 * Returns the component instance of the activated component configuration.
+	 * 
+	 * @return The component instance or <code>null</code> if the component
+	 *         configuration has been deactivated.
+	 */
+	public Object getInstance();
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/ComponentInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/package.html
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/package.html?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/package.html (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/package.html Wed Mar 29 13:05:08 2006
@@ -0,0 +1,11 @@
+<!-- $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/package.html,v 1.2 2004/12/01 19:01:25 hargrave Exp $ -->
+<BODY>
+<P>The OSGi Service Component Package. Specification Version 1.0.
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.service.component; version=1.0
+</pre>
+</BODY>
+

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/packageinfo
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/packageinfo?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/packageinfo (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/packageinfo Wed Mar 29 13:05:08 2006
@@ -0,0 +1 @@
+version 1.0

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/component/packageinfo
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Constants.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Constants.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Constants.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,75 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/Constants.java,v 1.7 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). 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.osgi.service.device;
+
+/**
+ * This interface defines standard names for property keys associated with
+ * {@link Device}and {@link Driver}services.
+ * 
+ * <p>
+ * The values associated with these keys are of type <code>java.lang.String</code>,
+ * unless otherwise stated.
+ * 
+ * @version $Revision: 1.7 $
+ * @since 1.1
+ * @see Device
+ * @see Driver
+ */
+public interface Constants {
+	/**
+	 * Property (named &quot;DRIVER_ID&quot;) identifying a driver.
+	 * 
+	 * <p>
+	 * A <code>DRIVER_ID</code> should start with the reversed domain name of the
+	 * company that implemented the driver (e.g., <code>com.acme</code>), and
+	 * must meet the following requirements:
+	 * 
+	 * <ul>
+	 * <li>It must be independent of the location from where it is obtained.
+	 * <li>It must be independent of the {@link DriverLocator}service that
+	 * downloaded it.
+	 * <li>It must be unique.
+	 * <li>It must be different for different revisions of the same driver.
+	 * </ul>
+	 * 
+	 * <p>
+	 * This property is mandatory, i.e., every <code>Driver</code> service must be
+	 * registered with it.
+	 */
+	public static final String	DRIVER_ID			= "DRIVER_ID";
+	/**
+	 * Property (named &quot;DEVICE_CATEGORY&quot;) containing a human readable
+	 * description of the device categories implemented by a device. This
+	 * property is of type <code>String[]</code>
+	 * 
+	 * <p>
+	 * Services registered with this property will be treated as devices and
+	 * discovered by the device manager
+	 */
+	public static final String	DEVICE_CATEGORY		= "DEVICE_CATEGORY";
+	/**
+	 * Property (named &quot;DEVICE_SERIAL&quot;) specifying a device's serial
+	 * number.
+	 */
+	public static final String	DEVICE_SERIAL		= "DEVICE_SERIAL";
+	/**
+	 * Property (named &quot;DEVICE_DESCRIPTION&quot;) containing a human
+	 * readable string describing the actual hardware device.
+	 */
+	public static final String	DEVICE_DESCRIPTION	= "DEVICE_DESCRIPTION";
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Device.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Device.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Device.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Device.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,62 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/Device.java,v 1.8 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). 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.osgi.service.device;
+
+/**
+ * <p>
+ * Interface for identifying device services.
+ * 
+ * <p>
+ * A service must implement this interface or use the
+ * {@link Constants#DEVICE_CATEGORY}registration property to indicate that it
+ * is a device. Any services implementing this interface or registered with the
+ * <code>DEVICE_CATEGORY</code> property will be discovered by the device manager.
+ * 
+ * <p>
+ * Device services implementing this interface give the device manager the
+ * opportunity to indicate to the device that no drivers were found that could
+ * (further) refine it. In this case, the device manager calls the
+ * {@link #noDriverFound}method on the <code>Device</code> object.
+ * 
+ * <p>
+ * Specialized device implementations will extend this interface by adding
+ * methods appropriate to their device category to it.
+ * 
+ * @version $Revision: 1.8 $
+ * @see Driver
+ */
+public interface Device {
+	/**
+	 * Return value from {@link Driver#match}indicating that the driver cannot
+	 * refine the device presented to it by the device manager.
+	 * 
+	 * The value is zero.
+	 */
+	public static final int	MATCH_NONE	= 0;
+
+	/**
+	 * Indicates to this <code>Device</code> object that the device manager has
+	 * failed to attach any drivers to it.
+	 * 
+	 * <p>
+	 * If this <code>Device</code> object can be configured differently, the
+	 * driver that registered this <code>Device</code> object may unregister it
+	 * and register a different Device service instead.
+	 */
+	public void noDriverFound();
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Device.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Driver.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Driver.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Driver.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Driver.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,108 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/Driver.java,v 1.9 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). 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.osgi.service.device;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A <code>Driver</code> service object must be registered by each Driver bundle
+ * wishing to attach to Device services provided by other drivers. For each
+ * newly discovered {@link Device}object, the device manager enters a bidding
+ * phase. The <code>Driver</code> object whose {@link #match}method bids the
+ * highest for a particular <code>Device</code> object will be instructed by the
+ * device manager to attach to the <code>Device</code> object.
+ * 
+ * @version $Revision: 1.9 $
+ * @see Device
+ * @see DriverLocator
+ */
+public interface Driver {
+	/**
+	 * Checks whether this Driver service can be attached to the Device service.
+	 * 
+	 * The Device service is represented by the given {@link ServiceReference}
+	 * and returns a value indicating how well this driver can support the given
+	 * Device service, or {@link Device#MATCH_NONE}if it cannot support the
+	 * given Device service at all.
+	 * 
+	 * <p>
+	 * The return value must be one of the possible match values defined in the
+	 * device category definition for the given Device service, or
+	 * <code>Device.MATCH_NONE</code> if the category of the Device service is not
+	 * recognized.
+	 * 
+	 * <p>
+	 * In order to make its decision, this Driver service may examine the
+	 * properties associated with the given Device service, or may get the
+	 * referenced service object (representing the actual physical device) to
+	 * talk to it, as long as it ungets the service and returns the physical
+	 * device to a normal state before this method returns.
+	 * 
+	 * <p>
+	 * A Driver service must always return the same match code whenever it is
+	 * presented with the same Device service.
+	 * 
+	 * <p>
+	 * The match function is called by the device manager during the matching
+	 * process.
+	 * 
+	 * @param reference the <code>ServiceReference</code> object of the device to
+	 *        match
+	 * 
+	 * @return value indicating how well this driver can support the given
+	 *         Device service, or <code>Device.MATCH_NONE</code> if it cannot
+	 *         support the Device service at all
+	 * 
+	 * @throws java.lang.Exception if this Driver service cannot examine the
+	 *            Device service
+	 */
+	public int match(ServiceReference reference) throws Exception;
+
+	/**
+	 * Attaches this Driver service to the Device service represented by the
+	 * given <code>ServiceReference</code> object.
+	 * 
+	 * <p>
+	 * A return value of <code>null</code> indicates that this Driver service has
+	 * successfully attached to the given Device service. If this Driver service
+	 * is unable to attach to the given Device service, but knows of a more
+	 * suitable Driver service, it must return the <code>DRIVER_ID</code> of that
+	 * Driver service. This allows for the implementation of referring drivers
+	 * whose only purpose is to refer to other drivers capable of handling a
+	 * given Device service.
+	 * 
+	 * <p>
+	 * After having attached to the Device service, this driver may register the
+	 * underlying device as a new service exposing driver-specific
+	 * functionality.
+	 * 
+	 * <p>
+	 * This method is called by the device manager.
+	 * 
+	 * @param reference the <code>ServiceReference</code> object of the device to
+	 *        attach to
+	 * 
+	 * @return <code>null</code> if this Driver service has successfully attached
+	 *         to the given Device service, or the <code>DRIVER_ID</code> of a
+	 *         more suitable driver
+	 * 
+	 * @throws java.lang.Exception if the driver cannot attach to the given
+	 *            device and does not know of a more suitable driver
+	 */
+	public String attach(ServiceReference reference) throws Exception;
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Driver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverLocator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverLocator.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverLocator.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverLocator.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,66 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/DriverLocator.java,v 1.8 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). 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.osgi.service.device;
+
+import java.util.Dictionary;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * A Driver Locator service can find and load device driver bundles given a
+ * property set. Each driver is represented by a unique <code>DRIVER_ID</code>.
+ * <p>
+ * Driver Locator services provide the mechanism for dynamically downloading new
+ * device driver bundles into an OSGi environment. They are supplied by
+ * providers and encapsulate all provider-specific details related to the
+ * location and acquisition of driver bundles.
+ * 
+ * @version $Revision: 1.8 $
+ * @see Driver
+ */
+public interface DriverLocator {
+	/**
+	 * Returns an array of <code>DRIVER_ID</code> strings of drivers capable of
+	 * attaching to a device with the given properties.
+	 * 
+	 * <p>
+	 * The property keys in the specified <code>Dictionary</code> objects are
+	 * case-insensitive.
+	 * 
+	 * @param props the properties of the device for which a driver is sought
+	 * @return array of driver <code>DRIVER_ID</code> strings of drivers capable
+	 *         of attaching to a Device service with the given properties, or
+	 *         <code>null</code> if this Driver Locator service does not know of
+	 *         any such drivers
+	 */
+	public String[] findDrivers(Dictionary props);
+
+	/**
+	 * Get an <code>InputStream</code> from which the driver bundle providing a
+	 * driver with the giving <code>DRIVER_ID</code> can be installed.
+	 * 
+	 * @param id the <code>DRIVER_ID</code> of the driver that needs to be
+	 *        installed.
+	 * @return An <code>InputStream</code> object from which the driver bundle can
+	 *         be installed or <code>null</code> if the driver with the given ID
+	 *         cannot be located
+	 * @throws java.io.IOException the input stream for the bundle cannot be
+	 *         created
+	 */
+	public InputStream loadDriver(String id) throws IOException;
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverSelector.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverSelector.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverSelector.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverSelector.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,54 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/DriverSelector.java,v 1.8 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2005). 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.osgi.service.device;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * When the device manager detects a new Device service, it calls all registered
+ * Driver services to determine if anyone matches the Device service. If at
+ * least one Driver service matches, the device manager must choose one. If
+ * there is a Driver Selector service registered with the Framework, the device
+ * manager will ask it to make the selection. If there is no Driver Selector
+ * service, or if it returns an invalid result, or throws an <code>Exception</code>,
+ * the device manager uses the default selection strategy.
+ * 
+ * @version $Revision: 1.8 $
+ * @since 1.1
+ */
+public interface DriverSelector {
+	/**
+	 * Return value from <code>DriverSelector.select</code>, if no Driver service
+	 * should be attached to the Device service. The value is -1.
+	 */
+	public static final int	SELECT_NONE	= -1;
+
+	/**
+	 * Select one of the matching Driver services. The device manager calls this
+	 * method if there is at least one driver bidding for a device. Only Driver
+	 * services that have responded with nonzero (not {@link Device#MATCH_NONE})
+	 * <code></code> match values will be included in the list.
+	 * 
+	 * @param reference the <code>ServiceReference</code> object of the Device
+	 *        service.
+	 * @param matches the array of all non-zero matches.
+	 * @return index into the array of <code>Match</code> objects, or
+	 *         <code>SELECT_NONE</code> if no Driver service should be attached
+	 */
+	public int select(ServiceReference reference, Match[] matches);
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/DriverSelector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Match.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Match.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Match.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Match.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,44 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/Match.java,v 1.8 2006/03/14 01:20:43 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2005). 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.osgi.service.device;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Instances of <code>Match</code> are used in the {@link DriverSelector#select}
+ * method to identify Driver services matching a Device service.
+ * 
+ * @version $Revision: 1.8 $
+ * @since 1.1
+ * @see DriverSelector
+ */
+public interface Match {
+	/**
+	 * Return the reference to a Driver service.
+	 * 
+	 * @return <code>ServiceReference</code> object to a Driver service.
+	 */
+	public ServiceReference getDriver();
+
+	/**
+	 * Return the match value of this object.
+	 * 
+	 * @return the match value returned by this Driver service.
+	 */
+	public int getMatchValue();
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/Match.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/package.html
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/package.html?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/package.html (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/package.html Wed Mar 29 13:05:08 2006
@@ -0,0 +1,10 @@
+<!-- $Header: /cvshome/build/org.osgi.service.device/src/org/osgi/service/device/package.html,v 1.2 2004/12/01 19:01:15 hargrave Exp $ -->
+<BODY>
+<P>The OSGi Device Access Package. Specification Version 1.1.
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.service.device; version=1.1
+</pre>
+</BODY>

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/packageinfo
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/packageinfo?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/packageinfo (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/packageinfo Wed Mar 29 13:05:08 2006
@@ -0,0 +1 @@
+version 1.1

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/device/packageinfo
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/Event.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/Event.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/Event.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/Event.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,199 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/Event.java,v 1.6 2006/03/14 01:21:30 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2005). 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.osgi.service.event;
+
+import java.util.*;
+
+import org.osgi.framework.Filter;
+
+/**
+ * An event.
+ * 
+ * <code>Event</code> objects are delivered to <code>EventHandler</code>
+ * services which subsrcibe to the topic of the event.
+ * 
+ * @version $Revision: 1.6 $
+ */
+public class Event {
+	/**
+	 * The topic of this event.
+	 */
+	String	topic;
+	/**
+	 * The properties carried by this event. Keys are strings and values are
+	 * objects
+	 */
+	Hashtable	properties;
+
+	/**
+	 * Constructs an event.
+	 * 
+	 * @param topic The topic of the event.
+	 * @param properties The event's properties (may be <code>null</code>).
+	 * 
+	 * @throws IllegalArgumentException If topic is not a valid topic name.
+	 */
+	public Event(String topic, Dictionary properties) {
+		this.topic = topic;
+		validateTopicName();
+		this.properties = new Hashtable();
+		if (properties != null) {
+			for (Enumeration e = properties.keys(); e.hasMoreElements();) {
+				String key = (String) e.nextElement();
+				Object value = properties.get(key);
+				this.properties.put(key, value);
+			}
+		}
+		this.properties.put(EventConstants.EVENT_TOPIC, topic);
+	}
+
+	/**
+	 * Retrieves a property.
+	 * 
+	 * @param name the name of the property to retrieve
+	 * 
+	 * @return The value of the property, or <code>null</code> if not found.
+	 */
+	public final Object getProperty(String name) {
+		return properties.get(name);
+	}
+
+	/**
+	 * Returns a list of this event's property names.
+	 * 
+	 * @return A non-empty array with one element per property.
+	 */
+	public final String[] getPropertyNames() {
+		String[] names = new String[properties.size()];
+		Enumeration keys = properties.keys();
+		for (int i = 0; keys.hasMoreElements(); i++) {
+			names[i] = (String) keys.nextElement();
+		}
+		return names;
+	}
+
+	/**
+	 * Returns the topic of this event.
+	 * 
+	 * @return The topic of this event.
+	 */
+	public final String getTopic() {
+		return topic;
+	}
+
+	/**
+	 * Tests this event's properties against the given filter.
+	 * 
+	 * @param filter The filter to test.
+	 * 
+	 * @return true If this event's properties match the filter, false
+	 *         otherwise.
+	 */
+	public final boolean matches(Filter filter) {
+		return filter.matchCase(properties);
+	}
+
+	/**
+	 * Compares this <code>Event</code> object to another object.
+	 * 
+	 * <p>
+	 * An event is considered to be <b>equal to </b> another
+	 * event if the topic is equal and the properties are equal.
+	 * 
+	 * @param object The <code>Event</code> object to be compared.
+	 * @return <code>true</code> if <code>object</code> is a
+	 *         <code>Event</code> and is equal to this object;
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean equals(Object object) {
+		if (object == this) { // quicktest
+			return true;
+		}
+
+		if (!(object instanceof Event)) {
+			return false;
+		}
+
+		Event event = (Event) object;
+		return topic.equals(event.topic) && properties.equals(event.properties);
+	}
+
+	/**
+	 * Returns a hash code value for the object.
+	 * 
+	 * @return An integer which is a hash code value for this object.
+	 */
+	public int hashCode() {
+		return topic.hashCode() ^ properties.hashCode();
+	}
+
+	/**
+	 * Returns the string representation of this event.
+	 * 
+	 * @return The string representation of this event.
+	 */
+	public String toString() {
+		return getClass().getName() + " [topic=" + topic + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	private static final String	SEPARATOR	= "/"; //$NON-NLS-1$
+
+	/**
+	 * Called by the constructor to validate the topic name.
+	 * 
+	 * @throws IllegalArgumentException If the topic name is invalid.
+	 */
+	private void validateTopicName() {
+		try {
+			StringTokenizer st = new StringTokenizer(topic, SEPARATOR, true);
+			validateToken(st.nextToken());
+
+			while (st.hasMoreTokens()) {
+				st.nextToken(); // consume delimiter
+				validateToken(st.nextToken());
+			}
+		}
+		catch (NoSuchElementException e) {
+			throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+		}
+	}
+
+	private static final String	alphaGrammar	= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; //$NON-NLS-1$
+	private static final String	tokenGrammar	= alphaGrammar + "0123456789_"; //$NON-NLS-1$
+
+	/**
+	 * Validate a token.
+	 * 
+	 * @throws IllegalArgumentException If the token is invalid.
+	 */
+	private void validateToken(String token) {
+		int length = token.length();
+		if (length < 1) {
+			throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+		}
+		if (alphaGrammar.indexOf(token.charAt(0)) == -1) { //$NON-NLS-1$
+			throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+		}
+		for (int i = 1; i < length; i++) {
+			if (tokenGrammar.indexOf(token.charAt(i)) == -1) { //$NON-NLS-1$
+				throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+			}
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/Event.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventAdmin.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventAdmin.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventAdmin.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventAdmin.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,53 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventAdmin.java,v 1.5 2006/03/14 01:21:30 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2005). 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.osgi.service.event;
+
+/**
+ * The Event Admin service. Bundles wishing to publish events must obtain the
+ * Event Admin service and call one of the event delivery methods.
+ * 
+ * @version $Revision: 1.5 $
+ */
+public interface EventAdmin {
+	/**
+	 * Initiate asynchronous delivery of an event. This method returns to
+	 * the caller before delivery of the event is completed.
+	 * 
+	 * @param event The event to send to all listeners which subscribe
+	 *        to the topic of the event.
+	 * 
+	 * @throws SecurityException If the caller does not have
+	 *            <code>TopicPermission[topic,PUBLISH]</code> for the topic
+	 *            specified in the event.
+	 */
+	void postEvent(Event event);
+
+	/**
+	 * Initiate synchronous delivery of an event. This method does not
+	 * return to the caller until delivery of the event is completed.
+	 * 
+	 * @param event The event to send to all listeners which subscribe
+	 *        to the topic of the event.
+	 * 
+	 * @throws SecurityException If the caller does not have
+	 *            <code>TopicPermission[topic,PUBLISH]</code> for the topic
+	 *            specified in the event.
+	 */
+	void sendEvent(Event event);
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventAdmin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventConstants.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventConstants.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventConstants.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventConstants.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,147 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventConstants.java,v 1.12 2006/03/14 01:21:30 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2005). 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.osgi.service.event;
+
+import org.osgi.framework.Constants;
+
+/**
+ * 
+ * Defines standard names for <code>EventHandler</code> properties.
+ * 
+ * @version $Revision: 1.12 $
+ */
+public interface EventConstants {
+
+	/**
+	 * Service registration property (named <code>event.topic</code>)
+	 * specifying the <code>Event</code> topics of interest to a Event Handler
+	 * service.
+	 * <p>
+	 * Event handlers SHOULD be registered with this property. The value of the
+	 * property is an array of strings that describe the topics in which the
+	 * handler is interested. An asterisk ('*') may be used as a
+	 * trailing wildcard. Event Handlers which do not have a value for this property
+	 * must not receive events. More precisely, the value of each entry in the
+	 * array must conform to the following grammar:
+	 * 
+	 * <pre>
+	 *          topic-description := '*' | topic ( '/*' )?
+	 *          topic := token ( '/' token )*
+	 * </pre>
+	 * 
+	 * @see Event
+	 */
+	public static final String	EVENT_TOPIC			= "event.topics";
+
+	/**
+	 * Service Registration property (named <code>event.filter</code>)
+	 * specifying a filter to further select <code>Event</code> s of interest
+	 * to a Event Handler service.
+	 * <p>
+	 * Event handlers MAY be registered with this property. The value of this
+	 * property is a string containing an LDAP-style filter specification. Any
+	 * of the event's properties may be used in the filter expression. Each
+	 * event handler is notified for any event which belongs to the topics in
+	 * which the handler has expressed an interest. If the event handler is also
+	 * registered with this service property, then the properties of the event
+	 * must also match the filter for the event to be delivered to the event
+	 * handler.
+	 * <p>
+	 * If the filter syntax is invalid, then the Event Handler must be ignored and a 
+	 * warning should be logged.
+	 * 
+	 * @see Event
+	 * @see org.osgi.framework.Filter
+	 */
+	public static final String	EVENT_FILTER		= "event.filter";
+
+	/**
+	 * The Distinguished Name of the bundle relevant to the event.
+	 */
+	public static final String	BUNDLE_SIGNER		= "bundle.signer";
+
+	/**
+	 * The Bundle Symbolic Name of the bundle relevant to the event.
+	 */
+	public static final String	BUNDLE_SYMBOLICNAME	= "bundle.symbolicName";
+
+	/**
+	 * The actual event object. Used when rebroadcasting an event that was sent
+	 * via some other event mechanism.
+	 */
+	public static final String	EVENT				= "event";
+
+	/**
+	 * An exception or error.
+	 */
+	public static final String	EXCEPTION			= "exception";
+
+	/**
+	 * Must be equal to the name of the Exception class.
+	 */
+	public static final String	EXCEPTION_CLASS		= "exception.class";
+	
+	/**
+	 * This constant was released with an incorrect spelling. It has been
+	 * replaced by {@link #EXCEPTION_CLASS}
+	 * @deprecated As of 1.0.1, replaced by EXCEPTION_CLASS
+	 */
+	public static final String	EXECPTION_CLASS		= "exception.class";
+
+	/**
+	 * Must be equal to exception.getMessage()
+	 */
+	public static final String	EXCEPTION_MESSAGE	= "exception.message";
+
+	/**
+	 * A human-readable message that is usually not localized.
+	 */
+	public static final String	MESSAGE				= "message";
+
+	/**
+	 * A service
+	 */
+
+	public static final String	SERVICE				= "service";
+
+	/**
+	 * A service’s id.
+	 */
+	public static final String	SERVICE_ID			= Constants.SERVICE_ID;
+
+	/**
+	 * 
+	 * A service's objectClass
+	 */
+	public static final String	SERVICE_OBJECTCLASS	= "service.objectClass";
+
+	/**
+	 * 
+	 * A service’s persistent identity.
+	 */
+	public static final String	SERVICE_PID			= Constants.SERVICE_PID;
+
+	/**
+	 * 
+	 * The time when the event occurred, as reported by
+	 * System.currentTimeMillis()
+	 */
+	public static final String	TIMESTAMP			= "timestamp";
+
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventHandler.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventHandler.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventHandler.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventHandler.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,67 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventHandler.java,v 1.8 2006/03/14 01:21:30 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2005). 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.osgi.service.event;
+
+/**
+ * Listener for Events.
+ * 
+ * <p>
+ * <code>EventHandler</code> objects are registered with the Framework service
+ * registry and are notified with an <code>Event</code> object when an
+ * event is sent or posted.
+ * <p>
+ * <code>EventHandler</code> objects can inspect the received
+ * <code>Event</code> object to determine its topic and properties.
+ * 
+ * <p>
+ * <code>EventHandler</code> objects must be registered with a service
+ * property {@link EventConstants#EVENT_TOPIC} whose value is the list of
+ * topics in which the event handler is interesed.
+ * <p>
+ * For example:
+ * 
+ * <pre>
+ * String[] topics = new String[] {EventConstants.EVENT_TOPIC, &quot;com/isv/*&quot;};
+ * Hashtable ht = new Hashtable();
+ * ht.put(EVENT_TOPIC, topics);
+ * context.registerService(EventHandler.class.getName(), this, ht);
+ * </pre>
+ * Event Handler services can also be registered with an @link EventConstants#EVENT_FILTER}
+ * service propery to further filter the events. If the syntax of this filter is invalid,
+ * then the Event Handler must be ignored by the Event Admin service. The Event Admin
+ * service should log a warning.
+ * <p>
+ * Security Considerations. Bundles wishing to monitor <code>Event</code>
+ * objects will require <code>ServicePermission[EventHandler,REGISTER]</code>
+ * to register an <code>EventHandler</code> service. The bundle must also have
+ * <code>TopicPermission[topic,SUBSCRIBE]</code> for the topic specified in the
+ * event in order to receive the event.
+ * 
+ * @see Event
+ * 
+ * @version $Revision: 1.8 $
+ */
+public interface EventHandler {
+	/**
+	 * Called by the {@link EventAdmin} service to notify the listener of an event.
+	 * 
+	 * @param event The event that occurred.
+	 */
+	void handleEvent(Event event);
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/EventHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/TopicPermission.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/TopicPermission.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/TopicPermission.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/TopicPermission.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,506 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/TopicPermission.java,v 1.10 2006/03/14 01:21:30 hargrave Exp $
+ * 
+ * Copyright (c) OSGi Alliance (2005). 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.osgi.service.event;
+
+import java.io.IOException;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * A bundle's authority to publish or subscribe to event on a topic.
+ * 
+ * <p>
+ * A topic is a slash-separated string that defines a topic.
+ * <p>
+ * For example:
+ * 
+ * <pre>
+ * org/osgi/service/foo/FooEvent/ACTION
+ * </pre>
+ * 
+ * <p>
+ * <code>TopicPermission</code> has two actions: <code>publish</code> and
+ * <code>subscribe</code>.
+ * 
+ * @version $Revision: 1.10 $
+ */
+public final class TopicPermission extends Permission {
+	static final long			serialVersionUID	= -5855563886961618300L;
+	/**
+	 * The action string <code>publish</code>.
+	 */
+	public final static String	PUBLISH				= "publish";				//$NON-NLS-1$
+	/**
+	 * The action string <code>subscribe</code>.
+	 */
+	public final static String	SUBSCRIBE			= "subscribe";				//$NON-NLS-1$
+	private final static int	ACTION_PUBLISH		= 0x00000001;
+	private final static int	ACTION_SUBSCRIBE	= 0x00000002;
+	private final static int	ACTION_ALL			= ACTION_PUBLISH
+															| ACTION_SUBSCRIBE;
+	private final static int	ACTION_NONE			= 0;
+	/**
+	 * The actions mask.
+	 */
+	private transient int		action_mask			= ACTION_NONE;
+
+	/**
+	 * prefix if the name is wildcarded.
+	 */
+	private transient String	prefix;
+
+	/**
+	 * The actions in canonical form.
+	 * 
+	 * @serial
+	 */
+	private String				actions				= null;
+
+	/**
+	 * Defines the authority to publich and/or subscribe to a topic within the
+	 * EventAdmin service.
+	 * <p>
+	 * The name is specified as a slash-separated string. Wildcards may be used.
+	 * For example:
+	 * 
+	 * <pre>
+	 *    org/osgi/service/fooFooEvent/ACTION
+	 *    com/isv/*
+	 *    *
+	 * </pre>
+	 * 
+	 * <p>
+	 * A bundle that needs to publish events on a topic must have the
+	 * appropriate <code>TopicPermission</code> for that topic; similarly, a
+	 * bundle that needs to subscribe to events on a topic must have the
+	 * appropriate <code>TopicPermssion</code> for that topic.
+	 * <p>
+	 * 
+	 * @param name Topic name.
+	 * @param actions <code>publish</code>,<code>subscribe</code>
+	 *        (canonical order).
+	 */
+	public TopicPermission(String name, String actions) {
+		this(name, getMask(actions));
+	}
+
+	/**
+	 * Package private constructor used by TopicPermissionCollection.
+	 * 
+	 * @param name class name
+	 * @param mask action mask
+	 */
+	TopicPermission(String name, int mask) {
+		super(name);
+		init(name, mask);
+	}
+
+	/**
+	 * Called by constructors and when deserialized.
+	 * 
+	 * @param name topic name
+	 * @param mask action mask
+	 */
+	private void init(String name, int mask) {
+		if ((name == null) || name.length() == 0) {
+			throw new IllegalArgumentException("invalid name"); //$NON-NLS-1$
+		}
+
+		if (name.equals("*")) {
+			prefix = "";
+		}
+		else
+			if (name.endsWith("/*")) {
+				prefix = name.substring(0, name.length() - 1);
+			}
+			else {
+				prefix = null;
+			}
+
+		if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) {
+			throw new IllegalArgumentException("invalid action string"); //$NON-NLS-1$
+		}
+		action_mask = mask;
+	}
+
+	/**
+	 * Parse action string into action mask.
+	 * 
+	 * @param actions Action string.
+	 * @return action mask.
+	 */
+	private static int getMask(String actions) {
+		boolean seencomma = false;
+		int mask = ACTION_NONE;
+		if (actions == null) {
+			return mask;
+		}
+		char[] a = actions.toCharArray();
+		int i = a.length - 1;
+		if (i < 0)
+			return mask;
+		while (i != -1) {
+			char c;
+			// skip whitespace
+			while ((i != -1)
+					&& ((c = a[i]) == ' ' || c == '\r' || c == '\n'
+							|| c == '\f' || c == '\t'))
+				i--;
+			// check for the known strings
+			int matchlen;
+			if (i >= 8 && (a[i - 8] == 's' || a[i - 8] == 'S')
+					&& (a[i - 7] == 'u' || a[i - 7] == 'U')
+					&& (a[i - 6] == 'b' || a[i - 6] == 'B')
+					&& (a[i - 5] == 's' || a[i - 5] == 'S')
+					&& (a[i - 4] == 'c' || a[i - 4] == 'C')
+					&& (a[i - 3] == 'r' || a[i - 3] == 'R')
+					&& (a[i - 2] == 'i' || a[i - 2] == 'I')
+					&& (a[i - 1] == 'b' || a[i - 1] == 'B')
+					&& (a[i] == 'e' || a[i] == 'E')) {
+				matchlen = 9;
+				mask |= ACTION_SUBSCRIBE;
+			}
+			else
+				if (i >= 6 && (a[i - 6] == 'p' || a[i - 6] == 'P')
+						&& (a[i - 5] == 'u' || a[i - 5] == 'U')
+						&& (a[i - 4] == 'b' || a[i - 4] == 'B')
+						&& (a[i - 3] == 'l' || a[i - 3] == 'L')
+						&& (a[i - 2] == 'i' || a[i - 2] == 'I')
+						&& (a[i - 1] == 's' || a[i - 1] == 'S')
+						&& (a[i] == 'h' || a[i] == 'H')) {
+					matchlen = 7;
+					mask |= ACTION_PUBLISH;
+				}
+				else {
+					// parse error
+					throw new IllegalArgumentException("invalid permission: " //$NON-NLS-1$
+							+ actions);
+				}
+			// make sure we didn't just match the tail of a word
+			// like "ackbarfpublish". Also, skip to the comma.
+			seencomma = false;
+			while (i >= matchlen && !seencomma) {
+				switch (a[i - matchlen]) {
+					case ',' :
+						seencomma = true;
+					/* FALLTHROUGH */
+					case ' ' :
+					case '\r' :
+					case '\n' :
+					case '\f' :
+					case '\t' :
+						break;
+					default :
+						throw new IllegalArgumentException(
+								"invalid permission: " + actions); //$NON-NLS-1$
+				}
+				i--;
+			}
+			// point i at the location of the comma minus one (or -1).
+			i -= matchlen;
+		}
+		if (seencomma) {
+			throw new IllegalArgumentException("invalid permission: " + actions); //$NON-NLS-1$
+		}
+		return mask;
+	}
+
+	/**
+	 * Determines if the specified permission is implied by this object.
+	 * 
+	 * <p>
+	 * This method checks that the topic name of the target is implied by the
+	 * topic name of this object. The list of <code>TopicPermission</code>
+	 * actions must either match or allow for the list of the target object to
+	 * imply the target <code>TopicPermission</code> action.
+	 * 
+	 * <pre>
+	 *    x/y/*,&quot;publish&quot; -&gt; x/y/z,&quot;publish&quot; is true
+	 *    *,&quot;subscribe&quot; -&gt; x/y,&quot;subscribe&quot;   is true
+	 *    *,&quot;publish&quot; -&gt; x/y,&quot;subscribe&quot;     is false
+	 *    x/y,&quot;publish&quot; -&gt; x/y/z,&quot;publish&quot;   is false
+	 * </pre>
+	 * 
+	 * @param p The target permission to interrogate.
+	 * @return <code>true</code> if the specified <code>TopicPermission</code>
+	 *         action is implied by this object; <code>false</code> otherwise.
+	 */
+	public boolean implies(Permission p) {
+		if (p instanceof TopicPermission) {
+			TopicPermission target = (TopicPermission) p;
+			if ((action_mask & target.action_mask) == target.action_mask) {
+				if (prefix != null) {
+					return target.getName().startsWith(prefix);
+				}
+
+				return target.getName().equals(getName());
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Returns the canonical string representation of the
+	 * <code>TopicPermission</code> actions.
+	 * 
+	 * <p>
+	 * Always returns present <code>TopicPermission</code> actions in the
+	 * following order: <code>publish</code>,<code>subscribe</code>.
+	 * 
+	 * @return Canonical string representation of the
+	 *         <code>TopicPermission</code> actions.
+	 */
+	public String getActions() {
+		if (actions == null) {
+			StringBuffer sb = new StringBuffer();
+			boolean comma = false;
+			if ((action_mask & ACTION_PUBLISH) == ACTION_PUBLISH) {
+				sb.append(PUBLISH);
+				comma = true;
+			}
+			if ((action_mask & ACTION_SUBSCRIBE) == ACTION_SUBSCRIBE) {
+				if (comma)
+					sb.append(',');
+				sb.append(SUBSCRIBE);
+			}
+			actions = sb.toString();
+		}
+		return actions;
+	}
+
+	/**
+	 * Returns a new <code>PermissionCollection</code> object suitable for
+	 * storing <code>TopicPermission</code> objects.
+	 * 
+	 * @return A new <code>PermissionCollection</code> object.
+	 */
+	public PermissionCollection newPermissionCollection() {
+		return new TopicPermissionCollection();
+	}
+
+	/**
+	 * Determines the equality of two <code>TopicPermission</code> objects.
+	 * 
+	 * This method checks that specified <code>TopicPermission</code> has the same topic name and
+	 * actions as this
+	 * <code>TopicPermission</code> object.
+	 * 
+	 * @param obj The object to test for equality with this
+	 *        <code>TopicPermission</code> object.
+	 * @return <code>true</code> if <code>obj</code> is a
+	 *         <code>TopicPermission</code>, and has the same topic name and
+	 *         actions as this <code>TopicPermission</code> object;
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean equals(Object obj) {
+		if (obj == this) {
+			return true;
+		}
+		if (!(obj instanceof TopicPermission)) {
+			return false;
+		}
+		TopicPermission p = (TopicPermission) obj;
+		return (action_mask == p.action_mask) && getName().equals(p.getName());
+	}
+
+	/**
+	 * Returns the hash code value for this object.
+	 * 
+	 * @return A hash code value for this object.
+	 */
+	public int hashCode() {
+		return getName().hashCode() ^ getActions().hashCode();
+	}
+
+	/**
+	 * Returns the current action mask.
+	 * <p>
+	 * Used by the TopicPermissionCollection class.
+	 * 
+	 * @return Current action mask.
+	 */
+	int getMask() {
+		return action_mask;
+	}
+
+	/**
+	 * WriteObject is called to save the state of this permission object to a
+	 * stream. The actions are serialized, and the superclass takes care of the
+	 * name.
+	 */
+	private synchronized void writeObject(java.io.ObjectOutputStream s)
+			throws IOException {
+		// Write out the actions. The superclass takes care of the name
+		// call getActions to make sure actions field is initialized
+		if (actions == null)
+			getActions();
+		s.defaultWriteObject();
+	}
+
+	/**
+	 * readObject is called to restore the state of this permission from a
+	 * stream.
+	 */
+	private synchronized void readObject(java.io.ObjectInputStream s)
+			throws IOException, ClassNotFoundException {
+		// Read in the action, then initialize the rest
+		s.defaultReadObject();
+		init(getName(), getMask(actions));
+	}
+}
+
+/**
+ * Stores a set of <code>TopicPermission</code> permissions.
+ * 
+ * @see java.security.Permission
+ * @see java.security.Permissions
+ * @see java.security.PermissionCollection
+ */
+final class TopicPermissionCollection extends PermissionCollection {
+	static final long	serialVersionUID	= -614647783533924048L;
+	/**
+	 * Table of permissions.
+	 * 
+	 * @serial
+	 */
+	private Hashtable	permissions;
+	/**
+	 * Boolean saying if "*" is in the collection.
+	 * 
+	 * @serial
+	 */
+	private boolean		all_allowed;
+
+	/**
+	 * Create an empty TopicPermissions object.
+	 * 
+	 */
+	public TopicPermissionCollection() {
+		permissions = new Hashtable();
+		all_allowed = false;
+	}
+
+	/**
+	 * Adds a permission to the <code>TopicPermission</code> objects. The key
+	 * for the hash is the name.
+	 * 
+	 * @param permission The <code>TopicPermission</code> object to add.
+	 * 
+	 * @throws IllegalArgumentException If the permission is not a
+	 *            <code>TopicPermission</code> instance.
+	 * 
+	 * @throws SecurityException If this
+	 *            <code>TopicPermissionCollection</code> object has been
+	 *            marked read-only.
+	 */
+	public void add(Permission permission) {
+		if (!(permission instanceof TopicPermission))
+			throw new IllegalArgumentException("invalid permission: " //$NON-NLS-1$
+					+ permission);
+		if (isReadOnly())
+			throw new SecurityException("attempt to add a Permission to a " //$NON-NLS-1$
+					+ "readonly PermissionCollection"); //$NON-NLS-1$
+		TopicPermission pp = (TopicPermission) permission;
+		String name = pp.getName();
+		TopicPermission existing = (TopicPermission) permissions.get(name);
+		if (existing != null) {
+			int oldMask = existing.getMask();
+			int newMask = pp.getMask();
+			if (oldMask != newMask) {
+				permissions.put(name, new TopicPermission(name, oldMask
+						| newMask));
+			}
+		}
+		else {
+			permissions.put(name, permission);
+		}
+		if (!all_allowed) {
+			if (name.equals("*")) //$NON-NLS-1$
+				all_allowed = true;
+		}
+	}
+
+	/**
+	 * Determines if the specified permissions implies the permissions expressed
+	 * in <code>permission</code>.
+	 * 
+	 * @param permission The Permission object to compare with this
+	 *        <code>TopicPermission</code> object.
+	 * 
+	 * @return <code>true</code> if <code>permission</code> is a proper
+	 *         subset of a permission in the set; <code>false</code>
+	 *         otherwise.
+	 */
+	public boolean implies(Permission permission) {
+		if (!(permission instanceof TopicPermission))
+			return false;
+		TopicPermission pp = (TopicPermission) permission;
+		TopicPermission x;
+		int desired = pp.getMask();
+		int effective = 0;
+		// short circuit if the "*" Permission was added
+		if (all_allowed) {
+			x = (TopicPermission) permissions.get("*"); //$NON-NLS-1$
+			if (x != null) {
+				effective |= x.getMask();
+				if ((effective & desired) == desired)
+					return true;
+			}
+		}
+		// strategy:
+		// Check for full match first. Then work our way up the
+		// name looking for matches on a/b/*
+		String name = pp.getName();
+		x = (TopicPermission) permissions.get(name);
+		if (x != null) {
+			// we have a direct hit!
+			effective |= x.getMask();
+			if ((effective & desired) == desired)
+				return true;
+		}
+		// work our way up the tree...
+		int last, offset;
+		offset = name.length() - 1;
+		while ((last = name.lastIndexOf("/", offset)) != -1) { //$NON-NLS-1$
+			name = name.substring(0, last + 1) + "*"; //$NON-NLS-1$
+			x = (TopicPermission) permissions.get(name);
+			if (x != null) {
+				effective |= x.getMask();
+				if ((effective & desired) == desired)
+					return true;
+			}
+			offset = last - 1;
+		}
+		// we don't have to check for "*" as it was already checked
+		// at the top (all_allowed), so we just return false
+		return false;
+	}
+
+	/**
+	 * Returns an enumeration of all <code>TopicPermission</code> objects in
+	 * the container.
+	 * 
+	 * @return Enumeration of all <code>TopicPermission</code> objects.
+	 */
+	public Enumeration elements() {
+		return permissions.elements();
+	}
+}
\ No newline at end of file

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/TopicPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/package.html
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/package.html?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/package.html (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/package.html Wed Mar 29 13:05:08 2006
@@ -0,0 +1,10 @@
+<!-- $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/package.html,v 1.6 2005/11/01 18:55:09 hargrave Exp $ -->
+<BODY>
+<P>The OSGi Event Admin Specification Version 1.0.1.
+<p>Bundles wishing to use this package must list the package
+in the <TT>Import-Package</TT> header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.service.event; version=1.0.1
+</pre>
+</BODY>

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/packageinfo
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/packageinfo?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/packageinfo (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/packageinfo Wed Mar 29 13:05:08 2006
@@ -0,0 +1 @@
+version 1.0.1

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/event/packageinfo
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/http/HttpContext.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/http/HttpContext.java?rev=389891&view=auto
==============================================================================
--- incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/http/HttpContext.java (added)
+++ incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/http/HttpContext.java Wed Mar 29 13:05:08 2006
@@ -0,0 +1,167 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.http/src/org/osgi/service/http/HttpContext.java,v 1.9 2006/03/14 01:20:39 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). 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.osgi.service.http;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This interface defines methods that the Http Service may call to get
+ * information about a registration.
+ * 
+ * <p>
+ * Servlets and resources may be registered with an <code>HttpContext</code>
+ * object; if no <code>HttpContext</code> object is specified, a default
+ * <code>HttpContext</code> object is used. Servlets that are registered using the
+ * same <code>HttpContext</code> object will share the same
+ * <code>ServletContext</code> object.
+ * 
+ * <p>
+ * This interface is implemented by users of the <code>HttpService</code>.
+ * 
+ * @version $Revision: 1.9 $
+ */
+public interface HttpContext {
+	/**
+	 * <code>HttpServletRequest</code> attribute specifying the name of the
+	 * authenticated user. The value of the attribute can be retrieved by
+	 * <code>HttpServletRequest.getRemoteUser</code>. This attribute name is
+	 * <code>org.osgi.service.http.authentication.remote.user</code>.
+	 * 
+	 * @since 1.1
+	 */
+	public static final String	REMOTE_USER			= "org.osgi.service.http.authentication.remote.user";
+	/**
+	 * <code>HttpServletRequest</code> attribute specifying the scheme used in
+	 * authentication. The value of the attribute can be retrieved by
+	 * <code>HttpServletRequest.getAuthType</code>. This attribute name is
+	 * <code>org.osgi.service.http.authentication.type</code>.
+	 * 
+	 * @since 1.1
+	 */
+	public static final String	AUTHENTICATION_TYPE	= "org.osgi.service.http.authentication.type";
+	/**
+	 * <code>HttpServletRequest</code> attribute specifying the
+	 * <code>Authorization</code> object obtained from the
+	 * <code>org.osgi.service.useradmin.UserAdmin</code> service. The value of the
+	 * attribute can be retrieved by
+	 * <code>HttpServletRequest.getAttribute(HttpContext.AUTHORIZATION)</code>.
+	 * This attribute name is <code>org.osgi.service.useradmin.authorization</code>.
+	 * 
+	 * @since 1.1
+	 */
+	public static final String	AUTHORIZATION		= "org.osgi.service.useradmin.authorization";
+
+	/**
+	 * Handles security for the specified request.
+	 * 
+	 * <p>
+	 * The Http Service calls this method prior to servicing the specified
+	 * request. This method controls whether the request is processed in the
+	 * normal manner or an error is returned.
+	 * 
+	 * <p>
+	 * If the request requires authentication and the Authorization header in
+	 * the request is missing or not acceptable, then this method should set the
+	 * WWW-Authenticate header in the response object, set the status in the
+	 * response object to Unauthorized(401) and return <code>false</code>. See
+	 * also RFC 2617: <i>HTTP Authentication: Basic and Digest Access
+	 * Authentication </i> (available at http://www.ietf.org/rfc/rfc2617.txt).
+	 * 
+	 * <p>
+	 * If the request requires a secure connection and the <code>getScheme</code>
+	 * method in the request does not return 'https' or some other acceptable
+	 * secure protocol, then this method should set the status in the response
+	 * object to Forbidden(403) and return <code>false</code>.
+	 * 
+	 * <p>
+	 * When this method returns <code>false</code>, the Http Service will send
+	 * the response back to the client, thereby completing the request. When
+	 * this method returns <code>true</code>, the Http Service will proceed with
+	 * servicing the request.
+	 * 
+	 * <p>
+	 * If the specified request has been authenticated, this method must set the
+	 * {@link #AUTHENTICATION_TYPE}request attribute to the type of
+	 * authentication used, and the {@link #REMOTE_USER}request attribute to
+	 * the remote user (request attributes are set using the
+	 * <code>setAttribute</code> method on the request). If this method does not
+	 * perform any authentication, it must not set these attributes.
+	 * 
+	 * <p>
+	 * If the authenticated user is also authorized to access certain resources,
+	 * this method must set the {@link #AUTHORIZATION}request attribute to the
+	 * <code>Authorization</code> object obtained from the
+	 * <code>org.osgi.service.useradmin.UserAdmin</code> service.
+	 * 
+	 * <p>
+	 * The servlet responsible for servicing the specified request determines
+	 * the authentication type and remote user by calling the
+	 * <code>getAuthType</code> and <code>getRemoteUser</code> methods,
+	 * respectively, on the request.
+	 * 
+	 * @param request the HTTP request
+	 * @param response the HTTP response
+	 * @return <code>true</code> if the request should be serviced, <code>false</code>
+	 *         if the request should not be serviced and Http Service will send
+	 *         the response back to the client.
+	 * @throws java.io.IOException may be thrown by this method. If this
+	 *            occurs, the Http Service will terminate the request and close
+	 *            the socket.
+	 */
+	public boolean handleSecurity(HttpServletRequest request,
+			HttpServletResponse response) throws IOException;
+
+	/**
+	 * Maps a resource name to a URL.
+	 * 
+	 * <p>
+	 * Called by the Http Service to map a resource name to a URL. For servlet
+	 * registrations, Http Service will call this method to support the
+	 * <code>ServletContext</code> methods <code>getResource</code> and
+	 * <code>getResourceAsStream</code>. For resource registrations, Http Service
+	 * will call this method to locate the named resource. The context can
+	 * control from where resources come. For example, the resource can be
+	 * mapped to a file in the bundle's persistent storage area via
+	 * <code>bundleContext.getDataFile(name).toURL()</code> or to a resource in
+	 * the context's bundle via <code>getClass().getResource(name)</code>
+	 * 
+	 * @param name the name of the requested resource
+	 * @return URL that Http Service can use to read the resource or
+	 *         <code>null</code> if the resource does not exist.
+	 */
+	public URL getResource(String name);
+
+	/**
+	 * Maps a name to a MIME type.
+	 * 
+	 * Called by the Http Service to determine the MIME type for the name. For
+	 * servlet registrations, the Http Service will call this method to support
+	 * the <code>ServletContext</code> method <code>getMimeType</code>. For
+	 * resource registrations, the Http Service will call this method to
+	 * determine the MIME type for the Content-Type header in the response.
+	 * 
+	 * @param name determine the MIME type for this name.
+	 * @return MIME type (e.g. text/html) of the name or <code>null</code> to
+	 *         indicate that the Http Service should determine the MIME type
+	 *         itself.
+	 */
+	public String getMimeType(String name);
+}

Propchange: incubator/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/http/HttpContext.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message