[Comsuite-svn] SF.net SVN: comsuite: [198] trunk/code
Brought to you by:
zduniak
|
From: <ma...@us...> - 2006-10-05 08:04:41
|
Revision: 198
http://svn.sourceforge.net/comsuite/?rev=198&view=rev
Author: marasm
Date: 2006-10-05 01:04:29 -0700 (Thu, 05 Oct 2006)
Log Message:
-----------
message state set to failed/sent after sending to sap
Modified Paths:
--------------
trunk/code/CSCommon/src/org/commsuite/aop/SystemArchitecture.java
trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java
Modified: trunk/code/CSCommon/src/org/commsuite/aop/SystemArchitecture.java
===================================================================
--- trunk/code/CSCommon/src/org/commsuite/aop/SystemArchitecture.java 2006-10-05 07:54:26 UTC (rev 197)
+++ trunk/code/CSCommon/src/org/commsuite/aop/SystemArchitecture.java 2006-10-05 08:04:29 UTC (rev 198)
@@ -65,7 +65,9 @@
final StringBuilder parameters = new StringBuilder();
- if (null != pjp.getArgs()) {
+ if (null != pjp.getArgs()
+ && !pjp.getSignature().toString().toUpperCase().contains(
+ "JCOFUNCTION")) {
// TODO: consider using only one method invocation:
// Arrays.toString(pjp.getArgs())
// instead of below loop:
@@ -93,8 +95,12 @@
throw e;
}
- logger.debug(pjp.getSignature() + " " + result);
+ if (!pjp.getSignature().toString().toUpperCase()
+ .contains("JCOFUNCTION")) {
+ logger.debug(pjp.getSignature() + " " + result);
+ } else {
+ logger.debug(pjp.getSignature());
+ }
return result;
}
-
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java 2006-10-05 07:54:26 UTC (rev 197)
+++ trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java 2006-10-05 08:04:29 UTC (rev 198)
@@ -32,13 +32,11 @@
import org.apache.log4j.Logger;
import org.commsuite.enums.State;
import org.commsuite.managers.MessageManager;
-import org.commsuite.managers.SentContentManager;
import org.commsuite.model.Message;
import org.commsuite.model.SAPInstanceDef;
import org.commsuite.model.SentContent;
import org.commsuite.notification.INotificationsManager;
import org.commsuite.util.SpringContext;
-import org.commsuite.util.SpringMiddlewareBeansConstants;
import org.commsuite.util.SpringMiddlewareContext;
import com.sap.mw.jco.JCO;
@@ -65,7 +63,7 @@
private boolean enabled;
private INotificationsManager notificationsManager;
-
+
/**
* @param enabled
* The enabled to set.
@@ -82,12 +80,13 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public SAPCommManager() {
super();
sapComms = new FastMap<String, ISAPComm>();
- enabled = "true".equals(SpringContext.getProperty("commsuite.SAPCommManager.enabled"));
+ enabled = "true".equals(SpringContext
+ .getProperty("commsuite.SAPCommManager.enabled"));
}
/**
@@ -102,8 +101,8 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void sendMessageToDefault(Message message) {
logger.debug("Sending message to default SAP servers");
@@ -115,12 +114,17 @@
for (final ISAPComm sapComm : sapComms.values()) {
if (sapComm.isDefault()) {
logger.debug("Sending message to: " + sapComm.getName());
+
+ State state = (sapComm.sendMessage(message)) ? State.SENT
+ : State.FAILED;
- // TODO: message must be cloned and stored in DB as set of distinct messages.
- // Enumeration Message.SentContents.State must be set accordingly to what
- // state was received from SAP server for each of messages.
+ for (SentContent sentContent : message.getSentContents()) {
+ sentContent.setState(state);
+ }
- sapComm.sendMessage(message);
+ SpringMiddlewareContext.getMessageManager()
+ .saveMessage(message);
+
logger.debug("Message sent to: " + sapComm.getName());
// SentContentManager sentContentManager = SpringMiddlewareContext.getSentContentManager();
@@ -138,41 +142,47 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void init() {
- logger.debug("Running init() method in SAPCommManager (size: " + sapComms.size() + ")");
+ logger.debug("Running init() method in SAPCommManager (size: "
+ + sapComms.size() + ")");
initJCOTracePath();
- final Collection<ISAPComm> clonnedSapComms = new FastTable<ISAPComm>(sapComms.values());
+ final Collection<ISAPComm> clonnedSapComms = new FastTable<ISAPComm>(
+ sapComms.values());
for (final ISAPComm sapComm : clonnedSapComms) {
- if (sapComm.isActiveInstance()) {
- logger.info("Initiating: " + sapComm);
- try {
- sapComm.startServer();
- } catch (Throwable t) {
- logger.fatal("Error during starting SAPComm: " + sapComm, t);
- // stop partially started SAPComm:
- try {
- sapComm.destroy();
- } catch (Throwable ignore) {
- // Ignore
- }
- // remove error prone SAPComm from oryginal collection:
- // REVIEW: maybe it is not good idea to remove sap instance from collection ?
- // sapComms.remove(sapComm.getName());
- }
- }
+ if (sapComm.isActiveInstance()) {
+ logger.info("Initiating: " + sapComm);
+ try {
+ sapComm.startServer();
+ } catch (Throwable t) {
+ logger
+ .fatal("Error during starting SAPComm: " + sapComm,
+ t);
+ // stop partially started SAPComm:
+ try {
+ sapComm.destroy();
+ } catch (Throwable ignore) {
+ // Ignore
+ }
+ // remove error prone SAPComm from oryginal collection:
+ // REVIEW: maybe it is not good idea to remove sap instance
+ // from collection ?
+ // sapComms.remove(sapComm.getName());
+ }
+ }
}
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
private void initJCOTracePath() {
- final String jcoTracePath = getClass().getResource("/").getPath() + ".." + File.separator
- + ".." + File.separator + ".." + File.separator + ".." + File.separator + "logs"
+ final String jcoTracePath = getClass().getResource("/").getPath()
+ + ".." + File.separator + ".." + File.separator + ".."
+ + File.separator + ".." + File.separator + "logs"
+ File.separator;
JCO.setTracePath(jcoTracePath);
JCO.setTraceLevel(TRACE_LEVEL);
@@ -182,8 +192,8 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void destroy() {
logger.info("Destroying SAPCommManager");
for (final ISAPComm sapComm : sapComms.values()) {
@@ -193,14 +203,15 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
// TODO: should this method be sensitive on active field??
public void setSapInstances(Collection<SAPInstanceDef> sapInstances) {
// TODO: init sapComms collection with values from DB
- logger.info("Running setSapInstances() method in SAPCommManager (size: "
- + sapInstances.size() + ")");
+ logger
+ .info("Running setSapInstances() method in SAPCommManager (size: "
+ + sapInstances.size() + ")");
if (!isEnabled()) {
return;
@@ -211,75 +222,80 @@
sapComm.init(inst);
final SAPNotificationConsumer sapNotificationConsumer = new SAPNotificationConsumer(
sapComm);
-
+
// TODO: this condition is used only during performing tests.
- // Refactor it in order to neglect below condition in production code.
+ // Refactor it in order to neglect below condition in production
+ // code.
if (null != notificationsManager) {
- notificationsManager.associateNewConsumer(sapComm.getName(), sapNotificationConsumer);
+ notificationsManager.associateNewConsumer(sapComm.getName(),
+ sapNotificationConsumer);
}
- sapComms.put(sapComm.getName(), sapComm);
+ sapComms.put(sapComm.getName(), sapComm);
}
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
// TODO: should this method be sensitive on active field??
public void setSapInstance(SAPInstanceDef instance) {
- if (!isEnabled()) {
- return;
- }
- final ISAPComm sapComm = new SAPComm();
- sapComm.init(instance);
- final SAPNotificationConsumer sapNotificationConsumer = new SAPNotificationConsumer(
+ if (!isEnabled()) {
+ return;
+ }
+ final ISAPComm sapComm = new SAPComm();
+ sapComm.init(instance);
+ final SAPNotificationConsumer sapNotificationConsumer = new SAPNotificationConsumer(
sapComm);
- notificationsManager.associateNewConsumer(sapComm.getName(), sapNotificationConsumer);
+ notificationsManager.associateNewConsumer(sapComm.getName(),
+ sapNotificationConsumer);
sapComms.put(sapComm.getName(), sapComm);
}
/**
- * TODO: JavaDoc
- */
- public void setNotificationsManager(INotificationsManager notificationsManager) {
+ * TODO: JavaDoc
+ */
+ public void setNotificationsManager(
+ INotificationsManager notificationsManager) {
this.notificationsManager = notificationsManager;
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public boolean isEnabled() {
return enabled;
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
/* package scope */void checkExistenceOfSAPInstance(String instanceName) {
if (!sapComms.containsKey(instanceName)) {
- throw new SAPInstanceException("Instance: " + instanceName + " does not exist.");
+ throw new SAPInstanceException("Instance: " + instanceName
+ + " does not exist.");
}
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void startInstance(String instanceName) {
logger.info("Starting instance: " + instanceName);
checkExistenceOfSAPInstance(instanceName);
final ISAPComm instance = sapComms.get(instanceName);
if (instance.isActiveInstance()) {
- instance.startServer();
- logger.info("Instance started: " + instanceName);
+ instance.startServer();
+ logger.info("Instance started: " + instanceName);
} else {
- logger.warn("Instance is not active");
- throw new RuntimeException("Unable to start inactive instance");
+ logger.warn("Instance is not active");
+ throw new RuntimeException("Unable to start inactive instance");
}
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void stopInstance(String instanceName) {
logger.info("Stopping instance: " + instanceName);
checkExistenceOfSAPInstance(instanceName);
@@ -289,30 +305,30 @@
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public void destroyInstance(String instanceName) {
logger.info("Destroying instance: " + instanceName);
checkExistenceOfSAPInstance(instanceName);
final ISAPComm instance = sapComms.get(instanceName);
- logger.debug("INSTANCE: "+ instance);
+ logger.debug("INSTANCE: " + instance);
sapComms.remove(instance.getName());
instance.destroy();
logger.info("Instance destroyed: " + instanceName);
}
/**
- * TODO: JavaDoc
- */
+ * TODO: JavaDoc
+ */
public ISAPComm getSAPCommByName(String name) {
return sapComms.get(name);
}
/**
- * TODO: JavaDoc
- */
- public boolean isSapServerWorking(String name) {
- ISAPComm SappCommByName = getSAPCommByName(name);
- return (null != SappCommByName && null != SappCommByName.getServer());
- }
+ * TODO: JavaDoc
+ */
+ public boolean isSapServerWorking(String name) {
+ ISAPComm SappCommByName = getSAPCommByName(name);
+ return (null != SappCommByName && null != SappCommByName.getServer());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|