Search in sources :

Example 1 with TokenValue

use of com.sun.enterprise.admin.util.TokenValue in project Payara by payara.

the class CLICommand method expandManPage.

/**
 * Return a man page for this command that has the tokens substituted
 * @param r
 * @return
 */
public BufferedReader expandManPage(Reader r) {
    manpageTokenValues[0] = programOpts.getCommandName();
    manpageTokenValues[1] = Environment.getPrefix();
    manpageTokenValues[2] = Version.getBriefProductName();
    TokenValueSet tvs = new TokenValueSet();
    for (int i = 0; i < manpageTokens.length; i++) {
        tvs.add(new TokenValue(manpageTokens[i], manpageTokenValues[i], "{", "}"));
    }
    return new BufferedReader(new LineTokenReplacer(tvs).getReader(r));
}
Also used : TokenValueSet(com.sun.enterprise.admin.util.TokenValueSet) LineTokenReplacer(com.sun.enterprise.admin.util.LineTokenReplacer) TokenValue(com.sun.enterprise.admin.util.TokenValue)

Example 2 with TokenValue

use of com.sun.enterprise.admin.util.TokenValue in project Payara by payara.

the class PEScriptsTokens method getTokenValueSet.

/**
 * @return Returns the TokenValueSet that has the (token, value) pairs for
 * startserv & stopserv scripts.
 * @param domainConfig
 */
public static TokenValueSet getTokenValueSet(DomainConfig domainConfig) {
    final PEFileLayout layout = new PEFileLayout(domainConfig);
    final TokenValueSet tokens = new TokenValueSet();
    final String configRootDir = domainConfig.getConfigRoot();
    TokenValue tv = new TokenValue(CONFIG_HOME, configRootDir);
    tokens.add(tv);
    final String instanceRoot = layout.getRepositoryDir().getAbsolutePath();
    tv = new TokenValue(INSTANCE_ROOT, instanceRoot);
    tokens.add(tv);
    final String instanceName = (String) domainConfig.get(DomainConfig.K_SERVERID);
    if ((instanceName == null) || (instanceName.equals("")))
        tv = new TokenValue(SERVER_NAME, PEFileLayout.DEFAULT_INSTANCE_NAME);
    else
        tv = new TokenValue(SERVER_NAME, instanceName);
    tokens.add(tv);
    tv = new TokenValue(DOMAIN_NAME, domainConfig.getDomainName());
    tokens.add(tv);
    return (tokens);
}
Also used : TokenValueSet(com.sun.enterprise.admin.util.TokenValueSet) TokenValue(com.sun.enterprise.admin.util.TokenValue)

Example 3 with TokenValue

use of com.sun.enterprise.admin.util.TokenValue in project Payara by payara.

the class TokenReplacementTester method getTokensFromFile.

private TokenValueSet getTokensFromFile(String fileName) {
    final TokenValueSet tokens = new TokenValueSet();
    try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {
        String line = null;
        while ((line = reader.readLine()) != null) {
            final TokenValue tv = getTokenValue(line);
            tokens.add(tv);
        }
        reader.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return tokens;
}
Also used : TokenValueSet(com.sun.enterprise.admin.util.TokenValueSet) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) TokenValue(com.sun.enterprise.admin.util.TokenValue)

Example 4 with TokenValue

use of com.sun.enterprise.admin.util.TokenValue in project Payara by payara.

the class ServicesUtils method map2Set.

static TokenValueSet map2Set(final Map<String, String> map) {
    final Set<TokenValue> set = new HashSet<TokenValue>();
    for (final Map.Entry<String, String> e : map.entrySet()) {
        final String key = e.getKey();
        final String value = e.getValue();
        final TokenValue tv = new TokenValue(key, value);
        set.add(tv);
    }
    final TokenValueSet tvset = new TokenValueSet(set);
    return (tvset);
}
Also used : TokenValueSet(com.sun.enterprise.admin.util.TokenValueSet) TokenValue(com.sun.enterprise.admin.util.TokenValue)

Example 5 with TokenValue

use of com.sun.enterprise.admin.util.TokenValue in project Payara by payara.

the class RepositoryManager method createJBIInstance.

/**
 * Create JBI instance.
 * @param instanceName the name of the instance to create
 * @param config the {@link RepositoryConfig} to create the JBI instance within
 * @throws RepositoryException if an error occured creating the JBI instance
 */
protected void createJBIInstance(String instanceName, RepositoryConfig config) throws RepositoryException {
    final PEFileLayout layout = getFileLayout(config);
    layout.createJBIDirectories();
    final TokenValueSet tvSet = new TokenValueSet();
    final String tvDelimiter = "@";
    final String tJbiInstanceName = "JBI_INSTANCE_NAME";
    final String tJbiInstanceRoot = "JBI_INSTANCE_ROOT";
    try {
        final TokenValue tvJbiInstanceName = new TokenValue(tJbiInstanceName, instanceName, tvDelimiter);
        final TokenValue tvJbiInstanceRoot = new TokenValue(tJbiInstanceRoot, layout.getRepositoryDir().getCanonicalPath(), tvDelimiter);
        tvSet.add(tvJbiInstanceName);
        tvSet.add(tvJbiInstanceRoot);
        final File src = layout.getJbiTemplateFile();
        final File dest = layout.getJbiRegistryFile();
        generateFromTemplate(tvSet, src, dest);
        final File httpConfigSrc = layout.getHttpBcConfigTemplate();
        final File httpConfigDest = layout.getHttpBcConfigFile();
        // tokens will be added in a follow-up integration
        final TokenValueSet httpTvSet = new TokenValueSet();
        generateFromTemplate(httpTvSet, httpConfigSrc, httpConfigDest);
        createHttpBCInstallRoot(layout);
        createJavaEESEInstallRoot(layout);
        createWSDLSLInstallRoot(layout);
    } catch (Exception ioe) {
        throw new RepositoryException(STRING_MANAGER.getString("jbiRegistryFileNotCreated"), ioe);
    }
}
Also used : TokenValueSet(com.sun.enterprise.admin.util.TokenValueSet) PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) File(java.io.File) ZipFile(com.sun.enterprise.util.zip.ZipFile) IOException(java.io.IOException) TokenValue(com.sun.enterprise.admin.util.TokenValue)

Aggregations

TokenValue (com.sun.enterprise.admin.util.TokenValue)6 TokenValueSet (com.sun.enterprise.admin.util.TokenValueSet)5 PEFileLayout (com.sun.enterprise.admin.servermgmt.pe.PEFileLayout)1 LineTokenReplacer (com.sun.enterprise.admin.util.LineTokenReplacer)1 ZipFile (com.sun.enterprise.util.zip.ZipFile)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 StringTokenizer (java.util.StringTokenizer)1