on ‎2020 Jan 02 10:37 PM
I am trying to understand what is the difference between
MessageLogFactory and messageLogFactory
I am tried using below class to get the instance of message log but getting an exception as shown in error details.
com.sap.it.api.msglog.MessageLogFactoryError Details java.lang.NoSuchMethodException: No signature of method: static com.sap.it.api.msglog.MessageLogFactory.getMessageLog() is applicable for argument types: (com.sap.gateway.ip.core.customdev.processor.MessageImpl) values: [com.sap.gateway.ip.core.customdev.processor.MessageImpl@172e1254]
The context object can be either a Camel Exchange, a CXF exchange, or a com.sap.it.api.msg.ExchangePropertyProvider.
This piece of code works fine
def logVariable(Message message, String name, String value) {
boolean enableLogging = Boolean.parseBoolean(message.getProperty("enable_logging") as String)
if (enableLogging) {
def messageLog = messageLogFactory.getMessageLog(message)
messageLog.setStringProperty(name, value)
}
}
This code gives me an error
def logVariable1(Message message){
def messageLog = MessageLogFactory.getMessageLog(message)
messageLog.setStringProperty("Test_Log", "Test Log")
}
Request clarification before answering.
Hi Srini
MessageLogFactory (upper case M) is the name of an interface in the com.sap.it.api.msglog package. messageLogFactory (lower case M), on the other hand, is the name of a variable made available to your scripts by the runtime. The variable references an instance of a class, which implements the MessageLogFactory (upper case M again) interface.
If you are curious about which class, run the following script:
import com.sap.gateway.ip.core.customdev.util.Message
def Message processData(Message message) {
message.setBody(messageLogFactory.getClass().getName())
return message
}Right now it returns com.sap.it.op.agent.mpl.factory.impl.MessageLogFactoryImpl. The class is not important, though. What's important is that it implements the interface, and therefore lets you create MessageLog instances.
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Morten.
It helps me understand it better now. I never thought of it as the implementation class for the interface. 🙂
Regards,
Srini
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.