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); } } }
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(); }
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 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(); }
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 Set<PolicySet> deactivateDefinitions(URI uri) throws PolicyActivationException { Set<PolicySet> policySets = new HashSet<PolicySet>(); Contribution contribution = metaDataStore.find(uri); for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> resourceElement : resource.getResourceElements()) { Object value = resourceElement.getValue(); if (value instanceof AbstractPolicyDefinition) { AbstractPolicyDefinition definition = (AbstractPolicyDefinition) value; deactivate(definition); if (definition instanceof PolicySet) { PolicySet policySet = (PolicySet) definition; if (policySet.getAttachTo() != null) { policySets.add(policySet); } } } } } return policySets; }
/** * Returns the web component type created during index of Java artifacts or creates one if necessary (i.e. no artifacts generated component type metadata). * * @param contribution the current contribution * @return the web component type */ 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(); }
@SuppressWarnings({"unchecked"}) public Definition resolveWsdl(URI contributionUri, QName wsdlName) throws WsdlResolutionException { WsdlSymbol symbol = new WsdlSymbol(wsdlName); try { ResourceElement<WsdlSymbol, Definition> element = store.find(contributionUri, Definition.class, symbol); if (element == null) { throw new WsdlResolutionException("WSDL not found: " + wsdlName); } return element.getValue(); } catch (StoreException e) { throw new WsdlResolutionException(e); } }
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); }
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); }
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 resolveLocalCallbackContract(QName callbackPortTypeName, WsdlServiceContract contract, Resource resource, IntrospectionContext context) { WsdlServiceContractSymbol symbol = new WsdlServiceContractSymbol(callbackPortTypeName); for (ResourceElement<?, ?> resourceElement : resource.getResourceElements()) { if (resourceElement.getSymbol().equals(symbol)) { WsdlServiceContract callbackContract = (WsdlServiceContract) resourceElement.getValue(); contract.setCallbackContract(callbackContract); break; } } if (contract.getCallbackContract() == null) { PortTypeNotFound error = new PortTypeNotFound("Callback port type not found: " + callbackPortTypeName); context.addError(error); } }
private WsdlServiceContract resolveContract(QName portTypeName, XMLStreamReader reader, IntrospectionContext context) { Location startLocation = reader.getLocation(); WsdlServiceContractSymbol symbol = new WsdlServiceContractSymbol(portTypeName); URI contributionUri = context.getContributionUri(); ResourceElement<WsdlServiceContractSymbol, WsdlServiceContract> element; try { element = store.resolve(contributionUri, WsdlServiceContract.class, symbol, context); } catch (StoreException e) { ElementLoadFailure failure = new ElementLoadFailure("Error loading element", e, startLocation); context.addError(failure); return new WsdlServiceContract(null, null); } if (element == null) { PortTypeNotFound error = new PortTypeNotFound("Port type not found: " + portTypeName); context.addError(error); return new WsdlServiceContract(null, null); } WsdlServiceContract contract = element.getValue(); // return a copy as it may be modified return contract.copy(); }
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 validate(URI contributionUri, LogicalBinding<WsBindingDefinition> binding, AbstractEndpointDefinition endpointDefinition) throws EndpointValidationException { if (!enabled) { return; } try { ServiceContract otherContract = binding.getParent().getServiceContract(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(); PortSymbol portSymbol = new PortSymbol(endpointDefinition.getPortName()); QName name = store.resolve(contributionUri, Port.class, portSymbol, context).getValue().getBinding().getPortType().getQName(); WsdlServiceContractSymbol contractSymbol = new WsdlServiceContractSymbol(name); WsdlServiceContract contract = store.resolve(contributionUri, WsdlServiceContract.class, contractSymbol, context).getValue(); MatchResult result = matcher.isAssignableFrom(contract, otherContract, true); if (!result.isAssignable()) { throw new EndpointValidationException(result.getError()); } } catch (StoreException e) { throw new EndpointValidationException(e); } }
private void resolveExternalCallbackContract(QName callbackPortTypeName, WsdlServiceContract contract, IntrospectionContext context) { WsdlServiceContractSymbol symbol = new WsdlServiceContractSymbol(callbackPortTypeName); URI contributionUri = context.getContributionUri(); ResourceElement<WsdlServiceContractSymbol, WsdlServiceContract> resolved; try { resolved = store.resolve(contributionUri, WsdlServiceContract.class, symbol, context); } catch (StoreException e) { CallbackContractLoadError error = new CallbackContractLoadError("Error resolving callback port type:" + callbackPortTypeName, e); context.addError(error); return; } if (resolved == null) { PortTypeNotFound error = new PortTypeNotFound("Callback port type not found: " + callbackPortTypeName); context.addError(error); return; } WsdlServiceContract callbackContract = resolved.getValue(); contract.setCallbackContract(callbackContract); }
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 Definition resolveWsdlByBindingName(URI contributionUri, QName bindingName) throws WsdlResolutionException { BindingSymbol symbol = new BindingSymbol(bindingName); ResourceElement<BindingSymbol, Binding> resourceElement; try { resourceElement = store.find(contributionUri, Binding.class, symbol); } catch (StoreException e) { throw new WsdlResolutionException("Error resolving binding: " + bindingName, e); } if (resourceElement == null) { throw new WsdlResolutionException("WSDL binding not found: " + bindingName); } Resource resource = resourceElement.getResource(); for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WsdlSymbol) { return (Definition) element.getValue(); } } throw new WsdlResolutionException("WSDL for binding not found: " + bindingName); } }
public void process(Resource resource, IntrospectionContext context) throws InstallException { Definition definition = resolveLocalWsdl(resource); // Process callbacks here (as opposed to eagerly in #index(..) since the SCA callback attribute may reference a portType in another document. // Processing at this point guarantees the callback portType will be indexed and referenceable. for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WsdlServiceContractSymbol) { WsdlServiceContract contract = (WsdlServiceContract) element.getValue(); PortType portType = contract.getPortType(); QName callbackPortTypeName = (QName) portType.getExtensionAttribute(CALLBACK_ATTRIBUTE); if (callbackPortTypeName != null) { PortType callbackPortType = definition.getPortType(callbackPortTypeName); if (callbackPortType != null) { resolveLocalCallbackContract(callbackPortTypeName, contract, resource, context); } else { resolveExternalCallbackContract(callbackPortTypeName, contract, context); } } } } resource.setState(ResourceState.PROCESSED); }
public Resource introspect(Class<?> clazz, Contribution contribution, IntrospectionContext context) { ResourceElement<WebComponentTypeSymbol, WebComponentType> element = getTypeElement(contribution); WebComponentType componentType = element.getValue(); // introspect the class and generate a component type that will be merged into the web component type WebArtifactImplementation artifactImpl = new WebArtifactImplementation(); InjectingComponentType tempType = new InjectingComponentType(clazz); artifactImpl.setComponentType(tempType); TypeMapping mapping = context.getTypeMapping(clazz); if (mapping == null) { mapping = new TypeMapping(); context.addTypeMapping(clazz, mapping); helper.resolveTypeParameters(clazz, mapping); } classVisitor.visit(tempType, clazz, context); mergeComponentTypes(componentType, tempType, context); return element.getResource(); }