Example usage for java.util Hashtable Hashtable

List of usage examples for java.util Hashtable Hashtable

Introduction

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

Prototype

public Hashtable() 

Source Link

Document

Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).

Usage

From source file:gov.nih.nci.protexpress.util.ConfigurationHelper.java

/**
 * @return the ldap context parameters.//from  www.  j  av a  2  s. c o m
 */
public static Hashtable<String, String> getLdapContextParameters() {
    if (ldapContextParams == null) {
        ldapContextParams = new Hashtable<String, String>();

        ServletContext context = ServletActionContext.getServletContext();
        Enumeration<String> e = context.getInitParameterNames();
        while (e.hasMoreElements()) {
            String param = e.nextElement();
            if (param.startsWith("ldap")) {
                ldapContextParams.put(param, context.getInitParameter(param));
            }
        }
    }
    return ldapContextParams;
}

From source file:com.microsoft.azure.servicebus.samples.jmsqueuequickstart.JmsQueueQuickstart.java

public void run(String connectionString) throws Exception {

    // The connection string builder is the only part of the azure-servicebus SDK library
    // we use in this JMS sample and for the purpose of robustly parsing the Service Bus 
    // connection string. 
    ConnectionStringBuilder csb = new ConnectionStringBuilder(connectionString);

    // set up JNDI context
    Hashtable<String, String> hashtable = new Hashtable<>();
    hashtable.put("connectionfactory.SBCF",
            "amqps://" + csb.getEndpoint().getHost() + "?amqp.idleTimeout=120000&amqp.traceFrames=true");
    hashtable.put("queue.QUEUE", "BasicQueue");
    hashtable.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
    Context context = new InitialContext(hashtable);
    ConnectionFactory cf = (ConnectionFactory) context.lookup("SBCF");

    // Look up queue
    Destination queue = (Destination) context.lookup("QUEUE");

    // we create a scope here so we can use the same set of local variables cleanly 
    // again to show the receive side separately with minimal clutter
    {// www .  j a  v a  2s .co m
        // Create Connection
        Connection connection = cf.createConnection(csb.getSasKeyName(), csb.getSasKey());
        // Create Session, no transaction, client ack
        Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

        // Create producer
        MessageProducer producer = session.createProducer(queue);

        // Send messages
        for (int i = 0; i < totalSend; i++) {
            BytesMessage message = session.createBytesMessage();
            message.writeBytes(String.valueOf(i).getBytes());
            producer.send(message);
            System.out.printf("Sent message %d.\n", i + 1);
        }

        producer.close();
        session.close();
        connection.stop();
        connection.close();
    }

    {
        // Create Connection
        Connection connection = cf.createConnection(csb.getSasKeyName(), csb.getSasKey());
        connection.start();
        // Create Session, no transaction, client ack
        Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        // Create consumer
        MessageConsumer consumer = session.createConsumer(queue);
        // create a listener callback to receive the messages
        consumer.setMessageListener(message -> {
            try {
                // receives message is passed to callback
                System.out.printf("Received message %d with sq#: %s\n", totalReceived.incrementAndGet(), // increments the tracking counter
                        message.getJMSMessageID());
                message.acknowledge();
            } catch (Exception e) {
                logger.error(e);
            }
        });

        // wait on the main thread until all sent messages have been received
        while (totalReceived.get() < totalSend) {
            Thread.sleep(1000);
        }
        consumer.close();
        session.close();
        connection.stop();
        connection.close();
    }

    System.out.printf("Received all messages, exiting the sample.\n");
    System.out.printf("Closing queue client.\n");
}

From source file:org.eclipse.swordfish.core.configuration.ConfigurationConsumerRegistry.java

@Override
protected void doRegister(ConfigurationConsumer configurationConsumer, Map<String, ?> properties)
        throws Exception {
    Assert.notNull(configurationConsumer);
    Dictionary props = new Hashtable();
    LOG.info("Registering configurationConsumer with id = " + configurationConsumer.getId());
    Assert.notNull(configurationConsumer.getId());
    props.put(Constants.SERVICE_PID, configurationConsumer.getId());
    registrations.put(configurationConsumer, bundleContext.registerService(ManagedService.class.getName(),
            new ManagedServiceAdapter(configurationConsumer), props));
    super.doRegister(configurationConsumer, properties);
}

From source file:werecloud.api.controller.v1_0_0.VirtualMachineController.java

@RequestMapping(value = "ping", method = RequestMethod.GET)
public ModelAndView ping() {
    Map<String, Boolean> toRet = new Hashtable<String, Boolean>();
    toRet.put("ping", true);
    return new ModelAndView("json", "model", toRet);
}

From source file:com.yahoo.messenger.manager.YahooMessengerContactListManager.java

protected YahooMessengerContactListManager() {

    YahooMessengerNotificationManager.getInstance();

    contactsHashtable = new Hashtable();
    propertyChangeSupport = new IndexedPropertyChangeSupport();

}

From source file:org.eclipse.swordfish.core.configuration.ConfigurationServiceImpl.java

public <T> void updateConfiguration(String id, Map<String, T> configurationData) {
    try {//from   w ww .j a  v  a2s .co m
        Configuration configuration = configurationAdmin.getConfiguration(id);
        Assert.notNull(configuration, "Could npot find configuration by id = " + id);
        if (configurationData == null) {
            configuration.update(null);
            return;
        }
        Dictionary properties = new Hashtable();
        for (Object key : configurationData.keySet()) {
            properties.put(key, configurationData.get(key));
        }
        configuration.update(properties);
    } catch (Exception ex) {
        throw new SwordfishException(ex);
    }

}

From source file:com.ibm.crail.terasort.ParseTeraOptions.java

ParseTeraOptions() {
    options = new Options();
    sparkParams = new Hashtable<String, String>();

    testNames = new String[] { "loadonly", "loadstore", "loadcount", "loadcountstore", "loadsort",
            "loadsortstore" };
    testIndex = 5; /* loadsortstore is the default */

    serializer = new String[] { "none", "kryo", "byte", "f22" };
    serializerIndex = 0; /* default is none */

    inputDir = null;/*  w ww .j  a v a  2s  . c o m*/
    outputDir = null;
    bufferSize = 4096; //1048576;

    paritionSize = -1;
    isPartitionSet = false;
    syncOutput = false;

    options.addOption("h", "help", false, "show help.");
    options.addOption("n", "testname", true,
            "<string> Name of the test valid tests are :\n" + "1. loadOnly: load and counts the input dataset\n"
                    + "2. loadStore: load the input dataset and stores it\n"
                    + "3. loadCount: load, shuffle, and then count the \n" + "   resulting dataset\n"
                    + "4. loadCountStore: load, shuffle, count, and then \n"
                    + "   store the resulting dataset\n" + "5. loadSort: load, shuffle, and then sort on key \n"
                    + "   the resulting dataset\n" + "6. loadSortStore: load, shuffle, sort on key, then \n"
                    + "   store the resulting dataset\n" + "the default is : loadSortStore");
    options.addOption("i", "inputDir", true, "<string> Name of the input directory");
    options.addOption("o", "outputDir", true, "<string> Name of the output directory");
    options.addOption("S", "sync", true,
            "<int> Takes 0 or 1 to pass to the sync call to the output \n" + "FS while writing (default: 0)");
    options.addOption("p", "partitionSize", true, "<long> Partition size, takes k,m,g,t suffixes\n"
            + "(default: input partition size, HDFS 2.6 has 128MB)");
    options.addOption("s", "useSerializer", true,
            "<string> You can use following serializers: \n" + "none: uses the Spark default serializer \n"
                    + "kryo: optimized Kryo for TeraSort \n" + "byte: a simple byte[] serializer \n"
                    + "f22: an optimized crail-specific byte[] serializer\n"
                    + "     f22 requires CrailShuffleNativeRadixSorter for sorting\n");
    options.addOption("O", "options", true, "string,string : Sets properties on the Spark context. The first \n"
            + "string is the key, and the second is the value");
    options.addOption("b", "bufferSize", true, "<int> Buffer size for Kryo (only valid for kryo)");
    //options.addOption("K", "useKryoOptimizations", true, "<int> use kryoOptimizations (NYI)");
}

From source file:com.android.aft.AFCuteJsonParser.AFCuteJsonParser.java

public AFCuteJsonParser() {
    mActions = new Hashtable<String, Vector<AFJsonAction<?>>>();
}

From source file:bzstats.chart.KillRatioHistoryChart.java

/**
 * @param period//w  w w . j a  va 2  s .co  m
 *            The period to set.
 */
public void setPeriod(EventSequence period) {
    this.period = period;
    series = new Hashtable();
}

From source file:com.yahoo.messenger.reqresp.YahooMessengerCreateSessionReqResp.java

public YahooMessengerCreateSessionReqResp() {

    //  Instantiate only the response parameters that are
    //  objects other than String.

    contactList = new ContactList();
    displayInfo = new Hashtable();

}