Search in sources :

Example 11 with Config

use of com.icodici.universa.node2.Config in project nc-reactor-generator by ThizThizzyDizzy.

the class NCPFExporter method saveReactor.

private static void saveReactor(Reactor reactor, FileOutputStream stream) {
    Config react = Config.newConfig();
    react.set("id", 1);
    ConfigNumberList size = new ConfigNumberList();
    size.add((byte) reactor.x);
    size.add((byte) reactor.y);
    size.add((byte) reactor.z);
    react.set("size", size);
    boolean compact = reactor.getEmptySpace() < .25;
    react.set("compact", compact);
    ConfigNumberList blocks = new ConfigNumberList();
    ConfigNumberList fuels = new ConfigNumberList();
    ConfigNumberList sources = new ConfigNumberList();
    ConfigNumberList irradiatorRecipes = new ConfigNumberList();
    for (int x = 0; x < reactor.x; x++) {
        for (int y = 0; y < reactor.x; y++) {
            for (int z = 0; z < reactor.x; z++) {
                ReactorPart part = reactor.parts[x][y][z];
                if (part instanceof FuelCell) {
                    sources.add((byte) ReactorPart.GROUP_CELLS.indexOf(part));
                    fuels.add((byte) (Fuel.fuels.indexOf(reactor.fuel[x][y][z]) * 4 + reactor.fuelType[x][y][z].ordinal()));
                    part = ReactorPart.FUEL_CELL;
                }
                if (part instanceof Irradiator) {
                    irradiatorRecipes.add((byte) 0);
                }
                if (!compact) {
                    blocks.add((byte) x);
                    blocks.add((byte) y);
                    blocks.add((byte) z);
                }
                blocks.add((byte) (ReactorPart.parts.indexOf(part) + 1));
            }
        }
    }
    react.set("blocks", blocks);
    react.set("fuels", fuels);
    react.set("sources", sources);
    react.set("irradiatorRecipes", irradiatorRecipes);
    react.save(stream);
}
Also used : Config(simplelibrary.config2.Config) ConfigNumberList(simplelibrary.config2.ConfigNumberList)

Example 12 with Config

use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.

the class Semicolon method main.

public static void main(String[] args) throws Throwable {
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/comments.conf");
    Config config = Config.getInstance();
    config.get("section", "value");
}
Also used : Config(sun.security.krb5.Config)

Example 13 with Config

use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.

the class ConfigWithQuotations method main.

public static void main(String[] args) throws Exception {
    // This config file is generated using Kerberos.app on a Mac
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/edu.mit.Kerberos");
    Config config = Config.getInstance();
    System.out.println(config);
    if (!config.getDefaultRealm().equals("MAC.LOCAL")) {
        throw new Exception("Realm error");
    }
    if (!config.getKDCList("MAC.LOCAL").equals("kdc.mac.local:88")) {
        throw new Exception("KDC error");
    }
}
Also used : Config(sun.security.krb5.Config)

Example 14 with Config

use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.

the class KDCOptions method setDefault.

private void setDefault() {
    try {
        Config config = Config.getInstance();
        // If key not present, returns Integer.MIN_VALUE, which is
        // almost all zero.
        int options = config.getIntValue("libdefaults", "kdc_default_options");
        if ((options & KDC_OPT_RENEWABLE_OK) == KDC_OPT_RENEWABLE_OK) {
            set(RENEWABLE_OK, true);
        } else {
            if (config.getBooleanValue("libdefaults", "renewable")) {
                set(RENEWABLE_OK, true);
            }
        }
        if ((options & KDC_OPT_PROXIABLE) == KDC_OPT_PROXIABLE) {
            set(PROXIABLE, true);
        } else {
            if (config.getBooleanValue("libdefaults", "proxiable")) {
                set(PROXIABLE, true);
            }
        }
        if ((options & KDC_OPT_FORWARDABLE) == KDC_OPT_FORWARDABLE) {
            set(FORWARDABLE, true);
        } else {
            if (config.getBooleanValue("libdefaults", "forwardable")) {
                set(FORWARDABLE, true);
            }
        }
    } catch (KrbException e) {
        if (DEBUG) {
            System.out.println("Exception in getting default values for " + "KDC Options from the configuration ");
            e.printStackTrace();
        }
    }
}
Also used : Config(sun.security.krb5.Config) KrbException(sun.security.krb5.KrbException)

Example 15 with Config

use of com.icodici.universa.node2.Config in project Payara by payara.

the class WebContainerImpl method setConfiguration.

// --------------------------------------------------------- Public Methods
public void setConfiguration(WebContainerConfig config) {
    if (!initialized) {
        init();
    }
    this.config = config;
    final WebContainerConfig webConfig = config;
    try {
        VirtualServer vs = getVirtualServer(config.getVirtualServerId());
        if (vs != null) {
            ((StandardHost) vs).setDefaultWebXmlLocation(config.getDefaultWebXml().getPath());
        }
        com.sun.enterprise.config.serverbeans.VirtualServer vsBean = httpService.getVirtualServerByName(config.getVirtualServerId());
        if (vsBean != null) {
            ConfigSupport.apply(new SingleConfigCode<com.sun.enterprise.config.serverbeans.VirtualServer>() {

                public Object run(com.sun.enterprise.config.serverbeans.VirtualServer avs) throws PropertyVetoException, TransactionFailure {
                    avs.setId(webConfig.getVirtualServerId());
                    if (webConfig.getDocRootDir() != null) {
                        avs.setDocroot(webConfig.getDocRootDir().getAbsolutePath());
                    }
                    avs.setHosts(webConfig.getHostNames());
                    avs.setNetworkListeners(webConfig.getListenerName());
                    Property property = avs.createChild(Property.class);
                    property.setName("default-web-xml");
                    property.setValue(webConfig.getDefaultWebXml().getPath());
                    avs.getProperty().add(property);
                    return avs;
                }
            }, vsBean);
        } else {
            vs = createVirtualServer(config.getVirtualServerId(), config.getDocRootDir());
            addVirtualServer(vs);
        }
        EmbeddedWebArchivist archivist = habitat.<EmbeddedWebArchivist>getService(EmbeddedWebArchivist.class);
        archivist.setDefaultWebXml(config.getDefaultWebXml());
        embedded.setDirectoryListing(config.getListings());
        WebListener listener = getWebListener(config.getListenerName());
        if (listener == null) {
            listener = getWebListener(config.getPort());
            if (listener == null) {
                boolean found = false;
                for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
                    if (((WebConnector) entry.getValue()).getPort() == config.getPort()) {
                        found = true;
                        log.info("Port " + config.getPort() + " is already configured");
                    }
                }
                if (!found) {
                    listener = createWebListener(config.getListenerName(), HttpListener.class);
                    listener.setPort(config.getPort());
                    addWebListener(listener, config.getVirtualServerId());
                }
            }
        } else {
            if (listener.getPort() != config.getPort()) {
                listener.setPort(config.getPort());
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : WebContainerConfig(org.glassfish.embeddable.web.config.WebContainerConfig) PropertyVetoException(java.beans.PropertyVetoException) GlassFishException(org.glassfish.embeddable.GlassFishException) PropertyVetoException(java.beans.PropertyVetoException) StandardHost(org.apache.catalina.core.StandardHost) org.jvnet.hk2.config(org.jvnet.hk2.config) Property(org.jvnet.hk2.config.types.Property) Map(java.util.Map)

Aggregations

Config (sun.security.krb5.Config)8 Test (org.junit.Test)7 IOException (java.io.IOException)6 Config (simplelibrary.config2.Config)6 KeyAddress (com.icodici.crypto.KeyAddress)5 File (java.io.File)5 TimeoutException (java.util.concurrent.TimeoutException)4 Before (org.junit.Before)3 Timeout (akka.util.Timeout)2 PrivateKey (com.icodici.crypto.PrivateKey)2 com.icodici.universa.contract (com.icodici.universa.contract)2 QuorumVoteRole (com.icodici.universa.contract.roles.QuorumVoteRole)2 com.icodici.universa.contract.services (com.icodici.universa.contract.services)2 Config (com.icodici.universa.node2.Config)2 EventExecutor (io.netty.util.concurrent.EventExecutor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ZonedDateTime (java.time.ZonedDateTime)2 java.util (java.util)2 HashSet (java.util.HashSet)2 java.util.concurrent (java.util.concurrent)2