{"id":814,"date":"2019-08-28T15:41:49","date_gmt":"2019-08-28T03:41:49","guid":{"rendered":"https:\/\/www.ronella.xyz\/?p=814"},"modified":"2021-09-28T13:59:59","modified_gmt":"2021-09-28T00:59:59","slug":"getting-a-resource-using-modulelayer","status":"publish","type":"post","link":"https:\/\/www.ronella.xyz\/?p=814","title":{"rendered":"Getting a Resource using ModuleLayer"},"content":{"rendered":"<p>If the <strong>resource<\/strong> and the <strong>module<\/strong> are known, we can use the <strong>ModuleLayer<\/strong> to access it like the following snippet.<\/p>\n<pre style=\"white-space: pre;\">ModuleLayer.boot().findModule(&lt;MODULE_NAME&gt;).ifPresent(___module -&gt; {\r\n    try {\r\n        var modResource = ___module.getResourceAsStream(&lt;RESOURCE_NAME&gt;);\r\n    } catch (IOException e) {\r\n        e.printStackTrace();\r\n    }\r\n});\r\n<\/pre>\n<p>Where:<\/p>\n<p><strong>MODULE_NAME<\/strong> -&gt; the name of the module that has the resource.<br \/>\n<strong>RESOURCE_NAME<\/strong> -&gt; the resource of interest.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If the resource and the module are known, we can use the ModuleLayer to access it like the following snippet. ModuleLayer.boot().findModule(&lt;MODULE_NAME&gt;).ifPresent(___module -&gt; { try { var modResource = ___module.getResourceAsStream(&lt;RESOURCE_NAME&gt;); } catch (IOException e) { e.printStackTrace(); } }); Where: MODULE_NAME -&gt; the name of the module that has the resource. RESOURCE_NAME -&gt; the resource of interest.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,71],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/814"}],"collection":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=814"}],"version-history":[{"count":6,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions"}],"predecessor-version":[{"id":820,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions\/820"}],"wp:attachment":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}