Example usage for java.lang Module name

List of usage examples for java.lang Module name

Introduction

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

Prototype

String name

To view the source code for java.lang Module name.

Click Source Link

Usage

From source file:com.sugaronrest.restapicalls.ModuleInfo.java

/**
 * Gets the module model info object./*from  ww  w .  j av a2s.c  o  m*/
 *
 *  @param type The module model type.
 *  @return The model info object.
 */
private static ModuleInfo readByType(Type type) throws Exception {
    ModuleInfo moduleInfo = new ModuleInfo();

    Class<?> moduleClass = (Class<?>) type;

    String moduleName = null;
    String jsonModuleName = null;

    Annotation[] moduleAnnotations = moduleClass.getAnnotations();
    for (Annotation annotation : moduleAnnotations) {
        if (annotation instanceof Module) {
            Module module = (Module) annotation;
            moduleName = module.name();
            jsonModuleName = module.tablename();
        }
    }

    if ((moduleName == null) || (jsonModuleName == null)) {
        return null;
    }

    moduleInfo.name = moduleName;
    moduleInfo.jsonName = jsonModuleName;
    moduleInfo.type = moduleClass;

    List<ModuleProperty> modelProperties = getFieldAnnotations(moduleClass);
    moduleInfo.modelProperties = modelProperties;

    return moduleInfo;
}

From source file:com.sugaronrest.restapicalls.ModuleInfo.java

/**
 * Gets the module model info object.//from  w w w .j  av  a 2 s .c  om
 *
 *  @param moduleName The module model name.
 *  @return The model info object.
 */
private static ModuleInfo readByName(String moduleName) throws Exception {
    ModuleInfo moduleInfo = new ModuleInfo();
    Class moduleClass = getClassFromName(moduleName);
    String jsonModuleName = null;

    if (moduleClass == null) {
        moduleInfo.name = moduleName;
        return moduleInfo;
    }

    Annotation[] moduleAnnotations = moduleClass.getAnnotations();
    for (Annotation annotation : moduleAnnotations) {
        if (annotation instanceof Module) {
            Module module = (Module) annotation;
            moduleName = module.name();
            jsonModuleName = module.tablename();
        }
    }

    if ((moduleName == null) || (jsonModuleName == null)) {
        return null;
    }

    moduleInfo.name = moduleName;
    moduleInfo.jsonName = jsonModuleName;
    moduleInfo.type = moduleClass;

    List<ModuleProperty> modelProperties = getFieldAnnotations(moduleClass);
    moduleInfo.modelProperties = modelProperties;

    return moduleInfo;
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testEmpty() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();
    asset.addModule("com.mycorp", "main");

    List<Module> modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testRejectExcludingDuplicate() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();
    asset.excludeModule("com.mycorp", "main");

    List<Module> modules = asset.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    asset.excludeModule("com.mycorp");

    modules = asset.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    module = modules.get(0);/*from   ww w  .j  av  a 2  s.c o m*/
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testAdditive() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();
    asset.addModule("com.mycorp", "main");

    JBossDeploymentStructureAsset asset2 = new JBossDeploymentStructureAsset(asset.openStream());

    List<Module> modules = asset2.deploymentModules();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    asset2.addModule("com.mycorp.another", "api");

    assertThat(asset2.deploymentExclusions()).isNullOrEmpty();

    modules = asset2.deploymentModules();
    assertThat(modules.size()).isEqualTo(2);
    assertThat(modules.get(0)).isNotNull();
    assertThat(modules.get(1)).isNotNull();

    module = modules.get(0);// w w  w.  ja  v a2  s  . c o m
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.mycorp.another");
    assertThat(module.slot()).isEqualTo("api");
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testExclusion() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();
    asset.excludeModule("com.mycorp", "main");

    JBossDeploymentStructureAsset asset2 = new JBossDeploymentStructureAsset(asset.openStream());

    List<Module> modules = asset2.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    asset2.excludeModule("com.mycorp.more", "special");

    assertThat(asset2.deploymentModules()).isNullOrEmpty();

    modules = asset2.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(2);
    assertThat(modules.get(0)).isNotNull();
    assertThat(modules.get(1)).isNotNull();

    module = modules.get(0);//from www . ja  v a  2s . c o m
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.mycorp.more");
    assertThat(module.slot()).isEqualTo("special");
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testDependencyAndExclusion() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();

    assertThat(asset.deploymentModules()).isNullOrEmpty();
    assertThat(asset.deploymentExclusions()).isNullOrEmpty();

    asset.excludeModule("com.mycorp", "main");

    JBossDeploymentStructureAsset asset2 = new JBossDeploymentStructureAsset(asset.openStream());

    List<Module> modules = asset2.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    Module module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    asset2.excludeModule("com.mycorp.more", "special");

    assertThat(asset2.deploymentModules()).isNullOrEmpty();

    modules = asset2.deploymentExclusions();
    assertThat(modules.size()).isEqualTo(2);
    assertThat(modules.get(0)).isNotNull();
    assertThat(modules.get(1)).isNotNull();

    module = modules.get(0);//from  w ww . j  ava 2s . c  o  m
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");

    module = modules.get(1);
    assertThat(module.name()).isEqualTo("com.mycorp.more");
    assertThat(module.slot()).isEqualTo("special");
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testExistingFileInArchive() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset(
            this.getClass().getClassLoader().getResourceAsStream("jboss-deployment-structure.xml"));

    assertThat(asset.deploymentExclusions().size()).isEqualTo(0);
    assertThat(asset.deploymentModules().size()).isEqualTo(1);

    Module module = asset.deploymentModules().get(0);
    assertThat(module.name()).isEqualTo("org.apache.httpcomponents");
    assertThat(module.export()).isTrue();
    assertThat(module.services()).isEqualTo(Module.ServiceHandling.EXPORT);

    JBossDeploymentStructureAsset asset2 = new JBossDeploymentStructureAsset(asset.openStream());

    module = asset2.deploymentModules().get(0);
    assertThat(module.name()).isEqualTo("org.apache.httpcomponents");
    assertThat(module.export()).isTrue();
    assertThat(module.services()).isEqualTo(Module.ServiceHandling.EXPORT);
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testRejectAddingDuplicate() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();
    Module module = asset.addModule("com.mycorp", "main");
    module.withExport(true);//from   ww  w . ja v  a  2s. com

    List<Module> modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");
    assertThat(module.export()).isTrue();

    asset.addModule("com.mycorp");

    modules = asset.deploymentModules();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");
    assertThat(module.export()).isTrue();
}

From source file:org.wildfly.swarm.spi.api.JBossDeploymentStructureAssetTest.java

@Test
public void testExportPaths() throws Exception {
    JBossDeploymentStructureAsset asset = new JBossDeploymentStructureAsset();

    assertThat(asset.deploymentModules()).isNullOrEmpty();
    assertThat(asset.deploymentExclusions()).isNullOrEmpty();

    Module module = asset.addModule("com.mycorp");
    module.withExport(true);/*from w w  w . jav a  2  s. c  o  m*/
    module.withServices(Module.ServiceHandling.EXPORT);
    module.withExportIncludePath("a/path");
    module.withExportIncludePath("some/path");
    module.withExportExcludePath("**");

    JBossDeploymentStructureAsset asset2 = new JBossDeploymentStructureAsset(asset.openStream());

    List<Module> modules = asset2.deploymentModules();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0)).isNotNull();

    module = modules.get(0);
    assertThat(module.name()).isEqualTo("com.mycorp");
    assertThat(module.slot()).isEqualTo("main");
    assertThat(module.export()).isTrue();
    assertThat(module.services()).isEqualTo(Module.ServiceHandling.EXPORT);
    assertThat(module.exportIncludePaths().size()).isEqualTo(2);
    assertThat(module.exportIncludePaths().get(0)).isEqualTo("a/path");
    assertThat(module.exportIncludePaths().get(1)).isEqualTo("some/path");
    assertThat(module.exportExcludePaths().size()).isEqualTo(1);
    assertThat(module.exportExcludePaths().get(0)).isEqualTo("**");
}