From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/jaegertracing/thrift/lib/as3/CMakeLists.txt | 68 +++++ src/jaegertracing/thrift/lib/as3/Makefile.am | 60 ++++ src/jaegertracing/thrift/lib/as3/README.md | 37 +++ src/jaegertracing/thrift/lib/as3/build.gradle | 56 ++++ .../thrift/lib/as3/coding_standards.md | 1 + src/jaegertracing/thrift/lib/as3/gradle.properties | 23 ++ .../thrift/lib/as3/gradle/publishing.gradle | 96 +++++++ .../lib/as3/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55190 bytes .../as3/gradle/wrapper/gradle-wrapper.properties | 5 + src/jaegertracing/thrift/lib/as3/gradlew | 172 +++++++++++ src/jaegertracing/thrift/lib/as3/gradlew.bat | 84 ++++++ src/jaegertracing/thrift/lib/as3/settings.gradle | 20 ++ .../src/org/apache/thrift/AbstractMethodError.as | 31 ++ .../thrift/lib/as3/src/org/apache/thrift/Set.as | 82 ++++++ .../as3/src/org/apache/thrift/TApplicationError.as | 106 +++++++ .../thrift/lib/as3/src/org/apache/thrift/TBase.as | 67 +++++ .../thrift/lib/as3/src/org/apache/thrift/TError.as | 29 ++ .../src/org/apache/thrift/TFieldRequirementType.as | 32 +++ .../lib/as3/src/org/apache/thrift/TProcessor.as | 32 +++ .../org/apache/thrift/meta_data/FieldMetaData.as | 57 ++++ .../apache/thrift/meta_data/FieldValueMetaData.as | 44 +++ .../org/apache/thrift/meta_data/ListMetaData.as | 31 ++ .../src/org/apache/thrift/meta_data/MapMetaData.as | 33 +++ .../src/org/apache/thrift/meta_data/SetMetaData.as | 31 ++ .../org/apache/thrift/meta_data/StructMetaData.as | 31 ++ .../org/apache/thrift/protocol/TBinaryProtocol.as | 316 +++++++++++++++++++++ .../as3/src/org/apache/thrift/protocol/TField.as | 43 +++ .../as3/src/org/apache/thrift/protocol/TList.as | 33 +++ .../lib/as3/src/org/apache/thrift/protocol/TMap.as | 33 +++ .../as3/src/org/apache/thrift/protocol/TMessage.as | 42 +++ .../src/org/apache/thrift/protocol/TMessageType.as | 28 ++ .../src/org/apache/thrift/protocol/TProtocol.as | 124 ++++++++ .../org/apache/thrift/protocol/TProtocolError.as | 39 +++ .../org/apache/thrift/protocol/TProtocolFactory.as | 27 ++ .../org/apache/thrift/protocol/TProtocolUtil.as | 148 ++++++++++ .../lib/as3/src/org/apache/thrift/protocol/TSet.as | 33 +++ .../as3/src/org/apache/thrift/protocol/TStruct.as | 31 ++ .../as3/src/org/apache/thrift/protocol/TType.as | 39 +++ .../thrift/transport/TFullDuplexHttpClient.as | 251 ++++++++++++++++ .../src/org/apache/thrift/transport/THttpClient.as | 134 +++++++++ .../as3/src/org/apache/thrift/transport/TSocket.as | 194 +++++++++++++ .../src/org/apache/thrift/transport/TTransport.as | 127 +++++++++ .../org/apache/thrift/transport/TTransportError.as | 37 +++ 43 files changed, 2907 insertions(+) create mode 100644 src/jaegertracing/thrift/lib/as3/CMakeLists.txt create mode 100644 src/jaegertracing/thrift/lib/as3/Makefile.am create mode 100644 src/jaegertracing/thrift/lib/as3/README.md create mode 100644 src/jaegertracing/thrift/lib/as3/build.gradle create mode 100644 src/jaegertracing/thrift/lib/as3/coding_standards.md create mode 100644 src/jaegertracing/thrift/lib/as3/gradle.properties create mode 100644 src/jaegertracing/thrift/lib/as3/gradle/publishing.gradle create mode 100644 src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.jar create mode 100644 src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.properties create mode 100755 src/jaegertracing/thrift/lib/as3/gradlew create mode 100644 src/jaegertracing/thrift/lib/as3/gradlew.bat create mode 100644 src/jaegertracing/thrift/lib/as3/settings.gradle create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/AbstractMethodError.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/Set.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TApplicationError.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TBase.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TError.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TFieldRequirementType.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TProcessor.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TField.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TList.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMap.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessage.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessageType.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocol.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TSet.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TStruct.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TType.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/THttpClient.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TSocket.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransport.as create mode 100644 src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransportError.as (limited to 'src/jaegertracing/thrift/lib/as3') diff --git a/src/jaegertracing/thrift/lib/as3/CMakeLists.txt b/src/jaegertracing/thrift/lib/as3/CMakeLists.txt new file mode 100644 index 000000000..999905da0 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/CMakeLists.txt @@ -0,0 +1,68 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +if (IS_ABSOLUTE "${LIB_INSTALL_DIR}") + set(AS3_INSTALL_DIR "${LIB_INSTALL_DIR}/as3") +else () + set(AS3_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/as3") +endif () + +set(PRELEASE "true") +if (CMAKE_BUILD_TYPE MATCHES DEBUG) + set(PRELEASE "false") +endif () + +add_custom_target(ThriftAs3 ALL + COMMENT "Building as3 library using Gradle Wrapper" + COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} compileFlex + --console=plain --no-daemon + -Prelease=${PRELEASE} + "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + +# Enable publishing from CMake if the publishing information is provided +if (NOT CMAKE_BUILD_TYPE MATCHES DEBUG) + add_custom_target(MavenPublishAs3 + COMMENT "Publishing as3 library to Apache Maven staging" + COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean publishMavenPublicationToMavenRepository + --console=plain --no-daemon + -Prelease=${PRELEASE} + -Psign=${PRELEASE} + "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +endif () + +# Hook the CMake install process to the results from make ALL. +# This works best when 'make all && sudo make install/fast' is used. +# Using slash to end the source location to avoid copying the directory path. +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/libs/ + DESTINATION ${AS3_INSTALL_DIR} + FILES_MATCHING PATTERN "libthrift-as3.swc") + +if (BUILD_TESTING) + add_test(NAME As3Test + COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test + --console=plain --no-daemon + -Prelease=${PRELEASE} + "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" + "-Pthrift.compiler=${THRIFT_COMPILER}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +endif () diff --git a/src/jaegertracing/thrift/lib/as3/Makefile.am b/src/jaegertracing/thrift/lib/as3/Makefile.am new file mode 100644 index 000000000..0b3c3befc --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/Makefile.am @@ -0,0 +1,60 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +all-local: + ./gradlew $(GRADLE_OPTS) compile \ + -Prelease=true \ + --console=plain + +install-exec-hook: + ./gradlew $(GRADLE_OPTS) publishToMavenLocal \ + -Prelease=true \ + --console=plain + +clean-local: + ./gradlew $(GRADLE_OPTS) clean \ + -Prelease=true \ + --console=plain + $(RM) -r .gradle + +check-local: $(THRIFT) + ./gradlew $(GRADLE_OPTS) test \ + -Prelease=true \ + --console=plain + +maven-publish: + ./gradlew $(GRADLE_OPTS) publishMavenPublicationToMavenRepository \ + -Prelease=true \ + -Psign=true \ + --console=plain + +dist-hook: + $(RM) -r $(distdir)/.gradle/ + +EXTRA_DIST = \ + CMakeLists.txt \ + README.md \ + build.gradle \ + coding_standards.md \ + gradle \ + gradle.properties \ + gradlew \ + gradlew.bat \ + settings.gradle \ + src diff --git a/src/jaegertracing/thrift/lib/as3/README.md b/src/jaegertracing/thrift/lib/as3/README.md new file mode 100644 index 000000000..c14f8c78b --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/README.md @@ -0,0 +1,37 @@ +# Apache Thrift ActionScript Library + +## Building + +We use gradle and gradlefx to build the as3 library. Unfortunately gradlefx requires +an older version of gradle (2.5) but it still works - for now. If you use the docker +container to do the build, the Adobe Flex SDK 4.6 is installed and the FLEX_HOME +environment variable is configured: + + dev@ubuntu:~/thrift$ docker run -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash + root@7624b61bbf84:/thrift/src# cd lib/as3 + root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true compileFlex + + ... + + :compileFlex UP-TO-DATE + + BUILD SUCCESSFUL + + Total time: 10.784 secs + + root@7624b61bbf84:/thrift/src/lib/as3# ls -ls build/ + total 4 + 4 -rw-r--r-- 1 root root 1379 Jan 22 19:23 libthrift-as3.swc + +## Publishing + +We use a similar gradle-based signing and publishing mechanism as in the java +library. See the java library [README.md](../java/README.md) for more details. + +To publish into a local .m2 repository you can mount a directory into the docker container, +for example: + + dev@ubuntu:~/thrift$ docker run -v~/.m2:/root/.m2 -v $(pwd):/thrift/src:rw -it thrift/thrift-build:ubuntu-bionic /bin/bash + root@7624b61bbf84:/thrift/src/lib/as3# ./gradlew -Prelease=true publishToMavenLocal + +You will find your `~/.m2` directory is now populated with a release build `swc`. diff --git a/src/jaegertracing/thrift/lib/as3/build.gradle b/src/jaegertracing/thrift/lib/as3/build.gradle new file mode 100644 index 000000000..78534996a --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/build.gradle @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.5.0' + } +} + +plugins { + id 'maven-publish' + id 'signing' +} + +apply plugin: 'gradlefx' + +description = 'Apache Thrift ActionScript Library' +frameworkLinkage = 'none' +group = property('thrift.groupid') +srcDirs = ['src'] +type = 'swc' + +// We use the SNAPSHOT suffix for non-release versions +if (Boolean.parseBoolean(project.release)) { + additionalCompilerOptions = ['-compiler.debug=false', '-compiler.strict=true'] + version = property('thrift.version') +} else { + additionalCompilerOptions = ['-compiler.debug=true', '-compiler.strict=true'] + version = property('thrift.version') + '-SNAPSHOT' +} + +defaultTasks 'compile' + +// Keeping the rest of the build logic in functional named scripts for clarity +apply from: 'gradle/publishing.gradle' + diff --git a/src/jaegertracing/thrift/lib/as3/coding_standards.md b/src/jaegertracing/thrift/lib/as3/coding_standards.md new file mode 100644 index 000000000..fa0390bb5 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/coding_standards.md @@ -0,0 +1 @@ +Please follow [General Coding Standards](/doc/coding_standards.md) diff --git a/src/jaegertracing/thrift/lib/as3/gradle.properties b/src/jaegertracing/thrift/lib/as3/gradle.properties new file mode 100644 index 000000000..02d5eefad --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/gradle.properties @@ -0,0 +1,23 @@ +# This file is shared currently between this Gradle build and the +# Ant builds for fd303 and JavaScript. Keep the dotted notation for +# the properties to minimize the changes in the dependencies. +thrift.version=0.13.0 +thrift.groupid=org.apache.thrift +release=false +sign=false + +# Local Install paths +install.path=/usr/local/lib +install.javadoc.path=/usr/local/lib + +# Test execution properties +testPort=9090 + +# Maven dependency download locations +mvn.repo=http://repo1.maven.org/maven2 +apache.repo=https://repository.apache.org/content/repositories/releases + +# Apache Maven publish +license=http://www.apache.org/licenses/LICENSE-2.0.txt +maven-repository-url=https://repository.apache.org/service/local/staging/deploy/maven2 +maven-repository-id=apache.releases.https diff --git a/src/jaegertracing/thrift/lib/as3/gradle/publishing.gradle b/src/jaegertracing/thrift/lib/as3/gradle/publishing.gradle new file mode 100644 index 000000000..3e0ecf319 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/gradle/publishing.gradle @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// Following Gradle best practices to keep build logic organized + +model { + tasks.signMavenPublication { + dependsOn compileFlex + } +} + +publishing { + publications { + maven(MavenPublication) { + + groupId = "$group" + artifactId = "${project.name}" + version = "$version" + + def swcFile = file("$buildDir/libthrift-as3.swc") + artifact(swcFile) + + pom { + description = 'Thrift is a software framework for scalable cross-language services development.' + packaging = 'swc' + + // older gradle doesn't recognize all the properties, so we inject them.. + withXml { + asNode().with { + appendNode('name', 'Apache Thrift') + appendNode('url', 'http://thrift.apache.org/') + appendNode('scm').with { + appendNode('url', 'https://github.com/apache/thrift/') + appendNode('connection', 'scm:git:https://github.com/apache/thrift.git') + appendNode('developerConnection', 'scm:git:git@github.com:apache/thrift.git') + } + appendNode('issueManagement').with { + appendNode('url', 'https://issues.apache.org/jira/projects/THRIFT/') + appendNode('system', 'Jira') + } + appendNode('licenses').with { + appendNode('license').with { + appendNode('name', 'The Apache Software License, Version 2.0') + appendNode('url', "${project.license}") + } + } + appendNode('organization').with { + appendNode('name', 'The Apache Software Foundation') + appendNode('url', 'http://www.apache.org/') + } + appendNode('developers').with { + appendNode('developer').with { + appendNode('id', 'dev') + appendNode('name', 'Apache Thrift Developers') + appendNode('email', 'dev@thrift.apache.org') + } + } + } + } + } + } + } + repositories { + maven { + url = property('maven-repository-url') + + if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) { + credentials { + username = property('mavenUser') + password = property('mavenPassword') + } + } + } + } +} + +signing { + required { property('sign') } + sign publishing.publications.maven +} diff --git a/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.jar b/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..87b738cbd Binary files /dev/null and b/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.properties b/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..558870dad --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/jaegertracing/thrift/lib/as3/gradlew b/src/jaegertracing/thrift/lib/as3/gradlew new file mode 100755 index 000000000..af6708ff2 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/src/jaegertracing/thrift/lib/as3/gradlew.bat b/src/jaegertracing/thrift/lib/as3/gradlew.bat new file mode 100644 index 000000000..6d57edc70 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/jaegertracing/thrift/lib/as3/settings.gradle b/src/jaegertracing/thrift/lib/as3/settings.gradle new file mode 100644 index 000000000..493234641 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/settings.gradle @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +rootProject.name = 'libthrift-as3' diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/AbstractMethodError.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/AbstractMethodError.as new file mode 100644 index 000000000..a2082b888 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/AbstractMethodError.as @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + + import flash.errors.IllegalOperationError; + + public class AbstractMethodError extends IllegalOperationError { + + public function AbstractMethodError(message:String="") { + super("Attempt to call an abstract method"); + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/Set.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/Set.as new file mode 100644 index 000000000..ae5f42843 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/Set.as @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + import flash.utils.Dictionary; + + + public class Set { + + private var _elements:Dictionary = new Dictionary(); + private var _size:int = 0; + + public function Set(... values) { + for each (var value:* in values) { + add(value); + } + } + + public function add(o:*):Boolean { + var alreadyPresent:Boolean = _elements.hasOwnProperty(o); + if (! alreadyPresent) { + _size++; + _elements[o] = true; + } + + return ! alreadyPresent; + } + + public function clear():void { + for (var value:* in _elements) { + remove(value); + } + } + + public function contains(o:Object):Boolean { + return _elements.hasOwnProperty(o); + } + + public function isEmpty():Boolean { + return _size == 0; + } + + public function remove(o:*):Boolean { + if (contains(o)) { + delete _elements[o]; + _size--; + return true; + } + else { + return false; + } + } + + public function toArray():Array { + var ret:Array = new Array(); + for (var key:* in _elements) { + ret.push(key); + } + return ret; + } + + public function get size():int { + return _size; + } + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TApplicationError.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TApplicationError.as new file mode 100644 index 000000000..3448fce0e --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TApplicationError.as @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + + import org.apache.thrift.protocol.TField; + import org.apache.thrift.protocol.TProtocol; + import org.apache.thrift.protocol.TProtocolUtil; + import org.apache.thrift.protocol.TStruct; + import org.apache.thrift.protocol.TType; + + /** + * Application level exception + */ + public class TApplicationError extends TError { + + private static const TAPPLICATION_EXCEPTION_STRUCT:TStruct = new TStruct("TApplicationException"); + private static const MESSAGE_FIELD:TField = new TField("message", TType.STRING, 1); + private static const TYPE_FIELD:TField = new TField("type", TType.I32, 2); + + public static const UNKNOWN:int = 0; + public static const UNKNOWN_METHOD:int = 1; + public static const INVALID_MESSAGE_TYPE:int = 2; + public static const WRONG_METHOD_NAME:int = 3; + public static const BAD_SEQUENCE_ID:int = 4; + public static const MISSING_RESULT:int = 5; + public static const INTERNAL_ERROR:int = 6; + public static const PROTOCOL_ERROR:int = 7; + public static const INVALID_TRANSFORM:int = 8; + public static const INVALID_PROTOCOL:int = 9; + public static const UNSUPPORTED_CLIENT_TYPE:int = 10; + + public function TApplicationError(type:int = UNKNOWN, message:String = "") { + super(message, type); + } + + public static function read(iprot:TProtocol):TApplicationError { + var field:TField; + iprot.readStructBegin(); + + var message:String = null; + var type:int = UNKNOWN; + + while (true) { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + switch (field.id) { + case 1: + if (field.type == TType.STRING) { + message = iprot.readString(); + } + else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: + if (field.type == TType.I32) { + type = iprot.readI32(); + } + else { + TProtocolUtil.skip(iprot, field.type); + } + break; + default: + TProtocolUtil.skip(iprot, field.type); + break; + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + return new TApplicationError(type, message); + } + + public function write(oprot:TProtocol):void { + oprot.writeStructBegin(TAPPLICATION_EXCEPTION_STRUCT); + if (message != null) { + oprot.writeFieldBegin(MESSAGE_FIELD); + oprot.writeString(message); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(TYPE_FIELD); + oprot.writeI32(errorID); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TBase.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TBase.as new file mode 100644 index 000000000..615db1d75 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TBase.as @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + + import org.apache.thrift.protocol.TProtocol; + + /** + * Generic base interface for generated Thrift objects. + * + */ + public interface TBase { + + /** + * Reads the TObject from the given input protocol. + * + * @param iprot Input protocol + */ + function read(iprot:TProtocol):void; + + /** + * Writes the objects out to the protocol + * + * @param oprot Output protocol + */ + function write(oprot:TProtocol):void; + + /** + * Check if a field is currently set or unset. + * + * @param fieldId The field's id tag as found in the IDL. + */ + function isSet(fieldId:int):Boolean; + + /** + * Get a field's value by id. Primitive types will be wrapped in the + * appropriate "boxed" types. + * + * @param fieldId The field's id tag as found in the IDL. + */ + function getFieldValue(fieldId:int):*; + + /** + * Set a field's value by id. Primitive types must be "boxed" in the + * appropriate object wrapper type. + * + * @param fieldId The field's id tag as found in the IDL. + */ + function setFieldValue(fieldId:int, value:*):void; + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TError.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TError.as new file mode 100644 index 000000000..ccc13b554 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TError.as @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + + public class TError extends Error { + + public function TError(message:String = "", errorCode:int = 0) { + super(message, errorCode); + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TFieldRequirementType.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TFieldRequirementType.as new file mode 100644 index 000000000..6fb4e58f9 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TFieldRequirementType.as @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift { + + /** + * Requirement type constants. + * + */ + public class TFieldRequirementType { + public static const REQUIRED:int = 1; + public static const OPTIONAL:int = 2; + public static const DEFAULT:int = 3; + } + +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TProcessor.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TProcessor.as new file mode 100644 index 000000000..850acc946 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TProcessor.as @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + package org.apache.thrift { + +import org.apache.thrift.protocol.TProtocol; + + /** + * A processor is a generic object which operates upon an input stream and + * writes to some output stream. + * + */ + public interface TProcessor { + function process(input:TProtocol, output:TProtocol):Boolean; + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as new file mode 100644 index 000000000..cb18a1445 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldMetaData.as @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + import flash.utils.Dictionary; + + /** + * This class is used to store meta data about thrift fields. Every field in a + * a struct should have a corresponding instance of this class describing it. + * + */ + public class FieldMetaData { + + public var fieldName:String; + public var requirementType:int; + public var valueMetaData:FieldValueMetaData; + + private static var structMap:Dictionary = new Dictionary(); + + public function FieldMetaData(name:String, req:int, vMetaData:FieldValueMetaData) { + this.fieldName = name; + this.requirementType = req; + this.valueMetaData = vMetaData; + } + + public static function addStructMetaDataMap(sClass:Class, map:Dictionary):void{ + structMap[sClass] = map; + } + + /** + * Returns a map with metadata (i.e. instances of FieldMetaData) that + * describe the fields of the given class. + * + * @param sClass The TBase class for which the metadata map is requested + */ + public static function getStructMetaDataMap(sClass:Class):Dictionary { + return structMap[sClass]; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as new file mode 100644 index 000000000..07fe1be20 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/FieldValueMetaData.as @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + import org.apache.thrift.protocol.TType; + + /** + * FieldValueMetaData and collection of subclasses to store metadata about + * the value(s) of a field + */ + public class FieldValueMetaData { + + public var type:int; + + public function FieldValueMetaData(type:int) { + this.type = type; + } + + public function isStruct():Boolean { + return type == TType.STRUCT; + } + + public function isContainer():Boolean { + return type == TType.LIST || type == TType.MAP || type == TType.SET; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as new file mode 100644 index 000000000..a2cc73288 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/ListMetaData.as @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + public class ListMetaData extends FieldValueMetaData { + + public var elemMetaData:FieldValueMetaData; + + public function ListMetaData(type:int, eMetaData:FieldValueMetaData) { + super(type); + this.elemMetaData = eMetaData; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as new file mode 100644 index 000000000..e7f1f9f08 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/MapMetaData.as @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + public class MapMetaData extends FieldValueMetaData { + + public var keyMetaData:FieldValueMetaData; + public var valueMetaData:FieldValueMetaData; + + public function MapMetaData(type:int, kMetaData:FieldValueMetaData, vMetaData:FieldValueMetaData) { + super(type); + this.keyMetaData = kMetaData; + this.valueMetaData = vMetaData; + } + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as new file mode 100644 index 000000000..390f03468 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/SetMetaData.as @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + public class SetMetaData extends FieldValueMetaData { + + public var elemMetaData:FieldValueMetaData; + + public function SetMetaData(type:int, eMetaData:FieldValueMetaData) { + super(type); + this.elemMetaData = eMetaData; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as new file mode 100644 index 000000000..fc9b0bee6 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/meta_data/StructMetaData.as @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.meta_data { + + public class StructMetaData extends FieldValueMetaData { + + public var structClass:Class; + + public function StructMetaData(type:int, sClass:Class) { + super(type); + this.structClass = sClass; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as new file mode 100644 index 000000000..b2ff9d808 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as @@ -0,0 +1,316 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + import flash.utils.ByteArray; + + import org.apache.thrift.TError; + import org.apache.thrift.transport.THttpClient; + import org.apache.thrift.transport.TTransport; + + /** + * Binary protocol implementation for thrift. + */ + public class TBinaryProtocol implements TProtocol { + + private static var ANONYMOUS_STRUCT:TStruct = new TStruct(); + + protected static const VERSION_MASK:int = int(0xffff0000); + protected static const VERSION_1:int = int(0x80010000); + + protected var strictRead_:Boolean = false; + protected var strictWrite_:Boolean = true; + + /** + * Factory + */ + /* + public static class Factory implements TProtocolFactory { + protected boolean strictRead_ = false; + protected boolean strictWrite_ = true; + + public Factory() { + this(false, true); + } + + public Factory(boolean strictRead, boolean strictWrite) { + strictRead_ = strictRead; + strictWrite_ = strictWrite; + } + + public TProtocol getProtocol(TTransport trans) { + return new TBinaryProtocol(trans, strictRead_, strictWrite_); + } + } + */ + + private var trans_:TTransport; + + /** + * Constructor + */ + public function TBinaryProtocol(trans:TTransport, strictRead:Boolean=false, strictWrite:Boolean=true) { + trans_ = trans; + strictRead_ = strictRead; + strictWrite_ = strictWrite; + } + + public function getTransport():TTransport { + return trans_; + } + + public function writeMessageBegin(message:TMessage):void { + if (strictWrite_) { + var version:int = VERSION_1 | message.type; + writeI32(version); + writeString(message.name); + writeI32(message.seqid); + } else { + writeString(message.name); + writeByte(message.type); + writeI32(message.seqid); + } + } + + public function writeMessageEnd():void {} + + public function writeStructBegin(struct:TStruct):void {} + + public function writeStructEnd():void {} + + public function writeFieldBegin(field:TField):void { + writeByte(field.type); + writeI16(field.id); + } + + public function writeFieldEnd():void {} + + public function writeFieldStop():void { + writeByte(TType.STOP); + } + + public function writeMapBegin(map:TMap):void { + writeByte(map.keyType); + writeByte(map.valueType); + writeI32(map.size); + } + + public function writeMapEnd():void {} + + public function writeListBegin(list:TList):void { + writeByte(list.elemType); + writeI32(list.size); + } + + public function writeListEnd():void {} + + public function writeSetBegin(set:TSet):void { + writeByte(set.elemType); + writeI32(set.size); + } + + public function writeSetEnd():void {} + + public function writeBool(b:Boolean):void { + writeByte(b ? 1 : 0); + } + + private var out:ByteArray = new ByteArray(); + public function writeByte(b:int):void { + reset(out); + out.writeByte(b); + trans_.write(out, 0, 1); + } + + public function writeI16(i16:int):void { + reset(out); + out.writeShort(i16); + trans_.write(out, 0, 2); + } + + public function writeI32(i32:int):void { + reset(out); + out.writeInt(i32); + trans_.write(out, 0, 4); + } + + //private byte[] i64out = new byte[8]; + //public function writeI64(i64:Number):void { + //i64out[0] = (byte)(0xff & (i64 >> 56)); + //i64out[1] = (byte)(0xff & (i64 >> 48)); + //i64out[2] = (byte)(0xff & (i64 >> 40)); + //i64out[3] = (byte)(0xff & (i64 >> 32)); + //i64out[4] = (byte)(0xff & (i64 >> 24)); + //i64out[5] = (byte)(0xff & (i64 >> 16)); + //i64out[6] = (byte)(0xff & (i64 >> 8)); + //i64out[7] = (byte)(0xff & (i64)); + //trans_.write(i64out, 0, 8); + //} + + public function writeDouble(dub:Number):void { + reset(out); + out.writeDouble(dub); + trans_.write(out, 0, 8); + } + + private var stringOut:ByteArray = new ByteArray(); + + public function writeString(str:String):void { + reset(stringOut); + stringOut.writeUTFBytes(str); + + writeI32(stringOut.length); + trans_.write(stringOut, 0, stringOut.length); + } + + public function writeBinary(bin:ByteArray):void { + writeI32(bin.length); + trans_.write(bin, 0, bin.length); + } + + /** + * Reading methods. + */ + + public function readMessageBegin():TMessage { + var size:int = readI32(); + if (size < 0) { + var version:int = size & VERSION_MASK; + if (version != VERSION_1) { + throw new TProtocolError(TProtocolError.BAD_VERSION, "Bad version in readMessageBegin"); + } + return new TMessage(readString(), size & 0x000000ff, readI32()); + } + else { + if (strictRead_) { + throw new TProtocolError(TProtocolError.BAD_VERSION, "Missing version in readMessageBegin, old client?"); + } + return new TMessage(readStringBody(size), readByte(), readI32()); + } + } + + public function readMessageEnd():void {} + + public function readStructBegin():TStruct { + return ANONYMOUS_STRUCT; + } + + public function readStructEnd():void {} + + public function readFieldBegin():TField { + var type:int = readByte(); + var id:int = type == TType.STOP ? 0 : readI16(); + return new TField("", type, id); + } + + public function readFieldEnd():void {} + + public function readMapBegin():TMap { + return new TMap(readByte(), readByte(), readI32()); + } + + public function readMapEnd():void {} + + public function readListBegin():TList { + return new TList(readByte(), readI32()); + } + + public function readListEnd():void {} + + public function readSetBegin():TSet { + return new TSet(readByte(), readI32()); + } + + public function readSetEnd():void {} + + public function readBool():Boolean { + return (readByte() == 1); + } + + private var bytes:ByteArray = new ByteArray(); + + public function readByte():int { + readAll(1); + return bytes.readByte(); + } + + public function readI16():int { + readAll(2); + return bytes.readShort(); + } + + public function readI32():int { + readAll(4); + return bytes.readInt(); + } + + //private byte[] i64rd = new byte[8]; + /* + public function readI64() throws TException { + readAll(i64rd, 0, 8); + return + ((long)(i64rd[0] & 0xff) << 56) | + ((long)(i64rd[1] & 0xff) << 48) | + ((long)(i64rd[2] & 0xff) << 40) | + ((long)(i64rd[3] & 0xff) << 32) | + ((long)(i64rd[4] & 0xff) << 24) | + ((long)(i64rd[5] & 0xff) << 16) | + ((long)(i64rd[6] & 0xff) << 8) | + ((long)(i64rd[7] & 0xff)); + } + */ + + public function readDouble():Number { + readAll(8); + return bytes.readDouble(); + } + + public function readString():String { + var size:int = readI32(); + readAll(size); + return bytes.readUTFBytes(size); + } + + public function readStringBody(size:int):String { + readAll(size); + return bytes.readUTFBytes(size); + } + + public function readBinary():ByteArray { + var size:int = readI32(); + var buf:ByteArray = new ByteArray(); + trans_.readAll(buf, 0, size); + return buf; + } + + private function readAll(len:int):void { + reset(bytes); + + trans_.readAll(bytes, 0, len); + + bytes.position = 0; + } + + private static function reset(arr:ByteArray):void { + arr.length = 0; + arr.position = 0; + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TField.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TField.as new file mode 100644 index 000000000..1277f3a18 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TField.as @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TField { + + public var name:String; + public var type:int; + public var id:int; + + public function TField(n:String = "", t:int = 0, i:int = 0) { + name = n; + type = t; + id = i; + } + + public function toString():String { + return ""; + } + + public function equals(otherField:TField):Boolean { + return type == otherField.type && id == otherField.id; + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TList.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TList.as new file mode 100644 index 000000000..f0bdbadba --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TList.as @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TList { + + public var elemType:int; + public var size:int; + + public function TList(t:int = 0, s:int = 0) { + elemType = t; + size = s; + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMap.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMap.as new file mode 100644 index 000000000..2298804fb --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMap.as @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + public class TMap { + + public var keyType:int; + public var valueType:int; + public var size:int; + + public function TMap(k:int = 0, v:int = 0, s:int = 0) { + keyType = k; + valueType = v; + size = s; + } + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessage.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessage.as new file mode 100644 index 000000000..9817235c3 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessage.as @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TMessage { + + public var name:String; + public var type:int; + public var seqid:int; + + public function TMessage(n:String = "", t:int = 0, s:int = 0) { + name = n; + type = t; + seqid = s; + } + + public function toString():String { + return ""; + } + + public function equals(other:TMessage):Boolean { + return name == other.name && type == other.type && seqid == other.seqid; + } + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessageType.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessageType.as new file mode 100644 index 000000000..56a9ba52b --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TMessageType.as @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TMessageType { + public static const CALL:int = 1; + public static const REPLY:int = 2; + public static const EXCEPTION:int = 3; + public static const ONEWAY:int = 4; + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocol.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocol.as new file mode 100644 index 000000000..bb9d74472 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocol.as @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + import org.apache.thrift.TError; + import org.apache.thrift.transport.TTransport; + + import flash.utils.ByteArray; + + /** + * Protocol interface definition + */ + public interface TProtocol { + + function TProtocol(trans:TTransport); + + function getTransport():TTransport; + + /** + * Writing methods. + */ + function writeMessageBegin(message:TMessage):void; + + function writeMessageEnd():void; + + function writeStructBegin(struct:TStruct):void; + + function writeStructEnd():void; + + function writeFieldBegin(field:TField):void; + + function writeFieldEnd():void; + + function writeFieldStop():void; + + function writeMapBegin(map:TMap):void; + + function writeMapEnd():void; + + function writeListBegin(list:TList):void; + + function writeListEnd():void; + + function writeSetBegin(set:TSet):void; + + function writeSetEnd():void; + + function writeBool(b:Boolean):void; + + function writeByte(b:int):void; + + function writeI16(i16:int):void; + + function writeI32(i32:int):void; + + //function writeI64(i64:Number):void; + + function writeDouble(dub:Number):void; + + function writeString(str:String):void; + + function writeBinary(bin:ByteArray):void; + + /** + * Reading methods. + */ + function readMessageBegin():TMessage; + + function readMessageEnd():void; + + function readStructBegin():TStruct; + + function readStructEnd():void; + + function readFieldBegin():TField; + + function readFieldEnd():void; + + function readMapBegin():TMap; + + function readMapEnd():void; + + function readListBegin():TList; + + function readListEnd():void; + + function readSetBegin():TSet; + + function readSetEnd():void; + + function readBool():Boolean; + + function readByte():int; + + function readI16():int; + + function readI32():int; + + //function readI64():Number; + + function readDouble():Number; + + function readString():String; + + function readBinary():ByteArray; + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as new file mode 100644 index 000000000..9fff73081 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + import org.apache.thrift.TError; + + public class TProtocolError extends TError { + + public static const UNKNOWN:int = 0; + public static const INVALID_DATA:int = 1; + public static const NEGATIVE_SIZE:int = 2; + public static const SIZE_LIMIT:int = 3; + public static const BAD_VERSION:int = 4; + public static const NOT_IMPLEMENTED:int = 5; + public static const DEPTH_LIMIT:int = 6; + + public function TProtocolError(error:int = UNKNOWN, message:String = "") { + super(message, error); + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as new file mode 100644 index 000000000..c7f5e2995 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolFactory.as @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + import org.apache.thrift.transport.TTransport; + + public interface TProtocolFactory { + function getProtocol(trans:TTransport):TProtocol; + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as new file mode 100644 index 000000000..22877b75b --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TProtocolUtil.as @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + import org.apache.thrift.TError; + + /** + * Utility class with static methods for interacting with protocol data + * streams. + * + */ + public class TProtocolUtil { + + /** + * The maximum recursive depth the skip() function will traverse before + * throwing a TException. + */ + private static var maxSkipDepth:int = int.MAX_VALUE; + + /** + * Specifies the maximum recursive depth that the skip function will + * traverse before throwing a TException. This is a global setting, so + * any call to skip in this JVM will enforce this value. + * + * @param depth the maximum recursive depth. A value of 2 would allow + * the skip function to skip a structure or collection with basic children, + * but it would not permit skipping a struct that had a field containing + * a child struct. A value of 1 would only allow skipping of simple + * types and empty structs/collections. + */ + public function setMaxSkipDepth(depth:int):void { + maxSkipDepth = depth; + } + + /** + * Skips over the next data element from the provided input TProtocol object. + * + * @param prot the protocol object to read from + * @param type the next value will be intepreted as this TType value. + */ + public static function skip(prot:TProtocol, type:int):void { + skipMaxDepth(prot, type, maxSkipDepth); + } + + /** + * Skips over the next data element from the provided input TProtocol object. + * + * @param prot the protocol object to read from + * @param type the next value will be intepreted as this TType value. + * @param maxDepth this function will only skip complex objects to this + * recursive depth, to prevent Java stack overflow. + */ + public static function skipMaxDepth(prot:TProtocol, type:int, maxDepth:int):void { + if (maxDepth <= 0) { + throw new TError("Maximum skip depth exceeded"); + } + switch (type) { + case TType.BOOL: { + prot.readBool(); + break; + } + case TType.BYTE: { + prot.readByte(); + break; + } + case TType.I16: { + prot.readI16(); + break; + } + case TType.I32: { + prot.readI32(); + break; + } + /* + case TType.I64: { + prot.readI64(); + break; + } + */ + case TType.DOUBLE: { + prot.readDouble(); + break; + } + case TType.STRING: { + prot.readBinary(); + break; + } + case TType.STRUCT: { + prot.readStructBegin(); + while (true) { + var field:TField = prot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + skipMaxDepth(prot, field.type, maxDepth - 1); + prot.readFieldEnd(); + } + prot.readStructEnd(); + break; + } + case TType.MAP: { + var map:TMap = prot.readMapBegin(); + for (var i:int = 0; i < map.size; i++) { + skipMaxDepth(prot, map.keyType, maxDepth - 1); + skipMaxDepth(prot, map.valueType, maxDepth - 1); + } + prot.readMapEnd(); + break; + } + case TType.SET: { + var set:TSet = prot.readSetBegin(); + for (var j:int = 0; j < set.size; j++) { + skipMaxDepth(prot, set.elemType, maxDepth - 1); + } + prot.readSetEnd(); + break; + } + case TType.LIST: { + var list:TList = prot.readListBegin(); + for (var k:int = 0; k < list.size; k++) { + skipMaxDepth(prot, list.elemType, maxDepth - 1); + } + prot.readListEnd(); + break; + } + default: + throw new TProtocolError(TProtocolError.INVALID_DATA, "invalid data"); + } + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TSet.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TSet.as new file mode 100644 index 000000000..3f0e1a604 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TSet.as @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TSet { + + public var elemType:int; + public var size:int; + + public function TSet(t:int = 0, s:int = 0) { + elemType = t; + size = s; + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TStruct.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TStruct.as new file mode 100644 index 000000000..dffad79f6 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TStruct.as @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TStruct { + + public var name:String; + + public function TStruct(n:String = "") { + name = n; + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TType.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TType.as new file mode 100644 index 000000000..69af208c1 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/protocol/TType.as @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol { + + public class TType { + + public static const STOP:int = 0; + public static const VOID:int = 1; + public static const BOOL:int = 2; + public static const BYTE:int = 3; + public static const DOUBLE:int = 4; + public static const I16:int = 6; + public static const I32:int = 8; + public static const I64:int = 10; + public static const STRING:int = 11; + public static const STRUCT:int = 12; + public static const MAP:int = 13; + public static const SET:int = 14; + public static const LIST:int = 15; + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as new file mode 100644 index 000000000..863c59b35 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TFullDuplexHttpClient.as @@ -0,0 +1,251 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.transport +{ + + import flash.errors.EOFError; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; + import flash.events.SecurityErrorEvent; + import flash.net.URLLoader; + import flash.net.URLLoaderDataFormat; + import flash.net.URLRequest; + import flash.net.URLRequestMethod; + import flash.utils.IDataInput; + import flash.utils.IDataOutput; + import flash.utils.ByteArray; + import flash.net.Socket; + import flash.events.EventDispatcher; + + + /** + * HTTP implementation of the TTransport interface. Used for working with a + * Thrift web services implementation. + * Unlike Http Client, it uses a single POST, and chunk-encoding to transfer all messages. + */ + + public class TFullDuplexHttpClient extends TTransport + { + private var socket:Socket = null; + + private var host:String; + + private var port:int; + + private var resource:String; + + private var stripped:Boolean = false; + + private var obuffer:ByteArray = new ByteArray(); + + private var input:IDataInput; + + private var output:IDataOutput; + + private var bytesInChunk:int = 0; + + private var CRLF:ByteArray = new ByteArray(); + + private var ioCallback:Function = null; + + private var eventDispatcher:EventDispatcher = new EventDispatcher(); + + public function TFullDuplexHttpClient(host:String, port:int, resource:String):void + { + CRLF.writeByte(13); + CRLF.writeByte(10); + this.host = host; + this.port = port; + this.resource = resource; + } + + public override function close():void + { + this.input = null; + this.output = null; + this.stripped = false; + socket.close() + } + + public override function peek():Boolean + { + if(socket.connected) + { + trace("Bytes remained:" + socket.bytesAvailable); + return socket.bytesAvailable>0; + } + return false; + } + + public override function read(buf:ByteArray, off:int, len:int):int + { + var n1:int = 0, n2:int = 0, n3:int = 0, n4:int = 0, cidx:int = 2; + var chunkSize:ByteArray = new ByteArray(); + + try + { + while (!stripped) + { + n1 = n2; + n2 = n3; + n3 = n4; + n4 = input.readByte(); + if ((n1 == 13) && (n2 == 10) && (n3 == 13) && (n4 == 10)) + { + stripped = true; + } + } + + // read chunk size + if (bytesInChunk == 0) + { + n1 = input.readByte(); + n2 = input.readByte(); + + chunkSize.writeByte(n1); + chunkSize.writeByte(n2); + + while (!((n1 == 13) && (n2 == 10))) + { + n1 = n2; + n2 = input.readByte(); + chunkSize.writeByte(n2); + } + + bytesInChunk = parseInt(chunkSize.toString(), 16); + } + + input.readBytes(buf, off, len); + debugBuffer(buf); + bytesInChunk -= len; + + if (bytesInChunk == 0) + { + // advance the : "\r\n" + input.readUTFBytes(2); + } + return len; + } + catch (e:EOFError) + { + trace(e); + throw new TTransportError(TTransportError.UNKNOWN, "No more data available."); + } + catch (e:Error) + { + trace(e); + // WTF?? + throw new TTransportError(TTransportError.UNKNOWN, "Bad IO error:" + e); + } + return 0; + } + + public function debugBuffer(buf:ByteArray):void + { + var debug:String = "BUFFER >>"; + var i:int; + for (i = 0; i < buf.length; i++) + { + debug += buf[i] as int; + debug += " "; + } + + trace(debug + "<<"); + } + + public override function write(buf:ByteArray, off:int, len:int):void + { + obuffer.writeBytes(buf, off, len); + } + + public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void + { + this.eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); + } + + public override function open():void + { + this.socket = new Socket(); + this.socket.addEventListener(Event.CONNECT, socketConnected); + this.socket.addEventListener(IOErrorEvent.IO_ERROR, socketError); + this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, socketSecurityError); + this.socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler); + this.socket.connect(host, port); + } + + public function socketConnected(event:Event):void + { + this.output = this.socket; + this.input = this.socket; + this.output.writeUTF("CONNECT " + resource + " HTTP/1.1\n" + "Host: " + host + ":" + port + "\r\n" + "User-Agent: Thrift/AS3\r\n" + "Transfer-Encoding: chunked\r\n" + "content-type: application/x-thrift\r\n" + "Accept: */*\r\n\r\n"); + this.eventDispatcher.dispatchEvent(event); + } + + public function socketError(event:IOErrorEvent):void + { + trace("Error Connecting:" + event); + this.close(); + if (ioCallback == null) + { + return; + } + ioCallback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text)); + this.eventDispatcher.dispatchEvent(event); + } + + public function socketSecurityError(event:SecurityErrorEvent):void + { + trace("Security Error Connecting:" + event); + this.close(); + this.eventDispatcher.dispatchEvent(event); + } + + public function socketDataHandler(event:ProgressEvent):void + { + trace("Got Data call:" +ioCallback); + if (ioCallback != null) + { + ioCallback(null); + }; + this.eventDispatcher.dispatchEvent(event); + } + + public override function flush(callback:Function = null):void + { + trace("set callback:" + callback); + this.ioCallback = callback; + this.output.writeUTF(this.obuffer.length.toString(16)); + this.output.writeBytes(CRLF); + this.output.writeBytes(this.obuffer); + this.output.writeBytes(CRLF); + this.socket.flush(); + // waiting for new Flex sdk 3.5 + //this.obuffer.clear(); + this.obuffer = new ByteArray(); + } + + public override function isOpen():Boolean + { + return (this.socket == null ? false : this.socket.connected); + } + + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/THttpClient.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/THttpClient.as new file mode 100644 index 000000000..435f91132 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/THttpClient.as @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.transport { + + import flash.errors.EOFError; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.SecurityErrorEvent; + import flash.net.URLLoader; + import flash.net.URLLoaderDataFormat; + import flash.net.URLRequest; + import flash.net.URLRequestMethod; + import flash.system.Capabilities; + import flash.utils.ByteArray; + + /** + * HTTP implementation of the TTransport interface. Used for working with a + * Thrift web services implementation. + */ + public class THttpClient extends TTransport { + + private var request_:URLRequest = null; + private var requestBuffer_:ByteArray = new ByteArray(); + private var responseBuffer_:ByteArray = null; + private var traceBuffers_:Boolean = Capabilities.isDebugger; + + + public function getBuffer():ByteArray { + return requestBuffer_; + } + + public function THttpClient(request:URLRequest, traceBuffers:Boolean=true):void { + request.contentType = "application/x-thrift"; + request_ = request; + if(traceBuffers == false) { + traceBuffers_ = traceBuffers; + } + } + + public override function open():void { + } + + public override function close():void { + } + + public override function isOpen():Boolean { + return true; + } + + public override function read(buf:ByteArray, off:int, len:int):int { + if (responseBuffer_ == null) { + throw new TTransportError(TTransportError.UNKNOWN, "Response buffer is empty, no request."); + } + try { + responseBuffer_.readBytes(buf, off, len); + if (traceBuffers_) { + dumpBuffer(buf, "READ"); + } + return len; + } + catch (e:EOFError) { + if (traceBuffers_) { + dumpBuffer(requestBuffer_, "FAILED-RESPONSE-REQUEST"); + dumpBuffer(responseBuffer_, "FAILED-RESPONSE"); + } + throw new TTransportError(TTransportError.UNKNOWN, "No more data available."); + } + return 0; + } + + public override function write(buf:ByteArray, off:int, len:int):void { + requestBuffer_.writeBytes(buf, off, len); + } + + public override function flush(callback:Function=null):void { + var loader:URLLoader = new URLLoader(); + if (callback != null) { + loader.addEventListener(Event.COMPLETE, function(event:Event):void { + responseBuffer_ = URLLoader(event.target).data; + if (traceBuffers_) { + dumpBuffer(responseBuffer_, "RESPONSE_BUFFER"); + } + callback(null); + responseBuffer_ = null; + }); + loader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void { + callback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text)); + responseBuffer_ = null; + }); + loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(event:SecurityErrorEvent):void { + callback(new TTransportError(TTransportError.UNKNOWN, "SecurityError: " + event.text)); + responseBuffer_ = null; + }); + } + request_.method = URLRequestMethod.POST; + loader.dataFormat = URLLoaderDataFormat.BINARY; + requestBuffer_.position = 0; + request_.data = requestBuffer_; + loader.load(request_); + } + + private function dumpBuffer(buf:ByteArray, prefix:String):String { + var debugString : String = prefix + " BUFFER "; + if (buf != null) { + debugString += "length: " + buf.length + ", "; + for (var i : int = 0; i < buf.length; i++) { + debugString += "[" + buf[i].toString(16) + "]"; + } + } else { + debugString = "null"; + } + trace(debugString); + return debugString; + } + + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TSocket.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TSocket.as new file mode 100644 index 000000000..c60d7115e --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TSocket.as @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.transport +{ + + import flash.events.EventDispatcher; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; + import flash.events.SecurityErrorEvent; + import flash.errors.EOFError; + import flash.errors.IOError; + import flash.net.URLLoader; + import flash.net.URLLoaderDataFormat; + import flash.net.URLRequest; + import flash.net.URLRequestMethod; + import flash.utils.IDataInput; + import flash.utils.IDataOutput; + import flash.utils.ByteArray; + import flash.net.Socket; + + + /** + * Socket implementation of the TTransport interface. Used for working with a + * Thrift Socket Server based implementations. + */ + + public class TSocket extends TTransport + { + private var socket:Socket = null; + + private var host:String; + + private var port:int; + + private var obuffer:ByteArray = new ByteArray(); + + private var input:IDataInput; + + private var output:IDataOutput; + + private var ioCallback:Function = null; + + private var eventDispatcher:EventDispatcher = new EventDispatcher(); + + public function TSocket(host:String, port:int):void + { + this.host = host; + this.port = port; + } + + public override function close():void + { + this.input = null; + this.output = null; + socket.close() + } + + public override function peek():Boolean + { + if(socket.connected) + { + trace("Bytes remained:" + socket.bytesAvailable); + return socket.bytesAvailable>0; + } + return false; + } + + public override function read(buf:ByteArray, off:int, len:int):int + { + var n1:int = 0, n2:int = 0, n3:int = 0, n4:int = 0, cidx:int = 2; + var chunkSize:ByteArray = new ByteArray(); + + try + { + input.readBytes(buf, off, len); + return len; + } + catch (e:EOFError) + { + trace(e); + throw new TTransportError(TTransportError.END_OF_FILE, "No more data available."); + } + catch (e:IOError) + { + trace(e); + if(isOpen()) + { + throw new TTransportError(TTransportError.UNKNOWN, "IO error while reading: " + e); + } + else + { + throw new TTransportError(TTransportError.NOT_OPEN, "Socket seem not to be opened: " + e); + } + } + catch (e:Error) + { + trace(e); + throw new TTransportError(TTransportError.UNKNOWN, "Bad IO error: " + e); + } + return 0; + } + + public override function write(buf:ByteArray, off:int, len:int):void + { + obuffer.writeBytes(buf, off, len); + } + + public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void + { + this.eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); + } + + public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void + { + this.eventDispatcher.removeEventListener(type, listener, useCapture); + } + + public override function open():void + { + this.socket = new Socket(); + this.socket.addEventListener(Event.CONNECT, socketConnected); + this.socket.addEventListener(IOErrorEvent.IO_ERROR, socketError); + this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, socketSecurityError); + this.socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler); + this.socket.connect(host, port); + } + + public function socketConnected(event:Event):void + { + this.output = this.socket; + this.input = this.socket; + this.eventDispatcher.dispatchEvent(event); + } + + public function socketError(event:IOErrorEvent):void + { + trace("Error Connecting:" + event); + this.close(); + if (ioCallback == null) + { + return; + } + ioCallback(new TTransportError(TTransportError.UNKNOWN, "IOError: " + event.text)); + this.eventDispatcher.dispatchEvent(event); + } + + public function socketSecurityError(event:SecurityErrorEvent):void + { + trace("Security Error Connecting:" + event); + this.close(); + this.eventDispatcher.dispatchEvent(event); + } + + public function socketDataHandler(event:ProgressEvent):void + { + if (ioCallback != null) + { + ioCallback(null); + } + this.eventDispatcher.dispatchEvent(event); + } + + public override function flush(callback:Function = null):void + { + this.ioCallback = callback; + this.output.writeBytes(this.obuffer); + this.socket.flush(); + this.obuffer.clear(); + } + + public override function isOpen():Boolean + { + return (this.socket == null ? false : this.socket.connected); + } + } +} diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransport.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransport.as new file mode 100644 index 000000000..83160af69 --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransport.as @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.transport { + + import flash.utils.ByteArray; + import org.apache.thrift.AbstractMethodError; + + public class TTransport { + + /** + * Queries whether the transport is open. + * + * @return True if the transport is open. + */ + public function isOpen():Boolean { + throw new AbstractMethodError(); + } + + /** + * Is there more data to be read? + * + * @return True if the remote side is still alive and feeding us + */ + public function peek():Boolean { + return isOpen(); + } + + /** + * Opens the transport for reading/writing. + * + * @throws TTransportException if the transport could not be opened + */ + public function open():void { + throw new AbstractMethodError(); + } + + /** + * Closes the transport. + */ + public function close():void { + throw new AbstractMethodError(); + }; + + /** + * Reads up to len bytes into buffer buf, starting att offset off. + * + * @param buf Array to read into + * @param off Index to start reading at + * @param len Maximum number of bytes to read + * @return The number of bytes actually read + * @throws TTransportException if there was an error reading data + */ + public function read(buf:ByteArray, off:int, len:int):int { + throw new AbstractMethodError(); + } + + /** + * Guarantees that all of len bytes are actually read off the transport. + * + * @param buf Array to read into + * @param off Index to start reading at + * @param len Maximum number of bytes to read + * @return The number of bytes actually read, which must be equal to len + * @throws TTransportException if there was an error reading data + */ + public function readAll(buf:ByteArray, off:int, len:int):int { + var got:int = 0; + var ret:int = 0; + while (got < len) { + ret = read(buf, off+got, len-got); + if (ret <= 0) { + throw new TTransportError(TTransportError.UNKNOWN, "Cannot read. Remote side has closed. Tried to read " + len + " bytes, but only got " + got + " bytes."); + } + got += ret; + } + return got; + } + + /** + * Writes the buffer to the output + * + * @param buf The output data buffer + * @throws TTransportException if an error occurs writing data + */ + public function writeAll(buf:ByteArray):void { + write(buf, 0, buf.length); + } + + /** + * Writes up to len bytes from the buffer. + * + * @param buf The output data buffer + * @param off The offset to start writing from + * @param len The number of bytes to write + * @throws TTransportException if there was an error writing data + */ + public function write(buf:ByteArray, off:int, len:int):void { + throw new AbstractMethodError(); + } + + /** + * Flush any pending data out of a transport buffer. + * + * @throws TTransportException if there was an error writing out data. + */ + public function flush(callback:Function=null):void { + throw new AbstractMethodError(); + } + } +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransportError.as b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransportError.as new file mode 100644 index 000000000..10a6f621b --- /dev/null +++ b/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/transport/TTransportError.as @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.transport { + + import org.apache.thrift.TError; + + public class TTransportError extends TError { + + public static const UNKNOWN:int = 0; + public static const NOT_OPEN:int = 1; + public static const ALREADY_OPEN:int = 2; + public static const TIMED_OUT:int = 3; + public static const END_OF_FILE:int = 4; + + public function TTransportError(error:int = UNKNOWN, message:String = "") { + super(message, error); + } + + } +} \ No newline at end of file -- cgit v1.2.3