Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTCOMM-2064: Refactor ExtensionController and implement getEffectiveConfiguration #2923

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

abdulazizali77
Copy link
Contributor

What this PR does / why we need it:
Centralize configuration hierarchy lookup in getEffectiveConfiguration. Add an ExtensionContext interface for implementing extensions to access public extension framework functionality.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes # RESTCOMM-2064, RESTCOMM-1617

Special notes for your reviewer:
Decided to go with ExtensionContext instead of ExtensionControllerFacade.
One other possible option is to not have ExtensionController implement ExtensionContext but create new ExtensionContextImpl class instead

…roller with ExtensionContext. Implement getEffectiveConfiguration in impl. Add init to ExtensionController to initialize ServletContext.
@abdulazizali77 abdulazizali77 requested a review from a team April 19, 2018 04:55
OrganizationsDao od = daoManager.getOrganizationsDao();
ExtensionConfiguration extCfg = ecd.getAccountExtensionConfiguration(scopeSid, extensionSid);

Sid sid = new Sid(scopeSid);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we save cost of multiple queries here by querying the exact dao which sid belong to

*/
package org.restcomm.connect.extension.api;

public interface ExtensionContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea of having a Context for extension was already in my mind. Could we inject this through the actual extension points, instead of using servletContext?

private final String id;

public enum Type {
ACCOUNT, APPLICATION, ANNOUNCEMENT, CALL, CLIENT, CONFERENCE, GATEWAY, INVALID, NOTIFICATION, PHONE_NUMBER, RECORDING, REGISTRATION, SHORT_CODE, SMS_MESSAGE, TRANSCRIPTION, INSTANCE, EXTENSION_CONFIGURATION, GEOLOCATION, ORGANIZATION, PROFILE
CALL(null, CALL_SID_STRING),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how this Sid refactoring is related to original PR issue, but im fine with it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went overboard with it, we just needed to add a getType to the Sid because we dont know what the incoming Sid is in getEfectiveConfiguration

@@ -43,6 +44,8 @@
public ExtensionBootstrapper(final ServletContext context, final Configuration configuration) {
this.configuration = configuration;
this.context = context;
this.context.setAttribute(ExtensionContext.class.getName(), ExtensionController.getInstance());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this anylonger?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

/**
* @param set ExtensionContext
*/
void setExtensionContext(ExtensionContext ec);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need the setter in the interface, but is a minor thing now

@abdulazizali77
Copy link
Contributor Author

@jaimecasero @maria-farooq PTAL

@gvagenas
Copy link
Contributor

gvagenas commented Apr 24, 2018

Team, I did a review in this branch and here is my comment related to the Configuration sets we make available to the Extensions.

So we have two sets of configuration sets

  1. First set is the extension base configuration which is expressed as a sub-class of DefaultExtensionConfiguration. This configuration set is somewhat static (file based or similar)

  2. And the second set, the configuration expressed with the ExtensionConfiguration object that contains the extension’s rules private Object configurationData and have some common properties with the first set, the default conf, such as the private boolean enabled;. We use the common properties in order to dynamically control an extension by updating the DB record, for example, disable an extension at runtime. This configuration set is stored in DB and we provide DAO and now with this PR, we provide ExtensionController.getEffectiveConfiguration to retrieve this configuration set.

The separation of concerns between those two configuration sets is clear but the naming used so far is ambiguous and doesn't make clear what is the role of each configuration sets.

For this reason, I suggest a name change for the ExtensionConfiguration to ExtensionRules in order to be more clear what this object represents.

In future work on the Extension API, where we plan for handling configuration the same way we handle Profiles, we should merge the two sets of configuration (DefaultConfiguration and ExtensionRules) and let the ExtensionController provide the methods to retrieve each subset of the conf, for example

  • ExtensionController.getBaseConfiguration(Sid extensionSid)
  • ExtensionController.getEffectiveConfiguration(Sid extensionSid, Sid accountSid)
  • ExtensionController.getEffectiveConfiguration(Sid extensionSid, Sid clientSid)
  • ExtensionController.getEffectiveConfiguration(Sid extensionSid, Sid orgSid)

As part of this story and PR, I will provide the ExtensionConfiguration renaming to ExtensionRules

Important
Database table restcomm_extensions_configuration and rest api endpoint path @path("/ExtensionsConfiguration") will NOT be refactored in order to avoid DB migration scripts and uneccessary changes in the REST API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants