private URI createWebUri(Contribution contribution) { String context = contribution.getManifest().getContext(); if (context != null) { return URI.create(context); } return contribution.getUri(); }
public Resource inspect(Class<?> clazz, URL url, Contribution contribution, IntrospectionContext context) { String sourceUrl = contribution.getLocation().toString(); if (!sourceUrl.endsWith(".war")) { // not a WAR file return null; } if (contribution.getManifest().isExtension()) { return null; } if (!Servlet.class.isAssignableFrom(clazz) && !Filter.class.isAssignableFrom(clazz)) { // skip classes that are not servlets or filters return null; } return introspect(clazz, contribution, context); }
public List<URL> process(Contribution contribution) throws Fabric3Exception { URL url = contribution.getLocation(); List<Library> libraries = contribution.getManifest().getLibraries(); List<URL> classpath = new ArrayList<>(); // add the the jar itself to the classpath classpath.add(url); if (libraries.isEmpty() && !hasLibDirectory(new File(url.getFile()), "lib") && !hasLibDirectory(new File(url.getFile()), "classes")) { return classpath; } try { // add libraries from the jar addLibraries(classpath, url); } catch (IOException e) { throw new Fabric3Exception(e); } return classpath; }
public List<URL> process(Contribution contribution) throws Fabric3Exception { URL url = contribution.getLocation(); List<Library> libraries = contribution.getManifest().getLibraries(); List<URL> classpath = new ArrayList<>(); // add the the jar itself to the classpath classpath.add(url); if (libraries.isEmpty() && !hasLibDirectory(new File(url.getFile()), "lib") && !hasLibDirectory(new File(url.getFile()), "classes")) { return classpath; } try { // add libraries from the jar addLibraries(classpath, url); } catch (IOException e) { throw new Fabric3Exception(e); } return classpath; }
public void releaseLocks(Set<Contribution> contributions) { for (Contribution contribution : contributions) { for (Deployable deployable : contribution.getManifest().getDeployables()) { QName name = deployable.getName(); if (contribution.getLockOwners().contains(name)) { contribution.releaseLock(name); } } } }
public void lock(Set<Contribution> contributions) throws CompositeAlreadyDeployedException { for (Contribution contribution : contributions) { for (Deployable deployable : contribution.getManifest().getDeployables()) { QName name = deployable.getName(); // check if the deployable has already been deployed by querying the lock owners if (contribution.getLockOwners().contains(name)) { throw new CompositeAlreadyDeployedException("Composite has already been deployed: " + name); } contribution.acquireLock(name); } } }
public void onProcessManifest(Contribution contribution) { if (contribution.getManifest().isExtension()) { boolean sunImported = false; ContributionManifest manifest = contribution.getManifest(); for (Import imprt : manifest.getImports()) { if (imprt instanceof JavaImport) {
public void onProcessManifest(Contribution contribution) { if (contribution.getManifest().isExtension()) { boolean sunImported = false; ContributionManifest manifest = contribution.getManifest(); for (Import imprt : manifest.getImports()) { if (imprt instanceof JavaImport) {
private PhysicalClassLoaderDefinition createClassLoaderDefinition(Contribution contribution) { URI uri = contribution.getUri(); if (Names.BOOT_CONTRIBUTION.equals(uri) || Names.HOST_CONTRIBUTION.equals(uri)) { return null; } boolean provisionArtifact = contribution.getLocation() != null; // don't provision synthetic artifacts; List<Library> libraries = contribution.getManifest().getLibraries(); PhysicalClassLoaderDefinition definition = new PhysicalClassLoaderDefinition(uri, libraries, provisionArtifact); List<ContributionWire<?, ?>> contributionWires = contribution.getWires(); for (ContributionWire<?, ?> wire : contributionWires) { ClassLoaderWireGenerator generator = generators.get(wire.getClass()); if (generator == null) { // not all contribution wires resolve resources through classloaders, so skip if one is not found continue; } PhysicalClassLoaderWireDefinition wireDefinition = generator.generate(wire); definition.add(wireDefinition); } return definition; }
@ManagementOperation(description = "Returns metadata for all contributions deployed in a domain") public Set<ContributionInfo> getContributions() { Set<Contribution> contributions = metaDataStore.getContributions(); Set<ContributionInfo> infos = new TreeSet<ContributionInfo>(); for (Contribution contribution : contributions) { URI uri = contribution.getUri(); String state = contribution.getState().toString(); long timestamp = contribution.getTimestamp(); List<QName> deployables = new ArrayList<QName>(); for (Deployable deployable : contribution.getManifest().getDeployables()) { deployables.add(deployable.getName()); } ContributionInfo info = new ContributionInfo(uri, state, deployables, timestamp); infos.add(info); } return infos; }
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; }
public void onProcessManifest(Contribution contribution) { ContributionManifest manifest = contribution.getManifest(); if (manifest.isExtension()) { // extensions should manually enable JAXB return; } manifest.addImport(jaxbImport); manifest.addImport(iStackImport); manifest.addImport(xsomImport); manifest.addImport(txw2Import); manifest.addImport(dtdParserImport); manifest.addImport(utilImport); }
public synchronized void undeploy(URI uri) throws Fabric3Exception { Contribution contribution = metadataStore.find(uri); if (contribution == null) { throw new Fabric3Exception("Contribution not found: " + uri); } List<Deployable> deployables = contribution.getManifest().getDeployables(); if (deployables.isEmpty()) { return; } LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); collector.markForCollection(uri, domain); Deployment deployment = generator.generate(domain); collector.collect(domain); deployer.deploy(deployment); contribution.undeploy(); }
public synchronized void undeploy(URI uri) throws Fabric3Exception { Contribution contribution = metadataStore.find(uri); if (contribution == null) { throw new Fabric3Exception("Contribution not found: " + uri); } List<Deployable> deployables = contribution.getManifest().getDeployables(); if (deployables.isEmpty()) { return; } LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); collector.markForCollection(uri, domain); Deployment deployment = generator.generate(domain); collector.collect(domain); deployer.deploy(deployment); contribution.undeploy(); }
public void onProcessManifest(Contribution contribution) { ContributionManifest manifest = contribution.getManifest(); if (manifest.isExtension()) { // extensions should manually enable JAXB return; } manifest.addImport(jaxbImport); manifest.addImport(iStackImport); manifest.addImport(xsomImport); manifest.addImport(txw2Import); manifest.addImport(dtdParserImport); manifest.addImport(utilImport); }
public void onProcessManifest(Contribution contribution) { ContributionManifest manifest = contribution.getManifest(); if (manifest.isExtension()) { // extensions should manually enable JAXB return; } manifest.addImport(jaxbImport); manifest.addImport(iStackImport); manifest.addImport(xsomImport); manifest.addImport(txw2Import); manifest.addImport(dtdParserImport); manifest.addImport(utilImport); }
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); }
Contribution contribution = new Contribution(contributionUri); contribution.setState(ContributionState.INSTALLED); ContributionManifest manifest = contribution.getManifest(); manifest.setExtension(extension);
public void onInstall(Contribution contribution) { if (!isWar(contribution)) { return; } if (hasImplementation(contribution)) { return; // web component was explicitly configured in the contribution } // synthesize a web implementation URI uri = createWebUri(contribution); WebImplementation implementation = new WebImplementation(uri); // retrieve the component type introspected during contribution indexing or create one if no web artifacts resulted in it being generated WebComponentType componentType = getComponentType(contribution); implementation.setComponentType(componentType); // synthesize a deployable composite IndexHelper.indexImplementation(implementation, contribution); Composite composite = createComposite(implementation, contribution); contribution.getManifest().addDeployable(new Deployable(composite.getName())); contribution.addResource(createResource(contribution, composite)); }