General
Using bpm4struts
Tuning bpm4struts
Other technologies
Bpm4Struts stands for: Business Modeling for Struts. It means you will be able to create your Struts web application by modeling business processes. Business processes in a Struts application typically involve displaying JSP pages and sending requests to the server by means of actions performed on those pages, such as button clicks or navigating using hyperlinks. These actions mostly result in code being executed on the server (in the action itself, or better yet: delegated to the business layer), it is this code which contains the business logic.
Currently only MagicDraw has been extensively tested, unfortunately this is commercial software and requires a licence to run. Support for a free tool such as Poseidon is underway.
There is the general documentation Bpm4Struts, there is a user-guide and there is the how-to which serves as a small tutorial describing an example application. All of this is hosted here.
Subscribe to our forum, Go here: AndroMDA forum
You have to make sure your model complies with the constraints as documented in the user guide. Failing to do so will confuse the cartridge and might have unpredicatable behavior such as exceptions or undeployable Struts code.
Here are some common exceptions with a description and their resolution
Exception | Description | Resolution |
---|---|---|
NullPointerException at StrutsActionLogicImpl.getPackageName(StrutsActionLogicImpl.java) | The cartridge tried to resolve the package for an action by trying to look for the controller, the controller was not found. | Make sure all activity graphs have a controller assigned to them. |
ClassCastException at StrutsActivityGraphLogic.getController(StrutsActivityGraphLogic.java) | A controller was found but does not seem suited for bpm4struts. | |
MethodInvocationException at class StrutsTriggerLogicImpl | A method was called on one of the triggers, but some of the required information was not found, such as the name. | Make sure all triggers on transitions going out of a jsp page (action states with the FrontEndView stereotype) have a suitable name, it may not be empty. |
Did you make sure your action states all have names ? in magicdraw you really need to click 'open specification...' in order to e nter the name, if you typed the name in the diagram directly you have not entered the name, rather a label. So click 'open specification...' (right-click --> context menu) on all your action states to make sure their names are not-empty.
Yes, and the reason is very simple: the cartridge maps stereotypes to templates. This is a way of telling which files should be generated from what elements.
No, but failing to do so will not enable some of the more interesting cartridge features. Using tagged values you can enable the validation of form input fields, for example. It depends on the context of the specific model element whether or not a tagged value would be needed. All tagged values have a default value, so if you don't add one it' value will be implied.
Let's get over the things to do for a single use-case with a single page:
Since the forms are stored in the session scope it is possible to have stale data in different instances of the same use-case. In order to avoid this we must make sure the data is removed from the form whenever we re-enter that use-case. But in doing so we make it more difficult to send data between use-cases, sometimes it is needed to send an ID or semething to the next use-case, how can we make sure the form cleaning does not dispose this data ?
The solution is in fact very simple: do not use the forms when transporting values to another use-case. In fact it is a better idea to simple use HttpServletRequest.setAttribute(String,Object), this will put the value as a request scope variable that is available in the target use-case.
Controllers are not generated (the implementation that is) until you give it at least one operation (since it would be pointless otherwise).
Sure you can, openup the cartridge and go into the 'templates' directory. You will find a bunch of templates, how they map onto files can be found in the deployment-descriptor in the 'META-INF' subdirectory (next to 'templates'). You can override cartridge resources, this is all explained here.
Sure it can, just put the compiled JSPs in your WAR bundle under WEB-INF/classes.
If you have set up your environment using the andromdapp:generate plugin you can go into the 'web' component and open the project.properties file. In this file make sure you have the following property set: precompileJsps=true. Doing so will enable precompilation.
It is possible AndroMDA generates servlets with a path that is too long for the Windows filesystem when it is read from the ear bundle. In that case it is sufficient to explode you ear or war when you deploy, this will cause the path to the file to be shortened. This problem manifests itself by means of a java.lang.ClassNotFoundException.
You don't specify that in the UML model directly
You should consider the bpm4struts cartridge just as an example ,... customization can be done in the templates .. so you would like to change one of them .. more particular the one called 'StrutsXDocletMergeWebSecurity.vsl', you will understand it when you open it.
Anyway, form based authentication is configured by default, but the security is disabled by default too .. so you need to enable it.
You will need to open up andromda.xml and in the bpm4struts namespace give the 'securityRealm' the value of your security realm.
<property name="securityRealm">other</property> <property name="pages">${app.root.dir}/${web.dir}/${jsp.src.dir}</property> <property name="forms">${app.root.dir}/${web.dir}/${mda.build.dir}</property> <property name="actions">${app.root.dir}/${web.dir}/${mda.build.dir}</property> <property name="controllers">${app.root.dir}/${web.dir}/${mda.build.dir}</property> <property name="controller-impls">${app.root.dir}/${web.dir}/${java.src.dir}</property> <property name="messages">${app.root.dir}/${web.dir}/${properties.src.dir}</property> <property name="configuration">${app.root.dir}/${web.dir}/${mda.build.dir}</property>
Security is disabled by default because it requires you to configure your container too (i.e. users/roles).
Not really, at this point there is no cartridge for Webwork, but it can easily be written. Taking a look at how bpm4struts is designed will make it straightforward to implement the same thing for Webwork. This new cartridge could be called bpm4webwork ...
No, JSF is not Struts. For more information go here: Apache Struts JSF Faq. If you'd like to use JSF instead, check out the JSF cartridge.
The bpm4struts cartridge for AndroMDA has mainly been created out of a general discomfort with working with JSP/Servlets or even Struts directly. The problem was that I would find myself spending too much time on details related to the underlying technology, rather than on the core business of the application.
More concretely: