/** Load persistent deployed state */ Map<AssemblyId, DeployedAssembly> load() { Map<AssemblyId, DeployedAssembly> assembliesById = new HashMap<AssemblyId, DeployedAssembly>(); Map<TypedComponentId, List<String>> resourceListsByComponentId = new HashMap<TypedComponentId, List<String>>(); Connection c = null; EasyResultSet rs = null; try { c = getConnection(); EasyStatement selecta = new EasyStatement(c, "SELECT * FROM DEPLOY_ASSEMBLIES"); try { rs = selecta.executeQuery(); while (rs.next()) { String assembly = rs.readString(); int version = rs.readInt(); String adir = rs.readString(); boolean active = rs.readInt() != 0; AssemblyId aid = new AssemblyId(assembly, version); adir = (new File(_deployDir, adir)).toString(); DeployedAssembly da = new DeployedAssembly(aid, adir, new ArrayList<DeployedComponent>(), active); assembliesById.put(aid, da); } } finally { if (rs != null) rs.close(); selecta.close(); } EasyStatement selectb = new EasyStatement(c, "SELECT * FROM DEPLOY_RESOURCES"); try { rs = selectb.executeQuery(); while (rs.next()) { String assembly = rs.readString(); int version = rs.readInt(); String component = rs.readString(); String type = rs.readString(); String resource = rs.readString(); TypedComponentId tcid = new TypedComponentId(assembly, version, component, type); List<String> deployedResource = resourceListsByComponentId.get(tcid); if (deployedResource == null) { deployedResource = new ArrayList<String>(); resourceListsByComponentId.put(tcid, deployedResource); } deployedResource.add(resource); } } finally { if (rs != null) rs.close(); selectb.close(); } EasyStatement selectc = new EasyStatement(c, "SELECT * FROM DEPLOY_COMPONENTS"); try { rs = selectc.executeQuery(); while (rs.next()) { String assembly = rs.readString(); int version = rs.readInt(); String component = rs.readString(); String type = rs.readString(); String cdir = rs.readString(); AssemblyId aid = new AssemblyId(assembly, version); ComponentId cid = new ComponentId(aid, component); DeployedAssembly da = assembliesById.get(aid); if (da == null) { LOG.error("Deployed component entry is missing parent assembly: " + cid); } else { cdir = (new File(da.getAssemblyDir(), cdir)).toString(); List<String> deployedResources = resourceListsByComponentId.get(new TypedComponentId(cid, type)); if (deployedResources == null) { deployedResources = new ArrayList<String>(); } DeployedComponent dc = new DeployedComponent(cid, cdir, type, deployedResources); da.getDeployedComponents().add(dc); if (LOG.isDebugEnabled()) LOG.debug( "DEPLOYMENT.component discovered: " + dc + ", resources = " + dc.getDeployedResources()); } } } finally { if (rs != null) rs.close(); selectc.close(); } return assembliesById; } catch (SQLException e) { throw new PersistenceException(e); } finally { close(c); } }