Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Recommendations for adding plugin/addon capability to a program

by sundialsvc4 (Abbot)
on Dec 31, 2013 at 00:05 UTC ( #1068785=note: print w/ replies, xml ) Need Help??


in reply to Recommendations for adding plugin/addon capability to a program

I would probably use the existing class-hierarchy capabilities of the Perl language, and perhaps the very-goodness of UNIVERSAL::require.

Your system would stipulate that all plugins must inherit from some base-class (perhaps “among others”) via a use base statement.   It would also require that the modules live in some specified location.   When a new plugin was requested, it would attempt to require the appropriate module, then, if successful in doing that, would perhaps call some class-method to initialize it.

Okay, for a brass-tacks example of what I am talking about, peruse http://search.cpan.org/~mkanat/RPC-Any-1.00/lib/RPC/Any/Server.pm#HOW_RPC_METHODS_ARE_CALLED which describes a similar “plugin” notion in the context of an RPC-server which loads request-handling modules on demand.   There are many others.   Study the source-code of “live examples” to see exactly how they did it.


Comment on Re: Recommendations for adding plugin/addon capability to a program

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-07-28 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls