You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carlos Munoz <ca...@redhat.com> on 2020/06/11 01:06:12 UTC
Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Hi all,
We are currently using class
org.apache.sling.servlets.post.AbstractPostOperation but it is deprecated
(seems to have been for a while). We found non-deprecated class
org.apache.sling.servlets.post.impl.operations.AbstractPostOperation which
seems to be almost the same (save for a thrown exception in one of its
methods) but it is not found when deploying a bundle to Sling. It is part
of the the org.apache.sling.servlets.post bundle, but the deployment fails
as the package cannot be found.
Could you provide some guidance on which is the correct class to use to
implement Post operations?
Regards.
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Carlos,
On Tue, Jun 23, 2020 at 1:35 AM Carlos Munoz <ca...@redhat.com> wrote:
> ...Bertrand, I confirmed the approach works two ways...
Thank you! I have added a javadoc comment mentioning this, in commit 1536b10
-Bertrand
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Carlos Munoz <ca...@redhat.com>.
Bertrand, I confirmed the approach works two ways:
1. By embedding the dependency directly in the bundle using the
<Include-Dependency> directive.
2. By using the <Include-Resource> directive with the following content:
@org.apache.sling.servlets.post-*.jar!/org/apache/sling/servlets/post/impl/**
This includes the full private package that is not accessible as part of
the bundle.
Regards,
Carlos
On Mon, Jun 22, 2020 at 10:35 AM Bertrand Delacretaz <bd...@apache.org>
wrote:
> On Mon, Jun 22, 2020 at 2:36 PM Carlos Munoz <ca...@redhat.com> wrote:
> > ...My suggestion would be to add this
> > solution you just proposed to the javadocs of those deprecated classes...
>
> Good idea - let's wait until you confirm that it works for you and
> this sounds like a plan!
>
> -Bertrand
>
>
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Jun 22, 2020 at 2:36 PM Carlos Munoz <ca...@redhat.com> wrote:
> ...My suggestion would be to add this
> solution you just proposed to the javadocs of those deprecated classes...
Good idea - let's wait until you confirm that it works for you and
this sounds like a plan!
-Bertrand
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Carlos Munoz <ca...@redhat.com>.
Thanks Bertrand. I will try this out, but I believe in theory it should
work for us.
And no worries about the contribution, at least it let me get more familiar
with some of Sling's internals :)
I'll still reiterate that the deprecation on the Post classes threw me off
because it meant our code ended up using deprecated classes, adding several
warnings to the compilation process. My suggestion would be to add this
solution you just proposed to the javadocs of those deprecated classes.
Regards,
Carlos
On Mon, Jun 22, 2020 at 8:27 AM Bertrand Delacretaz <bd...@apache.org>
wrote:
> Hi Carlos,
>
> On Thu, Jun 18, 2020 at 3:59 AM Carlos Munoz <ca...@redhat.com> wrote:
> ...
> > https://github.com/apache/sling-org-apache-sling-servlets-post/pull/5
> ...
>
> Thank you for this!
>
> In the meantime I think there's a simpler way for you to use the
> existing
> org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
> with no changes to Sling code.
>
> That class is public, so you can use it in your code, however it's not
> exported at runtime so your bundle fails to load it.
>
> The workaround is to embed the class in your bundle, using a bnd
> -includeresource as in [1].
>
> I think this is in some ways better than us moving that class to an
> exported package, as you can then precisely control which version of
> that class you use as that's the one you embedded as opposed to
> whatever the environment provides.
>
> Would that work for you?
>
> -Bertrand
>
> P.S. too bad this means we probably don't need your contribution,
> sorry that we didn't suggest this variant before
>
> [1]
> https://github.com/apache/sling-org-apache-sling-servlets-post/blob/master/bnd.bnd
>
>
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Carlos,
On Thu, Jun 18, 2020 at 3:59 AM Carlos Munoz <ca...@redhat.com> wrote:
...
> https://github.com/apache/sling-org-apache-sling-servlets-post/pull/5
...
Thank you for this!
In the meantime I think there's a simpler way for you to use the
existing org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
with no changes to Sling code.
That class is public, so you can use it in your code, however it's not
exported at runtime so your bundle fails to load it.
The workaround is to embed the class in your bundle, using a bnd
-includeresource as in [1].
I think this is in some ways better than us moving that class to an
exported package, as you can then precisely control which version of
that class you use as that's the one you embedded as opposed to
whatever the environment provides.
Would that work for you?
-Bertrand
P.S. too bad this means we probably don't need your contribution,
sorry that we didn't suggest this variant before
[1] https://github.com/apache/sling-org-apache-sling-servlets-post/blob/master/bnd.bnd
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Carlos Munoz <ca...@redhat.com>.
Hi Bertrand, I did just that (moved the code up to the public package) and
submitted a PR for it:
https://github.com/apache/sling-org-apache-sling-servlets-post/pull/5
Let me know what you think.
Carlos
On Thu, Jun 11, 2020 at 8:24 AM Bertrand Delacretaz <bd...@apache.org>
wrote:
> Hi,
>
> On Thu, Jun 11, 2020 at 1:51 PM Carlos Munoz <ca...@redhat.com> wrote:
> > ...I might take it upon myself to code up said public replacement (my
> first
> > Sling contribution!) which avoids using the jcr apis...
>
> That would be fantastic! As mentioned, moving the code from the
> servlets.post.impl.operations to the servlets.post package might do,
> but I haven't checked the details.
>
> -Bertrand
>
>
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,
On Thu, Jun 11, 2020 at 1:51 PM Carlos Munoz <ca...@redhat.com> wrote:
> ...I might take it upon myself to code up said public replacement (my first
> Sling contribution!) which avoids using the jcr apis...
That would be fantastic! As mentioned, moving the code from the
servlets.post.impl.operations to the servlets.post package might do,
but I haven't checked the details.
-Bertrand
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Carlos Munoz <ca...@redhat.com>.
Thanks Bertrand, that makes sense.
So, to recap it's fine to use the deprecated API.
I would recommend getting rid of the deprecation in all honesty as it
might be sending the wrong message to developers, especially since there is
no effective replacement.
I might take it upon myself to code up said public replacement (my first
Sling contribution!) which avoids using the jcr apis.
Regards,
Carlos
On Thu, Jun 11, 2020 at 4:40 AM Bertrand Delacretaz <bd...@apache.org>
wrote:
> Hi,
>
> On Thu, Jun 11, 2020 at 3:06 AM Carlos Munoz <ca...@redhat.com> wrote:
> > ...We are currently using class
> > org.apache.sling.servlets.post.AbstractPostOperation but it is deprecated
> > (seems to have been for a while)...
>
> As per https://issues.apache.org/jira/browse/SLING-6722 the reason for
> deprecation is that it'0s "using javax.jcr api and therefore creates a
> mixture between Sling's resource API and the JCR api".
>
> Which I think is a good reason, but if you use JCR APIs elsewhere
> anyway in your project I don't think using that class is a problem for
> you. I just clarified its Javadoc comments to mention that.
>
> I don't think we have a public replacement at this point, as you
> mention the
> org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
> is in a non-exported package. If we need a non-JCR public variant of
> it, we could move that code to a new
> o.a.s.servlets.post.SlingAbstractPostOperation and have
> o.a.s.servlets.post.impl.operations.AbstractPostOperation inherit from
> it.
>
> -Bertrand
>
>
Re: Deprecated org.apache.sling.servlets.post.AbstractPostOperation
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,
On Thu, Jun 11, 2020 at 3:06 AM Carlos Munoz <ca...@redhat.com> wrote:
> ...We are currently using class
> org.apache.sling.servlets.post.AbstractPostOperation but it is deprecated
> (seems to have been for a while)...
As per https://issues.apache.org/jira/browse/SLING-6722 the reason for
deprecation is that it'0s "using javax.jcr api and therefore creates a
mixture between Sling's resource API and the JCR api".
Which I think is a good reason, but if you use JCR APIs elsewhere
anyway in your project I don't think using that class is a problem for
you. I just clarified its Javadoc comments to mention that.
I don't think we have a public replacement at this point, as you
mention the org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
is in a non-exported package. If we need a non-JCR public variant of
it, we could move that code to a new
o.a.s.servlets.post.SlingAbstractPostOperation and have
o.a.s.servlets.post.impl.operations.AbstractPostOperation inherit from
it.
-Bertrand