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; }
private boolean hasImplementation(Contribution contribution) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WebImplementationSymbol) { return true; } } } return false; }
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); } } }
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(); }
/** * 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(); }
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; }
/** * 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 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; }
Set<PolicySet> attachedPolicySets = new HashSet<PolicySet>(); for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> resourceElement : resource.getResourceElements()) { Object value = resourceElement.getValue(); if (value instanceof Intent) {
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 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); }
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); } }
for (ResourceElement element : resource.getResourceElements()) { Symbol candidateSymbol = new QNameSymbol(candidate.getName()); if (element.getSymbol().equals(candidateSymbol)) {
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 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); } }
@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 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); }