Hi,

Both approaches are valid
Approach 2 will much better to used IMO since


   - We have followed approach 2 in ES and UES (in our other products/apps)
   - 'carbon' jaggery module have function called 'loadConfig' and it is
   written to get carbon server config and
'conf\datasources\master-datasources.xml'
   is valid config file to get through carbon module

Thanks

[1]
https://github.com/wso2/enterprise-store/blob/master/modules/apps/publisher/config/app.js


On Tue, Apr 1, 2014 at 12:41 PM, Tanya Madurapperuma <[email protected]> wrote:

> Hi all,
>
> I need to $ subject in a jaggery app and came across the following two
> approaches.
> What is the best approach to go ahead with? Or is there any other approach?
>
> *Approach 1*
>
> <%
>
> var log = new Log();
> var datasourceManager =
> Packages.org.wso2.carbon.ndatasource.core.DataSourceManager;
> var mydatasourceManager = new datasourceManager();
>
> var coll =
> mydatasourceManager.getInstance().getDataSourceRepository().getAllDataSources();
> var iterator = coll.iterator();
>
> while (iterator.hasNext()) {
>    log.info(iterator.next().getDSMInfo().getName());
> }
>
>
> %>
>
>
> *Approach 2*
>
> <%
>
> var log = new Log();
> var carbon = require('carbon');
> var masterds =
> carbon.server.loadConfig('datasources/master-datasources.xml');
> var ds = masterds.*::['datasources'].*::['datasource'].*::['name'].text();
> log.info(ds);
>
> %>
>
>
> Thanks,
> Tanya
>
>
> --
> Tanya Madurapperuma
>
> Software Engineer,
> WSO2 Inc. : wso2.com
> Mobile : +94718184439
> Blog : http://tanyamadurapperuma.blogspot.com
>



-- 
*Madhuka* Udantha
Senior Software Engineer
Development Technologies
WSO2 Inc. : http://wso2.com

*Mobile*: +94774066336
*Blog*: http://madhukaudantha.blogspot.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to