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:com.cyclopsgroup.waterview.jelly.JellyScriptsRunner.java

/**
 * Main entry to run a script/*from w w  w . j a  v a2 s. c o  m*/
 *
 * @param args Script paths
 * @throws Exception Throw it out
 */
public static final void main(String[] args) throws Exception {
    List scripts = new ArrayList();
    for (int i = 0; i < args.length; i++) {
        String path = args[i];
        File file = new File(path);
        if (file.isFile()) {
            scripts.add(file.toURL());
        } else {
            Enumeration enu = JellyScriptsRunner.class.getClassLoader().getResources(path);
            CollectionUtils.addAll(scripts, enu);
        }
    }
    if (scripts.isEmpty()) {
        System.out.println("No script to run, return!");
        return;
    }

    String basedir = new File("").getAbsolutePath();
    Properties initProperties = new Properties(System.getProperties());
    initProperties.setProperty("basedir", basedir);
    initProperties.setProperty("plexus.home", basedir);

    WaterviewPlexusContainer container = new WaterviewPlexusContainer();
    for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) {
        String initPropertyName = (String) j.next();
        container.addContextValue(initPropertyName, initProperties.get(initPropertyName));
    }

    container.addContextValue(Waterview.INIT_PROPERTIES, initProperties);
    container.initialize();
    container.start();

    JellyEngine je = (JellyEngine) container.lookup(JellyEngine.ROLE);
    JellyContext jc = new JellyContext(je.getGlobalContext());
    XMLOutput output = XMLOutput.createXMLOutput(System.out);
    for (Iterator i = scripts.iterator(); i.hasNext();) {
        URL script = (URL) i.next();
        System.out.print("Running script " + script);
        ExtendedProperties ep = new ExtendedProperties();
        ep.putAll(initProperties);
        ep.load(script.openStream());
        for (Iterator j = ep.getKeys("script"); j.hasNext();) {
            String name = (String) j.next();
            if (name.endsWith(".file")) {
                File file = new File(ep.getString(name));
                if (file.exists()) {
                    System.out.println("Runner jelly file " + file);
                    jc.runScript(file, output);
                }
            } else if (name.endsWith(".resource")) {
                Enumeration k = JellyScriptsRunner.class.getClassLoader().getResources(ep.getString(name));
                while (j != null && k.hasMoreElements()) {
                    URL s = (URL) k.nextElement();
                    System.out.println("Running jelly script " + s);
                    jc.runScript(s, output);
                }
            }
        }
        //jc.runScript( script, XMLOutput.createDummyXMLOutput() );
        System.out.println("... Done!");
    }
    container.dispose();
}

From source file:com.fiveclouds.jasper.JasperRunner.java

public static void main(String[] args) {

    // Set-up the options for the utility
    Options options = new Options();
    Option report = new Option("report", true, "jasper report to run (i.e. /path/to/report.jrxml)");
    options.addOption(report);//w w w . j  a v a  2s  .  co m

    Option driver = new Option("driver", true, "the jdbc driver class (i.e. com.mysql.jdbc.Driver)");
    driver.setRequired(true);
    options.addOption(driver);

    options.addOption("jdbcurl", true, "database jdbc url (i.e. jdbc:mysql://localhost:3306/database)");
    options.addOption("excel", true, "Will override the PDF default and export to Microsoft Excel");
    options.addOption("username", true, "database username");
    options.addOption("password", true, "database password");
    options.addOption("output", true, "the output filename (i.e. path/to/report.pdf");
    options.addOption("help", false, "print this message");

    Option propertyOption = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("use value as report property").create("D");

    options.addOption(propertyOption);

    // Parse the options and build the report
    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("jasper-runner", options);
        } else {

            System.out.println("Building report " + cmd.getOptionValue("report"));
            try {
                Class.forName(cmd.getOptionValue("driver"));
                Connection connection = DriverManager.getConnection(cmd.getOptionValue("jdbcurl"),
                        cmd.getOptionValue("username"), cmd.getOptionValue("password"));
                System.out.println("Connected to " + cmd.getOptionValue("jdbcurl"));
                JasperReport jasperReport = JasperCompileManager.compileReport(cmd.getOptionValue("report"));

                JRPdfExporter pdfExporter = new JRPdfExporter();

                Properties properties = cmd.getOptionProperties("D");
                Map<String, Object> parameters = new HashMap<String, Object>();

                Map<String, JRParameter> reportParameters = new HashMap<String, JRParameter>();

                for (JRParameter param : jasperReport.getParameters()) {
                    reportParameters.put(param.getName(), param);
                }

                for (Object propertyKey : properties.keySet()) {
                    String parameterName = String.valueOf(propertyKey);
                    String parameterValue = String.valueOf(properties.get(propertyKey));
                    JRParameter reportParam = reportParameters.get(parameterName);

                    if (reportParam != null) {
                        if (reportParam.getValueClass().equals(String.class)) {
                            System.out.println(
                                    "Property " + parameterName + " set to String = " + parameterValue);
                            parameters.put(parameterName, parameterValue);
                        } else if (reportParam.getValueClass().equals(Integer.class)) {
                            System.out.println(
                                    "Property " + parameterName + " set to Integer = " + parameterValue);
                            parameters.put(parameterName, Integer.parseInt(parameterValue));
                        } else {
                            System.err.print("Unsupported type for property " + parameterName);
                            System.exit(1);

                        }
                    } else {
                        System.out.println("Property " + parameterName + " not found in the report! IGNORING");

                    }
                }

                JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, connection);

                pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
                pdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, cmd.getOptionValue("output"));
                System.out.println("Exporting report to " + cmd.getOptionValue("output"));
                pdfExporter.exportReport();
            } catch (JRException e) {
                System.err.print("Unable to parse report file (" + cmd.getOptionValue("r") + ")");
                e.printStackTrace();
                System.exit(1);
            } catch (ClassNotFoundException e) {
                System.err.print("Unable to find the database driver,  is it on the classpath?");
                e.printStackTrace();
                System.exit(1);
            } catch (SQLException e) {
                System.err.print("An SQL exception has occurred (" + e.getMessage() + ")");
                e.printStackTrace();
                System.exit(1);
            }
        }
    } catch (ParseException e) {
        System.err.print("Unable to parse command line options (" + e.getMessage() + ")");
        System.exit(1);
    }
}

From source file:edu.osu.ling.pep.Pep.java

/**
 * Invokes Pep from the command line./*from  w  w  w .ja va 2s  . c  om*/
 * <p>
 * The main work this method does, apart from tokenizing the arguments and
 * input tokens, is to load and parse the XML grammar file (as specified by
 * <code>-g</code> or <code>--grammar</code>). If any of the arguments
 * <code>-g</code>, <code>--grammar</code>, <code>-s</code>,
 * <code>--seed</code>, <code>-o</code>, <code>--option</code>, occur with
 * no argument following, this method prints an error notifying the user.
 * 
 * @param args
 *            The expected arguments are as follows, and can occur in any
 *            particular order:
 *            <ul>
 *            <li><code>-g|--grammar &lt;grammar file&gt;</code></li> <li>
 *            <code>-s|--seed &lt;seed category&gt;</code></li> <li><code>
 *            -v|--verbose {verbosity level}</code></li> <li><code>
 *            -o|--option &lt;OPTION_NAME=value&gt;</code></li> <li><code>
 *            -h|--help (prints usage information)</code></li> <li><code>
 *            &lt;token1 ... token<em>n</em>&gt;</code> (or <code>-</code>
 *            for standard input)</li>
 *            </ul>
 *            <code>OPTION_NAME</code> must be the name of one of the
 *            recognized {@link ParserOption options}. If <code>-h</code> or
 *            <code>--help</code> occur anywhere in the arguments, usage
 *            information is printed and no parsing takes place.
 */
@SuppressWarnings("static-access")
public static final void main(final String[] args) {
    try {
        final Options opts = new Options();

        opts.addOption(OptionBuilder.withLongOpt("grammar").withDescription("the grammar to use").hasArg()
                .isRequired().withArgName("grammar file").create('g'));

        opts.addOption(OptionBuilder.withLongOpt("seed").withDescription("the seed category to parse for")
                .hasArg().isRequired().withArgName("seed category").create('s'));

        opts.addOption(OptionBuilder.withLongOpt("verbose").withDescription("0-3").hasOptionalArg()
                .withArgName("verbosity level").create('v'));

        opts.addOption(OptionBuilder.withLongOpt("option").withDescription("sets parser options")
                .withArgName("OPTION=value").hasArgs(2).withValueSeparator()
                .withDescription("use value for given property").create("o"));

        opts.addOption(OptionBuilder.withLongOpt("help").withDescription("prints this message").create('h'));

        final CommandLineParser parser = new GnuParser();
        try {
            final CommandLine line = parser.parse(opts, args);
            if (line.hasOption('h')) {
                Pep.printHelp(opts);
            } else {
                final int v = Integer.parseInt(line.getOptionValue('v', Integer.toString(Pep.V_PARSE)));
                if (v < 0) {
                    throw new PepException("verbosity < 0: " + v);
                }

                Pep.verbosity = v;
                final Map<ParserOption, Boolean> options = new EnumMap<ParserOption, Boolean>(
                        ParserOption.class);

                final Properties props = line.getOptionProperties("o");
                for (final Object key : props.keySet()) {
                    try {
                        options.put(ParserOption.valueOf(key.toString()),
                                Boolean.valueOf(props.get(key).toString()));
                    } catch (final IllegalArgumentException iae) {
                        Pep.printError("no option named " + key.toString());
                        Pep.printHelp(opts);
                        return;
                    }
                }

                final Pep pep = new Pep(options);
                // final Grammar grammar =
                // new GrammarParser(Pep.findGrammar(line
                // .getOptionValue('g'))).t.parse();

                final List<?> ts = line.getArgList();
                List<String> tokens = null;
                if (ts.isEmpty() || ts.get(0).equals("-")) {
                    tokens = Pep.readTokens(new Scanner(System.in));
                } else {
                    tokens = new ArrayList<String>(ts.size());
                    for (final Object t : ts) {
                        tokens.add(t.toString());
                    }
                }

                pep.lastParseStart = System.currentTimeMillis();
                // try {
                // pep.parse(grammar, tokens,
                // new Category(line.getOptionValue('s')));
                // } catch (final PepException ignore) {
                // // ignore here, we're listening
                // }
            }
        } catch (final ParseException pe) {
            Pep.printError("command-line syntax problem: " + pe.getMessage());
            Pep.printHelp(opts);
        }
    } catch (final PepException pe) {
        final Throwable cause = pe.getCause();
        Pep.printError((cause == null) ? pe : cause);
    } catch (final RuntimeException re) {
        Pep.printError(re);
    }
}

From source file:org.objectrepository.MessageConsumerDaemon.java

/**
 * main//  www  . java  2  s  .c  o m
 * <p/>
 * Accepts one folder as argument:  -messageQueues
 * That folder ought to contain one or more folders ( or symbolic links ) to the files
 * The folder has the format: [foldername] or [foldername].[maxTasks]
 * MaxTasks is to indicate the total number of jobs being able to run.
 *
 * long
 *
 * @param argv
 */
public static void main(String[] argv) {

    if (instance == null) {
        final Properties properties = new Properties();

        if (argv.length > 0) {
            for (int i = 0; i < argv.length; i += 2) {
                try {
                    properties.put(argv[i], argv[i + 1]);
                } catch (ArrayIndexOutOfBoundsException arr) {
                    System.out.println("Missing value after parameter " + argv[i]);
                    System.exit(-1);
                }
            }
        } else {
            log.fatal("Usage: pmq-agent.jar -messageQueues [queues] -heartbeatInterval [interval in ms]\n"
                    + "The queues is a folder that contains symbolic links to the startup scripts.");
            System.exit(-1);
        }

        if (log.isInfoEnabled()) {
            log.info("Arguments set: ");
            for (String key : properties.stringPropertyNames()) {
                log.info("'" + key + "'='" + properties.getProperty(key) + "'");
            }
        }

        if (!properties.containsKey("-messageQueues")) {
            log.fatal("Expected case sensitive parameter: -messageQueues");
            System.exit(-1);
        }

        final File messageQueues = new File((String) properties.get("-messageQueues"));
        if (!messageQueues.exists()) {
            log.fatal("Cannot find folder for messageQueues: " + messageQueues.getAbsolutePath());
            System.exit(-1);
        }

        if (messageQueues.isFile()) {
            log.fatal(
                    "-messageQueues should point to a folder, not a file: " + messageQueues.getAbsolutePath());
            System.exit(-1);
        }

        long heartbeatInterval = 600000;
        if (properties.containsKey("-heartbeatInterval")) {
            heartbeatInterval = Long.parseLong((String) properties.get("heartbeatInterval"));
        }

        String identifier = null;
        if (properties.containsKey("-id")) {
            identifier = (String) properties.get("-id");
        } else if (properties.containsKey("-identifier")) {
            identifier = (String) properties.get("-identifier");
        }

        final File[] files = messageQueues.listFiles();
        final String[] scriptNames = (properties.containsKey("-startup"))
                ? new String[] { properties.getProperty("-startup") }
                : new String[] { "/startup.sh", "\\startup.bat" };
        final List<Queue> queues = new ArrayList<Queue>();
        for (File file : files) {
            final String name = file.getName();
            final String[] split = name.split("\\.", 2);
            final String queueName = split[0];
            for (String scriptName : scriptNames) {
                final String shellScript = file.getAbsolutePath() + scriptName;
                final int maxTask = (split.length == 1) ? 1 : Integer.parseInt(split[1]);
                log.info("Candidate mq client for " + queueName + " maxTasks " + maxTask);
                if (new File(shellScript).exists()) {
                    final Queue queue = new Queue(queueName, shellScript, false);
                    queue.setCorePoolSize(1);
                    queue.setMaxPoolSize(maxTask);
                    queue.setQueueCapacity(1);
                    queues.add(queue);
                    break;
                } else {
                    log.warn("... skipping, because no startup script found at " + shellScript);
                }
            }
        }

        if (queues.size() == 0) {
            log.fatal("No queue folders seen in " + messageQueues.getAbsolutePath());
            System.exit(-1);
        }

        // Add the system queue
        queues.add(new Queue("Connection", null, true));

        getInstance(queues, identifier, heartbeatInterval).run();
    }
    System.exit(0);
}

From source file:com.mgreau.jboss.as7.cli.CliLauncher.java

public static void main(String[] args) throws Exception {
    int exitCode = 0;
    CommandContext cmdCtx = null;/*from   www .j av  a  2 s.  c o  m*/
    boolean gui = false;
    String appName = "";
    try {
        String argError = null;
        List<String> commands = null;
        File file = null;
        boolean connect = false;
        String defaultControllerProtocol = "http-remoting";
        String defaultControllerHost = null;
        int defaultControllerPort = -1;
        boolean version = false;
        String username = null;
        char[] password = null;
        int connectionTimeout = -1;

        //App deployment
        boolean isAppDeployment = false;
        final Properties props = new Properties();

        for (String arg : args) {
            if (arg.startsWith("--controller=") || arg.startsWith("controller=")) {
                final String fullValue;
                final String value;
                if (arg.startsWith("--")) {
                    fullValue = arg.substring(13);
                } else {
                    fullValue = arg.substring(11);
                }
                final int protocolEnd = fullValue.lastIndexOf("://");
                if (protocolEnd == -1) {
                    value = fullValue;
                } else {
                    value = fullValue.substring(protocolEnd + 3);
                    defaultControllerProtocol = fullValue.substring(0, protocolEnd);
                }

                String portStr = null;
                int colonIndex = value.lastIndexOf(':');
                if (colonIndex < 0) {
                    // default port
                    defaultControllerHost = value;
                } else if (colonIndex == 0) {
                    // default host
                    portStr = value.substring(1);
                } else {
                    final boolean hasPort;
                    int closeBracket = value.lastIndexOf(']');
                    if (closeBracket != -1) {
                        //possible ip v6
                        if (closeBracket > colonIndex) {
                            hasPort = false;
                        } else {
                            hasPort = true;
                        }
                    } else {
                        //probably ip v4
                        hasPort = true;
                    }
                    if (hasPort) {
                        defaultControllerHost = value.substring(0, colonIndex).trim();
                        portStr = value.substring(colonIndex + 1).trim();
                    } else {
                        defaultControllerHost = value;
                    }
                }

                if (portStr != null) {
                    int port = -1;
                    try {
                        port = Integer.parseInt(portStr);
                        if (port < 0) {
                            argError = "The port must be a valid non-negative integer: '" + args + "'";
                        } else {
                            defaultControllerPort = port;
                        }
                    } catch (NumberFormatException e) {
                        argError = "The port must be a valid non-negative integer: '" + arg + "'";
                    }
                }
            } else if ("--connect".equals(arg) || "-c".equals(arg)) {
                connect = true;
            } else if ("--version".equals(arg)) {
                version = true;
            } else if ("--gui".equals(arg)) {
                gui = true;
            } else if (arg.startsWith("--appDeployment=") || arg.startsWith("appDeployment=")) {
                isAppDeployment = true;
                appName = arg.startsWith("--") ? arg.substring(16) : arg.substring(14);
            } else if (arg.startsWith("--file=") || arg.startsWith("file=")) {
                if (file != null) {
                    argError = "Duplicate argument '--file'.";
                    break;
                }
                if (commands != null) {
                    argError = "Only one of '--file', '--commands' or '--command' can appear as the argument at a time.";
                    break;
                }

                final String fileName = arg.startsWith("--") ? arg.substring(7) : arg.substring(5);
                if (!fileName.isEmpty()) {
                    file = new File(fileName);
                    if (!file.exists()) {
                        argError = "File " + file.getAbsolutePath() + " doesn't exist.";
                        break;
                    }
                } else {
                    argError = "Argument '--file' is missing value.";
                    break;
                }
            } else if (arg.startsWith("--commands=") || arg.startsWith("commands=")) {
                if (file != null) {
                    argError = "Only one of '--file', '--commands' or '--command' can appear as the argument at a time.";
                    break;
                }
                if (commands != null) {
                    argError = "Duplicate argument '--command'/'--commands'.";
                    break;
                }
                final String value = arg.startsWith("--") ? arg.substring(11) : arg.substring(9);
                commands = Util.splitCommands(value);
            } else if (arg.startsWith("--command=") || arg.startsWith("command=")) {
                if (file != null) {
                    argError = "Only one of '--file', '--commands' or '--command' can appear as the argument at a time.";
                    break;
                }
                if (commands != null) {
                    argError = "Duplicate argument '--command'/'--commands'.";
                    break;
                }
                final String value = arg.startsWith("--") ? arg.substring(10) : arg.substring(8);
                commands = Collections.singletonList(value);
            } else if (arg.startsWith("--user=")) {
                username = arg.startsWith("--") ? arg.substring(7) : arg.substring(5);
            } else if (arg.startsWith("--password=")) {
                password = (arg.startsWith("--") ? arg.substring(11) : arg.substring(9)).toCharArray();
            } else if (arg.startsWith("--timeout=")) {
                if (connectionTimeout > 0) {
                    argError = "Duplicate argument '--timeout'";
                    break;
                }
                final String value = arg.substring(10);
                try {
                    connectionTimeout = Integer.parseInt(value);
                } catch (final NumberFormatException e) {
                    //
                }
                if (connectionTimeout <= 0) {
                    argError = "The timeout must be a valid positive integer: '" + value + "'";
                }
            } else if (arg.equals("--help") || arg.equals("-h")) {
                commands = Collections.singletonList("help");
            } else if (arg.startsWith("--properties=")) {
                final String value = arg.substring(13);
                final File propertiesFile = new File(value);
                if (!propertiesFile.exists()) {
                    argError = "File doesn't exist: " + propertiesFile.getAbsolutePath();
                    break;
                }

                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(propertiesFile);
                    props.load(fis);
                } catch (FileNotFoundException e) {
                    argError = e.getLocalizedMessage();
                    break;
                } catch (java.io.IOException e) {
                    argError = "Failed to load properties from " + propertiesFile.getAbsolutePath() + ": "
                            + e.getLocalizedMessage();
                    break;
                } finally {
                    if (fis != null) {
                        try {
                            fis.close();
                        } catch (java.io.IOException e) {
                        }
                    }
                }
                for (final Object prop : props.keySet()) {
                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
                        public Object run() {
                            System.setProperty((String) prop, (String) props.get(prop));
                            return null;
                        }
                    });
                }
            } else if (!(arg.startsWith("-D") || arg.equals("-XX:"))) {// skip system properties and jvm options
                // assume it's commands
                if (file != null) {
                    argError = "Only one of '--file', '--commands' or '--command' can appear as the argument at a time: "
                            + arg;
                    break;
                }
                if (commands != null) {
                    argError = "Duplicate argument '--command'/'--commands'.";
                    break;
                }
                commands = Util.splitCommands(arg);
            }
        }

        if (argError != null) {
            System.err.println(argError);
            exitCode = 1;
            return;
        }

        if (version) {
            cmdCtx = initCommandContext(defaultControllerProtocol, defaultControllerHost, defaultControllerPort,
                    username, password, false, connect, connectionTimeout);
            VersionHandler.INSTANCE.handle(cmdCtx);
            return;
        }

        if (file != null) {
            cmdCtx = initCommandContext(defaultControllerProtocol, defaultControllerHost, defaultControllerPort,
                    username, password, false, connect, connectionTimeout);
            processFile(file, cmdCtx, isAppDeployment, appName, props);
            return;
        }

        if (commands != null) {
            cmdCtx = initCommandContext(defaultControllerProtocol, defaultControllerHost, defaultControllerPort,
                    username, password, false, connect, connectionTimeout);
            processCommands(commands, cmdCtx);
            return;
        }

        // Interactive mode
        cmdCtx = initCommandContext(defaultControllerProtocol, defaultControllerHost, defaultControllerPort,
                username, password, true, connect, connectionTimeout);
        cmdCtx.interact();
    } catch (Throwable t) {
        t.printStackTrace();
        exitCode = 1;
    } finally {
        if (cmdCtx != null && cmdCtx.getExitCode() != 0) {
            exitCode = cmdCtx.getExitCode();
        }
        if (!gui) {
            System.exit(exitCode);
        }
    }
    System.exit(exitCode);
}

From source file:cd.go.authentication.ldap.utils.Util.java

public static String pluginId() {
    String s = readResource("/plugin.properties");
    try {//w  ww  .ja va2  s.  com
        Properties properties = new Properties();
        properties.load(new StringReader(s));
        return (String) properties.get("pluginId");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.impetus.client.cassandra.pelops.PelopsUtils.java

/**
 * Generate pool name./*ww w . j a v a2  s. co  m*/
 * 
 * @param persistenceUnit
 *            the persistence unit
 * @return the string
 */
public static String generatePoolName(String persistenceUnit) {
    PersistenceUnitMetadata persistenceUnitMetadatata = KunderaMetadata.INSTANCE.getApplicationMetadata()
            .getPersistenceUnitMetadata(persistenceUnit);
    Properties props = persistenceUnitMetadatata.getProperties();
    String contactNodes = (String) props.get(PersistenceProperties.KUNDERA_NODES);
    String defaultPort = (String) props.get(PersistenceProperties.KUNDERA_PORT);
    String keyspace = (String) props.get(PersistenceProperties.KUNDERA_KEYSPACE);

    return contactNodes + ":" + defaultPort + ":" + keyspace;
}

From source file:uk.org.openeyes.oink.it.ITSupport.java

public static IGenericClient buildHapiClientForFacade(Properties proxyProps) {
    String proxyUri = (String) proxyProps.get("proxy.uri");

    // Create a context and get the client factory so it can be configured
    FhirContext ctx = new FhirContext();
    IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();

    // Create an HTTP Client Builder
    HttpClientBuilder builder = HttpClientBuilder.create();

    // This interceptor adds HTTP username/password to every request
    String username = (String) proxyProps.get("proxy.username");
    String password = (String) proxyProps.get("proxy.password");
    builder.addInterceptorFirst(new HttpBasicAuthInterceptor(username, password));

    builder.addInterceptorFirst(new HttpRequestInterceptor() {

        @Override/* www .  ja v a2  s. c om*/
        public void process(HttpRequest req, HttpContext context) throws HttpException, IOException {
            req.addHeader("Accept", "application/json+fhir; charset=UTF-8");
        }
    });

    // Use the new HTTP client builder
    clientFactory.setHttpClient(builder.build());

    IGenericClient client = clientFactory.newGenericClient("http://" + proxyUri);

    return client;
}

From source file:com.fjn.helper.frameworkex.webservice.xfire.XFireHelper.java

/**
 * classPathfilepath,??serviceNameSEI/*w ww .  j  a  va 2 s  .c o  m*/
 * @param filepath
 * @param serviceName
 * @param serviceEndpointInterface (SEI)
 * @return
 */
public static <T> T getEndpoint(String filepath, String serviceName, Class<T> serviceEndpointInterface) {
    T endpoint = null;
    InputStream in = ResourceFinder.getInputStreamFromClassPath(filepath);
    Properties props = ResourceFinder.loadPropreties(in);
    if (props == null)
        return null;

    String wsdlURL = props.get(serviceName).toString();
    log.info(wsdlURL);
    if (StringUtil.isNull(wsdlURL))
        return null;

    if (StringUtil.endsWithIgnoreCase(wsdlURL, "?wsdl")) {
        wsdlURL = wsdlURL.substring(0, wsdlURL.length() - 5);
    }
    endpoint = getEndpoint(wsdlURL, serviceEndpointInterface);
    return endpoint;
}

From source file:eagle.storage.DataStorageManager.java

/**
 * Get data storage by properties/*w w  w  .  j a v a2 s .c o m*/
 *
 * @param properties
 * @return
 * @throws IllegalDataStorageTypeException
 */
public static DataStorage newDataStorage(Properties properties) throws IllegalDataStorageTypeException {
    String storageType = (String) properties.get(EAGLE_STORAGE_TYPE);
    if (storageType == null) {
        LOG.error(EAGLE_STORAGE_TYPE + " is null");
        throw new IllegalDataStorageTypeException(EAGLE_STORAGE_TYPE + " is null");
    }
    return newDataStorage(storageType);
}