Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by sundialsvc4 (Monsignor)
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 scrutinizing the Monastery: (14)
As of 2014-09-17 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (89 votes), past polls