Class Workspace

  • All Implemented Interfaces:
    Constants, Registry, aQute.service.reporter.Report, aQute.service.reporter.Reporter, java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable<java.lang.String>

    public class Workspace
    extends Processor
    • Field Detail

      • BND_DEFAULT_WS

        public static final java.io.File BND_DEFAULT_WS
      • BND_CACHE_REPONAME

        public static final java.lang.String BND_CACHE_REPONAME
        See Also:
        Constant Field Values
      • BNDDIR

        @Deprecated
        public static final java.lang.String BNDDIR
        Deprecated.
        See Also:
        Constant Field Values
      • CACHEDIR

        public static final java.lang.String CACHEDIR
      • STANDALONE_REPO_CLASS

        public static final java.lang.String STANDALONE_REPO_CLASS
        See Also:
        Constant Field Values
      • remoteWorkspaces

        public static boolean remoteWorkspaces
    • Constructor Detail

      • Workspace

        public Workspace​(java.io.File workspaceDir)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • Workspace

        public Workspace​(java.io.File workspaceDir,
                         java.lang.String bndDir)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • getProject

        public static Project getProject​(java.io.File projectDir)
                                  throws java.lang.Exception
        This static method finds the workspace and creates a project (or returns an existing project)
        Parameters:
        projectDir -
        Throws:
        java.lang.Exception
      • getDefaults

        public static Processor getDefaults()
      • createDefaultWorkspace

        public static Workspace createDefaultWorkspace()
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getWorkspace

        public static Workspace getWorkspace​(java.io.File workspaceDir)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getWorkspaceWithoutException

        public static Workspace getWorkspaceWithoutException​(java.io.File workspaceDir)
                                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • findWorkspace

        public static Workspace findWorkspace​(java.io.File base)
                                       throws java.lang.Exception
        /* Return the nearest workspace
        Throws:
        java.lang.Exception
      • getWorkspace

        public static Workspace getWorkspace​(java.io.File workspaceDir,
                                             java.lang.String bndDir)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setFileSystem

        public void setFileSystem​(java.io.File workspaceDir,
                                  java.lang.String bndDir)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getProjectFromFile

        public Project getProjectFromFile​(java.io.File projectDir)
      • getProject

        public Project getProject​(java.lang.String bsn)
      • isPresent

        public boolean isPresent​(java.lang.String name)
      • refreshProjects

        public void refreshProjects()
        Signal that the driver has detected a dynamic change in the workspace directory, for example a project was added or removed in the IDE. Since this does not affect the inherited properties we can only change the list of projects.
      • _workspace

        public java.lang.String _workspace​(java.lang.String[] args)
      • addCommand

        public void addCommand​(java.lang.String menu,
                               Action action)
      • removeCommand

        public void removeCommand​(java.lang.String menu)
      • fillActions

        public void fillActions​(java.util.Map<java.lang.String,​Action> all)
      • getAllProjects

        public java.util.Collection<Project> getAllProjects()
      • changedFile

        public void changedFile​(java.io.File f)
        Inform any listeners that we changed a file (created/deleted/changed).
        Parameters:
        f - The changed file
      • bracket

        public void bracket​(boolean begin)
      • signal

        public void signal​(aQute.service.reporter.Reporter reporter)
      • syncCache

        public void syncCache()
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getBuildOrder

        public java.util.Collection<Project> getBuildOrder()
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getWorkspace

        public static Workspace getWorkspace​(java.lang.String path)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getMaven

        public Maven getMaven()
      • setTypeSpecificPlugins

        protected void setTypeSpecificPlugins​(java.util.Set<java.lang.Object> list)
        Overrides:
        setTypeSpecificPlugins in class Processor
      • addExtensions

        protected void addExtensions​(java.util.Set<java.lang.Object> list)
        Add any extensions listed
        Overrides:
        addExtensions in class Processor
        Parameters:
        list -
      • isOffline

        public boolean isOffline()
      • getOffline

        public java.util.concurrent.atomic.AtomicBoolean getOffline()
      • setOffline

        public Workspace setOffline​(boolean on)
      • _global

        public java.lang.String _global​(java.lang.String[] args)
                                 throws java.lang.Exception
        Provide access to the global settings of this machine.
        Throws:
        java.lang.Exception
      • _user

        public java.lang.String _user​(java.lang.String[] args)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _repodigests

        public java.lang.Object _repodigests​(java.lang.String[] args)
                                      throws java.lang.Exception
        Return the repository signature digests. These digests are a unique id for the contents of the repository
        Throws:
        java.lang.Exception
      • getRun

        public static Run getRun​(java.io.File file)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • report

        public void report​(java.util.Map<java.lang.String,​java.lang.Object> table)
                    throws java.lang.Exception
        Report details of this workspace
        Overrides:
        report in class Processor
        Throws:
        java.lang.Exception
      • getCache

        public java.io.File getCache​(java.lang.String name)
      • getWorkspaceRepository

        public WorkspaceRepository getWorkspaceRepository()
        Return the workspace repo
      • checkStructure

        public void checkStructure()
      • getBuildDir

        public java.io.File getBuildDir()
      • setBuildDir

        public void setBuildDir​(java.io.File buildDir)
      • isValid

        public boolean isValid()
      • getRepository

        public RepositoryPlugin getRepository​(java.lang.String repo)
                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class Processor
      • getDriver

        public java.lang.String getDriver()
        Get the bnddriver, can be null if not set. The overallDriver is the environment that runs this bnd.
      • setDriver

        public static void setDriver​(java.lang.String driver)
        Set the driver of this environment
      • _driver

        public java.lang.String _driver​(java.lang.String[] args)
        Macro to return the driver. Without any arguments, we return the name of the driver. If there are arguments, we check each of the arguments against the name of the driver. If it matches, we return the driver name. If none of the args match the driver name we return an empty string (which is false).
      • addGestalt

        public static void addGestalt​(java.lang.String part,
                                      Attrs attrs)
        Add a gestalt to all workspaces. The gestalt is a set of parts describing the environment. Each part has a name and optionally attributes. This method adds a gestalt to the VM. Per workspace it is possible to augment this.
      • getGestalt

        public Attrs getGestalt​(java.lang.String part)
        Get the attrs for a gestalt part
      • getGestalt

        public Parameters getGestalt()
        Get the attrs for a gestalt part
      • getLayout

        public WorkspaceLayout getLayout()
        Get the layout style of the workspace.
      • _gestalt

        public java.lang.String _gestalt​(java.lang.String[] args)
        The macro to access the gestalt

        $ gestalt;part[;key[;value]]

      • toString

        public java.lang.String toString()
        Description copied from class: Processor
        Printout of the status of this processor for toString()
        Overrides:
        toString in class Processor
      • addPlugin

        public boolean addPlugin​(java.lang.Class<?> plugin,
                                 java.lang.String alias,
                                 java.util.Map<java.lang.String,​java.lang.String> parameters,
                                 boolean force)
                          throws java.lang.Exception
        Add a plugin
        Parameters:
        plugin -
        Throws:
        java.lang.Exception
      • removePlugin

        public boolean removePlugin​(java.lang.String alias)
      • createStandaloneWorkspace

        public static Workspace createStandaloneWorkspace​(Processor run,
                                                          java.net.URI base)
                                                   throws java.lang.Exception
        Create a workspace that does not inherit from a cnf directory etc.
        Parameters:
        run -
        Throws:
        java.lang.Exception
      • isDefaultWorkspace

        public boolean isDefaultWorkspace()
      • isInteractive

        public boolean isInteractive()
        Description copied from class: Processor
        Return if this is an interactive environment like Eclipse or runs in batch mode. If interactive, things can get refreshed.
        Overrides:
        isInteractive in class Processor
      • resetStatic

        public static void resetStatic()
      • createProject

        public Project createProject​(java.lang.String name)
                              throws java.lang.Exception
        Create a project in this workspace
        Throws:
        java.lang.Exception
      • createWorkspace

        public static Workspace createWorkspace​(java.io.File wsdir)
                                         throws java.lang.Exception
        Create a new Workspace
        Parameters:
        wsdir -
        Throws:
        java.lang.Exception
      • readLocked

        public <T> T readLocked​(java.util.concurrent.Callable<T> r,
                                long timeoutInMs)
                         throws java.lang.Exception
        Lock the workspace and its corresponding projects for reading. The r parameter when called can freely use any read function in the workspace.
        Parameters:
        r - the lambda to run
        timeoutInMs - the timeout in milliseconds
        Returns:
        the value of the lambda
        Throws:
        java.lang.Exception
      • readLocked

        public <T> T readLocked​(java.util.concurrent.Callable<T> r)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writeLocked

        public <T> T writeLocked​(java.util.concurrent.Callable<T> r,
                                 long timeoutInMs)
                          throws java.lang.Exception
        Lock the workspace and its corresponding projects for all functions. The r parameter when called can freely use any function in the workspace.
        Parameters:
        r - the lambda to run
        timeoutInMs - the timeout in milliseconds
        Returns:
        the value of the lambda
        Throws:
        java.lang.Exception
      • writeLocked

        public <T> T writeLocked​(java.util.concurrent.Callable<T> r)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _projectswhere

        public java.lang.String _projectswhere​(java.lang.String[] args)
      • search

        public Result<java.util.Map<java.lang.String,​java.util.List<BundleId>>,​java.lang.String> search​(java.lang.String partialFqn)
                                                                                                             throws java.lang.Exception
        Search for a partial class name. The partialFqn name may be a simple class name (Foo) or a fully qualified class name line (foo.bar.Foo), including nested classes, or only a package name prefix (foo.bar or even foo.ba).

        This method uses the heuristic in determine() to split the package name from the (possibly nested) class name - the start of the class name is taken as the first element that starts with a capital letter. This heuristic works fine in most cases, but it is not foolproof. In contexts where you have a better idea of how to separate the package name from the class name, you can use search(String, String) for this purpose.

        Parameters:
        partialFqn - a packagename ( '.' classname )*
        Returns:
        a multi-map containing the search matches with the matching fully-qualified class name as each entry's key, and a list of matching bundles as the value.
        Throws:
        java.lang.Exception
        See Also:
        search(String, String)
      • search

        public Result<java.util.Map<java.lang.String,​java.util.List<BundleId>>,​java.lang.String> search​(java.lang.String packageName,
                                                                                                                    java.lang.String className)
                                                                                                             throws java.lang.Exception
        Search for a class name inside particular package. Use this in preference to search(String) when you know that the qualifier resolves to a package and not to a class.
        Parameters:
        packageName - the package to search
        className - a classname ( '.' classname )*
        Returns:
        a multi-map containing the search matches with the matching fully-qualified class name as each entry's key, and a list of matching bundles as the value.
        Throws:
        java.lang.Exception
        See Also:
        search(String)
      • _findproviders

        public java.lang.String _findproviders​(java.lang.String[] args)
                                        throws java.lang.Exception
        A macro that returns a set of resources in bundle selection format from the repository. For example:
         ${findproviders;osgi.wiring.package;(osgi.wiring.package=aQute.bnd.build)}
         
        Throws:
        java.lang.Exception
      • findProviders

        public java.util.stream.Stream<org.osgi.resource.Capability> findProviders​(java.lang.String namespace,
                                                                                   java.lang.String filter)
                                                                            throws java.lang.Exception
        Convenient findProviders
        Throws:
        java.lang.Exception
      • getBundle

        public Result<java.io.File,​java.lang.String> getBundle​(org.osgi.resource.Resource resource)
      • getBundle

        public Result<java.io.File,​java.lang.String> getBundle​(java.lang.String bsn,
                                                                     Version version,
                                                                     java.util.Map<java.lang.String,​java.lang.String> attrs)