I was wondering what are the general steps required in building some sort of java extension or plugin. More specifically, I’m looking to build something like a C++ struct in java that will allow me to declare the methods from a particular class so that I can indicate the order they should be executed by the JVM. This is just pie in the sky at the moment and I’m interested in how the likes of AspectJ or other java extensions work to allow you to declare syntax that is not native to java. I’m assuming this would require some sort of compiler plugin.
As an example, I envisage something like the following
public struct weakProfile {
streamDataViaGprs();
sendSimpleMap();
}
public struct strongProfile {
streamDataVia3G();
sendComplexMap();
sendAudio();
}
In the above example, if I have a web service and the client has a weak profile, meaning that the device they are using to invoke the service has low processing and poor bandwidth capabilities, then I would like to only deliver only streamDataViaGprs() and sendSimpleMap() functionality. However, if the client device has strong processing capabilities and excellent bandwidth connection, then I would like to streamDataVia3G(), sendComplexMap() and sendAudio(). This is my ultimate goal, however I’m not sure what would be involved in developing a structure as that above, let alone if it’s even possible.
If you are using Eclipse you can take a look at Xtext.
It allows you to create a DSL and a code editor (with syntax highlighting and code completion) inside Eclipse.
There is also JetBrains MPS, the Meta Programming System.