Skip to content

Add OpEnvironment API to Generate OpInfos from a Collection/Array of Classes #80

Closed
scijava/incubator
#51

Description

@gselzer

We need to replace the functionality of SciJava Common's plugin framework. The best way I can think of is to use ServiceLoader to declare some OpEnvironmentFactory implementations, which are capable of returning an OpEnvironment. This OpEnvironmentFactory should have:

  • A method OpEnvironment create()
  • Some prioritization mechanism allowing us to choose a single OpEnvironment when given multiple OpEnvironmentFactory objects without having to hardcode an implementation class.

The problem with this implementation is that it becomes extremely difficult to modify the OpEnvironment. Currently, the only functionality available is register(OpInfo info), which is not helpful when we will no longer have access to the OpInfoGenerators and Discoverers created by the OpEnvironmentFactory.

What we need is a more powerful API for adding Ops to the OpEnvironment. For now, I like the idea of

public Iterable<OpInfo> registerFrom(Class<?>... classes);

Such functionality should be able to parse a set of OpInfos from each of the elements of classes and insert them into the op directory of the OpEnvironment. Issues to implementing such API:

  • The OpInfoGenerators cannot generate a List<OpInfo> from a Class, but only from a Discoverer (which it holds as its state). OpInfoGenerators should instead have a (static?) method that takes a Collection<? extends Class<?>> and returns a List<OpInfo>. OpInfoGenerators use the functionality of Discoverer, however, so that must be reconciled.
  • DefaultOpEnvironment lazily initializes its opDirectory, which causes a nightmare when trying to add new Ops. Currently, any call to register(OpInfo) will populate the entire opDirectory (which, depending on the Discoverers available, can take a while). We need to refactor the DefaultOpEnvironment to be smarter.
  • Discoverer has two different methods, implsOfType() and elementsTaggedWith(). We need a wrapper that can combine the returns from both methods, returning a List<Class<?>> that can be passed to the OpInfoGenerators.

For now, to continue development, we can use the HACK of scijava/incubator@67bef74

Activity

  1. added this to the 1.0.0 milestone on Nov 4, 2021
  2. self-assigned this
    on Nov 4, 2021
  3. added 2 commits that reference this issue on May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions