You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Dimitar Dimitrov <dd...@consult.bg> on 2012/12/04 09:52:53 UTC

getting ContentImporter service

Hello everyone.
I am a pretty new in Sling and for now I am searching the way to get the 
ContentImporter instance in my SlingPostProcessor implementation.
The main idea is to import some content which is produced in runtime by 
using the native ContentImporter service. Is there another way that 
could be used to import the jcr.xml based content into repository except 
using the default Import operation in default SlingPostServlet.

Thanks in advance.
Dimitar

Re: getting ContentImporter service

Posted by Dimitar Dimitrov <dd...@consult.bg>.
Thanks Bertrand.
It works just as you say.

Regards
Dimitar

On 12/04/2012 11:21 AM, Bertrand Delacretaz wrote:
> Hi Dimitar,
>
> On Tue, Dec 4, 2012 at 9:52 AM, Dimitar Dimitrov <dd...@consult.bg> wrote:
>> ...I am a pretty new in Sling and for now I am searching the way to get the
>> ContentImporter instance in my SlingPostProcessor implementation...
> You can get it in the same way as the SlingPostServlet [1] does, using
> an @Reference to a ContentImporter. Checking /system/console/services
> does show that such a ContentImporter service is available in a
> default Sling launchpad instance.
>
> The default reference options are probably good for your case, so just
>
>    @Reference
>    private ContentImporter contentImporter;
>
> should do.
>
> -Bertrand
>
> [1] http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java


Re: getting ContentImporter service

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Dimitar,

On Tue, Dec 4, 2012 at 9:52 AM, Dimitar Dimitrov <dd...@consult.bg> wrote:
> ...I am a pretty new in Sling and for now I am searching the way to get the
> ContentImporter instance in my SlingPostProcessor implementation...

You can get it in the same way as the SlingPostServlet [1] does, using
an @Reference to a ContentImporter. Checking /system/console/services
does show that such a ContentImporter service is available in a
default Sling launchpad instance.

The default reference options are probably good for your case, so just

  @Reference
  private ContentImporter contentImporter;

should do.

-Bertrand

[1] http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java