Information Technology Reference
In-Depth Information
IProtocol p;
generate() {
p = ProtocolFactory.getProtocol(name);
p.setOptions(protocolOptions);
p.validateOptions();
p.generateProtocol();
}
ProtocolFactory
Generator
<<interface>>
IProtocol
Contains common
weaving functionality
Protocol
RMIProtocol
JMSProtocol
RESTProtocol
...Protocol
Javassist
Figure 5.2.
Extendible code generation support.
public interface IProtocol {
void validateOptions() throws OptionException;
void setOptions(ProtocolOptions opt);
void setServerOutputDirectory(String serverOutputDirectory);
void setClientOutputDirectory(String clientOutputDirectory);
void setService(String spelling);
void setImports(Vector<String> imports);
void setReporter(ErrorHandler reporter);
void setLineNumber(SourcePosition position);
void setRecovery(Vector<JavaMethod> recovery);
void setProtocolDescription(ProtocolDescription protocols);
void generateAll();
}
Figure 5.3.
IProtocol class.
This approach makes it relatively easy to add additional protocols as no
changes need to be made to the language or the compiler/generator to support
new protocols and their options.
5.2.1
Bytecode Rewriting
The RemoteJ compiler/generator uses the Javassist [19] library, a bytecode rewrit-
ing library used by the JBoss AOP framework [54], for all bytecode rewriting.
Search WWH ::




Custom Search