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); }
private Definition resolveLocalWsdl(Resource resource) { Definition definition = null; for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WsdlSymbol) { definition = (Definition) element.getValue(); break; } } if (definition == null) { // should not happen throw new AssertionError("WSDL document not found"); } return definition; }
public Definition resolveWsdlByPortName(URI contributionUri, QName portName) throws WsdlResolutionException { PortSymbol symbol = new PortSymbol(portName); ResourceElement<PortSymbol, Port> resourceElement; try { resourceElement = store.find(contributionUri, Port.class, symbol); } catch (StoreException e) { throw new WsdlResolutionException("Error resolving port: " + portName, e); } if (resourceElement == null) { throw new WsdlResolutionException("WSDL port not found: " + portName); } Resource resource = resourceElement.getResource(); for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WsdlSymbol) { return (Definition) element.getValue(); } } throw new WsdlResolutionException("WSDL for port not found: " + portName); }
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 void getDeploymentPlans(Contribution contribution, List<DeploymentPlan> plans) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> entry : resource.getResourceElements()) { if (!(entry.getValue() instanceof DeploymentPlan)) { continue; } @SuppressWarnings({"unchecked"}) ResourceElement<QNameSymbol, DeploymentPlan> element = (ResourceElement<QNameSymbol, DeploymentPlan>) entry; DeploymentPlan plan = element.getValue(); plans.add(plan); } } }
@SuppressWarnings("unchecked") private ResourceElement<WebComponentTypeSymbol, WebComponentType> getTypeElement(Contribution contribution) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WebComponentTypeSymbol) { return (ResourceElement<WebComponentTypeSymbol, WebComponentType>) element; } } } WebComponentType componentType = new WebComponentType(); WebComponentTypeSymbol symbol = new WebComponentTypeSymbol(); ResourceElement<WebComponentTypeSymbol, WebComponentType> element = new ResourceElement<>(symbol, componentType); Resource resource = new Resource(contribution, null, "web"); resource.addResourceElement(element); resource.setState(ResourceState.PROCESSED); contribution.addResource(resource); return element; }
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); }
/** * 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); }
private boolean hasImplementation(Contribution contribution) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WebImplementationSymbol) { return true; } } } return false; }
/** * Adds a resource element. * * @param element the resourceElement */ public void addResourceElement(ResourceElement<?, ?> element) { elements.add(element); element.setResource(this); }
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 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); }
return artifacts; Resource resource = resourceElement.getResource(); InputStream stream = null; try {
private WebComponentType getComponentType(Contribution contribution) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WebComponentTypeSymbol) { return (WebComponentType) element.getValue(); } } } return new WebComponentType(); }
public Definition resolveWsdlByServiceName(URI contributionUri, QName serviceName) throws WsdlResolutionException { ServiceSymbol symbol = new ServiceSymbol(serviceName); ResourceElement<ServiceSymbol, Service> resourceElement; try { resourceElement = store.find(contributionUri, Service.class, symbol); } catch (StoreException e) { throw new WsdlResolutionException("Error resolving service: " + serviceName, e); } if (resourceElement == null) { throw new WsdlResolutionException("WSDL service not found: " + serviceName); } Resource resource = resourceElement.getResource(); for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WsdlSymbol) { return (Definition) element.getValue(); } } throw new WsdlResolutionException("WSDL for service not found: " + serviceName); }
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); }
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 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); } }
+ ". The domain journal (domain.xml) may be out of sync."); Contribution contribution = element.getResource().getContribution(); if (contribution == null) {