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.
If you are using TM v5.1.0 or greater, you can try TM Fluent API:
SvcDef svcDef = new SvcDefQuery()
More info here:
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.
Hi Mark, this should help
use ServiceDefinitionDao#getServiceForClientNameAndVersion(Long, String, Integer) or ServiceDefinitionDao.getClientService(Long, String, Integer) instead
ServiceDefinitionDao#getServiceForClientNameAndVersion(Long, String, Integer)
ServiceDefinitionDao.getClientService(Long, String, Integer)
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.