这有可能吗?
@Name("geolocationService")
public interface GeolocationService
{
@Query("SELECT g FROM Geolocation geolocation INNER JOIN geolocation.deployment deployment WHERE geolocation.ipStart <= INET_ATON(:ipAddress) AND deployment.active = TRUE")
Geolocation findByIpAddress(@NamedParameter("ipAddress")final String ipAddress);
}
public GeolocationAction
{
@In
private GeolocationService geolocationService;
@RequestParameter("ipAddress")
private String ipAddress;
@Out
private Geolocation geolocation;
public void find()
{
geolocation = geolocationService.findByIpAddress(ipAddress);
}
}
是否可以在不实现接口的情况下做到这一点?完成这项工作需要什么?我想保持更少,做更多。
如果我可以拦截对 geolocationService 的调用,那么我很幸运,我该怎么做?我不希望它被实例化,所以它总是为空(我也不想要 @Name 和 @In 注释)。
沃尔特