1

I would like to implement a plugin mechanism where js code is stored in a database and dynamically loaded into the class. A query for a specific plugin is performed, then the code resulting from the query is used to update a javascript class (functions and members).

So what I would achieve is that part of the class is loaded at startup from the JS class file and additional parts of the class are loaded from the db, and eventually unloaded, at runtime, giving it more functionalities.

Is this feasible? how to create a function from string? do you think it is a good approach?

JS Framework is ExtJS 4.1.1, database is postgres 9.2

Thanks

1 Answer 1

1

I'm new to ExtJS, but I would not recommend this way to do.

  1. ExtJS has a recommended directory hierarchy and a command line build tool, that is powerful. Download it and play around with a test app. You will see if you can combine your approach with this. I really doubt. If you want to stick to your approach, you must somehow get it to be compatible with the basic requirements and recommandation of ExtJS application architecture.
  2. Think about maintainability. How do you update the code in your database ? Will the code in your development version also be in the DB ?
    Yes: This will be very impracticle for development
    No: Your build process will quite be heavy and convoluted.

My personal approach with plugins of the app is like this:

  1. In my database I store which user has access to which plugin. I also store dependecies. I send this information to the client in a simple array containing the list of the plugins the user is authorized to use.
  2. The application code is the same for everyone. This allows me to use one only minified javascript file, I build with the sencha app build command line.
  3. I load the plugins happens in the launch method of Ext.application what I'm doing is basicly add each plugin's menu to the main menu.
  4. To secure the access to the plugins, the whole php backend is secured to ensure that a user only can access a feature he is allowed to.

I hope this will give some inspiration to develop a more simple concept.

Sign up to request clarification or add additional context in comments.

1 Comment

1. not compatible with my approach 2. Agree, now storing on DB only plugin name and path to the plugin file on disk. Current architecture is designed on a per functionality basis. It means that all users have the same priviledges. The code handles a set of lists, most of the lists are of the same nature, other are "special". Well, when user clicks or open such lists then list name plugin apply. The framework remains unchanged, the class is updated dynamically with the code from plugin. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.