[Comsuite-svn] SF.net SVN: comsuite: [120] trunk/code
Brought to you by:
zduniak
|
From: <sku...@us...> - 2006-08-30 19:50:33
|
Revision: 120
http://svn.sourceforge.net/comsuite/?rev=120&view=rev
Author: skuzniak
Date: 2006-08-30 12:49:57 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
all services switched to singletons, additional field in sapinstancedef added.
Modified Paths:
--------------
trunk/code/CSCommon/src/org/commsuite/ws/ICommunicateWS.java
trunk/code/CSMiddleware/src/org/commsuite/dao/SAPInstanceDefDao.java
trunk/code/CSMiddleware/src/org/commsuite/dao/hibernate/SAPInstanceDefDaoImpl.java
trunk/code/CSMiddleware/src/org/commsuite/managers/SAPInstanceDefManager.java
trunk/code/CSMiddleware/src/org/commsuite/managers/impl/SAPInstanceDefManagerImpl.java
trunk/code/CSMiddleware/src/org/commsuite/sap/ISAPComm.java
trunk/code/CSMiddleware/src/org/commsuite/sap/SAPComm.java
trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java
trunk/code/CSMiddleware/src/org/commsuite/ws/CommunicateWS.java
trunk/code/CSMiddleware/src/org/commsuite/ws/services/ActionsService.java
trunk/code/CSMiddleware/src/org/commsuite/ws/services/GroupsService.java
trunk/code/CSMiddleware/src/org/commsuite/ws/services/RolesService.java
trunk/code/CSMiddleware/src/org/commsuite/ws/services/ServersService.java
Modified: trunk/code/CSCommon/src/org/commsuite/ws/ICommunicateWS.java
===================================================================
--- trunk/code/CSCommon/src/org/commsuite/ws/ICommunicateWS.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSCommon/src/org/commsuite/ws/ICommunicateWS.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -183,6 +183,8 @@
public Collection<WSRole> getRolesForGroup(String id) throws WebServiceException;
public Collection<WSGroup> getGroupsByUser(String name) throws WebServiceException;
+
+ public void deactivateServer(String id, boolean mode) throws WebServiceException ;
/**
* This method allows test server with known ID
Modified: trunk/code/CSMiddleware/src/org/commsuite/dao/SAPInstanceDefDao.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/dao/SAPInstanceDefDao.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/dao/SAPInstanceDefDao.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -45,5 +45,7 @@
public void deleteSAPInstanceDef(SAPInstanceDef sapInstanceDef);
public SAPInstanceDef getSAPInstanceDefByMessageId(Long long1);
+
+ public void deactivateInstance(String id, boolean mode);
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/dao/hibernate/SAPInstanceDefDaoImpl.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/dao/hibernate/SAPInstanceDefDaoImpl.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/dao/hibernate/SAPInstanceDefDaoImpl.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -138,5 +138,11 @@
logger.debug("SIZE OF INSTANCES MATCHING TO GIVES PATTERN: " + list.size());
return list;
}
+
+ public void deactivateInstance(String id, boolean mode) {
+ SAPInstanceDef instance = getSAPInstanceDef(Long.getLong(id).longValue());
+ instance.setActiveInstance(mode);
+ getHibernateTemplate().saveOrUpdate(id, instance);
+ }
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/managers/SAPInstanceDefManager.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/managers/SAPInstanceDefManager.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/managers/SAPInstanceDefManager.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -45,5 +45,7 @@
public void deleteSAPInstanceDef(SAPInstanceDef sapInstanceDef);
public SAPInstanceDef getSAPInstanceDefByMessageId(String string);
+
+ public void deactivateInstance(String id, boolean mode);
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/managers/impl/SAPInstanceDefManagerImpl.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/managers/impl/SAPInstanceDefManagerImpl.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/managers/impl/SAPInstanceDefManagerImpl.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -88,5 +88,7 @@
return dao.getSAPInstanceDefByMessageId(Long.valueOf(messageId));
}
-
+ public void deactivateInstance(String id, boolean mode) {
+ dao.deactivateInstance(id, mode);
+ }
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/sap/ISAPComm.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/sap/ISAPComm.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/sap/ISAPComm.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -56,6 +56,8 @@
public abstract String getName();
public abstract IJCOServer getServer();
+
+ public abstract boolean isActiveInstance();
public String toString();
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/sap/SAPComm.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/sap/SAPComm.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/sap/SAPComm.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -582,5 +582,9 @@
public boolean isHandlingRequest() {
return handlingRequest;
}
+
+ public boolean isActiveInstance() {
+ return this.instanceDef.isActiveInstance();
+ }
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/sap/SAPCommManager.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -127,21 +127,23 @@
final Collection<ISAPComm> clonnedSapComms = new FastTable<ISAPComm>(sapComms.values());
for (final ISAPComm sapComm : clonnedSapComms) {
- 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());
+ }
+ }
}
}
Modified: trunk/code/CSMiddleware/src/org/commsuite/ws/CommunicateWS.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/ws/CommunicateWS.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/ws/CommunicateWS.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -318,7 +318,7 @@
public Collection<WSAction> getActionsAvailable() throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.getActionsAvailable();
} catch (Throwable t) {
logger.fatal("error in getActionsAvailable method", t);
@@ -328,7 +328,7 @@
public Collection<WSAction> getActionsByRole(String id) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.getActionsByRole(id);
} catch (Throwable t) {
logger.fatal("error in getActionsByRole method", t);
@@ -340,7 +340,7 @@
// do zapisywania zmian przy edycji juz istniejacych akcji ? nazwa tej metody jest odpowiednia ?
public WSAction addActionToDatabase(WSAction action) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.addActionToDatabase(action);
} catch (DataIntegrityViolationException dive) {
logger.fatal("duplicate action name");
@@ -354,7 +354,7 @@
// TODO: [SK] czy ta metoda nie powinna zwracac obiektu typu WSAction ?
public Action getActionById(String id) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.getActionById(id);
} catch (Throwable t) {
logger.fatal("error in getActionById method", t);
@@ -364,7 +364,7 @@
public WSAction getWSActionById(String id) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.getWSActionById(id);
} catch (Throwable t) {
logger.fatal("error in getActionById method", t);
@@ -374,7 +374,7 @@
public void deleteActionFromDatabase(String id) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
service.deleteActionFromDatabase(id);
} catch (DataIntegrityViolationException diva) {
logger.fatal("This action is assigned.");
@@ -387,7 +387,7 @@
public Collection<WSAction> getActionsByName(String name) throws WebServiceException {
try {
- ActionsService service = new ActionsService();
+ ActionsService service = ActionsService.getInstance();
return service.getActionsByName(name);
} catch (Throwable t) {
logger.fatal("error in addActionToDatabase method", t);
@@ -397,7 +397,7 @@
public WSRole updateRole(WSRole wsRole) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.updateRole(wsRole);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -410,7 +410,7 @@
public WSRole updateActionsForRole(WSRole wsRole, String[] ids) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.updateActionsForRole(wsRole, ids);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -424,7 +424,7 @@
public WSRole updateUsersForRole(WSRole wsRole, String[] idsToAdd, String[] idsToDelete)
throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.updateUsersForRole(wsRole, idsToAdd, idsToDelete);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -437,7 +437,7 @@
public void deleteRoleFromDatabase(String id) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
service.deleteRoleFromDatabase(id);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Something is assigned to this role");
@@ -450,7 +450,7 @@
public Collection<WSRole> getAllRoles() throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getAllRoles();
} catch (Throwable t) {
logger.fatal("error in getAllRoles method", t);
@@ -471,7 +471,7 @@
public Collection<WSGroup> getAllGroups() throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.getAllGroups();
} catch (Throwable t) {
logger.fatal("error in getAllGroups method", t);
@@ -481,7 +481,7 @@
public WSGroup updateGroup(WSGroup wsGroup) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.updateGroup(wsGroup);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -494,7 +494,7 @@
public WSGroup updateRolesForGroup(WSGroup wsGroup, String[] ids) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.updateRolesForGroup(wsGroup, ids);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -508,7 +508,7 @@
public WSGroup updateUsersForGroup(WSGroup wsGroup, String[] idsToAdd, String[] idsToDelete)
throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.updateUsersForGroup(wsGroup, idsToAdd, idsToDelete);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Duplicate name error");
@@ -521,7 +521,7 @@
public void deleteGroupFromDatabase(String id) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
service.deleteGroupFromDatabase(id);
} catch (DataIntegrityViolationException dive) {
logger.fatal("Something is assigned to this group");
@@ -554,7 +554,7 @@
public WSRole getRoleById(String id) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getRoleById(id);
} catch (Throwable t) {
logger.fatal("error in getRoleById method", t);
@@ -564,7 +564,7 @@
public WSGroup getGroupById(String id) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.getGroupById(id);
} catch (Throwable t) {
logger.fatal("error in getGroupById method", t);
@@ -574,7 +574,7 @@
public Collection<WSRole> getRolesByName(String name) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getRolesByName(name);
} catch (Throwable t) {
logger.fatal("error in getAllRoles method", t);
@@ -584,7 +584,7 @@
public Collection<WSGroup> getGroupsByName(String name) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.getGroupsByName(name);
} catch (Throwable t) {
logger.fatal("error in getAllGroups method", t);
@@ -614,7 +614,7 @@
public Collection<WSRole> getRolesForGroup(String id) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getRolesForGroup(id);
} catch (Throwable t) {
logger.fatal("Exception while getting roles for group: " + id, t);
@@ -634,7 +634,7 @@
public Collection<WSRole> getRolesByUser(String id) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getRolesByUser(id);
} catch (Throwable t) {
logger.fatal("Exception while getting roles for user: " + id, t);
@@ -644,7 +644,7 @@
public Collection<WSGroup> getGroupsByUser(String id) throws WebServiceException {
try {
- GroupsService service = new GroupsService();
+ GroupsService service = GroupsService.getInstance();
return service.getGroupsByUser(id);
} catch (Throwable t) {
logger.fatal("Exception while getting groups for user: " + id, t);
@@ -654,7 +654,7 @@
public Collection<WSRole> getRoleByActionId(String id) throws WebServiceException {
try {
- RolesService service = new RolesService();
+ RolesService service = RolesService.getInstnce();
return service.getRoleByActionId(id);
} catch (Throwable t) {
logger.fatal("Exception while getting roles for action: " + id, t);
@@ -701,5 +701,15 @@
throw new WebServiceException(t);
}
}
+
+ public void deactivateServer(String id, boolean mode) throws WebServiceException {
+ try {
+ ServersService service = ServersService.getInstance();
+ service.deactivateServer(id, mode);
+ } catch(Throwable t) {
+ logger.fatal("error while deactivating server", t);
+ throw new WebServiceException(t);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/code/CSMiddleware/src/org/commsuite/ws/services/ActionsService.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/ws/services/ActionsService.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/ws/services/ActionsService.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -41,6 +41,19 @@
public class ActionsService {
private static final Logger logger = Logger.getLogger(ActionsService.class);
+
+ private static ActionsService instance;
+
+ private ActionsService() {
+
+ }
+
+ public synchronized static ActionsService getInstance() {
+ if (null == instance) {
+ instance = new ActionsService();
+ }
+ return instance;
+ }
public Collection<WSAction> getActionsAvailable() throws WebServiceException {
try {
Modified: trunk/code/CSMiddleware/src/org/commsuite/ws/services/GroupsService.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/ws/services/GroupsService.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/ws/services/GroupsService.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -47,6 +47,19 @@
private static final Logger logger = Logger.getLogger(GroupsService.class);
+ private static GroupsService instance;
+
+ private GroupsService() {
+
+ }
+
+ public synchronized static GroupsService getInstance() {
+ if (null == instance) {
+ instance = new GroupsService();
+ }
+ return instance;
+ }
+
public Collection<WSGroup> getAllGroups() throws WebServiceException {
try {
GroupManager groupManager = (GroupManager) SpringMiddlewareContext.getGroupManager();
Modified: trunk/code/CSMiddleware/src/org/commsuite/ws/services/RolesService.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/ws/services/RolesService.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/ws/services/RolesService.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -50,6 +50,19 @@
private static final Logger logger = Logger.getLogger(RolesService.class);
+ private static RolesService instance;
+
+ private RolesService() {
+
+ }
+
+ public static synchronized RolesService getInstnce() {
+ if (null == instance) {
+ instance = new RolesService();
+ }
+ return instance;
+ }
+
public WSRole updateRole(WSRole wsRole) throws WebServiceException {
Role role;
try {
Modified: trunk/code/CSMiddleware/src/org/commsuite/ws/services/ServersService.java
===================================================================
--- trunk/code/CSMiddleware/src/org/commsuite/ws/services/ServersService.java 2006-08-21 19:09:35 UTC (rev 119)
+++ trunk/code/CSMiddleware/src/org/commsuite/ws/services/ServersService.java 2006-08-30 19:49:57 UTC (rev 120)
@@ -421,5 +421,16 @@
throw new WebServiceException(t);
}
}
+
+ public void deactivateServer(String id, boolean mode) throws WebServiceException {
+ /*try {
+ final SAPInstanceDefManager instManager = (SAPInstanceDefManager) SpringMiddlewareContext
+ .getSAPInstanceDefManager();
+ instManager.deactivateInstance(id, mode);
+ } catch(Throwable t) {
+ logger.fatal("error in deactivateServer method", t);
+ throw new WebServiceException(t);
+ }*/
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|