Hi Johann,

NDatasource component is not specific to RDBMS data sources. It is a
generic component that can be (and we have) used to create any type of a
data source. That is why, the payload you send to testConnection in
ndatasource component basically contains all the information required to
fully identify the data source type and all its properties. It does not
contain any unwanted properties, but have just the required amount of data
to implement this as a generic feature. So this test connection behavior is
originally created to be used by the data sources UI component, where it
has all these information readily available, if not, if you're using this
API, you have to create this structure yourself, and send it. The existing
data source types such as RDBMS type [1], we simply use JAXB to create the
XML payload need to be send as the "datasourceDefinition", where you can
populate RDBMSConfiguration object and serialize it. This may possibly how
you guys are doing it in other places now.

Anyways, you mentioned you cannot use the same functionality to do this
from the backend, I've just in my earlier mail pointed out how you can do
this. You can simply look at how the admin service is implemented which you
use from your UI. It's done basically by using
"DataSourceManager.getInstance().getDataSourceRepository().testDataSourceConnection()".
So you can directly call it like that. And also with that, you yourself can
write a more convenient RDBMS specific backend service to do connection
validations by only passing in the properties you need for a JDBC
connection.

[1]
https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.2.0/core/org.wso2.carbon.ndatasource.rdbms/4.2.0/src/main/java/org/wso2/carbon/ndatasource/rdbms/RDBMSConfiguration.java

Cheers,
Anjana.


On Fri, Apr 4, 2014 at 6:40 PM, Johann Nallathamby <[email protected]> wrote:

> Hi Anjana,
>
>
> On Thu, Apr 3, 2014 at 3:04 PM, Anjana Fernando <[email protected]> wrote:
>
>> Hi Maduranga,
>>
>> Yeah, seems like the packages exported from the stub is not correct. We
>> will have to fix those eventually, @Chanika please note.
>>
>> But for your requirement, I'm guessing you will have your own admin
>> service operations when adding user stores and all. So calling another
>> service from through a backend service is overkill, you can directly call
>> the required functionality directly. Check here [1] to see how
>> "testDataSourceConnection()" is implemented, you just have to use a logic
>> similar to do it.
>>
>
> We are not calling the service from the BE. We are using the same
> ndatasource stub to call the web service from the UI component itself.
>
> We find that the nadatasource UI component is doing quite a lot of
> processing and creating a complex object before sending  the request to the
> back end. I don't think all that processing is needed in the UI. Due to
> this we also had to duplicate all that code in our
> user.store.configuration.ui. Effectively you should only need the
> connection URL, username, password and Driver class to test the JDBC
> connection from the UI. If the service was accepting only these parameters
> our lives would have been much easier.
>
> Another problem with this is that we cannot use the same service to do
> validation from our backend components. What comes to my mind right now as
> a work around is to have all that code we duplicated in a common bundle and
> use it in both FE and BE components. I wonder if you are doing this
> validation both in FE and BE and if so how you are doing it.
>
> If you are doing any changes related to these components please consider
> the above improvements.
>
>
>> But then again, if your requirement is directly from the UI to check the
>> validity of database connection information, then yeah, do fix the data
>> source UI component as you've done, but you have to check all the usages of
>> those packages and fix those as well.
>>
>> [1]
>> https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.2.0/core/org.wso2.carbon.ndatasource.core/4.2.0/src/main/java/org/wso2/carbon/ndatasource/core/services/NDataSourceAdminService.java
>>
>> Cheers,
>> Anjana.
>>
>>
>> On Thu, Apr 3, 2014 at 1:32 PM, Maduranga Siriwardena <[email protected]
>> > wrote:
>>
>>> Hi all,
>>> In the IS, when a secondary JDBC user store is creating the database
>>> connection is not tested. So when we do a operation on the user store,
>>> exceptions are thrown. So to fix the issue, I need to check the database
>>> connection before creating the user store.
>>>
>>> Same scenario happens in DSS. It uses org.wso2.carbon.ndatasource.stub
>>> and generate a client and call the relevant methods. But as you can see
>>> imports are done as org.wso2.carbon.ndatasource.ui.stub in [1]. So if I
>>> do the same thing and build my component, I builds without errors. But when
>>> I add the jar to the pack and run the server it gives runtime errors(can't
>>> remember the exact error. but it was about problems with finding the
>>> correct packages and classes.). But if I add
>>> the org.wso2.carbon.ndatasource.ui component also to the dropins folder, it
>>> works without errors.
>>>
>>> But I can't add the UI component to the IS as it will change the UI of
>>> the IS.
>>> When I checked the folder structure of the jar of the stub, it was like 
>>> org/wso2/carbon/ndatasource/ui/stub.
>>> So I think there is a problem with exporting the packages in the stub. So I
>>> did some changes to the pom of the stub (in the maven-antrun-plugin
>>> section) changing some package names when generating the stub from
>>> wsdl2java (changed pom and diff are attached here). So by doing this, I can
>>> test the connection in IS without a problem.
>>> As changing the stub will break the other components that user the stub,
>>> I changed the above mentioned UI component. Now it is working without a
>>> problem. (not much sure of any other component that use the stub)
>>>
>>> Can someone please comment about the suitability of this approach.
>>>
>>>
>>>
>>> [1]
>>> https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/ndatasource/org.wso2.carbon.ndatasource.ui/4.2.2/src/main/java/org/wso2/carbon/ndatasource/ui/NDataSourceAdminServiceClient.java
>>>
>>> Thank you,
>>> Maduranga
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Anjana Fernando*
>> Technical Lead
>> WSO2 Inc. | http://wso2.com
>> lean . enterprise . middleware
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Thanks & Regards,
>
> *Johann Dilantha Nallathamby*
> Senior Software Engineer
> Integration Technologies Team
>  WSO2, Inc.
> lean.enterprise.middleware
>
> Mobile - *+94777776950*
> Blog - *http://nallaa.wordpress.com <http://nallaa.wordpress.com>*
>



-- 
*Anjana Fernando*
Technical Lead
WSO2 Inc. | http://wso2.com
lean . enterprise . middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to