I created a custom workflow step but the issue is it doesn't show up in the list when I try to add it to a new workflow.
I've followed guides and done everything as described to no avail.
There are no error messages that I can find.
In the web console, I can see my bundle. It is being updated correctly every time I install it, BUT, while my workflow package is visible, the service itself is not visible. So, it looks like it's not being loaded for some reason.
Note: Maybe unrelated but servlets that use a "path" don't work either (they're not visible in the bundle in the console). The example servlet that comes with the AEM archetype works fine however but works differently (it uses the resourceType instead of a path).
Also, in Eclipse, it says the Felix scr annotations are deprecated and they have a line through them. I don't use eclipse for the build and install so I'm not sure that's the issue, but I thought it was worth mentioning.
Thanks
Edit - Here's some example code:
package company.aem.core.workflow;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import org.apache.felix.scr.annotations.Component; // <--- shows up as deprecated
import org.apache.felix.scr.annotations.Properties;// <--- shows up as deprecated
import org.apache.felix.scr.annotations.Property;// <--- shows up as deprecated
import org.apache.felix.scr.annotations.Service;// <--- shows up as deprecated
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.framework.Constants;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
@Component // <----- this shows up as deprecated in eclipse
@Service // <----- this shows up as deprecated in eclipse
public class CommunityObjectsDeploymentWorkflow implements WorkflowProcess {
@Property(value = "Test workflow implementation") // <----- this shows up as deprecated in eclipse
static final String DESCRIPTION = Constants.SERVICE_DESCRIPTION;
@Property(value = "Some vendor") // <----- this shows up as deprecated in eclipse
static final String VENDOR = Constants.SERVICE_VENDOR;
@Property(value = "My Sample Workflow Process") // <----- this shows up as deprecated in eclipse
static final String LABEL="My test workflow";
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
Session session = (Session) workflowSession.adaptTo(Session.class);
Workspace workspace = session.getWorkspace();
try {
// do JCR related stuff
} catch (RepositoryException e) {
e.printStackTrace();
}
}
}
Edit: The solution was to choose the correct component annotation import.
Change this:
import org.apache.felix.scr.annotations.Component;
To this:
import org.osgi.service.component.annotations.Component;
Now the service is running, and visible in the web console.
Note: Even though the other annotations are technically deprecated, they still work. It looks like only the Component one needed to change.
And for it to be visible in the process editor, it needs the process.label property (using the Property annotation in the Felix package) like so:
import org.apache.felix.scr.annotations.Property;
@Property(value = "My Sample Workflow Process")
static final String LABEL="process.label";