开发者

Interface design pattern / Java / Seam

Is this possible somehow?

@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);
  }
}

Is it possible to do this without implementing the interface? What is required to make that work? I want to maintain less and do more.

If I can intercept invocations of the geolocationService then I am golden, how would I do that? I don't want it to ever be instantiated, so it will always be null (I don't want the @Name and @In annot开发者_高级运维ations either then).

Walter


For the time being, I wrap all methods in my services. I automatically find the query they're looking for and inject the parameters (either named or indexed). This isn't as clean as I'd like it, but there is room for improvement.

I write an interface as well as a implementation with no code in the body except return(null);

Walter


First of all an interface is not supposed to be a seam component. How will you instantiate that seam component (interface)?

Secondly. You cannot use @Query like that.

Third, what are you actually asking? I don't understand your question.


I don't really know what Seam is and I don't see a nice simple one paragraph description so I might be talking about something completely irrelevant.

I've have played a little with an idea like for running SQL procedures using nothing but a few annotations. The implementation comes from a dynamic proxy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜