private ClassLoaderModelBuilder createBuilderWithoutExportedPackages(ClassLoaderModel originalClassLoaderModel) { ClassLoaderModelBuilder classLoaderModelBuilder = new ClassLoaderModelBuilder() .dependingOn(originalClassLoaderModel.getDependencies()) .exportingPrivilegedPackages(originalClassLoaderModel.getPrivilegedExportedPackages(), originalClassLoaderModel.getPrivilegedArtifacts()) .exportingResources(originalClassLoaderModel.getExportedResources()); for (URL url : originalClassLoaderModel.getUrls()) { classLoaderModelBuilder.containing(url); } return classLoaderModelBuilder; }
private boolean isPlugin(BundleDependency dependency) { return dependency.getDescriptor().isPlugin(); }
@Override public T create(File artifactFolder, Optional<Properties> deploymentProperties) throws ArtifactDescriptorCreateException { final M artifactModel = createArtifactModel(artifactFolder); return createArtifact(artifactFolder, deploymentProperties, artifactModel); }
private ClassLoaderModel createClassLoaderModelWithDomain() { BundleDescriptor domainDescriptor = new BundleDescriptor.Builder().setArtifactId(DOMAIN_NAME).setGroupId("test") .setVersion("1.0.0").setClassifier(MULE_DOMAIN_CLASSIFIER).build(); Set<BundleDependency> domainDependency = Collections.singleton(new BundleDependency.Builder().setDescriptor(domainDescriptor).build()); return new ClassLoaderModel.ClassLoaderModelBuilder().dependingOn(domainDependency).build(); }
public static BundleDescriptor getDomainBundleDescriptor(String appName) { return new BundleDescriptor.Builder().setGroupId("test").setArtifactId(appName) .setVersion("1.0.0").setClassifier("mule-domain").build(); } }
private static boolean isResolvedDependency(BundleDescriptor availableBundleDescriptor, BundleDescriptor expectedBundleDescriptor) { return availableBundleDescriptor.getArtifactId().equals(expectedBundleDescriptor.getArtifactId()) && availableBundleDescriptor.getGroupId().equals(expectedBundleDescriptor.getGroupId()) && isCompatibleVersion(availableBundleDescriptor.getVersion(), expectedBundleDescriptor.getVersion()); }
protected M createArtifactModel(File artifactFolder) { final File artifactJsonFile = new File(artifactFolder, MULE_ARTIFACT_FOLDER + separator + getDescriptorFileName()); if (!artifactJsonFile.exists()) { throw new ArtifactDescriptorCreateException(ARTIFACT_DESCRIPTOR_DOES_NOT_EXISTS_ERROR + artifactJsonFile); } return loadModelFromJson(getDescriptorContent(artifactJsonFile)); }
/** * This is the version of the bundle. * * @param version the version of the bundle. Cannot be null or empty. * @return the builder */ public BundleDescriptor.Builder setVersion(String version) { validateIsNotEmpty(version, VERSION); bundleDependency.version = version; return this; }
/** * This is the descriptor of the bundle. * * @param descriptor the version of the bundle. Cannot be null or empty. * @return the builder */ public Builder setDescriptor(BundleDescriptor descriptor) { validateIsNotNull(descriptor, BUNDLE_DESCRIPTOR); this.bundleDependency.descriptor = descriptor; return this; }
/** * Sets a validation for minMuleVersion as {@link #validateMinMuleVersion()} but the validation should only consider * semantic version when checking the minMuleVersion vs Mule Runtime version. * * @return this */ public ArtifactDescriptorValidatorBuilder validateMinMuleVersionUsingSemanticVersion() { this.validateMinMuleVersion(); this.validateMinMuleVersionWithSemanticVersioning = true; return this; }
/** * Creates a new factory * * @param descriptorLoaderRepository contains all the {@link ClassLoaderModelLoader} registered on the container. Non null * @param artifactDescriptorValidatorBuilder {@link ArtifactDescriptorValidatorBuilder} to create the {@link ArtifactDescriptorValidator} in order to check the state of the descriptor once loaded. */ public ServiceDescriptorFactory(DescriptorLoaderRepository descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder artifactDescriptorValidatorBuilder) { super(descriptorLoaderRepository, artifactDescriptorValidatorBuilder.doNotFailIfBundleDescriptorNotPresentWhenValidationVersionFormat()); }
protected T createArtifact(File artifactFolder, Optional<Properties> deploymentProperties, M artifactModel) { T artifactDescriptor = loadFromJsonDescriptor(artifactFolder, artifactModel, deploymentProperties); return artifactDescriptor; }
/** * Allows to avoid checking version format for {@link ArtifactDescriptor} that don't have a {@link BundleDescriptor}. * * @return this */ public ArtifactDescriptorValidatorBuilder doNotFailIfBundleDescriptorNotPresentWhenValidationVersionFormat() { this.validateVersionFormat(); this.doNotFailIfBundleDescriptorNotPresent = true; return this; }
/** * Creates an instance of the builder. * * @return a new builder instance. */ public static ArtifactDescriptorValidatorBuilder builder() { return new ArtifactDescriptorValidatorBuilder(); }
/** * @return a {@code BundleDescriptor} with the previous provided parameters to the builder. */ public BundleDescriptor build() { validateIsNotEmpty(bundleDependency.groupId, GROUP_ID); validateIsNotEmpty(bundleDependency.artifactId, ARTIFACT_ID); validateIsNotEmpty(bundleDependency.version, VERSION); return this.bundleDependency; }
/** * @return a {@code BundleDescriptor} with the previous provided parameters to the builder. */ public BundleDependency build() { validateIsNotNull(bundleDependency.descriptor, BUNDLE_DESCRIPTOR); return this.bundleDependency; }
/** * Sets a validation for minMuleVersion as {@link #validateMinMuleVersion()} but the Mule Runtime version could * be provided as a supplier. Used by Tooling. * * @return this */ public ArtifactDescriptorValidatorBuilder validateMinMuleVersion(Supplier<String> muleRuntimeVersionSupplier) { this.validateMinMuleVersion(); this.muleRuntimeVersionSupplier = muleRuntimeVersionSupplier; return this; }
/** * @param artifactId the artifactId id of the bundle. Cannot be null or empty. * @return the builder */ public BundleDescriptor.Builder setArtifactId(String artifactId) { validateIsNotEmpty(artifactId, ARTIFACT_ID); bundleDependency.artifactId = artifactId; return this; }
/** * Sets the extension type of the bundle. * * @param type the type id of the bundle. Cannot be null or empty. * @return the builder */ public BundleDescriptor.Builder setType(String type) { validateIsNotEmpty(type, TYPE); bundleDependency.type = type; return this; }
/** * @param groupId the group id of the bundle. Cannot be null or empty. * @return the builder */ public BundleDescriptor.Builder setGroupId(String groupId) { validateIsNotEmpty(groupId, GROUP_ID); bundleDependency.groupId = groupId; return this; }