Example usage for java.lang String intern

List of usage examples for java.lang String intern

Introduction

In this page you can find the example usage for java.lang String intern.

Prototype

public native String intern();

Source Link

Document

Returns a canonical representation for the string object.

Usage

From source file:org.diorite.nbt.NbtAbstractTag.java

@Override
public void setName(String name) {
    if (this.parent != null) {
        this.parent.removeTag(this);
    }//from w  ww . j  ava 2  s. c  o  m
    if (name != null) {
        name = name.intern();
    }
    this.name = name;
    if (this.parent != null) {
        if (this.parent instanceof NbtAnonymousTagContainer) {
            ((NbtAnonymousTagContainer) this.parent).addTag(this);
        } else {
            ((NbtNamedTagContainer) this.parent).addTag(this);
        }
    }
}

From source file:com.qwazr.utils.json.DirectoryJsonManager.java

protected T delete(String name) throws ServerException, IOException {
    if (StringUtils.isEmpty(name))
        return null;
    name = name.intern();
    rwl.writeLock().lock();/*from   w  w w.  j  a  va2 s .  c  o  m*/
    try {
        getFile(name).delete();
        Pair<Long, T> instance = instancesMap.remove(name);
        buildCache();
        return instance.getRight();
    } finally {
        rwl.writeLock().unlock();
    }
}

From source file:com.qwazr.library.cassandra.CassandraCluster.java

public CassandraSession getSession(final String keySpace) {
    if (keySpace == null)
        return getSession();
    checkCluster();//from   w w w  .  j  av a 2 s  .c  o m
    final String fKeySpace = keySpace.intern();

    return rwl.readOrWrite(() -> sessions.get(fKeySpace), () -> {
        CassandraSession session = new CassandraSession(cluster, keySpace);
        sessions.put(keySpace, session);
        return session;
    });
}

From source file:org.wso2.carbon.apimgt.impl.APIManagerFactory.java

public APIProvider getAPIProvider(String username) throws APIManagementException {
    APIProvider provider = providers.get(username);
    if (provider == null) {
        synchronized (username.intern()) {
            provider = providers.get(username);
            if (provider != null) {
                return provider;
            }/*from   w ww. j  a  v  a  2 s .  co  m*/

            provider = newProvider(username);
            providers.put(username, provider);
        }
    }
    return provider;
}

From source file:org.wso2.carbon.apimgt.impl.APIManagerFactory.java

public APIConsumer getAPIConsumer(String username) throws APIManagementException {
    APIConsumer consumer = consumers.get(username);
    if (consumer == null) {
        synchronized (username.intern()) {
            consumer = consumers.get(username);
            if (consumer != null) {
                return consumer;
            }//from w  w  w  . j a  v a 2s  .  c  o  m

            consumer = newConsumer(username);
            consumers.put(username, consumer);
        }
    }
    return consumer;
}

From source file:org.wso2.carbon.appmgt.impl.APIManagerFactory.java

public APIProvider getAPIProvider(String username) throws AppManagementException {
    APIProvider provider = providers.get(username);
    if (provider == null) {
        synchronized (username.intern()) {
            provider = providers.get(username);
            if (provider != null) {
                return provider;
            }//from w  ww  .j  a  v a 2 s  .com

            provider = newProvider(username);
            providers.put(username, provider);
        }
    }
    return provider;
}

From source file:org.wso2.carbon.appmgt.impl.APIManagerFactory.java

public APIConsumer getAPIConsumer(String username) throws AppManagementException {
    APIConsumer consumer = consumers.get(username);
    if (consumer == null) {
        synchronized (username.intern()) {
            consumer = consumers.get(username);
            if (consumer != null) {
                return consumer;
            }/*from ww  w . j av  a  2s .  co  m*/

            consumer = newConsumer(username);
            consumers.put(username, consumer);
        }
    }
    return consumer;
}

From source file:org.apache.synapse.commons.throttle.core.ThrottleReplicator.java

public void add(String key) {
    if (configContext == null) {
        throw new IllegalStateException("ConfigurationContext has not been set");
    }/*from   w w  w  . j av  a2 s.co m*/
    synchronized (key.intern()) {
        set.add(key);
    }
    if (log.isDebugEnabled()) {
        log.trace("Adding key " + key + " to replication list");
    }
}

From source file:com.thoughtworks.go.server.cache.GoCache.java

public boolean remove(String key) {
    synchronized (key.intern()) {
        Object value = getWithoutTransactionCheck(key);
        if (value instanceof KeyList) {
            for (String subKey : (KeyList) value) {
                ehCache.remove(compositeKey(key, subKey));
            }//from   w w w.jav  a2 s.  c  o  m
        }
        return ehCache.remove(key);
    }
}

From source file:org.quartz.impl.jdbcjobstore.JTANonClusteredSemaphore.java

/**
 * Determine whether the calling thread owns a lock on the identified
 * resource.// w w w. jav  a2 s  .  c o m
 */
public synchronized boolean isLockOwner(Connection conn, String lockName) {
    lockName = lockName.intern();

    return getThreadLocks().contains(lockName);
}