⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jumpisolateprocessimpl.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package com.sun.jumpimpl.isolate.jvmprocess;import com.sun.jump.isolate.jvmprocess.JUMPIsolateProcess;import com.sun.jump.isolate.jvmprocess.JUMPAppContainer;import com.sun.jump.isolate.jvmprocess.JUMPAppContainerContext;import com.sun.jump.common.JUMPAppModel;import com.sun.jump.common.JUMPProcess;import com.sun.jump.common.JUMPIsolate;import com.sun.jump.common.JUMPProcessProxy;import com.sun.jump.common.JUMPApplication;import com.sun.jump.message.JUMPMessagingService;import com.sun.jump.message.JUMPMessageDispatcher;import com.sun.jump.message.JUMPOutgoingMessage;import com.sun.jump.message.JUMPMessage;import com.sun.jump.message.JUMPMessageResponseSender;import com.sun.jump.message.JUMPMessageReader;import com.sun.jump.os.JUMPOSInterface;import com.sun.jumpimpl.process.JUMPModulesConfig;import com.sun.jumpimpl.process.JUMPProcessProxyImpl;import com.sun.jumpimpl.process.RequestSenderHelper;import com.sun.jump.command.JUMPIsolateLifecycleRequest;import com.sun.jump.command.JUMPExecutiveLifecycleRequest;import com.sun.jump.command.JUMPCommand;import com.sun.jump.command.JUMPRequest;import com.sun.jump.command.JUMPResponse;import com.sun.jump.command.JUMPResponseInteger;import com.sun.jump.message.JUMPMessageHandler;import com.sun.jumpimpl.client.module.windowing.WindowingIsolateClient;import com.sun.jumpimpl.client.module.serviceregistry.ServiceRegistryClient;import java.rmi.Remote;import java.rmi.NotBoundException;import javax.microedition.xlet.XletContext;import javax.microedition.xlet.ixc.IxcRegistry;import com.sun.jumpimpl.ixc.XletContextFactory;import sun.misc.MIDPConfig;import sun.misc.ThreadRegistry;import java.util.Map;import java.util.StringTokenizer;public class JUMPIsolateProcessImpl     extends JUMPIsolateProcess    implements JUMPMessageHandler, JUMPAppContainerContext{    private JUMPProcessProxyImpl    pp;    private JUMPOSInterface         os;    private int                     isolateId;    private JUMPProcessProxy        execProcess;    private JUMPMessageDispatcher   disp;    private JUMPAppModel            appModel;    private JUMPAppContainer        appContainer;    private WindowingIsolateClient  windowing;    private ServiceRegistryClient   serviceRegistry;    private Object stateChangeMutex = new Object();    private boolean dispatchingStateChange;    private boolean exitAfterStateChange;    private final KeepAliveMonitor keepAliveMonitor = new KeepAliveMonitor();    protected JUMPIsolateProcessImpl() {	super();	os = JUMPOSInterface.getInstance();	isolateId = os.getProcessID();	pp = JUMPProcessProxyImpl.createProcessProxyImpl(isolateId);    }    public JUMPProcessProxy    getExecutiveProcess() {        if(execProcess == null) {	    int epid = os.getExecutiveProcessID();            execProcess = JUMPProcessProxyImpl.createProcessProxyImpl(epid);        }        return execProcess;    }    public int    getProcessId() {        return os.getProcessID();    }    public Map    getConfig() {        return JUMPModulesConfig.getProperties();    }    /**     * Get app model running in this isolate process     */    public JUMPAppModel getAppModel() {	return appModel;    }        public synchronized JUMPMessageDispatcher    getMessageDispatcher() {	if (disp == null) {	    disp = pp.getMessageDispatcher();	}	return disp;    }    public JUMPOutgoingMessage    newOutgoingMessage(String mesgType) {        return pp.newOutgoingMessage(mesgType);    }    public JUMPOutgoingMessage    newOutgoingMessage(JUMPMessage requestMessage) {        return pp.newOutgoingMessage(requestMessage);    }    public JUMPMessage    newMessage(byte[] rawData) {        return pp.newMessage(rawData);    }    public void    kill(boolean force) {        throw new UnsupportedOperationException();    }    //    // The message handlers do the job.    // The message processor thread keeps the JVM alive.    //    public static void main(String[] args) {	try {            if(args.length > 1 && args[1] != null) {                JUMPModulesConfig.overrideDefaultConfig(args[1]);            }            // Initialize os interface            new com.sun.jumpimpl.os.JUMPOSInterfaceImpl();            // Create and register the singleton isolate process            JUMPIsolateProcessImpl ipi = new JUMPIsolateProcessImpl();	    // Register the executive before starting the messaging thread            ipi.getExecutiveProcess();            JUMPMessageDispatcher d = ipi.getMessageDispatcher();            d.registerHandler("mvm/client", ipi);            // FIXME: should go away once Ixc is on messaging            d.registerHandler("mvm/ixc", ipi);            JUMPAppModel appModel = JUMPAppModel.fromName(args[0]);            if (appModel == null) {                // Unknown app model                throw new RuntimeException("Unknown app model "+args[0]);            }            ipi.initialize(appModel);            //            // Once registerDirect() completes with success,            // we know we can receive messages. Report.            //            ipi.reportIsolateInitialized();            // Keep around the main thread              ipi.keepAliveMonitor.startWaiting();	} catch (Throwable e) {	    e.printStackTrace();	    System.exit(-1);	}    }    public void initialize(JUMPAppModel appModel) {	System.err.println("Setting app model to "+appModel);	this.appModel = appModel;        AppContainerFactoryImpl factory = new AppContainerFactoryImpl();        this.appContainer = factory.getAppContainer(appModel, this);        this.windowing = new WindowingIsolateClient();        System.err.println(            this + " config: " + JUMPModulesConfig.getProperties());        String classes = (String)getConfig().get("isolate-init-classes");        if(classes != null) {            StringTokenizer st = new StringTokenizer(classes, ",");            while(st.hasMoreTokens()) {                try {                    Class.forName(st.nextToken()).newInstance();                } catch(Exception e) {                    e.printStackTrace();                    throw new RuntimeException("Initialization failed");                }            }        }    }    //    // Messages to this VM processed here    // For now, all we do is report receipt, send back a success code    // Eventually, we should handle generic messages here, and pass on    // anything we don't know about to the container to process.    //    public void handleMessage(JUMPMessage in) {	JUMPOutgoingMessage responseMessage;	JUMPCommand raw = JUMPRequest.fromMessage(in);	String id = raw.getCommandId();	System.err.println("RECEIVED MESSAGE TYPE "+id);        synchronized (stateChangeMutex) {            dispatchingStateChange = true;        }        try {            // Now let's figure out the type            if (id.equals(JUMPExecutiveLifecycleRequest.ID_START_APP)) {                responseMessage = handleStartAppMessage(in);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -