Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Update ExampleLiveActionFactory to use OSGi Declarative Services Annotations

Avatar

Level 2

How do I update the LiveActionFactory example to use OSGi Declarative Services Annotations?

 

@component(metatype = false)
@Service
public class ExampleLiveActionFactory implements LiveActionFactory<LiveAction> {
    @property(value="exampleLiveAction")
    static final String actionname = LiveActionFactory.LIVE_ACTION_NAME;
 
...
}

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
2 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Community Advisor

Hi @danc13675873 , Try the below code snippet:

 

package aem.service;

import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.LiveAction;
import com.day.cq.wcm.msm.api.LiveActionFactory;
import org.apache.sling.api.resource.Resource;
import org.osgi.service.component.annotations.Component;

@Component(immediate = false, service = LiveActionFactory.class)
public class ExampleLiveActionFactory implements LiveActionFactory<LiveAction>{

@Override
public String createsAction() {
//add your code
return null;
}

@Override
public LiveAction createAction(Resource resource) throws WCMException {
//add your code
return null;
}
}