public DeploymentPlan findPlan(String plan) throws DeploymentException { QName planName = new QName(PLAN_NAMESPACE, plan); QNameSymbol symbol = new QNameSymbol(planName); ResourceElement<QNameSymbol, DeploymentPlan> element = metadataStore.find(DeploymentPlan.class, symbol); if (element == null) { return null; } return element.getValue(); }
public void index(Resource resource, XMLStreamReader reader, IntrospectionContext context) throws InstallException { QName qname = reader.getName(); assert PLAN.equals(qname); String name = reader.getAttributeValue(null, "name"); if (name == null) { context.addError(new MissingAttribute("Deployment plan name not specified", reader)); return; } QName planQName = new QName(PLAN_NAMESPACE, name); QNameSymbol symbol = new QNameSymbol(planQName); ResourceElement<QNameSymbol, DeploymentPlan> element = new ResourceElement<QNameSymbol, DeploymentPlan>(symbol); resource.addResourceElement(element); }
public Composite findComposite(QName deployable) throws DeploymentException { QNameSymbol symbol = new QNameSymbol(deployable); ResourceElement<QNameSymbol, Composite> element = metadataStore.find(Composite.class, symbol); if (element == null) { String id = deployable.toString(); throw new DeployableNotFoundException("Deployable not found: " + id, id); } return element.getValue(); }
public void index(Resource resource, XMLStreamReader reader, IntrospectionContext context) { QNameSymbol symbol = new QNameSymbol(qname); WebXml webXml = new WebXml(); ResourceElement<QNameSymbol, WebXml> element = new ResourceElement<QNameSymbol, WebXml>(symbol, webXml); resource.addResourceElement(element); }
QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, AbstractDefinition> element = new ResourceElement<QNameSymbol, AbstractDefinition>(symbol);
public DeploymentPlan findDefaultPlan(QName deployable) { // default to first found deployment plan in a contribution if one is not specifed for a distributed deployment QNameSymbol symbol = new QNameSymbol(deployable); Contribution contribution = metadataStore.find(Composite.class, symbol).getResource().getContribution(); return findDefaultPlan(contribution); }
public void undeploy(QName name) throws Fabric3Exception { QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metaDataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Component not deployed: " + name); } Composite composite = element.getValue(); domain.undeploy(composite); Resource resource = element.getResource(); Contribution contribution = resource.getContribution(); contribution.getResources().remove(resource); }
private Resource createResource(Contribution contribution, Composite composite) { QNameSymbol symbol = new QNameSymbol(composite.getName()); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, composite); Resource resource = new Resource(contribution, null, Constants.COMPOSITE_CONTENT_TYPE); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); return resource; }
private Resource createResource(Contribution contribution, Composite composite, Source source) { QNameSymbol symbol = new QNameSymbol(composite.getName()); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<QNameSymbol, Composite>(symbol, composite); Resource resource = new Resource(contribution, source, Constants.COMPOSITE_CONTENT_TYPE); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); return resource; }
public void undeploy(QName name) throws Fabric3Exception { QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metaDataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Component not deployed: " + name); } Composite composite = element.getValue(); domain.undeploy(composite); Resource resource = element.getResource(); Contribution contribution = resource.getContribution(); contribution.getResources().remove(resource); }
/** * Updates the deployment plan ResourceElement with the parsed DeploymentPlan. * * @param resource the plan resource to update * @param plan the deployment plan */ private void updatePlan(Resource resource, DeploymentPlan plan) { String name = plan.getName(); QName planQName = new QName(PLAN_NAMESPACE, name); QNameSymbol symbol = new QNameSymbol(planQName); boolean found = false; for (ResourceElement element : resource.getResourceElements()) { if (element.getSymbol().equals(symbol)) { element.setValue(plan); found = true; break; } } if (!found) { // this is a programming error if this happens as the indexer did not set the resource element properly throw new AssertionError("Deployment plan not found: " + name); } resource.setProcessed(true); }
public void undeploy(QName name) throws DeploymentException { try { QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metaDataStore.find(Composite.class, symbol); if (element == null) { throw new DeploymentException("Component not deployed: " + name); } Composite composite = element.getValue(); domain.undeploy(composite, false); Resource resource = element.getResource(); Contribution contribution = resource.getContribution(); contribution.getResources().remove(resource); } catch (org.fabric3.api.host.domain.DeploymentException e) { throw new DeploymentException(e); } }
private void addCompositeToContribution(Composite wrapper) { QName compositeName = wrapper.getName(); URI uri = ContributionResolver.getContribution(); Contribution contribution = metaDataStore.find(uri); Resource resource = new Resource(contribution, null, Constants.COMPOSITE_CONTENT_TYPE); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, wrapper); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
private void addCompositeToContribution(Composite wrapper) { QName compositeName = wrapper.getName(); URI uri = ContributionResolver.getContribution(); Contribution contribution = metaDataStore.find(uri); Resource resource = new Resource(contribution, null, Constants.COMPOSITE_CONTENT_TYPE); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, wrapper); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
private void addCompositeToContribution(Composite wrapper) { QName compositeName = wrapper.getName(); URI uri = ContributionResolver.getContribution(); Contribution contribution = metaDataStore.find(uri); Resource resource = new Resource(contribution, null, Constants.COMPOSITE_CONTENT_TYPE); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, wrapper); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
/** * Adds the composite as a resource to the contribution. * * @param contribution the contribution * @param composite the composite */ private static void addResource(Contribution contribution, Composite composite) { Source source = new UrlSource(COMPOSITE_URL); Resource resource = new Resource(contribution, source, Constants.COMPOSITE_CONTENT_TYPE); QName compositeName = composite.getName(); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, composite); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
/** * Adds the composite as a resource to the contribution. * * @param contribution the contribution * @param composite the composite */ private static void addResource(Contribution contribution, Composite composite) { Source source = new UrlSource(COMPOSITE_URL); Resource resource = new Resource(contribution, source, Constants.COMPOSITE_CONTENT_TYPE); QName compositeName = composite.getName(); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<>(symbol, composite); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
/** * Adds the composite as a resource to the contribution. * * @param contribution the contribution * @param composite the composite * @param scdlLocation the location of the composite file */ private static void addResource(Contribution contribution, Composite composite, URL scdlLocation) { Source source = new UrlSource(scdlLocation); Resource resource = new Resource(contribution, source, Constants.COMPOSITE_CONTENT_TYPE); QName compositeName = composite.getName(); QNameSymbol symbol = new QNameSymbol(compositeName); ResourceElement<QNameSymbol, Composite> element = new ResourceElement<QNameSymbol, Composite>(symbol, composite); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); }
/** * Instantiates and deploys the given composite. * * @param composite the composite to instantiate and deploy * @throws Fabric3Exception if a deployment error occurs */ private void instantiateAndDeploy(Composite composite) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); QName name = composite.getName(); QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metadataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Composite not found in metadata store: " + name); } Contribution contribution = element.getResource().getContribution(); if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } InstantiationContext context = logicalModelInstantiator.include(composite, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } deploy(domain); contribution.deploy(); }
/** * Instantiates and deploys the given composite. * * @param composite the composite to instantiate and deploy * @throws Fabric3Exception if a deployment error occurs */ private void instantiateAndDeploy(Composite composite) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); QName name = composite.getName(); QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metadataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Composite not found in metadata store: " + name); } Contribution contribution = element.getResource().getContribution(); if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } InstantiationContext context = logicalModelInstantiator.include(composite, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } deploy(domain); contribution.deploy(); }