Package net.hasor.core

Examples of net.hasor.core.Module


public class UserControllerTest {
    @Test
    public void userControllerTest() throws Throwable {
        System.out.println("--->>userControllerTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                /*绑定一个接口的实现类*/
                apiBinder.installModule(new ControllerModule());
            }
        });
View Full Code Here


            if (!Module.class.isAssignableFrom(modClass)) {
                Hasor.logWarn("not implemented net.hasor.core.Module :%s", modClass);
                continue;/*错误*/
            }
            /*Hasor 模块*/
            Module modObject = createModule(modClass);
            ModuleInfo moduleInfo = appContext.addModule(modObject);
            //
            AnnoModule modAnno = modClass.getAnnotation(AnnoModule.class);
            String dispName = StringUtils.isBlank(modAnno.displayName()) ? modClass.getSimpleName() : modAnno.displayName();
            String description = StringUtils.isBlank(modAnno.description()) ? modClass.getName() : modAnno.description();
View Full Code Here

                    if (StringUtils.isBlank(moduleTypeString)) {
                        continue;
                    }
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();
                    Class<?> moduleType = ClassUtils.getClass(loader, moduleTypeString);
                    Module module = (Module) moduleType.newInstance();
                    this.installModule(module);
                }
            }
        }
        //2.继续init
View Full Code Here

public class ControllerTest {
    @Test
    public void controllerTest() throws Throwable {
        System.out.println("--->>controllerTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                /*绑定一个接口的实现类*/
                apiBinder.installModule(new ControllerModule());
            }
        });
View Full Code Here

public class InterfaceBindTest {
    @Test
    public void faceBindTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>faceBindTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                /*绑定一个接口的实现类*/
                apiBinder.bindType(PojoInfo.class).to(PojoBean.class);
            }
        });
View Full Code Here

public class ScopeTest {
    @Test
    public void scopeTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>scopeTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                MyScope myScope1 = new MyScope();
                //
                apiBinder.bindType(PojoBean.class).nameWith("myBean1").toScope(myScope1);
            }
View Full Code Here

public class TypeBindTest {
    @Test
    public void typeBindTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>typeBindTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                /*绑定类型到Hasor*/
                apiBinder.bindType(PojoBean.class);
            }
        });
View Full Code Here

public class SingletonBindTest {
    @Test
    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);
            }
View Full Code Here

public class NameBindTest {
    @Test
    public void nameBindTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>nameBindTest<<--");
        //1.创建一个标准的 Hasor 容器。
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                //绑定一个接口和实现类
                apiBinder.bindType(CharSequence.class).nameWith("ModuleA").toInstance("this String form A");
                apiBinder.bindType(CharSequence.class).nameWith("ModuleB").toInstance("this String form B");
            }
View Full Code Here

public class NameBindTest {
    @Test
    public void nameBindTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>nameBindTest<<--");
        //1.创建一个标准的 Hasor 容器。
        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();
View Full Code Here

TOP

Related Classes of net.hasor.core.Module

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.