You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2005/08/16 20:34:41 UTC
svn commit: r233031 [21/21] - in /incubator/oscar/trunk: ./ etc/ lib/ src/
src/org/ src/org/apache/ src/org/apache/osgi/ src/org/apache/osgi/bundle/
src/org/apache/osgi/bundle/bundlerepository/
src/org/apache/osgi/bundle/bundlerepository/kxmlsax/ src/o...
Added: incubator/oscar/trunk/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java
URL: http://svn.apache.org/viewcvs/incubator/oscar/trunk/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java?rev=233031&view=auto
==============================================================================
--- incubator/oscar/trunk/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java (added)
+++ incubator/oscar/trunk/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java Tue Aug 16 11:33:34 2005
@@ -0,0 +1,84 @@
+/*
+ * $Header: /cvshome/build/org.osgi.util.tracker/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java,v 1.7 2005/05/13 20:33:35 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2000, 2005). All Rights Reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
+ */
+
+package org.osgi.util.tracker;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The <code>ServiceTrackerCustomizer</code> interface allows a
+ * <code>ServiceTracker</code> object to customize the service objects that are
+ * tracked. The <code>ServiceTrackerCustomizer</code> object is called when a
+ * service is being added to the <code>ServiceTracker</code> object. The
+ * <code>ServiceTrackerCustomizer</code> can then return an object for the tracked
+ * service. The <code>ServiceTrackerCustomizer</code> object is also called when a
+ * tracked service is modified or has been removed from the
+ * <code>ServiceTracker</code> object.
+ *
+ * <p>
+ * The methods in this interface may be called as the result of a
+ * <code>ServiceEvent</code> being received by a <code>ServiceTracker</code> object.
+ * Since <code>ServiceEvent</code> s are synchronously delivered by the Framework,
+ * it is highly recommended that implementations of these methods do not
+ * register (<code>BundleContext.registerService</code>), modify (
+ * <code>ServiceRegistration.setProperties</code>) or unregister (
+ * <code>ServiceRegistration.unregister</code>) a service while being
+ * synchronized on any object.
+ *
+ * @version $Revision: 1.7 $
+ */
+public interface ServiceTrackerCustomizer {
+ /**
+ * A service is being added to the <code>ServiceTracker</code> object.
+ *
+ * <p>
+ * This method is called before a service which matched the search
+ * parameters of the <code>ServiceTracker</code> object is added to it. This
+ * method should return the service object to be tracked for this
+ * <code>ServiceReference</code> object. The returned service object is stored
+ * in the <code>ServiceTracker</code> object and is available from the
+ * <code>getService</code> and <code>getServices</code> methods.
+ *
+ * @param reference Reference to service being added to the
+ * <code>ServiceTracker</code> object.
+ * @return The service object to be tracked for the
+ * <code>ServiceReference</code> object or <code>null</code> if the
+ * <code>ServiceReference</code> object should not be tracked.
+ */
+ public abstract Object addingService(ServiceReference reference);
+
+ /**
+ * A service tracked by the <code>ServiceTracker</code> object has been
+ * modified.
+ *
+ * <p>
+ * This method is called when a service being tracked by the
+ * <code>ServiceTracker</code> object has had it properties modified.
+ *
+ * @param reference Reference to service that has been modified.
+ * @param service The service object for the modified service.
+ */
+ public abstract void modifiedService(ServiceReference reference,
+ Object service);
+
+ /**
+ * A service tracked by the <code>ServiceTracker</code> object has been
+ * removed.
+ *
+ * <p>
+ * This method is called after a service is no longer being tracked by the
+ * <code>ServiceTracker</code> object.
+ *
+ * @param reference Reference to service that has been removed.
+ * @param service The service object for the removed service.
+ */
+ public abstract void removedService(ServiceReference reference,
+ Object service);
+}
\ No newline at end of file
Added: incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/CdCommand.java
URL: http://svn.apache.org/viewcvs/incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/CdCommand.java?rev=233031&view=auto
==============================================================================
--- incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/CdCommand.java (added)
+++ incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/CdCommand.java Tue Aug 16 11:33:34 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.ungoverned.osgi.service.shell;
+
+/**
+ * This interface defines the <tt>cd</tt> command service interface for the
+ * Felix shell service. The <tt>cd</tt> command does not really change the
+ * directory of the shell, rather it maintains a base URL for
+ * simplifying URL entry.
+ * <p>
+ * For example, if the base URL is <tt>http://www.foo.com/<tt> and you
+ * try to install a bundle <tt>foo.jar</tt>, the actual URL will be
+ * expanded to <tt>http://www.foo.com/foo.jar</tt>. Any bundles wishing
+ * to retrieve or set the current directory of the shell can use this
+ * service interface.
+**/
+public interface CdCommand extends Command
+{
+ /**
+ * Property used to configure the base URL.
+ **/
+ public static final String BASE_URL_PROPERTY = "felix.shell.baseurl";
+
+ /**
+ * Returns the current <i>directory</i> of the shell service.
+ * @return the current shell directory.
+ **/
+ public String getBaseURL();
+
+ /**
+ * Sets the current <i>directory</i> of the shell service.
+ * @param s the new value for the base URL.
+ **/
+ public void setBaseURL(String s);
+}
Added: incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/Command.java
URL: http://svn.apache.org/viewcvs/incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/Command.java?rev=233031&view=auto
==============================================================================
--- incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/Command.java (added)
+++ incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/Command.java Tue Aug 16 11:33:34 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.ungoverned.osgi.service.shell;
+
+import java.io.PrintStream;
+
+/**
+ * This interface is used to define commands for the Felix shell
+ * service. Any bundle wishing to create commands for the
+ * shell service simply needs to create a service object that
+ * implements this interface and then register it with the OSGi
+ * framework. The shell service automatically includes any
+ * registered command services in its list of available commands.
+**/
+public interface Command
+{
+ /**
+ * Returns the name of the command that is implemented by the
+ * interface. The command name should not contain whitespace
+ * and should also be unique.
+ * @return the name of the command.
+ **/
+ public String getName();
+
+ /**
+ * Returns the usage string for the command. The usage string is
+ * a short string that illustrates how to use the command on the
+ * command line. This information is used when generating command
+ * help information. An example usage string for the <tt>install</tt>
+ * command is:
+ * <pre>
+ * install <URL> [<URL> ...]
+ * </pre>
+ * @return the usage string for the command.
+ **/
+ public String getUsage();
+
+ /**
+ * Returns a short description of the command; this description
+ * should be as short as possible. This information is used when
+ * generating the command help information.
+ * @return a short description of the command.
+ **/
+ public String getShortDescription();
+
+ /**
+ * Executes the command using the supplied command line, output
+ * print stream, and error print stream.
+ * @param line the complete command line, including the command name.
+ * @param out the print stream to use for standard output.
+ * @param err the print stream to use for standard error.
+ **/
+ public void execute(String line, PrintStream out, PrintStream err);
+}
Added: incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/ShellService.java
URL: http://svn.apache.org/viewcvs/incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/ShellService.java?rev=233031&view=auto
==============================================================================
--- incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/ShellService.java (added)
+++ incubator/oscar/trunk/src/org/ungoverned/osgi/service/shell/ShellService.java Tue Aug 16 11:33:34 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.ungoverned.osgi.service.shell;
+
+import java.io.PrintStream;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * This interface defines the Felix shell service. The shell service
+ * is an extensible, user interface neutral shell for controlling and
+ * interacting with the framework. In general, the shell service assumes that
+ * it is operating in a command line fashion, i.e., it receives a
+ * complete command line, parses it, and executes the corresponding
+ * command, but graphical interfaces are also possible.
+ * <p>
+ * All commands in the shell service are actually implemented as OSGi
+ * services; these services implement the <tt>Command</tt> service
+ * interface. Any bundle can implement custom commands by creating
+ * command services and registering them with the OSGi framework.
+**/
+public interface ShellService
+{
+ /**
+ * Returns an array of command names available in the shell service.
+ * @return an array of available command names or an empty array.
+ **/
+ public String[] getCommands();
+
+ /**
+ * Returns the usage string associated with the specified command name.
+ * @param name the name of the target command.
+ * @return the usage string of the specified command or null.
+ **/
+ public String getCommandUsage(String name);
+
+ /**
+ * Returns the description associated with the specified command name.
+ * @param name the name of the target command.
+ * @return the description of the specified command or null.
+ **/
+ public String getCommandDescription(String name);
+
+ /**
+ * Returns the service reference associated with the specified
+ * command name.
+ * @param name the name of the target command.
+ * @return the description of the specified command or null.
+ **/
+ public ServiceReference getCommandReference(String name);
+
+ /**
+ *
+ * This method executes the supplied command line using the
+ * supplied output and error print stream. The assumption of
+ * this method is that a command line will be typed by the user
+ * (or perhaps constructed by a GUI) and passed into it for
+ * execution. The command line is interpretted in a very
+ * simplistic fashion; it takes the leading string of characters
+ * terminated by a space character (not including it) and
+ * assumes that this leading token is the command name. For an
+ * example, consider the following command line:
+ * </p>
+ * <pre>
+ * update 3 http://www.foo.com/bar.jar
+ * </pre>
+ * <p>
+ * This is interpretted as an <tt>update</tt> command; as a
+ * result, the entire command line (include command name) is
+ * passed into the <tt>execute()</tt> method of the command
+ * service with the name <tt>update</tt> if one exists. If the
+ * corresponding command service is not found, then an error
+ * message is printed to the error print stream.
+ * @param commandLine the command line to execute.
+ * @param out the standard output print stream.
+ * @param err the standard error print stream.
+ **/
+ public void executeCommand(
+ String commandLine, PrintStream out, PrintStream err)
+ throws Exception;
+}
\ No newline at end of file