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.wso2.carbon.appfactory.deployers.AbstractStratosDeployer.java

/**
 * deploying artifacts/*from   w  ww. j a v a 2 s  .  c  om*/
 *
 * @param artifactType      type of the artifact war /jaxrs/jaxws etc.
 * @param artifactsToDeploy current artifact to deploy
 * @param parameters        hash map with values needed to deploy an artifact
 * @param notify            notify after deployment happens
 * @throws AppFactoryException
 */
protected void deploy(String artifactType, File[] artifactsToDeploy, Map<String, String[]> parameters,
        Boolean notify) throws AppFactoryException {

    String applicatonId = DeployerUtil.getParameter(parameters, AppFactoryConstants.APPLICATION_ID);
    String currentVersion = DeployerUtil.getParameter(parameters, AppFactoryConstants.APPLICATION_VERSION);
    String deployStage = DeployerUtil.getParameter(parameters, AppFactoryConstants.DEPLOY_STAGE);
    String serverDeploymentPath = DeployerUtil.getParameter(parameters,
            AppFactoryConstants.SERVER_DEPLOYMENT_PATHS);
    String tenantDomain = DeployerUtil.getParameter(parameters, AppFactoryConstants.TENANT_DOMAIN);
    //TODO move tenantId to a constant
    int tenantId = Integer.parseInt(DeployerUtil.getParameter(parameters, "tenantId"));

    String condition = applicatonId + AppFactoryConstants.MINUS + currentVersion + AppFactoryConstants.MINUS
            + deployStage + AppFactoryConstants.MINUS + tenantDomain;
    synchronized (condition.intern()) {

        for (File artifactToDeploy : artifactsToDeploy) {
            String fileName = artifactToDeploy.getName();
            addToGitRepo(fileName, artifactToDeploy, parameters, artifactType, serverDeploymentPath, null,
                    tenantDomain, tenantId);
        }

        if (notify) {
            // git uses "master" for the main branch while , we need to parse "trunk" here for the main branch
            if (AppFactoryConstants.MASTER.equals(currentVersion)) {
                postDeploymentNoifier(null, applicatonId, AppFactoryConstants.TRUNK, artifactType, deployStage,
                        tenantDomain);
            } else {
                postDeploymentNoifier(null, applicatonId, currentVersion, artifactType, deployStage,
                        tenantDomain);
            }
        }
    }
}

From source file:org.diorite.chat.placeholder.PlaceholderType.java

/**
 * Construct new placeholder type for given id and class without any super types.
 *
 * @param id   id of placeholder./*w  w w  .j av  a 2s . c  o m*/
 * @param type type of placeholder object.
 */
public PlaceholderType(final String id, final Class<T> type) {
    this.id = id.intern();
    this.type = type;
    this.superTypes = new HashSet<>(3);
}

From source file:org.opennms.netmgt.xml.eventconf.Maskelement.java

/**
 * /*from w  w  w . j a v  a  2 s.com*/
 * 
 * @param vMevalue
 * @throws IndexOutOfBoundsException if the index
 * given is outside the bounds of the collection
 */
public void addMevalue(final String vMevalue) throws IndexOutOfBoundsException {
    this.m_mevalueList.add(vMevalue.intern());
}

From source file:org.protempa.AbstractPropositionDefinition.java

/**
 * Creates a new knowledge definition.//from   w w w  .  j  a v a2  s  .co m
 *
 * @param id the requested {@link String} id of propositions created by this
 * definition. If <code>null</code> or already taken by another knowledge
 * definition, another id will be assigned (check with
 * <code>getId()</code>).
 */
AbstractPropositionDefinition(String id) {
    if (id == null) {
        throw new IllegalArgumentException("id cannot be null");
    }
    this.id = id.intern();
    this.propositionId = this.id;
    this.children = ArrayUtils.EMPTY_STRING_ARRAY;
    this.inverseIsA = ArrayUtils.EMPTY_STRING_ARRAY;
    this.termIds = ArrayUtils.EMPTY_STRING_ARRAY;
    this.displayName = "";
    this.abbrevDisplayName = "";
    this.description = "";
    this.propertyDefinitions = EMPTY_PROPERTIES;
    this.referenceDefinitions = EMPTY_REFERENCES;
    this.sourceId = NotRecordedSourceId.getInstance();
    this.attributes = EMPTY_ATTRIBUTES;
}

From source file:org.apache.hadoop.chukwa.dataloader.FSMDataLoader.java

public void load(ChukwaConfiguration conf, FileSystem fs, FileStatus[] fileList) throws IOException {

    if (executor == null) {
        try {//from   ww  w  .  jav  a2s  .c o m
            this.size = Integer.parseInt(conf.get(DATA_LOADER_THREAD_LIMIT));
        } catch (Exception e) {
            this.size = 1;
        }
        executor = Executors.newFixedThreadPool(size);
    }
    if (completion == null) {
        completion = new ExecutorCompletionService(executor);
    }

    try {
        // Locate directory output directories of the current demux, and create a unique directory list.
        HashSet<Path> inputPaths = new HashSet<Path>();
        HashSet<Path> outputPaths = new HashSet<Path>();
        int counter = 0;
        for (int i = 0; i < fileList.length; i++) {
            Path temp = fileList[i].getPath().getParent();
            if (!inputPaths.contains(temp)) {
                inputPaths.add(temp);
            }
        }
        String outputDir = conf.get("chukwa.tmp.data.dir") + File.separator + "fsm_"
                + System.currentTimeMillis() + "_";
        if (inputPaths.size() > 0) {
            Configuration fsmConf = new Configuration();
            // Run fsm map reduce job for dn, tt, and jobhist.
            for (String mapper : mappers) {
                String[] args = new String[inputPaths.size() + 3];
                args[0] = "-in";
                int k = 2;
                boolean hasData = false;
                for (Path temp : inputPaths) {
                    String tempPath = temp.toUri().toString();
                    if ((mapper.intern() == mappers[0].intern() && tempPath.indexOf("ClientTraceDetailed") > 0)
                            || (mapper.intern() == mappers[1].intern()
                                    && tempPath.indexOf("ClientTraceDetailed") > 0)
                            || (mapper.intern() == mappers[2].intern() && tempPath.indexOf("TaskData") > 0)
                            || (mapper.intern() == mappers[2].intern() && tempPath.indexOf("JobData") > 0)) {
                        args[k] = tempPath;
                        k++;
                        hasData = true;
                    }
                }
                args[1] = k - 2 + "";
                fsmConf.set("chukwa.salsa.fsm.mapclass", mapper);
                args[k] = outputDir + mapper;
                Path outputPath = new Path(args[k]);
                outputPaths.add(outputPath);
                if (hasData) {
                    int res = ToolRunner.run(fsmConf, new FSMBuilder(), args);
                }
            }
        }
        // Find the mapreduce output and load to MDL.
        for (Path outputPath : outputPaths) {
            Path searchDir = new Path(outputPath.toUri().toString() + "/*/*/*.evt");
            log.info("Search dir:" + searchDir.toUri().toString());
            FileStatus[] outputList = fs.globStatus(searchDir);
            if (outputList != null) {
                for (int j = 0; j < outputList.length; j++) {
                    String outputFile = outputList[j].getPath().toUri().toString();
                    log.info("FSM -> MDL loading: " + outputFile);
                    completion.submit(new MetricDataLoader(conf, fs, outputFile));
                    counter++;
                }
            } else {
                log.warn("No output to load.");
            }
        }
        for (int i = 0; i < counter; i++) {
            completion.take().get();
        }
        // Clean up mapreduce output of fsm.
        for (Path dir : outputPaths) {
            fs.delete(dir, true);
        }
    } catch (Exception e) {
        log.error(ExceptionUtil.getStackTrace(e));
        throw new IOException();
    } finally {
    }
}

From source file:org.opennms.netmgt.xml.eventconf.Correlation.java

/**
 * Sets the value of field 'path'. The field 'path' has the
 * following description: The correlation path
 * //from  w  w w  .j ava  2 s.co  m
 * @param path the value of field 'path'.
 */
public void setPath(final String path) {
    this.m_path = path.intern();
}

From source file:org.opennms.netmgt.xml.eventconf.Correlation.java

/**
 * Sets the value of field 'state'. The field 'state' has the
 * following description: The state determines if event is
 *  correlated/*from   w w  w .j av  a  2s  . c  o m*/
 * 
 * @param state the value of field 'state'.
 */
public void setState(final String state) {
    this.m_state = state.intern();
}

From source file:org.opennms.netmgt.xml.eventconf.Maskelement.java

/**
 * // w  w w. j  ava 2 s .co  m
 * 
 * @param index
 * @param vMevalue
 * @throws IndexOutOfBoundsException if the index
 * given is outside the bounds of the collection
 */
public void addMevalue(final int index, final String vMevalue) throws IndexOutOfBoundsException {
    this.m_mevalueList.add(index, vMevalue.intern());
}

From source file:com.amazon.carbonado.repo.jdbc.JDBCStorableIntrospector.java

static String intern(String str) {
    return str == null ? null : str.intern();
}

From source file:org.corpus_tools.salt.graph.impl.LabelImpl.java

/** {@inheritDoc Label#setName(String)} */
@Override/* w ww  .ja va 2 s.c o m*/
public void setName(String name) {
    if ((name == null) || (name.isEmpty())) {
        throw new SaltException("Cannot set the name of this label object, because it is empty.");
    }
    if (name.contains(NS_SEPERATOR)) {
        throw new SaltException(
                "Cannot set the name to the given, because a namespace with namespace seperaor is illegal.");
    }
    this.name = name.intern();
}