Package org.rhq.scripting

Examples of org.rhq.scripting.ScriptEngineInitializer


            if (exceptionHolder.scriptException != null) {
                LOG.info("The script execution for CLI notification of alert [" + alert + "] failed.",
                    exceptionHolder.scriptException);

                //make things pretty for the UI
                ScriptEngineInitializer initializer = ScriptEngineFactory.getInitializer(language);
                String message = initializer.extractUserFriendlyErrorMessage(exceptionHolder.scriptException);
                int col = exceptionHolder.scriptException.getColumnNumber();
                int line = exceptionHolder.scriptException.getLineNumber();
                String scriptName = createSummary(config, "script $packageName ($packageVersion) in repo $repoName");
                throw new ScriptException(message, scriptName, line, col);
            } else if (exceptionHolder.throwable != null) {
View Full Code Here


     * @see #getScriptEngine(String, PackageFinder, StandardBindings, ScriptSourceProvider...)
     */
    public static ScriptEngine getSecuredScriptEngine(String language, PackageFinder packageFinder,
        StandardBindings bindings, PermissionCollection permissions) throws ScriptException, IOException {
       
        ScriptEngineInitializer initializer = getInitializer(language);

        if (initializer == null) {
            return null;
        }

        ScriptEngine engine = initializer.instantiate(packageFinder.findPackages("org.rhq.core.domain"),
            permissions);

        if (bindings != null) {
            injectStandardBindings(engine, bindings, true);
        }
View Full Code Here

            ScriptEngineProvider engineProvider = KNOWN_PROVIDERS.get(language);
            if (engineProvider == null) {
                throw new IllegalArgumentException("The supplied script engine [" + engine + "] is not supported.");
            }

            ScriptEngineInitializer initializer = engineProvider.getInitializer();

            ScriptSourceProvider provider = null;

            for (ScriptSourceProvider p : scriptSourceProviders) {
                if (p instanceof StandardBindings.RhqFacadeChangeListener) {
                    bindings.addRhqFacadeChangeListener((StandardBindings.RhqFacadeChangeListener) p);
                }
            }
            provider = new MultiScriptSourceProvider(scriptSourceProviders);

            initializer.installScriptSourceProvider(engine, provider);
        }

        engine.setBindings(engineBindings, ScriptContext.ENGINE_SCOPE);

        bindings.postInject(engine);
View Full Code Here

            LOG.debug("The script engine doesn't contain a binding called '" + bindingName
                + "'. No indirection functions will be generated.");
            return;
        }

        ScriptEngineInitializer initializer = getInitializer((String) scriptEngine.getFactory().getParameter(
            ScriptEngine.NAME));

        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass(), Object.class);
            MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();

            Map<String, Set<Method>> overloadsPerMethodName = new HashMap<String, Set<Method>>();
            for (MethodDescriptor methodDescriptor : methodDescriptors) {
                Method method = methodDescriptor.getMethod();
                if (shouldIndirect(method)) {
                    Set<Method> overloads = overloadsPerMethodName.get(method.getName());
                    if (overloads == null) {
                        overloads = new HashSet<Method>();
                        overloadsPerMethodName.put(method.getName(), overloads);
                    }
                    overloads.add(method);
                }
            }

            for (Set<Method> overloads : overloadsPerMethodName.values()) {
                Set<String> methodDefs = initializer.generateIndirectionMethods(bindingName, overloads);
                for (String methodDef : methodDefs) {
                    try {
                        scriptEngine.eval(methodDef);
                    } catch (ScriptException e) {
                        LOG.warn("Unable to define global function declared as:\n" + methodDef, e);
View Full Code Here

TOP

Related Classes of org.rhq.scripting.ScriptEngineInitializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.