org.apache.servicecomb.foundation.common.utils.BeanUtils Java Examples
The following examples show how to use
org.apache.servicecomb.foundation.common.utils.BeanUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeFirstMain.java From skywalking with Apache License 2.0 | 6 votes |
public static void init() { while (true) { try { Log4jUtils.init(); BeanUtils.init(); return; } catch (Throwable e) { try { LOGGER.error(e.getMessage(), e); Thread.sleep(5000); } catch (InterruptedException ex) { // ignore } } } }
Example #2
Source File: TestExecutorManager.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void findExecutor_twoParam_opCfg_withOpDef(@Mocked Executor executor, @Mocked Executor defExecutor, @Mocked OperationMeta operationMeta) { String schemaQualifiedName = "schemaId.opId"; String opBeanId = "opBeanId"; ArchaiusUtils.setProperty(ExecutorManager.KEY_EXECUTORS_PREFIX + schemaQualifiedName, opBeanId); new Expectations(BeanUtils.class) { { operationMeta.getSchemaQualifiedName(); result = schemaQualifiedName; BeanUtils.getBean(opBeanId); result = executor; } }; Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, defExecutor)); }
Example #3
Source File: ConsumerMain.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Log4jUtils.init(); BeanUtils.init(); new Consumer().testEncrypt(); System.out.println("Running api dispatcher."); new Consumer().run("api"); System.out.println("Running rest dispatcher."); new Consumer().run("rest"); System.out.println("Running url dispatcher."); new Consumer().run("url"); System.out.println("Running http dispatcher."); new Consumer().run("http"); System.out.println("All test case finished."); }
Example #4
Source File: AuthConsumerMain.java From servicecomb-samples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { BeanUtils.init(); Person person = new Person(); person.setName("ServiceComb/Authenticate"); System.out .println("RestTemplate Consumer or POJO Consumer. You can choose whatever you like."); String sayHiResult = restTemplate .postForObject( "cse://auth-provider/springmvchello/sayhi?name=Authenticate", null, String.class); String sayHelloResult = restTemplate.postForObject( "cse://auth-provider/springmvchello/sayhello", person, String.class); System.out.println(sayHiResult); System.out.println(sayHelloResult); }
Example #5
Source File: ConsumerMain.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Throwable { deploys.init(); deploys.getServiceCenter().ensureReady(); BeanUtils.init(); ITUtils.waitBootFinished(); try { run(); } finally { SCBEngine.getInstance().destroy(); deploys.getServiceCenter().stop(); } resultPrinter.print(); if (autoExit) { System.exit(0); } }
Example #6
Source File: TestExecutorManager.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void findExecutor_twoParam_schemaCfg_withoutOpDef(@Mocked Executor executor, @Mocked OperationMeta operationMeta) { String schemaName = "schemaId"; String opBeanId = "opBeanId"; ArchaiusUtils.setProperty(ExecutorManager.KEY_EXECUTORS_PREFIX + schemaName, opBeanId); new Expectations(BeanUtils.class) { { operationMeta.getSchemaId(); result = schemaName; BeanUtils.getBean(opBeanId); result = executor; } }; Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta, null)); }
Example #7
Source File: PojoConsumerMain.java From servicecomb-samples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { BeanUtils.init(); System.out.println(hello.sayHi("Java Chassis")); Person person = new Person(); person.setName("ServiceComb/Java Chassis"); System.out.println(hello.sayHello(person)); System.out.println("a=1, b=2, result=" + compute.add(1, 2)); }
Example #8
Source File: DynamicConfigurationIT.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { vertx = Vertx.vertx(); vertx.deployVerticle(new SimApolloServer()); Log4jUtils.init(); BeanUtils.init(); }
Example #9
Source File: ExecutorManager.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public Executor findExecutorById(String id) { Executor executor = executors.get(id); if (executor != null) { return executor; } return BeanUtils.getBean(id); }
Example #10
Source File: SpringmvcClient.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { try { Log4jUtils.init(); BeanUtils.init(); run(); } catch (Throwable e) { TestMgr.check("success", "failed"); LOGGER.error("-------------- test failed -------------"); LOGGER.error("", e); LOGGER.error("-------------- test failed -------------"); } TestMgr.summary(); }
Example #11
Source File: SagaConsumerHandler.java From txle with Apache License 2.0 | 5 votes |
public SagaConsumerHandler() { OmegaContext context = null; try { context = BeanUtils.getBean("omegaContext"); } catch (NullPointerException npe) { LOG.warn("SagaConsumerHandler cannot work rightly, please make sure omegaContext is in the spring application context."); } this.omegaContext = context; }
Example #12
Source File: ServerApplication.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { new SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args); SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker"); invoker.latch.await(10, TimeUnit.SECONDS); TestMgr.check(invoker.result, "hello"); TestMgr.summary(); if (!TestMgr.errors().isEmpty()) { System.exit(1); } }
Example #13
Source File: SpringmvcConsumerMain.java From servicecomb-samples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { BeanUtils.init(); SpringmvcBasicClient springmvcBasicClient = BeanUtils.getBean("SpringmvcBasicClient"); SpringmvcHelloClient springmvcHelloClient = BeanUtils.getBean("SpringmvcHelloClient"); long begin = System.currentTimeMillis(); springmvcHelloClient.run(); springmvcBasicClient.run(); System.out.println("Spring MVC Consumer execute successfully." + (System.currentTimeMillis() - begin) ); }
Example #14
Source File: PojoProducers.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
protected void processProvider(String beanName, Object bean) { // aop后,新的实例的父类可能是原class,也可能只是个proxy,父类不是原class // 所以,需要先取出原class,再取标注 Class<?> beanCls = BeanUtils.getImplClassFromBean(bean); if (beanCls == null) { return; } RpcSchema rpcSchema = beanCls.getAnnotation(RpcSchema.class); if (rpcSchema == null) { return; } String schemaId = rpcSchema.schemaId(); if (StringUtils.isEmpty(schemaId)) { Class<?>[] intfs = beanCls.getInterfaces(); if (intfs.length == 1) { schemaId = intfs[0].getName(); } else { throw new Error("Must be schemaId or implements only one interface"); } } PojoProducerMeta pojoProducerMeta = new PojoProducerMeta(); pojoProducerMeta.setSchemaId(schemaId); pojoProducerMeta.setInstance(bean); registerPojoProducer(pojoProducerMeta); }
Example #15
Source File: MockUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public void mockBeanUtils() { new MockUp<BeanUtils>() { @Mock ApplicationContext getContext() { return Mockito.mock(ApplicationContext.class); } @Mock <T> T getBean(String name) { return null; } }; }
Example #16
Source File: JaxrsConsumerMain.java From servicecomb-samples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { BeanUtils.init(); System.out.println(hello.sayHi("Java Chassis")); Person person = new Person(); person.setName("ServiceComb/Java Chassis"); System.out.println(hello.sayHello(person)); RestTemplate restTemplate = RestTemplateBuilder.create(); String result = restTemplate.getForObject("cse://jaxrs/jaxrshello/saybye", String.class); System.out.println(result); }
Example #17
Source File: MainServer.java From servicecomb-samples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { BeanUtils.init(); while (true) { System.out.println(DynamicPropertyFactory.getInstance().getStringProperty("timeout", "default")); Thread.sleep(3000); } }
Example #18
Source File: CrossappClient.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); Log4jUtils.init(); BeanUtils.init(); run(); TestMgr.summary(); System.setProperty("sun.net.http.allowRestrictedHeaders", "false"); }
Example #19
Source File: SagaProviderHandler.java From txle with Apache License 2.0 | 5 votes |
public SagaProviderHandler() { OmegaContext context = null; try { context = BeanUtils.getBean("omegaContext"); } catch (NullPointerException npe) { LOG.warn("SagaProviderHandler cannot work rightly, please make sure omegaContext is in the spring application context.\""); } this.omegaContext = context; }
Example #20
Source File: CategorizedTestCaseRunner.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void runCategorizedTestCase(String microserviceName) throws Exception { Map<String, CategorizedTestCase> tests = BeanUtils.getContext().getBeansOfType(CategorizedTestCase.class); for (String transport : DemoConst.transports) { for (CategorizedTestCase testCase : tests.values()) { try { if (testCase.getMicroserviceName() != null) { changeTransport(testCase.getMicroserviceName(), transport); } else { changeTransport(microserviceName, transport); } testCase.testAllTransport(); if ("rest".equals(transport)) { testCase.testRestTransport(); } else if ("highway".equals(transport)) { testCase.testHighwayTransport(); } } catch (Exception e) { e.printStackTrace(); TestMgr.failed("run categorized test case " + testCase.getClass().getName() + " failed, reason " + e.getMessage(), e); } } } }
Example #21
Source File: ServerApplication.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { new SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args); SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker"); invoker.latch.await(10, TimeUnit.SECONDS); TestMgr.check(invoker.result, "hello"); TestMgr.summary(); if (!TestMgr.errors().isEmpty()) { System.exit(1); } }
Example #22
Source File: BClientMain.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Log4jUtils.init(); BeanUtils.init(); BClient client = BeanUtils.getContext().getBean(BClient.class); client.run(); TestMgr.summary(); }
Example #23
Source File: MultipleClient.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Log4jUtils.init(); BeanUtils.init(); AClient aClient = BeanUtils.getContext().getBean(AClient.class); BClient bClient = BeanUtils.getContext().getBean(BClient.class); aClient.run(); bClient.run(); TestMgr.summary(); }
Example #24
Source File: AClientMain.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Log4jUtils.init(); BeanUtils.init(); AClient client = BeanUtils.getContext().getBean(AClient.class); client.run(); TestMgr.summary(); }
Example #25
Source File: CseApplicationListener.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (this.applicationContext == applicationContext) { // same object. avoid initialize many times. return; } this.applicationContext = applicationContext; BeanUtils.setContext(applicationContext); HttpClients.load(); RegistrationManager.INSTANCE.init(); DiscoveryManager.INSTANCE.init(); }
Example #26
Source File: TestExecutorManager.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void findExecutor_oneParam(@Mocked Executor executor, @Mocked OperationMeta operationMeta) { new Expectations(BeanUtils.class) { { BeanUtils.getBean(ExecutorManager.EXECUTOR_DEFAULT); result = executor; } }; Assert.assertSame(executor, new ExecutorManager().findExecutor(operationMeta)); }
Example #27
Source File: TestCseXmlWebApplicationContext.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void testGetConfigLocationsEmptyAndDefaultEmpty() { context.setDefaultBeanResource(null); String[] result = context.getConfigLocations(); Assert.assertThat(result, Matchers.arrayContaining(BeanUtils.DEFAULT_BEAN_CORE_RESOURCE, BeanUtils.DEFAULT_BEAN_NORMAL_RESOURCE)); }
Example #28
Source File: EdgeApplication.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { new SpringApplicationBuilder().sources(EdgeApplication.class).web(WebApplicationType.NONE).build().run(args); SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker"); invoker.latch.await(10, TimeUnit.SECONDS); TestMgr.check(invoker.result, "hello"); TestMgr.summary(); if (!TestMgr.errors().isEmpty()) { System.exit(1); } }
Example #29
Source File: ServerApplication.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { new SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args); SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker"); invoker.latch.await(10, TimeUnit.SECONDS); TestMgr.check(invoker.result, "hello"); TestMgr.summary(); if (!TestMgr.errors().isEmpty()) { System.exit(1); } }
Example #30
Source File: PerfMain.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { BeanUtils.init(); // redis RedisClientUtils.init(VertxUtils.getOrCreateVertxByName("transport", null)); List<String> argList = Arrays.asList(args); if (argList.contains("-c")) { PerfConsumer consumer = BeanUtils.getContext().getBean(PerfConsumer.class); consumer.runConsumer(); } }