Jedi Plugin feature modification by Cyclatron 11/24/2010, thought I'd share.


Why :  I needed inner-module communication so I added some things..

1) Added non-published event property for the Host within the Plugin class that fires when a plug-in 
   calls broadcast. ->All loaded plug-ins<- can get messages through plug-in manager.  Nothing special 
   need be done.

2) Added published event property in Host that fires when messages are received. 
   Originator does not receive it's own messages. (There's no message looping).

3) Added ability to pass objects between modules (plug-in to plug-in). ShareMEM 
   required when doing this.

You'll need to copy the Jedi Plugin source to the Jedi run directory and recompile.
I tried to make sure everything I did, did not affect the current implementation,
meaning it's not going to screw-up existing users.  Methods were added rather
then changed.

------------------------------

*Tested with D7 and D2010. Both work. Not checked for leaks. 
*Recommended FastMM (FastMM497.zip) usage for ShareMem replacement.
*D2010 will upgrade the D7 project.
*All output files need to be outputted to same directory.
*Basic BDE and demo tables required for demo project.

*In the demo project you find most of work being done by the plug-ins with
the host controller just listening. Unlike (I think) the other demos this one
operates mostly plug-in to plug-in. The form in the demo also has easy 
access to the plug-in hosting it.  I think the demo mimics structurally 
closer too something I might write so that's why I made it.

-------------------------------

Changes to JvPlugin.pas

1) Added a new message type, TPluginMessageObjEvent. This version carries a object with messages.
2) Added new set of event fields for the TPluginMessageObjEvent.  Added to leave existing code intact.
3) Removed TriggerPluginMessageEvent. Not needed
4) Added OnPluginBroadcast and OnPluginBroadcastObj for Host to hook up to, fires when plug-ins broadcast.
5) Added OnPluginMessageWithjObj Event for new message type receiving within plug-in.

Changes to JvPluginManager.pas

1) Added FPluginHostMessage with uses the new TPluginMessageObjEvent. Still fires with old message type 
   but AObj parameter will be  nil.
2) Added to compatible methods for Host to assign to the Plug-in's broadcasting events. ReBroadcastMessages
   and ReBroadcastMessagesObj. They send out the messages from the plug-ins.
3) Added OnPluginHostMessage property that can be used to listen to plug-in message traffic.

Source Diff included.

More notes..  Read Article submitted by Emil Santos called "Delphi memory manager problems 
in dynamic libraries".  Didn't realize how much of a problem working with DLLs was till I started
doing it.  Thought about it and I think I fall into the "Use Sharemem.pas/Borlndmm.dll, and proceed 
normally" camp.  The project I'm working only requires the Delphi I'm working with so the modifications
done work for me. If you need plug-ins for working other compilers, well... I don't think the JV 
plug-ins created before the mods would of worked either (correct me if I'm wrong). Way I see it, mods just make
a more usable version of what is available.  I did have a few ideas I had that I'll share.  Let me
know about any mistakes, always interested in where I screwed up!  Especially on this topic.

1) One idea involved using a available library that pipes values through a memory map file to other modules. 
You could have another component, no matter the environment, interpret the stream and reconstruct a common object 
structure using some sort of common object structure schema. Not talking about re-creating the VCL, just a mutual 
transfer data-store object.  Would solve problems with transferring data across modules but it's very limited.

2) Next idea is similar but uses the VCL in another Delphi to instruct a module on what object to create
on the receivers side, then pipes the values.  This one involves a component that is placed on the
plug-in's DM form and connects with other modules it finds through the plug-in manager. Transfer calls to component 
copy or transport the objects across modules taking into account differences in the VCLS.

Article Url : http://delphi.about.com/od/objectpascalide/l/aa103003b.htm

Going to look into interfaces next (when I get around to it). Anyways, anymore updates I do, I'll share.  

Have a nice day,
Cyclatron.