Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Factory for Datasources (serverConstructor="org.myapp.MyDataSource")

    Hi,

    I was able to make my Dmi classes participate in Guice dependencty injection with a factory, as I explained here: https://forums.smartclient.com/forum...ce-server-side

    The DmiFactory gets an instance of the Guice injector and creates an instance of the Dmi class with this injector. In such a way, the Dmi is able to use injected objects. This works fine.

    Now I need to inject objects to a Datasource:
    In my datasources I have a serverConstructor:

    Code:
    <DataSource ID="myDatasource" serverType="sql" tableName="myTable"
    serverConstructor="org.myapp.MyDataSource">
    I suppose SmartGWT creates an instance of this using "new org.myapp.MyDataSource()" (with no arguments).
    Is there a way to use a factory here, analogous as the factory in the Dmi? In my Dmis I use this:
    Code:
    <operationBinding operationType="custom">
    <serverObject className="org.myapp.DmiFactory"
     lookupStyle="factory" />
    With this code, the Dmi is not longer created with "new Dmi()" but using the factory. I need an analogous way to use a factory for a Datasource. The datasource should not be longer created using "new MyDataSource()" but using the factory. Is this possible?

    Using smartgwt 6.1p power.
    Last edited by edulid; 30 Apr 2018, 00:18.

    #2
    No, sorry, no factory pattern is available for DataSource construction. The closest thing is the ability to use a spring bean in the format spring:beanName (see docs).

    Comment

    Working...
    X