public void releaseLocks(Set<Contribution> contributions) { for (Contribution contribution : contributions) { for (Deployable deployable : contribution.getManifest().getDeployables()) { QName name = deployable.getName(); if (contribution.getLockOwners().contains(name)) { contribution.releaseLock(name); } } } }
public void lock(Set<Contribution> contributions) throws CompositeAlreadyDeployedException { for (Contribution contribution : contributions) { for (Deployable deployable : contribution.getManifest().getDeployables()) { QName name = deployable.getName(); // check if the deployable has already been deployed by querying the lock owners if (contribution.getLockOwners().contains(name)) { throw new CompositeAlreadyDeployedException("Composite has already been deployed: " + name); } contribution.acquireLock(name); } } }
@ManagementOperation(description = "Returns metadata for all contributions deployed in a domain") public Set<ContributionInfo> getContributions() { Set<Contribution> contributions = metaDataStore.getContributions(); Set<ContributionInfo> infos = new TreeSet<ContributionInfo>(); for (Contribution contribution : contributions) { URI uri = contribution.getUri(); String state = contribution.getState().toString(); long timestamp = contribution.getTimestamp(); List<QName> deployables = new ArrayList<QName>(); for (Deployable deployable : contribution.getManifest().getDeployables()) { deployables.add(deployable.getName()); } ContributionInfo info = new ContributionInfo(uri, state, deployables, timestamp); infos.add(info); } return infos; }
public List<Composite> getDeployables(Set<Contribution> contributions) { List<Composite> deployables = new ArrayList<>(); for (Contribution contribution : contributions) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof Composite)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, Composite> element = (ResourceElement<QNameSymbol, Composite>) entry; QName name = element.getSymbol().getKey(); Composite composite = element.getValue(); for (Deployable deployable : contribution.getManifest().getDeployables()) { if (deployable.getName().equals(name)) { List<RuntimeMode> deployableModes = deployable.getRuntimeModes(); // only add deployables that are set to boot in the current runtime mode and where the environment matches if (deployableModes.contains(hostInfo.getRuntimeMode())) { List<String> environments = deployable.getEnvironments(); if (environments.isEmpty() || environments.contains(hostInfo.getEnvironment())) { deployables.add(composite); } } break; } } } } } return deployables; }
public List<Composite> getDeployables(Set<Contribution> contributions) { List<Composite> deployables = new ArrayList<>(); for (Contribution contribution : contributions) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof Composite)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, Composite> element = (ResourceElement<QNameSymbol, Composite>) entry; QName name = element.getSymbol().getKey(); Composite composite = element.getValue(); for (Deployable deployable : contribution.getManifest().getDeployables()) { if (deployable.getName().equals(name)) { List<RuntimeMode> deployableModes = deployable.getRuntimeModes(); // only add deployables that are set to boot in the current runtime mode and where the environment matches if (deployableModes.contains(hostInfo.getRuntimeMode())) { List<String> environments = deployable.getEnvironments(); if (environments.isEmpty() || environments.contains(hostInfo.getEnvironment())) { deployables.add(composite); } } break; } } } } } return deployables; }
public List<Composite> getDeployables(Set<Contribution> contributions) { List<Composite> deployables = new ArrayList<Composite>(); for (Contribution contribution : contributions) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof Composite)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, Composite> element = (ResourceElement<QNameSymbol, Composite>) entry; QName name = element.getSymbol().getKey(); Composite composite = element.getValue(); for (Deployable deployable : contribution.getManifest().getDeployables()) { if (deployable.getName().equals(name)) { List<RuntimeMode> deployableModes = deployable.getRuntimeModes(); // only add deployables that are set to boot in the current runtime mode and where the environment matches if (deployableModes.contains(hostInfo.getRuntimeMode())) { List<String> environments = deployable.getEnvironments(); if (environments.isEmpty() || environments.contains(hostInfo.getEnvironment())) { deployables.add(composite); } } break; } } } } } return deployables; }
public synchronized void undeploy(URI uri) throws Fabric3Exception { Contribution contribution = metadataStore.find(uri); if (contribution == null) { throw new Fabric3Exception("Contribution not found: " + uri); } List<Deployable> deployables = contribution.getManifest().getDeployables(); if (deployables.isEmpty()) { return; } LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); collector.markForCollection(uri, domain); Deployment deployment = generator.generate(domain); collector.collect(domain); deployer.deploy(deployment); contribution.undeploy(); }
public synchronized void undeploy(URI uri) throws Fabric3Exception { Contribution contribution = metadataStore.find(uri); if (contribution == null) { throw new Fabric3Exception("Contribution not found: " + uri); } List<Deployable> deployables = contribution.getManifest().getDeployables(); if (deployables.isEmpty()) { return; } LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); collector.markForCollection(uri, domain); Deployment deployment = generator.generate(domain); collector.collect(domain); deployer.deploy(deployment); contribution.undeploy(); }
throw new ContributionNotFoundException("Contribution not found: " + uri); List<Deployable> deployables = contribution.getManifest().getDeployables(); if (deployables.isEmpty()) { return;
public void onInstall(Contribution contribution) { String sourceUrl = contribution.getLocation().toString(); if (!sourceUrl.endsWith(".war")) { // not a WAR file return; } ContributionManifest manifest = contribution.getManifest(); if (!manifest.getDeployables().isEmpty()) { return; } for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getValue() instanceof Composite) { // a composite was defined, return; return; } } } // no composites were defined, synthesize one Composite composite = createComposite(contribution); Source source = contribution.getSource(); Resource resource = createResource(contribution, composite, source); contribution.addResource(resource); QName name = composite.getName(); Deployable deployable = new Deployable(name); manifest.addDeployable(deployable); }
throw new ContributionNotInstalledManagementException(e.getMessage()); for (Deployable deployable : contribution.getManifest().getDeployables()) { QName name = deployable.getName(); try {