Package net.test.simple.core._02_bind

Examples of net.test.simple.core._02_bind.InterfaceBindTest


                //
                apiBinder.bindType(PojoBean.class).nameWith("myBean1").toScope(myScope1);
            }
        });
        //
        PojoBean myBean = null;
        myBean = appContext.findBindingBean("myBean1", PojoBean.class);
        System.out.println("Scope 1 : " + myBean.getName() + myBean);
        myBean = appContext.findBindingBean("myBean1", PojoBean.class);
        System.out.println("Scope 1 : " + myBean.getName() + myBean);
    }
View Full Code Here


            }
        });
        //
        //
        //通过绑定的类型获取Bean
        PojoBean myBean1 = appContext.getInstance(PojoBean.class);
        System.out.println(myBean1.getName() + "\t" + myBean1);
    }
View Full Code Here

    public void singletonBindTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>singletonBindTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                PojoBean pojo = new PojoBean();
                pojo.setName("马大帅");
                apiBinder.bindType(PojoBean.class).idWith("myBean1").toInstance(pojo);
            }
        });
        //
        PojoBean myBean1 = appContext.getInstance("myBean1");
        System.out.println(myBean1.getName() + "\t" + myBean1);
        PojoBean myBean2 = appContext.getInstance("myBean1");
        System.out.println(myBean2.getName() + "\t" + myBean2);
    }
View Full Code Here

        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                //Bean1
                apiBinder.bindType(PojoBean.class).idWith("myBean1");
                //Bean2
                PojoBean pojo = new PojoBean();
                pojo.setName("马大帅");
                apiBinder.bindType(PojoBean.class).idWith("myBean2").toInstance(pojo);
            }
        });
        //
        PojoBean myBean1 = appContext.getInstance("myBean1");
        System.out.println(myBean1.getName() + "\t" + myBean1);
        PojoBean myBean2 = appContext.getInstance("myBean2");
        System.out.println(myBean2.getName() + "\t" + myBean2);
    }
View Full Code Here

                apiBinder.bindType(PojoInfo.class).to(PojoBean.class);
            }
        });
        //
        //通过接口获取绑定的Bean
        PojoInfo myBean2 = appContext.getInstance(PojoInfo.class);
        System.out.println(myBean2.getName() + "\t" + myBean2);
    }
View Full Code Here

*/
public class ModuleTest {
    @Test
    public void moduleTest() throws IOException, URISyntaxException {
        System.out.println("--->>moduleTest<<--");
        AppContext appContext = Hasor.createAppContext(new Mod_1(), new Mod_2(), new Mod_3());
        //
        List<String> says = appContext.findBindingBean(String.class);
        Hasor.logInfo("all modules say:%s.", says);
    }
View Full Code Here

*/
public class ModuleTest {
    @Test
    public void moduleTest() throws IOException, URISyntaxException {
        System.out.println("--->>moduleTest<<--");
        AppContext appContext = Hasor.createAppContext(new Mod_1(), new Mod_2(), new Mod_3());
        //
        List<String> says = appContext.findBindingBean(String.class);
        Hasor.logInfo("all modules say:%s.", says);
    }
View Full Code Here

*/
public class ModuleTest {
    @Test
    public void moduleTest() throws IOException, URISyntaxException {
        System.out.println("--->>moduleTest<<--");
        AppContext appContext = Hasor.createAppContext(new Mod_1(), new Mod_2(), new Mod_3());
        //
        List<String> says = appContext.findBindingBean(String.class);
        Hasor.logInfo("all modules say:%s.", says);
    }
View Full Code Here

    @Test
    public void customAnnoAopTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>customAnnoAopTest<<--");
        AppContext appContext = Hasor.createAppContext(new WarpAnnoAop());
        //
        FooBean fooBean1 = appContext.getInstance(FooBean.class);
        FooBean fooBean2 = appContext.getInstance(CustomAnnoFooBean.class);
        //
        System.out.println("---fooBean1.fooCall()---");
        fooBean1.fooCall();
        System.out.println("---fooBean2.fooCall()---");
        fooBean2.fooCall();
    }
View Full Code Here

    @Test
    public void aopTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>aopTest<<--");
        AppContext appContext = Hasor.createAppContext(new WarpAop());
        //
        FooBean fooBean = appContext.getInstance(FooBean.class);
        fooBean.fooCall();
    }
View Full Code Here

TOP

Related Classes of net.test.simple.core._02_bind.InterfaceBindTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.