Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

AEM 6.3: Felix SCR Annotations Deprecated - Replacement for @SlingFilter?

Avatar

Level 3

Hello, it appears that the Felix SCR annotations have been deprecated in AEM 6.3.  This is not reflected on the Sling website or documentation as far as I can tell, but is appearing that way when we compile against the 6.3 uberjar.

In fact, the latest AEM Maven Archetype does not include the Felix SCR dependency at all.

I see this blog post from last year that covers a lot of conversion questions.

And this very recent one from Feike.

The OSGi 6 method for registering configuration properties using a separate interface class is fairly convoluted, and thinly documented, but with enough time and money I am sure we can figure it out.

However, there does not seem to be mention in either article of what is replacing the @SlingFilter annotation, which is mentioned as the recommended approach even in fairly recent articles.

All our classes that use the @SlingFilter annotation no longer work (they are throwing ArrayIndexOutOfBounds exceptions), even keeping the Felix SCR dependency, and updating it to the latest version.

Is there documentation somewhere of what is replacing the @SlingFilter annotation?

Is there a plan for a more complete document describing the recommended migration path, and changes to the product that cause existing @SlingFilter usage not to work?

Thanks!

Tim

desktop_exl_promo_600x100_weknowyou.png

1 Accepted Solution

Avatar

Correct answer by
Employee

when using non-String types make sure to use the correct data-type.

Example here for the service-ranking and using :Integer

https://github.com/heervisscher/htl-examples/blob/master/core/src/main/java/com/adobe/examples/htl/c...

View solution in original post

17 Replies

Avatar

Employee

I am not aware that the Felix annotations are deprecated in AEM6.3.

To your question on @SlingFilter, this is same like @SlingServlet

There isn't an equivalent you can use. You need to specify the properties like in this sample for a servlet.

https://github.com/heervisscher/htl-examples/blob/master/core/src/main/java/com/adobe/examples/htl/c...

Avatar

Correct answer by
Employee

when using non-String types make sure to use the correct data-type.

Example here for the service-ranking and using :Integer

https://github.com/heervisscher/htl-examples/blob/master/core/src/main/java/com/adobe/examples/htl/c...

Avatar

Level 3

Yes, most of the Felix annotations show deprecated when compiling against the 6.3 UberJar.  I'll try setting things up with @Component. Thanks!

Avatar

Level 5

I use OSGI R6 annotation based approach:

@Component(service = Filter.class, property = {

EngineConstants.SLING_FILTER_SCOPE + "=" + EngineConstants.FILTER_SCOPE_REQUEST,

Constants.SERVICE_RANKING + ":Integer=" + -10002

})

public class MyCustomFilter implements Filter {

Avatar

Level 2

import com.icfolson.aem.library.core.services.OsgiConfiguration

import com.ingredion.aem.core.services.EloquaService

import com.ingredion.aem.core.services.EloquaServiceUS

import com.ingredion.aem.core.services.SalesforceService

import org.apache.felix.scr.annotations.Activate
import org.apache.felix.scr.annotations.Component
import org.apache.felix.scr.annotations.Modified
import org.apache.felix.scr.annotations.Property
import org.apache.felix.scr.annotations.Service


@Component(label = "Ingredion Eloqua Connector Service For US", metatype = true)

@Service(EloquaServiceUS)

class DefaultEloquaServiceUS implements EloquaServiceUS

{

   private static final String DEFAULT_URL = "https://s2141011786.t.eloqua.com/e/f2"
   private static final String DEFAULT_ELQ_SITE_ID = "2141011786"

   @Property(label = "Eloqua URL", description = "Eloqua Url",

  value = DefaultEloquaServiceUS.DEFAULT_URL)

   private static final String URL = "url"

   @Property(label = "Eloqua Site ID", description = "This ID will tell Eloqua that the request is coming from Ingredion",

  value = DefaultEloquaServiceUS.DEFAULT_ELQ_SITE_ID)

   private static final String ELQ_SITE_ID = "elqSiteId"

   String url

   String elqSiteId

   @Activate
  @Modified
   void activate(Map<String, Object> properties) {

   def configuration = new OsgiConfiguration(properties)

   url = configuration.getAsString(URL, DEFAULT_URL)

   elqSiteId = configuration.getAsString(ELQ_SITE_ID, DEFAULT_ELQ_SITE_ID)

  }

}

This is my code and this was written in groovy.

Now we are upgrading to aem 6.3 from 6.1.

@Activate, @Modified, @Component, @Service is dericated.

So i replaced with osgi annotations.

But not sure how to replace below lines.

@Property(label = "Eloqua URL", description = "Eloqua Url",

  value = DefaultEloquaServiceUS.DEFAULT_URL)

   private static final String URL = "url"

  

Can anyone suggest me how to replace @Property?

Avatar

Level 2

Hi,

Did you get the replacement for @Property? Also what is the replacement for @Service in osgi? Can you share the exact import here. I'm struck with the two issues. Thanks in advance.

Regards,

Vijay

Avatar

Level 2

did you find replacement for @Property ?

Avatar

Community Advisor

Hi,

Replacement of @Property is property attribute inside component annotation.

And for service it is service attribute

e.g.

@Component(service = WorkflowProcess.class, property = {
Constants.SERVICE_DESCRIPTION + "=A workflow process to Build Package.",
"process.label=A workflow process to Build Package." })

Please check Using OSGi annotations (>= AEM6.2) - Experience Delivers and Migration of SCR annotations to OSGi R6 annotations in AEM 6.3 for more details.

Thanks
Arun



Arun Patidar

Avatar

Level 2

my question is for property attribute outside @Service annotation.

I am looking for replacement for below

@Property(label = "Eloqua URL", description = "Eloqua Url",value = DefaultEloquaServiceUS.DEFAULT_URL)

   private static final String URL = "url"

Avatar

Community Advisor

Hi,

It should be replaced like below:

@Component(service = MyService.class, name = "My Service", immediate = true,

property = {

  "url="+DefaultEloquaServiceUS.DEFAULT_URL;

})



Arun Patidar

Avatar

Level 2

check above question above from   cmr96960454 . I meant to say declaration not inside @searcice, its outside it.

import com.icfolson.aem.library.core.services.OsgiConfiguration

import com.ingredion.aem.core.services.EloquaService

import com.ingredion.aem.core.services.EloquaServiceUS

import com.ingredion.aem.core.services.SalesforceService

import org.apache.felix.scr.annotations.Activate
import org.apache.felix.scr.annotations.Component
import org.apache.felix.scr.annotations.Modified
import org.apache.felix.scr.annotations.Property
import org.apache.felix.scr.annotations.Service


@Component(label = "Ingredion Eloqua Connector Service For US", metatype = true)

@Service(EloquaServiceUS)

class DefaultEloquaServiceUS implements EloquaServiceUS

{

   private static final String DEFAULT_URL = "https://s2141011786.t.eloqua.com/e/f2"
   private static final String DEFAULT_ELQ_SITE_ID = "2141011786"

   @Property(label = "Eloqua URL", description = "Eloqua Url",

  value = DefaultEloquaServiceUS.DEFAULT_URL)

   private static final String URL = "url"

   @Property(label = "Eloqua Site ID", description = "This ID will tell Eloqua that the request is coming from Ingredion",

  value = DefaultEloquaServiceUS.DEFAULT_ELQ_SITE_ID)

   private static final String ELQ_SITE_ID = "elqSiteId"

   String url

   String elqSiteId

   @Activate
  @Modified
   void activate(Map<String, Object> properties) {

   def configuration = new OsgiConfiguration(properties)

   url = configuration.getAsString(URL, DEFAULT_URL)

   elqSiteId = configuration.getAsString(ELQ_SITE_ID, DEFAULT_ELQ_SITE_ID)

  }

}

This is my code and this was written in groovy.

Now we are upgrading to aem 6.3 from 6.1.

@Activate, @Modified, @Component, @Service is dericated.

So i replaced with osgi annotations.

But not sure how to replace below lines.

@Property(label = "Eloqua URL", description = "Eloqua Url",

  value = DefaultEloquaServiceUS.DEFAULT_URL)

   private static final String URL = "url"

 

Can anyone suggest me how to replace @Property?

Avatar

Level 1

Hello!

May I ask if you found a way to replace @property? For example, how to replace the following?
private static final boolean R_FWD_FLOWS_EXPORT = true;
@property(name = "ReactiveForwardingFlowExport", boolValue = R_FWD_FLOWS_EXPORT,
label = "Reactive Forwarding application flow exported via IPFIX on removal")

Private Boolean reactiveForwardingFlowExport = R_FWD_FLOWS_EXPORT;

Avatar

Community Advisor

Hi,

I am not sure what you are trying to do here.

Are you trying to create configurations for your service? then please check below threads

acs-aem-samples/SampleOsgiR6AnnotationsImpl.java at master · Adobe-Consulting-Services/acs-aem-sampl...

Using OSGi annotations (>= AEM6.2) - Experience Delivers

Note sure what are you upto.

Thanks
Arun



Arun Patidar