/** * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before * launch the application */ public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class); context.start(); System.in.read(); }
/** * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before * launch the application */ public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class); context.start(); DemoService service = context.getBean("demoServiceComponent", DemoServiceComponent.class); String hello = service.sayHello("world"); System.out.println("result :" + hello); }
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RabbitMQConfig.class); context.start(); } }
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class); context.start(); GreetingServiceConsumer greetingServiceConsumer = context.getBean(GreetingServiceConsumer.class); String hello = greetingServiceConsumer.doSayHello("annotation"); System.out.println("result: " + hello); }
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class); context.start(); log.info("service started successfully!"); Runtime.getRuntime().addShutdownHook(new Thread(){ @Override public void run() { log.info("Shutdown hook was invoked. Shutting down Service."); context.close(); } }); CountDownLatch countDownLatch = new CountDownLatch(1); countDownLatch.await(); } }
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class); context.start(); GreetingServiceConsumer greetingServiceConsumer = context.getBean(GreetingServiceConsumer.class); String hello = greetingServiceConsumer.doSayHello("configuration"); System.out.println("result: " + hello); }
public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class); context.start(); final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction"); String hello = annotationAction.doSayHello("world"); System.err.println("result :" + hello); System.in.read(); }
public void start() { String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG); if (configPath == null || configPath.length() == 0) { configPath = DEFAULT_SPRING_JAVACONFIG; } context = new AnnotationConfigApplicationContext(configPath); context.start(); }
public void start() { String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG); if (configPath == null || configPath.length() == 0) { configPath = DEFAULT_SPRING_JAVACONFIG; } context = new AnnotationConfigApplicationContext(configPath); context.start(); }
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class); context.start(); UserRepository userRepository = (UserRepository) context.getBean("userRepository"); CacheConfiguration cacheConfiguration = (CacheConfiguration) context.getBean("cacheConfiguration"); while (true) { String name = userRepository.getUserCacheable(1L); System.out.println(String.format("name=%s", name)); System.out.println(String.format("timeout=%s", cacheConfiguration.getTimeout())); TimeUnit.SECONDS.sleep(5); } } }
public static void main(String[] args) { System.setProperty("spring.cloud.appId", "my-cloud-app"); System.setProperty("spring.cloud.my-vault-service", "https://localhost:8200?token=my-token"); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( MyConfig.class, ClientComponent.class); context.start(); ClientComponent component = context.getBean(ClientComponent.class); log.info("VaultOperations (hash): {}", component.getVaultOperations()); context.stop(); }
public static void main(String[] args) throws Exception { new EmbeddedZooKeeper(2181, false).start(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class); context.start(); System.in.read(); }
public static void main(String[] args) throws Exception { new EmbeddedZooKeeper(2181, false).start(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class); context.start(); System.in.read(); }
public static void main(String[] args) throws Exception { new EmbeddedZooKeeper(2181, false).start(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class); context.start(); System.in.read(); }
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); // all other initialisation part ... // before! refresh ctx.setId("portal-lasg-appCtx-id"); // now refresh .. ctx.refresh(); ctx.start();
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( VaultConnectorsConfig.class, VaultConfig.class); context.start(); Cloud cloud = context.getBean(Cloud.class); SslConfiguration sslConfiguration = context.getBean(SslConfiguration.class); VaultServiceInfo vaultServiceInfo = (VaultServiceInfo) cloud .getServiceInfos(VaultOperations.class).get(0); VaultServiceConnectorConfig config = VaultServiceConnectorConfig.builder() .sslConfiguration(sslConfiguration).build(); VaultOperations vaultOperations = cloud .getSingletonServiceConnector(VaultOperations.class, config); VaultResponse response = vaultOperations .read(vaultServiceInfo.getBackends().get("generic") + "/application"); log.info("Retrieved app-key: {}", response.getData().get("app-key")); context.stop(); }
private static void addPostprocessorAndUpdateContext(Class<?> currentVerticleClass, AnnotationConfigApplicationContext annotationConfigApplicationContext) { annotationConfigApplicationContext.addBeanFactoryPostProcessor(new SpringSingleVerticleConfiguration(currentVerticleClass)); annotationConfigApplicationContext.refresh(); annotationConfigApplicationContext.start(); annotationConfigApplicationContext.registerShutdownHook(); }
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( VaultConfiguration.class); context.start(); VaultTemplate vaultTemplate = context.getBean(VaultTemplate.class); MySecretData mySecretData = new MySecretData(); mySecretData.setUsername("walter"); mySecretData.setPassword("white"); vaultTemplate.write( "secret/myapplication/user/3128", mySecretData); log.info("Wrote data to Vault"); VaultResponseSupport<MySecretData> response = vaultTemplate.read( "secret/myapplication/user/3128", MySecretData.class); log.info("Retrieved data {} from Vault", response.getData().getUsername()); context.stop(); }
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( VaultConfiguration.class); context.start(); PersonRepository repository = context.getBean(PersonRepository.class); Person person = new Person(); person.setId("heisenberg"); person.setFirstname("Walter"); person.setLastname("White"); person.setSsn("1234"); repository.save(person); log.info("Wrote data to Vault"); VaultTemplate template = context.getBean(VaultTemplate.class); VaultResponse response = template.read("secret/person/heisenberg"); log.info("Retrieved data {} from Vault via Template API", response.getData()); Optional<Person> loaded = repository.findById(person.getId()); log.info("Retrieved data {} from Vault via Repository", loaded.get()); context.stop(); }
protected CompletableFuture<ApplicationContext> springRuntimeContextInitialize() { @SuppressWarnings("resource") AnnotationConfigApplicationContext runtimeContext = new AnnotationConfigApplicationContext(); runtimeContext.setId(MangoWebApplicationInitializer.RUNTIME_CONTEXT_ID); runtimeContext.getEnvironment().getPropertySources().addLast(new MangoPropertySource("envProps", Common.envProps)); runtimeContext.register(MangoRuntimeContextConfiguration.class); runtimeContext.refresh(); runtimeContext.start(); return MangoRuntimeContextConfiguration.getFutureRuntimeContext(); }