OSCAR startup analysis

xiaoxiao2021-03-06  72

1. OSCAR first looks for the System.Properties file with oscar.jar in the same directory, load all system properties.

You can change the path to the System.Properties file by setting an OSCar.System.Properties property.

2. Find the value of cache_profile_prop to determine the Profile name property;

Find values ​​for cache_profile_dir_prop Determine the Profile directory properties.

3, OSCAR Other Attributes Setting [Option]

4, instantiate OSCAR

1) Create a copy of the incoming configuration properties

m_configpropmap = new hashmap ();

For (Enumeration E = Props.propertyNames (); E.haASMoreElements ();)

{

String name = (string) E.NEXTELEMENT ();

m_configpropmap.put (name, props.getproperty);

}

2) Instantiate the cache instance of bundle bundle [Analysis] if the cache_class_prop system property is not specified, then instantiate the defaultbundlecache.

When an exception occurs during this process, the JVM is stopped if OSCAR is started independently.

3) Initialize the OSCAR instance

/ *******************************************************

** ImportSearchPolicy SearchPolicy = New OsgiImportSearchPolicy (this);

** m_mgr = new moduleManager (SearchPolicy, New OsgiURLPOLICY (THIS));

**

** m_mgr.addModuleListener ((OSGISElectionPolicy) searchPolicy.getSelectionPolicy ());

**

** SearchPolicy.AddValidationListener (New ValidationListener ()

* /

Construct an ImportSearchPolicy instance [Analysis]. ImportSearchPolicy implements ModuleLoader's finding policies to support modules mutual import and resources.

Construct OsgiurlPolicy instance [analysis]

Use the specified Search Policies and URL Policy Construction ModuleManager [Analysis]

Registering an OSGi Selection Policy instance on ModuleManager as a Module listening to the Module to clean Package Export Cache when modules are uninstalled.

Register Validation listening on the ImportSearchPolicy instance so that when Modules is updated after Validated (such as resolved).

Configuration Support SYNCHRONOSBUNDLISTENER's example [Analysis]

Construct Installed Bundle Map instance

** m_dispatchqueue = new oscardispatchqueue ();

** m_installedbundlemap = new hashmap ();

Constructing Framework Properties instance (CaseinSensitiveMap)

** m_frameworkpropmap = new caseinsensitiveMap ();

Initialize OSGi Properties (InitializeSgiproperties [Analysis])

Initialize Bundle Properties (Initializeosgiproperties) [Analysis] ** Initializeosgiproperties ();

** Initializeosgiproperties ();

/ *****************************************

** burleinfo info = new bundleinfo

** New SystemBundLearchive (), NULL);

** systembundle = new systembundle (this, info, activatorlist);

** systembundle.getInfo (). Addmodule

** m_mgr.addmodule

** "0", systembundle.getattributes (),

** SystemBundle.getResourcesources (),

** systembundle.getlibrarySources ()));

** m_installedbundlemap.put

** SystemBundle.getInfo (). GetLocation (), systembundle;

**

** SearchPolicy.Validate (SystemBundle.getInfo (). GetCurrentModule ());

* /

Create a system bundle instance:

Simple bundle info instance for System Bundle [Todo: Analysis Bundleinfo Construction]

Instantiate System Bundle [Todo: Analysis of Systembundle Construction]

Put System Bundle in Installed Bundle Map

Call the ImportSearchPolicy instance to the Validate System bundle to make its status as resolved. 【analysis】

Launch System Bundle [Analysis]

Re-load and cache bundles

Bundlearchive [] Archives = m_cache.getarchives ();

Processing if the bundle labeled uninstalled is completely uninstalled because of Crash or File Lock

/ ** if (Archives [i] .GetPersisterStentState () == bundle.unInStalled)

** {

** m_cache.remove (Archives [i]);

**}

* /

Otherwise, all bundle [Analyze InstallBundle] in Install Bundlearchives

/ ** else

** {

** // install the cached bundle.

** bundle = (bundleimpl) installbundle () INSTALLBUNDLE

** Archives [i] .GetId (), Archives [i] .getlocation (), null;

**}

* /

Get the default Start Level

Load bundles from Auto-INSTALL and Auto-Start Properties;

ProcessAutoproperties (); [Analysis]

Set the Active Start Level of Framework, if necessary, you may restart your bundles.

SetStartLevel (StartLevel); [Analysis]

OSCAR enters the start state

m_oscarstatus = running_status;

Set the State of System Bundle to active.systemBundle.GetInfo (). SetState (bundle.active);

Trigger Started Event for System Bundle.

Firebundleevent (bundleevent.started, systembundle);

Send a Framework Event indicates that OSCAR has started.

FirefraMeworKevent (frameworkevent.started, getBundle (0), NULL);

转载请注明原文地址:https://www.9cbs.com/read-91810.html

New Post(0)