You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ma...@apache.org on 2008/01/30 17:46:39 UTC
svn commit: r616813 [6/9] - in /felix/trunk/deploymentadmin: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/felix/
src/main/java/org/apache/felix/deploymentadmin/
src/main/java/org/apache/felix/de...
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/ResourceProcessorException.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/ResourceProcessorException.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/ResourceProcessorException.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/ResourceProcessorException.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,123 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.deploymentadmin/src/org/osgi/service/deploymentadmin/spi/ResourceProcessorException.java,v 1.7 2006/07/12 21:22:10 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.deploymentadmin.spi;
+
+import java.io.InputStream;
+
+/**
+ * Checked exception received when something fails during a call to a Resource
+ * Processor. A <code>ResourceProcessorException</code> always contains an error
+ * code (one of the constants specified in this class), and may optionally contain
+ * the textual description of the error condition and a nested cause exception.
+ */
+public class ResourceProcessorException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 9135007015668223386L;
+
+ /**
+ * Resource Processors are allowed to raise an exception with this error code
+ * to indicate that the processor is not able to commit the operations it made
+ * since the last call of {@link ResourceProcessor#begin(DeploymentSession)} method.<p>
+ *
+ * Only the {@link ResourceProcessor#prepare()} method is allowed to throw exception
+ * with this error code.
+ */
+ public static final int CODE_PREPARE = 1;
+
+ /**
+ * An artifact of any resource already exists.<p>
+ *
+ * Only the {@link ResourceProcessor#process(String, InputStream)} method
+ * is allowed to throw exception with this error code.
+ */
+ public static final int CODE_RESOURCE_SHARING_VIOLATION = 461;
+
+ /**
+ * Other error condition.<p>
+ *
+ * All Resource Processor methods which throw <code>ResourceProcessorException</code>
+ * is allowed throw an exception with this erro code if the error condition cannot be
+ * categorized.
+ */
+ public static final int CODE_OTHER_ERROR = 463;
+
+ private final int code;
+ private final String message;
+ private final Throwable cause;
+
+ /**
+ * Create an instance of the exception.
+ *
+ * @param code The error code of the failure. Code should be one of the
+ * predefined integer values (<code>CODE_X</code>).
+ * @param message Message associated with the exception
+ * @param cause the originating exception
+ */
+ public ResourceProcessorException(int code, String message, Throwable cause) {
+ this.code = code;
+ this.message = message;
+ this.cause = cause;
+ }
+
+ /**
+ * Create an instance of the exception. Cause exception is implicitly set to
+ * null.
+ *
+ * @param code The error code of the failure. Code should be one of the
+ * predefined integer values (<code>CODE_X</code>).
+ * @param message Message associated with the exception
+ */
+ public ResourceProcessorException(int code, String message) {
+ this(code, message, null);
+ }
+
+ /**
+ * Create an instance of the exception. Cause exception and message are
+ * implicitly set to null.
+ *
+ * @param code The error code of the failure. Code should be one of the
+ * predefined integer values (<code>CODE_X</code>).
+ */
+ public ResourceProcessorException(int code) {
+ this(code, null, null);
+ }
+
+ /**
+ * @return Returns the cause.
+ */
+ public Throwable getCause() {
+ return cause;
+ }
+
+ /**
+ * @return Returns the code.
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * @return Returns the message.
+ */
+ public String getMessage() {
+ return message;
+ }
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/package.html?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/package.html (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/package.html Wed Jan 30 08:46:24 2008
@@ -0,0 +1,12 @@
+<!-- $Header: /cvshome/build/org.osgi.service.deploymentadmin/src/org/osgi/service/deploymentadmin/spi/package.html,v 1.3 2006/07/12 21:07:12 hargrave Exp $ -->
+<BODY>
+<p>Deployment Admin SPI Package Version 1.0.
+The SPI is used by Resource Processors.
+<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.deploymentadmin.spi; version=1.0
+</pre>
+</BODY>
+</BODY>
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/packageinfo?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/packageinfo (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/deploymentadmin/spi/packageinfo Wed Jan 30 08:46:24 2008
@@ -0,0 +1 @@
+version 1.0
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/Event.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/Event.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/Event.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/Event.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,195 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/Event.java,v 1.8 2006/07/12 13:17:04 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.8 $
+ */
+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 tokenAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; //$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) { // token must contain at least one character
+ throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+ }
+ for (int i = 0; i < length; i++) { // each character in the token must be from the token alphabet
+ if (tokenAlphabet.indexOf(token.charAt(i)) == -1) { //$NON-NLS-1$
+ throw new IllegalArgumentException("invalid topic"); //$NON-NLS-1$
+ }
+ }
+ }
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventAdmin.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventAdmin.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventAdmin.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,53 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventAdmin.java,v 1.6 2006/06/16 16:31:48 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.6 $
+ */
+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);
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventConstants.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventConstants.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventConstants.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventConstants.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,163 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventConstants.java,v 1.14 2006/07/12 21:06:18 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.14 $
+ */
+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 Bundle id of the bundle relevant to the event.
+ *
+ * @since 1.1
+ */
+ public static final String BUNDLE_ID = "bundle.id";
+
+ /**
+ * The Bundle object of the bundle relevant to the event.
+ *
+ * @since 1.1
+ */
+ public static final String BUNDLE = "bundle";
+
+ /**
+ * 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.
+ *
+ * @since 1.1
+ */
+ public static final String EXCEPTION_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";
+
+ /**
+ * This constant was released with an incorrect spelling. It has been
+ * replaced by {@link #EXCEPTION_CLASS}
+ *
+ * @deprecated As of 1.1, replaced by EXCEPTION_CLASS
+ */
+ public static final String EXECPTION_CLASS = "exception.class";
+}
\ No newline at end of file
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventHandler.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventHandler.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/EventHandler.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,67 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventHandler.java,v 1.10 2006/07/11 16:43:59 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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, "com/isv/*"};
+ * 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.10 $
+ */
+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);
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/TopicPermission.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/TopicPermission.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/TopicPermission.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/TopicPermission.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,506 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/TopicPermission.java,v 1.11 2006/06/16 16:31:48 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.11 $
+ */
+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/*,"publish" -> x/y/z,"publish" is true
+ * *,"subscribe" -> x/y,"subscribe" is true
+ * *,"publish" -> x/y,"subscribe" is false
+ * x/y,"publish" -> x/y/z,"publish" 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();
+ }
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/package.html?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/package.html (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/package.html Wed Jan 30 08:46:24 2008
@@ -0,0 +1,10 @@
+<!-- $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/package.html,v 1.8 2006/07/12 21:07:18 hargrave Exp $ -->
+<BODY>
+<p>Event Admin Package Version 1.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.1
+</pre>
+</BODY>
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/packageinfo?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/packageinfo (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/event/packageinfo Wed Jan 30 08:46:24 2008
@@ -0,0 +1 @@
+version 1.1
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectionFactory.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectionFactory.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectionFactory.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,62 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.io/src/org/osgi/service/io/ConnectionFactory.java,v 1.9 2006/07/12 21:22:12 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2002, 2006). 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.io;
+
+import java.io.IOException;
+
+import javax.microedition.io.Connection;
+
+/**
+ * A Connection Factory service is called by the implementation of the Connector
+ * Service to create <code>javax.microedition.io.Connection</code> objects which
+ * implement the scheme named by <code>IO_SCHEME</code>.
+ *
+ * When a <code>ConnectorService.open</code> method is called, the implementation
+ * of the Connector Service will examine the specified name for a scheme. The
+ * Connector Service will then look for a Connection Factory service which is
+ * registered with the service property <code>IO_SCHEME</code> which matches the
+ * scheme. The {@link #createConnection} method of the selected Connection
+ * Factory will then be called to create the actual <code>Connection</code>
+ * object.
+ *
+ * @version $Revision: 1.9 $
+ */
+public interface ConnectionFactory {
+ /**
+ * Service property containing the scheme(s) for which this Connection
+ * Factory can create <code>Connection</code> objects. This property is of
+ * type <code>String[]</code>.
+ */
+ public static final String IO_SCHEME = "io.scheme";
+
+ /**
+ * Create a new <code>Connection</code> object for the specified URI.
+ *
+ * @param name The full URI passed to the <code>ConnectorService.open</code>
+ * method
+ * @param mode The mode parameter passed to the
+ * <code>ConnectorService.open</code> method
+ * @param timeouts The timeouts parameter passed to the
+ * <code>ConnectorService.open</code> method
+ * @return A new <code>javax.microedition.io.Connection</code> object.
+ * @throws IOException If a <code>javax.microedition.io.Connection</code>
+ * object can not not be created.
+ */
+ public Connection createConnection(String name, int mode, boolean timeouts)
+ throws IOException;
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectorService.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectorService.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectorService.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/ConnectorService.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,167 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.io/src/org/osgi/service/io/ConnectorService.java,v 1.9 2006/07/12 21:22:12 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2002, 2006). 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.io;
+
+import java.io.*;
+
+import javax.microedition.io.Connection;
+import javax.microedition.io.Connector;
+
+/**
+ * The Connector Service should be called to create and open
+ * <code>javax.microedition.io.Connection</code> objects.
+ *
+ * When an <code>open*</code> method is called, the implementation of the
+ * Connector Service will examine the specified name for a scheme. The Connector
+ * Service will then look for a Connection Factory service which is registered
+ * with the service property <code>IO_SCHEME</code> which matches the scheme. The
+ * <code>createConnection</code> method of the selected Connection Factory will
+ * then be called to create the actual <code>Connection</code> object.
+ *
+ * <p>
+ * If more than one Connection Factory service is registered for a particular
+ * scheme, the service with the highest ranking (as specified in its
+ * <code>service.ranking</code> property) is called. If there is a tie in ranking,
+ * the service with the lowest service ID (as specified in its
+ * <code>service.id</code> property), that is the service that was registered
+ * first, is called. This is the same algorithm used by
+ * <code>BundleContext.getServiceReference</code>.
+ *
+ * @version $Revision: 1.9 $
+ */
+public interface ConnectorService {
+ /**
+ * Read access mode.
+ *
+ * @see "javax.microedition.io.Connector.READ"
+ */
+ public static final int READ = Connector.READ;
+ /**
+ * Write access mode.
+ *
+ * @see "javax.microedition.io.Connector.WRITE"
+ */
+ public static final int WRITE = Connector.WRITE;
+ /**
+ * Read/Write access mode.
+ *
+ * @see "javax.microedition.io.Connector.READ_WRITE"
+ */
+ public static final int READ_WRITE = Connector.READ_WRITE;
+
+ /**
+ * Create and open a <code>Connection</code> object for the specified name.
+ *
+ * @param name The URI for the connection.
+ * @return A new <code>javax.microedition.io.Connection</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.open(String name)"
+ */
+ public Connection open(String name) throws IOException;
+
+ /**
+ * Create and open a <code>Connection</code> object for the specified name and
+ * access mode.
+ *
+ * @param name The URI for the connection.
+ * @param mode The access mode.
+ * @return A new <code>javax.microedition.io.Connection</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.open(String name, int mode)"
+ */
+ public Connection open(String name, int mode) throws IOException;
+
+ /**
+ * Create and open a <code>Connection</code> object for the specified name,
+ * access mode and timeouts.
+ *
+ * @param name The URI for the connection.
+ * @param mode The access mode.
+ * @param timeouts A flag to indicate that the caller wants timeout
+ * exceptions.
+ * @return A new <code>javax.microedition.io.Connection</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "<code>javax.microedition.io.Connector.open</code>"
+ */
+ public Connection open(String name, int mode, boolean timeouts)
+ throws IOException;
+
+ /**
+ * Create and open an <code>InputStream</code> object for the specified name.
+ *
+ * @param name The URI for the connection.
+ * @return An <code>InputStream</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.openInputStream(String name)"
+ */
+ public InputStream openInputStream(String name) throws IOException;
+
+ /**
+ * Create and open a <code>DataInputStream</code> object for the specified
+ * name.
+ *
+ * @param name The URI for the connection.
+ * @return A <code>DataInputStream</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.openDataInputStream(String name)"
+ */
+ public DataInputStream openDataInputStream(String name) throws IOException;
+
+ /**
+ * Create and open an <code>OutputStream</code> object for the specified name.
+ *
+ * @param name The URI for the connection.
+ * @return An <code>OutputStream</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.openOutputStream(String name)"
+ */
+ public OutputStream openOutputStream(String name) throws IOException;
+
+ /**
+ * Create and open a <code>DataOutputStream</code> object for the specified
+ * name.
+ *
+ * @param name The URI for the connection.
+ * @return A <code>DataOutputStream</code> object.
+ * @throws IllegalArgumentException If a parameter is invalid.
+ * @throws javax.microedition.io.ConnectionNotFoundException If the
+ * connection cannot be found.
+ * @throws IOException If some other kind of I/O error occurs.
+ * @see "javax.microedition.io.Connector.openDataOutputStream(String name)"
+ */
+ public DataOutputStream openDataOutputStream(String name)
+ throws IOException;
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/package.html?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/package.html (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/package.html Wed Jan 30 08:46:24 2008
@@ -0,0 +1,10 @@
+<!-- $Header: /cvshome/build/org.osgi.service.io/src/org/osgi/service/io/package.html,v 1.3 2006/07/12 21:07:06 hargrave Exp $ -->
+<BODY>
+<p>IO Connector Package Version 1.0.
+<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.io; version=1.0, javax.microedition.io
+</pre>
+</BODY>
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/packageinfo?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/packageinfo (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/io/packageinfo Wed Jan 30 08:46:24 2008
@@ -0,0 +1 @@
+version 1.0
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogEntry.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogEntry.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogEntry.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogEntry.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,109 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogEntry.java,v 1.9 2006/06/16 16:31:49 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2006). 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.log;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Provides methods to access the information contained in an individual Log
+ * Service log entry.
+ *
+ * <p>
+ * A <code>LogEntry</code> object may be acquired from the
+ * <code>LogReaderService.getLog</code> method or by registering a
+ * <code>LogListener</code> object.
+ *
+ * @version $Revision: 1.9 $
+ * @see LogReaderService#getLog
+ * @see LogListener
+ */
+public interface LogEntry {
+ /**
+ * Returns the bundle that created this <code>LogEntry</code> object.
+ *
+ * @return The bundle that created this <code>LogEntry</code> object;
+ * <code>null</code> if no bundle is associated with this
+ * <code>LogEntry</code> object.
+ */
+ public Bundle getBundle();
+
+ /**
+ * Returns the <code>ServiceReference</code> object for the service associated
+ * with this <code>LogEntry</code> object.
+ *
+ * @return <code>ServiceReference</code> object for the service associated
+ * with this <code>LogEntry</code> object; <code>null</code> if no
+ * <code>ServiceReference</code> object was provided.
+ */
+ public ServiceReference getServiceReference();
+
+ /**
+ * Returns the severity level of this <code>LogEntry</code> object.
+ *
+ * <p>
+ * This is one of the severity levels defined by the <code>LogService</code>
+ * interface.
+ *
+ * @return Severity level of this <code>LogEntry</code> object.
+ *
+ * @see LogService#LOG_ERROR
+ * @see LogService#LOG_WARNING
+ * @see LogService#LOG_INFO
+ * @see LogService#LOG_DEBUG
+ */
+ public int getLevel();
+
+ /**
+ * Returns the human readable message associated with this <code>LogEntry</code>
+ * object.
+ *
+ * @return <code>String</code> containing the message associated with this
+ * <code>LogEntry</code> object.
+ */
+ public String getMessage();
+
+ /**
+ * Returns the exception object associated with this <code>LogEntry</code>
+ * object.
+ *
+ * <p>
+ * In some implementations, the returned exception may not be the original
+ * exception. To avoid references to a bundle defined exception class, thus
+ * preventing an uninstalled bundle from being garbage collected, the Log
+ * Service may return an exception object of an implementation defined
+ * Throwable subclass. The returned object will attempt to provide as much
+ * information as possible from the original exception object such as the
+ * message and stack trace.
+ *
+ * @return <code>Throwable</code> object of the exception associated with this
+ * <code>LogEntry</code>;<code>null</code> if no exception is
+ * associated with this <code>LogEntry</code> object.
+ */
+ public Throwable getException();
+
+ /**
+ * Returns the value of <code>currentTimeMillis()</code> at the time this
+ * <code>LogEntry</code> object was created.
+ *
+ * @return The system time in milliseconds when this <code>LogEntry</code>
+ * object was created.
+ * @see "System.currentTimeMillis()"
+ */
+ public long getTime();
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogListener.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogListener.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogListener.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,51 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogListener.java,v 1.9 2006/06/16 16:31:49 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2006). 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.log;
+
+import java.util.EventListener;
+
+/**
+ * Subscribes to <code>LogEntry</code> objects from the <code>LogReaderService</code>.
+ *
+ * <p>
+ * A <code>LogListener</code> object may be registered with the Log Reader Service
+ * using the <code>LogReaderService.addLogListener</code> method. After the
+ * listener is registered, the <code>logged</code> method will be called for each
+ * <code>LogEntry</code> object created. The <code>LogListener</code> object may be
+ * unregistered by calling the <code>LogReaderService.removeLogListener</code>
+ * method.
+ *
+ * @version $Revision: 1.9 $
+ * @see LogReaderService
+ * @see LogEntry
+ * @see LogReaderService#addLogListener(LogListener)
+ * @see LogReaderService#removeLogListener(LogListener)
+ */
+public interface LogListener extends EventListener {
+ /**
+ * Listener method called for each LogEntry object created.
+ *
+ * <p>
+ * As with all event listeners, this method should return to its caller as
+ * soon as possible.
+ *
+ * @param entry A <code>LogEntry</code> object containing log information.
+ * @see LogEntry
+ */
+ public void logged(LogEntry entry);
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogReaderService.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogReaderService.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogReaderService.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogReaderService.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,98 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogReaderService.java,v 1.10 2006/06/16 16:31:49 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2006). 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.log;
+
+import java.util.Enumeration;
+
+/**
+ * Provides methods to retrieve <code>LogEntry</code> objects from the log.
+ * <p>
+ * There are two ways to retrieve <code>LogEntry</code> objects:
+ * <ul>
+ * <li>The primary way to retrieve <code>LogEntry</code> objects is to register a
+ * <code>LogListener</code> object whose <code>LogListener.logged</code> method will
+ * be called for each entry added to the log.
+ * <li>To retrieve past <code>LogEntry</code> objects, the <code>getLog</code>
+ * method can be called which will return an <code>Enumeration</code> of all
+ * <code>LogEntry</code> objects in the log.
+ *
+ * @version $Revision: 1.10 $
+ * @see LogEntry
+ * @see LogListener
+ * @see LogListener#logged(LogEntry)
+ */
+public interface LogReaderService {
+ /**
+ * Subscribes to <code>LogEntry</code> objects.
+ *
+ * <p>
+ * This method registers a <code>LogListener</code> object with the Log Reader
+ * Service. The <code>LogListener.logged(LogEntry)</code> method will be
+ * called for each <code>LogEntry</code> object placed into the log.
+ *
+ * <p>
+ * When a bundle which registers a <code>LogListener</code> object is stopped
+ * or otherwise releases the Log Reader Service, the Log Reader Service must
+ * remove all of the bundle's listeners.
+ *
+ * <p>
+ * If this Log Reader Service's list of listeners already contains a
+ * listener <code>l</code> such that <code>(l==listener)</code>, this method
+ * does nothing.
+ *
+ * @param listener A <code>LogListener</code> object to register; the
+ * <code>LogListener</code> object is used to receive <code>LogEntry</code>
+ * objects.
+ * @see LogListener
+ * @see LogEntry
+ * @see LogListener#logged(LogEntry)
+ */
+ public void addLogListener(LogListener listener);
+
+ /**
+ * Unsubscribes to <code>LogEntry</code> objects.
+ *
+ * <p>
+ * This method unregisters a <code>LogListener</code> object from the Log
+ * Reader Service.
+ *
+ * <p>
+ * If <code>listener</code> is not contained in this Log Reader Service's list
+ * of listeners, this method does nothing.
+ *
+ * @param listener A <code>LogListener</code> object to unregister.
+ * @see LogListener
+ */
+ public void removeLogListener(LogListener listener);
+
+ /**
+ * Returns an <code>Enumeration</code> of all <code>LogEntry</code> objects in
+ * the log.
+ *
+ * <p>
+ * Each element of the enumeration is a <code>LogEntry</code> object, ordered
+ * with the most recent entry first. Whether the enumeration is of all
+ * <code>LogEntry</code> objects since the Log Service was started or some
+ * recent past is implementation-specific. Also implementation-specific is
+ * whether informational and debug <code>LogEntry</code> objects are included
+ * in the enumeration.
+ * @return An <code>Enumeration</code> of all <code>LogEntry</code> objects in
+ * the log.
+ */
+ public Enumeration getLog();
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogService.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogService.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogService.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/LogService.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,156 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogService.java,v 1.9 2006/06/16 16:31:49 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2006). 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.log;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Provides methods for bundles to write messages to the log.
+ *
+ * <p>
+ * <code>LogService</code> methods are provided to log messages; optionally with a
+ * <code>ServiceReference</code> object or an exception.
+ *
+ * <p>
+ * Bundles must log messages in the OSGi environment with a severity level
+ * according to the following hierarchy:
+ * <ol>
+ * <li>{@link #LOG_ERROR}
+ * <li>{@link #LOG_WARNING}
+ * <li>{@link #LOG_INFO}
+ * <li>{@link #LOG_DEBUG}
+ * </ol>
+ *
+ * @version $Revision: 1.9 $
+ */
+public interface LogService {
+ /**
+ * An error message (Value 1).
+ *
+ * <p>
+ * This log entry indicates the bundle or service may not be functional.
+ */
+ public static final int LOG_ERROR = 1;
+ /**
+ * A warning message (Value 2).
+ *
+ * <p>
+ * This log entry indicates a bundle or service is still functioning but may
+ * experience problems in the future because of the warning condition.
+ */
+ public static final int LOG_WARNING = 2;
+ /**
+ * An informational message (Value 3).
+ *
+ * <p>
+ * This log entry may be the result of any change in the bundle or service
+ * and does not indicate a problem.
+ */
+ public static final int LOG_INFO = 3;
+ /**
+ * A debugging message (Value 4).
+ *
+ * <p>
+ * This log entry is used for problem determination and may be irrelevant to
+ * anyone but the bundle developer.
+ */
+ public static final int LOG_DEBUG = 4;
+
+ /**
+ * Logs a message.
+ *
+ * <p>
+ * The <code>ServiceReference</code> field and the <code>Throwable</code> field
+ * of the <code>LogEntry</code> object will be set to <code>null</code>.
+ *
+ * @param level The severity of the message. This should be one of the
+ * defined log levels but may be any integer that is interpreted in a
+ * user defined way.
+ * @param message Human readable string describing the condition or
+ * <code>null</code>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(int level, String message);
+
+ /**
+ * Logs a message with an exception.
+ *
+ * <p>
+ * The <code>ServiceReference</code> field of the <code>LogEntry</code> object
+ * will be set to <code>null</code>.
+ *
+ * @param level The severity of the message. This should be one of the
+ * defined log levels but may be any integer that is interpreted in a
+ * user defined way.
+ * @param message The human readable string describing the condition or
+ * <code>null</code>.
+ * @param exception The exception that reflects the condition or
+ * <code>null</code>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(int level, String message, Throwable exception);
+
+ /**
+ * Logs a message associated with a specific <code>ServiceReference</code>
+ * object.
+ *
+ * <p>
+ * The <code>Throwable</code> field of the <code>LogEntry</code> will be set to
+ * <code>null</code>.
+ *
+ * @param sr The <code>ServiceReference</code> object of the service that this
+ * message is associated with or <code>null</code>.
+ * @param level The severity of the message. This should be one of the
+ * defined log levels but may be any integer that is interpreted in a
+ * user defined way.
+ * @param message Human readable string describing the condition or
+ * <code>null</code>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(ServiceReference sr, int level, String message);
+
+ /**
+ * Logs a message with an exception associated and a
+ * <code>ServiceReference</code> object.
+ *
+ * @param sr The <code>ServiceReference</code> object of the service that this
+ * message is associated with.
+ * @param level The severity of the message. This should be one of the
+ * defined log levels but may be any integer that is interpreted in a
+ * user defined way.
+ * @param message Human readable string describing the condition or
+ * <code>null</code>.
+ * @param exception The exception that reflects the condition or
+ * <code>null</code>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(ServiceReference sr, int level, String message,
+ Throwable exception);
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/package.html?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/package.html (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/package.html Wed Jan 30 08:46:24 2008
@@ -0,0 +1 @@
+<!-- $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/package.html,v 1.4 2006/07/12 21:07:15 hargrave Exp $ -->
<BODY>
<p>Log Service Package Version 1.3.
<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.log; version=1.3
</pre>
</BODY>
\ No newline at end of file
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/packageinfo?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/packageinfo (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/log/packageinfo Wed Jan 30 08:46:24 2008
@@ -0,0 +1 @@
+version 1.3
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/AttributeDefinition.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/AttributeDefinition.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/AttributeDefinition.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/AttributeDefinition.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,279 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.metatype/src/org/osgi/service/metatype/AttributeDefinition.java,v 1.13 2006/06/16 16:31:23 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2006). 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.metatype;
+
+/**
+ * An interface to describe an attribute.
+ *
+ * <p>
+ * An <code>AttributeDefinition</code> object defines a description of the data
+ * type of a property/attribute.
+ *
+ * @version $Revision: 1.13 $
+ */
+public interface AttributeDefinition {
+ /**
+ * The <code>STRING</code> (1) type.
+ *
+ * <p>
+ * Attributes of this type should be stored as <code>String</code>,
+ * <code>Vector</code> with <code>String</code> or <code>String[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int STRING = 1;
+ /**
+ * The <code>LONG</code> (2) type.
+ *
+ * Attributes of this type should be stored as <code>Long</code>,
+ * <code>Vector</code> with <code>Long</code> or <code>long[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int LONG = 2;
+ /**
+ * The <code>INTEGER</code> (3) type.
+ *
+ * Attributes of this type should be stored as <code>Integer</code>,
+ * <code>Vector</code> with <code>Integer</code> or <code>int[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int INTEGER = 3;
+ /**
+ * The <code>SHORT</code> (4) type.
+ *
+ * Attributes of this type should be stored as <code>Short</code>,
+ * <code>Vector</code> with <code>Short</code> or <code>short[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int SHORT = 4;
+ /**
+ * The <code>CHARACTER</code> (5) type.
+ *
+ * Attributes of this type should be stored as <code>Character</code>,
+ * <code>Vector</code> with <code>Character</code> or <code>char[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int CHARACTER = 5;
+ /**
+ * The <code>BYTE</code> (6) type.
+ *
+ * Attributes of this type should be stored as <code>Byte</code>,
+ * <code>Vector</code> with <code>Byte</code> or <code>byte[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int BYTE = 6;
+ /**
+ * The <code>DOUBLE</code> (7) type.
+ *
+ * Attributes of this type should be stored as <code>Double</code>,
+ * <code>Vector</code> with <code>Double</code> or <code>double[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int DOUBLE = 7;
+ /**
+ * The <code>FLOAT</code> (8) type.
+ *
+ * Attributes of this type should be stored as <code>Float</code>,
+ * <code>Vector</code> with <code>Float</code> or <code>float[]</code> objects,
+ * depending on the <code>getCardinality()</code> value.
+ */
+ public static final int FLOAT = 8;
+ /**
+ * The <code>BIGINTEGER</code> (9) type.
+ *
+ * Attributes of this type should be stored as <code>BigInteger</code>,
+ * <code>Vector</code> with <code>BigInteger</code> or <code>BigInteger[]</code>
+ * objects, depending on the <code>getCardinality()</code> value.
+ *
+ * @deprecated As of 1.1.
+ */
+ public static final int BIGINTEGER = 9;
+ /**
+ * The <code>BIGDECIMAL</code> (10) type.
+ *
+ * Attributes of this type should be stored as <code>BigDecimal</code>,
+ * <code>Vector</code> with <code>BigDecimal</code> or <code>BigDecimal[]</code>
+ * objects depending on <code>getCardinality()</code>.
+ *
+ * @deprecated As of 1.1.
+ */
+ public static final int BIGDECIMAL = 10;
+ /**
+ * The <code>BOOLEAN</code> (11) type.
+ *
+ * Attributes of this type should be stored as <code>Boolean</code>,
+ * <code>Vector</code> with <code>Boolean</code> or <code>boolean[]</code> objects
+ * depending on <code>getCardinality()</code>.
+ */
+ public static final int BOOLEAN = 11;
+
+ /**
+ * Get the name of the attribute. This name may be localized.
+ *
+ * @return The localized name of the definition.
+ */
+ public String getName();
+
+ /**
+ * Unique identity for this attribute.
+ *
+ * Attributes share a global namespace in the registry. E.g. an attribute
+ * <code>cn</code> or <code>commonName</code> must always be a <code>String</code>
+ * and the semantics are always a name of some object. They share this
+ * aspect with LDAP/X.500 attributes. In these standards the OSI Object
+ * Identifier (OID) is used to uniquely identify an attribute. If such an
+ * OID exists, (which can be requested at several standard organisations and
+ * many companies already have a node in the tree) it can be returned here.
+ * Otherwise, a unique id should be returned which can be a Java class name
+ * (reverse domain name) or generated with a GUID algorithm. Note that all
+ * LDAP defined attributes already have an OID. It is strongly advised to
+ * define the attributes from existing LDAP schemes which will give the OID.
+ * Many such schemes exist ranging from postal addresses to DHCP parameters.
+ *
+ * @return The id or oid
+ */
+ public String getID();
+
+ /**
+ * Return a description of this attribute.
+ *
+ * The description may be localized and must describe the semantics of this
+ * type and any constraints.
+ *
+ * @return The localized description of the definition.
+ */
+ public String getDescription();
+
+ /**
+ * Return the cardinality of this attribute.
+ *
+ * The OSGi environment handles multi valued attributes in arrays ([]) or in
+ * <code>Vector</code> objects. The return value is defined as follows:
+ *
+ * <pre>
+ *
+ * x = Integer.MIN_VALUE no limit, but use Vector
+ * x < 0 -x = max occurrences, store in Vector
+ * x > 0 x = max occurrences, store in array []
+ * x = Integer.MAX_VALUE no limit, but use array []
+ * x = 0 1 occurrence required
+ *
+ * </pre>
+ *
+ * @return The cardinality of this attribute.
+ */
+ public int getCardinality();
+
+ /**
+ * Return the type for this attribute.
+ *
+ * <p>
+ * Defined in the following constants which map to the appropriate Java
+ * type. <code>STRING</code>,<code>LONG</code>,<code>INTEGER</code>,
+ * <code>CHAR</code>,<code>BYTE</code>,<code>DOUBLE</code>,<code>FLOAT</code>,
+ * <code>BOOLEAN</code>.
+ *
+ * @return The type for this attribute.
+ */
+ public int getType();
+
+ /**
+ * Return a list of option values that this attribute can take.
+ *
+ * <p>
+ * If the function returns <code>null</code>, there are no option values
+ * available.
+ *
+ * <p>
+ * Each value must be acceptable to validate() (return "") and must be a
+ * <code>String</code> object that can be converted to the data type defined
+ * by getType() for this attribute.
+ *
+ * <p>
+ * This list must be in the same sequence as <code>getOptionLabels()</code>.
+ * I.e. for each index i in <code>getOptionValues</code>, i in
+ * <code>getOptionLabels()</code> should be the label.
+ *
+ * <p>
+ * For example, if an attribute can have the value male, female, unknown,
+ * this list can return
+ * <code>new String[] { "male", "female", "unknown" }</code>.
+ *
+ * @return A list values
+ */
+ public String[] getOptionValues();
+
+ /**
+ * Return a list of labels of option values.
+ *
+ * <p>
+ * The purpose of this method is to allow menus with localized labels. It is
+ * associated with <code>getOptionValues</code>. The labels returned here are
+ * ordered in the same way as the values in that method.
+ *
+ * <p>
+ * If the function returns <code>null</code>, there are no option labels
+ * available.
+ * <p>
+ * This list must be in the same sequence as the <code>getOptionValues()</code>
+ * method. I.e. for each index i in <code>getOptionLabels</code>, i in
+ * <code>getOptionValues()</code> should be the associated value.
+ *
+ * <p>
+ * For example, if an attribute can have the value male, female, unknown,
+ * this list can return (for dutch)
+ * <code>new String[] { "Man", "Vrouw", "Onbekend" }</code>.
+ *
+ * @return A list values
+ */
+ public String[] getOptionLabels();
+
+ /**
+ * Validate an attribute in <code>String</code> form.
+ *
+ * An attribute might be further constrained in value. This method will
+ * attempt to validate the attribute according to these constraints. It can
+ * return three different values:
+ *
+ * <pre>
+ * null No validation present
+ * "" No problems detected
+ * "..." A localized description of why the value is wrong
+ * </pre>
+ *
+ * @param value The value before turning it into the basic data type
+ * @return <code>null</code>, "", or another string
+ */
+ public String validate(String value);
+
+ /**
+ * Return a default for this attribute.
+ *
+ * The object must be of the appropriate type as defined by the cardinality
+ * and <code>getType()</code>. The return type is a list of <code>String</code>
+ * objects that can be converted to the appropriate type. The cardinality of
+ * the return array must follow the absolute cardinality of this type. E.g.
+ * if the cardinality = 0, the array must contain 1 element. If the
+ * cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must
+ * contain from 0 to max 5 elements. Note that the special case of a 0
+ * cardinality, meaning a single value, does not allow arrays or vectors of
+ * 0 elements.
+ *
+ * @return Return a default value or <code>null</code> if no default exists.
+ */
+ public String[] getDefaultValue();
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeInformation.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeInformation.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeInformation.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeInformation.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,52 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.metatype/src/org/osgi/service/metatype/MetaTypeInformation.java,v 1.8 2006/06/16 16:31:23 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.metatype;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A MetaType Information object is created by the MetaTypeService to return
+ * meta type information for a specific bundle.
+ *
+ * @version $Revision: 1.8 $
+ * @since 1.1
+ */
+public interface MetaTypeInformation extends MetaTypeProvider {
+ /**
+ * Return the PIDs (for ManagedServices) for which ObjectClassDefinition
+ * information is available.
+ *
+ * @return Array of PIDs.
+ */
+ public String[] getPids();
+
+ /**
+ * Return the Factory PIDs (for ManagedServiceFactories) for which
+ * ObjectClassDefinition information is available.
+ *
+ * @return Array of Factory PIDs.
+ */
+ public String[] getFactoryPids();
+
+ /**
+ * Return the bundle for which this object provides meta type information.
+ *
+ * @return Bundle for which this object provides meta type information.
+ */
+ public Bundle getBundle();
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeProvider.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeProvider.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeProvider.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,57 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.metatype/src/org/osgi/service/metatype/MetaTypeProvider.java,v 1.11 2006/06/16 16:31:23 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2006). 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.metatype;
+
+/**
+ * Provides access to metatypes.
+ *
+ * @version $Revision: 1.11 $
+ */
+public interface MetaTypeProvider {
+ /**
+ * Returns an object class definition for the specified id localized to the
+ * specified locale.
+ *
+ * <p>
+ * The locale parameter must be a name that consists of <code>language</code>[
+ * "_" <code>country</code>[ "_" <code>variation</code>] ] as is customary in
+ * the <code>Locale</code> class. This <code>Locale</code> class is not used
+ * because certain profiles do not contain it.
+ *
+ * @param id The ID of the requested object class. This can be a pid or
+ * factory pid returned by getPids or getFactoryPids.
+ * @param locale The locale of the definition or <code>null</code> for default
+ * locale.
+ * @return A <code>ObjectClassDefinition</code> object.
+ * @throws IllegalArgumentException If the id or locale arguments are not
+ * valid
+ */
+ public ObjectClassDefinition getObjectClassDefinition(String id, String locale);
+
+ /**
+ * Return a list of available locales.
+ *
+ * The results must be names that consists of language [ _ country [ _
+ * variation ]] as is customary in the <code>Locale</code> class.
+ *
+ * @return An array of locale strings or <code>null</code> if there is no
+ * locale specific localization can be found.
+ *
+ */
+ public String[] getLocales();
+}
Added: felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeService.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeService.java?rev=616813&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeService.java (added)
+++ felix/trunk/deploymentadmin/src/main/java/org/osgi/service/metatype/MetaTypeService.java Wed Jan 30 08:46:24 2008
@@ -0,0 +1,53 @@
+/*
+ * $Header: /cvshome/build/org.osgi.service.metatype/src/org/osgi/service/metatype/MetaTypeService.java,v 1.10 2006/06/16 16:31:23 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005, 2006). 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.metatype;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * The MetaType Service can be used to obtain meta type information for a
+ * bundle. The MetaType Service will examine the specified bundle for meta type
+ * documents to create the returned <code>MetaTypeInformation</code> object.
+ *
+ * <p>
+ * If the specified bundle does not contain any meta type documents, then a
+ * <code>MetaTypeInformation</code> object will be returned that wrappers any
+ * <code>ManagedService</code> or <code>ManagedServiceFactory</code>
+ * services registered by the specified bundle that implement
+ * <code>MetaTypeProvider</code>. Thus the MetaType Service can be used to
+ * retrieve meta type information for bundles which contain a meta type
+ * documents or which provide their own <code>MetaTypeProvider</code> objects.
+ *
+ * @version $Revision: 1.10 $
+ * @since 1.1
+ */
+public interface MetaTypeService {
+ /**
+ * Return the MetaType information for the specified bundle.
+ *
+ * @param bundle The bundle for which meta type information is requested.
+ * @return A MetaTypeInformation object for the specified bundle.
+ */
+ public MetaTypeInformation getMetaTypeInformation(Bundle bundle);
+
+ /**
+ * Location of meta type documents. The MetaType Service will process each
+ * entry in the meta type documents directory.
+ */
+ public final static String METATYPE_DOCUMENTS_LOCATION = "OSGI-INF/metatype";
+}