本文整理匯總了Golang中v/io/x/jni/v23/context.GoContext函數的典型用法代碼示例。如果您正苦於以下問題:Golang GoContext函數的具體用法?Golang GoContext怎麽用?Golang GoContext使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GoContext函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Java_io_v_impl_google_lib_discovery_UpdateImpl_nativeAttachment
//export Java_io_v_impl_google_lib_discovery_UpdateImpl_nativeAttachment
func Java_io_v_impl_google_lib_discovery_UpdateImpl_nativeAttachment(jenv *C.JNIEnv, _ C.jobject, goRef C.jlong, jCtx C.jobject, jName C.jstring, jCbObj C.jobject) {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jCtx))))
if err != nil {
jutil.JThrowV(env, err)
return
}
update := *(*discovery.Update)(jutil.GoRefValue(jutil.Ref(goRef)))
name := jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
jCb := jutil.Object(uintptr(unsafe.Pointer(jCbObj)))
jutil.DoAsyncCall(env, jCb, func() (jutil.Object, error) {
dataOrErr := <-update.Attachment(ctx, name)
if dataOrErr.Error != nil {
return jutil.NullObject, err
}
env, freeFunc := jutil.GetEnv()
defer freeFunc()
jData, err := jutil.JByteArray(env, dataOrErr.Data)
if err != nil {
return jutil.NullObject, err
}
// Must grab a global reference as we free up the env and all local references that come
// along with it.
return jutil.NewGlobalRef(env, jData), nil // Un-refed in DoAsyncCall
})
}
示例2: Java_io_v_v23_security_PublicKeyThirdPartyCaveatValidator_nativeValidate
//export Java_io_v_v23_security_PublicKeyThirdPartyCaveatValidator_nativeValidate
func Java_io_v_v23_security_PublicKeyThirdPartyCaveatValidator_nativeValidate(jenv *C.JNIEnv, jThirdPartyValidatorClass C.jclass, jContext C.jobject, jCall C.jobject, jCaveatParam C.jobject) {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
param, err := jutil.GoVomCopyValue(env, jutil.Object(uintptr(unsafe.Pointer(jCaveatParam))))
if err != nil {
jutil.JThrowV(env, err)
return
}
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
jutil.JThrowV(env, err)
return
}
call, err := GoCall(env, jutil.Object(uintptr(unsafe.Pointer(jCall))))
if err != nil {
jutil.JThrowV(env, err)
return
}
caveat, err := security.NewCaveat(security.PublicKeyThirdPartyCaveat, param)
if err != nil {
jutil.JThrowV(env, err)
return
}
if err := caveat.Validate(ctx, call); err != nil {
jutil.JThrowV(env, err)
return
}
}
示例3: Java_io_v_v23_security_VSecurity_nativeGetSigningBlessingNames
//export Java_io_v_v23_security_VSecurity_nativeGetSigningBlessingNames
func Java_io_v_v23_security_VSecurity_nativeGetSigningBlessingNames(jenv *C.JNIEnv, jVSecurityClass C.jclass, jCtx C.jobject, jPrincipal C.jobject, jBlessings C.jobject) C.jobjectArray {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jCtx))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
principal, err := GoPrincipal(env, jutil.Object(uintptr(unsafe.Pointer(jPrincipal))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
blessings, err := GoBlessings(env, jutil.Object(uintptr(unsafe.Pointer(jBlessings))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
blessingStrs, _ := security.SigningBlessingNames(ctx, principal, blessings)
jArr, err := jutil.JStringArray(env, blessingStrs)
if err != nil {
jutil.JThrowV(env, err)
return nil
}
return C.jobjectArray(unsafe.Pointer(jArr))
}
示例4: Java_io_v_impl_google_lib_discovery_GlobalDiscovery_nativeNewDiscovery
//export Java_io_v_impl_google_lib_discovery_GlobalDiscovery_nativeNewDiscovery
func Java_io_v_impl_google_lib_discovery_GlobalDiscovery_nativeNewDiscovery(jenv *C.JNIEnv, jRuntime C.jclass, jContext C.jobject, jPath C.jstring, jMountTTL, jScanInterval C.jobject) C.jobject {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
path := jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jPath))))
mountTTL, err := jutil.GoDuration(env, jutil.Object(uintptr(unsafe.Pointer(jMountTTL))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
scanInterval, err := jutil.GoDuration(env, jutil.Object(uintptr(unsafe.Pointer(jScanInterval))))
if err != nil {
jutil.JThrowV(env, err)
return nil
}
discovery, err := gdiscovery.NewWithTTL(ctx, path, mountTTL, scanInterval)
if err != nil {
jutil.JThrowV(env, err)
return nil
}
jDiscovery, err := JavaDiscovery(env, discovery)
if err != nil {
jutil.JThrowV(env, err)
return nil
}
return C.jobject(unsafe.Pointer(jDiscovery))
}
示例5: Java_io_v_impl_google_lib_discovery_FactoryUtil_injectMockPlugin
//export Java_io_v_impl_google_lib_discovery_FactoryUtil_injectMockPlugin
func Java_io_v_impl_google_lib_discovery_FactoryUtil_injectMockPlugin(jenv *C.JNIEnv, _ C.jclass, jCtx C.jobject) {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jCtx))))
if err != nil {
jutil.JThrowV(env, err)
return
}
injectMockPlugin(ctx)
}
示例6: unmountArgs
func unmountArgs(env jutil.Env, jName, jServer C.jstring, jContext, jOptions C.jobject) (name, server string, context *context.T, options []naming.NamespaceOpt, err error) {
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
server = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jServer))))
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
return
}
示例7: Java_io_v_impl_google_lib_discovery_DiscoveryImpl_nativeAdvertise
//export Java_io_v_impl_google_lib_discovery_DiscoveryImpl_nativeAdvertise
func Java_io_v_impl_google_lib_discovery_DiscoveryImpl_nativeAdvertise(jenv *C.JNIEnv, _ C.jobject, goRef C.jlong, jCtx C.jobject, jAdObj C.jobject, jVisibilityObj C.jobject, jCbObj C.jobject) {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jCtx))))
if err != nil {
jutil.JThrowV(env, err)
return
}
d := *(*discovery.T)(jutil.GoRefValue(jutil.Ref(goRef)))
jAd := jutil.Object(uintptr(unsafe.Pointer(jAdObj)))
jVisibility := jutil.Object(uintptr(unsafe.Pointer(jVisibilityObj)))
var ad discovery.Advertisement
if err := jutil.GoVomCopy(env, jAd, jAdvertisementClass, &ad); err != nil {
jutil.JThrowV(env, err)
return
}
jVisibilityList, err := jutil.GoObjectList(env, jVisibility)
if err != nil {
jutil.JThrowV(env, err)
return
}
visibility := make([]security.BlessingPattern, len(jVisibilityList))
for i, jPattern := range jVisibilityList {
if err := jutil.GoVomCopy(env, jPattern, jBlessingPatternClass, &visibility[i]); err != nil {
jutil.JThrowV(env, err)
return
}
}
done, err := d.Advertise(ctx, &ad, visibility)
if err != nil {
jutil.JThrowV(env, err)
return
}
// Copy back the advertisement id.
jId, err := jutil.JVomCopy(env, &ad.Id, jAdIdClass)
if err != nil {
jutil.JThrowV(env, err)
return
}
if err = jutil.CallVoidMethod(env, jAd, "setId", []jutil.Sign{adIdSign}, jId); err != nil {
jutil.JThrowV(env, err)
return
}
jCb := jutil.Object(uintptr(unsafe.Pointer(jCbObj)))
jutil.DoAsyncCall(env, jCb, func() (jutil.Object, error) {
<-done
return jutil.NullObject, nil
})
}
示例8: globArgs
func globArgs(env jutil.Env, jContext C.jobject, jPattern C.jstring, jOptions C.jobject) (context *context.T, cancel func(), pattern string, opts []naming.NamespaceOpt, err error) {
context, cancel, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
opts, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
if err != nil {
return
}
pattern = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jPattern))))
return
}
示例9: getPermissionsArgs
func getPermissionsArgs(env jutil.Env, jContext C.jobject, jName C.jstring, jOptions C.jobject) (context *context.T, name string, options []naming.NamespaceOpt, err error) {
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
if err != nil {
return
}
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
return
}
示例10: resolveToMountTableArgs
func resolveToMountTableArgs(env jutil.Env, jContext, jOptions C.jobject, jName C.jstring) (context *context.T, options []naming.NamespaceOpt, name string, err error) {
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
if err != nil {
return
}
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
return
}
示例11: deleteArgs
func deleteArgs(env jutil.Env, jContext, jOptions C.jobject, jName C.jstring, jDeleteSubtree C.jboolean) (context *context.T, options []naming.NamespaceOpt, name string, deleteSubtree bool, err error) {
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
if err != nil {
return
}
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
deleteSubtree = jDeleteSubtree == C.JNI_TRUE
return
}
示例12: Java_io_v_v23_syncbase_DatabaseImpl_nativeListenForInvites
//export Java_io_v_v23_syncbase_DatabaseImpl_nativeListenForInvites
func Java_io_v_v23_syncbase_DatabaseImpl_nativeListenForInvites(jenv *C.JNIEnv, jDatabase C.jobject, jContext C.jobject, jInviteHandler C.jobject) {
env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
database := jutil.Object(uintptr(unsafe.Pointer(jDatabase)))
handler := jutil.Object(uintptr(unsafe.Pointer(jInviteHandler)))
ctx, _, err := jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
jutil.JThrowV(env, err)
return
}
jDbId, err := jutil.CallObjectMethod(env, database, "id", nil, idSign)
if err != nil {
jutil.JThrowV(env, err)
return
}
dbName, err := jutil.CallStringMethod(env, jDbId, "getName", nil)
if err != nil {
jutil.JThrowV(env, err)
return
}
dbBlessing, err := jutil.CallStringMethod(env, jDbId, "getBlessing", nil)
if err != nil {
jutil.JThrowV(env, err)
return
}
dbId := wire.Id{Name: dbName, Blessing: dbBlessing}
// Note: There is no need to use a buffered channel here. ListenForInvites
// spawns a goroutine for this listener that acts as an infinite buffer so we can
// process invites at our own pace.
ch := make(chan discovery.Invite)
if err := discovery.ListenForInvites(ctx, dbId, ch); err != nil {
jutil.JThrowV(env, err)
return
}
handler = jutil.NewGlobalRef(env, handler)
go func() {
for invite := range ch {
if err := handleInvite(invite, handler); err != nil {
// TODO(mattr): We should cancel the stream and return an error to
// the user here.
ctx.Errorf("couldn't call invite handler: %v", err)
}
}
env, free := jutil.GetEnv()
jutil.DeleteGlobalRef(env, handler)
free()
}()
}
示例13: setPermissionsArgs
func setPermissionsArgs(env jutil.Env, jContext, jPermissions C.jobject, jName, jVersion C.jstring, jOptions C.jobject) (context *context.T, permissions access.Permissions, name, version string, options []naming.NamespaceOpt, err error) {
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
err = jutil.GoVomCopy(env, jutil.Object(uintptr(unsafe.Pointer(jPermissions))), jPermissionsClass, &permissions)
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
version = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jVersion))))
return
}
示例14: mountArgs
func mountArgs(env jutil.Env, jContext C.jobject, jName, jServer C.jstring, jDuration, jOptions C.jobject) (context *context.T, name, server string, duration time.Duration, options []naming.NamespaceOpt, err error) {
context, _, err = jcontext.GoContext(env, jutil.Object(uintptr(unsafe.Pointer(jContext))))
if err != nil {
return
}
name = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jName))))
server = jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jServer))))
duration, err = jutil.GoDuration(env, jutil.Object(uintptr(unsafe.Pointer(jDuration))))
if err != nil {
return
}
options, err = goNamespaceOptions(env, jutil.Object(uintptr(unsafe.Pointer(jOptions))))
return
}
示例15: Context
func (c *callImpl) Context() *context.T {
env, freeFunc := jutil.GetEnv()
defer freeFunc()
contextSign := jutil.ClassSign("io.v.v23.context.VContext")
jCtx, err := jutil.CallObjectMethod(env, c.jCall, "context", nil, contextSign)
if err != nil {
log.Printf("Couldn't get Java Vanadium context: %v", err)
}
ctx, _, err := jcontext.GoContext(env, jCtx)
if err != nil {
log.Printf("Couldn't convert Java Vanadium context to Go: %v", err)
}
return ctx
}