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

📄 resourcemanagerfactory.java

📁 aglet的部分源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    });            _map.remove(cs);        }    }    /**     *  Description of the Method     *     * @param  codebase  Description of Parameter     * @param  owner     Description of Parameter     * @param  t         Description of Parameter     * @return           Description of the Returned Value     */    public synchronized ResourceManager createResourceManager(URL codebase,            Certificate owner, ClassName[] t) {        AgletClassLoader loader = getClassLoaderInCache(codebase, owner, t);        log.info("Creating ResourceManager.");        if (loader == null) {            loader = createClassLoader(codebase, owner);        } else {            log.debug("Using cached loader: " + codebase);        }        String ownerName = null;        if (owner != null) {            ownerName =                    ((java.security.cert.X509Certificate) owner).getSubjectDN()                    .getName();        }        return new ResourceManagerImpl(loader, ownerName);    }    /**     * @param  name  Description of Parameter     * @return       Description of the Returned Value     */    public URL lookupCodeBaseFor(String name) {        String codebase = null;        log.debug("lookupCodeBaseFor()++ : ["+name+"]");        try {            codebase = lookupCodeBaseInManifest(name);            // System.out.println("lookupCodeBaseInManifest("+name+")="+codebase);            if (codebase == null) {                codebase = lookupCodeBaseFrom(name, _agletsClassPath);                // System.out.println("lookupCodeBaseFrom("+name+", _agletsClassPath)="+codebase);            }            if (codebase == null) {                return null;            }        } catch (IOException ex) {            ex.printStackTrace();        }        // System.out.println("export root="+_exportRoot);        if (codebase.startsWith(_publicRoot)) {            codebase = _localAddr + File.separatorChar                     + codebase.substring(_publicRoot.length());        } else {            if (codebase.startsWith("/")) {                codebase = "file:" + codebase;            } else {                codebase = "file:/" + codebase;            }        }        URL u;                try {            u = new URL(codebase.replace(File.separatorChar, '/'));        } catch (Exception ex) {            log.error("Error creating URL: ", ex);             u = null;        }        log.debug("lookupCodeBaseFor()-- : ["+u+"]");        return u;    }    /**     *  Gets the classLoaderInCache attribute of the ResourceManagerFactory     *  object     *     * @param  codebase  Description of Parameter     * @param  owner     Description of Parameter     * @param  table     Description of Parameter     * @return           The classLoaderInCache value     */    private AgletClassLoader getClassLoaderInCache(URL codebase,            Certificate owner, ClassName[] table) {        Certificate[] owners;        if (owner != null) {            owners = new Certificate[]{                    owner                    };        } else {            owners = new Certificate[0];        }        CodeSource cs = new CodeSource(codebase, owners);        Vector v = (Vector) _map.get(cs);        log.debug("Looking for cached loader: " + codebase);        if (table == null && JarAgletClassLoader.isJarFile(codebase)) {            log.debug("Codebase is jar file.");            try {                final URL fCodebase = codebase;                ClassName[] tmpTab = (ClassName[]) AccessController.doPrivileged(                    new PrivilegedExceptionAction() {                        public Object run() throws IOException {                            java.io.InputStream in = fCodebase.openStream();                            JarArchive jar = new JarArchive(in);                            // table = jar.getClassNames();                            Archive.Entry ae[] = jar.entries();                            ClassName[] tab = new ClassName[ae.length];                            for (int i = 0; i < ae.length; i++) {                                tab[i] = new ClassName(ae[i].name(),                                        DigestTable.toByteArray(ae[i].digest()));                            }                            // tab = jar.getDigestTable();                            in.close();                            return tab;                            // Nothing to retrun.                        }                    }                        );                table = new ClassName[tmpTab.length];                System.arraycopy(tmpTab, 0, table, 0, table.length);            } catch (PrivilegedActionException ex) {                log.error(ex);            }        }        // REMIND: synchronization. MO        if (v != null) {            Enumeration e = v.elements();            while (e.hasMoreElements()) {                AgletClassLoader loader = (AgletClassLoader) e.nextElement();                if (table == null || loader.matchAndImport(table)) {                    return loader;                }            }        }        return null;    }    /**     *  Description of the Method     *     * @param  codeBase  Description of Parameter     * @param  owner     Description of Parameter     * @return           Description of the Returned Value     */    private AgletClassLoader createClassLoader(URL codeBase,            Certificate owner) {        String oo = null;        if (owner != null) {            oo =                    ((java.security.cert.X509Certificate) owner).getSubjectDN()                    .getName();        }        log.debug("creating AgletClassLoader: for " + codeBase + " : " + oo);        // do not forget the scope!        Certificate[] owners;        if (owner != null) {            owners = new Certificate[]{                    owner                    };        } else {            owners = new Certificate[0];        }        CodeSource cs = new CodeSource(codeBase, owners);        Vector v = (Vector) _map.get(cs);        if (v == null) {            v = new Vector();            _map.put(cs, v);        }        AgletClassLoader loader = null;        try {            if (JarAgletClassLoader.isJarFile(codeBase)) {                loader = new JarAgletClassLoader(codeBase, owner);            } else {                String f = codeBase.getFile();                if (f != null && f.endsWith("/") == false) {                    codeBase = new URL(codeBase, codeBase.getFile() + "/");                }                loader = new AgletClassLoader(codeBase, owner);                for (int i = 0; i < exportedClass.length; i++) {                    loader.cacheResolvedClass(exportedClass[i]);                }            }            v.insertElementAt(loader, 0);        } catch (IOException ex) {            ex.printStackTrace();            loader = null;        }        return loader;    }    /*     *  Just to load classes in the app domain.     */    /**     *  Description of the Class     *     * @author    robert     */    final class AppResourceManager implements ResourceManager {        // private ClassLoader _loader;        /**         *  Constructor for the AppResourceManager object         */        AppResourceManager() { }        /**         *  Sets the resourceManagerContext attribute of the AppResourceManager         *  object         */        public void setResourceManagerContext() { }        /**         *  Gets the archive attribute of the AppResourceManager object         *         * @param  table  Description of Parameter         * @return        The archive value         */        public Archive getArchive(ClassName[] table) {            return null;        }        /**         *  Gets the classNames attribute of the AppResourceManager object         *         * @param  classes  Description of Parameter         * @return          The classNames value         */        public ClassName[] getClassNames(Class[] classes) {            return null;        }        /**         *  Description of the Method         *         * @param  name                        Description of Parameter         * @return                             Description of the Returned Value         * @exception  ClassNotFoundException  Description of Exception         */        public Class loadClass(String name) throws ClassNotFoundException {            return Class.forName(name);        }        /**         *  Description of the Method         *         * @param  cls  Description of Parameter         * @return      Description of the Returned Value         */        public boolean contains(Class cls) {            return cls != null && cls.getClassLoader() == null;        }        /**         *  Description of the Method         *         * @param  a  Description of Parameter         */        public void importArchive(Archive a) { }        /**         *  Adds a feature to the Resource attribute of the AppResourceManager         *  object         *         * @param  obj  The feature to be added to the Resource attribute         */        public void addResource(Object obj) { }        /**         *  Description of the Method         */        public void disposeAllResources() { }        /**         *  Description of the Method         *         * @param  mm  Description of Parameter         * @return     Description of the Returned Value         */        public AgletThread newAgletThread(MessageManager mm) {            return null;        }        /**         *  Description of the Method         */        public void stopAllThreads() { }        /**         *  Description of the Method         */        public void stopThreadGroup() { }        /**         *  Description of the Method         */        public void suspendAllThreads() { }        /**         *  Description of the Method         */        public void resumeAllThreads() { }        /**         *  Description of the Method         */        public void unsetResourceManagerContext() { }    }}

⌨️ 快捷键说明

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