Search in sources :

Example 6 with LocalStringManagerImpl

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

the class WebArchiveLoadableHelper method getFailedResults.

public static String getFailedResults(ClosureCompiler cc, File jspDir) {
    StringBuilder sb = new StringBuilder();
    sb.append("\n");
    for (Object o : cc.getFailed().entrySet()) {
        Map.Entry<String, List<String>> referencingPathToFailedList = (Map.Entry<String, List<String>>) o;
        LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager();
        String classes = "Failed to find following classes:";
        if (smh != null) {
            classes = smh.getLocalString(WebArchiveLoadableHelper.class.getName() + ".classes", classes);
        }
        sb.append(classes).append("\n[");
        for (Iterator<String> iii = referencingPathToFailedList.getValue().iterator(); iii.hasNext(); ) {
            sb.append("\n\t").append(iii.next());
            if (iii.hasNext())
                sb.append(",");
        }
        sb.append("\n]");
        String referencingPath = referencingPathToFailedList.getKey();
        // skip if a top level class is not found
        if (referencingPath.length() == 0)
            continue;
        String ref = "referenced in the following call stack :";
        String reference = "at";
        if (smh != null) {
            ref = smh.getLocalString(WebArchiveLoadableHelper.class.getName() + ".ref", ref);
            reference = smh.getLocalString(WebArchiveLoadableHelper.class.getName() + ".reference", reference);
        }
        StringTokenizer st = new StringTokenizer(referencingPath, File.separator);
        Stack<String> referencingClassStack = new Stack<String>();
        boolean jspDirExists = (jspDir != null && jspDir.exists());
        final String jspPkgName = "org.apache.jsp.";
        while (st.hasMoreTokens()) {
            String className = st.nextToken();
            // This logic is to map the compiled jsp class to original jsp name.
            // The logic is to find whether the ref class is in jsp out dir. If true
            // then maniputale the ref class to get the jsp name
            String fileName = className.replace(".", File.separator) + ".class";
            if (jspDirExists && className.startsWith(jspPkgName) && new File(jspDir, fileName).exists()) {
                StringBuilder jspName = new StringBuilder(className.substring(jspPkgName.length()));
                int innerClassIndex = jspName.indexOf("$");
                if (innerClassIndex != -1) {
                    jspName = jspName.replace(innerClassIndex, jspName.length(), "");
                }
                if (jspName.toString().endsWith("_jsp")) {
                    jspName = jspName.replace(jspName.lastIndexOf("_jsp"), jspName.length(), ".jsp");
                } else if (jspName.toString().endsWith("_jspx")) {
                    jspName = jspName.replace(jspName.lastIndexOf("_jspx"), jspName.length(), ".jspx");
                }
                className = jspName.toString();
            }
            referencingClassStack.push(className);
        }
        if ((!referencingClassStack.isEmpty()))
            sb.append("\n\n" + ref);
        while (!referencingClassStack.isEmpty()) {
            sb.append("\n\t").append(reference).append(" ");
            sb.append(referencingClassStack.pop());
        }
        sb.append("\n\n");
    }
    return sb.toString();
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) Stack(java.util.Stack) StringTokenizer(java.util.StringTokenizer) List(java.util.List) Map(java.util.Map) File(java.io.File)

Example 7 with LocalStringManagerImpl

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

the class VerifierMain method main.

public static void main(String[] args) throws GlassFishException, IOException {
    VerifierFrameworkContext verifierFrameworkContext = new Initializer(args).getVerificationContext();
    // Since in gui mode, we don't get a chance to clean up, we need to install a shutdown hook
    addShutdownHook();
    gfr = GlassFishRuntime.bootstrap();
    GlassFishProperties gfp = new GlassFishProperties();
    gfp.setProperty(StartupContext.TIME_ZERO_NAME, (new Long(System.currentTimeMillis())).toString());
    final String VERIFIER_MODULE = "org.glassfish.verifier";
    gfp.setProperty(StartupContext.STARTUP_MODULE_NAME, VERIFIER_MODULE);
    // gfp.setConfigFileURI("file:/tmp/domain.xml");
    GlassFish gf = gfr.newGlassFish(gfp);
    gf.start();
    int failedCount = -1;
    Verifier verifier = gf.getService(Verifier.class);
    if (verifierFrameworkContext.isUsingGui()) {
        MainFrame mf = new MainFrame(verifierFrameworkContext.getJarFileName(), true, verifier);
        mf.setSize(800, 600);
        mf.setVisible(true);
    } else {
        LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager();
        try {
            verifier.init(verifierFrameworkContext);
            verifier.verify();
        } catch (Exception e) {
            LogRecord logRecord = new LogRecord(Level.SEVERE, smh.getLocalString(verifier.getClass().getName() + // NOI18N
            ".verifyFailed", // NOI18N
            "Could not verify successfully."));
            logRecord.setThrown(e);
            verifierFrameworkContext.getResultManager().log(logRecord);
        }
        verifier.generateReports();
        failedCount = verifierFrameworkContext.getResultManager().getFailedCount() + verifierFrameworkContext.getResultManager().getErrorCount();
        System.exit(failedCount);
    }
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) LogRecord(java.util.logging.LogRecord) GlassFish(org.glassfish.embeddable.GlassFish) GlassFishProperties(org.glassfish.embeddable.GlassFishProperties) MainFrame(com.sun.enterprise.tools.verifier.gui.MainFrame) GlassFishException(org.glassfish.embeddable.GlassFishException) IOException(java.io.IOException)

Example 8 with LocalStringManagerImpl

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

the class PlainTextActionReporter method writeReport.

@Override
public void writeReport(OutputStream os) throws IOException {
    // The caller will read MAGIC and the next characters for success/failure
    // everything after the HEADER_END is good data
    writer = new PrintWriter(os);
    writer.print(MAGIC);
    if (isFailure()) {
        writer.print("FAILURE");
        Throwable t = getFailureCause();
        if (t != null) {
            writer.print(t);
        }
    } else {
        writer.print("SUCCESS");
    }
    StringBuilder finalOutput = new StringBuilder();
    getCombinedMessages(this, finalOutput);
    String outs = finalOutput.toString();
    if (!ok(outs)) {
        // we want at least one line of output.  Otherwise RemoteResponseManager
        // will consider this an error.  It is NOT an error there just is no data to report.
        LocalStringManagerImpl localStrings = new LocalStringManagerImpl(PlainTextActionReporter.class);
        writer.print(localStrings.getLocalString("get.mon.no.data", "No monitoring data to report."));
        // forces an error to manifest constructor
        writer.print("\n");
    } else
        writer.print(outs);
    writer.flush();
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) PrintWriter(java.io.PrintWriter)

Example 9 with LocalStringManagerImpl

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

the class ConfigModularityUtils method getDefaultConfigurations.

/**
 * If exists, locate and return a URL to the configuration snippet for the given config bean class.
 *
 * @param configBeanClass the config bean type we want to check for its configuration snippet
 * @return A url to the file or null of not exists
 */
public List<ConfigBeanDefaultValue> getDefaultConfigurations(Class configBeanClass, String runtimeType) {
    // Determine if it is DAS or instance
    CustomConfiguration c = (CustomConfiguration) configBeanClass.getAnnotation(CustomConfiguration.class);
    List<ConfigBeanDefaultValue> defaults = Collections.emptyList();
    if (c.usesOnTheFlyConfigGeneration()) {
        Method m = getGetDefaultValuesMethod(configBeanClass);
        if (m != null) {
            try {
                defaults = (List<ConfigBeanDefaultValue>) m.invoke(null, runtimeType);
            } catch (Exception e) {
                LogHelper.log(LOG, Level.INFO, cannotGetDefaultConfig, e, configBeanClass.getName());
            }
        }
    } else {
        // TODO properly handle the exceptions
        LocalStringManager localStrings = new LocalStringManagerImpl(configBeanClass);
        ModuleXMLConfigurationFileParser parser = new ModuleXMLConfigurationFileParser(localStrings);
        try {
            defaults = parser.parseServiceConfiguration(getConfigurationFileUrl(configBeanClass, c.baseConfigurationFileName(), runtimeType).openStream());
        } catch (XMLStreamException e) {
            LOG.log(Level.SEVERE, cannotParseDefaultDefaultConfig, e);
        } catch (IOException e) {
            LOG.log(Level.SEVERE, cannotParseDefaultDefaultConfig, e);
        }
    }
    return defaults;
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) ConfigBeanDefaultValue(com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue) XMLStreamException(javax.xml.stream.XMLStreamException) ModuleXMLConfigurationFileParser(com.sun.enterprise.config.modularity.parser.ModuleXMLConfigurationFileParser) LocalStringManager(com.sun.enterprise.util.LocalStringManager) CustomConfiguration(com.sun.enterprise.config.modularity.annotation.CustomConfiguration) Method(java.lang.reflect.Method) IOException(java.io.IOException) PropertyVetoException(java.beans.PropertyVetoException) XMLStreamException(javax.xml.stream.XMLStreamException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Example 10 with LocalStringManagerImpl

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

the class GenericDeleteCommand method postConstruct.

@Override
public void postConstruct() {
    super.postConstruct();
    delete = targetMethod.getAnnotation(Delete.class);
    resolverType = delete.resolver();
    try {
        // we pass false for "useAnnotations" as the @Param declarations on
        // the target type are not used for the Delete method parameters.
        model = new GenericCommandModel(targetType, false, delete.cluster(), delete.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, AnnotationUtil.presentTransitive(ManagedJob.class, delete.decorator()), delete.resolver(), delete.decorator());
        if (logger.isLoggable(level)) {
            for (String paramName : model.getParametersNames()) {
                CommandModel.ParamModel param = model.getModelFor(paramName);
                logger.log(Level.FINE, "I take {0} parameters", param.getName());
            }
        }
    } catch (Exception e) {
        String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage());
        LogHelper.log(logger, Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, e, new Object[] { commandName });
        throw new RuntimeException(msg, e);
    }
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) PropertyVetoException(java.beans.PropertyVetoException)

Aggregations

LocalStringManagerImpl (com.sun.enterprise.util.LocalStringManagerImpl)11 PropertyVetoException (java.beans.PropertyVetoException)3 GenericCommandModel (org.glassfish.common.util.admin.GenericCommandModel)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 CustomConfiguration (com.sun.enterprise.config.modularity.annotation.CustomConfiguration)1 ConfigBeanDefaultValue (com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue)1 ModuleXMLConfigurationFileParser (com.sun.enterprise.config.modularity.parser.ModuleXMLConfigurationFileParser)1 MainFrame (com.sun.enterprise.tools.verifier.gui.MainFrame)1 LocalStringManager (com.sun.enterprise.util.LocalStringManager)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 Field (java.lang.reflect.Field)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Stack (java.util.Stack)1 StringTokenizer (java.util.StringTokenizer)1 LogRecord (java.util.logging.LogRecord)1