Walter White
Walter White

Reputation:

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 annotations either then).

Walter

Upvotes: 0

Views: 906

Answers (3)

Walter White
Walter White

Reputation:

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

Upvotes: 1

Michael Lloyd Lee mlk
Michael Lloyd Lee mlk

Reputation: 14661

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.

Upvotes: 0

Shervin Asgari
Shervin Asgari

Reputation: 24499

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.

Upvotes: 0

Related Questions