Package net.hasor.core

Examples of net.hasor.core.Module


*/
public class AwareContextTest {
    @Test
    public void awareContextTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>awareContextTest<<--");
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                //由于init过程中无法取得 appContext对象,因此让Hasor在适当的时机将自身注入进去。
                AwareBean aware = apiBinder.autoAware(new AwareBean());
                //
                apiBinder.bindType(AwareBean.class).toInstance(aware);
View Full Code Here


*/
public class IocTest {
    @Test
    public void iocTest() throws IOException, URISyntaxException, InterruptedException {
        System.out.println("--->>iocTest<<--");
        AppContext appContext = Hasor.createAppContext(new Module() {
            public void loadModule(ApiBinder apiBinder) throws Throwable {
                apiBinder.bindType(UserBean.class);
                apiBinder.bindType(UserTypeBean.class);
            }
        });
View Full Code Here

                configResource = config.value();
                for (Class<? extends Module> mod : config.loadModules())
                    loadModule.add(mod.newInstance());
            }
            //2.初始化绑定Test
            loadModule.add(new Module() {
                @Override
                public void loadModule(final ApiBinder apiBinder) throws Throwable {
                    HasorUnitRunner.this.typeRegister = apiBinder.bindType(klass).uniqueName().toInfo();
                }
            });
View Full Code Here

    //
    /**获取启动模块*/
    protected Module getStartModule(ServletContext sc) throws Exception {
        //
        //1.Start Module.
        Module startModule = null;
        String startModuleType = sc.getInitParameter("startModule");
        if (StringUtils.isBlank(startModuleType)) {
            Hasor.logWarn("startModule is undefinition.");
        } else {
            Class<Module> startModuleClass = (Class<Module>) Thread.currentThread().getContextClassLoader().loadClass(startModuleType);
View Full Code Here

        try {
            //1.create AppContext
            final ServletContext sc = servletContextEvent.getServletContext();
            this.appContext = this.createAppContext(sc);
            if (this.appContext.isStart() == false) {
                Module startModule = this.getStartModule(sc);
                this.appContext.start(startModule);
            }
            //
            RuntimeListener.LocalServletContext.set(servletContextEvent.getServletContext());
            RuntimeListener.LocalAppContext.set(this.appContext);
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.