Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * $Header: /cvshome/build/org.osgi.service.obr/src/org/osgi/service/obr/RepositoryAdmin.java,v 1.3 2006/03/16 14:56:17 hargrave Exp $ |
| 3 | * |
| 4 | * Copyright (c) OSGi Alliance (2006). All Rights Reserved. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | // This document is an experimental draft to enable interoperability |
| 20 | // between bundle repositories. There is currently no commitment to |
| 21 | // turn this draft into an official specification. |
| 22 | package org.osgi.service.obr; |
| 23 | |
| 24 | import java.net.URL; |
| 25 | |
Guillaume Nodet | cd87ae5 | 2010-02-21 14:08:56 +0000 | [diff] [blame] | 26 | import org.osgi.framework.Filter; |
| 27 | import org.osgi.framework.InvalidSyntaxException; |
| 28 | |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 29 | /** |
| 30 | * Provides centralized access to the distributed repository. |
| 31 | * |
| 32 | * A repository contains a set of <i>resources</i>. A resource contains a |
| 33 | * number of fixed attributes (name, version, etc) and sets of: |
| 34 | * <ol> |
| 35 | * <li>Capabilities - Capabilities provide a named aspect: a bundle, a display, |
| 36 | * memory, etc.</li> |
| 37 | * <li>Requirements - A named filter expression. The filter must be satisfied |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 38 | * by one or more Capabilities with the given name. These capabilities can come |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 39 | * from other resources or from the platform. If multiple resources provide the |
| 40 | * requested capability, one is selected. (### what algorithm? ###)</li> |
| 41 | * <li>Requests - Requests are like requirements, except that a request can be |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 42 | * fulfilled by 0..n resources. This feature can be used to link to resources |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 43 | * that are compatible with the given resource and provide extra functionality. |
| 44 | * For example, a bundle could request all its known fragments. The UI |
| 45 | * associated with the repository could list these as optional downloads.</li> |
| 46 | * |
| 47 | * @version $Revision: 1.3 $ |
| 48 | */ |
| 49 | public interface RepositoryAdmin |
| 50 | { |
| 51 | /** |
| 52 | * Discover any resources that match the given filter. |
| 53 | * |
| 54 | * This is not a detailed search, but a first scan of applicable resources. |
| 55 | * |
| 56 | * ### Checking the capabilities of the filters is not possible because that |
| 57 | * requires a new construct in the filter. |
| 58 | * |
| 59 | * The filter expression can assert any of the main headers of the resource. |
| 60 | * The attributes that can be checked are: |
| 61 | * |
| 62 | * <ol> |
| 63 | * <li>name</li> |
| 64 | * <li>version (uses filter matching rules)</li> |
| 65 | * <li>description</li> |
| 66 | * <li>category</li> |
| 67 | * <li>copyright</li> |
| 68 | * <li>license</li> |
| 69 | * <li>source</li> |
| 70 | * </ol> |
| 71 | * |
| 72 | * @param filterExpr |
| 73 | * A standard OSGi filter |
| 74 | * @return List of resources matching the filters. |
| 75 | */ |
| 76 | Resource[] discoverResources(String filterExpr); |
| 77 | |
| 78 | /** |
Guillaume Nodet | 4ff5c7a | 2010-02-21 14:31:33 +0000 | [diff] [blame] | 79 | * Discover any resources that match the given requirements. |
| 80 | * |
| 81 | * @param requirements |
| 82 | * @return List of resources matching the filter |
| 83 | */ |
| 84 | Resource[] discoverResources(Requirement[] requirements); |
| 85 | |
| 86 | /** |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 87 | * Create a resolver. |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 88 | * |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 89 | * @return |
| 90 | */ |
| 91 | Resolver resolver(); |
| 92 | |
| 93 | /** |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 94 | * Create a resolver on the given repositories. |
| 95 | * |
| 96 | * @param repositories the list of repositories to use for the resolution |
| 97 | * @return |
| 98 | */ |
| 99 | Resolver resolver(Repository[] repositories); |
| 100 | |
| 101 | /** |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 102 | * Add a new repository to the federation. |
| 103 | * |
| 104 | * The url must point to a repository XML file. |
| 105 | * |
| 106 | * @param repository |
| 107 | * @return |
| 108 | * @throws Exception |
| 109 | */ |
| 110 | Repository addRepository(URL repository) throws Exception; |
| 111 | |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 112 | /** |
| 113 | * Remove a repository from the federation |
| 114 | * |
| 115 | * The url must point to a repository XML file. |
| 116 | * |
| 117 | * @param repository |
| 118 | * @return |
| 119 | */ |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 120 | boolean removeRepository(URL repository); |
| 121 | |
| 122 | /** |
| 123 | * List all the repositories. |
| 124 | * |
| 125 | * @return |
| 126 | */ |
| 127 | Repository[] listRepositories(); |
| 128 | |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 129 | /** |
| 130 | * Return the repository containing the system bundle |
| 131 | * |
| 132 | * @return |
| 133 | */ |
| 134 | Repository getSystemRepository(); |
| 135 | |
| 136 | /** |
| 137 | * Return the repository containing locally installed resources |
| 138 | * |
| 139 | * @return |
| 140 | */ |
| 141 | Repository getLocalRepository(); |
| 142 | |
Guillaume Nodet | cd87ae5 | 2010-02-21 14:08:56 +0000 | [diff] [blame] | 143 | Resource getResource(String repositoryId); |
| 144 | |
| 145 | /** |
| 146 | * Create a simple requirement to be used for selection |
| 147 | * @param name |
| 148 | * @param filter |
| 149 | * @return |
| 150 | */ |
| 151 | Requirement requirement(String name, String filter) throws InvalidSyntaxException; |
| 152 | |
| 153 | /** |
| 154 | * Create an extender filter supporting the SUBSET, SUPERSET and other extensions |
| 155 | * |
| 156 | * @param filter the string filter |
| 157 | * @return |
| 158 | */ |
| 159 | Filter filter(String filter) throws InvalidSyntaxException; |
| 160 | |
Guillaume Nodet | 66b87bd | 2010-02-23 11:34:29 +0000 | [diff] [blame] | 161 | /** |
| 162 | * Create a repository from the specified URL. |
| 163 | * |
| 164 | * @param repository |
| 165 | * @return |
| 166 | */ |
| 167 | Repository repository(URL repository) throws Exception; |
| 168 | |
Richard S. Hall | a2dc451 | 2006-04-04 13:17:11 +0000 | [diff] [blame] | 169 | } |