この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
Dear community members,
I am migrating my codebase from using SCR annotations to DS annotations. While the previous implementation sets the 'pipeline.type' property this way and it's working:
And I just tried this way to migrate it:
but it couldn't set the property somehow. It threw:
Valuable thoughts?
Thanks in advance, Bilal.
解決済! 解決策の投稿を見る。
トピックはコミュニティのコンテンツの分類に役立ち、関連コンテンツを発見する可能性を広げます。
Hi @bilal_ahmad
You are doing it wrong.
Refer this blog https://medium.com/adobetech/aem-6-4-creating-a-scheduler-using-osgi-r6-annotations-4ad0b8c6fce7
Unlike with SCR annotations, it is very clean and simple to create OSGi configurations using R6 annotations by simply using @AttributeDefinition.
If you want to create your OCD in same class then you can refer below code:
package aem.core.service;
import org.apache.sling.rewriter.Transformer;
import org.apache.sling.rewriter.TransformerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
@Component(service = TransformerFactory.class, immediate = true)
@Designate(ocd = LinkTransformerFactory.Config.class)
public class LinkTransformerFactory implements TransformerFactory {
@ObjectClassDefinition(name = "LinkTransformerFactory Service", description = "LinkTransformerFactory Configuration")
public @interface Config {
@AttributeDefinition(name = "Pipeline Type", required = true)
String getPipelineType() default "gatedassettransformer";
}
@Activate
@Modified
protected void activate(final Config config) {
String pipelineType = config.getPipelineType();
}
@Override
public Transformer createTransformer() {
return null;
}
}
Hi @bilal_ahmad
You are doing it wrong.
Refer this blog https://medium.com/adobetech/aem-6-4-creating-a-scheduler-using-osgi-r6-annotations-4ad0b8c6fce7
Unlike with SCR annotations, it is very clean and simple to create OSGi configurations using R6 annotations by simply using @AttributeDefinition.
If you want to create your OCD in same class then you can refer below code:
package aem.core.service;
import org.apache.sling.rewriter.Transformer;
import org.apache.sling.rewriter.TransformerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
@Component(service = TransformerFactory.class, immediate = true)
@Designate(ocd = LinkTransformerFactory.Config.class)
public class LinkTransformerFactory implements TransformerFactory {
@ObjectClassDefinition(name = "LinkTransformerFactory Service", description = "LinkTransformerFactory Configuration")
public @interface Config {
@AttributeDefinition(name = "Pipeline Type", required = true)
String getPipelineType() default "gatedassettransformer";
}
@Activate
@Modified
protected void activate(final Config config) {
String pipelineType = config.getPipelineType();
}
@Override
public Transformer createTransformer() {
return null;
}
}
表示
返信
いいね!の合計
Hi @bilal_ahmad
I've tried the same code in my AEM instance and it is working fine for me. I am able to log the updated pipeline type which is correctly reflected.
However, if the shared code is somehow not working for you, please go through the blog link that I've shared.
Regards,
Arpit Varshney
表示
返信
いいね!の合計
Please refer below code which has been copied from Adobe's documentation.[Link]
package com.adobe.community.rewriter.core;
import org.apache.sling.rewriter.Transformer;
import org.apache.sling.rewriter.TransformerFactory;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A TransformerFactory service instance for creating a Transformer to add link
* type icons into links to documents.
*
* @author dklco@apache.org
* @see com.perficient.adobe.rewriter.LinkTypeTransformer
*/
@Component(property = { "pipeline.type=linktype" }, service = { TransformerFactory.class })
public class LinkTypeTransformerFactory implements TransformerFactory {
private static final Logger log = LoggerFactory.getLogger(LinkTypeTransformerFactory.class);
/*
* (non-Javadoc)
*
* @see org.apache.sling.rewriter.TransformerFactory#createTransformer()
*/
@Override
public Transformer createTransformer() {
log.trace("createTransformer");
return new LinkTypeTransformer();
}
}
表示
返信
いいね!の合計
Please check sample code :
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/CustomLinkChecker.java
表示
返信
いいね!の合計
Dear @arunpatidar and @ArpitVarshney, Thank you very much for your valuable time and attention. While I was worried about why it wasn't working, turned out that I messed up with maven-bundle-plugin version in my project pom.xml(I was using 2.5.3 and changed it to 4.1.0 but somehow it got changed back to 2.5.3). Once i fixed that, I was being able to set the property the way I was trying without any changes in my java class:
表示
返信
いいね!の合計