Java tutorial
/* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.curly.artifact; import io.curly.artifact.model.Artifact; import io.curly.artifact.model.Category; import io.curly.artifact.model.Language; import io.curly.artifact.model.Tag; import io.curly.commons.config.cache.annotation.EnableRedisCache; import io.curly.commons.config.context.EnableWorkQueueExecutor; import io.curly.commons.github.GitHubResolverConfigurerAdapter; import io.curly.commons.logging.annotation.config.EnableLoggable; import io.curly.commons.mongo.PrincipalAuditorAware; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.context.annotation.Bean; import org.springframework.data.mongodb.core.MongoTemplate; import java.time.LocalDate; import java.util.HashSet; import java.util.Set; /** * @author Joo Pedro Evangelista * @since 25/04/15 */ @RibbonClient("artifactory") @EnableFeignClients @EnableLoggable @EnableWorkQueueExecutor @EnableRedisCache @EnableDiscoveryClient @EnableCircuitBreaker @SpringBootApplication public class ArtifactoryApplication extends GitHubResolverConfigurerAdapter { public static void main(String[] args) { SpringApplication.run(ArtifactoryApplication.class, args); } @Bean PrincipalAuditorAware auditorAware() { return new PrincipalAuditorAware(); } @Bean CommandLineRunner commandLineRunner(MongoTemplate mongoTemplate) { return args -> { Artifact artifact = new Artifact(); Set<Language> languages = new HashSet<>(0); Set<Tag> tags = new HashSet<>(0); tags.add(new Tag("document")); tags.add(new Tag("nosql")); languages.add(new Language("java")); languages.add(new Language("groovy")); languages.add(new Language("ruby")); languages.add(new Language("scala")); languages.add(new Language("javascript")); artifact.setName("curly"); artifact.setDescription("a hobby project"); artifact.setAuthor("joaoevangelista"); artifact.setCategory(new Category("database")); artifact.setHomePage("http://example.com"); artifact.setIncubation(LocalDate.now().toString()); artifact.setLanguages(languages); artifact.setTags(tags); artifact.setOwner("6969"); mongoTemplate.save(artifact); }; } }