ValueMapDecorator using impl class in api

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ValueMapDecorator using impl class in api

Roy Teeuwen
Hey dev's,

Since the use of the ObjectConverter, the ValueMapDecorator class which is in the api package bundle, uses an impl class. Is this good practice?

See https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java <https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java>

We are for example using the uber-jar provided by Adobe for their product, AEM. This uber-jar only contains the api classes that you should program your code against, but now since this change our unit tests fail because the ValueMapDecorator uses an impl class that is not available in this uber jar.

Greets,
Roy
Reply | Threaded
Open this post in threaded view
|

Re: ValueMapDecorator using impl class in api

Robert Munteanu-2
Hi Roy,

On Tue, 2019-01-22 at 13:35 +0100, Roy Teeuwen wrote:

> Hey dev's,
>
> Since the use of the ObjectConverter, the ValueMapDecorator class
> which is in the api package bundle, uses an impl class. Is this good
> practice?
>
> See
> https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java
> <
> https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java
> >

The usage of the class is not exposed, so IMO there is no problem with
it.

>
> We are for example using the uber-jar provided by Adobe for their
> product, AEM. This uber-jar only contains the api classes that you
> should program your code against, but now since this change our unit
> tests fail because the ValueMapDecorator uses an impl class that is
> not available in this uber jar.

Then I guess that's a problem with the Adobe uber-jar. That impl class
is part of the api bundle, there's no reason not to use it.

Robert

Reply | Threaded
Open this post in threaded view
|

Re: ValueMapDecorator using impl class in api

Radu Cotescu-3
Hi,

> On 22 Jan 2019, at 13:42, Robert Munteanu <[hidden email]> wrote:
>
>
> Then I guess that's a problem with the Adobe uber-jar. That impl class
> is part of the api bundle, there's no reason not to use it.

I agree with Robert here.

The are similar things happening in the HTL compilers, where API classes use implementation classes from the same bundle. They don’t return objects of those types, but it’s perfectly ok to use those implementation classes.

Cheers,
Radu