[switchyard-issues] [JBoss JIRA] Created: (SWITCHYARD-428) Defining resources as classes in @Process and @Rules is clunky
David Ward (JIRA)
jira-events at lists.jboss.org
Fri Aug 26 18:15:18 EDT 2011
Defining resources as classes in @Process and @Rules is clunky
--------------------------------------------------------------
Key: SWITCHYARD-428
URL: https://issues.jboss.org/browse/SWITCHYARD-428
Project: SwitchYard
Issue Type: Bug
Components: common, component-bpm, component-rules
Affects Versions: 0.2
Reporter: David Ward
Assignee: David Ward
Fix For: 0.3
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!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the switchyard-issues
mailing list