Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

In this page you can find the example usage for java.util Properties get.

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:snoopware.api.UsergridSdkTest.java

@Test
public void testUsergridAuth() throws IOException, URISyntaxException {

    Properties properties = new Properties();
    properties.load(getClass().getResourceAsStream("/app.properties"));

    URI targetUri = new URI((String) properties.get("app.usergridUri"));

    String organizationId = (String) properties.get("org.id");
    String applicationId = (String) properties.get("app.id");
    Client client = new Client(organizationId, applicationId);

    String clientId = (String) properties.get("org.clientId");
    String clientSecret = (String) properties.get("org.clientSecret");
    client.authorizeAppClient(clientId, clientSecret);

    Client.Query queryUsers = client.queryUsers();
    Assert.assertTrue(queryUsers.getResponse().getEntities().size() > 0);
    for (Entity entity : queryUsers.getResponse().getEntities()) {
        log.info("found username: " + entity.getProperties().get("username").asText());
    }/*from   w w w .ja v  a2  s .  c o m*/

    //    {
    //      ApiResponse res = client.apiRequest(HttpMethod.GET, null, null, 
    //        (String)properties.get("org.name"), (String)properties.get("app.name"), "user", "b");
    //      Assert.assertEquals("service_resource_not_found", res.getError());
    //      log.info(res.getStatus());
    //    }
    //
    //    {
    //      ApiResponse res = client.apiRequest(HttpMethod.GET, null, null, 
    //        (String)properties.get("org.name"), (String)properties.get("app.name"), "user", "bob");
    //      Assert.assertEquals(null, res.getError());
    //    }

}

From source file:com.openteach.diamond.rpc.protocol.diamond.DefaultRPCProtocol4ClientFactory.java

@Override
public RPCProtocol4Client newProtocol() {
    try {//from   w ww. j a va 2s . c  om
        Properties properties = this
                .loadConfiguration(String.format("%s-client", DefaultRPCProtocol4Client.PROTOCOL));
        Class clazz = Class.forName(StringUtils.trim((String) properties.get("network.client.factory")));
        NetworkClientFactory clientFactory = (NetworkClientFactory) clazz.newInstance();
        DefaultRPCProtocol4Client protocol = new DefaultRPCProtocol4Client(properties2Configuration(properties),
                clientFactory);
        protocol.initialize();
        protocol.start();
        return protocol;
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    } catch (InstantiationException e) {
        throw new IllegalArgumentException(e);
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:com.openteach.diamond.rpc.protocol.diamond.DefaultRPCProtocol4ServerFactory.java

@Override
public RPCProtocol4Server newProtocol(NetworkRequestHandler handler) {
    try {//from  ww w  .java  2  s  .  co  m
        Properties properties = this
                .loadConfiguration(String.format("%s-server", DefaultRPCProtocol4Server.PROTOCOL));
        Class clazz = Class.forName(StringUtils.trim((String) properties.get("network.server.factory")));
        NetworkServerFactory serverFactory = (NetworkServerFactory) clazz.newInstance();
        DefaultRPCProtocol4Server protocol = new DefaultRPCProtocol4Server(properties2Configuration(properties),
                serverFactory, handler);
        protocol.initialize();
        protocol.start();
        return protocol;
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    } catch (InstantiationException e) {
        throw new IllegalArgumentException(e);
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:com.marvinformatics.hibernate.json.JsonUserType.java

@Override
public void setParameterValues(Properties parameters) {
    final ParameterType reader = (ParameterType) parameters.get(PARAMETER_TYPE);

    if (reader != null)
        this.returnedClass = reader.getReturnedClass();

}

From source file:com.github.horrorho.liquiddonkey.settings.commandline.CommandLineConfigFactory.java

public Config fromArgs(String[] args) {
    logger.trace("<< fromArgs() < {}", (Object) args);
    try {//from  w  w w.  j  av  a 2 s.  co m

        PropertiesFactory factory = PropertiesFactory.create();

        // Fallback defaults
        Properties properties = factory.fromDefaults();

        // Jar defaults
        try {
            String resource = properties.get(Property.PROPERTIES_JAR.name()).toString();
            IOSupplier<InputStream> supplier = () -> this.getClass().getResourceAsStream(resource);
            properties = factory.fromInputStream(properties, supplier);
        } catch (IOException ex) {
            logger.warn("-- fromArgs() > exception: ", ex);
        }

        // Command line args
        CommandLineOptions commandLineOptions = CommandLineOptions.from(properties);
        properties = CommandLinePropertiesFactory.create().from(properties, commandLineOptions, args);

        if (properties.containsKey(Property.COMMAND_LINE_HELP.name())) {
            HelpFormatter helpFormatter = new HelpFormatter();
            helpFormatter.setOptionComparator(null);
            helpFormatter.printHelp(properties.getProperty(Property.APP_NAME.name())
                    + " [OPTION]... (<token> | <appleid> <password>) ", commandLineOptions.options());
            return null;
        }

        if (properties.containsKey(Property.COMMAND_LINE_VERSION.name())) {
            System.out.println(properties.getProperty(Property.PROJECT_VERSION.name()));
            return null;
        }

        // Build config
        Config config = Config.from(properties);

        logger.trace(">> fromArgs() > {}", config);
        return config;

    } catch (ParseException | IllegalArgumentException | IllegalStateException ex) {
        logger.trace("-- fromArgs() > exception: ", ex);
        System.out.println(ex.getLocalizedMessage());
        System.out.println("Try '--help' for more information.");
        return null;
    }
}

From source file:com.qubole.quark.catalog.json.SchemaFactory.java

/**
 * Creates list of QuarkSchema//from www.  j  a v  a 2 s  .  co m
 *
 * @param info A JSON string which represents a RootSchema and its dependent objects.
 * @return
 * @throws QuarkException
 */
public QuarkFactoryResult create(Properties info) throws QuarkException {
    try {
        ObjectMapper objectMapper = new ObjectMapper();
        RootSchema rootSchema = objectMapper.readValue((String) info.get("model"), RootSchema.class);

        ImmutableList.Builder<DataSourceSchema> schemaList = new ImmutableList.Builder<>();

        for (com.qubole.quark.catalog.json.DataSourceSchema secondary : rootSchema.dataSources) {
            schemaList.add(secondary);
        }

        List<DataSourceSchema> schemas = schemaList.build();
        return new QuarkFactoryResult(schemas, rootSchema.relSchema,
                rootSchema.defaultDataSource != null ? schemas.get(rootSchema.defaultDataSource) : null);
    } catch (java.io.IOException e) {
        LOG.error("Unexpected Exception during create", e);
        throw new QuarkException(e);
    }
}

From source file:com.ebay.logstorm.server.platform.spark.SparkExecutionPlatform.java

@Override
public void prepare(Properties properties) {
    this.runner = new SparkPipelineRunner();
    this.sparkRestUrl = (String) properties.get(SparkPipelineRunner.SPARK_DRIVER_KEY);
    this.properties = properties;
}

From source file:coral.CoralHeadServable.java

@Override
public void init(Properties properties, BlockingQueue<Message> loopQueue, Linker linker) {

    shell = (Shell) properties.get("shell");

    if (!properties.containsKey("coral.head.res")) {
        try {// ww  w .  j  av  a 2s  .c  om
            res = File.createTempFile("coral", "server");
            res.delete();
            res.mkdirs();
        } catch (IOException e1) {
            throw new RuntimeException(
                    "problem creating temporary directory for polyp, please specify with coral.polyp.res", e1);
        }
    } else {
        res = new File(properties.getProperty("coral.head.res"), "server_res/");
        res.mkdirs();
    }

    mainfilename = properties.getProperty("coral.head.main", "main.html");

    String sidebarfilename = properties.getProperty("coral.head.sidebar", "servervm/sidebar.html");

    File dir = new File(properties.getProperty("exp.basepath", "./"));
    File sidebarfile = new File(dir, sidebarfilename);

    String sidebartext = "<html><a href='" + CoralUtils.getHostStr() + CoralUtils.SERVER_KEY
            + "/info.vm'>SERVER</a></html>";
    if (sidebarfile.exists()) {
        try {
            sidebartext = new Scanner(sidebarfile).useDelimiter("\\Z").next();
        } catch (FileNotFoundException e) {
            logger.warn("Could not read sidebar file " + sidebarfilename, e);
        }
    }

    try {
        sidebrowser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
        logger.warn("Could not instantiate sidebar Browser: ", e);
        throw new RuntimeException("Could not instantiate Browser", e);
    }

    super.setup();

    browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));

    sidebrowser.setText(sidebartext);
    sidebrowser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

    sidebrowser.addLocationListener(getLocationListener());

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 5;
    gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);

    // Shell shell = new Shell(SWT.NO_TRIM | SWT.ON_TOP);
    // shell.setLayout(new FillLayout());
    // shell.setBounds(Display.getDefault().getPrimaryMonitor().getBounds());

    // shell.setBounds(20,20,1044,788);
    // shell.open();

    // res.mkdirs();

    logger.debug("ready");
}

From source file:com.pangdata.sdk.http.AbstractHttp.java

public AbstractHttp(boolean mustinvoke) {
    try {//w ww.  j av  a2  s .  c o m
        Properties props = SdkUtils.loadPangProperties();

        String username = (String) props.get("pang.username");
        if (username != null && username.trim().length() > 0) {
            this.username = username;
        } else {
            throw new PangException(new IllegalStateException("pang.username not found in pang.properties"));
        }
        String userkey = (String) props.get("pang.userkey");
        if (userkey != null && userkey.trim().length() > 0) {
            this.userkey = userkey;
        } else {
            throw new PangException(new IllegalStateException("pang.userkey not found in pang.properties"));
        }
        String url = (String) props.get("pang.url");
        if (url != null && url.trim().length() > 0) {
            this.url = url;
        }
    } catch (PangException e) {
        logger.error("Property error", e);
        throw e;
    } catch (IOException e) {
        logger.error("Could not find a pang.properties in classpath", e);
        throw new PangException(new FileNotFoundException("pang.properties"));
    }
}

From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadArrayOfObject() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResources(new Resource[] { new ByteArrayResource(
            "foo:\n- bar:\n    spam: crap\n- baz\n- one: two\n  three: four".getBytes()) });
    Properties properties = factory.getObject();
    // System.err.println(properties);
    assertEquals("crap", properties.get("foo[0].bar.spam"));
    assertEquals("baz", properties.get("foo[1]"));
    assertEquals("two", properties.get("foo[2].one"));
    assertEquals("four", properties.get("foo[2].three"));
    assertEquals("{bar={spam=crap}},baz,{one=two, three=four}", properties.get("foo"));
}