Class Workspace

All Implemented Interfaces:
Constants, Registry, Report, Reporter, Closeable, AutoCloseable, Iterable<String>

public class Workspace extends Processor
  • Field Details

  • Constructor Details

  • Method Details

    • getProject

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

      public static Processor getDefaults()
    • createDefaultWorkspace

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

      public static Workspace getWorkspace(File workspaceDir) throws Exception
      Throws:
      Exception
    • getWorkspaceWithoutException

      public static Workspace getWorkspaceWithoutException(File workspaceDir) throws Exception
      Throws:
      Exception
    • findWorkspace

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

      public static Workspace getWorkspace(File workspaceDir, String bndDir) throws Exception
      Throws:
      Exception
    • setFileSystem

      public void setFileSystem(File workspaceDir, String bndDir) throws Exception
      Throws:
      Exception
    • getProjectFromFile

      public Project getProjectFromFile(File projectDir)
    • getProject

      public Project getProject(String bsn)
    • isPresent

      public boolean isPresent(String name)
    • refresh

      public boolean refresh()
      Overrides:
      refresh in class Processor
    • 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.
    • propertiesChanged

      public void propertiesChanged()
      Overrides:
      propertiesChanged in class Processor
    • _workspace

      public String _workspace(String[] args)
    • addCommand

      public void addCommand(String menu, Action action)
    • removeCommand

      public void removeCommand(String menu)
    • fillActions

      public void fillActions(Map<String,Action> all)
    • getAllProjects

      public Collection<Project> getAllProjects()
    • getCurrentProjects

      public Collection<Project> getCurrentProjects()
      See Also:
    • changedFile

      public void changedFile(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(Reporter reporter)
    • signal

      public void signal()
      Overrides:
      signal in class Processor
    • syncCache

      public void syncCache() throws Exception
      Throws:
      Exception
    • getRepositories

      public List<RepositoryPlugin> getRepositories()
    • initRepositories

      private List<RepositoryPlugin> initRepositories()
    • getBuildOrder

      public Collection<Project> getBuildOrder() throws Exception
      Throws:
      Exception
    • getBuildOrder

      private void getBuildOrder(Collection<Project> dependsOn, Set<Project> result) throws Exception
      Throws:
      Exception
    • getWorkspace

      public static Workspace getWorkspace(String path) throws Exception
      Throws:
      Exception
    • getMaven

      public Maven getMaven()
    • setTypeSpecificPlugins

      protected void setTypeSpecificPlugins(Set<Object> list)
      Overrides:
      setTypeSpecificPlugins in class Processor
    • addExtensions

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

      public boolean isOffline()
    • getOffline

      public AtomicBoolean getOffline()
    • setOffline

      public Workspace setOffline(boolean on)
    • _global

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

      public String _user(String[] args) throws Exception
      Throws:
      Exception
    • _repodigests

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

      public static Run getRun(File file) throws Exception
      Throws:
      Exception
    • report

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

      public File getCache(String name)
    • getWorkspaceRepository

      public WorkspaceRepository getWorkspaceRepository()
      Return the workspace repo
    • checkStructure

      public void checkStructure()
    • getBuildDir

      public File getBuildDir()
    • setBuildDir

      public void setBuildDir(File buildDir)
    • isValid

      public boolean isValid()
    • getRepository

      public RepositoryPlugin getRepository(String repo) throws Exception
      Throws:
      Exception
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class Processor
    • refreshData

      private void refreshData()
    • getDriver

      public 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(String driver)
      Set the driver of this environment
    • _driver

      public String _driver(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(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(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 String _gestalt(String[] args)
      The macro to access the gestalt

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

    • toString

      public 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(Class<?> plugin, String alias, Map<String,String> parameters, boolean force) throws Exception
      Add a plugin
      Parameters:
      plugin -
      Throws:
      Exception
    • newInstance

      private static <T> T newInstance(Class<T> rawClass) throws Exception
      Throws:
      Exception
    • escaped

      private Object escaped(String value)
    • removePlugin

      public boolean removePlugin(String alias)
    • createStandaloneWorkspace

      public static Workspace createStandaloneWorkspace(Processor run, URI base) throws Exception
      Create a workspace that does not inherit from a cnf directory etc.
      Parameters:
      run -
      Throws:
      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(String name) throws Exception
      Create a project in this workspace
      Throws:
      Exception
    • removeProject

      void removeProject(Project p) throws Exception
      Throws:
      Exception
    • createWorkspace

      public static Workspace createWorkspace(File wsdir) throws Exception
      Create a new Workspace
      Parameters:
      wsdir -
      Throws:
      Exception
    • readLocked

      public <T> T readLocked(Callable<T> r, long timeoutInMs) throws 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:
      Exception
    • readLocked

      public <T> T readLocked(Callable<T> r) throws Exception
      Throws:
      Exception
    • writeLocked

      public <T> T writeLocked(Callable<T> r, long timeoutInMs) throws 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:
      Exception
    • writeLocked

      public <T> T writeLocked(Callable<T> r) throws Exception
      Throws:
      Exception
    • locked

      <T> T locked(Callable<T> r, long timeoutInMs, Lock readLock) throws Exception
      Throws:
      Exception
    • _projectswhere

      public String _projectswhere(String[] args)
    • refresh

      public void refresh(RepositoryPlugin repo)
    • search

      public Result<Map<String,List<BundleId>>,String> search(String partialFqn) throws 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:
      Exception
      See Also:
    • search

      public Result<Map<String,List<BundleId>>,String> search(String packageName, String className) throws 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:
      Exception
      See Also:
    • getResourceRepository

      org.osgi.service.repository.Repository getResourceRepository() throws Exception
      Return an aggregate repository of all the workspace's repository and the projects repository. This workspace must be gotten for each operation, it might become stale over time.

      TODO make this public in 5.2.0 & use everywhere

      Returns:
      an aggregate repository
      Throws:
      Exception
    • _findproviders

      public String _findproviders(String[] args) throws 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:
      Exception
    • findProviders

      public Stream<org.osgi.resource.Capability> findProviders(String namespace, String filter) throws Exception
      Convenient findProviders
      Throws:
      Exception
    • getExternalPlugins

      public WorkspaceExternalPluginHandler getExternalPlugins()
      Execute a function with a class from a plugin loaded from the repositories. See WorkspaceExternalPluginHandler.
    • getBundle

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

      public Result<File,String> getBundle(String bsn, Version version, Map<String,String> attrs)