Example usage for java.lang Module getName

List of usage examples for java.lang Module getName

Introduction

In this page you can find the example usage for java.lang Module getName.

Prototype

public String getName() 

Source Link

Document

Returns the module name or null if this module is an unnamed module.

Usage

From source file:org.apache.commons.rng.examples.jpms.app.DiceGameApplication.java

/**
 * Display JPMS information./*from w  w w .jav a  2s  .c om*/
 */
private void displayModuleInfo() {
    final StringBuilder str = new StringBuilder();

    for (Module mod : new Module[] { DiceGame.class.getModule(), DiceGameApplication.class.getModule() }) {
        System.out.println("--- " + mod + " ---");
        final ModuleDescriptor desc = mod.getDescriptor();

        for (ModuleDescriptor.Requires r : desc.requires()) {
            System.out.println(mod.getName() + " requires " + r.name());
        }

        System.out.println();
    }
}

From source file:com.powermonitor.epitech.ConfigModules.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);
    AdapterView.AdapterContextMenuInfo minfo = (AdapterView.AdapterContextMenuInfo) info;
    Module r = adapter.getItem(minfo.position);
    _selectionPos = minfo.position;/*from   w  w w. j  ava2 s  . co m*/
    menu.setHeaderTitle(r.getName());
    menu.add(0, 0, 0, "Renommer");
    menu.add(0, 1, 0, "Changer le profil");
    menu.add(0, 2, 0, "Changer le profil interne");
}

From source file:nl.edia.xapi.proxy.impl.TestObjectBuilder.java

public IStatementObject buildActivity(Object target) {
    String id = null;//from w  w w .j  av a 2s  .c  om
    ActivityDefinition definition = new ActivityDefinition();
    if (target instanceof TextExposure) {
        Text text = ((TextExposure) target).getText();
        id = text.getLocation();
        definition.setName(new HashMap<String, String>());
        definition.getName().put(Locale.getDefault().toString(), text.getTitleTxt());
    } else if (target instanceof Text) {
        Text text = ((Text) target);
        id = text.getLocation();
        definition.setName(new HashMap<String, String>());
        definition.getName().put(Locale.getDefault().toString(), text.getTitleTxt());
    } else if (target instanceof TestResult) {
        id = Long.toString(((TestResult) target).getId());
    } else if (target instanceof Module) {
        Module module = (Module) target;
        id = Long.toString(module.getId());
        definition.setName(new HashMap<String, String>());
        definition.setDescription(new HashMap<String, String>());
        definition.getName().put(Locale.getDefault().toString(), module.getName());
        definition.getDescription().put(Locale.getDefault().toString(), module.getDescription());
    } else if (target instanceof Course) {
        Course course = (Course) target;
        id = Long.toString(course.getId());
        definition.setName(new HashMap<String, String>());
        definition.getName().put(Locale.getDefault().toString(), course.getName());
    }

    if (id != null) {
        return new Activity(id, definition);
    }
    LOG.warn("Cannnot build object from object: " + (target == null ? null : target.getClass()));
    return null;
}

From source file:de.juwimm.cms.content.modules.ModuleFactoryStandardImpl.java

public String isModuleValid() {
    String retVal = "";
    Iterator it = this.htModules.values().iterator();
    while (it.hasNext()) {
        Module mod = (Module) it.next();
        log.info("VALIDATION: FOUND MOD " + mod.getName());
        if (!mod.isModuleValid()) {
            if (!retVal.equals(""))
                retVal += "<br><hr>";
            String prepend = Messages.getString("content.moduleFactory.validationPrepend", mod.getLabel());
            String errMsg = mod.getValidationError();
            errMsg = errMsg.replaceAll("[\n]", "<br>");
            retVal += "<font face=\"Arial, Helvetica, sans-serif\"><b>" + prepend + "</b><br>" + errMsg
                    + "</font>";
        }/*from ww w. jav  a 2  s .  co  m*/
    }
    return retVal;
}

From source file:org.whitesource.ant.WhitesourceTask.java

private void scanModules() {
    log("Collecting OSS usage information");

    for (Module module : modules) {
        // create project info
        AgentProjectInfo projectInfo = new AgentProjectInfo();
        if (StringUtils.isBlank(module.getName())) {
            projectInfo.setProjectToken(module.getToken());
            log("Processing module with token " + module.getToken());
        } else {// www  . j  a  va2 s.c  om
            projectInfo.setCoordinates(new Coordinates(null, module.getName(), null));
            log("Processing " + module.getName());
        }

        // get all files located in module paths
        Set<File> filesToUpdate = new HashSet<File>(); // We're using a set in order to avoid chance of duplicate files.
        for (Path path : module.getPaths()) {
            for (String includedFile : path.list()) {
                File file = new File(includedFile);
                if (!file.isDirectory()) {
                    filesToUpdate.add(file);
                }
            }
        }

        // calculate SHA-1 for all files
        Collection<DependencyInfo> dependencies = projectInfo.getDependencies();
        for (File file : filesToUpdate) {
            String fileName = file.getName();
            DependencyInfo dependency = new DependencyInfo();
            dependency.setArtifactId(fileName);
            dependency.setSystemPath(file.getAbsolutePath());
            try {
                dependency.setSha1(ChecksumUtils.calculateSHA1(file));
            } catch (IOException e) {
                log("Problem calculating SHA-1 for '" + fileName + "'", e, Project.MSG_DEBUG);
            }
            dependencies.add(dependency);
        }

        projectInfos.add(projectInfo);
        log("Found " + dependencies.size() + " direct dependencies");
        debugAgentProjectInfos(projectInfos);
    }
}

From source file:org.metamorphosis.core.ModuleManager.java

public void updateModule(Module module) {
    try {//from  w ww.j  a  v  a  2  s .c o  m
        logger.log(Level.INFO, "updating module  : " + module.getName());
        File folder = module.getFolder();
        int index = module.getIndex();
        String id = module.getId();
        module = parse(new File(folder + "/" + MODULE_METADATA));
        module.setFolder(folder);
        module.setIndex(index);
        initModule(module);
        modules.set(index, module);
        configuration.removePackageConfig(id);
        PackageConfig.Builder packageBuilder = new PackageConfig.Builder(module.getId());
        packageBuilder.namespace("/" + module.getUrl());
        packageBuilder.addParent(configuration.getPackageConfig("root"));
        for (Menu menu : module.getMenus()) {
            for (MenuItem item : menu.getMenuItems()) {
                if (!item.getUrl().equals(module.getUrl())) {
                    String url = item.getUrl().substring(module.getUrl().length() + 1);
                    ActionConfig.Builder actionBuilder = new ActionConfig.Builder(url, url, null);
                    ResultConfig.Builder resultBuilder = new ResultConfig.Builder("success",
                            "org.apache.struts2.views.tiles.TilesResult");
                    resultBuilder.addParam("location", item.getUrl());
                    actionBuilder.addResultConfig(resultBuilder.build());
                    ActionConfig actionConfig = actionBuilder.build();
                    packageBuilder.addActionConfig(url, actionConfig);
                }
            }
        }
        for (Action action : module.getActions()) {
            ActionConfig.Builder actionBuilder = new ActionConfig.Builder(action.getUrl(), action.getUrl(),
                    action.getClassName());
            actionBuilder.methodName(action.getMethod());
            for (Result result : action.getResults()) {
                if (!result.getValue().equals("") && !result.getValue().startsWith("/")) {
                    result.setValue(module.getUrl() + "/" + result.getValue());
                }
                String type = result.getType();
                ResultConfig.Builder resultBuilder = null;
                if (type.equals("tiles")) {
                    resultBuilder = new ResultConfig.Builder(result.getName(),
                            "org.apache.struts2.views.tiles.TilesResult");
                } else if (type.equals("redirect")) {
                    resultBuilder = new ResultConfig.Builder(result.getName(),
                            "org.apache.struts2.dispatcher.ServletRedirectResult");
                } else if (type.equals("redirectAction")) {
                    resultBuilder = new ResultConfig.Builder(result.getName(),
                            "org.apache.struts2.dispatcher.ServletActionRedirectResult");
                } else if (type.equals("dispatcher")) {
                    resultBuilder = new ResultConfig.Builder(result.getName(),
                            "org.apache.struts2.dispatcher.ServletDispatcherResult");
                } else if (type.equals("json")) {
                    resultBuilder = new ResultConfig.Builder(result.getName(),
                            "org.apache.struts2.json.JSONResult");
                }
                if (resultBuilder != null) {
                    resultBuilder.addParam("location", result.getValue());
                    for (Parameter parameter : result.getParameters()) {
                        resultBuilder.addParam(parameter.getName(), parameter.getValue());
                    }
                    actionBuilder.addResultConfig(resultBuilder.build());
                }
            }
            ActionConfig actionConfig = actionBuilder.build();
            packageBuilder.addActionConfig(action.getUrl(), actionConfig);
            if (action.getName() != null && action.isGlobal()) {
                servletContext.setAttribute(action.getName(), module.getUrl() + "/" + action.getUrl());
            }
        }
        PackageConfig packageConfig = packageBuilder.build();
        configuration.addPackageConfig(module.getId(), packageConfig);
        configuration.rebuildRuntimeConfiguration();
        registerPages(module);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:uk.codingbadgers.SurvivalPlus.SurvivalPlus.java

private void handleModulesCommand(CommandSender sender) {
    List<Module> modules = m_moduleLoader.getModules();
    String moduleString = ChatColor.GREEN + "Modules(" + modules.size() + "): ";
    boolean first = true;

    for (Module module : modules) {
        moduleString += (first ? "" : ", ") + module.getName();
        first = false;/*from   w ww.jav a2 s  .  c o m*/
    }

    sender.sendMessage(moduleString);
}

From source file:fr.treeptik.cloudunit.service.impl.SnapshotServiceImpl.java

private void backupModule(Module module) {
    Application application;//from   w  w  w  .  j a  v a  2s .co m
    try {
        application = applicationService.findByNameAndUser(module.getApplication().getUser(),
                module.getApplication().getName());
        DockerContainer dockerContainer = new DockerContainer();
        dockerContainer.setName(module.getName() + "-data");
        dockerContainer = DockerContainer.findOne(dockerContainer, application.getManagerIp());
        Map<String, String> configShell = new HashMap<>();
        configShell.put("port", dockerContainer.getPorts().get("22/tcp"));
        configShell.put("dockerManagerAddress", application.getManagerIp());
        String rootPassword = module.getApplication().getUser().getPassword();
        configShell.put("password", rootPassword);
        int code = shellUtils.executeShell("/cloudunit/scripts/backup-data.sh", configShell);
        logger.info("The backup script return : " + code);

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.openmrs.module.ModuleFactory.java

/**
 * Gets the error message of a module which fails to start.
 * //from  w  ww.  j a va  2  s .co m
 * @param module the module that has failed to start.
 * @return the message text.
 */
private static String getFailedToStartModuleMessage(Module module) {
    String[] params = { module.getName(), OpenmrsUtil.join(getMissingRequiredModules(module), ", ") };
    return Context.getMessageSourceService().getMessage("Module.error.moduleCannotBeStarted", params,
            Context.getLocale());
}

From source file:org.whitesource.ant.WhitesourceTask.java

private void validateAndPrepare() {
    // api key//from   ww  w .  j a  v a2  s .  c  om
    if (StringUtils.isBlank(apiKey)) {
        error("Missing API Key");
    }

    // product
    if (StringUtils.isBlank(product)) {
        product = getProject().getName();
    }

    // modules
    if (modules.isEmpty()) {
        Module module = new Module(); // Treat whole project as single module
        module.setName("Default Module");
        addDefaultPaths(module);
        modules.add(module);
    } else {
        int emptyModules = 0;
        for (Module module : modules) {
            if (StringUtils.isBlank(module.getName()) && StringUtils.isBlank(module.getToken())) {
                error("Expecting module name or token");
            }
            if (module.getPaths().isEmpty()) {
                emptyModules++;
            }
        }
        if (emptyModules > 0) {
            if (modules.size() == 1) {
                addDefaultPaths(modules.iterator().next());
            } else {
                error("Path not set");
            }
        }
    }

    // check policies
    if (!checkPolicies.isEmpty()) {
        shouldCheckPolicies = true;
        policyCheck = checkPolicies.iterator().next();
        File reportDir = policyCheck.getReportdir();
        if (reportDir == null) {
            reportDir = new File(this.getProject().getBaseDir(), "reports");
            policyCheck.setReportdir(reportDir);
        }
        if (!reportDir.exists() && !reportDir.mkdirs()) {
            error("Policies report directory doesn't exists and can not be created");
        }
    }
}