1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
|
/*******************************************************************************
* Copyright (c) 2003, 2011 IBM Corporation and others.
* 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
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.osgi.service.resolver;
import java.io.*;
import java.util.*;
import org.eclipse.osgi.internal.resolver.StateObjectFactoryImpl;
import org.osgi.framework.*;
/**
* A factory for states and their component objects.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* @since 3.1
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface StateObjectFactory {
/**
* The default object factory that can be used to create, populate and resolve
* states. This is particularly useful when using the resolver outside the context
* of a running Equinox framework.
*/
public static final StateObjectFactory defaultFactory = new StateObjectFactoryImpl();
/**
* Creates an empty state. The returned state does not have an
* attached resolver.
*
* @return the created state
* @deprecated use {@link #createState(boolean) }
*/
public State createState();
/**
* Creates an empty state with or without a resolver.
*
* @param resolver true if the created state should be initialized with a resolver.
* @return the created state
* @since 3.2
*/
public State createState(boolean resolver);
/**
* Creates a new state that is a copy of the given state. The returned state
* will contain copies of all bundle descriptions in the given state.
* The user objects from the original bundle descriptions is not copied and
* no data pertaining to resolution is copied. The returned state will have a
* new resolver attached to it.
*
* @param state a state to be copied
* @return the created state
*/
public State createState(State state);
/**
* Creates a bundle description from the given parameters.
*
* @param id id for the bundle
* @param symbolicName symbolic name for the bundle (may be
* <code>null</code>)
* @param version version for the bundle (may be <code>null</code>)
* @param location location for the bundle (may be <code>null</code>)
* @param required version constraints for all required bundles (may be
* <code>null</code>)
* @param host version constraint specifying the host for the bundle to be
* created. Should be <code>null</code> if the bundle is not a fragment
* @param imports version constraints for all packages imported
* (may be <code>null</code>)
* @param exports package descriptions of all the exported packages
* (may be <code>null</code>)
* @param providedPackages the list of provided packages (may be <code>null</code>)
* @param singleton whether the bundle created should be a singleton
* @return the created bundle description
* @deprecated use {@link #createBundleDescription(long, String, Version, String, BundleSpecification[], HostSpecification, ImportPackageSpecification[], ExportPackageDescription[], boolean, boolean, boolean, String, String[], GenericSpecification[], GenericDescription[])}
*/
public BundleDescription createBundleDescription(long id, String symbolicName, Version version, String location, BundleSpecification[] required, HostSpecification host, ImportPackageSpecification[] imports, ExportPackageDescription[] exports, String[] providedPackages, boolean singleton);
/**
* Creates a bundle description from the given parameters.
*
* @param id id for the bundle
* @param symbolicName symbolic name for the bundle (may be
* <code>null</code>)
* @param version version for the bundle (may be <code>null</code>)
* @param location location for the bundle (may be <code>null</code>)
* @param required version constraints for all required bundles (may be
* <code>null</code>)
* @param host version constraint specifying the host for the bundle to be
* created. Should be <code>null</code> if the bundle is not a fragment
* @param imports version constraints for all packages imported
* (may be <code>null</code>)
* @param exports package descriptions of all the exported packages
* (may be <code>null</code>)
* @param providedPackages the list of provided packages (may be <code>null</code>)
* @param singleton whether the bundle created should be a singleton
* @param attachFragments whether the bundle allows fragments to attach
* @param dynamicFragments whether the bundle allows fragments to dynamically attach
* @param platformFilter the platform filter (may be <code>null</code>)
* @param executionEnvironment the execution environment (may be <code>null</code>)
* @param genericRequires the version constraints for all required capabilities (may be <code>null</code>)
* @param genericCapabilities the specifications of all the capabilities of the bundle (may be <code>null</code>)
* @return the created bundle description
* @deprecated use {@link #createBundleDescription(long, String, Version, String, BundleSpecification[], HostSpecification, ImportPackageSpecification[], ExportPackageDescription[], boolean, boolean, boolean, String, String[], GenericSpecification[], GenericDescription[])}
*/
public BundleDescription createBundleDescription(long id, String symbolicName, Version version, String location, BundleSpecification[] required, HostSpecification host, ImportPackageSpecification[] imports, ExportPackageDescription[] exports, String[] providedPackages, boolean singleton, boolean attachFragments, boolean dynamicFragments, String platformFilter, String executionEnvironment, GenericSpecification[] genericRequires, GenericDescription[] genericCapabilities);
/**
* Creates a bundle description from the given parameters.
*
* @param id id for the bundle
* @param symbolicName symbolic name for the bundle (may be <code>null</code>)
* @param version version for the bundle (may be <code>null</code>)
* @param location location for the bundle (may be <code>null</code>)
* @param required version constraints for all required bundles (may be <code>null</code>)
* @param host version constraint specifying the host for the bundle to be created. Should be <code>null</code> if the bundle is not a fragment
* @param imports version constraints for all packages imported (may be <code>null</code>)
* @param exports package descriptions of all the exported packages (may be <code>null</code>)
* @param singleton whether the bundle created should be a singleton
* @param attachFragments whether the bundle allows fragments to attach
* @param dynamicFragments whether the bundle allows fragments to dynamically attach
* @param platformFilter the platform filter (may be <code>null</code>)
* @param executionEnvironments the execution environment (may be <code>null</code>)
* @param genericRequires the version constraints for all required capabilities (may be <code>null</code>)
* @param genericCapabilities the specifications of all the capabilities of the bundle (may be <code>null</code>)
* @return the created bundle description
*/
public BundleDescription createBundleDescription(long id, String symbolicName, Version version, String location, BundleSpecification[] required, HostSpecification host, ImportPackageSpecification[] imports, ExportPackageDescription[] exports, boolean singleton, boolean attachFragments, boolean dynamicFragments, String platformFilter, String[] executionEnvironments, GenericSpecification[] genericRequires, GenericDescription[] genericCapabilities);
/**
* Creates a bundle description from the given parameters.
*
* @param id id for the bundle
* @param symbolicName symbolic name for the bundle (may be <code>null</code>)
* @param version version for the bundle (may be <code>null</code>)
* @param location location for the bundle (may be <code>null</code>)
* @param required version constraints for all required bundles (may be <code>null</code>)
* @param host version constraint specifying the host for the bundle to be created. Should be <code>null</code> if the bundle is not a fragment
* @param imports version constraints for all packages imported (may be <code>null</code>)
* @param exports package descriptions of all the exported packages (may be <code>null</code>)
* @param singleton whether the bundle created should be a singleton
* @param attachFragments whether the bundle allows fragments to attach
* @param dynamicFragments whether the bundle allows fragments to dynamically attach
* @param platformFilter the platform filter (may be <code>null</code>)
* @param executionEnvironments the execution environment (may be <code>null</code>)
* @param genericRequires the version constraints for all required capabilities (may be <code>null</code>)
* @param genericCapabilities the specifications of all the capabilities of the bundle (may be <code>null</code>)
* @param nativeCode the native code specification of the bundle (may be <code>null</code>)
* @return the created bundle description
* @since 3.4
*/
public BundleDescription createBundleDescription(long id, String symbolicName, Version version, String location, BundleSpecification[] required, HostSpecification host, ImportPackageSpecification[] imports, ExportPackageDescription[] exports, boolean singleton, boolean attachFragments, boolean dynamicFragments, String platformFilter, String[] executionEnvironments, GenericSpecification[] genericRequires, GenericDescription[] genericCapabilities, NativeCodeSpecification nativeCode);
/**
* Creates a bundle description from the given parameters.
*
* @param id id for the bundle
* @param symbolicName the symbolic name of the bundle. This may include directives and/or attributes encoded using the Bundle-SymbolicName header.
* @param version version for the bundle (may be <code>null</code>)
* @param location location for the bundle (may be <code>null</code>)
* @param required version constraints for all required bundles (may be <code>null</code>)
* @param host version constraint specifying the host for the bundle to be created. Should be <code>null</code> if the bundle is not a fragment
* @param imports version constraints for all packages imported (may be <code>null</code>)
* @param exports package descriptions of all the exported packages (may be <code>null</code>)
* @param platformFilter the platform filter (may be <code>null</code>)
* @param executionEnvironments the execution environment (may be <code>null</code>)
* @param genericRequires the version constraints for all required capabilities (may be <code>null</code>)
* @param genericCapabilities the specifications of all the capabilities of the bundle (may be <code>null</code>)
* @param nativeCode the native code specification of the bundle (may be <code>null</code>)
* @return the created bundle description
* @since 3.8
*/
public BundleDescription createBundleDescription(long id, String symbolicName, Version version, String location, BundleSpecification[] required, HostSpecification host, ImportPackageSpecification[] imports, ExportPackageDescription[] exports, String platformFilter, String[] executionEnvironments, GenericSpecification[] genericRequires, GenericDescription[] genericCapabilities, NativeCodeSpecification nativeCode);
/**
* Returns a bundle description based on the information in the supplied manifest dictionary.
* The manifest should contain String keys and String values which correspond to
* proper OSGi manifest headers and values.
*
* @param state the state for which the description is being created
* @param manifest a collection of OSGi manifest headers and values
* @param location the URL location of the bundle (may be <code>null</code>)
* @param id the id of the bundle
* @return a bundle description derived from the given information
* @throws BundleException if an error occurs while reading the manifest
*/
public BundleDescription createBundleDescription(State state, Dictionary<String, String> manifest, String location, long id) throws BundleException;
/**
* Returns a bundle description based on the information in the supplied manifest dictionary.
* The manifest should contain String keys and String values which correspond to
* proper OSGi manifest headers and values.
*
* @param manifest a collection of OSGi manifest headers and values
* @param location the URL location of the bundle (may be <code>null</code>)
* @param id the id of the bundle
* @return a bundle description derived from the given information
* @throws BundleException if an error occurs while reading the manifest
* @deprecated use {@link #createBundleDescription(State, Dictionary, String, long)}
*/
public BundleDescription createBundleDescription(Dictionary<String, String> manifest, String location, long id) throws BundleException;
/**
* Creates a bundle description that is a copy of the given description.
* The user object of the original bundle description is not copied.
*
* @param original the bundle description to be copied
* @return the created bundle description
*/
public BundleDescription createBundleDescription(BundleDescription original);
/**
* Creates a bundle specification from the given parameters.
*
* @param requiredSymbolicName the symbolic name for the required bundle
* @param requiredVersionRange the required version range (may be <code>null</code>)
* @param export whether the required bundle should be re-exported
* @param optional whether the constraint should be optional
* @return the created bundle specification
* @see VersionConstraint for information on the available match rules
*/
public BundleSpecification createBundleSpecification(String requiredSymbolicName, VersionRange requiredVersionRange, boolean export, boolean optional);
/**
* Creates a bundle specification that is a copy of the given constraint.
*
* @param original the constraint to be copied
* @return the created bundle specification
*/
public BundleSpecification createBundleSpecification(BundleSpecification original);
/**
* Creates bundle specifications from the given declaration. The declaration uses
* the bundle manifest syntax for the Require-Bundle header.
* @param declaration a string declaring bundle specifications
* @return the bundle specifications
* @since 3.8
*/
public List<BundleSpecification> createBundleSpecifications(String declaration);
/**
* Creates a host specification from the given parameters.
*
* @param hostSymbolicName the symbolic name for the host bundle
* @param hostVersionRange the version range for the host bundle (may be <code>null</code>)
* @return the created host specification
* @see VersionConstraint for information on the available match rules
*/
public HostSpecification createHostSpecification(String hostSymbolicName, VersionRange hostVersionRange);
/**
* Creates host specifications from the given declaration. The declaration uses
* the bundle manifest syntax for the Fragment-Host header.
* @param declaration a string declaring host specifications
* @return the host specifications
* @since 3.8
*/
public List<HostSpecification> createHostSpecifications(String declaration);
/**
* Creates a host specification that is a copy of the given constraint.
*
* @param original the constraint to be copied
* @return the created host specification
*/
public HostSpecification createHostSpecification(HostSpecification original);
/**
* Creates an import package specification from the given parameters.
*
* @param packageName the package name
* @param versionRange the package versionRange (may be <code>null</code>).
* @param bundleSymbolicName the Bundle-SymbolicName of the bundle that must export the package (may be <code>null</code>)
* @param bundleVersionRange the bundle versionRange (may be <code>null</code>).
* @param directives the directives for this package (may be <code>null</code>)
* @param attributes the arbitrary attributes for the package import (may be <code>null</code>)
* @param importer the importing bundle (may be <code>null</code>)
* @return the created package specification
*/
public ImportPackageSpecification createImportPackageSpecification(String packageName, VersionRange versionRange, String bundleSymbolicName, VersionRange bundleVersionRange, Map<String, ?> directives, Map<String, ?> attributes, BundleDescription importer);
/**
* Creates an import package specification that is a copy of the given import package
* @param original the import package to be copied
* @return the created package specification
*/
public ImportPackageSpecification createImportPackageSpecification(ImportPackageSpecification original);
/**
* Creates an import package specifications from the given declaration. The declaration uses
* the bundle manifest syntax for the Import-Package header.
* @param declaration a string declaring import package specifications
* @return the import package specifications
* @since 3.8
*/
public List<ImportPackageSpecification> createImportPackageSpecifications(String declaration);
/**
* Used by the Resolver to dynamically create ExportPackageDescription objects during the resolution process.
* The Resolver needs to create ExportPackageDescriptions dynamically for a host when a fragment.
* exports a package<p>
*
* @param packageName the package name
* @param version the version of the package (may be <code>null</code>)
* @param directives the directives for the package (may be <code>null</code>)
* @param attributes the attributes for the package (may be <code>null</code>)
* @param root whether the package is a root package
* @param exporter the exporter of the package (may be <code>null</code>)
* @return the created package
*/
public ExportPackageDescription createExportPackageDescription(String packageName, Version version, Map<String, ?> directives, Map<String, ?> attributes, boolean root, BundleDescription exporter);
/**
* Creates a generic description from the given parameters
* @param name the name of the generic description
* @param type the type of the generic description (may be <code>null</code>)
* @param version the version of the generic description (may be <code>null</code>)
* @param attributes the attributes for the generic description (may be <code>null</code>)
* @return the created generic description
* @deprecated use {@link #createGenericDescription(String, String, Version, Map)}
*/
public GenericDescription createGenericDescription(String name, String type, Version version, Map<String, ?> attributes);
/**
* Creates a generic description from the given parameters
* @param type the type of the generic description (may be <code>null</code>)
* @param attributes the attributes for the generic description (may be <code>null</code>)
* @param directives the directives for the generic description (may be <code>null</code>)
* @param supplier the supplier of the generic description (may be <code>null</code>)
* @return the created generic description
* @since 3.7
*/
public GenericDescription createGenericDescription(String type, Map<String, ?> attributes, Map<String, String> directives, BundleDescription supplier);
/**
* Creates generic descriptions from the given declaration. The declaration uses
* the bundle manifest syntax for the Provide-Capability header.
* @param declaration a string declaring generic descriptions
* @return the generic descriptions
* @since 3.8
*/
public List<GenericDescription> createGenericDescriptions(String declaration);
/**
* Creates a generic specification from the given parameters
* @param name the name of the generic specification
* @param type the type of the generic specification (may be <code>null</code>)
* @param matchingFilter the matching filter (may be <code>null</code>)
* @param optional whether the specification is optional
* @param multiple whether the specification allows for multiple suppliers
* @return the created generic specification
* @throws InvalidSyntaxException if the matching filter is invalid
*/
public GenericSpecification createGenericSpecification(String name, String type, String matchingFilter, boolean optional, boolean multiple) throws InvalidSyntaxException;
/**
* Creates generic specifications from the given declaration. The declaration uses
* the bundle manifest syntax for the Require-Capability header.
* @param declaration a string declaring generic specifications
* @return the generic specifications
* @since 3.8
*/
public List<GenericSpecification> createGenericSpecifications(String declaration);
/**
* Creates a native code specification from the given parameters
* @param nativeCodeDescriptions the native code descriptors
* @param optional whether the specification is optional
* @return the created native code specification
* @since 3.4
*/
public NativeCodeSpecification createNativeCodeSpecification(NativeCodeDescription[] nativeCodeDescriptions, boolean optional);
/**
* Creates a native code description from the given parameters
* @param nativePaths the native code paths (may be <code>null</code>)
* @param processors the supported processors (may be <code>null</code>)
* @param osNames the supported operating system names (may be <code>null</code>)
* @param osVersions the supported operating system version ranges (may be <code>null</code>)
* @param languages the supported languages (may be <code>null</code>)
* @param filter the selection filter (may be <code>null</code>)
* @return the created native code description
* @throws InvalidSyntaxException if the selection filter is invalid
* @since 3.4
*/
public NativeCodeDescription createNativeCodeDescription(String[] nativePaths, String[] processors, String[] osNames, VersionRange[] osVersions, String[] languages, String filter) throws InvalidSyntaxException;
/**
* Creates an export package specification that is a copy of the given constraint
* @param original the export package to be copied
* @return the created package
*/
public ExportPackageDescription createExportPackageDescription(ExportPackageDescription original);
/**
* Creates export package descriptions from the given declaration. The declaration uses
* the bundle manifest syntax for the Export-Package header.
* @param declaration a string declaring export package descriptions
* @return the export package descriptions
* @since 3.8
*/
public List<ExportPackageDescription> createExportPackageDescriptions(String declaration);
/**
* Persists the given state in the given output stream. Closes the stream.
*
* @param state the state to be written
* @param stream the stream where to write the state to
* @throws IOException if an IOException happens while writing the state to
* the stream
* @throws IllegalArgumentException if the state provided was not created by
* this factory
* @deprecated use {@link #writeState(State, File)} instead
* @since 3.1
*/
public void writeState(State state, OutputStream stream) throws IOException;
/**
* Persists the given state in the given output stream. Closes the stream.
*
* @param state the state to be written
* @param stream the stream where to write the state to
* @throws IOException if an IOException happens while writing the state to
* the stream
* @throws IllegalArgumentException if the state provided was not created by
* this factory
* @deprecated use {@link #writeState(State, File)} instead
* @see #writeState(State, OutputStream)
*/
public void writeState(State state, DataOutputStream stream) throws IOException;
/**
* Persists the given state in the given directory.
*
* @param state the state to be written
* @param stateDirectory the directory where to write the state to
* @throws IOException if an IOException happens while writing the state to
* the stream
* @throws IllegalArgumentException if the state provided was not created by
* this factory
*/
public void writeState(State state, File stateDirectory) throws IOException;
/**
* Reads a persisted state from the given stream. Closes the stream.
*
* @param stream the stream where to read the state from
* @return the state read
* @throws IOException if an IOException happens while reading the state from
* the stream
* @deprecated use {@link #readState(File)} instead
* @since 3.1
*/
public State readState(InputStream stream) throws IOException;
/**
* Reads a persisted state from the given stream. Closes the stream.
*
* @param stream the stream where to read the state from
* @return the state read
* @throws IOException if an IOException happens while reading the state from
* the stream
* @deprecated use {@link #readState(File)} instead
* @see #readState(InputStream)
*/
public State readState(DataInputStream stream) throws IOException;
/**
* Reads a persisted state from the given directory.
*
* @param stateDirectory the directory where to read the state from
* @return the state read
* @throws IOException if an IOException happens while reading the state from
* the stream
*/
public State readState(File stateDirectory) throws IOException;
}
|