Entry point for the Stetho dumpapp script.

{@link #initialize} must have been called in the app before running dumpapp.
964702
@Override
  public void dump(DumperContext dumpContext) throws DumpException {
    ensureInitialized();
    List<String> args = dumpContext.getArgsAsList();
    PrintStream writer = dumpContext.getStdout();

    String cmd = args.isEmpty() ? null : args.get(0);
    List<String> rest = args.isEmpty() ? new ArrayList<String>() : args.subList(1, args.size());

    if (cmd != null && cmd.equals("memcache")) {
      memcache(writer, rest);
    } else if (cmd != null && cmd.equals("diskcache")) {
      diskcache(mMainFileCache, "Main", writer, rest);
      diskcache(mSmallFileCache, "Small", writer, rest);
    } else {
      usage(writer);
      if (TextUtils.isEmpty(cmd)) {
        throw new DumpUsageException("Missing command");
      } else {
        throw new DumpUsageException("Unknown command: " + cmd);
      }
    }
  }
375185
async function initialize(dispatch) {
	shimInit();

	// blobTest();

	Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
	Setting.setConstant('appId', 'net.cozic.joplin-mobile');
	Setting.setConstant('appType', 'mobile');
	//Setting.setConstant('resourceDir', () => { return RNFetchBlob.fs.dirs.DocumentDir; });
	Setting.setConstant('resourceDir', RNFetchBlob.fs.dirs.DocumentDir);

	const logDatabase = new Database(new DatabaseDriverReactNative());
	await logDatabase.open({ name: 'log.sqlite' });
	await logDatabase.exec(Logger.databaseCreateTableSql());

	const mainLogger = new Logger();
	mainLogger.addTarget('database', { database: logDatabase, source: 'm' });
	mainLogger.setLevel(Logger.LEVEL_INFO);
	
	if (Setting.value('env') == 'dev') {
		mainLogger.addTarget('console');
		mainLogger.setLevel(Logger.LEVEL_DEBUG);
	}

	reg.setLogger(mainLogger);
	reg.setShowErrorMessageBoxHandler((message) => { alert(message) });

	BaseService.logger_ = mainLogger;

	reg.logger().info('====================================');
	reg.logger().info('Starting application ' + Setting.value('appId') + ' (' + Setting.value('env') + ')');

	const dbLogger = new Logger();
	dbLogger.addTarget('database', { database: logDatabase, source: 'm' }); 
	if (Setting.value('env') == 'dev') {
		dbLogger.addTarget('console');
		dbLogger.setLevel(Logger.LEVEL_INFO); // Set to LEVEL_DEBUG for full SQL queries
	} else {
		dbLogger.setLevel(Logger.LEVEL_INFO);
	}

	let db = new JoplinDatabase(new DatabaseDriverReactNative());
	db.setLogger(dbLogger);
	reg.setDb(db);

	reg.dispatch = dispatch;
	BaseModel.dispatch = dispatch;
	FoldersScreenUtils.dispatch = dispatch;
	BaseSyncTarget.dispatch = dispatch;
	NavService.dispatch = dispatch;
	BaseModel.db_ = db;

	BaseItem.loadClass('Note', Note);
	BaseItem.loadClass('Folder', Folder);
	BaseItem.loadClass('Resource', Resource);
	BaseItem.loadClass('Tag', Tag);
	BaseItem.loadClass('NoteTag', NoteTag);
	BaseItem.loadClass('MasterKey', MasterKey);
	BaseItem.loadClass('Revision', Revision);

	const fsDriver = new FsDriverRN();

	Resource.fsDriver_ = fsDriver;
	FileApiDriverLocal.fsDriver_ = fsDriver;

	AlarmService.setDriver(new AlarmServiceDriver());
	AlarmService.setLogger(mainLogger);

	try {
		if (Setting.value('env') == 'prod') {
			await db.open({ name: 'joplin.sqlite' })
		} else {
			await db.open({ name: 'joplin-68.sqlite' })
		}

		reg.logger().info('Database is ready.');
		reg.logger().info('Loading settings...');
		await Setting.load();

		if (Setting.value('firstStart')) {
			let locale = NativeModules.I18nManager.localeIdentifier
			if (!locale) locale = defaultLocale();
			Setting.setValue('locale', closestSupportedLocale(locale));
			if (Setting.value('env') === 'dev') Setting.setValue('sync.target', SyncTargetRegistry.nameToId('onedrive_dev'));
			Setting.setValue('firstStart', 0);
		}

		if (Setting.value('db.ftsEnabled') === -1) {
			const ftsEnabled = await db.ftsEnabled();
			Setting.setValue('db.ftsEnabled', ftsEnabled ? 1 : 0);
			reg.logger().info('db.ftsEnabled = ', Setting.value('db.ftsEnabled'));
		}

		BaseItem.revisionService_ = RevisionService.instance();

		// Note: for now we hard-code the folder sort order as we need to 
		// create a UI to allow customisation (started in branch mobile_add_sidebar_buttons)
		Setting.setValue('folders.sortOrder.field', 'title');
		Setting.setValue('folders.sortOrder.reverse', false);

		reg.logger().info('Sync target: ' + Setting.value('sync.target'));

		setLocale(Setting.value('locale'));

		// ----------------------------------------------------------------
		// E2EE SETUP
		// ----------------------------------------------------------------

		EncryptionService.fsDriver_ = fsDriver;
		EncryptionService.instance().setLogger(mainLogger);
		BaseItem.encryptionService_ = EncryptionService.instance();
		DecryptionWorker.instance().dispatch = dispatch;
		DecryptionWorker.instance().setLogger(mainLogger);
		DecryptionWorker.instance().setEncryptionService(EncryptionService.instance());
		await EncryptionService.instance().loadMasterKeysFromSettings();

		// ----------------------------------------------------------------
		// / E2EE SETUP
		// ----------------------------------------------------------------

		reg.logger().info('Loading folders...');

		await FoldersScreenUtils.refreshFolders();

		const tags = await Tag.allWithNotes();

		dispatch({
			type: 'TAG_UPDATE_ALL',
			items: tags,
		});

		const masterKeys = await MasterKey.all();

		dispatch({
			type: 'MASTERKEY_UPDATE_ALL',
			items: masterKeys,
		});

		let folderId = Setting.value('activeFolderId');
		let folder = await Folder.load(folderId);

		if (!folder) folder = await Folder.defaultFolder();

		dispatch({
			type: 'FOLDER_SET_COLLAPSED_ALL',
			ids: Setting.value('collapsedFolderIds'),
		});

		if (!folder) {
			dispatch({
				type: 'NAV_GO',
				routeName: 'Welcome',
			});
		} else {
			dispatch({
				type: 'NAV_GO',
				routeName: 'Notes',
				folderId: folder.id,
			});
		}
	} catch (error) {
		alert('Initialization error: ' + error.message);
		reg.logger().error('Initialization error:', error);
	}

	reg.setupRecurrentSync();

	PoorManIntervals.setTimeout(() => {
		AlarmService.garbageCollect();
	}, 1000 * 60 * 60);

	ResourceService.runInBackground();

	ResourceFetcher.instance().setFileApi(() => { return reg.syncTarget().fileApi() });
	ResourceFetcher.instance().setLogger(reg.logger());
	ResourceFetcher.instance().start();

	SearchEngine.instance().setDb(reg.db());
	SearchEngine.instance().setLogger(reg.logger());
	SearchEngine.instance().scheduleSyncTables();

	reg.scheduleSync().then(() => {
		// Wait for the first sync before updating the notifications, since synchronisation
		// might change the notifications.
		AlarmService.updateAllNotifications();

		DecryptionWorker.instance().scheduleStart();
	});

	await WelcomeUtils.install(dispatch);

	// Collect revisions more frequently on mobile because it doesn't auto-save
	// and it cannot collect anything when the app is not active.
	RevisionService.instance().runInBackground(1000 * 30);

	reg.logger().info('Application initialized');
}
951002
public void initialize() {
        val pair = buildLoggerContext(environment, resourceLoader);
        pair.ifPresent(it -> {
            this.logConfigurationFile = it.getKey();
            this.loggerContext = it.getValue();
        });
    }
724039
public void onInitialDataDownloaded() {
        Log.d(TAG, "Initial Data Loaded");
        context().getContactsModule().startImport();
        if (appStateVM.isBookImported()) {
            onAppLoaded();
        }
    }
1327974
@Override
    public Application onApplicationInit(Application app, JaxRsModuleMetaData metaData) {

        Class<?> clazz = app.getClass();

        if (!shouldHandle(clazz, true)) {
            return null;
        }
        Application newApp = null;

        ManagedObject<?> mo = getClassFromManagedObject(clazz);
        metaData.setManagedAppRef(mo);

        if (mo != null) {
            newApp = (Application) (mo.getObject());
        }

        if (newApp == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "App: app is null from CDI , get app from rs for " + app.getClass().getName());
            }
            return app;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "App: get app from CDI " + app.getClass().getName());
        }
        return newApp;
    }
569826
public static void init() throws JMFSchemaIdException {
    // Register the MFP diagnostic module
    MfpDiagnostics.initialize();


    try {
      JMFRegistry.instance.register(JsHdrAccess.schema);
      JMFRegistry.instance.register(JsHdr2Access.schema);
      JMFRegistry.instance.register(JsApiAccess.schema);
      JMFRegistry.instance.register(JsPayloadAccess.schema);
      JMFRegistry.instance.register(JmsBytesBodyAccess.schema);
      JMFRegistry.instance.register(JmsTextBodyAccess.schema);
      JMFRegistry.instance.register(JmsObjectBodyAccess.schema);
      JMFRegistry.instance.register(JmsStreamBodyAccess.schema);
      JMFRegistry.instance.register(JmsMapBodyAccess.schema);
      JMFRegistry.instance.register(TrmAccess.schema);
      JMFRegistry.instance.register(SubscriptionAccess.schema);
      JMFRegistry.instance.register(ControlAccess.schema);
      JMFRegistry.instance.register(TrmFirstContactAccess.schema);

      
    } catch (JMFSchemaIdException e) {
      FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.SchemaManager.<clinit>", "188");
      throw e;
    }
  }
1201634
protected function onInit()
    {
        $this->useDataSource();
        $this->useAutoName("gchart");

        $this->clientEvents = Utility::get($this->params, "clientEvents", array());
        $this->columns = Utility::get($this->params, "columns", null);
        $this->options = Utility::get($this->params, "options", array());
        $this->width = Utility::get($this->params, "width", "100%");
        $this->height = Utility::get($this->params, "height", "400px");
        $this->title = Utility::get($this->params, "title");
        $this->pointerOnHover = Utility::get($this->params, "pointerOnHover");
        $this->mapsApiKey = Utility::get($this->params, "mapsApiKey", '');

        if (!$this->dataStore) {
            //Backward compatible with setting through "data"
            $data = Utility::get($this->params, "data");
            if (is_array($data)) {
                if (count($data) > 0) {
                    $this->dataStore = new DataStore;
                    $this->dataStore->data($data);
                    $row = $data[0];
                    $meta = array("columns" => array());
                    foreach ($row as $cKey => $cValue) {
                        $meta["columns"][$cKey] = array(
                            "type" => Utility::guessType($cValue),
                        );
                    }
                    $this->dataStore->meta($meta);
                } else {
                    $this->dataStore = new DataStore;
                    $this->dataStore->data(array());
                    $this->dataStore->meta(array("columns" => array()));
                }
            }
            if ($this->dataStore == null) {
                throw new \Exception("dataSource is required");
                return;
            }
        }

        $this->type = Utility::getClassName($this);
        if ($this->type == "Chart") {
            $this->type = Utility::get($this->params, "type");
        }
        //Color Scheme
        $this->colorScheme = Utility::get($this->params, "colorScheme");
        if (!is_array($this->colorScheme)) {
            $theme = $this->getReport()->getTheme();
            if ($theme) {
                $theme->applyColorScheme($this->colorScheme);
            }
        }
        if (!is_array($this->colorScheme)) {
            $this->colorScheme = null;
        }
    }
926317
void initialize()
    {
        if (m_backend == BackendTarget.HSQLDB_BACKEND) {
            m_non_voltdb_backend = HsqlBackend.initializeHSQLBackend(m_siteId,
                                                       m_context);
        }
        else if (m_backend == BackendTarget.POSTGRESQL_BACKEND) {
            m_non_voltdb_backend = PostgreSQLBackend.initializePostgreSQLBackend(m_context);
        }
        else if (m_backend == BackendTarget.POSTGIS_BACKEND) {
            m_non_voltdb_backend = PostGISBackend.initializePostGISBackend(m_context);
        }
        else {
            m_non_voltdb_backend = null;
        }
    }
424766
static void initialize() {
        if (INITIALIZED.getAndSet(true)) {
            throw new IllegalStateException("Already initialized");
        }
        // Set the default initializer if none has been provided yet.
        INITIALIZER.compareAndSet(null, new ServiceLoaderZoneRulesInitializer());
        INITIALIZER.get().initializeProviders();
    }
301347
def init_app(self, app):
        """"""
        self.init_config(app)
        if hasattr(app, 'cli'):
            app.cli.add_command(files_cmd)
        app.extensions['invenio-files-rest'] = _FilesRESTState(app)
632159
public void InitializeScript() {

        for (InteractiveObject interactiveObject : interactiveObjects) {
            if (interactiveObject.getScriptObject() != null) {

                BuildInitJavaScript(interactiveObject);
                Object[] parameters = SetJavaScriptArguments(interactiveObject, 0, 0, 0, 0,false);
                parameters[0] = 0;
                if (interactiveObject.getScriptObject().getTimeStampParameter()) parameters[1] = 0;

                if ( V8JavaScriptEngine ) {
                    // Using V8 JavaScript compiler and run-time engine
                    GVRJavascriptV8File gvrJavascriptV8File = interactiveObject.getScriptObject().getGVRJavascriptV8File();
                    // Append the X3D data type constructors to the end of the JavaScript file
                    if ( !interactiveObject.getScriptObject().getInitializationDone()) {
                        gvrJavascriptV8File.setScriptText(gvrJavascriptV8File.getScriptText() +
                                interactiveObject.getScriptObject().getGearVRinitJavaScript());

                        if ( !interactiveObject.getScriptObject().getScriptCalledPerFrame() ) {
                            // only initialize if this is not called per frame
                            // initialization for scripts called per frame must be called
                            // when we begin the first frame due to V8 engine start-up
                            String paramString = "var params =[";
                            for (int i = 0; i < parameters.length; i++ ) {
                                paramString += (parameters[i] + ", ");
                            }
                            paramString = paramString.substring(0, (paramString.length()-2)) + "];";

                            final GVRJavascriptV8File gvrJavascriptV8FileFinal = gvrJavascriptV8File;
                            final InteractiveObject interactiveObjectFinal = interactiveObject;
                            final Object[] parametersFinal = parameters;
                            final String paramStringFinal = paramString;
                            gvrContext.runOnGlThread(new Runnable() {
                                @Override
                                public void run() {
                                    RunInitializeScriptThread( gvrJavascriptV8FileFinal, interactiveObjectFinal, parametersFinal, paramStringFinal);
                                }
                            });
                        }  // ! per frame script
                    }
                    interactiveObject.getScriptObject().setInitializationDone(true);

                } //  end of running initialize functions in V8 JavaScript engine
                else {
                    // Using older Mozilla Rhino engine
                    GVRJavascriptScriptFile gvrJavascriptFile = interactiveObject.getScriptObject().getGVRJavascriptScriptFile();

                    // Append the X3D data type constructors to the end of the JavaScript file
                    gvrJavascriptFile.setScriptText(gvrJavascriptFile.getScriptText() +
                            interactiveObject.getScriptObject().getGearVRinitJavaScript());

                    // Run the newly created method 'GEARVR_INIT_JAVASCRIPT_FUNCTION' that
                    //    constructs the objects required for this JavaScript program.
                    boolean complete = gvrJavascriptFile.invokeFunction(GEARVR_INIT_JAVASCRIPT_FUNCTION_NAME, parameters);
                    if (complete) {
                        // if the objects required for this function were constructed, then
                        //   check if this <SCRIPT> has an initialize() method that is run just once.
                        if (gvrJavascriptFile.getScriptText().contains(INITIALIZE_FUNCTION)) {
                            RunScript(interactiveObject, INITIALIZE_FUNCTION, parameters);
                        }
                    } else {
                        Log.e(TAG, "Error parsing / running initializing Rhino JavaScript function in SCRIPT '" +
                                interactiveObject.getScriptObject().getName() + "'");
                    }
                }  //  end using older Mozilla Rhino engine
            }  // end check for interactiveObject having a Script Object
        }  // end loop thru all interactiveObjects for a ScriptObject
    }
576722
public static void initApplication(Application app){
		
		// Add the Jawr tag handler to the MarkupParserFactory 
		MarkupFactory factory = new MarkupFactory(){
			
			public MarkupParser newMarkupParser(final MarkupResourceStream resource)
		    {
		       MarkupParser parser = new MarkupParser(new XmlPullParser(), resource);
		       parser.add(new JawrWicketLinkTagHandler());
		       return parser;
		    }
		};
		
		app.getMarkupSettings().setMarkupFactory(factory);
		
		// Add the Jawr link resolver
		app.getPageSettings().addComponentResolver(new JawrWicketLinkResolver());
	}
283472
protected void onInit(Holo config, Bundle savedInstanceState) {
        if (mInited) {
            throw new IllegalStateException("This instance was already inited");
        }
        mInited = true;
        if (config == null) {
            config = createConfig(savedInstanceState);
        }
        if (config == null) {
            config = Holo.defaultConfig();
        }
        onPreInit(config, savedInstanceState);
        if (!config.ignoreApplicationInstanceCheck && !(getApplication() instanceof Application)) {
            boolean throwError = true;
            if (config.allowMockApplicationInstance) {
                try {
                    throwError = !(getApplication() instanceof MockApplication);
                    if (!throwError) {
                        Log.w("HoloEverywhere", "Application instance is MockApplication. Wow. Let's begin tests...");
                    }
                } catch (Exception e) {
                }
            }
            if (throwError) {
                String text = "Application instance isn't HoloEverywhere.\n";
                if (getApplication().getClass() == android.app.Application.class) {
                    text += "Put attr 'android:name=\"org.holoeverywhere.app.Application\"'" +
                            " in <application> tag of AndroidManifest.xml";
                } else {
                    text += "Please sure that you extend " + getApplication().getClass() +
                            " from a org.holoeverywhere.app.Application";
                }
                throw new IllegalStateException(text);
            }
        }
        getLayoutInflater().setFragmentActivity(this);
        if (this instanceof Activity) {
            final Activity activity = (Activity) this;
            ThemeManager.applyTheme(activity, mLastThemeResourceId == 0);
            if (!config.ignoreThemeCheck && ThemeManager.getThemeType(this) == ThemeManager.INVALID) {
                throw new HoloThemeException(activity);
            }
            TypedArray a = obtainStyledAttributes(new int[]{android.R.attr.windowActionBarOverlay, R.attr.windowActionBarOverlay});
            if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
                supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
            }
            a.recycle();
            a = obtainStyledAttributes(new int[]{android.R.attr.windowActionModeOverlay, R.attr.windowActionBarOverlay});
            if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
                supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
            }
            a.recycle();
        }
        onPostInit(config, savedInstanceState);
        lockAttaching();
    }
1331861
async function init () {
    // initialze logging
    initLogging(this.immutableApp)
    // initialize global dir config by merging module configs
    initDir(this.immutableApp)
    // initalize handlebars
    initHandlebars(this.immutableApp)
    // initalize express request handling - bodyParser, cookieParser, etc
    initExpress(this.immutableApp)
    // initialize app
    initApp(this.immutableApp)
    // add error handler after all other middleware and routers
    initErrorHandler(this.immutableApp)
    // initialize models
    await initModels(this.immutableApp)
    // intialize components after models since they may use models
    initComponents(this.immutableApp)
    // initialize services after models since they may use models
    await initServices(this.immutableApp)
    // set initialize flag to true
    this.immutableApp.initialized = true
    // debug
    debug('init', this.immutableApp)
}
242347
public static void initApplication(String... args) {
		if (args.length < 1) {
			System.err.println("Please specify an Application as argument");
			System.exit(-1);
		}
		setInstance(createApplicationByClassName(args[0]));
	}
943874
private void init() {
        jsFactory = new JsonFactory();
        jsFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        jsFactory.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        jsFactory.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
    }
1125914
private void initialize() {
//		if (selection != null && selection.isEmpty() == false
//				&& selection instanceof IStructuredSelection) {
//			IStructuredSelection ssel = (IStructuredSelection) selection;
//			if (ssel.size() > 1)
//				return;
//			Object obj = ssel.getFirstElement();
//			if (obj instanceof IResource) {
//				IContainer container;
//				if (obj instanceof IContainer)
//					container = (IContainer) obj;
//				else
//					container = ((IResource) obj).getParent();
//				containerText.setText(container.getFullPath().toString());
//			}
//		}
		System.err.println("### Set default selected MuleVersion to index: " + muleVersionCombo.getItemCount());
		muleVersionCombo.select(muleVersionCombo.getItemCount() - 1);
	}