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; }
@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 index(Resource resource, IntrospectionContext context) throws InstallException { InputStream stream = null; try { Source source = resource.getSource(); stream = source.openStream(); // eagerly process the WSDL since port types need to be available during contribution processing. parse(resource, context); } catch (IOException e) { throw new InstallException(e); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e) { e.printStackTrace(); } } }
/** * 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 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 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 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); }
Source source = resource.getSource(); Definition definition = parseWsdl(source, context); QName wsdlQName = definition.getQName(); WsdlSymbol wsdlSymbol = new WsdlSymbol(wsdlQName); ResourceElement<WsdlSymbol, Definition> wsdlElement = new ResourceElement<>(wsdlSymbol, definition); resource.addResourceElement(wsdlElement); ServiceSymbol serviceSymbol = new ServiceSymbol(service.getQName()); ResourceElement<ServiceSymbol, Service> serviceElement = new ResourceElement<>(serviceSymbol, service); resource.addResourceElement(serviceElement); Map<String, Port> ports = service.getPorts(); for (Port port : ports.values()) { PortSymbol portSymbol = new PortSymbol(portName); ResourceElement<PortSymbol, Port> portElement = new ResourceElement<>(portSymbol, port); resource.addResourceElement(portElement); PortTypeSymbol symbol = new PortTypeSymbol(name); ResourceElement<PortTypeSymbol, PortType> element = new ResourceElement<>(symbol, portType); resource.addResourceElement(element); ResourceElement<WsdlServiceContractSymbol, WsdlServiceContract> element = new ResourceElement<>(symbol, contract); resource.addResourceElement(element); BindingSymbol bindingSymbol = new BindingSymbol(binding.getQName()); ResourceElement<BindingSymbol, Binding> serviceElement = new ResourceElement<>(bindingSymbol, binding); resource.addResourceElement(serviceElement);
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); }
Resource resource = new Resource(contribution, source, contentType); contribution.addResource(resource);
private boolean hasImplementation(Contribution contribution) { for (Resource resource : contribution.getResources()) { for (ResourceElement<?, ?> element : resource.getResourceElements()) { if (element.getSymbol() instanceof WebImplementationSymbol) { return true; } } } return false; }
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 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); }
Resource resource = new Resource(contribution, source, contentType); contribution.addResource(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 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); } } }
ResourceElement<QNameSymbol, AbstractDefinition> element = new ResourceElement<QNameSymbol, AbstractDefinition>(symbol); resource.addResourceElement(element); break; case XMLStreamConstants.END_DOCUMENT:
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); }
InputStream stream = null; try { stream = resource.getSource().openStream(); XMLStreamReader reader = xmlFactory.createXMLStreamReader(stream); while (true) {
/** * Creates an index entry in the given contribution for the web implementation. * * Only one web implementation can exist per web contribution. * * @param implementation the implementation * @param contribution the contribution */ public static void indexImplementation(WebImplementation implementation, Contribution contribution) { WebImplementationSymbol symbol = new WebImplementationSymbol(); ResourceElement<WebImplementationSymbol, WebImplementation> element = new ResourceElement<>(symbol, implementation); Resource resource = new Resource(contribution, null, "webimpl"); resource.addResourceElement(element); contribution.addResource(resource); resource.setState(ResourceState.PROCESSED); } }