Interface StateObjectFactory

  • All Known Implementing Classes:
    StateObjectFactory.StateObjectFactoryProxy

    public interface StateObjectFactory
    A factory for states and their component objects.

    This interface is not intended to be implemented by clients.

    Since:
    3.1
    Restriction:
    This interface is not intended to be implemented by clients.
    • Field Detail

      • defaultFactory

        static final StateObjectFactory defaultFactory
        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.
    • Method Detail

      • createState

        State createState()
        Deprecated.
        Creates an empty state. The returned state does not have an attached resolver.
        Returns:
        the created state
      • createState

        State createState​(boolean resolver)
        Creates an empty state with or without a resolver.
        Parameters:
        resolver - true if the created state should be initialized with a resolver.
        Returns:
        the created state
        Since:
        3.2
      • createState

        State createState​(State state)
        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.
        Parameters:
        state - a state to be copied
        Returns:
        the created state
      • createBundleDescription

        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.
        Parameters:
        id - id for the bundle
        symbolicName - symbolic name for the bundle (may be null)
        version - version for the bundle (may be null)
        location - location for the bundle (may be null)
        required - version constraints for all required bundles (may be null)
        host - version constraint specifying the host for the bundle to be created. Should be null if the bundle is not a fragment
        imports - version constraints for all packages imported (may be null)
        exports - package descriptions of all the exported packages (may be null)
        singleton - whether the bundle created should be a singleton
        attachFragments - whether the bundle allows fragments to attach
        dynamicFragments - whether the bundle allows fragments to dynamically attach
        platformFilter - the platform filter (may be null)
        executionEnvironments - the execution environment (may be null)
        genericRequires - the version constraints for all required capabilities (may be null)
        genericCapabilities - the specifications of all the capabilities of the bundle (may be null)
        Returns:
        the created bundle description
      • createBundleDescription

        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.
        Parameters:
        id - id for the bundle
        symbolicName - symbolic name for the bundle (may be null)
        version - version for the bundle (may be null)
        location - location for the bundle (may be null)
        required - version constraints for all required bundles (may be null)
        host - version constraint specifying the host for the bundle to be created. Should be null if the bundle is not a fragment
        imports - version constraints for all packages imported (may be null)
        exports - package descriptions of all the exported packages (may be null)
        singleton - whether the bundle created should be a singleton
        attachFragments - whether the bundle allows fragments to attach
        dynamicFragments - whether the bundle allows fragments to dynamically attach
        platformFilter - the platform filter (may be null)
        executionEnvironments - the execution environment (may be null)
        genericRequires - the version constraints for all required capabilities (may be null)
        genericCapabilities - the specifications of all the capabilities of the bundle (may be null)
        nativeCode - the native code specification of the bundle (may be null)
        Returns:
        the created bundle description
        Since:
        3.4
      • createBundleDescription

        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)
        Creates a bundle description from the given parameters.
        Parameters:
        id - id for the bundle
        symbolicName - the symbolic name of the bundle. This may include directives and/or attributes encoded using the Bundle-SymbolicName header.
        version - version for the bundle (may be null)
        location - location for the bundle (may be null)
        required - version constraints for all required bundles (may be null)
        host - version constraint specifying the host for the bundle to be created. Should be null if the bundle is not a fragment
        imports - version constraints for all packages imported (may be null)
        exports - package descriptions of all the exported packages (may be null)
        platformFilter - the platform filter (may be null)
        executionEnvironments - the execution environment (may be null)
        genericRequires - the version constraints for all required capabilities (may be null)
        genericCapabilities - the specifications of all the capabilities of the bundle (may be null)
        nativeCode - the native code specification of the bundle (may be null)
        Returns:
        the created bundle description
        Since:
        3.8
      • createBundleDescription

        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.
        Parameters:
        state - the state for which the description is being created
        manifest - a collection of OSGi manifest headers and values
        location - the URL location of the bundle (may be null)
        id - the id of the bundle
        Returns:
        a bundle description derived from the given information
        Throws:
        BundleException - if an error occurs while reading the manifest
      • createBundleDescription

        BundleDescription createBundleDescription​(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.
        Parameters:
        manifest - a collection of OSGi manifest headers and values
        location - the URL location of the bundle (may be null)
        id - the id of the bundle
        Returns:
        a bundle description derived from the given information
        Throws:
        BundleException - if an error occurs while reading the manifest
      • createBundleDescription

        BundleDescription createBundleDescription​(BundleDescription original)
        Creates a bundle description that is a copy of the given description. The user object of the original bundle description is not copied.
        Parameters:
        original - the bundle description to be copied
        Returns:
        the created bundle description
      • createBundleSpecification

        BundleSpecification createBundleSpecification​(String requiredSymbolicName,
                                                      VersionRange requiredVersionRange,
                                                      boolean export,
                                                      boolean optional)
        Creates a bundle specification from the given parameters.
        Parameters:
        requiredSymbolicName - the symbolic name for the required bundle
        requiredVersionRange - the required version range (may be null)
        export - whether the required bundle should be re-exported
        optional - whether the constraint should be optional
        Returns:
        the created bundle specification
        See Also:
        for information on the available match rules
      • createBundleSpecification

        BundleSpecification createBundleSpecification​(BundleSpecification original)
        Creates a bundle specification that is a copy of the given constraint.
        Parameters:
        original - the constraint to be copied
        Returns:
        the created bundle specification
      • createBundleSpecifications

        List<BundleSpecification> createBundleSpecifications​(String declaration)
        Creates bundle specifications from the given declaration. The declaration uses the bundle manifest syntax for the Require-Bundle header.
        Parameters:
        declaration - a string declaring bundle specifications
        Returns:
        the bundle specifications
        Since:
        3.8
      • createHostSpecification

        HostSpecification createHostSpecification​(String hostSymbolicName,
                                                  VersionRange hostVersionRange)
        Creates a host specification from the given parameters.
        Parameters:
        hostSymbolicName - the symbolic name for the host bundle
        hostVersionRange - the version range for the host bundle (may be null)
        Returns:
        the created host specification
        See Also:
        for information on the available match rules
      • createHostSpecifications

        List<HostSpecification> createHostSpecifications​(String declaration)
        Creates host specifications from the given declaration. The declaration uses the bundle manifest syntax for the Fragment-Host header.
        Parameters:
        declaration - a string declaring host specifications
        Returns:
        the host specifications
        Since:
        3.8
      • createHostSpecification

        HostSpecification createHostSpecification​(HostSpecification original)
        Creates a host specification that is a copy of the given constraint.
        Parameters:
        original - the constraint to be copied
        Returns:
        the created host specification
      • createImportPackageSpecification

        ImportPackageSpecification createImportPackageSpecification​(String packageName,
                                                                    VersionRange versionRange,
                                                                    String bundleSymbolicName,
                                                                    VersionRange bundleVersionRange,
                                                                    Map<String,​?> directives,
                                                                    Map<String,​?> attributes,
                                                                    BundleDescription importer)
        Creates an import package specification from the given parameters.
        Parameters:
        packageName - the package name
        versionRange - the package versionRange (may be null).
        bundleSymbolicName - the Bundle-SymbolicName of the bundle that must export the package (may be null)
        bundleVersionRange - the bundle versionRange (may be null).
        directives - the directives for this package (may be null)
        attributes - the arbitrary attributes for the package import (may be null)
        importer - the importing bundle (may be null)
        Returns:
        the created package specification
      • createImportPackageSpecification

        ImportPackageSpecification createImportPackageSpecification​(ImportPackageSpecification original)
        Creates an import package specification that is a copy of the given import package
        Parameters:
        original - the import package to be copied
        Returns:
        the created package specification
      • createImportPackageSpecifications

        List<ImportPackageSpecification> createImportPackageSpecifications​(String declaration)
        Creates an import package specifications from the given declaration. The declaration uses the bundle manifest syntax for the Import-Package header.
        Parameters:
        declaration - a string declaring import package specifications
        Returns:
        the import package specifications
        Since:
        3.8
      • createExportPackageDescription

        ExportPackageDescription createExportPackageDescription​(String packageName,
                                                                Version version,
                                                                Map<String,​?> directives,
                                                                Map<String,​?> attributes,
                                                                boolean root,
                                                                BundleDescription exporter)
        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

        Parameters:
        packageName - the package name
        version - the version of the package (may be null)
        directives - the directives for the package (may be null)
        attributes - the attributes for the package (may be null)
        root - whether the package is a root package
        exporter - the exporter of the package (may be null)
        Returns:
        the created package
      • createGenericDescription

        GenericDescription createGenericDescription​(String name,
                                                    String type,
                                                    Version version,
                                                    Map<String,​?> attributes)
        Creates a generic description from the given parameters
        Parameters:
        name - the name of the generic description
        type - the type of the generic description (may be null)
        version - the version of the generic description (may be null)
        attributes - the attributes for the generic description (may be null)
        Returns:
        the created generic description
      • createGenericDescription

        GenericDescription createGenericDescription​(String type,
                                                    Map<String,​?> attributes,
                                                    Map<String,​String> directives,
                                                    BundleDescription supplier)
        Creates a generic description from the given parameters
        Parameters:
        type - the type of the generic description (may be null)
        attributes - the attributes for the generic description (may be null)
        directives - the directives for the generic description (may be null)
        supplier - the supplier of the generic description (may be null)
        Returns:
        the created generic description
        Since:
        3.7
      • createGenericDescriptions

        List<GenericDescription> createGenericDescriptions​(String declaration)
        Creates generic descriptions from the given declaration. The declaration uses the bundle manifest syntax for the Provide-Capability header.
        Parameters:
        declaration - a string declaring generic descriptions
        Returns:
        the generic descriptions
        Since:
        3.8
      • createGenericSpecification

        GenericSpecification createGenericSpecification​(String name,
                                                        String type,
                                                        String matchingFilter,
                                                        boolean optional,
                                                        boolean multiple)
                                                 throws InvalidSyntaxException
        Creates a generic specification from the given parameters
        Parameters:
        name - the name of the generic specification
        type - the type of the generic specification (may be null)
        matchingFilter - the matching filter (may be null)
        optional - whether the specification is optional
        multiple - whether the specification allows for multiple suppliers
        Returns:
        the created generic specification
        Throws:
        InvalidSyntaxException - if the matching filter is invalid
      • createGenericSpecifications

        List<GenericSpecification> createGenericSpecifications​(String declaration)
        Creates generic specifications from the given declaration. The declaration uses the bundle manifest syntax for the Require-Capability header.
        Parameters:
        declaration - a string declaring generic specifications
        Returns:
        the generic specifications
        Since:
        3.8
      • createNativeCodeSpecification

        NativeCodeSpecification createNativeCodeSpecification​(NativeCodeDescription[] nativeCodeDescriptions,
                                                              boolean optional)
        Creates a native code specification from the given parameters
        Parameters:
        nativeCodeDescriptions - the native code descriptors
        optional - whether the specification is optional
        Returns:
        the created native code specification
        Since:
        3.4
      • createNativeCodeDescription

        NativeCodeDescription createNativeCodeDescription​(String[] nativePaths,
                                                          String[] processors,
                                                          String[] osNames,
                                                          VersionRange[] osVersions,
                                                          String[] languages,
                                                          String filter)
                                                   throws InvalidSyntaxException
        Creates a native code description from the given parameters
        Parameters:
        nativePaths - the native code paths (may be null)
        processors - the supported processors (may be null)
        osNames - the supported operating system names (may be null)
        osVersions - the supported operating system version ranges (may be null)
        languages - the supported languages (may be null)
        filter - the selection filter (may be null)
        Returns:
        the created native code description
        Throws:
        InvalidSyntaxException - if the selection filter is invalid
        Since:
        3.4
      • createExportPackageDescription

        ExportPackageDescription createExportPackageDescription​(ExportPackageDescription original)
        Creates an export package specification that is a copy of the given constraint
        Parameters:
        original - the export package to be copied
        Returns:
        the created package
      • createExportPackageDescriptions

        List<ExportPackageDescription> createExportPackageDescriptions​(String declaration)
        Creates export package descriptions from the given declaration. The declaration uses the bundle manifest syntax for the Export-Package header.
        Parameters:
        declaration - a string declaring export package descriptions
        Returns:
        the export package descriptions
        Since:
        3.8
      • writeState

        void writeState​(State state,
                        OutputStream stream)
                 throws IOException
        Deprecated.
        Persists the given state in the given output stream. Closes the stream.
        Parameters:
        state - the state to be written
        stream - the stream where to write the state to
        Throws:
        IOException - if an IOException happens while writing the state to the stream
        IllegalArgumentException - if the state provided was not created by this factory
        Since:
        3.1
      • writeState

        void writeState​(State state,
                        File stateDirectory)
                 throws IOException
        Persists the given state in the given directory.
        Parameters:
        state - the state to be written
        stateDirectory - the directory where to write the state to
        Throws:
        IOException - if an IOException happens while writing the state to the stream
        IllegalArgumentException - if the state provided was not created by this factory
      • readState

        State readState​(InputStream stream)
                 throws IOException
        Deprecated.
        use readState(File) instead
        Reads a persisted state from the given stream. Closes the stream.
        Parameters:
        stream - the stream where to read the state from
        Returns:
        the state read
        Throws:
        IOException - if an IOException happens while reading the state from the stream
        Since:
        3.1
      • readState

        State readState​(File stateDirectory)
                 throws IOException
        Reads a persisted state from the given directory.
        Parameters:
        stateDirectory - the directory where to read the state from
        Returns:
        the state read
        Throws:
        IOException - if an IOException happens while reading the state from the stream