0

MEF for dynamic load of process definitions

We have an application comprised of several parts:

  • ModelBuilder: domain model that allows the building of ProcessDefinitions (Activities, gateways, events, etc.) and Tasks.
  • Concrete ProcessDefinitions: collections of ProcessDefinitions that solve certain business. Each assembly contains a collection of concrete ProcessDefinitions, Tasks, etc.
  • Runtime: we would like it to load dynamically the assemblies containing Concrete ProcessDefinitions and be able to find them through a simple service, FindProcessDefinition(proceedingId,versionPolicy), which would look in all the Concrete ProcessDefinition parts. ProcessDefinition must be cached/singleton.

Do you think MEF could be the way to go with this problem? I have seen examples of MEF but they are used to implement interfaces, not for this "build" pattern.

Any hint of how to do it? Any other alternative? Thanks.

1 Answers1

0

If your concrete processdefinitions and the builders that instantiate those classes do not have a common interface then MEF doesn't seem the correct tool (imo).

Perhaps you could have the builders each implement a common interface. But then each concrete process definition would also need a common interface. That does not seem to be the case. In your code you don't do:

new ConcreteProcessDefinition1.run() 

and

new ConcreteProcessDefinition2.run(), 

In your code you do something like

ConcreteProcessDefinition1.doXYZ(input1, input2)

and

ConcreteProcessDefinition2.doSomethingTotallyDifferent(input3)

Why do you need to dynamically load the process definitions? Will your clients (who don't have access to your source code) create process definitions?

robor
  • 2,969
  • 2
  • 31
  • 48
  • ConcreteProcessDefinition : IProcessDefinition, they have a common interface. The builder is used by parts just to create ConcreteProcessDefinitions so it wouldn't be problematic to create an interface for it. – user1453555 Jun 13 '12 at 21:09
  • About the last question, Why. In order to simplify I didn't mention that we have a graphic tool that allows us to draw Process Definitions that are converted to Builder semnatics. Our plan is to deliver these definitions in dll's that can be loaded by the runtime. – user1453555 Jun 13 '12 at 21:13