1
0
-1

Hi,

we have a few core (legacy) services that are using the following code:

def theService = ServiceLocator.getServiceForName("MyService")

However, this is deprecated and the documentation does not detail how best to replace that.

I would like to replace the deprecated code, but the alternatives seem quite involved.

One possibility is to use:

def theService = ServiceLocator.getServiceForDefinition("myServiceDef")

However, the above method requires a new ServiceDefinition, which also requires me to 'setClient', and that requires me to find the client using Dao or similar, and also setServiceName.

So, it seems like a single method has been replaced by a complex set of methods, or am I missing the best alternative to use in this case.

This is being used in legacy core services; it is not a feasible option to replace the service with a new Fluent service at this stage.

So, I wonder if it is better to leave the deprecated code as is, or go to the effort of replacing the deprecated code to avoid any future problems.

Any guidance would be appreciated.

Thanks

Mark


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Mark

      If you are using TM v5.1.0 or greater, you can try TM Fluent API:

      import com.avoka.tm.query.SvcDefQuery
      import com.avoka.tm.vo.SvcDef
      
      
      SvcDef svcDef = new SvcDefQuery()
            .setName("MyService")
            .firstValue()

      More info here:

      https://support.avoka.com/confluence/display/SDK/SvcDefQuery

      Cheers
      Rado

      1. Mark Murray

        Hi Rado,

        thanks for the suggestion; however, we are only on TMv5.0. We will be upgrading to TM v5.1 within the next month or two, so it might be best if I wait until then.

        Thanks

        Mark

      2. Miroslav Botka

        Hi Mark, this should help

        use ServiceDefinitionDao#getServiceForClientNameAndVersion(Long, String, Integer) or ServiceDefinitionDao.getClientService(Long, String, Integer) instead

      3. Mark Murray

        Hi Miroslav,

        thanks for the detail.

        I investigated the options for this and will probably stay with the deprecated service for a short period, and then review it later. Other priorities have come up.


        Thanks

        Mark

      CommentAdd your comment...