BootStrap Loader

BootStrap Loader(引导程序)是一个轻量级的应用程序,它定义了应用程序之间想要共享的类。

BootStrap Loader第一个被加载,而在把主应用程序加载到自己的子应用程序域。然后主程序加载一个子程序到同域中。这连个程序都会被加载到bootstrap loader的应用程序域的子程序域。这样它们就可以共享任何在bootstrap里面定义的类,当然前提是使用它们自己的类定义。

通常在一个安全域中只有一个bootstrap loader。在不同的安全域中Bootstrap里面的类是不共享的。

Bootstrap Loader里面任何一个类的改变都会影响其它子程序。所以,要确保加入到BootStrap Loader里面的类一般是不经常改变的。

当你使用RPC类和Blaze DS、LCDS时,你就必须把RPC类隔离出BootStrap Loader。bootstrap loader应该只包含RPC类。你通常不添加你的自定义的值对象类到bootstrap loader来得到和设置服务器上数据,你可以添加这些类减少封装。但是如果是那样的话,这些类应该是简单的类,而不要关联到Flex框架,例如Array、ArrayCollection。添加复杂的值对象类到bootstrap loader是不支持的。

下面是一个RPC类的bootstrap loader的例子,这种bootstrap loader通常使用在子程序使用HTTPService和WebService类,以及代理服务。

注意MainApp.swf被加载,bootstrap loader使用Loader类,没有定义LoaderContext,意味着使用默认的Loader。默认是把子程序加载到一个子应用程序域,采取默认的安全域。

同时也注意每一条import,类的声明是紧接着导入的,结果就是这些类类定义直接关联到bootstrap loader中,主程序和子程序可以共享这些类了。

代码示例如下:

package {

import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;

/**
 *  Classes used by the networking protocols go here. These are the classes
 *  whose definitions are added to the bootstrap loader and then shared
 *  by the main application and all sub-applications.
 */
import mx.messaging.config.ConfigMap; ConfigMap;
import mx.messaging.messages.AcknowledgeMessage; AcknowledgeMessage;
import mx.messaging.messages.AcknowledgeMessageExt; AcknowledgeMessageExt;
import mx.messaging.messages.AsyncMessage; AsyncMessage;
import mx.messaging.messages.AsyncMessageExt; AsyncMessageExt;
import mx.messaging.messages.CommandMessage; CommandMessage;
import mx.messaging.messages.CommandMessageExt; CommandMessageExt;
import mx.messaging.messages.ErrorMessage; ErrorMessage;
import mx.messaging.messages.HTTPRequestMessage; HTTPRequestMessage;
import mx.messaging.messages.MessagePerformanceInfo; MessagePerformanceInfo;
import mx.messaging.messages.RemotingMessage; RemotingMessage;
import mx.messaging.messages.SOAPMessage; SOAPMessage;
import mx.messaging.channels.HTTPChannel; HTTPChannel;
import mx.core.mx_internal;

[SWF(width="600", height="700")]
public class RPCBootstrapLoader extends Sprite {
        /**
         *  The URL of the application SWF that this bootstrap loader loads.
         */
        private static const applicationURL:String = "MainApp.swf";

        /**
         *  Constructor.
         */
        public function RPCBootstrapLoader() {
                super();

                if (ApplicationDomain.currentDomain.hasDefinition("mx.core::UIComponent"))
                        throw new Error("UIComponent should not be in the bootstrap loader.");

                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP_LEFT;

                if (!stage)
                        isStageRoot = false;

                root.loaderInfo.addEventListener(Event.INIT, initHandler);
        }

        /**
         *  The Loader that loads the main application's SWF file.
         */
        private var loader:Loader;

        /**
         *  Whether the bootstrap loader is at the stage root or not.
         *  It is only the stage root if it was the root
         *  of the first SWF file that was loaded by Flash Player.
         *  Otherwise, it could be a top-level application but not stage root
         *  if it was loaded by some other non-Flex shell or is sandboxed.
         */
        private var isStageRoot:Boolean = true;

        /**
         *  Called when the bootstrap loader's SWF file has been loaded.
         *  Starts loading the application SWF specified by the applicationURL property.
         */
        private function initHandler(event:Event):void {
                loader = new Loader();
                addChild(loader);
                loader.load(new URLRequest(applicationURL));
                loader.addEventListener("mx.managers.SystemManager.isBootstrapRoot", 
                        bootstrapRootHandler);
                loader.addEventListener("mx.managers.SystemManager.isStageRoot", 
                        stageRootHandler);

                stage.addEventListener(Event.RESIZE, resizeHandler);
        }

        private function bootstrapRootHandler(event:Event):void {
                // Cancel event to indicate that the message was heard.
                event.preventDefault();
        }

        private function stageRootHandler(event:Event):void {
                // Cancel event to indicate that the message was heard.
                if (!isStageRoot)
                        event.preventDefault();
        }

        private function resizeHandler(event:Event):void {
                loader.width = stage.width;
                loader.height = stage.height;
                Object(loader.content).setActualSize(stage.width, stage.height);
        }
}

}

下面的图片说明了每个域通过定义了mx.messaging.*类的bootstrap loader来得到它的类定义:


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个异常信息表明在使用Spring Boot时,你的应用程序试图在启动时加载一个不支持的类。java.lang.Integer和java.lang.Long是Java语言中的基本数据类型,它们应该是Java平台的一部分,应该在java.base模块中的引导类加载器中找到。 这个问题可能是由于依赖冲突引起的。可能有两个依赖项尝试引入相同的类,但它们的版本不兼容,导致了这个异常。你可以尝试升级或降级相关的依赖项,或者排除其中一个依赖项,以解决这个问题。 另外,你还可以尝试在启动时使用 `--illegal-access=permit` 参数来解决这个问题。这个参数将允许你的应用程序访问Java平台的内部API,可能会解决这个问题。但是,这个参数会使你的应用程序在Java 9及以上的版本中不再兼容,因为Java 9及以上版本中已经禁用了对内部API的访问。 ### 回答2: Java.lang.Integer和Java.lang.Long是Java的内置类,它们分别用于表示整数和长整型数据。这两个类都位于Java基本模块(java.base)中,由引导类加载器(bootstrap loader)加载。 在Spring Boot中,当出现异常信息"java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap'"时,这意味着代码中可能存在类型转换或赋值错误的问题。 这个异常信息通常表示在Java的基本模块(java.base)的引导类加载器中,使用了错误的类型转换或赋值操作。出现这个异常的原因可能是尝试将一个长整型值(Long)赋给整型变量(Integer),或者进行了不兼容类型之间的转换操作。 要解决这个异常,我们需要仔细检查代码中的类型转换和赋值操作,确保它们是正确的。如果必要,可以使用相应的转换方法(如intValue()或longValue())将长整型值转换为整型值。另外,也要确保变量的声明类型和赋值的类型一致,以避免出现类型不匹配的错误。 在排查代码时,还可以检查相关的依赖库和版本是否与Spring Boot版本兼容。有时候,不兼容的依赖库也会导致这种异常的出现。 总结来说,当出现"java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap'"的异常信息时,我们需要仔细检查代码中的类型转换和赋值操作,确保它们是正确的。同时,还要确保所使用的依赖库和版本与Spring Boot兼容。通过这些步骤,我们可以解决这个异常并保证代码的正确执行。 ### 回答3: 当出现"java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap'"的异常信息,通常是由于Spring Boot项目中存在的包冲突导致的。 在Java中,java.lang.Integer和java.lang.Long是基本的数据类型,它们通常是由Java虚拟机的引导类加载器加载的,这个加载器是Java运行环境的一部分,并负责加载Java核心类库。 然而,在Spring Boot项目中,可能会有一些第三方库或自定义的类库使用了同样的包名和类名,这样就会与Java的基本类冲突。当这些冲突的类被加载时,Java虚拟机会选择使用项目中的类而不是Java核心类库中的类,因为项目类加载器的优先级比引导类加载器高。 为了解决这个问题,可以尝试以下几种方法: 1.检查项目中的依赖关系:查看项目的依赖列表,确保没有引入重复的包或版本冲突的包。可以使用Maven或Gradle等构建工具来管理依赖关系。 2.更新依赖库版本:如果发现某个依赖库的版本过旧,可能存在与Java基本类库的冲突。尝试更新依赖库的最新版本以解决冲突。 3.使用类的完全限定名:当引用Integer或Long类时,使用完全限定名来指定类的来源,例如使用java.lang.Integer和java.lang.Long来代替Integer和Long。这样可以明确指定使用Java核心类库中的类而不是项目中的类。 总之,解决"java.lang.Integer和java.lang.Long在'bootstrap'加载器的java.base模块中"的异常信息,需要检查项目中的依赖关系,更新依赖库版本,或使用类的完全限定名来避免包冲突。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值