Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The service spring beans are configured in applicationContext.xml (not in action-servlet.xml) as singletons. Because of this, there should be no instance variables defined for your service other than static variables that you intend to be accessed across threads (users). For instance, in the example below, a static variable, log, is defined. This means all users will write to the same log file which is the behavior you want.

More Info on SAPServiceSupport 

All of our services are subclasses of SAPServiceSupport which does have has 4 singleton instance variables (messageKeys, connectionMgr, messageMgr, packageName) which are all instantiated once with values from the applicationContext.xml config file when the Spring Framework instantiates the service.

  • The messageKeys are essentially strings for configuration to tell the framework what tables to look in for return messages.
  • The connectionManager allows you to generate connections. 
  • The messageManager is what holds all the messages from SAP. Now this might sound not "thread-safe", but the messageManager stores this data in a "ThreadLocal" which essentially binds the messages to the running Thread only.
  • The packageName, like messageKeys, is for configuration (apparently necessary for sap2java because of the way it utilizes reflection).

convertRFCMessage

If the message objects returned from the back end have both the TYPE and MESSAGE fields, then you do not need to modify the method convertRFCMessage. Error messages are automatically handled by mortar. However, if some other type of object is returned instead that doesn't have these fields, you will need to add code in the convertRFCMessage method to convert these message objects to the RFCMessage type.

...