Details
-
Type:
Bug
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Done
-
Affects Version/s: 0.2
-
Fix Version/s: 0.3
-
Component/s: common, component-bpm, component-rules
-
Labels:None
-
Affects:Documentation (Ref Guide, User Guide, etc.), Compatibility/Configuration
-
Estimated Difficulty:Medium
Description
Using the switchyard maven plugin and the BPMSwitchYardScanner, the following BPM component configuration:
<component name="MyService"> |
<implementation.bpm processDefinition="META-INF/MyService.bpmn" processDefinitionType="BPMN2" processId="MyService"> |
<taskHandler class="org.switchyard.component.bpm.task.SwitchYardServiceTaskHandler" name="SwitchYard Service"/> |
<resource location="/META-INF/MyServiceRules.drl" type="DRL"/> |
</implementation.bpm> |
<service name="MyService"> |
<interface.java interface="org.switchyard.userguide.MyService"/> |
</service> |
</component> |
can be auto-generated from this:
@Process(value=MyService.class, resources={MyServiceRules.class}) |
public interface MyServiceProcess extends MyService { |
public static final class MyServiceRules extends SimpleResource { |
public MyServiceRules() { |
super("/META-INF/MyServiceRules.drl", "DRL"); |
}
|
}
|
}
|
Similarly, using the switchyard maven plugin and the RulesSwitchYardScanner, the following Rules component configuration:
<component name="MyService"> |
<implementation.rules stateful="false"> |
<rulesAction name="process" type="EXECUTE_RULES"/> |
<resource location="/org/switchyard/userguide/MyService.drl" type="DRL"/> |
</implementation.rules> |
<service name="MyService"> |
<interface.java interface="org.switchyard.userguide.MyService"/> |
</service> |
</component> |
can be auto-generated from this:
@Rules(value=MyService.class, resources={MyServiceDrl.class}) |
public interface MyServiceRules extends MyService { |
@ExecuteRules |
public void process(MyData data); |
public static final class MyServiceDrl extends SimpleResource { |
public MyServiceDrl() { |
super("/org/switchyard/userguide/MyService.drl", "DRL"); |
}
|
}
|
}
|
The problem is that using a CLASSES array (of static classes) to define resources is VERY clunky, and causes the user to write a lot more code than he/she needs to. Instead, the resources array of the Rules annotation should instead just be an array of STRINGS pointing to the location of the resources.
The original reasoning behind using classes was that there were two different pieces of data to describe a resource: a location and a type. However, as part of this work, if we add a way for the ResourceType class (which already exists and is extensible to user-added types) to deduce the type via the file extension, then just the location would be required.
With this change, the above BPM code would be reduced to this:
@Process(value=MyService.class, resources={"/org/switchyard/userguide/MyService.drl"}) |
public interface MyServiceProcess extends MyService {} |
, and the above Rules code would be reduced to this:
@Rules(value=MyService.class, resources={"/org/switchyard/userguide/MyService.drl"}) |
public interface MyServiceRules extends MyService { |
@ExecuteRules |
public void process(MyData data); |
}
|
A lot cleaner!
https://github.com/jboss-switchyard/core/pull/291
https://github.com/jboss-switchyard/components/pull/221
https://github.com/jboss-switchyard/quickstarts/pull/71