本文整理汇总了Java中org.springframework.cloud.deployer.resource.maven.MavenResource类的典型用法代码示例。如果您正苦于以下问题:Java MavenResource类的具体用法?Java MavenResource怎么用?Java MavenResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MavenResource类属于org.springframework.cloud.deployer.resource.maven包,在下文中一共展示了MavenResource类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testApplication
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
/**
* Return a resource corresponding to the spring-cloud-deployer-spi-test-app app suitable for the target runtime.
*
* The default implementation returns an uber-jar fetched via Maven. Subclasses may override.
*/
protected Resource testApplication() {
Properties properties = new Properties();
try {
properties.load(new ClassPathResource("integration-test-app.properties").getInputStream());
}
catch (IOException e) {
throw new RuntimeException("Failed to determine which version of spring-cloud-deployer-spi-test-app to use", e);
}
return new MavenResource.Builder(mavenProperties)
.groupId("org.springframework.cloud")
.artifactId("spring-cloud-deployer-spi-test-app")
.classifier("exec")
.version(properties.getProperty("version"))
.extension("jar")
.build();
}
示例2: getResourceVersion
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
/**
* Extracts the version from the resource. Supported resource types are {@link
* MavenResource}, {@link DockerResource}, and {@link UrlResource}. @param resource to be
* used. @return the version the resource. @throws
*/
public static String getResourceVersion(Resource resource) {
Assert.notNull(resource, "resource must not be null");
if (resource instanceof MavenResource) {
MavenResource mavenResource = (MavenResource) resource;
return mavenResource.getVersion();
}
else if (resource instanceof DockerResource) {
DockerResource dockerResource = (DockerResource) resource;
return formatDockerResource(dockerResource, (s, i) -> s.substring(i + 1, s.length()));
}
else if (resource instanceof UrlResource) {
return getUrlResourceVersion((UrlResource) resource);
}
else {
throw new IllegalArgumentException("Do not support extracting resource from Resource of type "
+ resource.getClass().getSimpleName());
}
}
示例3: getResourceWithoutVersion
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
/**
* Extracts the string representing the resource with the version number extracted.
* @param resource to be used.
* @return String representation of the resource.
*/
public static String getResourceWithoutVersion(Resource resource) {
Assert.notNull(resource, "resource must not be null");
if (resource instanceof MavenResource) {
MavenResource mavenResource = (MavenResource) resource;
return String.format("maven://%s:%s",
mavenResource.getGroupId(),
mavenResource.getArtifactId());
}
else if (resource instanceof DockerResource) {
DockerResource dockerResource = (DockerResource) resource;
return formatDockerResource(dockerResource, (s, i) -> s.substring(0, i));
}
else if (resource instanceof UrlResource) {
return getUrlResourceWithoutVersion((UrlResource) resource);
}
else {
throw new IllegalArgumentException("Do not support extracting resource from Resource of type "
+ resource.getClass().getSimpleName());
}
}
示例4: getResource
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
/**
* Retrieve the corresponding {@link Resource} instance based on the URI String.
* Maven properties are used if the URI corresponds to maven resource.
*
* @param uriString String representation of the resource URI
* @param mavenProperties the maven properties to use in case of maven resource
* @return the resource instance
*/
public static Resource getResource(String uriString, MavenProperties mavenProperties) {
Assert.isTrue(StringUtils.hasText(uriString), "Resource URI must not be empty");
try {
URI uri = new URI(uriString);
String scheme = uri.getScheme();
Assert.notNull(scheme, "a scheme (prefix) is required");
if (scheme.equals("maven")) {
String coordinates = uriString.replaceFirst("maven:\\/*", "");
MavenResource mavenResource = MavenResource.parse(coordinates, mavenProperties);
return mavenResource;
}
else if (scheme.equals("docker")) {
String dockerUri = uriString.replaceFirst("docker:\\/*", "");
return new DockerResource(dockerUri);
}
else {
ResourceLoader resourceLoader = null;
if (!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) {
resourceLoader = new DefaultResourceLoader();
}
else {
resourceLoader = new DownloadingUrlResourceLoader();
}
return resourceLoader.getResource(uriString);
}
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
示例5: testMavenResourceProcessing
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
@Test
public void testMavenResourceProcessing() {
MavenResource mavenResource = new MavenResource.Builder()
.artifactId("timestamp-task")
.groupId("org.springframework.cloud.task.app")
.version("1.0.0.RELEASE")
.build();
String resourceWithoutVersion = ResourceUtils.getResourceWithoutVersion(mavenResource);
assertThat(resourceWithoutVersion).isEqualTo("maven://org.springframework.cloud.task.app:timestamp-task");
assertThat(ResourceUtils.getResourceVersion(mavenResource)).isEqualTo("1.0.0.RELEASE");
}
示例6: testAppRegisteredOnStreamDeploy
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
private void testAppRegisteredOnStreamDeploy(AppRegistryService appRegistryService) {
HashMap<String, String> timeAppProps = new HashMap<>();
timeAppProps.put("spring.cloud.dataflow.stream.app.type", "source");
AppDefinition timeAppDefinition = new AppDefinition("time", timeAppProps);
MavenResource timeResource = new MavenResource.Builder()
.artifactId("time-source-rabbit").groupId("org.springframework.cloud.stream.app")
.version("1.2.0.RELEASE").build();
AppDeploymentRequest timeAppDeploymentRequest = new AppDeploymentRequest(timeAppDefinition, timeResource);
HashMap<String, String> logAppProps = new HashMap<>();
logAppProps.put("spring.cloud.dataflow.stream.app.type", "sink");
AppDefinition logAppDefinition = new AppDefinition("log", logAppProps);
MavenResource logResource = new MavenResource.Builder()
.artifactId("log-sink-rabbit").groupId("org.springframework.cloud.stream.app")
.version("1.2.0.RELEASE").build();
AppDeploymentRequest logAppDeploymentRequest = new AppDeploymentRequest(logAppDefinition, logResource);
List<AppDeploymentRequest> appDeploymentRequests = Arrays.asList(logAppDeploymentRequest, timeAppDeploymentRequest);
Map<String, String> skipperDeployerProperties = new HashMap<>();
skipperDeployerProperties.put(SKIPPER_PACKAGE_NAME, "package1");
skipperDeployerProperties.put(SKIPPER_PACKAGE_VERSION, "1.0.1");
skipperDeployerProperties.put(SKIPPER_PLATFORM_NAME, "platform1");
skipperDeployerProperties.put(SKIPPER_REPO_NAME, "mylocal-repo1");
StreamDeploymentRequest streamDeploymentRequest = new StreamDeploymentRequest("test1", "time | log",
appDeploymentRequests, skipperDeployerProperties);
SkipperClient skipperClient = mock(SkipperClient.class);
SkipperStreamDeployer skipperStreamDeployer = new SkipperStreamDeployer(skipperClient,
mock(StreamDefinitionRepository.class),
appRegistryService, mock(ForkJoinPool.class));
skipperStreamDeployer.deployStream(streamDeploymentRequest);
}
示例7: testDestinationsOnBothSides
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
@Test
public void testDestinationsOnBothSides() throws Exception {
assertEquals(0, repository.count());
String definition = ":bar > filter > :foo";
AppStatus status = mock(AppStatus.class);
when(status.getState()).thenReturn(DeploymentState.unknown);
when(appDeployer.status("testID")).thenReturn(status);
mockMvc.perform(post("/streams/definitions/").param("name", "myStream").param("definition", definition)
.param("deploy", "true").accept(MediaType.APPLICATION_JSON)).andDo(print())
.andExpect(status().isCreated());
assertEquals(1, repository.count());
StreamDefinition myStream = repository.findOne("myStream");
assertEquals(definition, myStream.getDslText());
assertEquals("myStream", myStream.getName());
assertEquals(1, myStream.getAppDefinitions().size());
StreamAppDefinition filterDefinition = myStream.getAppDefinitions().get(0);
assertEquals(3, filterDefinition.getProperties().size());
assertEquals("bar", filterDefinition.getProperties().get(BindingPropertyKeys.INPUT_DESTINATION));
assertEquals("myStream", filterDefinition.getProperties().get(BindingPropertyKeys.INPUT_GROUP));
assertEquals("foo", filterDefinition.getProperties().get(BindingPropertyKeys.OUTPUT_DESTINATION));
ArgumentCaptor<AppDeploymentRequest> captor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(appDeployer).deploy(captor.capture());
AppDeploymentRequest request = captor.getValue();
assertThat(request.getDefinition().getName(), is("filter"));
assertThat(request.getResource(), instanceOf(MavenResource.class));
assertThat(((MavenResource) request.getResource()).getArtifactId(), is("filter-processor-rabbit"));
}
示例8: testGetResource
import org.springframework.cloud.deployer.resource.maven.MavenResource; //导入依赖的package包/类
@Test
public void testGetResource() {
String mavenUri = "maven://org.springframework.cloud.stream.app:aggregate-counter-sink-rabbit:1.3.0.RELEASE";
Resource resource = ResourceUtils.getResource(mavenUri, new MavenProperties());
assertThat(resource).isInstanceOf(MavenResource.class);
}