]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/services/impl/AgentServiceImpl.java
Update license header
[gpl/argeo-slc.git] / runtime / org.argeo.slc.server / src / main / java / org / argeo / slc / services / impl / AgentServiceImpl.java
index 03676bf1f24e053e0d3575029d8bfc67887cc4dc..60df72a9cf526ba33ced1d1cfcdeb4b879aac745 100644 (file)
@@ -1,11 +1,27 @@
+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.argeo.slc.services.impl;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.Executor;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.security.ArgeoSecurityService;
 import org.argeo.slc.dao.runtime.SlcAgentDescriptorDao;
 import org.argeo.slc.runtime.SlcAgent;
 import org.argeo.slc.runtime.SlcAgentDescriptor;
@@ -21,7 +37,7 @@ public class AgentServiceImpl implements AgentService, InitializingBean,
        private final SlcAgentDescriptorDao slcAgentDescriptorDao;
        private final SlcAgentFactory agentFactory;
 
-       private ArgeoSecurityService securityService;
+       private Executor systemExecutor;
 
        private Long pingCycle = 20000l;
 
@@ -49,9 +65,11 @@ public class AgentServiceImpl implements AgentService, InitializingBean,
                // if (pingCycle > 0)
                // new PingThread().start();
                if (pingCycle > 0) {
-                       Thread authenticatedThread = new Thread(securityService
-                                       .wrapWithSystemAuthentication(new AgentsPing()),
-                                       "SLC Agents Ping");
+                       Thread authenticatedThread = new Thread("SLC Agents Ping") {
+                               public void run() {
+                                       systemExecutor.execute(new AgentsPing());
+                               }
+                       };
                        authenticatedThread.start();
 
                }
@@ -66,8 +84,8 @@ public class AgentServiceImpl implements AgentService, InitializingBean,
                this.pingCycle = pingCycle;
        }
 
-       public void setSecurityService(ArgeoSecurityService securityService) {
-               this.securityService = securityService;
+       public void setSystemExecutor(Executor securityService) {
+               this.systemExecutor = securityService;
        }
 
        protected class AgentsPing implements Runnable {
@@ -90,7 +108,7 @@ public class AgentServiceImpl implements AgentService, InitializingBean,
                                        agentIds.add(ad.getUuid());
 
                                if (log.isTraceEnabled())
-                                       log.debug("Ping " + agentIds.size() + " agent.");
+                                       log.trace("Ping " + agentIds.size() + " agent(s).");
                                for (String agentId : agentIds) {
                                        SlcAgent agent = agentFactory.getAgent(agentId);
                                        if (!agent.ping()) {