X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2Fexecution%2FJcrAgent.java;h=751d8a97d2db20e82e567c6fb4a1a403d1285966;hb=b531186cfae271152ca520489fd6443ab3eace4d;hp=89b618d1bff74b535c6cf4f3fc02ec9a3b4c6366;hpb=24d560ee846fda5d7954d44f83cb22ab449dbe61;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrAgent.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrAgent.java index 89b618d1b..751d8a97d 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrAgent.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrAgent.java @@ -1,16 +1,32 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * 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.jcr.execution; import java.util.List; import java.util.UUID; import javax.jcr.Node; +import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; +import org.argeo.slc.core.execution.DefaultAgent; import org.argeo.slc.core.execution.ProcessThread; -import org.argeo.slc.core.runtime.DefaultAgent; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.jcr.SlcJcrConstants; @@ -21,7 +37,7 @@ import org.argeo.slc.runtime.SlcAgentFactory; /** SLC VM agent synchronizing with a JCR repository. */ public class JcrAgent extends DefaultAgent implements SlcAgentFactory, SlcNames { - private Session session; + private Repository repository; /** only one agent per VM is currently supported */ private final String agentNodeName = "default"; @@ -30,8 +46,10 @@ public class JcrAgent extends DefaultAgent implements SlcAgentFactory, SlcNames * LIFECYCLE */ protected String initAgentUuid() { + Session session = null; try { - Node vmAgentFactoryNode = JcrUtils.mkdirs(session, + session = repository.login(); + Node vmAgentFactoryNode = JcrUtils.mkdirsSafe(session, SlcJcrConstants.VM_AGENT_FACTORY_PATH, SlcTypes.SLC_AGENT_FACTORY); if (!vmAgentFactoryNode.hasNode(agentNodeName)) { @@ -46,11 +64,14 @@ public class JcrAgent extends DefaultAgent implements SlcAgentFactory, SlcNames } catch (RepositoryException e) { JcrUtils.discardQuietly(session); throw new SlcException("Cannot find JCR agent UUID", e); + } finally { + JcrUtils.logoutQuietly(session); } } - public void dispose() { - + @Override + public void destroy() { + super.destroy(); } /* @@ -88,12 +109,12 @@ public class JcrAgent extends DefaultAgent implements SlcAgentFactory, SlcNames /* * BEAN */ - public void setSession(Session session) { - this.session = session; - } - public String getAgentNodeName() { return agentNodeName; } + public void setRepository(Repository repository) { + this.repository = repository; + } + }