{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/82629237","pull_request_review_id":3523383,"id":82629237,"diff_hunk":"@@ -91,87 +91,162 @@\n public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvider>\n         implements RuleRegistry, StatusInfoCallback {\n \n+    private static final String SOURCE = RuleRegistryImpl.class.getSimpleName();\n+    private static final Logger LOGGER = LoggerFactory.getLogger(RuleRegistryImpl.class.getName());\n+    private BundleContext bundleContext;\n     private RuleEngine ruleEngine;\n-    private Logger logger;\n+    private StorageService storageService;\n     private Storage<Boolean> disabledRulesStorage;\n-    private TemplateManager templateManager;\n+    private ModuleTypeRegistry moduleTypeRegistry;\n+    private TemplateRegistry templateRegistry;\n+\n+    @SuppressWarnings(\"rawtypes\")\n+    private ServiceRegistration ruleRegistryReg;\n+    @SuppressWarnings(\"rawtypes\")\n+    private ServiceRegistration managedRuleProviderReg;\n \n     /**\n      * {@link Map} of template UIDs to rules where these templates participated.\n      */\n     private Map<String, Set<String>> mapTemplateToRules = new HashMap<String, Set<String>>();\n-    @SuppressWarnings(\"rawtypes\")\n-    private ServiceTracker templateProviderTracker;\n \n-    private static final String SOURCE = RuleRegistryImpl.class.getSimpleName();\n+    public RuleRegistryImpl() {\n+        super(RuleProvider.class);\n+    }\n \n-    @SuppressWarnings({ \"rawtypes\", \"unchecked\" })\n-    public RuleRegistryImpl(RuleEngine ruleEngine, TemplateManager tManager, final BundleContext bc) {\n-        super(null);\n-        logger = LoggerFactory.getLogger(getClass());\n-        this.ruleEngine = ruleEngine;\n-        this.templateManager = tManager;\n-        ruleEngine.setStatusInfoCallback(this);\n-        templateProviderTracker = new ServiceTracker(bc, TemplateProvider.class.getName(),\n-                new ServiceTrackerCustomizer() {\n-\n-                    @Override\n-                    public Object addingService(ServiceReference reference) {\n-                        TemplateProvider provider = (TemplateProvider) bc.getService(reference);\n-                        templateUpdated(provider.getTemplates(null));\n-                        return provider;\n-                    }\n+    /**\n+     * Activates this component. Called from DS.\n+     *\n+     * @param componentContext this component context.\n+     * @throws Exception\n+     */\n+    protected void activate(ComponentContext componentContext) throws Exception {\n+        this.bundleContext = componentContext.getBundleContext();\n+        this.ruleEngine = new RuleEngine(bundleContext, moduleTypeRegistry);\n+        this.ruleEngine.setStatusInfoCallback(this);\n+        super.activate(bundleContext);\n+    }\n \n-                    @Override\n-                    public void modifiedService(ServiceReference reference, Object service) {\n-                        TemplateProvider provider = (TemplateProvider) bc.getService(reference);\n-                        templateUpdated(provider.getTemplates(null));\n+    /**\n+     * Deactivates this component. Called from DS.\n+     *\n+     * @param componentContext this component context.\n+     */\n+    protected void deactivate(ComponentContext componentContext) {\n+        super.deactivate();\n+        // removeManagedProvider(managedProvider);\n+        ruleEngine.dispose();\n+        ruleEngine = null;\n+    }\n \n-                    }\n+    /**\n+     * Bind the {@link ModuleTypeRegistry} service - called from DS.\n+     *\n+     * @param moduleTypeRegistry moduleTypeRegistry service.\n+     */\n+    protected void setModuleTypeRegistry(ModuleTypeRegistry moduleTypeRegistry) {\n+        this.moduleTypeRegistry = moduleTypeRegistry;\n+    }\n \n-                    @Override\n-                    public void removedService(ServiceReference reference, Object service) {\n-                    }\n+    /**\n+     * Unbind the {@link ModuleTypeRegistry} service - called from DS.\n+     *\n+     * @param moduleTypeRegistry moduleTypeRegistry service.\n+     */\n+    protected void unsetModuleTypeRegistry(ModuleTypeRegistry moduleTypeRegistry) {\n+        this.moduleTypeRegistry = null;\n+    }\n \n-                });\n-        templateProviderTracker.open();\n+    /**\n+     * Bind the {@link TemplateRegistry} service - called from DS.\n+     *\n+     * @param templateRegistry templateRegistry service.\n+     */\n+    protected void setTemplateRegistry(TemplateRegistry templateRegistry) {\n+        this.templateRegistry = templateRegistry;\n+    }\n \n+    /**\n+     * Unbind the {@link TemplateRegistry} service - called from DS.\n+     *\n+     * @param templateRegistry templateRegistry service.\n+     */\n+    protected void unsetTemplateRegistry(TemplateRegistry templateRegistry) {\n+        this.templateRegistry = null;\n+    }\n+\n+    protected void setStorageService(StorageService storageService) {\n+        // this.storageService = storageService;","path":"bundles/automation/org.eclipse.smarthome.automation.core/src/main/java/org/eclipse/smarthome/automation/core/internal/RuleRegistryImpl.java","position":146,"original_position":146,"commit_id":"b086e7a64b11e5f136ec1f7d280b4a7c510951da","original_commit_id":"b086e7a64b11e5f136ec1f7d280b4a7c510951da","user":{"login":"kaikreuzer","id":3244965,"avatar_url":"https://avatars.githubusercontent.com/u/3244965?v=3","gravatar_id":"","url":"https://api.github.com/users/kaikreuzer","html_url":"https://github.com/kaikreuzer","followers_url":"https://api.github.com/users/kaikreuzer/followers","following_url":"https://api.github.com/users/kaikreuzer/following{/other_user}","gists_url":"https://api.github.com/users/kaikreuzer/gists{/gist_id}","starred_url":"https://api.github.com/users/kaikreuzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaikreuzer/subscriptions","organizations_url":"https://api.github.com/users/kaikreuzer/orgs","repos_url":"https://api.github.com/users/kaikreuzer/repos","events_url":"https://api.github.com/users/kaikreuzer/events{/privacy}","received_events_url":"https://api.github.com/users/kaikreuzer/received_events","type":"User","site_admin":false},"body":"1) Ok, RuleRegistry can have a 0:1 dependency on ManagedRuleProvider.\r\n2) It it is a static dependency, the RuleRegistry can be sure to have the ManagedRuleProvider injected before activate() is called - so it can deal with the priority.\r\n3) \"It starts RuleEngine.\" -> imho, it shouldn't. The RuleEngine could be a service on its own, having a dependency on the RuleRegistry.\r\n4) Then it definitely should be its on DS component and not be started by the RuleRegistry.","created_at":"2016-10-10T15:40:31Z","updated_at":"2016-10-10T15:40:31Z","html_url":"https://github.com/eclipse/smarthome/pull/2194#discussion_r82629237","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/2194","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/82629237"},"html":{"href":"https://github.com/eclipse/smarthome/pull/2194#discussion_r82629237"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/2194"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/2194","id":85920777,"html_url":"https://github.com/eclipse/smarthome/pull/2194","diff_url":"https://github.com/eclipse/smarthome/pull/2194.diff","patch_url":"https://github.com/eclipse/smarthome/pull/2194.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/2194","number":2194,"state":"open","locked":false,"title":"Refactored automation.core & adapted to use Declarative Services","user":{"login":"vilchev","id":12597047,"avatar_url":"https://avatars.githubusercontent.com/u/12597047?v=3","gravatar_id":"","url":"https://api.github.com/users/vilchev","html_url":"https://github.com/vilchev","followers_url":"https://api.github.com/users/vilchev/followers","following_url":"https://api.github.com/users/vilchev/following{/other_user}","gists_url":"https://api.github.com/users/vilchev/gists{/gist_id}","starred_url":"https://api.github.com/users/vilchev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vilchev/subscriptions","organizations_url":"https://api.github.com/users/vilchev/orgs","repos_url":"https://api.github.com/users/vilchev/repos","events_url":"https://api.github.com/users/vilchev/events{/privacy}","received_events_url":"https://api.github.com/users/vilchev/received_events","type":"User","site_admin":false},"body":"Activator, ModuleTypeManager,TemplateManager - removed \r\nRuleRegistry, RuleEventFactory, ModuleTypeRegistry, TemplateRegistry - extracted as DS components\r\nrefactored code\r\n\r\nSigned-off-by: Vasil Ilchev <v.ilchev@prosyst.bg>","created_at":"2016-09-20T07:00:17Z","updated_at":"2016-10-10T15:40:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7c92781013b23e25b7dffb91e50aac3be20d11d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/2194/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/2194/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/2194/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/b086e7a64b11e5f136ec1f7d280b4a7c510951da","head":{"label":"vilchev:automation_core_ds","ref":"automation_core_ds","sha":"b086e7a64b11e5f136ec1f7d280b4a7c510951da","user":{"login":"vilchev","id":12597047,"avatar_url":"https://avatars.githubusercontent.com/u/12597047?v=3","gravatar_id":"","url":"https://api.github.com/users/vilchev","html_url":"https://github.com/vilchev","followers_url":"https://api.github.com/users/vilchev/followers","following_url":"https://api.github.com/users/vilchev/following{/other_user}","gists_url":"https://api.github.com/users/vilchev/gists{/gist_id}","starred_url":"https://api.github.com/users/vilchev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vilchev/subscriptions","organizations_url":"https://api.github.com/users/vilchev/orgs","repos_url":"https://api.github.com/users/vilchev/repos","events_url":"https://api.github.com/users/vilchev/events{/privacy}","received_events_url":"https://api.github.com/users/vilchev/received_events","type":"User","site_admin":false},"repo":{"id":36233901,"name":"eclipse-smarthome","full_name":"vilchev/eclipse-smarthome","owner":{"login":"vilchev","id":12597047,"avatar_url":"https://avatars.githubusercontent.com/u/12597047?v=3","gravatar_id":"","url":"https://api.github.com/users/vilchev","html_url":"https://github.com/vilchev","followers_url":"https://api.github.com/users/vilchev/followers","following_url":"https://api.github.com/users/vilchev/following{/other_user}","gists_url":"https://api.github.com/users/vilchev/gists{/gist_id}","starred_url":"https://api.github.com/users/vilchev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vilchev/subscriptions","organizations_url":"https://api.github.com/users/vilchev/orgs","repos_url":"https://api.github.com/users/vilchev/repos","events_url":"https://api.github.com/users/vilchev/events{/privacy}","received_events_url":"https://api.github.com/users/vilchev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vilchev/eclipse-smarthome","description":"Eclipse SmartHome project","fork":true,"url":"https://api.github.com/repos/vilchev/eclipse-smarthome","forks_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/forks","keys_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/teams","hooks_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/hooks","issue_events_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/events","assignees_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/tags","blobs_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/languages","stargazers_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/stargazers","contributors_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/contributors","subscribers_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/subscribers","subscription_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/subscription","commits_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/merges","archive_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/downloads","issues_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/labels{/name}","releases_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/vilchev/eclipse-smarthome/deployments","created_at":"2015-05-25T13:52:03Z","updated_at":"2016-03-21T14:24:14Z","pushed_at":"2016-10-05T09:03:51Z","git_url":"git://github.com/vilchev/eclipse-smarthome.git","ssh_url":"git@github.com:vilchev/eclipse-smarthome.git","clone_url":"https://github.com/vilchev/eclipse-smarthome.git","svn_url":"https://github.com/vilchev/eclipse-smarthome","homepage":null,"size":21324,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"e7244ea77239b0a149c44c1397ef214c4bda27b1","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"name":"smarthome","full_name":"eclipse/smarthome","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/smarthome/deployments","created_at":"2014-01-09T20:47:19Z","updated_at":"2016-10-09T04:44:22Z","pushed_at":"2016-10-10T14:52:10Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":null,"size":39843,"stargazers_count":363,"watchers_count":363,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":357,"mirror_url":null,"open_issues_count":232,"forks":357,"open_issues":232,"watchers":363,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/2194"},"html":{"href":"https://github.com/eclipse/smarthome/pull/2194"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/2194"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/2194/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/2194/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/2194/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/b086e7a64b11e5f136ec1f7d280b4a7c510951da"}}}}
{"actor":{"display_login":"kaikreuzer"}}