Search in sources :

Example 21 with ThreadContext

use of org.jruby.runtime.ThreadContext in project jruby-openssl by jruby.

the class SSLSocket method copySessionSetupIfSet.

private void copySessionSetupIfSet() {
    if (setSession != null) {
        if (reusableSSLEngine()) {
            engine.setEnableSessionCreation(false);
            final ThreadContext context = getRuntime().getCurrentContext();
            if (!setSession.equals(getSession(context.runtime))) {
                getSession(context.runtime).set_timeout(context, setSession.timeout(context));
            }
        }
    }
}
Also used : ThreadContext(org.jruby.runtime.ThreadContext)

Example 22 with ThreadContext

use of org.jruby.runtime.ThreadContext in project jruby-openssl by jruby.

the class SSLSocket method createSSLSocket.

public static void createSSLSocket(final Ruby runtime, final RubyModule SSL) {
    // OpenSSL::SSL
    final ThreadContext context = runtime.getCurrentContext();
    RubyClass SSLSocket = SSL.defineClassUnder("SSLSocket", runtime.getObject(), ALLOCATOR);
    // SSLSocket.addReadAttribute(context, "io");
    // SSLSocket.defineAlias("to_io", "io");
    // SSLSocket.addReadAttribute(context, "context");
    SSLSocket.addReadWriteAttribute(context, "sync_close");
    SSLSocket.addReadWriteAttribute(context, "hostname");
    SSLSocket.defineAnnotatedMethods(SSLSocket.class);
    SSLSocket.undefineMethod("dup");
}
Also used : ThreadContext(org.jruby.runtime.ThreadContext) RubyClass(org.jruby.RubyClass)

Example 23 with ThreadContext

use of org.jruby.runtime.ThreadContext in project nokogiri by sparklemotion.

the class NokogiriXPathFunction method evaluate.

public Object evaluate(List<?> args) throws XPathFunctionException {
    if (args.size() != this.arity) {
        throw new XPathFunctionException("arity does not match");
    }
    if (name.getNamespaceURI().equals(NokogiriNamespaceContext.NOKOGIRI_BUILTIN_URI)) {
        if (name.getLocalPart().equals("css-class")) {
            return builtinCssClass(args);
        }
    }
    if (this.handler.isNil()) {
        throw new XPathFunctionException("no custom function handler declared for '" + name + "'");
    }
    final Ruby runtime = this.handler.getRuntime();
    ThreadContext context = runtime.getCurrentContext();
    IRubyObject result = Helpers.invoke(context, this.handler, this.name.getLocalPart(), fromObjectToRubyArgs(runtime, args));
    return fromRubyToObject(runtime, result);
}
Also used : XPathFunctionException(javax.xml.xpath.XPathFunctionException) ThreadContext(org.jruby.runtime.ThreadContext) IRubyObject(org.jruby.runtime.builtin.IRubyObject) Ruby(org.jruby.Ruby)

Example 24 with ThreadContext

use of org.jruby.runtime.ThreadContext in project nokogiri by sparklemotion.

the class NokogiriHandler method call.

private void call(String methodName, IRubyObject argument) {
    ThreadContext context = runtime.getCurrentContext();
    Helpers.invoke(context, document(context), methodName, argument);
}
Also used : ThreadContext(org.jruby.runtime.ThreadContext)

Example 25 with ThreadContext

use of org.jruby.runtime.ThreadContext in project nokogiri by sparklemotion.

the class NokogiriHandler method call.

private void call(String methodName) {
    ThreadContext context = runtime.getCurrentContext();
    Helpers.invoke(context, document(context), methodName);
}
Also used : ThreadContext(org.jruby.runtime.ThreadContext)

Aggregations

ThreadContext (org.jruby.runtime.ThreadContext)25 IRubyObject (org.jruby.runtime.builtin.IRubyObject)11 Ruby (org.jruby.Ruby)7 RubyArray (org.jruby.RubyArray)5 RubyClass (org.jruby.RubyClass)4 RubyString (org.jruby.RubyString)4 IOException (java.io.IOException)3 XPathFunctionException (javax.xml.xpath.XPathFunctionException)3 ByteList (org.jruby.util.ByteList)3 PublicKey (java.security.PublicKey)2 ArrayList (java.util.ArrayList)2 X500Name (org.bouncycastle.asn1.x500.X500Name)2 RubyHash (org.jruby.RubyHash)2 RubyModule (org.jruby.RubyModule)2 X509AuxCertificate (org.jruby.ext.openssl.x509store.X509AuxCertificate)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 List (java.util.List)1