Package org.jdesktop.wonderland.modules

Examples of org.jdesktop.wonderland.modules.Module


        /* Fetch thhe error logger for use in this method */
        Logger logger = ModuleManager.getLogger();
       
        /* Fetch the module from the module manager */
        ModuleManager manager = ModuleManager.getModuleManager();
        Module module = manager.getInstalledModules().get(moduleName);
        if (module == null) {
            /* Log an error and return an error response */
            logger.warning("ModuleManager: unable to locate module " + moduleName);
            ResponseBuilder rb = Response.status(Response.Status.BAD_REQUEST);
            return rb.build();
        }

        // For the base URL of assets within a module, use the server URL and
        // point it to the webdav repository
        String hostname = System.getProperty(Constants.WEBSERVER_URL_PROP) + "webdav/content/modules/installed/" + moduleName;

        /* Fetch the module repository, return an error if it does not exist */
        ModuleRepository mr = module.getRepository();
        if (mr == null || mr.getResources() == null || mr.getResources().length == 0) {
            /*
             * If the repository doesn't exist (perhaps from a missing repository.xml
             * file, then create a fallback response with this server as the
             * master.
 
View Full Code Here


        }

        logger.warning("[MODULES] deploying " + order.size() + " modules.");

        for (String name : order) {
            Module module = modules.get(name);

            try {
                this.deployManager.deploy(module);
            } catch (DeployerException excp) {
                /* Log a warning message and continue */
 
View Full Code Here

       
        /* Iterate through each module URL and make it a pending module */
        Iterator<File> it = moduleFiles.iterator();
        while (it.hasNext() == true) {
            File file = it.next();
            Module module = this.pendingMananger.add(file);
            if (module == null) {
                logger.warning("[MODULES] INSTALL Failed to add " + file);
                continue;
            }
            added.add(module);
View Full Code Here

            TaggedModule tm = it.next();
            File file = tm.getFile();
            Map<String, String> attributes = tm.getAttributes();
           
            /* Give the File to the manager of pending modules to add */
            Module module = this.pendingMananger.add(file);
            if (module == null) {
                logger.warning("[MODULES] INSTALL Failed to add " + file);
                continue;
            }
           
            /* See if we want to set attributes on the module and add if so */
            if (attributes != null) {
                ModuleInfo info = module.getInfo();
                info.putAttibutes(attributes);
                File infoFile = module.getFile(Module.MODULE_INFO);
                try {
                    FileWriter writer = new FileWriter(infoFile);
                    info.encode(writer);
                    writer.close();
                } catch (Exception ex) {
View Full Code Here

         */
        Iterator<String> it = moduleNames.iterator();
        Map<String, Module> installed = this.getInstalledModules();
        while (it.hasNext() == true) {
            String moduleName = it.next();
            Module module = installed.get(moduleName);
            logger.warning("ADD TO UNINSTALL " + moduleName + " " + module);
            if (module != null) {
                this.uninstallManager.add(moduleName, module.getInfo());
                removed.add(moduleName);
            }
        }
        return removed;
    }
View Full Code Here

         */
        Map<String, Module> pending = new HashMap(this.pendingMananger.getModules());
        Iterator<Map.Entry<String, Module>> it = pending.entrySet().iterator();
        while (it.hasNext() == true) {
            Map.Entry<String, Module> entry = it.next();
            Module module = entry.getValue();
            DeploymentQueryResult res = this.deployManager.canDeploy(module);
            if (res.getResult() == false) {
                StringBuffer message = new StringBuffer("[MODULES] Unable to install " +
                                                        module.getName() + ":\n");
                for (String reason : res.getReasons()) {
                    message.append(reason + "\n");
                }
                logger.warning(message.toString());
                it.remove();
            }
        }
       
        /*
         * Check to see that the module can be safely installed by making sure
         * that first its dependencies are met.
         */
        Map<Module, List<ModuleInfo>> failures =
                new LinkedHashMap<Module, List<ModuleInfo>>();
        Map<String, Module> passed = this.checkDependencies(pending, failures);

        /* Format a message to describe any failures */
        if (failures.isEmpty() == false) {
            StringBuffer failureMessage = new StringBuffer("[MODULES] Module dependency failures: \n");
            for (Map.Entry<Module, List<ModuleInfo>> e : failures.entrySet()) {
                failureMessage.append("Module " + e.getKey().getName() +
                                      " depends on ");
                for (ModuleInfo depend : e.getValue()) {
                    failureMessage.append(depend.getName() + " ");
                    failureMessage.append(" v. " + depend.getMajor() + ".");
                    failureMessage.append(depend.getMinor() + ".");
                    failureMessage.append(depend.getMini() + " ");
                }
                failureMessage.append("\n");
            }
            logger.warning(failureMessage.toString());
        }


        /*
         * Next check whether the module is overwriting an existing installed
         * module. Make sure that the new version of the module does not
         * violate the dependencies of other modules.
         */
        Iterator<Map.Entry<String, Module>> it1 = passed.entrySet().iterator();
        while (it1.hasNext() == true) {
            Map.Entry<String, Module> entry = it1.next();
            ModuleInfo info = entry.getValue().getInfo();
           
            OverwriteQueryResult res = ModuleOverwriteUtils.canOverwrite(info);
            if (res.getResult() == false) {
                StringBuffer message = new StringBuffer("[MODULES] Unable to replace module " +
                                                        info.getName() + ":\n");
                for (String reason : res.getReasons()) {
                    message.append(reason + "\n");
                }
                logger.warning(message.toString());

                it1.remove();
            }
        }
       
        /*
         * Go ahead and install the module and deploy.  Make sure to do
         * this in a valid deploy order
         */
        List<String> ordered = DeployManager.getDeploymentOrder(passed);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("[MODULES] Calculated deployment order: " + ordered.toString());
        }
       
        for (String moduleName : ordered) {
            Module module = passed.get(moduleName);
           
            /*
             * Check to see if the module is already installed. If we have
             * reached here it means that we can safely uninstall the module.
             * But we first have to undeploy it.
             */
            if (installed.containsKey(moduleName) == true) {
                try {
                    this.deployManager.undeploy(module);
                } catch (DeployerException excp) {
                    logger.log(Level.WARNING, "[MODULES] INSTALL ALL Unable to undeploy " + moduleName, excp);
                }
            }
           
            /*
             * Install the module into the installed/ directory. Fetch the
             * newly installed module (which differs from the pending Module)
             */
            File file = module.getFile();
            module = this.installedMananger.add(moduleName,file);
            if (module == null) {
                logger.warning("[MODULES] INSTALL ALL Failed on " + moduleName);
                continue;
            }
View Full Code Here

        Iterator<Map.Entry<String, ModuleInfo>> it = uninstall.entrySet().iterator();
        Map<String, Module> installed = this.installedMananger.getModules();
        while (it.hasNext() == true) {
            Map.Entry<String, ModuleInfo> entry = it.next();
            String moduleName = entry.getKey();
            Module module = installed.get(moduleName);

            // OWL issue #165: if the module doesn't exist, remove it from
            // the uninstall list and move on. The reference to the file
            // should be removed the next time the uninstall list is
            // written
            if (module == null) {
                logger.warning("Module " + moduleName + " no longer installed. "
                        + "Skipping.");
               
                it.remove();
                continue;
            }

            DeploymentQueryResult res = this.deployManager.canUndeploy(module);
            if (res.getResult() == false) {
                StringBuffer message = new StringBuffer("[MODULES] Unable to uninstall " +
                                                        module.getName() + ":\n");
                for (String reason : res.getReasons()) {
                    message.append(reason + "\n");
                }
                logger.warning(message.toString());
                it.remove();
            }
        }
       
        /*
         * Check to see that the module can be safely removed by making sure that
         * first it is no longer required
         */
        Map<String, Set<ModuleInfo>> failures = new LinkedHashMap<String, Set<ModuleInfo>>();
        Map<String, ModuleInfo> checked = this.checkRequired(uninstall, failures);

        /* Format a message to describe any failures */
        if (failures.isEmpty() == false) {
            StringBuffer failureMessage = new StringBuffer("[MODULES] Module dependency failures: \n");
            for (Map.Entry<String, Set<ModuleInfo>> e : failures.entrySet()) {
                failureMessage.append("Modules that depend on " + e.getKey() + " ");
                for (ModuleInfo depend : e.getValue()) {
                    failureMessage.append(depend.getName() + " ");
                }
                failureMessage.append("\n");
            }
            logger.warning(failureMessage.toString());
        }

        /*
         * For all of the modules that can be uninstalled, undeploy them and
         * uninstall them
         */
        Iterator<Map.Entry<String, ModuleInfo>> it2 = checked.entrySet().iterator();
        while (it2.hasNext() == true) {
            Map.Entry<String, ModuleInfo> entry = it2.next();
            String moduleName = entry.getKey();
           
            /* Undeploy the module, log the error if it happens (should be rare) */
            Module module = installed.get(moduleName);
            try {
                this.deployManager.undeploy(module);
            } catch (DeployerException excp) {
                logger.log(Level.WARNING, "[MODULES] UNINSTALL Failed to Undeploy", excp);
            }
View Full Code Here

        Map<String, Module> installed = this.installedMananger.getModules();
        Iterator<Map.Entry<String, Module>> it = installed.entrySet().iterator();
        while (it.hasNext() == true) {
            Map.Entry<String, Module> entry = it.next();
            String moduleName = entry.getKey();
            Module module = entry.getValue();
            if (module.getInfo().getAttribute(key) != null) {
                keyed.put(moduleName, module);
            }
        }
        return keyed;
    }
View Full Code Here

            /*
             * Fetch the map of modules that this module requires
             */
            Map.Entry<String, Module> entry = it2.next();
            String moduleName = entry.getKey();
            Module module = entry.getValue();
            ModuleInfo info = module.getInfo();
            ModuleRequires requirements = module.getRequires();
           
            /*
             * Loop through each of the requirements of the module and add it
             * to the ModuleRequiredCheck, if it exists. (If it does exist, it
             * means we are checking to see if the module is still required and
View Full Code Here

         */
        HashMap<Module, ModuleDependencyCheck> dependencies = new HashMap();
        Iterator<Map.Entry<String, Module>> it = modules.entrySet().iterator();
        while (it.hasNext() == true) {
            Map.Entry<String, Module> entry = it.next();
            Module module = entry.getValue();
            dependencies.put(module, new ModuleDependencyCheck(module));
        }
       
        /*
         * Fetch a map of installed. Loop through each and see if any of the
         * added modules depends upon the installed module. If so, mark the
         * dependency as met.
         */
        Map<String, Module> present = this.getInstalledModules();
        Iterator<Map.Entry<String, Module>> it2 = present.entrySet().iterator();
        while (it2.hasNext() == true) {
            ModuleInfo potentialDependency = it2.next().getValue().getInfo();
            Iterator<Map.Entry<Module, ModuleDependencyCheck>> it3 = dependencies.entrySet().iterator();
            while (it3.hasNext() == true) {
                ModuleDependencyCheck check = it3.next().getValue();
                check.checkDependency(potentialDependency);
            }
        }
       
        /*
         * Next we need to loop through and see which modules have had their
         * requirements met. When a module has all of its requirements met, then
         * we should add it to the map of satified modules and also remove it
         * from all of the other module dependency checks. We continue checking
         * until we can find no more additional modules requirements met.
         */
        boolean found = true;
        while (found == true) {
            found = false;
            Iterator<Map.Entry<Module, ModuleDependencyCheck>> it4 = dependencies.entrySet().iterator();
            while (it4.hasNext() == true) {
                Map.Entry<Module, ModuleDependencyCheck> entry = it4.next();
                Module module = entry.getKey();
                String moduleName = module.getName();
                ModuleDependencyCheck mdc = entry.getValue();
               
                /*
                 * If the module has all of its requirements met and it is not
                 * already in the map of modules who have had their requirements
                 * met (meaning, this is the first time we see it has had its
                 * requirements met), then...
                 */
                if (mdc.isDependenciesMet() == true && satisfied.containsKey(moduleName) == false) {
                    /* Add it to the 'satified map' */
                    satisfied.put(moduleName, module);
                   
                    /* Remove it from the dependency map using the iterator */
                    it4.remove();
                   
                    /*
                     * Iterator over the remaining dependency check objects. This
                     * part assumes the following works properly in Java: nested
                     * iterations where we just removed an entry from the original
                     * map using the Iterator.remove() method
                     */
                    ModuleInfo moduleInfo = module.getInfo();
                    Iterator<Map.Entry<Module, ModuleDependencyCheck>> it5 = dependencies.entrySet().iterator();
                    while (it5.hasNext() == true) {
                        Map.Entry<Module, ModuleDependencyCheck> check = it5.next();
                        check.getValue().checkDependency(moduleInfo);
                    }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.Module

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.