Yes i did it first with my last classes extending AbstractCustomServiceTask
But with the new one, i tried it but without success… i can t see it in the palette
Here my new Abstract class code :
<code>
public abstract class EffiTaskActivitiBehavior extends UserTaskActivityBehavior implements CustomServiceTask, ActivityBehavior, ExecutionListener {
protected TaskDefinition taskDefinition;
protected JavaDelegate javaDelegate;
private static final String DEFAULT_EXTENSIONS_DRAWER_NAME = "Extensions";
public String contributeToPaletteDrawer() {
return DEFAULT_EXTENSIONS_DRAWER_NAME;
}
public final String getId() {
return getClass().getCanonicalName();
}
public final DelegateType getDelegateType() {
return getDelegateType(getRuntimeAnnotation());
}
private DelegateType getDelegateType(final Runtime annotation) {
DelegateType result = DelegateType.NONE;
if (annotation != null) {
if (isDelegateDefined(annotation.javaDelegateClass())) {
result = DelegateType.JAVA_DELEGATE_CLASS;
} else if (isDelegateDefined(annotation.expression())) {
result = DelegateType.EXPRESSION;
} else if (isDelegateDefined(annotation.javaDelegateExpression())) {
result = DelegateType.JAVA_DELEGATE_EXPRESSION;
}
}
return result;
}
private boolean isDelegateDefined(final String definition) {
return definition != null && !definition.isEmpty() && !"".equals(definition);
}
public final String getDelegateSpecification() {
String result = "";
final DelegateType delegateType = getDelegateType();
if (!DelegateType.NONE.equals(delegateType)) {
Runtime runtimeAnnotation = getRuntimeAnnotation();
if (runtimeAnnotation != null) {
switch (delegateType) {
case JAVA_DELEGATE_CLASS:
result = runtimeAnnotation.javaDelegateClass();
break;
case EXPRESSION:
result = runtimeAnnotation.expression();
break;
case JAVA_DELEGATE_EXPRESSION:
result = runtimeAnnotation.javaDelegateExpression();
break;
default:
break;
}
}
}
return result;
}
private Runtime getRuntimeAnnotation() {
Runtime result = null;
final Annotation annotation = this.getClass().getAnnotation(Runtime.class);
if (annotation != null && Runtime.class.isAssignableFrom(annotation.getClass())) {
result = ((Runtime) annotation);
}
return result;
}
public abstract String getName();
public String getDescription() {
return getName();
}
public String getSmallIconPath() {
return null;
}
public String getLargeIconPath() {
return getSmallIconPath();
}
public String getShapeIconPath() {
return getSmallIconPath();
}
public DiagramBaseShape getDiagramBaseShape() {
return DiagramBaseShape.ACTIVITY;
}
public Integer getOrder() {
return 1;
}
@SuppressWarnings("rawtypes")
public String toString() {
StringBuilder builder = new StringBuilder();
final Class clazz = this.getClass();
final Field[] fields = clazz.getDeclaredFields();
builder.append("Custom Service Task ").append(this.getClass().getSimpleName()).append("\n\tID:\t").append(this.getId()).append("\n\tProvider class:\t").append(this.getClass().getCanonicalName()).append("\n\tPalette drawer:\t").append(contributeToPaletteDrawer()).append("\n\tProperties:\n");
for (final Field field : fields) {
final Annotation[] annotations = field.getAnnotations();
for (final Annotation annotation : annotations) {
if (annotation instanceof Property) {
builder.append("\t\t").append(field.getName()).append(" (").append(((Property) annotation).type().name()).append(")\n");
}
}
}
boolean hierarchyOpen = true;
Class currentClass = clazz;
while (hierarchyOpen) {
currentClass = currentClass.getSuperclass();
if (CustomServiceTask.class.isAssignableFrom(currentClass)) {
for (Field currentSuperclassField : currentClass.getDeclaredFields()) {
final Annotation[] currentSuperclassFieldAnnotations = currentSuperclassField.getAnnotations();
for (final Annotation currentSuperclassFieldAnnotation : currentSuperclassFieldAnnotations) {
if (currentSuperclassFieldAnnotation instanceof Property) {
builder.append("\t\t").append(currentSuperclassField.getName()).append(" (").append(((Property) currentSuperclassFieldAnnotation).type().name()).append(") (inherited from ").append(currentClass.getSimpleName()).append(")\n");
}
}
}
} else {
hierarchyOpen = false;
}
}
return builder.toString();
}
public EffiTaskActivitiBehavior(ExpressionManager expressionManager, TaskDefinition taskDefinition) {
super(expressionManager, taskDefinition);
}
public EffiTaskActivitiBehavior(ExpressionManager expressionManager, TaskDefinition taskDefinition, JavaDelegate javaDelegate) {
super(expressionManager, taskDefinition);
this.javaDelegate = javaDelegate;
}
public void execute(ActivityExecution execution) throws Exception {
execute(execution);
execute((DelegateExecution) execution);
leave(execution);
}
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
leave(execution);
}
public void notify(DelegateExecution execution) throws Exception {
execute((DelegateExecution) execution);
}
public void execute(DelegateExecution execution) throws Exception {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new JavaDelegateInvocation(javaDelegate, execution));
}
}
</code>
And here my class code i want to see in the palette :
<code>
@Help(displayHelpShort = "Send a new mail to the different owners")
@Runtime(javaDelegateClass = "com.effisoft.orion.fw.workflow.MailTask2")
public class MailTask2 extends EffiTaskActivitiBehavior {
public MailTask2(ExpressionManager expressionManager, TaskDefinition taskDefinition) {
super(expressionManager, taskDefinition);
}
public MailTask2(ExpressionManager expressionManager, TaskDefinition taskDefinition, JavaDelegate javaDelegate) {
super(expressionManager, taskDefinition, javaDelegate);
}
@Property(type = PropertyType.TEXT, displayName = "Recipient List", required = true)
private String recipients;
@Property(type = PropertyType.TEXT, displayName = "Subject", required = true)
private String subject;
@Property(type = PropertyType.TEXT, displayName = "Body", required = true)
private String body;
@Property(type = PropertyType.TEXT, displayName = "Attachment List")
private String attachments;
@Override
public String getName() {
return "MailTask2";
}
@Override
public String contributeToPaletteDrawer() {
return "Effisoft Corporation";
}
@Override
public String getSmallIconPath() {
return "icons/icon.gif";
}
}
</code>
Can you tell me where i m wrong ?
I just want to create an example to work with and implement my own class then