Package org.jdesktop.wonderland.common.modules

Examples of org.jdesktop.wonderland.common.modules.ModuleList


     * Reloads the list of modules from the server from scratch
     */
    private synchronized void reload() {
        /* Clear out the existing cache, load from the server */
        this.cachedModules.clear();
        ModuleList list = ModuleUtils.fetchModuleList(this.serverURL);
        if (list == null) {
            logger.info("[MODULES] No module information found");
            return;
        }
       
        /* Loop through each and create the module object, insert into map */
        for (ModuleInfo moduleInfo : list.getModuleInfos()) {
            CachedModule cachedModule = new CachedModule(serverURL, moduleInfo);
            this.cachedModules.put(moduleInfo.getName(), cachedModule);
        }
    }
View Full Code Here


        final ServerSessionManager targetServer =
                (ServerSessionManager) targetServerSelector.getSelectedItem();

        // Check we are not about to overwrite an existing module
        String url = targetServer.getServerURL();
        ModuleList moduleList = ModuleUtils.fetchModuleList(url);
        ModuleInfo[] modules = moduleList.getModuleInfos();
        if (modules != null) {
            boolean conflict = false;
            for (int i = 0; i < modules.length && !conflict; i++) {
                if (moduleName.equals(modules[i].getName())) {
                    conflict = true;
View Full Code Here

     */
    @GET
    @Produces({"application/xml", "application/json"})
    public Response getModuleList(@PathParam("state") String state) {
        ModuleManager manager = ModuleManager.getModuleManager();
        ModuleList moduleList = new ModuleList();
       
        /*
         * Check the state given, and fetch the modules. If the module state is
         * invalid, return a BAD_REQUEST error. Otherwise fetch the module list
         * according to the state and return a ModuleList object.
         */
        if (state == null) {
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
        else if (state.equals("installed") == true) {
            Map<String, Module> modules = manager.getInstalledModules();

            // sort in dependecy order
            List<String> ordered = DeployManager.getDeploymentOrder(modules);

            // create the list of infos in the correct order
            Collection<ModuleInfo> list = new LinkedList();
            for (String moduleName : ordered) {
                Module module = modules.get(moduleName);
                list.add(module.getInfo());
            }

            moduleList.setModuleInfos(list.toArray(new ModuleInfo[] {}));
            return Response.ok(moduleList).build();
        }
        else if (state.equals("pending") == true) {
            Map<String, Module> modules = manager.getPendingModules();
            Collection<ModuleInfo> list = new LinkedList();
            Iterator<Map.Entry<String, Module>> it = modules.entrySet().iterator();
            while (it.hasNext() == true) {
                Map.Entry<String, Module> entry = it.next();
                list.add(entry.getValue().getInfo());
            }
            moduleList.setModuleInfos(list.toArray(new ModuleInfo[] {}));
            return Response.ok(moduleList).build();
        }
        else if (state.equals("uninstall") == true) {
            Map<String, ModuleInfo> modules = manager.getUninstallModuleInfos();
            Collection<ModuleInfo> list = new LinkedList();
            Iterator<Map.Entry<String, ModuleInfo>> it = modules.entrySet().iterator();
            while (it.hasNext() == true) {
                Map.Entry<String, ModuleInfo> entry = it.next();
                list.add(entry.getValue());
            }
            moduleList.setModuleInfos(list.toArray(new ModuleInfo[] {}));
            return Response.ok(moduleList).build();
        }
        else {
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.common.modules.ModuleList

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.