├── .github ├── dependabot.yml └── workflows │ ├── integration.sh │ ├── integration.yml │ ├── interop-mode.yml │ ├── unit-manual.yml │ └── unit.yml ├── .gitignore ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── assets └── images │ ├── clone.png │ ├── fork.jpg │ ├── jira.png │ └── jira_start_progress.png ├── pom.xml ├── protocol.txt └── src ├── config ├── checkstyle-suppressions.xml └── checkstyle.xml ├── main ├── java │ └── org │ │ └── jboss │ │ └── ejb │ │ ├── _private │ │ ├── Keys.java │ │ ├── Logs.java │ │ └── NetworkUtil.java │ │ ├── client │ │ ├── AbstractEJBMetaData.java │ │ ├── AbstractInvocationContext.java │ │ ├── AbstractReceiverInvocationContext.java │ │ ├── Affinity.java │ │ ├── ArrayUtil.java │ │ ├── Attachable.java │ │ ├── AttachmentKey.java │ │ ├── AttachmentKeys.java │ │ ├── AuthenticationContextEJBClientInterceptor.java │ │ ├── BasicSessionID.java │ │ ├── CaptureCurrentAuthCtxSupplier.java │ │ ├── ClusterAffinity.java │ │ ├── ClusterAffinityInterest.java │ │ ├── ClusterNodeSelector.java │ │ ├── ConfigurationBasedEJBClientContextSelector.java │ │ ├── DeploymentNodeSelector.java │ │ ├── DiscoveredURISelector.java │ │ ├── DiscoveryEJBClientInterceptor.java │ │ ├── EJBClient.java │ │ ├── EJBClientCluster.java │ │ ├── EJBClientConnection.java │ │ ├── EJBClientContext.java │ │ ├── EJBClientInterceptor.java │ │ ├── EJBClientInterceptorInformation.java │ │ ├── EJBClientInvocationContext.java │ │ ├── EJBClientPermission.java │ │ ├── EJBHandle.java │ │ ├── EJBHomeHandle.java │ │ ├── EJBHomeLocator.java │ │ ├── EJBIdentifier.java │ │ ├── EJBInvocationHandler.java │ │ ├── EJBLocator.java │ │ ├── EJBMetaDataImpl.java │ │ ├── EJBMethodLocator.java │ │ ├── EJBModuleIdentifier.java │ │ ├── EJBNamingContextFactory.java │ │ ├── EJBProxyInformation.java │ │ ├── EJBProxyInterceptorInformation.java │ │ ├── EJBReceiver.java │ │ ├── EJBReceiverContext.java │ │ ├── EJBReceiverInvocationContext.java │ │ ├── EJBReceiverSessionCreationContext.java │ │ ├── EJBRootContext.java │ │ ├── EJBSessionCreationInvocationContext.java │ │ ├── EJBTransportProvider.java │ │ ├── EntityEJBLocator.java │ │ ├── EntityEJBMetaData.java │ │ ├── FinishedFuture.java │ │ ├── FixedSupplier.java │ │ ├── NamingEJBClientInterceptor.java │ │ ├── NodeAffinity.java │ │ ├── RemoteEJBPermission.java │ │ ├── RequestSendFailedException.java │ │ ├── SecurityUtils.java │ │ ├── SerializedEJBInvocationHandler.java │ │ ├── SessionID.java │ │ ├── StatefulEJBLocator.java │ │ ├── StatefulEJBMetaData.java │ │ ├── StatelessEJBLocator.java │ │ ├── StatelessEJBMetaData.java │ │ ├── SystemProperties.java │ │ ├── TransactionID.java │ │ ├── TransactionInterceptor.java │ │ ├── TransactionPostDiscoveryInterceptor.java │ │ ├── URIAffinity.java │ │ ├── UUIDSessionID.java │ │ ├── UnknownSessionID.java │ │ ├── UserTransactionID.java │ │ ├── Version.java │ │ ├── XidTransactionID.java │ │ ├── annotation │ │ │ ├── ClientAsynchronous.java │ │ │ ├── ClientInterceptorPriority.java │ │ │ ├── ClientInterceptors.java │ │ │ ├── ClientTransaction.java │ │ │ ├── ClientTransactionPolicy.java │ │ │ ├── CompressionHint.java │ │ │ └── Idempotent.java │ │ ├── legacy │ │ │ ├── CommonLegacyConfiguration.java │ │ │ ├── DiscoveryLegacyConfiguration.java │ │ │ ├── ElytronLegacyConfiguration.java │ │ │ ├── JBossEJBProperties.java │ │ │ ├── LegacyPropertiesConfiguration.java │ │ │ ├── RemotingLegacyConfiguration.java │ │ │ ├── SecurityUtils.java │ │ │ └── SystemProperties.java │ │ └── naming │ │ │ └── ejb │ │ │ └── ejbURLContextFactory.java │ │ ├── protocol │ │ └── remote │ │ │ ├── AbstractWritingExternalizer.java │ │ │ ├── ByteExternalizer.java │ │ │ ├── CallbackBuffer.java │ │ │ ├── DiscoveredNodeRegistry.java │ │ │ ├── EENamespaceInteroperability.java │ │ │ ├── EJBClientChannel.java │ │ │ ├── EJBMarshallingCompatibilityHelper.java │ │ │ ├── EJBServerChannel.java │ │ │ ├── EJBSimpleTransactionControl.java │ │ │ ├── EJBTransactionOperations.java │ │ │ ├── EJBTransactionProvider.java │ │ │ ├── NoFlushByteOutput.java │ │ │ ├── NodeInformation.java │ │ │ ├── PackedInteger.java │ │ │ ├── Protocol.java │ │ │ ├── ProtocolClassResolver.java │ │ │ ├── ProtocolObjectResolver.java │ │ │ ├── ProtocolV1ClassTable.java │ │ │ ├── ProtocolV1ObjectPreResolver.java │ │ │ ├── ProtocolV1ObjectResolver.java │ │ │ ├── ProtocolV1ObjectTable.java │ │ │ ├── ProtocolV3ObjectResolver.java │ │ │ ├── ProtocolV3ObjectTable.java │ │ │ ├── RemoteEJBDiscoveryConfigurator.java │ │ │ ├── RemoteEJBReceiver.java │ │ │ ├── RemoteEJBService.java │ │ │ ├── RemoteTransportProvider.java │ │ │ ├── RemotingEJBClientInterceptor.java │ │ │ ├── RemotingEJBDiscoveryProvider.java │ │ │ ├── RetryExecutorWrapper.java │ │ │ ├── SecurityUtils.java │ │ │ ├── StackTraceElement4.java │ │ │ ├── SystemProperties.java │ │ │ ├── TCCLUtils.java │ │ │ ├── V1EJBLocator.java │ │ │ └── WrapperMessageOutputStream.java │ │ └── server │ │ ├── Association.java │ │ ├── CancelHandle.java │ │ ├── ClusterTopologyListener.java │ │ ├── InvocationRequest.java │ │ ├── ListenerHandle.java │ │ ├── ModuleAvailabilityListener.java │ │ ├── Request.java │ │ └── SessionOpenRequest.java └── resources │ ├── org │ └── jboss │ │ └── ejb │ │ └── client │ │ └── Version.properties │ └── schema │ ├── wildfly-client-ejb_3_0.xsd │ ├── wildfly-client-ejb_3_1.xsd │ └── wildfly-client-ejb_3_2.xsd └── test ├── java └── org │ └── jboss │ └── ejb │ ├── client │ ├── ConfigurationBasedEJBClientContextSelectorTestCase.java │ ├── DiscoveryEJBClientInterceptorTestCase.java │ ├── DummyClientInterceptor.java │ ├── DummyClientInterceptor2.java │ ├── DummyNodeSelector.java │ ├── EJBRootContextTestCase.java │ ├── ProxyEqualityTestCase.java │ ├── SimpleInterface.java │ ├── legacy │ │ └── LegacyPropertiesConfigurationTestCase.java │ ├── remoting │ │ └── MethodInvocationRequest.java │ ├── serialization │ │ └── ProxySerializationTestCase.java │ └── test │ │ ├── AbstractEJBClientTestCase.java │ │ ├── ClassCallback.java │ │ ├── ClusterNodeSelectorTestCase.java │ │ ├── ClusteredInvocationFailOverTestCase.java │ │ ├── ClusteredInvocationTestCase.java │ │ ├── DefaultConfigurationDiscoveryTestCase.java │ │ ├── DeploymentNodeSelectorTestCase.java │ │ ├── InterruptRunningCallTestCase.java │ │ ├── JBossEJBPropertiesTestCase.java │ │ ├── LastNodeToLeaveTestCase.java │ │ ├── LearningTestCase.java │ │ ├── ManualTestRunner.java │ │ ├── NetworkBlackHoleInvocationTestCase.java │ │ ├── RemoteDiscoveryTimeoutTestCase.java │ │ ├── SimpleInvocationTestCase.java │ │ ├── TransactionTestCase.java │ │ ├── UnmarshallingFilterTestCase.java │ │ ├── WildflyClientXMLTestCase.java │ │ ├── byteman │ │ ├── BytemanTransactionTestCase.java │ │ ├── MixedModeServiceURLTestCase.java │ │ ├── MixedModeTestHelper.java │ │ ├── OOMEInInvocationTestCase.java │ │ └── TimeoutRetryTestCase.java │ │ └── common │ │ ├── DummyAssociationImpl.java │ │ ├── DummyServer.java │ │ ├── Echo.java │ │ ├── EchoBean.java │ │ ├── Foo.java │ │ ├── FooBean.java │ │ ├── Result.java │ │ ├── StatefulEchoBean.java │ │ ├── StatelessEchoBean.java │ │ ├── TypeReporter.java │ │ └── TypeReporterBean.java │ └── protocol │ └── remote │ └── NetworkUtilTestCase.java └── resources ├── broken-server-jboss-ejb-client.properties ├── cluster-node-selector-jboss-ejb-client.properties ├── clustered-jboss-ejb-client.properties ├── complete-jboss-ejb-client.properties ├── deployment-node-selector-jboss-ejb-client.properties ├── jboss-ejb-client.properties ├── jndi.properties ├── last-node-to-leave-jboss-ejb-client.properties ├── logging.properties ├── maximum-connected-nodes-jboss-ejb-client.properties ├── mixed-mode-wildfly-client.xml ├── no-protocol-jboss-ejb-client.properties ├── org └── jboss │ └── ejb │ └── client │ └── test │ └── byteman │ ├── BytemanTransactionTestCase.btm │ ├── OOMEInInvocationTestCase.btm │ └── TimeoutRetryTestCase.btm └── wildfly-client.xml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "maven" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | open-pull-requests-limit: 10 13 | - package-ecosystem: "github-actions" 14 | directory: "/" 15 | schedule: 16 | interval: "daily" 17 | -------------------------------------------------------------------------------- /.github/workflows/integration.sh: -------------------------------------------------------------------------------- 1 | echo "INTEGRATION TESTS" 2 | 3 | EJB_CLIENT_REPOSITORY=$1 4 | EJB_CLIENT_BRANCH=$2 5 | 6 | git clone --depth=1 https://github.com/wildfly/ejb-client-testsuite 7 | 8 | cd ejb-client-testsuite 9 | 10 | mvn -B -ntp package -DspecificModule=prepare -Dejb.client.repository=${EJB_CLIENT_REPOSITORY} -Dejb.client.branch=${EJB_CLIENT_BRANCH} 11 | mvn -B -ntp dependency:tree clean verify --fail-at-end 12 | 13 | -------------------------------------------------------------------------------- /.github/workflows/integration.yml: -------------------------------------------------------------------------------- 1 | name: Wildfly EJB Client CI Integration Tests 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize, reopened, ready_for_review] 6 | 7 | jobs: 8 | build-test-matrix: 9 | name: ${{ matrix.jdk-distribution}}-${{ matrix.jdk-version }}-${{ matrix.os }} 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: [ubuntu-latest] 15 | jdk-distribution: [temurin] 16 | jdk-version: [17] 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }} 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: ${{ matrix.jdk-distribution }} 23 | java-version: ${{ matrix.jdk-version }} 24 | cache: 'maven' 25 | - name: Run Tests 26 | run: bash ${GITHUB_WORKSPACE}/.github/workflows/integration.sh ${{github.event.pull_request.head.repo.html_url}} ${{github.head_ref}} 27 | - uses: actions/upload-artifact@v4 28 | if: failure() 29 | with: 30 | name: surefire-${{ matrix.jdk-distribution }}-${{ matrix.jdk-version }}-${{ matrix.os }} 31 | path: '**/surefire-reports/*.txt' 32 | -------------------------------------------------------------------------------- /.github/workflows/interop-mode.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: ee-namespace-interop profile 5 | 6 | on: 7 | pull_request: 8 | types: [opened, synchronize, reopened, ready_for_review] 9 | 10 | jobs: 11 | build-test-matrix: 12 | name: ${{ matrix.jdk-distribution}}-${{ matrix.jdk-version }}-${{ matrix.os }} 13 | runs-on: ${{ matrix.os }} 14 | timeout-minutes: 15 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, windows-latest] 19 | jdk-distribution: [adopt-openj9] 20 | jdk-version: [11, 17] 21 | steps: 22 | - name: Configure runner - Linux 23 | if: contains(matrix.os, 'ubuntu') 24 | run: | 25 | sudo bash -c "echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts" 26 | sudo bash -c "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts" 27 | - name: Configure Runner - Windows 28 | if: contains(matrix.os, 'windows') 29 | run: | 30 | echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > %SystemRoot%\System32\drivers\etc\hosts 31 | echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> %SystemRoot%\System32\drivers\etc\hosts 32 | shell: cmd 33 | - uses: actions/checkout@v4 34 | - name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }} 35 | uses: actions/setup-java@v4 36 | with: 37 | distribution: ${{ matrix.jdk-distribution }} 38 | java-version: ${{ matrix.jdk-version }} 39 | cache: 'maven' 40 | - name: Run Tests 41 | run: mvn -ntp -U -B -fae clean verify -Pee-namespace-interop 42 | - uses: actions/upload-artifact@v4 43 | if: failure() 44 | with: 45 | name: surefire-ee-interop-${{ matrix.jdk-distribution }}-${{ matrix.jdk-version }}-${{ matrix.os }} 46 | path: '**/surefire-ee-interoperable-reports/*.txt' 47 | -------------------------------------------------------------------------------- /.github/workflows/unit-manual.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Manual Unit Tests 5 | on: 6 | workflow_dispatch: 7 | inputs: 8 | profile: 9 | description: 'Profile' 10 | required: false 11 | default: 'allTests' 12 | type: choice 13 | options: 14 | - allTests 15 | - ee-namespace-interop 16 | os: 17 | description: 'OS' 18 | required: false 19 | default: 'ubuntu-latest' 20 | type: choice 21 | options: 22 | - ubuntu-latest 23 | - windows-latest 24 | - macos-latest 25 | jdk-distribution: 26 | description: 'JDK Distribution' 27 | required: false 28 | default: 'temurin' 29 | type: choice 30 | options: 31 | - temurin 32 | - semeru 33 | - microsoft 34 | - oracle 35 | - zulu 36 | - corretto 37 | - liberica 38 | jdk-version: 39 | description: 'JDK Version' 40 | required: false 41 | default: '11' 42 | type: choice 43 | options: 44 | - 11 45 | - 17 46 | 47 | jobs: 48 | build-test: 49 | name: ${{ inputs.jdk-distribution}}-${{ inputs.jdk-version }}-${{ inputs.os }} 50 | runs-on: ${{ inputs.os }} 51 | timeout-minutes: 25 52 | strategy: 53 | fail-fast: false 54 | steps: 55 | - uses: actions/checkout@v4 56 | - name: Set up JDK ${{ inputs.jdk-distribution }} ${{ inputs.jdk-version }} 57 | uses: actions/setup-java@v4 58 | with: 59 | distribution: ${{ inputs.jdk-distribution }} 60 | java-version: ${{ inputs.jdk-version }} 61 | cache: 'maven' 62 | - name: Run Tests 63 | run: mvn -ntp -U -B -fae -P${{ inputs.profile }} clean verify 64 | - uses: actions/upload-artifact@v4 65 | if: failure() 66 | with: 67 | name: ${{ inputs.profile }}-${{ inputs.jdk-distribution }}-${{ inputs.jdk-version }}-${{ inputs.os }} 68 | path: '**/surefire-reports/*.txt' 69 | -------------------------------------------------------------------------------- /.github/workflows/unit.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Wildfly EJB Client CI Unit Tests 5 | 6 | on: 7 | pull_request: 8 | types: [opened, synchronize, reopened, ready_for_review] 9 | 10 | jobs: 11 | build-test-matrix: 12 | name: ${{ matrix.jdk-distribution}}-${{ matrix.jdk-version }}-${{ matrix.os }} 13 | runs-on: ${{ matrix.os }} 14 | timeout-minutes: 15 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, windows-latest] 19 | jdk-distribution: [temurin] 20 | jdk-version: [11, 17] 21 | steps: 22 | - name: Configure runner - Linux 23 | if: contains(matrix.os, 'ubuntu') 24 | run: | 25 | sudo bash -c "echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts" 26 | sudo bash -c "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts" 27 | - name: Configure Runner - Windows 28 | if: contains(matrix.os, 'windows') 29 | run: | 30 | echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > %SystemRoot%\System32\drivers\etc\hosts 31 | echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> %SystemRoot%\System32\drivers\etc\hosts 32 | shell: cmd 33 | - uses: actions/checkout@v4 34 | - name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }} 35 | uses: actions/setup-java@v4 36 | with: 37 | distribution: ${{ matrix.jdk-distribution }} 38 | java-version: ${{ matrix.jdk-version }} 39 | cache: 'maven' 40 | - name: Run Tests 41 | run: mvn -ntp -U -B -fae clean verify 42 | - uses: actions/upload-artifact@v4 43 | if: failure() 44 | with: 45 | name: surefire-${{ matrix.jdk-distribution }}-${{ matrix.jdk-version }}-${{ matrix.os }} 46 | path: '**/surefire-reports/*.txt' 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore .svn metadata files 2 | .svn 3 | # ignore Maven generated target folders 4 | ~ 5 | target 6 | # ignore eclipse files 7 | .project 8 | .classpath 9 | .settings 10 | .metadata 11 | # ignore IDEA files 12 | *.iml 13 | *.ipr 14 | *.iws 15 | .idea 16 | maven-ant-tasks.jar 17 | test-output 18 | transaction.log 19 | # vim files 20 | *.swp 21 | /.gitk-tmp.* 22 | atlassian-ide-plugin.xml 23 | # temp files 24 | *~ 25 | # maven versions plugin 26 | pom.xml.versionsBackup 27 | # hprof dumps 28 | /*.hprof 29 | # ignore 'randomly' strewn around logs 30 | server.log 31 | # ignore java crashes 32 | hs_err_pid*.log 33 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @chengfang @tadamski 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## JBoss EJB CLient Community Code of Conduct v1.0 2 | 3 | ### Contributor Code of Conduct 4 | 5 | As contributors and maintainers of this project, and in the interest of fostering 6 | an open and welcoming community, we pledge to respect all people who contribute 7 | through reporting issues, posting feature requests, updating documentation, 8 | submitting pull requests or patches, and other activities. 9 | 10 | We are committed to making participation in this project a harassment-free experience for 11 | everyone, regardless of level of experience, gender, gender identity and expression, 12 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, 13 | religion, or nationality. 14 | 15 | Examples of unacceptable behavior by participants include: 16 | 17 | * The use of sexualized language or imagery 18 | * Personal attacks 19 | * Trolling or insulting/derogatory comments 20 | * Public or private harassment 21 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 22 | * Other unethical or unprofessional conduct. 23 | 24 | Project maintainers have the right and responsibility to remove, edit, or reject 25 | comments, commits, code, wiki edits, issues, and other contributions that are not 26 | aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers 27 | commit themselves to fairly and consistently applying these principles to every aspect 28 | of managing this project. Project maintainers who do not follow or enforce the Code of 29 | Conduct may be permanently removed from the project team. 30 | 31 | This code of conduct applies both within project spaces and in public spaces 32 | when an individual is representing the project or its community. 33 | 34 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 35 | contacting the JBoss EJB Client project lead, [Cheng Fang](mailto:cfang@redhat.com) or [Tomasz Adamski](mailto:tadamski@redhat.com) 36 | 37 | 38 | This Code of Conduct is adapted from the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md) which is 39 | adapted from the Contributor Covenant 40 | (http://contributor-covenant.org), version 1.2.0, available at 41 | http://contributor-covenant.org/version/1/2/0/ 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JBoss EJB client for WildFly 2 | 3 | JBoss EJB client is a library that enables invocation of Jakarta Enterprise Beans located in remote WildFly server. 4 | 5 | [Jakarta Enterprise Beans Specification](https://jakarta.ee/specifications/enterprise-beans/4.0/jakarta-enterprise-beans-spec-core-4.0.html) 6 | 7 | ## Build with Maven 8 | 9 | The command below builds the project and runs the embedded suite. 10 | 11 | ```console 12 | $ mvn clean install 13 | ``` 14 | 15 | ## Issue Tracking 16 | 17 | Bugs and features are tracked within the JBoss EJB client Jira project at https://issues.redhat.com/projects/EJBCLIENT 18 | 19 | ## Contributions 20 | 21 | All new features and enhancements should be submitted to _main_ branch. 22 | Our [contribution guide](https://github.com/wildfly/jboss-ejb-client/blob/main/CONTRIBUTING.md) will guide you through the steps for getting started on the JBoss EJB client project and will go through how to format and submit your first PR. 23 | 24 | 25 | ## Get Help 26 | 27 | If you would like to ask us some question or you need some help, feel free to ask on the WildFly user [forum](https://groups.google.com/g/wildfly). -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting of CVEs and Security Issues 2 | 3 | ## The WildFly community and our sponsor, Red Hat, take security bugs very seriously 4 | 5 | We aim to take immediate action to address serious security-related problems that involve our projects. 6 | 7 | Note that we will only fix such issues in the most recent minor release of WildFly. 8 | 9 | ## Reporting of Security Issues 10 | 11 | When reporting a security vulnerability it is important to not accidentally broadcast to the world that the issue exists, as this makes it easier for people to exploit it. The software industry uses the term embargo to describe the time a security issue is known internally until it is public knowledge. 12 | 13 | Our preferred way of reporting security issues in WildFly and its related projects is listed below. 14 | 15 | ### Email the mailing list 16 | 17 | The list at security@wildfly.org is the preferred mechanism for outside users to report security issues. A member of the WildFly team will open the required issues. 18 | 19 | ### Other considerations 20 | 21 | If you would like to work with us on a fix for the security vulnerability, please include your GitHub username in the above email, and we will provide you access to a temporary private fork where we can collaborate on a fix without it being disclosed publicly, **including in your own publicly visible git repository**. 22 | 23 | Do not open a public issue, send a pull request, or disclose any information about the suspected vulnerability publicly, **including in your own publicly visible git repository**. If you discover any publicly disclosed security vulnerabilities, please notify us immediately through security@wildfly.org 24 | -------------------------------------------------------------------------------- /assets/images/clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wildfly/jboss-ejb-client/1dace8e3536efe2afd79da6d29fc99a2359f2be8/assets/images/clone.png -------------------------------------------------------------------------------- /assets/images/fork.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wildfly/jboss-ejb-client/1dace8e3536efe2afd79da6d29fc99a2359f2be8/assets/images/fork.jpg -------------------------------------------------------------------------------- /assets/images/jira.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wildfly/jboss-ejb-client/1dace8e3536efe2afd79da6d29fc99a2359f2be8/assets/images/jira.png -------------------------------------------------------------------------------- /assets/images/jira_start_progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wildfly/jboss-ejb-client/1dace8e3536efe2afd79da6d29fc99a2359f2be8/assets/images/jira_start_progress.png -------------------------------------------------------------------------------- /src/config/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 23 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/config/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/_private/Keys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2018 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb._private; 20 | 21 | import org.jboss.ejb.client.AttachmentKey; 22 | import org.wildfly.naming.client.NamingProvider; 23 | import org.wildfly.security.auth.client.AuthenticationContext; 24 | 25 | /** 26 | */ 27 | public final class Keys { 28 | 29 | public static final AttachmentKey AUTHENTICATION_CONTEXT_ATTACHMENT_KEY = new AttachmentKey<>(); 30 | 31 | public static final AttachmentKey NAMING_PROVIDER_ATTACHMENT_KEY = new AttachmentKey<>(); 32 | 33 | private Keys() {} 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/AbstractReceiverInvocationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import org.wildfly.security.auth.client.AuthenticationContext; 22 | 23 | /** 24 | * The base class of receiver invocation contexts. 25 | * 26 | * @author David M. Lloyd 27 | */ 28 | public abstract class AbstractReceiverInvocationContext { 29 | AbstractReceiverInvocationContext() { 30 | } 31 | 32 | /** 33 | * Get the invocation context associated with this receiver invocation context. 34 | * 35 | * @return the invocation context 36 | */ 37 | public abstract AbstractInvocationContext getClientInvocationContext(); 38 | 39 | /** 40 | * Get the authentication context of the request. The configuration may be associated with the proxy, 41 | * or it may have been inherited from the environment. 42 | * 43 | * @return the authentication configuration of the request (not {@code null}) 44 | */ 45 | public abstract AuthenticationContext getAuthenticationContext(); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/ArrayUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client; 19 | 20 | /** 21 | * @author David M. Lloyd 22 | */ 23 | final class ArrayUtil { 24 | 25 | private ArrayUtil() {} 26 | 27 | static String bytesToString(byte[] bytes, int offs, int len) { 28 | StringBuilder b = new StringBuilder(len * 2); 29 | int h, l; 30 | for (int i = 0; i < len; i ++) { 31 | h = bytes[i + offs] & 0xff; 32 | l = h & 0x0f; 33 | h >>= 4; 34 | if (h < 10) { 35 | b.append('0' + h); 36 | } else { 37 | b.append('A' + h - 10); 38 | } 39 | if (l < 10) { 40 | b.append('0' + l); 41 | } else { 42 | b.append('A' + l - 10); 43 | } 44 | } 45 | return b.toString(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/AttachmentKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | /** 22 | * An attachment key. 23 | * 24 | * @param the attachment value type 25 | * @author David M. Lloyd 26 | */ 27 | @SuppressWarnings({"unused", "UtilityClassWithoutPrivateConstructor", "UtilityClassWithPublicConstructor"}) 28 | public final class AttachmentKey { 29 | 30 | /** 31 | * Construct a new instance. 32 | */ 33 | public AttachmentKey() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/AuthenticationContextEJBClientInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import static org.jboss.ejb._private.Keys.AUTHENTICATION_CONTEXT_ATTACHMENT_KEY; 22 | 23 | import org.jboss.ejb.client.annotation.ClientInterceptorPriority; 24 | import org.wildfly.common.function.ExceptionSupplier; 25 | import org.wildfly.security.auth.client.AuthenticationContext; 26 | 27 | /** 28 | * Enterprise Beans client interceptor to capture the {@code AuthenticationContext} after any application interceptors. 29 | * 30 | * @author Darran Lofthouse 31 | */ 32 | @ClientInterceptorPriority(AuthenticationContextEJBClientInterceptor.PRIORITY) 33 | public class AuthenticationContextEJBClientInterceptor implements EJBClientInterceptor { 34 | 35 | public static final int PRIORITY = ClientInterceptorPriority.JBOSS_AFTER + 25; 36 | 37 | @Override 38 | public SessionID handleSessionCreation(EJBSessionCreationInvocationContext context) throws Exception { 39 | return call(context::proceed, context); 40 | } 41 | 42 | @Override 43 | public void handleInvocation(EJBClientInvocationContext context) throws Exception { 44 | call(() -> { 45 | context.sendRequest(); 46 | return null; 47 | }, context); 48 | } 49 | 50 | @Override 51 | public Object handleInvocationResult(EJBClientInvocationContext context) throws Exception { 52 | return call(context::getResult, context); 53 | } 54 | 55 | private T call(ExceptionSupplier action, AbstractInvocationContext context) throws Exception { 56 | final AuthenticationContext captured = AuthenticationContext.captureCurrent(); 57 | final AuthenticationContext previous = context.putAttachment(AUTHENTICATION_CONTEXT_ATTACHMENT_KEY, captured); 58 | try { 59 | return action.get(); 60 | } finally { 61 | if (previous == null) { 62 | context.removeAttachment(AUTHENTICATION_CONTEXT_ATTACHMENT_KEY); 63 | } else { 64 | context.putAttachment(AUTHENTICATION_CONTEXT_ATTACHMENT_KEY, previous); 65 | } 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/BasicSessionID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | /** 22 | * A basic session ID object. 23 | * 24 | * @author David M. Lloyd 25 | */ 26 | public final class BasicSessionID extends SessionID { 27 | 28 | private static final long serialVersionUID = -7306257085240447972L; 29 | 30 | BasicSessionID(final byte[] encodedForm) { 31 | super(encodedForm); 32 | if (encodedForm[0] != 0x07) { 33 | throw wrongFormat(); 34 | } 35 | } 36 | 37 | private static IllegalArgumentException wrongFormat() { 38 | return new IllegalArgumentException("Wrong session ID format"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/CaptureCurrentAuthCtxSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.util.function.Supplier; 22 | 23 | import org.wildfly.security.auth.client.AuthenticationContext; 24 | 25 | /** 26 | * @author David M. Lloyd 27 | */ 28 | final class CaptureCurrentAuthCtxSupplier implements Supplier { 29 | private CaptureCurrentAuthCtxSupplier() {} 30 | 31 | static final CaptureCurrentAuthCtxSupplier INSTANCE = new CaptureCurrentAuthCtxSupplier(); 32 | 33 | public AuthenticationContext get() { 34 | return AuthenticationContext.captureCurrent(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/ClusterAffinity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.net.URI; 22 | import java.net.URISyntaxException; 23 | 24 | /** 25 | * A cluster affinity specification. 26 | * 27 | * @author David M. Lloyd 28 | */ 29 | public final class ClusterAffinity extends Affinity { 30 | 31 | private static final long serialVersionUID = -8078602613739377911L; 32 | 33 | private final String clusterName; 34 | 35 | /** 36 | * Construct a new instance. 37 | * 38 | * @param clusterName the associated cluster name 39 | */ 40 | public ClusterAffinity(final String clusterName) { 41 | this.clusterName = clusterName; 42 | } 43 | 44 | /** 45 | * Get the associated cluster name. 46 | * 47 | * @return the associated cluster name 48 | */ 49 | public String getClusterName() { 50 | return clusterName; 51 | } 52 | 53 | public String toString() { 54 | return String.format("Cluster \"%s\"", clusterName); 55 | } 56 | 57 | public URI getUri() { 58 | try { 59 | return new URI("cluster", clusterName, null); 60 | } catch (URISyntaxException e) { 61 | throw new IllegalStateException(e); 62 | } 63 | } 64 | 65 | public boolean equals(final Object other) { 66 | return other instanceof ClusterAffinity && equals((ClusterAffinity) other); 67 | } 68 | 69 | public boolean equals(final Affinity other) { 70 | return other instanceof ClusterAffinity && equals((ClusterAffinity) other); 71 | } 72 | 73 | public boolean equals(final ClusterAffinity other) { 74 | return other != null && clusterName.equals(other.clusterName); 75 | } 76 | 77 | public int hashCode() { 78 | return clusterName.hashCode() + 11; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/ClusterAffinityInterest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.client; 2 | 3 | /** 4 | * A callback interested in a cluster affinity. 5 | * 6 | * @author Jason T. Greene 7 | */ 8 | interface ClusterAffinityInterest { 9 | AttachmentKey KEY = new AttachmentKey<>(); 10 | 11 | void notifyAssignment(ClusterAffinity affinity); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBClientPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import org.wildfly.common.Assert; 22 | import org.wildfly.security.permission.AbstractNameSetOnlyPermission; 23 | import org.wildfly.security.util.StringEnumeration; 24 | import org.wildfly.security.util.StringMapping; 25 | 26 | /** 27 | * The class for various general Enterprise Beans client permissions. 28 | * 29 | * @author David M. Lloyd 30 | */ 31 | public final class EJBClientPermission extends AbstractNameSetOnlyPermission { 32 | 33 | private static final long serialVersionUID = 8406360684253911321L; 34 | 35 | private static final StringEnumeration names = StringEnumeration.of( 36 | "createContext", 37 | "createReceiver", 38 | "changeWeakAffinity", 39 | "changeStrongAffinity" 40 | ); 41 | 42 | private static final StringMapping mapping = new StringMapping<>(names, EJBClientPermission::new); 43 | 44 | public static final EJBClientPermission CREATE_CONTEXT = mapping.getItemById(0); 45 | public static final EJBClientPermission CREATE_RECEIVER = mapping.getItemById(1); 46 | public static final EJBClientPermission CHANGE_WEAK_AFFINITY = mapping.getItemById(2); 47 | public static final EJBClientPermission CHANGE_STRONG_AFFINITY = mapping.getItemById(3); 48 | 49 | private static final EJBClientPermission ALL = new EJBClientPermission("*"); 50 | 51 | public EJBClientPermission(final String name) { 52 | super(name, names); 53 | } 54 | 55 | public EJBClientPermission(final String name, @SuppressWarnings("unused") final String actions) { 56 | super(name, names); 57 | if (actions != null && ! actions.isEmpty()) { 58 | throw new IllegalArgumentException("Unsupported actions string '" + actions + "'"); 59 | } 60 | } 61 | 62 | public EJBClientPermission withName(final String name) { 63 | Assert.checkNotNullParam("name", name); 64 | return "*".equals(name) ? ALL : mapping.getItemByString(name); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.rmi.RemoteException; 22 | 23 | import jakarta.ejb.EJBObject; 24 | import jakarta.ejb.Handle; 25 | 26 | import org.wildfly.common.Assert; 27 | 28 | /** 29 | * A handle for an Enterprise Bean interface. 30 | * 31 | * @param the Enterprise Beans remote interface type 32 | * @author David M. Lloyd 33 | */ 34 | public final class EJBHandle implements Handle { 35 | 36 | private static final long serialVersionUID = -4870688692508067759L; 37 | 38 | private final EJBLocator locator; 39 | 40 | /** 41 | * Construct a new instance. 42 | * 43 | * @param locator the locator for the EJB instance 44 | */ 45 | public EJBHandle(final EJBLocator locator) { 46 | Assert.checkNotNullParam("locator", locator); 47 | this.locator = locator; 48 | } 49 | 50 | /** 51 | * Construct a new instance. 52 | * 53 | * @param locator the locator for the Enterprise Beans instance (must not be {@code null}) 54 | * @param the Enterprise Beans object type 55 | * @return the handle (not {@code null}) 56 | */ 57 | public static EJBHandle create(EJBLocator locator) { 58 | return new EJBHandle<>(locator); 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | public T getEJBObject() throws RemoteException { 65 | return EJBClient.createProxy(locator); 66 | } 67 | 68 | /** 69 | * Determine whether this object is equal to another. 70 | * 71 | * @param other the other object 72 | * @return {@code true} if they are equal, {@code false} otherwise 73 | */ 74 | public boolean equals(Object other) { 75 | return other instanceof EJBHandle && equals((EJBHandle) other); 76 | } 77 | 78 | /** 79 | * Determine whether this object is equal to another. 80 | * 81 | * @param other the other object 82 | * @return {@code true} if they are equal, {@code false} otherwise 83 | */ 84 | public boolean equals(EJBHandle other) { 85 | return this == other || other != null && locator.equals(other.locator); 86 | } 87 | 88 | /** 89 | * Get the hash code for this Enterprise Bean handle. 90 | * 91 | * @return the hash code 92 | */ 93 | public int hashCode() { 94 | return locator.hashCode(); 95 | } 96 | 97 | /** 98 | * Get the locator for this handle. 99 | * 100 | * @return the locator for this handle 101 | */ 102 | public EJBLocator getLocator() { 103 | return locator; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBNamingContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import javax.naming.Context; 22 | import javax.naming.NamingException; 23 | 24 | import org.kohsuke.MetaInfServices; 25 | import org.wildfly.naming.client.NamingContextFactory; 26 | import org.wildfly.naming.client.NamingProvider; 27 | import org.wildfly.naming.client.ProviderEnvironment; 28 | import org.wildfly.naming.client.util.FastHashtable; 29 | 30 | /** 31 | * The naming context factory for Enterprise Bean JNDI names. This covers any names that begin with {@code ejb:}. 32 | * 33 | * @author David M. Lloyd 34 | */ 35 | @MetaInfServices 36 | public final class EJBNamingContextFactory implements NamingContextFactory { 37 | /** 38 | * Construct a new instance. 39 | */ 40 | public EJBNamingContextFactory() { 41 | } 42 | 43 | public boolean supportsUriScheme(final NamingProvider namingProvider, final String nameScheme) { 44 | return "ejb".equals(nameScheme); 45 | } 46 | 47 | public Context createRootContext(final NamingProvider namingProvider, final String nameScheme, final FastHashtable env, final ProviderEnvironment providerEnvironment) throws NamingException { 48 | assert nameScheme.equals("ejb"); 49 | return new EJBRootContext(namingProvider, env, providerEnvironment); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBReceiverContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | /** 22 | * A context which is provided to Enterprise Beans receiver implementations in order to perform operations on the client context. 23 | * 24 | * @author David M. Lloyd 25 | */ 26 | public final class EJBReceiverContext { 27 | private final EJBClientContext clientContext; 28 | 29 | EJBReceiverContext(final EJBClientContext clientContext) { 30 | this.clientContext = clientContext; 31 | } 32 | 33 | /** 34 | * Get the client context that corresponds to this receiver context. 35 | * 36 | * @return the client context 37 | */ 38 | public EJBClientContext getClientContext() { 39 | return clientContext; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBReceiverSessionCreationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import org.wildfly.security.auth.client.AuthenticationContext; 22 | 23 | /** 24 | * The session creation context for a selected receiver. 25 | * 26 | * @author David M. Lloyd 27 | */ 28 | public final class EJBReceiverSessionCreationContext extends AbstractReceiverInvocationContext { 29 | private final EJBSessionCreationInvocationContext invocationContext; 30 | 31 | EJBReceiverSessionCreationContext(final EJBSessionCreationInvocationContext invocationContext) { 32 | this.invocationContext = invocationContext; 33 | } 34 | 35 | public EJBSessionCreationInvocationContext getClientInvocationContext() { 36 | return invocationContext; 37 | } 38 | 39 | public AuthenticationContext getAuthenticationContext() { 40 | AuthenticationContext authenticationContext = invocationContext.getAuthenticationContext(); 41 | return authenticationContext == null ? AuthenticationContext.captureCurrent() : authenticationContext; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EJBTransportProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | /** 22 | * An Enterprise Bean transport provider. 23 | * 24 | * @author David M. Lloyd 25 | */ 26 | public interface EJBTransportProvider { 27 | 28 | /** 29 | * Notify the provider instance that it has been registered with the given client context. 30 | * 31 | * @param receiverContext the Enterprise Beans receiver context (not {@code null}) 32 | */ 33 | default void notifyRegistered(EJBReceiverContext receiverContext) {} 34 | 35 | /** 36 | * Determine whether this transport provider supports the protocol identified by the given URI scheme. 37 | * 38 | * @param uriScheme the URI scheme 39 | * @return {@code true} if this provider supports the protocol, {@code false} otherwise 40 | */ 41 | boolean supportsProtocol(String uriScheme); 42 | 43 | /** 44 | * Get an Enterprise Bean receiver for the protocol identified by the given URI scheme. 45 | * 46 | * @param receiverContext the receiver context 47 | * @param uriScheme the URI scheme 48 | * @return the non-{@code null} Enterprise Beans receiver 49 | * @throws IllegalArgumentException if the protocol is not supported 50 | */ 51 | EJBReceiver getReceiver(EJBReceiverContext receiverContext, String uriScheme) throws IllegalArgumentException; 52 | 53 | default void close(EJBReceiverContext receiverContext) throws Exception {} 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/EntityEJBMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import jakarta.ejb.EJBHome; 22 | import jakarta.ejb.EJBObject; 23 | 24 | import org.wildfly.common.Assert; 25 | 26 | /** 27 | * Enterprise Beans metadata for entity Enterprise Beans. 28 | * 29 | * @param the remote interface type 30 | * @param the home interface type 31 | * 32 | * @author David M. Lloyd 33 | */ 34 | public final class EntityEJBMetaData extends AbstractEJBMetaData { 35 | 36 | private static final long serialVersionUID = 5985601714593841885L; 37 | 38 | private final Class primaryKeyClass; 39 | 40 | /** 41 | * Construct a new instance. 42 | * 43 | * @param remoteInterfaceClass the remote interface class 44 | * @param homeLocator the EJB home locator 45 | * @param primaryKeyClass the primary key class 46 | */ 47 | public EntityEJBMetaData(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator, final Class primaryKeyClass) { 48 | super(remoteInterfaceClass, homeLocator); 49 | Assert.checkNotNullParam("primaryKeyClass", primaryKeyClass); 50 | this.primaryKeyClass = primaryKeyClass; 51 | } 52 | 53 | /** 54 | * Construct a new instance. 55 | * 56 | * @param remoteInterfaceClass the remote interface class (must not be {@code null}) 57 | * @param homeLocator the Enterprise Beans home locator (must not be {@code null}) 58 | * @param primaryKeyClass the primary key class (must not be {@code null}) 59 | * @param the remote interface type 60 | * @param the home interface type 61 | * @return the new instance (not {@code null}) 62 | */ 63 | public static EntityEJBMetaData create(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator, final Class primaryKeyClass) { 64 | return new EntityEJBMetaData(remoteInterfaceClass, homeLocator, primaryKeyClass); 65 | } 66 | 67 | public boolean isSession() { 68 | return false; 69 | } 70 | 71 | public Class getPrimaryKeyClass() { 72 | return primaryKeyClass; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/FinishedFuture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.util.concurrent.ExecutionException; 22 | import java.util.concurrent.Future; 23 | import java.util.concurrent.TimeUnit; 24 | import java.util.concurrent.TimeoutException; 25 | 26 | /** 27 | * A finished future. 28 | * 29 | * @param the value type 30 | * @author David M. Lloyd 31 | */ 32 | final class FinishedFuture implements Future { 33 | private final T result; 34 | 35 | FinishedFuture(final T result) { 36 | this.result = result; 37 | } 38 | 39 | public boolean cancel(final boolean mayInterruptIfRunning) { 40 | return false; 41 | } 42 | 43 | public boolean isCancelled() { 44 | return false; 45 | } 46 | 47 | public boolean isDone() { 48 | return true; 49 | } 50 | 51 | public T get() throws InterruptedException, ExecutionException { 52 | return result; 53 | } 54 | 55 | public T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { 56 | return result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/FixedSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.util.function.Supplier; 22 | 23 | /** 24 | * A fixed supplier. 25 | * 26 | * @author David M. Lloyd 27 | */ 28 | final class FixedSupplier implements Supplier { 29 | private final T item; 30 | 31 | FixedSupplier(final T item) { 32 | this.item = item; 33 | } 34 | 35 | public T get() { 36 | return item; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/NodeAffinity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.net.URI; 22 | import java.net.URISyntaxException; 23 | 24 | import org.wildfly.common.Assert; 25 | 26 | /** 27 | * A single node affinity specification. 28 | * 29 | * @author David M. Lloyd 30 | */ 31 | public final class NodeAffinity extends Affinity { 32 | 33 | private static final long serialVersionUID = -1241023739831847480L; 34 | 35 | private final String nodeName; 36 | 37 | /** 38 | * Construct a new instance. 39 | * 40 | * @param nodeName the associated node name (must not be {@code null}) 41 | */ 42 | public NodeAffinity(final String nodeName) { 43 | Assert.checkNotNullParam("nodeName", nodeName); 44 | this.nodeName = nodeName; 45 | } 46 | 47 | /** 48 | * Get the associated node name. 49 | * 50 | * @return the associated node name 51 | */ 52 | public String getNodeName() { 53 | return nodeName; 54 | } 55 | 56 | public String toString() { 57 | return String.format("Node \"%s\"", nodeName); 58 | } 59 | 60 | public URI getUri() { 61 | try { 62 | return new URI("node", nodeName, null); 63 | } catch (URISyntaxException e) { 64 | throw new IllegalStateException(e); 65 | } 66 | } 67 | 68 | public boolean equals(final Object other) { 69 | return other instanceof NodeAffinity && equals((NodeAffinity) other); 70 | } 71 | 72 | public boolean equals(final Affinity other) { 73 | return other instanceof NodeAffinity && equals((NodeAffinity) other); 74 | } 75 | 76 | public boolean equals(final NodeAffinity other) { 77 | return other != null && nodeName.equals(other.nodeName); 78 | } 79 | 80 | public int hashCode() { 81 | return nodeName.hashCode() + 53; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/RemoteEJBPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import org.wildfly.security.permission.AbstractBooleanPermission; 22 | 23 | /** 24 | * Represents permission to invoke an Enterprise Bean remotely 25 | * 26 | * @author Stuart Douglas 27 | */ 28 | public class RemoteEJBPermission extends AbstractBooleanPermission { 29 | 30 | /** 31 | * Construct a new instance. 32 | */ 33 | public RemoteEJBPermission() { 34 | } 35 | 36 | /** 37 | * Construct a new instance. 38 | * 39 | * @param name ignored 40 | */ 41 | public RemoteEJBPermission(@SuppressWarnings("unused") final String name) { 42 | } 43 | 44 | /** 45 | * Construct a new instance. 46 | * 47 | * @param name ignored 48 | * @param actions ignored 49 | */ 50 | public RemoteEJBPermission(@SuppressWarnings("unused") final String name, @SuppressWarnings("unused") final String actions) { 51 | } 52 | 53 | private static final RemoteEJBPermission INSTANCE = new RemoteEJBPermission(); 54 | 55 | /** 56 | * Get the instance of this class. 57 | * 58 | * @return the instance of this class 59 | */ 60 | public static RemoteEJBPermission getInstance() { 61 | return INSTANCE; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/SecurityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client; 19 | 20 | import org.wildfly.security.manager.WildFlySecurityManager; 21 | 22 | /** 23 | * Security sensitive operations being used in this package. 24 | * 25 | * @author Richard Opálka 26 | */ 27 | final class SecurityUtils { 28 | 29 | private SecurityUtils() { 30 | // forbidden instantiation 31 | } 32 | 33 | static boolean getBoolean(final String propertyName) { 34 | return getBoolean(propertyName, false); 35 | } 36 | 37 | static boolean getBoolean(final String propertyName, final boolean defaultValue) { 38 | try { 39 | final String propertyValue = getString(propertyName); 40 | return propertyValue != null ? Boolean.valueOf(propertyValue) : defaultValue; 41 | } catch (Throwable t) { 42 | return defaultValue; 43 | } 44 | } 45 | 46 | static int getInteger(final String propertyName, final int defaultValue) { 47 | try { 48 | final String propertyValue = getString(propertyName); 49 | return propertyValue != null ? Integer.parseInt(propertyValue) : defaultValue; 50 | } catch (Throwable t) { 51 | return defaultValue; 52 | } 53 | } 54 | 55 | static long getLong(final String propertyName, final long defaultValue) { 56 | try { 57 | final String propertyValue = getString(propertyName); 58 | return propertyValue != null ? Long.parseLong(propertyValue) : defaultValue; 59 | } catch (Throwable t) { 60 | return defaultValue; 61 | } 62 | } 63 | 64 | static String getString(final String propertyName) { 65 | return getString(propertyName, null); 66 | } 67 | 68 | static String getString(final String propertyName, final String defaultValue) { 69 | return WildFlySecurityManager.getPropertyPrivileged(propertyName, defaultValue); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/StatefulEJBMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import jakarta.ejb.EJBHome; 22 | import jakarta.ejb.EJBObject; 23 | 24 | /** 25 | * EJB metadata for stateful EJBs. 26 | * 27 | * @param the remote interface type 28 | * @param the home interface type 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | public final class StatefulEJBMetaData extends AbstractEJBMetaData { 33 | 34 | private static final long serialVersionUID = 8596216068022888027L; 35 | 36 | /** 37 | * Construct a new instance. 38 | * 39 | * @param remoteInterfaceClass the remote interface class 40 | * @param homeLocator the EJB home locator 41 | */ 42 | public StatefulEJBMetaData(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator) { 43 | super(remoteInterfaceClass, homeLocator); 44 | } 45 | 46 | /** 47 | * Construct a new instance. 48 | * 49 | * @param remoteInterfaceClass the remote interface class (must not be {@code null}) 50 | * @param homeLocator the EJB home locator (must not be {@code null}) 51 | * @param the remote interface type 52 | * @param the home interface type 53 | * @return the new instance (not {@code null}) 54 | */ 55 | public static StatefulEJBMetaData create(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator) { 56 | return new StatefulEJBMetaData(remoteInterfaceClass, homeLocator); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/StatelessEJBMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import jakarta.ejb.EJBHome; 22 | import jakarta.ejb.EJBObject; 23 | 24 | /** 25 | * Enterprise Beans metadata for stateless Enterprise Beans. 26 | * 27 | * @param the remote interface type 28 | * @param the home interface type 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | public final class StatelessEJBMetaData extends AbstractEJBMetaData { 33 | 34 | private static final long serialVersionUID = 8596216068022888027L; 35 | 36 | /** 37 | * Construct a new instance. 38 | * 39 | * @param remoteInterfaceClass the remote interface class 40 | * @param homeLocator the Enterprise Beans home locator 41 | */ 42 | public StatelessEJBMetaData(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator) { 43 | super(remoteInterfaceClass, homeLocator); 44 | } 45 | 46 | /** 47 | * Construct a new instance. 48 | * 49 | * @param remoteInterfaceClass the remote interface class (must not be {@code null}) 50 | * @param homeLocator the Enterprise Beans home locator (must not be {@code null}) 51 | * @param the remote interface type 52 | * @param the home interface type 53 | * @return the new instance (not {@code null}) 54 | */ 55 | public static StatelessEJBMetaData create(final Class remoteInterfaceClass, final EJBHomeLocator homeLocator) { 56 | return new StatelessEJBMetaData<>(remoteInterfaceClass, homeLocator); 57 | } 58 | 59 | public boolean isStatelessSession() { 60 | return true; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/SystemProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client; 19 | 20 | /** 21 | * System properties being used in this package. 22 | * 23 | * @author Richard Opálka 24 | */ 25 | final class SystemProperties { 26 | 27 | static final String DISCOVERY_ADDITIONAL_NODE_TIMEOUT = "org.jboss.ejb.client.discovery.additional-node-timeout"; 28 | static final String DISCOVERY_BLOCKLIST_TIMEOUT = "org.jboss.ejb.client.discovery.blacklist.timeout"; 29 | static final String DISCOVERY_TIMEOUT = "org.jboss.ejb.client.discovery.timeout"; 30 | static final String JBOSS_NODE_NAME = "jboss.node.name"; 31 | static final String MAX_RETRIES = "org.jboss.ejb.client.max-retries"; 32 | static final String VIEW_ANNOTATION_SCAN_ENABLED = "org.jboss.ejb.client.view.annotation.scan.enabled"; 33 | static final String WILDFLY_TESTSUITE_HACK = "org.jboss.ejb.client.wildfly-testsuite-hack"; 34 | 35 | private SystemProperties() { 36 | // forbidden instantiation 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/URIAffinity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.net.URI; 22 | 23 | /** 24 | * A URI affinity specification. Create instances using {@link Affinity#forUri(URI)}. 25 | * 26 | * @author David M. Lloyd 27 | */ 28 | public final class URIAffinity extends Affinity { 29 | 30 | private static final long serialVersionUID = -8437624625197058354L; 31 | 32 | private final URI uri; 33 | 34 | /** 35 | * Construct a new instance. 36 | * 37 | * @param uri the URI to bind to (must not be {@code null}) 38 | */ 39 | public URIAffinity(final URI uri) { 40 | if (uri == null) { 41 | throw new IllegalArgumentException("URI is null"); 42 | } 43 | this.uri = uri; 44 | } 45 | 46 | public URI getUri() { 47 | return uri; 48 | } 49 | 50 | Object writeReplace() { 51 | String s = uri.getScheme(); 52 | if (s.equals("node")) { 53 | return new NodeAffinity(uri.getSchemeSpecificPart()); 54 | } else if (s.equals("cluster")) { 55 | return new ClusterAffinity(uri.getSchemeSpecificPart()); 56 | } else if (s.equals("local")) { 57 | return LOCAL; 58 | } else { 59 | // keep same object 60 | return this; 61 | } 62 | } 63 | 64 | public String toString() { 65 | return String.format("URI<%s>", uri); 66 | } 67 | 68 | public boolean equals(final Object other) { 69 | return other instanceof URIAffinity && equals((URIAffinity) other); 70 | } 71 | 72 | public boolean equals(final Affinity other) { 73 | return other instanceof URIAffinity && equals((URIAffinity) other); 74 | } 75 | 76 | public boolean equals(final URIAffinity other) { 77 | return other != null && uri.equals(other.uri); 78 | } 79 | 80 | public int hashCode() { 81 | return uri.hashCode(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/UUIDSessionID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.nio.ByteBuffer; 22 | import java.util.UUID; 23 | 24 | /** 25 | * A UUID-based session ID object. 26 | * 27 | * @author David M. Lloyd 28 | */ 29 | public final class UUIDSessionID extends SessionID { 30 | 31 | private static final long serialVersionUID = -7306257085240447972L; 32 | 33 | private final UUID uuid; 34 | 35 | UUIDSessionID(final byte[] encodedForm) { 36 | super(encodedForm); 37 | if (encodedForm[0] != 0x09) { 38 | throw wrongFormat(); 39 | } 40 | final ByteBuffer bb = ByteBuffer.wrap(encodedForm); 41 | bb.get(); 42 | // big-endian 43 | uuid = new UUID(bb.getLong(), bb.getLong()); 44 | } 45 | 46 | /** 47 | * Construct a new instance. 48 | * 49 | * @param uuid the UUID to use (must not be {@code null}) 50 | */ 51 | public UUIDSessionID(final UUID uuid) { 52 | super(encode(uuid)); 53 | this.uuid = uuid; 54 | } 55 | 56 | private static byte[] encode(final UUID uuid) { 57 | final ByteBuffer bb = ByteBuffer.wrap(new byte[17]); 58 | bb.put((byte) 0x09); 59 | bb.putLong(uuid.getMostSignificantBits()); 60 | bb.putLong(uuid.getLeastSignificantBits()); 61 | return bb.array(); 62 | } 63 | 64 | /** 65 | * Get the UUID. 66 | * 67 | * @return the UUID (must not be {@code null}) 68 | */ 69 | public UUID getUuid() { 70 | return uuid; 71 | } 72 | 73 | private static IllegalArgumentException wrongFormat() { 74 | return new IllegalArgumentException("Wrong session ID format"); 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return String.format("%s [%s]", getClass().getSimpleName(), uuid); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/UnknownSessionID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | /** 22 | * A session ID of an unknown format. 23 | * 24 | * @author David M. Lloyd 25 | */ 26 | public final class UnknownSessionID extends SessionID { 27 | 28 | private static final long serialVersionUID = 8565847732676192265L; 29 | 30 | /** 31 | * Construct a new instance. 32 | * 33 | * @param encodedForm the encoded form of this session ID 34 | */ 35 | UnknownSessionID(final byte[] encodedForm) { 36 | super(encodedForm); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.io.InputStreamReader; 24 | import java.nio.charset.StandardCharsets; 25 | import java.util.Properties; 26 | 27 | /** 28 | * @author David M. Lloyd 29 | */ 30 | public final class Version { 31 | private Version() { 32 | } 33 | 34 | private static final String JAR_NAME; 35 | private static final String VERSION; 36 | 37 | static { 38 | Properties versionProps = new Properties(); 39 | String jarName = "(unknown)"; 40 | String versionString = "(unknown)"; 41 | try { 42 | final InputStream stream = Version.class.getResourceAsStream("Version.properties"); 43 | try { 44 | final InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); 45 | try { 46 | versionProps.load(reader); 47 | jarName = versionProps.getProperty("jarName", jarName); 48 | versionString = versionProps.getProperty("version", versionString); 49 | } finally { 50 | try { 51 | reader.close(); 52 | } catch (Throwable ignored) { 53 | } 54 | } 55 | } finally { 56 | try { 57 | stream.close(); 58 | } catch (Throwable ignored) { 59 | } 60 | } 61 | } catch (IOException ignored) { 62 | } 63 | JAR_NAME = jarName; 64 | VERSION = versionString; 65 | } 66 | 67 | /** 68 | * Get the name of the program JAR. 69 | * 70 | * @return the name 71 | */ 72 | public static String getJarName() { 73 | return JAR_NAME; 74 | } 75 | 76 | /** 77 | * Get the version string. 78 | * 79 | * @return the version string 80 | */ 81 | public static String getVersionString() { 82 | return VERSION; 83 | } 84 | 85 | /** 86 | * Print out the current version on {@code System.out}. 87 | * 88 | * @param args ignored 89 | */ 90 | public static void main(String[] args) { 91 | System.out.printf("JBoss EJB Client version %s\n", VERSION); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/ClientAsynchronous.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Indicate that the annotated interface view class or method should run asynchronously regardless of how the target 28 | * EJB is actually deployed on the server. 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | @Target({ElementType.METHOD, ElementType.TYPE}) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface ClientAsynchronous { 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/ClientInterceptorPriority.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import static java.lang.annotation.ElementType.TYPE; 22 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 23 | 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * The priority of the client interceptor. If no priority is specified, then {@link #APPLICATION} is used. 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | @Target(TYPE) 33 | @Retention(RUNTIME) 34 | public @interface ClientInterceptorPriority { 35 | int value(); 36 | 37 | /** 38 | * The starting range value for application interceptors. 39 | */ 40 | int APPLICATION = 0; 41 | 42 | /** 43 | * The ending range value for application interceptors. 44 | */ 45 | int APPLICATION_END = APPLICATION + 99_999; 46 | 47 | /** 48 | * The starting range value for library "before" interceptors. 49 | */ 50 | int LIBRARY_BEFORE = -100_000; 51 | 52 | /** 53 | * The ending range value for library "before" interceptors. 54 | */ 55 | int LIBRARY_BEFORE_END = LIBRARY_BEFORE + 99_999; 56 | 57 | /** 58 | * The starting range value for provided JBoss "before" interceptors. 59 | */ 60 | int JBOSS_BEFORE = -200_000; 61 | 62 | /** 63 | * The ending range value for provided JBoss "before" interceptors. 64 | */ 65 | int JBOSS_BEFORE_END = JBOSS_BEFORE + 99_999; 66 | 67 | /** 68 | * The starting range value for library "after" interceptors. 69 | */ 70 | int LIBRARY_AFTER = 100_000; 71 | 72 | /** 73 | * The ending range value for library "after" interceptors. 74 | */ 75 | int LIBRARY_AFTER_END = LIBRARY_AFTER + 99_999; 76 | 77 | /** 78 | * The starting range value for provided JBoss "after" interceptors. 79 | */ 80 | int JBOSS_AFTER = 200_000; 81 | 82 | /** 83 | * The ending range value for provided JBoss "before" interceptors. 84 | */ 85 | int JBOSS_AFTER_END = JBOSS_AFTER + 99_999; 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/ClientInterceptors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | import org.jboss.ejb.client.EJBClientInterceptor; 27 | 28 | /** 29 | * Declares a list of client-side interceptors that should be used on a given remote Enterprise Bean proxy method or class. If 30 | * the corresponding class has a priority, that priority will govern the order of interception, otherwise the 31 | * interceptors will be used in the order described by {@link EJBClientInterceptor}. 32 | * 33 | * @author David M. Lloyd 34 | */ 35 | @Target({ElementType.TYPE, ElementType.METHOD}) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | public @interface ClientInterceptors { 38 | /** 39 | * The client interceptors contained by this repeatable annotation. 40 | * 41 | * @return the client interceptors 42 | */ 43 | Class[] value(); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/ClientTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Indicate the client-side transaction handling policy for the associated EJB interface or method. 28 | * 29 | * @author David M. Lloyd 30 | */ 31 | @Target({ElementType.METHOD, ElementType.TYPE}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface ClientTransaction { 34 | /** 35 | * The annotation value. 36 | * 37 | * @return the annotation value 38 | */ 39 | ClientTransactionPolicy value(); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/CompressionHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | import java.util.zip.Deflater; 26 | 27 | /** 28 | * A hint to the Enterprise Beans client API that the data being communicated between the Enterprise Beans client and the server via the {@link org.jboss.ejb.client.EJBReceiver EJBReceiver(s)} should be compressed. 29 | *

30 | * This is just a hint and it's ultimately the Enterprise Beans client API implementation and/or the EJBReceiver(s) which decide whether or not the data will be compressed. 31 | * 32 | * @author Jaikiran Pai 33 | */ 34 | @Target({ElementType.METHOD, ElementType.TYPE}) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | public @interface CompressionHint { 37 | 38 | /** 39 | * True if the request data of an Enterprise Bean invocation should be compressed. False otherwise. By default this is true. 40 | */ 41 | boolean compressRequest() default true; 42 | 43 | /** 44 | * True if the response data of an Enterprise Bean invocation should be compressed. False otherwise. By default this is true. 45 | */ 46 | boolean compressResponse() default true; 47 | 48 | /** 49 | * The compression level to be used while compressing the data. The values can be any of those that are supported by {@link Deflater}. By default the compression level is {@link Deflater#DEFAULT_COMPRESSION} 50 | */ 51 | int compressionLevel() default Deflater.DEFAULT_COMPRESSION; 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/annotation/Idempotent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Indicate that the interface or method annotated with this annotation is idempotent, meaning that invocations 28 | * to the interface or method with the same input can be repeated any number of additional times without additional effect. 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | @Target({ElementType.METHOD, ElementType.TYPE}) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface Idempotent { 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/legacy/CommonLegacyConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client.legacy; 20 | 21 | import java.net.URI; 22 | import java.net.URISyntaxException; 23 | 24 | import org.jboss.ejb._private.NetworkUtil; 25 | import org.xnio.OptionMap; 26 | import org.xnio.Options; 27 | 28 | /** 29 | * @author David M. Lloyd 30 | */ 31 | final class CommonLegacyConfiguration { 32 | private CommonLegacyConfiguration() { 33 | } 34 | 35 | static URI getUri(final JBossEJBProperties.ConnectionConfiguration connectionConfiguration, final OptionMap connectionOptions) { 36 | final String host = connectionConfiguration.getHost(); 37 | if (host == null) { 38 | return null; 39 | } 40 | final int port = connectionConfiguration.getPort(); 41 | if (port == -1) { 42 | return null; 43 | } 44 | final String scheme; 45 | final String protocol = connectionConfiguration.getProtocol(); 46 | if (protocol == null) { 47 | if (connectionOptions.get(Options.SECURE, false) && connectionOptions.get(Options.SSL_ENABLED, false)) { 48 | scheme = "remote+https"; 49 | } else { 50 | scheme = "remote+http"; 51 | } 52 | } else { 53 | scheme = protocol; 54 | } 55 | try { 56 | return new URI(scheme, null, NetworkUtil.formatPossibleIpv6Address(host), port, null, null, null); 57 | } catch (URISyntaxException e) { 58 | return null; 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/legacy/SecurityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.legacy; 19 | 20 | import org.wildfly.security.manager.WildFlySecurityManager; 21 | 22 | /** 23 | * Security sensitive operations being used in this package. 24 | * 25 | * @author Richard Opálka 26 | */ 27 | final class SecurityUtils { 28 | 29 | private SecurityUtils() { 30 | // forbidden instantiation 31 | } 32 | 33 | static boolean getBoolean(final String propertyName) { 34 | return getBoolean(propertyName, false); 35 | } 36 | 37 | static boolean getBoolean(final String propertyName, final boolean defaultValue) { 38 | try { 39 | final String propertyValue = getString(propertyName); 40 | return propertyValue != null ? Boolean.valueOf(propertyValue) : defaultValue; 41 | } catch (Throwable t) { 42 | return defaultValue; 43 | } 44 | } 45 | 46 | static String getString(final String propertyName) { 47 | return getString(propertyName, null); 48 | } 49 | 50 | static String getString(final String propertyName, final String defaultValue) { 51 | return WildFlySecurityManager.getPropertyPrivileged(propertyName, defaultValue); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/legacy/SystemProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.legacy; 19 | 20 | /** 21 | * System properties being used in this package. 22 | * 23 | * @author Richard Opálka 24 | */ 25 | final class SystemProperties { 26 | 27 | static final String EXPAND_PASSWORDS = "jboss-ejb-client.expandPasswords"; 28 | static final String PROPERTIES_FILE_PATH = "jboss.ejb.client.properties.file.path"; 29 | static final String QUIET_AUTH = "jboss.sasl.local-user.quiet-auth"; 30 | static final String USER_DIR = "user.dir"; 31 | 32 | private SystemProperties() { 33 | // forbidden instantiation 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/client/naming/ejb/ejbURLContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.naming.ejb; 19 | 20 | 21 | import javax.naming.Context; 22 | import javax.naming.Name; 23 | import javax.naming.spi.ObjectFactory; 24 | import java.util.Hashtable; 25 | 26 | import org.jboss.ejb._private.Logs; 27 | import org.wildfly.naming.client.WildFlyInitialContextFactory; 28 | 29 | /** 30 | * Compatibility class. 31 | * 32 | * @deprecated Use {@link WildFlyInitialContextFactory} instead. 33 | * @author Farah Juma 34 | */ 35 | public class ejbURLContextFactory implements ObjectFactory { 36 | static { 37 | Logs.MAIN.ejbURLContextFactoryDeprecated(); 38 | } 39 | 40 | private final WildFlyInitialContextFactory delegate = new WildFlyInitialContextFactory(); 41 | 42 | public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment) throws Exception { 43 | return delegate.getInitialContext(environment); 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/AbstractWritingExternalizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.io.IOException; 22 | import java.io.ObjectInput; 23 | 24 | import org.jboss.marshalling.Externalizer; 25 | import org.jboss.marshalling.Marshaller; 26 | import org.jboss.marshalling.ObjectTable; 27 | 28 | /** 29 | * @author David M. Lloyd 30 | */ 31 | abstract class AbstractWritingExternalizer implements ObjectTable.Writer, Externalizer { 32 | 33 | private static final long serialVersionUID = 2546561809542547016L; 34 | 35 | public void writeObject(final Marshaller marshaller, final Object object) throws IOException { 36 | writeExternal(object, marshaller); 37 | } 38 | 39 | public void readExternal(final Object subject, final ObjectInput input) throws IOException, ClassNotFoundException { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/ByteExternalizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.io.IOException; 22 | import java.io.ObjectInput; 23 | import java.io.ObjectOutput; 24 | 25 | /** 26 | * @author David M. Lloyd 27 | */ 28 | class ByteExternalizer extends AbstractWritingExternalizer { 29 | 30 | private static final long serialVersionUID = 2582968267716345788L; 31 | 32 | private final int b; 33 | private final Object object; 34 | 35 | ByteExternalizer(final Object object, final int b) { 36 | this.b = b & 0xff; 37 | this.object = object; 38 | } 39 | 40 | public void writeExternal(final Object subject, final ObjectOutput output) throws IOException { 41 | output.writeByte(b); 42 | } 43 | 44 | public Object createExternal(final Class subjectType, final ObjectInput input) throws IOException, ClassNotFoundException { 45 | return object; 46 | } 47 | 48 | int getByte() { 49 | return b; 50 | } 51 | 52 | Object getObject() { 53 | return object; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/DiscoveredNodeRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.net.URI; 22 | import java.util.List; 23 | 24 | /** 25 | * @author David M. Lloyd 26 | */ 27 | interface DiscoveredNodeRegistry { 28 | 29 | NodeInformation getNodeInformation(String nodeName); 30 | 31 | List getAllNodeInformation(); 32 | 33 | void addNode(String clusterName, String nodeName, URI registeredBy); 34 | 35 | void removeNode(String clusterName, String nodeName); 36 | 37 | void removeCluster(String clusterName); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/EENamespaceInteroperability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2022 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.protocol.remote; 19 | 20 | import org.jboss.marshalling.ClassNameTransformer; 21 | import org.jboss.marshalling.MarshallingConfiguration; 22 | 23 | /** 24 | * EE namespace interoperability implementation for allowing Jakarta EE namespace servers and clients communication with 25 | * Javax EE namespace endpoints. 26 | * 27 | * @author Flavia Rainone 28 | * @author Richard Opalka 29 | */ 30 | final class EENamespaceInteroperability { 31 | /** 32 | * Indicates if EE namespace interoperable mode is enabled. 33 | */ 34 | static final boolean EE_NAMESPACE_INTEROPERABLE_MODE = Boolean.parseBoolean( 35 | org.wildfly.security.manager.WildFlySecurityManager.getPropertyPrivileged("org.wildfly.ee.namespace.interop", "false")); 36 | 37 | static { 38 | if (EE_NAMESPACE_INTEROPERABLE_MODE) { 39 | org.jboss.ejb._private.Logs.REMOTING.javaeeToJakartaeeBackwardCompatibilityLayerInstalled(); 40 | } 41 | } 42 | 43 | private EENamespaceInteroperability() {} 44 | 45 | /** 46 | * Handles EE namespace interoperability for endpoint creation, updating the @{code marshallingConfiguration} to 47 | * transform Javax EE <-> Jakarta EE namespace classes if needed. 48 | * 49 | * @param marshallingConfiguration the marshalling configuration that will be used by the endpoint 50 | * @param channelProtocolVersion the channel protocol version used by the endpoint 51 | */ 52 | static void handleInteroperability(MarshallingConfiguration marshallingConfiguration, int channelProtocolVersion) { 53 | if (EE_NAMESPACE_INTEROPERABLE_MODE && channelProtocolVersion < Protocol.JAKARTAEE_PROTOCOL_VERSION && 54 | Protocol.LATEST_VERSION >= Protocol.JAKARTAEE_PROTOCOL_VERSION) { 55 | // current protocol version is version 4 or above, but the remote counterpart uses EJB PROTOCOL version 3 or below 56 | // so in this case we need to translate classes from Javax EE API to Jakarta EE API and vice versa 57 | marshallingConfiguration.setClassNameTransformer(ClassNameTransformer.JAVAEE_TO_JAKARTAEE); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/EJBMarshallingCompatibilityHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import org.jboss.marshalling.ObjectResolver; 22 | import org.kohsuke.MetaInfServices; 23 | import org.wildfly.naming.client.MarshallingCompatibilityHelper; 24 | import org.wildfly.naming.client.Transport; 25 | import org.wildfly.naming.client.remote.RemoteTransport; 26 | 27 | /** 28 | * The naming marshalling helper for EJB types. 29 | * 30 | * @author David M. Lloyd 31 | */ 32 | @MetaInfServices 33 | public final class EJBMarshallingCompatibilityHelper implements MarshallingCompatibilityHelper { 34 | public ObjectResolver getObjectResolver(final Transport transport, final boolean request) { 35 | if (transport instanceof RemoteTransport) { 36 | final RemoteTransport remoteTransport = (RemoteTransport) transport; 37 | if (remoteTransport.getVersion() == 1) { // this refers to the naming version, not the EJB version 38 | // naming version is 1, EJB version is 1 or 2 (same resolver either way) 39 | return new ProtocolV1ObjectResolver(remoteTransport.getConnection(), true); 40 | } else { 41 | // naming version is 2 or bigger, EJB version is 3 42 | return new ProtocolV3ObjectResolver(remoteTransport.getConnection(), true); 43 | } 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/EJBTransactionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.io.IOException; 22 | 23 | import org.jboss.remoting3.Connection; 24 | import org.kohsuke.MetaInfServices; 25 | import org.wildfly.transaction.client.provider.remoting.RemotingFallbackPeerProvider; 26 | import org.wildfly.transaction.client.provider.remoting.RemotingOperations; 27 | 28 | /** 29 | * The legacy EJB-protocol transaction provider. 30 | * 31 | * @author David M. Lloyd 32 | */ 33 | @MetaInfServices(RemotingFallbackPeerProvider.class) 34 | public final class EJBTransactionProvider implements RemotingFallbackPeerProvider { 35 | 36 | public EJBTransactionProvider() { 37 | } 38 | 39 | public RemotingOperations getOperations(final Connection connection) throws IOException { 40 | return new EJBTransactionOperations(connection); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/NoFlushByteOutput.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.protocol.remote; 2 | 3 | import java.io.IOException; 4 | 5 | import org.jboss.marshalling.ByteOutput; 6 | 7 | /** 8 | * An output stream that ignores flushes. The marshsaller will flush when it is done, which 9 | * results in two frames on the wire. By ignoring the flush only one frame is sent for 10 | * each message. 11 | * 12 | * @author Stuart Douglas 13 | */ 14 | class NoFlushByteOutput implements ByteOutput { 15 | 16 | private final ByteOutput delegate; 17 | 18 | NoFlushByteOutput(ByteOutput delegate) { 19 | this.delegate = delegate; 20 | } 21 | 22 | @Override 23 | public void write(int b) throws IOException { 24 | delegate.write(b); 25 | } 26 | 27 | @Override 28 | public void write(byte[] b) throws IOException { 29 | delegate.write(b); 30 | } 31 | 32 | @Override 33 | public void write(byte[] b, int off, int len) throws IOException { 34 | delegate.write(b, off, len); 35 | } 36 | 37 | @Override 38 | public void close() throws IOException { 39 | delegate.close(); 40 | } 41 | 42 | @Override 43 | public void flush() throws IOException { 44 | //ignore 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/PackedInteger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.protocol.remote; 19 | 20 | import java.io.DataInput; 21 | import java.io.DataOutput; 22 | import java.io.IOException; 23 | 24 | /** 25 | * A {@link PackedInteger} is a variable-length integer. The most-significant bit of each byte of a 26 | * {@link PackedInteger} value indicates whether that byte is the final (lowest-order) byte of the value. 27 | * If the bit is 0, then this is the last byte; if the bit is 1, then there is at least one more subsequent 28 | * byte pending, and the current value should be shifted to the left by 7 bits to accommodate the next byte's data. 29 | *

30 | * Note: {@link PackedInteger} cannot hold signed integer values. 31 | * 32 | * @author Carlo de Wolf 33 | */ 34 | class PackedInteger { 35 | 36 | 37 | /** 38 | * Reads a {@link PackedInteger} value from the passed {@link DataInput input} and returns the 39 | * value of the integer. 40 | * 41 | * @param input The {@link DataInput} from which the {@link PackedInteger} value will be read 42 | * @return 43 | * @throws IOException 44 | * @throws IllegalArgumentException If the passed input is null 45 | */ 46 | public static int readPackedInteger(final DataInput input) throws IOException { 47 | int b = input.readByte(); 48 | if ((b & 0x80) == 0x80) { 49 | return readPackedInteger(input) << 7 | (b & 0x7F); 50 | } 51 | return b; 52 | } 53 | 54 | /** 55 | * Converts the passed value into a {@link PackedInteger} and writes it to the 56 | * {@link DataOutput output} 57 | * 58 | * @param output The {@link DataOutput} to which the {@link PackedInteger} is written to 59 | * @param value The integer value which will be converted to a {@link PackedInteger} 60 | * @throws IOException 61 | * @throws IllegalArgumentException If the passed value is < 0. {@link PackedInteger} doesn't 62 | * allow signed integer 63 | * @throws IllegalArgumentException If the passed output is null 64 | */ 65 | public static void writePackedInteger(final DataOutput output, int value) throws IOException { 66 | if (value < 0) 67 | throw new IllegalArgumentException("Only unsigned integer can be packed"); 68 | if (value > 127) { 69 | output.writeByte(value & 0x7F | 0x80); 70 | writePackedInteger(output, value >> 7); 71 | } else { 72 | output.writeByte(value & 0xFF); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/ProtocolClassResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import static java.security.AccessController.doPrivileged; 22 | 23 | import java.io.IOException; 24 | import java.lang.reflect.Proxy; 25 | import java.security.PrivilegedAction; 26 | 27 | import org.jboss.marshalling.ContextClassResolver; 28 | import org.jboss.marshalling.Unmarshaller; 29 | 30 | /** 31 | * @author David M. Lloyd 32 | */ 33 | final class ProtocolClassResolver extends ContextClassResolver { 34 | static final ProtocolClassResolver INSTANCE = new ProtocolClassResolver(); 35 | 36 | private ProtocolClassResolver() { 37 | } 38 | 39 | public Class resolveProxyClass(final Unmarshaller unmarshaller, final String[] interfaces) throws IOException, ClassNotFoundException { 40 | final int length = interfaces.length; 41 | final Class[] classes = new Class[length]; 42 | 43 | for (int i = 0; i < length; ++ i) { 44 | classes[i] = this.loadClass(interfaces[i]); 45 | } 46 | 47 | final ClassLoader classLoader; 48 | if (length == 1) { 49 | classLoader = doPrivileged((PrivilegedAction) classes[0]::getClassLoader); 50 | } else { 51 | classLoader = getClassLoader(); 52 | } 53 | 54 | return Proxy.getProxyClass(classLoader, classes); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/ProtocolObjectResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2018 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import org.jboss.marshalling.ObjectResolver; 22 | import org.jboss.marshalling.SerializabilityChecker; 23 | 24 | /** 25 | * 26 | */ 27 | abstract class ProtocolObjectResolver implements ObjectResolver { 28 | private static final ThreadLocal ENABLED = new ThreadLocal<>(); 29 | 30 | protected ProtocolObjectResolver() { 31 | } 32 | 33 | public Object writeReplace(final Object o) { 34 | if (o != null && ENABLED.get() == Boolean.TRUE) { 35 | final Class clazz = o.getClass(); 36 | if (! clazz.isArray() && ! SerializabilityChecker.DEFAULT.isSerializable(clazz)) { 37 | return null; 38 | } 39 | } 40 | return o; 41 | } 42 | 43 | static void enableNonSerReplacement() { 44 | ENABLED.set(Boolean.TRUE); 45 | } 46 | 47 | static void disableNonSerReplacement() { 48 | ENABLED.set(Boolean.FALSE); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/ProtocolV1ObjectPreResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.util.Arrays; 22 | 23 | import org.jboss.ejb.client.EJBHomeLocator; 24 | import org.jboss.ejb.client.EJBLocator; 25 | import org.jboss.ejb.client.EntityEJBLocator; 26 | import org.jboss.ejb.client.StatefulEJBLocator; 27 | import org.jboss.ejb.client.StatelessEJBLocator; 28 | import org.jboss.marshalling.ObjectResolver; 29 | 30 | final class ProtocolV1ObjectPreResolver implements ObjectResolver { 31 | 32 | static final ProtocolV1ObjectPreResolver INSTANCE = new ProtocolV1ObjectPreResolver(); 33 | 34 | private ProtocolV1ObjectPreResolver() { 35 | } 36 | 37 | public Object readResolve(final Object replacement) { 38 | if (replacement instanceof Object[]) { 39 | final Object[] array = (Object[]) replacement; 40 | final int len = array.length; 41 | if (replacement instanceof StackTraceElement4[]) { 42 | return Arrays.copyOf(array, len, StackTraceElement[].class); 43 | } else if (replacement instanceof V1EntityLocator[]) { 44 | return Arrays.copyOf(array, len, EntityEJBLocator[].class); 45 | } else if (replacement instanceof V1HomeLocator[]) { 46 | return Arrays.copyOf(array, len, EJBHomeLocator[].class); 47 | } else if (replacement instanceof V1StatefulLocator[]) { 48 | return Arrays.copyOf(array, len, StatefulEJBLocator[].class); 49 | } else if (replacement instanceof V1StatelessLocator[]) { 50 | return Arrays.copyOf(array, len, StatelessEJBLocator[].class); 51 | } else if (replacement instanceof V1EJBLocator[]) { 52 | // this one has to be last 53 | return Arrays.copyOf(array, len, EJBLocator[].class); 54 | } 55 | } 56 | return replacement; 57 | } 58 | 59 | public Object writeReplace(final Object original) { 60 | return original; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/ProtocolV1ObjectTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import org.jboss.ejb.client.Affinity; 22 | import org.jboss.ejb.client.AttachmentKeys; 23 | import org.jboss.ejb.client.EJBClientInvocationContext; 24 | import org.jboss.ejb.client.TransactionID; 25 | import org.jboss.marshalling.Marshaller; 26 | import org.jboss.marshalling.ObjectTable; 27 | import org.jboss.marshalling.Unmarshaller; 28 | 29 | import java.io.IOException; 30 | import java.io.InvalidObjectException; 31 | import java.util.IdentityHashMap; 32 | import java.util.Map; 33 | 34 | /** 35 | * @author David M. Lloyd 36 | */ 37 | final class ProtocolV1ObjectTable implements ObjectTable { 38 | static final ProtocolV1ObjectTable INSTANCE = new ProtocolV1ObjectTable(); 39 | 40 | private static final Map writers; 41 | /** 42 | * Do NOT change the order of this list. 43 | */ 44 | private static final Object[] objects = { 45 | TransactionID.PRIVATE_DATA_KEY, 46 | Affinity.NONE, 47 | Affinity.WEAK_AFFINITY_CONTEXT_KEY, 48 | EJBClientInvocationContext.PRIVATE_ATTACHMENTS_KEY, 49 | AttachmentKeys.TRANSACTION_ID_KEY, 50 | AttachmentKeys.WEAK_AFFINITY, 51 | AttachmentKeys.COMPRESS_RESPONSE, 52 | AttachmentKeys.RESPONSE_COMPRESSION_LEVEL 53 | }; 54 | 55 | static { 56 | final Map map = new IdentityHashMap(); 57 | for (int i = 0, length = objects.length; i < length; i++) { 58 | map.put(objects[i], new ByteWriter((byte) i)); 59 | } 60 | writers = map; 61 | } 62 | 63 | public Writer getObjectWriter(final Object object) throws IOException { 64 | return writers.get(object); 65 | } 66 | 67 | public Object readObject(final Unmarshaller unmarshaller) throws IOException, ClassNotFoundException { 68 | int idx = unmarshaller.readUnsignedByte(); 69 | if (idx >= objects.length) { 70 | throw new InvalidObjectException("ObjectTable " + this.getClass().getName() + " cannot find an object for object index " + idx); 71 | } 72 | return objects[idx]; 73 | } 74 | 75 | static final class ByteWriter implements Writer { 76 | final byte[] bytes; 77 | 78 | ByteWriter(final byte... bytes) { 79 | this.bytes = bytes; 80 | } 81 | 82 | public void writeObject(final Marshaller marshaller, final Object object) throws IOException { 83 | marshaller.write(bytes); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/RemoteEJBDiscoveryConfigurator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.util.function.Consumer; 22 | 23 | import org.jboss.ejb.client.EJBClientContext; 24 | import org.kohsuke.MetaInfServices; 25 | import org.wildfly.discovery.spi.DiscoveryProvider; 26 | import org.wildfly.discovery.spi.DiscoveryRequest; 27 | import org.wildfly.discovery.spi.ExternalDiscoveryConfigurator; 28 | import org.wildfly.discovery.spi.RegistryProvider; 29 | 30 | @MetaInfServices 31 | public final class RemoteEJBDiscoveryConfigurator implements ExternalDiscoveryConfigurator { 32 | public RemoteEJBDiscoveryConfigurator() { 33 | } 34 | 35 | public void configure(final Consumer discoveryProviderConsumer, final Consumer registryProviderConsumer) { 36 | discoveryProviderConsumer.accept((serviceType, filterSpec, result) -> { 37 | final RemoteEJBReceiver receiver = EJBClientContext.getCurrent().getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); 38 | if (receiver == null) { 39 | result.complete(); 40 | return DiscoveryRequest.NULL; 41 | } 42 | return receiver.getDiscoveredNodeRegistry().discover(serviceType, filterSpec, result); 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/SecurityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.protocol.remote; 19 | 20 | import org.wildfly.security.manager.WildFlySecurityManager; 21 | 22 | /** 23 | * Security sensitive operations being used in this package. 24 | * 25 | * @author Richard Opálka 26 | */ 27 | final class SecurityUtils { 28 | 29 | static long getLong(final String propertyName, final long defaultValue) { 30 | try { 31 | final String propertyValue = getString(propertyName); 32 | return propertyValue != null ? Long.parseLong(propertyValue) : defaultValue; 33 | } catch (Throwable t) { 34 | return defaultValue; 35 | } 36 | } 37 | 38 | static String getString(final String propertyName) { 39 | return getString(propertyName, null); 40 | } 41 | 42 | static String getString(final String propertyName, final String defaultValue) { 43 | return WildFlySecurityManager.getPropertyPrivileged(propertyName, defaultValue); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/StackTraceElement4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import java.io.Serializable; 22 | 23 | /** 24 | * Allow safe deserialization of stack trace elements from Java 8 and earlier (4-field variant). 25 | * 26 | * @author David M. Lloyd 27 | */ 28 | final class StackTraceElement4 implements Serializable { 29 | // keep this exact UID for JDK compatibility 30 | private static final long serialVersionUID = 6992337162326171013L; 31 | 32 | private String declaringClass; 33 | private String methodName; 34 | private String fileName; 35 | private int lineNumber; 36 | 37 | StackTraceElement4() { 38 | } 39 | 40 | Object readResolve() { 41 | return new StackTraceElement(declaringClass, methodName, fileName, lineNumber); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/SystemProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2021 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.protocol.remote; 19 | 20 | /** 21 | * System properties being used in this package. 22 | * 23 | * @author Richard Opálka 24 | */ 25 | final class SystemProperties { 26 | 27 | static final String DESTINATION_RECHECK_INTERVAL = "org.jboss.ejb.client.destination-recheck-interval"; 28 | 29 | private SystemProperties() { 30 | // forbidden instantiation 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/TCCLUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2019 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.protocol.remote; 20 | 21 | import static java.lang.System.getSecurityManager; 22 | import static java.lang.Thread.currentThread; 23 | import static java.security.AccessController.doPrivileged; 24 | 25 | import org.wildfly.security.manager.action.GetContextClassLoaderAction; 26 | import org.wildfly.security.manager.action.SetContextClassLoaderAction; 27 | 28 | /** 29 | * @author Richard Opalka 30 | */ 31 | final class TCCLUtils { 32 | 33 | private static final ClassLoader SAFE_CL; 34 | 35 | static { 36 | ClassLoader safeClassLoader = TCCLUtils.class.getClassLoader(); 37 | if (safeClassLoader == null) { 38 | safeClassLoader = ClassLoader.getSystemClassLoader(); 39 | } 40 | if (safeClassLoader == null) { 41 | safeClassLoader = new ClassLoader() { 42 | }; 43 | } 44 | SAFE_CL = safeClassLoader; 45 | } 46 | 47 | private TCCLUtils() { 48 | // forbidden instantiation 49 | } 50 | 51 | /** 52 | * Sets safe TCCL and returns previous one. 53 | * @return previous TCCL 54 | */ 55 | static ClassLoader getAndSetSafeTCCL() { 56 | final ClassLoader old; 57 | if (getSecurityManager() != null) { 58 | old = doPrivileged(GetContextClassLoaderAction.getInstance()); 59 | doPrivileged(new SetContextClassLoaderAction(SAFE_CL)); 60 | } else { 61 | old = currentThread().getContextClassLoader(); 62 | currentThread().setContextClassLoader(SAFE_CL); 63 | } 64 | return old; 65 | } 66 | 67 | /** 68 | * Resets TCCL to previous one. 69 | */ 70 | static void resetTCCL(final ClassLoader old) { 71 | if (getSecurityManager() != null) { 72 | doPrivileged(new SetContextClassLoaderAction(old)); 73 | } else { 74 | currentThread().setContextClassLoader(old); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/protocol/remote/WrapperMessageOutputStream.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.protocol.remote; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | import org.jboss.remoting3.MessageOutputStream; 7 | 8 | /** 9 | * Extended version of DataOutputStream that does not flush before close 10 | * 11 | * @author Stuart Douglas 12 | */ 13 | class WrapperMessageOutputStream extends MessageOutputStream { 14 | 15 | private final MessageOutputStream underlyingMessage; 16 | private final OutputStream delegate; 17 | 18 | WrapperMessageOutputStream(MessageOutputStream underlyingMessage, OutputStream delegate) { 19 | this.underlyingMessage = underlyingMessage; 20 | this.delegate = delegate; 21 | } 22 | 23 | @Override 24 | public void write(int b) throws IOException { 25 | delegate.write(b); 26 | } 27 | 28 | @Override 29 | public void flush() throws IOException { 30 | delegate.flush(); 31 | } 32 | 33 | @Override 34 | public void close() throws IOException { 35 | delegate.close(); 36 | } 37 | 38 | @Override 39 | public MessageOutputStream cancel() { 40 | return underlyingMessage.cancel(); 41 | } 42 | 43 | @Override 44 | public void write(byte[] b) throws IOException { 45 | delegate.write(b); 46 | } 47 | 48 | @Override 49 | public void write(byte[] b, int off, int len) throws IOException { 50 | delegate.write(b, off, len); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/server/Association.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.server; 20 | 21 | import org.wildfly.common.annotation.NotNull; 22 | 23 | /** 24 | * A server association. Since server associations yield {@link ClassLoader} instances, it is important that classes 25 | * implementing this interface are not accessible without a permission check when a security manager is present. This 26 | * class is implemented by Enterprise Beans server environments and consumed by protocol implementations. 27 | * 28 | * @author David M. Lloyd 29 | */ 30 | public interface Association { 31 | 32 | /** 33 | * Receive and execute an invocation request. An invocation may be cancelled; the returned handle may be used 34 | * by the protocol implementation when a cancellation request is received by the server. 35 | * 36 | * @param invocationRequest the invocation request (not {@code null}) 37 | * @param the type of the target Enterprise Beans 38 | * @return a handle which may be used to request cancellation of the invocation (must not be {@code null}) 39 | */ 40 | @NotNull 41 | CancelHandle receiveInvocationRequest(@NotNull InvocationRequest invocationRequest); 42 | 43 | /** 44 | * Receive and execute a session open request. An invocation may be cancelled; the returned handle may be used 45 | * by the protocol implementation when a cancellation request is received by the server. 46 | * 47 | * @param sessionOpenRequest the session open request (not {@code null}) 48 | * @return a handle which may be used to request cancellation of the invocation (must not be {@code null}) 49 | */ 50 | @NotNull 51 | CancelHandle receiveSessionOpenRequest(@NotNull SessionOpenRequest sessionOpenRequest); 52 | 53 | /** 54 | * Register a cluster topology listener. This is used by legacy protocols to transmit cluster updates to old clients. 55 | * 56 | * @param clusterTopologyListener the cluster topology listener (not {@code null}) 57 | * @return a handle which may be used to cancel the topology listener registration (must not be {@code null}) 58 | */ 59 | @NotNull 60 | ListenerHandle registerClusterTopologyListener(@NotNull ClusterTopologyListener clusterTopologyListener); 61 | 62 | /** 63 | * Register a module availability listener. This is used by legacy clients which use no-affinity Enterprise Bean locators. 64 | * 65 | * @param moduleAvailabilityListener the module availability listener (not {@code null}) 66 | * @return a handle which may be used to cancel the availability listener registration (must not be {@code null}) 67 | */ 68 | @NotNull 69 | ListenerHandle registerModuleAvailabilityListener(@NotNull ModuleAvailabilityListener moduleAvailabilityListener); 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/server/CancelHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.server; 20 | 21 | /** 22 | * A handle which may be used to request the cancellation an invocation request. A cancel request may or may not be 23 | * honored by the server implementation. 24 | * 25 | * @author David M. Lloyd 26 | */ 27 | @FunctionalInterface 28 | public interface CancelHandle { 29 | 30 | /** 31 | * Attempt to cancel the in-progress invocation. If the invocation is past the point where cancellation is 32 | * possible, the method has no effect. The invocation may not support cancellation, in which case the method 33 | * has no effect. 34 | * 35 | * @param aggressiveCancelRequested {@code false} to only cancel if the method invocation has not yet begun, {@code true} to 36 | * attempt to cancel even if the method is running 37 | */ 38 | void cancel(boolean aggressiveCancelRequested); 39 | 40 | /** 41 | * A null cancel handle which does nothing. 42 | */ 43 | CancelHandle NULL = ignored -> {}; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/server/ListenerHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.server; 20 | 21 | /** 22 | * A listener registration handle. 23 | */ 24 | public interface ListenerHandle extends AutoCloseable { 25 | /** 26 | * Close the handle, unsubscribing the listener. 27 | */ 28 | void close(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/server/ModuleAvailabilityListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.server; 20 | 21 | import java.util.List; 22 | 23 | import org.jboss.ejb.client.EJBModuleIdentifier; 24 | 25 | /** 26 | * A module availability listener for no-affinity Enterprise Beans. 27 | * 28 | * @author David M. Lloyd 29 | */ 30 | public interface ModuleAvailabilityListener { 31 | void moduleAvailable(List modules); 32 | 33 | void moduleUnavailable(List modules); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/jboss/ejb/server/SessionOpenRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.server; 20 | 21 | import jakarta.transaction.SystemException; 22 | import jakarta.transaction.Transaction; 23 | 24 | /** 25 | * An Enterprise Bean session-open request. 26 | * 27 | * @author David M. Lloyd 28 | */ 29 | public interface SessionOpenRequest extends Request { 30 | /** 31 | * Determine if the request has a transaction. 32 | * 33 | * @return {@code true} if there is a transaction context with this request 34 | */ 35 | boolean hasTransaction(); 36 | 37 | /** 38 | * Get the inflowed transaction of the request. This should not be called unless it is desired to actually inflow 39 | * the transaction; doing so without using the transaction will cause needless work for the transaction coordinator. 40 | * To perform transaction checks, use {@link #hasTransaction()} first. This method should only be called one time 41 | * as it will inflow the transaction when called. 42 | *

43 | * If a transaction is present but transaction inflow has failed, a {@link SystemException} is thrown. In this case, 44 | * the invocation should fail. 45 | *

46 | * It is the caller's responsibility to check the status of the returned transaction to ensure that it is in an 47 | * active state; failure to do so can result in undesirable behavior. 48 | * 49 | * @return the transaction, or {@code null} if there is none for the request 50 | * @throws SystemException if inflowing the transaction failed 51 | * @throws IllegalStateException if this method is called more than one time 52 | */ 53 | Transaction getTransaction() throws SystemException, IllegalStateException; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/org/jboss/ejb/client/Version.properties: -------------------------------------------------------------------------------- 1 | version=${project.version} 2 | jarName=${project.artifactId} 3 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/DiscoveryEJBClientInterceptorTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2020 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package org.jboss.ejb.client; 20 | 21 | import java.net.URI; 22 | 23 | import org.junit.Assert; 24 | import org.junit.Test; 25 | 26 | /** 27 | * Tests for the DiscoveryEJBClientInterceptor 28 | * 29 | * @author Lin Gao 30 | */ 31 | public class DiscoveryEJBClientInterceptorTestCase { 32 | 33 | /** 34 | * A test for the "blocklist" feature of the DiscoveryEJBClientInterceptor which allows invocation targets 35 | * to be added to a blocklist. Presence of a URL on the blocklist eans that they should currently be excluded 36 | * from discovery request results. The blocklist has an associated timeout; blocklisted entries are cleared 37 | * once their time in the blocklist has passed the timeout to avoid being blocklisted forever. 38 | * 39 | * THis test validates the addition of a URL to the blicklist, as well as its expiration from the blocklist. 40 | * 41 | * @throws Exception 42 | */ 43 | @Test 44 | public void testBlocklist() throws Exception { 45 | long timeout = 1000L; 46 | System.setProperty(SystemProperties.DISCOVERY_BLOCKLIST_TIMEOUT, timeout + ""); 47 | AbstractInvocationContext context = new AbstractInvocationContext(null, null, null) { 48 | @Override 49 | public void requestRetry() { 50 | } 51 | }; 52 | URI destination = new URI("http-remoting://localhost:9443"); 53 | DiscoveryEJBClientInterceptor.addBlocklistedDestination(destination); 54 | Assert.assertTrue(DiscoveryEJBClientInterceptor.isBlocklisted(context, destination)); 55 | Assert.assertEquals(1, DiscoveryEJBClientInterceptor.getBlocklist().size()); 56 | 57 | // If sleeping for just the timeout duration, the lifespan of the blocklist may equal to, but not greater than, 58 | // the configured timeout, and so will not be removed yet. So sleep a bit longer. 59 | Thread.sleep(timeout * 2); 60 | Assert.assertFalse(DiscoveryEJBClientInterceptor.isBlocklisted(context, destination)); 61 | Assert.assertEquals(0, DiscoveryEJBClientInterceptor.getBlocklist().size()); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/DummyClientInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jboss.ejb.client; 17 | 18 | import org.jboss.ejb.client.EJBClientInterceptor; 19 | import org.jboss.ejb.client.EJBClientInvocationContext; 20 | 21 | /** 22 | * A dummy ClientInterceptor that does nothing. 23 | * It's purely for testing. 24 | * 25 | * @author Brad Maxwell 26 | */ 27 | public class DummyClientInterceptor implements EJBClientInterceptor { 28 | 29 | public void handleInvocation(EJBClientInvocationContext context) throws Exception { 30 | context.sendRequest(); 31 | } 32 | 33 | public Object handleInvocationResult(EJBClientInvocationContext context) throws Exception { 34 | return context.getResult(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/DummyClientInterceptor2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jboss.ejb.client; 17 | 18 | import org.jboss.ejb.client.EJBClientInterceptor; 19 | import org.jboss.ejb.client.EJBClientInvocationContext; 20 | 21 | /** 22 | * A dummy ClientInterceptor that does nothing. 23 | * It's purely for testing. 24 | * 25 | * @author Brad Maxwell 26 | */ 27 | public class DummyClientInterceptor2 implements EJBClientInterceptor { 28 | 29 | public void handleInvocation(EJBClientInvocationContext context) throws Exception { 30 | context.sendRequest(); 31 | } 32 | 33 | public Object handleInvocationResult(EJBClientInvocationContext context) throws Exception { 34 | return context.getResult(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/DummyNodeSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jboss.ejb.client; 17 | 18 | /** 19 | * A dummy SelectorNode implementation for a DeploymentNodeSelector and a ClusterNodeSelector that does nothing. 20 | * It's purely for testing. 21 | * 22 | * @author Joerg Baesner 23 | */ 24 | public class DummyNodeSelector implements DeploymentNodeSelector, ClusterNodeSelector{ 25 | 26 | public static final String DEPLOYMENT_NODE_IDENTIFIER = "deploymentNodeSelector"; 27 | public static final String CLUSTER_NODE_IDENTIFIER = "clusterNodeSelector"; 28 | 29 | @Override 30 | public String selectNode(String[] eligibleNodes, String appName, String moduleName, String distinctName) { 31 | return DEPLOYMENT_NODE_IDENTIFIER; 32 | } 33 | 34 | @Override 35 | public String selectNode(String clusterName, String[] connectedNodes, String[] totalAvailableNodes) { 36 | return CLUSTER_NODE_IDENTIFIER; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/EJBRootContextTestCase.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.client; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.wildfly.naming.client.ProviderEnvironment; 6 | import org.wildfly.naming.client.SimpleName; 7 | import org.wildfly.naming.client.util.FastHashtable; 8 | 9 | import javax.naming.InvalidNameException; 10 | import javax.naming.NamingException; 11 | 12 | /** 13 | * A set of tests which validate that invocation.timeout values set in the properties map of a JNDI context 14 | * get propagated to the proxies created from that JNDI context. 15 | * 16 | * @author unknown 17 | */ 18 | public class EJBRootContextTestCase { 19 | 20 | private static final String LOOKUP_NAME = "appName/moduleName/distinctName!org.jboss.ejb.client.test.common.Echo"; 21 | 22 | /** 23 | * Test which validates that an integer-valued invocation.timeout property set in the properties map for 24 | * a JNDI context gets passed through to a proxy created from that JNDI context. 25 | * 26 | * @throws NamingException 27 | */ 28 | @Test 29 | public void testInvocationTimeoutEnvPropertyInteger() throws NamingException { 30 | FastHashtable env = new FastHashtable<>(); 31 | env.put("invocation.timeout", 100); 32 | 33 | Object proxy = invokeContextLookup(env); 34 | 35 | Assert.assertEquals(100, EJBInvocationHandler.forProxy(proxy).getInvocationTimeout()); 36 | } 37 | 38 | /** 39 | * Test which validates that a string-valued invocation.timeout property set in the properties map for 40 | * a JNDI context gets passed through to a proxy created from that JNDI context. 41 | * 42 | * @throws NamingException 43 | */ 44 | @Test 45 | public void testInvocationTimeoutEnvPropertyString() throws NamingException { 46 | FastHashtable env = new FastHashtable<>(); 47 | env.put("invocation.timeout", "100"); 48 | 49 | Object proxy = invokeContextLookup(env); 50 | 51 | Assert.assertEquals(100, EJBInvocationHandler.forProxy(proxy).getInvocationTimeout()); 52 | } 53 | 54 | /** 55 | * Test which validates that a long-valued invocation.timeout property set in the properties map for 56 | * a JNDI context gets passed through to a proxy created from that JNDI context. 57 | * 58 | * @throws NamingException 59 | */ 60 | @Test 61 | public void testInvocationTimeoutEnvPropertyLong() throws NamingException { 62 | FastHashtable env = new FastHashtable<>(); 63 | env.put("invocation.timeout", 100L); 64 | 65 | Object proxy = invokeContextLookup(env); 66 | 67 | Assert.assertEquals(100, EJBInvocationHandler.forProxy(proxy).getInvocationTimeout()); 68 | } 69 | 70 | /** 71 | * Test which validates that the default invocation.timeout property for a JNDI context is -1. 72 | * 73 | * @throws NamingException 74 | */ 75 | @Test 76 | public void testInvocationTimeoutEnvPropertyEmpty() throws NamingException { 77 | FastHashtable env = new FastHashtable<>(); 78 | 79 | Object proxy = invokeContextLookup(env); 80 | 81 | Assert.assertEquals(-1, EJBInvocationHandler.forProxy(proxy).getInvocationTimeout()); 82 | } 83 | 84 | private Object invokeContextLookup(FastHashtable env) throws NamingException { 85 | EJBRootContext context = new EJBRootContext(null, env, new ProviderEnvironment.Builder().build()); 86 | return context.lookupNative(new SimpleName(LOOKUP_NAME)); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/ProxyEqualityTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2010 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client; 19 | 20 | import java.lang.reflect.InvocationHandler; 21 | import java.lang.reflect.Proxy; 22 | 23 | import org.junit.Assert; 24 | import org.junit.Test; 25 | 26 | /** 27 | * Tests which validate the test for proxy equality works for proxies created by the EJB Client API. 28 | * 29 | * Proxy equality is based on module name, use of an EJBINvocationHandler and viewType. 30 | * 31 | * @author Stuart Douglas 32 | */ 33 | public class ProxyEqualityTestCase { 34 | 35 | /** 36 | * A test for proxy equality, inequality and use of the correct invocation handler. 37 | */ 38 | @Test 39 | public void testClientProxyEquality() { 40 | // create a proxy with appName = a, moduleName = m, beanName = b and distinctName = d 41 | final StatelessEJBLocator locatorA = new StatelessEJBLocator(SimpleInterface.class, "a", "m", "b", "d"); 42 | SimpleInterface proxyA = EJBClient.createProxy(locatorA); 43 | 44 | final StatelessEJBLocator locatorB = new StatelessEJBLocator(SimpleInterface.class, "a", "m", "b", "d"); 45 | SimpleInterface proxyB = EJBClient.createProxy(locatorB); 46 | 47 | final StatelessEJBLocator locatorC = new StatelessEJBLocator(SimpleInterface.class, "a", "m", "b", "other"); 48 | SimpleInterface proxyC = EJBClient.createProxy(locatorC); 49 | 50 | // validate proxy equality 51 | Assert.assertTrue(proxyA.equals(proxyB)); 52 | Assert.assertEquals(proxyA.hashCode(), proxyB.hashCode()); 53 | 54 | // valite proxy inequality 55 | Assert.assertFalse(proxyA.equals(proxyC)); 56 | Assert.assertTrue(proxyA.hashCode() != proxyC.hashCode()); 57 | 58 | // validate the proxy was created from EJB Client API 59 | Assert.assertTrue(EJBClient.isEJBProxy(proxyA)); 60 | Assert.assertTrue(EJBClient.isEJBProxy(proxyB)); 61 | Assert.assertTrue(EJBClient.isEJBProxy(proxyC)); 62 | 63 | InvocationHandler invocationHandler1 = (proxy, method, args) -> method.invoke(proxy, args); 64 | final Object proxy1 = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Runnable.class}, invocationHandler1); 65 | Assert.assertFalse(EJBClient.isEJBProxy(proxy1)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/SimpleInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2011 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client; 19 | 20 | /** 21 | * Interface used in the tests 22 | * 23 | * @author Stuart Douglas 24 | */ 25 | public interface SimpleInterface { 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/legacy/LegacyPropertiesConfigurationTestCase.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.client.legacy; 2 | 3 | import org.jboss.ejb.client.EJBClientContext; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | import java.io.IOException; 8 | 9 | /** 10 | * Tests to verify that configuration of the EJBClientContext by a legacy jboss-ejb-client.properties file works 11 | * as expected. The jboss-ejb-client.properties file allows configuring invocation-related properties for the 12 | * EJBClientContext at three different levels: 13 | * - invocations targetting singleton nodes 14 | * - invocations targetting clusters 15 | * - invocations targetting specific nodes in clusters 16 | * 17 | * @author Thomas Hofman 18 | */ 19 | public class LegacyPropertiesConfigurationTestCase { 20 | 21 | private static final String PROPERTIES_FILE_MAX_NODES_SET = "maximum-connected-nodes-jboss-ejb-client.properties"; 22 | private static final String PROPERTIES_FILE_MAX_NODES_NOT_SET = "clustered-jboss-ejb-client.properties"; 23 | 24 | /** 25 | * Tests that values configured for the cluster property "max-allowed-connected-nodes" are passed through 26 | * to the resulting EJBClientContext. 27 | * 28 | * @throws IOException 29 | */ 30 | @Test 31 | public void testMaximumConnectedNodesSet() throws IOException { 32 | JBossEJBProperties ejbProperties = JBossEJBProperties.fromClassPath(JBossEJBProperties.class.getClassLoader(), PROPERTIES_FILE_MAX_NODES_SET); 33 | Assert.assertEquals(-1, ejbProperties.getClusterConfigurations().get("ejb1").getMaximumAllowedConnectedNodes()); // default value returned by JBossEJBProperties 34 | Assert.assertEquals(42, ejbProperties.getClusterConfigurations().get("ejb2").getMaximumAllowedConnectedNodes()); // configured 35 | EJBClientContext context = buildContextFromLegacyProperties(ejbProperties); 36 | 37 | Assert.assertEquals(42, context.getMaximumConnectedClusterNodes()); 38 | } 39 | 40 | /** 41 | * Tests that default values configured for the cluster property "max-allowed-connected-nodes" are passed through 42 | * to the resulting EJBClientContext when the property is not set. 43 | * 44 | * @throws IOException 45 | */ 46 | @Test 47 | public void testMaximumConnectedNodesNotSet() throws IOException { 48 | JBossEJBProperties ejbProperties = JBossEJBProperties.fromClassPath(JBossEJBProperties.class.getClassLoader(), PROPERTIES_FILE_MAX_NODES_NOT_SET); 49 | Assert.assertEquals(-1, ejbProperties.getClusterConfigurations().get("ejb").getMaximumAllowedConnectedNodes()); // default value returned by JBossEJBProperties 50 | EJBClientContext context = buildContextFromLegacyProperties(ejbProperties); 51 | 52 | Assert.assertEquals(10, context.getMaximumConnectedClusterNodes()); // default value 53 | } 54 | 55 | private EJBClientContext buildContextFromLegacyProperties(JBossEJBProperties ejbProperties) { 56 | JBossEJBProperties.getContextManager().setThreadDefault(ejbProperties); 57 | EJBClientContext.Builder builder = new EJBClientContext.Builder(); 58 | LegacyPropertiesConfiguration.configure(builder); 59 | return builder.build(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/remoting/MethodInvocationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2011 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.remoting; 19 | 20 | import java.util.Map; 21 | 22 | /** 23 | * Test framework class representing a method invocation and its associated data. 24 | * 25 | * @author Carlo de Wolf 26 | */ 27 | public class MethodInvocationRequest { 28 | 29 | private final short invocationId; 30 | private final String appName; 31 | private final String moduleName; 32 | private final String beanName; 33 | private final String viewClassName; 34 | private final String methodName; 35 | private final String[] paramTypes; 36 | private final Object[] params; 37 | private final String distinctName; 38 | private final Map attachments; 39 | 40 | public MethodInvocationRequest(final short invocationId, final String appName, final String moduleName, 41 | final String distinctName, final String beanName, final String viewClassName, 42 | final String methodName, final String[] methodParamTypes, 43 | final Object[] methodParams, final Map attachments) { 44 | 45 | this.invocationId = invocationId; 46 | this.appName = appName; 47 | this.moduleName = moduleName; 48 | this.beanName = beanName; 49 | this.viewClassName = viewClassName; 50 | this.methodName = methodName; 51 | this.params = methodParams; 52 | this.attachments = attachments; 53 | this.paramTypes = methodParamTypes; 54 | this.distinctName = distinctName; 55 | 56 | } 57 | 58 | public short getInvocationId() { 59 | return invocationId; 60 | } 61 | 62 | public String getMethodName() { 63 | return methodName; 64 | } 65 | 66 | public String getViewClassName() { 67 | return this.viewClassName; 68 | } 69 | 70 | public Object[] getParams() { 71 | return params; 72 | } 73 | 74 | public String[] getParamTypes() { 75 | return this.paramTypes; 76 | } 77 | 78 | public Map getAttachments() { 79 | return attachments; 80 | } 81 | 82 | public String getAppName() { 83 | return this.appName; 84 | } 85 | 86 | public String getModuleName() { 87 | return this.moduleName; 88 | } 89 | 90 | public String getBeanName() { 91 | return this.beanName; 92 | } 93 | 94 | public String getDistinctName() { 95 | return this.distinctName; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/serialization/ProxySerializationTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2010 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.serialization; 19 | 20 | import java.io.ByteArrayInputStream; 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | 24 | import org.jboss.ejb.client.EJBClient; 25 | import org.jboss.ejb.client.SimpleInterface; 26 | import org.jboss.ejb.client.StatelessEJBLocator; 27 | import org.jboss.marshalling.InputStreamByteInput; 28 | import org.jboss.marshalling.Marshaller; 29 | import org.jboss.marshalling.MarshallingConfiguration; 30 | import org.jboss.marshalling.OutputStreamByteOutput; 31 | import org.jboss.marshalling.Unmarshaller; 32 | import org.jboss.marshalling.river.RiverMarshallerFactory; 33 | import org.junit.Assert; 34 | import org.junit.Test; 35 | 36 | /** 37 | * Tests that validate that an Enterprise Bean proxy can be serialized using JBoss Marshalling. 38 | * 39 | * @author Stuart Douglas 40 | */ 41 | public class ProxySerializationTestCase { 42 | 43 | /** 44 | * Tests that marshalling/unmarshalling an EJB proxy to and from a byte stream does not affect 45 | * the validity of the proxy. 46 | * 47 | * @throws IOException 48 | * @throws ClassNotFoundException 49 | */ 50 | @Test 51 | public void testProxySerialization() throws IOException, ClassNotFoundException { 52 | 53 | // create a sample EJB client proxy 54 | final StatelessEJBLocator locator = new StatelessEJBLocator(SimpleInterface.class, "a", "m", "b", "d"); 55 | final Object proxy = EJBClient.createProxy(locator); 56 | 57 | // configure a JBoss Marshalling marshaller and marshall the proxy into a byte array, "bytes" 58 | final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration(); 59 | marshallingConfiguration.setVersion(2); 60 | org.jboss.marshalling.MarshallerFactory factory = new RiverMarshallerFactory(); 61 | final Marshaller marshaller = factory.createMarshaller(marshallingConfiguration); 62 | final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 63 | marshaller.start(new OutputStreamByteOutput(bytes)); 64 | marshaller.writeObject(proxy); 65 | marshaller.finish(); 66 | 67 | // configure a JBoss Marshalling unmarshaller and unmarshal the byte array, "bytes", into an Object 68 | Unmarshaller unmarshaller = factory.createUnmarshaller(marshallingConfiguration); 69 | ByteArrayInputStream in = new ByteArrayInputStream(bytes.toByteArray()); 70 | unmarshaller.start(new InputStreamByteInput(in)); 71 | Object deserialized = unmarshaller.readObject(); 72 | 73 | // check for equality of the original proxy and the marshalled/unmarshalled proxy 74 | Assert.assertEquals(proxy, deserialized); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/ClassCallback.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.client.test; 2 | 3 | /** 4 | * A helper class to allow calling an arbitrary Runnable 5 | */ 6 | public class ClassCallback { 7 | private static volatile Runnable beforeClassCallback; 8 | 9 | public static void beforeClassCallback() { 10 | if (beforeClassCallback != null) { 11 | beforeClassCallback.run(); 12 | } 13 | } 14 | 15 | public static void setBeforeClassCallback(Runnable beforeClassCallback) { 16 | ClassCallback.beforeClassCallback = beforeClassCallback; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/WildflyClientXMLTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test; 19 | 20 | import org.jboss.ejb.client.EJBClientContext; 21 | import org.jboss.logging.Logger; 22 | import org.junit.Assert; 23 | import org.junit.BeforeClass; 24 | import org.junit.Test; 25 | 26 | import java.io.File; 27 | import java.net.URL; 28 | 29 | /** 30 | * Tests some basic features of using a wildfly-config.xml file to configure the various contextuals which 31 | * the EJB client library depends on for configuration of key cross cutting concerns. 32 | * 33 | * This processing reads a wildfly-config.xml file from the classpath (or one referenced by the system property 34 | * wildfly.config.url) and uses the configuration in that file to configure the following contextuals: 35 | * - Endpoint 36 | * - XNIOWorker 37 | * - EJBClientContext 38 | * - AuthenticationConfiguration 39 | * - Discovery 40 | * - WildflyHttpContext 41 | * 42 | * 43 | * @author Richard Achmatowicz 44 | * 45 | * @todo this test should include complete coverage of all available settings realting to the EJBClientContext 46 | * at a minimum. 47 | */ 48 | public class WildflyClientXMLTestCase { 49 | 50 | private static final Logger logger = Logger.getLogger(WildflyClientXMLTestCase.class); 51 | private static final String CONFIGURATION_FILE_SYSTEM_PROPERTY_NAME = "wildfly.config.url"; 52 | private static final String CONFIGURATION_FILE = "wildfly-client.xml"; 53 | private static final long INVOCATION_TIMEOUT = 10*1000; 54 | 55 | /** 56 | * Initialize the contextuals by setting the wildfly.config.url system property 57 | * @throws Exception 58 | */ 59 | @BeforeClass 60 | public static void beforeClass() throws Exception { 61 | // make sure the desired configuration file is picked up for processing 62 | ClassLoader cl = WildflyClientXMLTestCase.class.getClassLoader(); 63 | URL resource = cl != null ? cl.getResource(CONFIGURATION_FILE) : ClassLoader.getSystemResource(CONFIGURATION_FILE); 64 | File file = new File(resource.getFile()); 65 | System.setProperty(CONFIGURATION_FILE_SYSTEM_PROPERTY_NAME,file.getAbsolutePath()); 66 | ClassCallback.beforeClassCallback(); 67 | } 68 | 69 | /* 70 | * Tests that the invocation timeout value set in wildfly-config.xml is used to populate the invocation timeout 71 | * value in the EJBClientContext. 72 | */ 73 | @Test 74 | public void testInvocationTimeout() { 75 | EJBClientContext clientContext = EJBClientContext.getCurrent(); 76 | Assert.assertEquals("Got an unexpected timeout value", INVOCATION_TIMEOUT, clientContext.getInvocationTimeout()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/byteman/MixedModeTestHelper.java: -------------------------------------------------------------------------------- 1 | package org.jboss.ejb.client.test.byteman; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | import org.jboss.byteman.rule.Rule; 8 | import org.jboss.byteman.rule.helper.Helper; 9 | import org.jboss.ejb.client.EJBClientContext; 10 | import org.wildfly.discovery.FilterSpec; 11 | import org.wildfly.discovery.ServiceURL; 12 | 13 | /** 14 | * Helper class for the MixedModeServiceURLTestCase. 15 | * 16 | * Maintains a map of nodes to ServiceURLs used for test validation. 17 | * 18 | * @author rachmato@redhat.com 19 | */ 20 | public class MixedModeTestHelper extends Helper { 21 | 22 | private static final String NODE_LIST_MAP_NAME = "nodeListMap"; 23 | private static final FilterSpec EJB_MODULE_FILTER_SPEC = FilterSpec.hasAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE); 24 | 25 | public MixedModeTestHelper(Rule rule) { 26 | super(rule); 27 | } 28 | 29 | public void createNodeListMap() { 30 | createLinkMap(NODE_LIST_MAP_NAME); 31 | } 32 | 33 | public void addServiceURLCacheToMap(String node, List list) { 34 | if (list.size() < 4) { 35 | System.out.printf("Ignoring partial ServiceURLs: %s%n", list); 36 | return; 37 | } 38 | boolean hasEjbModule = true; 39 | for (ServiceURL u : list) { 40 | if (!u.satisfies(EJB_MODULE_FILTER_SPEC)) { 41 | hasEjbModule = false; 42 | break; 43 | } 44 | } 45 | if (!hasEjbModule) { 46 | System.out.printf("Ignoring invalid temp ServiceURLs: %s%n", list); 47 | return; 48 | } 49 | 50 | System.out.println("** Adding serviceURL to map: node = " + node + ", list = " + list); 51 | List oldList = (List) link(NODE_LIST_MAP_NAME, node, list); 52 | if (oldList != null) { 53 | System.out.println("** Overwrite occurred when writing to list map!"); 54 | } 55 | } 56 | 57 | @SuppressWarnings("unchecked") 58 | public Map> getNodeListMap() { 59 | System.out.println("** Getting results from Byteman"); 60 | ConcurrentHashMap> results = new ConcurrentHashMap<>(); 61 | // write the entries from the linkMap into a map 62 | for (Object nameObject: linkNames(NODE_LIST_MAP_NAME)) { 63 | String node = (String) nameObject; 64 | List list = (List) linked(NODE_LIST_MAP_NAME, nameObject); 65 | results.put(node, list); 66 | } 67 | return results; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/Echo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import org.jboss.ejb.client.annotation.ClientTransaction; 21 | import org.jboss.ejb.client.annotation.ClientTransactionPolicy; 22 | 23 | /** 24 | * User: jpai 25 | */ 26 | public interface Echo { 27 | Result echo(String msg); 28 | 29 | @ClientTransaction(ClientTransactionPolicy.NOT_SUPPORTED) 30 | Result echoNonTx(String msg); 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/EchoBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import org.jboss.logging.Logger; 21 | 22 | /** 23 | * User: jpai 24 | */ 25 | public class EchoBean implements Echo { 26 | 27 | private static final Logger logger = Logger.getLogger(EchoBean.class); 28 | private final String node; 29 | 30 | public EchoBean() { 31 | this("unknown"); 32 | } 33 | 34 | public EchoBean(String node) { 35 | this.node = node; 36 | } 37 | 38 | @Override 39 | public Result echo(String msg) { 40 | logger.info(this.getClass().getSimpleName() + " echoing message " + msg); 41 | if ("request to throw IllegalArgumentException".equals(msg)) { 42 | throw new IllegalArgumentException("Intentionally thrown upon request from caller"); 43 | } 44 | return new Result(msg, node); 45 | } 46 | 47 | @Override 48 | public Result echoNonTx(String msg) { 49 | logger.info(this.getClass().getSimpleName() + " echoing message (NonTx) " + msg); 50 | return new Result(msg, node); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import jakarta.ejb.Stateful; 21 | 22 | /** 23 | * User: jpai 24 | */ 25 | public interface Foo { 26 | 27 | Result echo(String msg); 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/FooBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import org.jboss.logging.Logger; 21 | 22 | import jakarta.ejb.Stateful; 23 | 24 | /** 25 | * User: jpai 26 | */ 27 | @Stateful 28 | public class FooBean implements Echo { 29 | 30 | private static final Logger logger = Logger.getLogger(FooBean.class); 31 | 32 | @Override 33 | public Result echo(String msg) { 34 | logger.info(this.getClass().getSimpleName() + " echoing message " + msg); 35 | return new Result(msg, "no idea!"); 36 | } 37 | 38 | @Override 39 | public Result echoNonTx(String msg) { 40 | logger.info(this.getClass().getSimpleName() + " echoing message " + msg); 41 | return new Result(msg, "no idea!"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/Result.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2019 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import java.io.Serializable; 21 | 22 | /** 23 | * /** 24 | * A wrapper for a return value that includes the node on which the result was generated. 25 | * @author Paul Ferraro 26 | */ 27 | 28 | public class Result implements Serializable { 29 | private static final long servialVersionUID = 12345L ; 30 | private final T value; 31 | private final String node; 32 | 33 | public Result(T value, String node) { 34 | this.value = value; 35 | this.node = node; 36 | } 37 | 38 | public T getValue() { 39 | return value; 40 | } 41 | 42 | public String getNode() { 43 | return node; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/StatefulEchoBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import jakarta.ejb.Stateful; 21 | 22 | /** 23 | * An instance of Echo marked explicitly as stateful. 24 | * 25 | * User: jpai 26 | */ 27 | @Stateful 28 | public class StatefulEchoBean extends EchoBean { 29 | public StatefulEchoBean(String node) { 30 | super(node); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/StatelessEchoBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2017 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | import jakarta.ejb.Stateless; 21 | 22 | /** 23 | * An instance of Echo marked explicitly as stateless. 24 | * 25 | * User: jpai 26 | */ 27 | @Stateless 28 | public class StatelessEchoBean extends EchoBean { 29 | public StatelessEchoBean(String node) { 30 | super(node); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/TypeReporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2020 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | public interface TypeReporter { 21 | 22 | String getObjectType(Object object); 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/client/test/common/TypeReporterBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2020 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.client.test.common; 19 | 20 | /** 21 | * A bean which can be used to report the type of the Object parameter passed to its only method. 22 | */ 23 | public class TypeReporterBean implements TypeReporter { 24 | 25 | @Override 26 | public String getObjectType(Object object) { 27 | return object.getClass().getName(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/jboss/ejb/protocol/remote/NetworkUtilTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source. 3 | * Copyright 2013 Red Hat, Inc., and individual contributors 4 | * as indicated by the @author tags. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.jboss.ejb.protocol.remote; 19 | 20 | import static org.junit.Assert.*; 21 | 22 | import java.net.InetAddress; 23 | import java.net.UnknownHostException; 24 | 25 | import org.jboss.ejb._private.NetworkUtil; 26 | import org.junit.Test; 27 | 28 | /** 29 | * Tests for the NetworkUtil network utility class. 30 | * 31 | * @author David M. Lloyd 32 | */ 33 | public final class NetworkUtilTestCase { 34 | 35 | /** 36 | * Validation of the method NetworkUtil.belongsToNetwork(...) used to determine if a given host InetAddress belongs 37 | * to a network specified by a network InetAddress value and a network mask. 38 | * 39 | * @throws UnknownHostException 40 | */ 41 | @Test 42 | public void testNetmask1() throws UnknownHostException { 43 | assertTrue(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { 10, 64, 33, 17 }), 8)); 44 | assertTrue(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 7, 0, (byte) 131 }), InetAddress.getByAddress("", new byte[] { 10, 64, 33, 17 }), 8)); 45 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 7, 0, (byte) 131 }), InetAddress.getByAddress("", new byte[] { 10, 64, 33, 17 }), 16)); 46 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 7, 0, (byte) 131 }), InetAddress.getByAddress("", new byte[] { 10, 64, 33, 17 }), 24)); 47 | 48 | assertTrue(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { 127, (byte) 192, 33, 17 }), 0)); 49 | assertTrue(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), 32)); 50 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { 10, 0, 0, 2 }), 32)); 51 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { (byte) 138, 0, 0, 1 }), 32)); 52 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { 10, 0, 0, 2 }), InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), 32)); 53 | assertFalse(NetworkUtil.belongsToNetwork(InetAddress.getByAddress("", new byte[] { (byte) 138, 0, 0, 1 }), InetAddress.getByAddress("", new byte[] { 10, 0, 0, 1 }), 32)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/resources/broken-server-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2019 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 27 | remote.connection.one.username=test 28 | remote.connection.one.password=test 29 | remote.connection.one.protocol=remote 30 | remote.connection.two.host=localhost 31 | remote.connection.two.port=7099 32 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 33 | remote.connection.two.username=test 34 | remote.connection.two.password=test 35 | remote.connection.two.protocol=remote 36 | -------------------------------------------------------------------------------- /src/test/resources/cluster-node-selector-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2010 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.protocol=remote 27 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 28 | remote.connection.one.username=test 29 | remote.connection.one.password=test 30 | remote.connection.one.realm=default 31 | 32 | # connection to a node at protocol://host:port 33 | remote.connection.two.host=localhost 34 | remote.connection.two.port=7099 35 | remote.connection.two.protocol=remote 36 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 37 | remote.connection.two.username=test 38 | remote.connection.two.password=test 39 | remote.connection.two.realm=default 40 | 41 | # the nodes are clustered in a cluster called ejb and have names node1, node2 42 | remote.clusters=ejb 43 | remote.cluster.ejb.node.node1.username=test 44 | remote.cluster.ejb.node.node1.password=test 45 | remote.cluster.ejb.clusternode.selector=org.jboss.ejb.client.test.ClusterNodeSelectorTestCase$TestSelector 46 | #remote.cluster.ejb.node.node2.username=test 47 | #remote.cluster.ejb.node.node2.password=test -------------------------------------------------------------------------------- /src/test/resources/clustered-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2010 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two,three 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.protocol=remote 27 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 28 | remote.connection.one.username=test 29 | remote.connection.one.password=test 30 | remote.connection.one.realm=default 31 | 32 | # connection to a node at protocol://host:port 33 | remote.connection.two.host=localhost 34 | remote.connection.two.port=7099 35 | remote.connection.two.protocol=remote 36 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 37 | remote.connection.two.username=test 38 | remote.connection.two.password=test 39 | remote.connection.two.realm=default 40 | 41 | # connection to a node at protocol://host:port 42 | remote.connection.three.host=localhost 43 | remote.connection.three.port=7199 44 | remote.connection.three.protocol=remote 45 | remote.connection.three.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 46 | remote.connection.three.username=test 47 | remote.connection.three.password=test 48 | remote.connection.three.realm=default 49 | 50 | # the nodes are clustered in a cluster called ejb and have names node1, node2 51 | remote.clusters=ejb 52 | remote.cluster.ejb.node.node1.username=test 53 | remote.cluster.ejb.node.node1.password=test 54 | remote.cluster.ejb.node.node2.username=test 55 | remote.cluster.ejb.node.node2.password=test -------------------------------------------------------------------------------- /src/test/resources/deployment-node-selector-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2010 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two 22 | 23 | deployment.node.selector=org.jboss.ejb.client.test.DeploymentNodeSelectorTestCase$TestSelector 24 | 25 | # connection to a node at protocol://host:port 26 | remote.connection.one.host=localhost 27 | remote.connection.one.port=6999 28 | remote.connection.one.protocol=remote 29 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 30 | remote.connection.one.username=test 31 | remote.connection.one.password=test 32 | remote.connection.one.realm=default 33 | 34 | # connection to a node at protocol://host:port 35 | remote.connection.two.host=localhost 36 | remote.connection.two.port=7099 37 | remote.connection.two.protocol=remote 38 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 39 | remote.connection.two.username=test 40 | remote.connection.two.password=test 41 | remote.connection.two.realm=default 42 | 43 | -------------------------------------------------------------------------------- /src/test/resources/jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2010 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.protocol=remote 27 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 28 | remote.connection.one.username=test 29 | remote.connection.one.password=test 30 | 31 | # connection to a node at protocol://host:port 32 | remote.connection.two.host=localhost 33 | remote.connection.two.port=7099 34 | remote.connection.two.protocol=remote 35 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 36 | remote.connection.two.username=test 37 | remote.connection.two.password=test 38 | -------------------------------------------------------------------------------- /src/test/resources/jndi.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2011 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | java.naming.factory.url.pkgs=org.jboss.ejb.client.naming 20 | -------------------------------------------------------------------------------- /src/test/resources/last-node-to-leave-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2019 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one,two 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.protocol=remote 27 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 28 | remote.connection.one.username=test 29 | remote.connection.one.password=test 30 | remote.connection.one.realm=default 31 | 32 | # connection to a node at protocol://host:port 33 | remote.connection.two.host=localhost 34 | remote.connection.two.port=7099 35 | remote.connection.two.protocol=remote 36 | remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 37 | remote.connection.two.username=test 38 | remote.connection.two.password=test 39 | remote.connection.two.realm=default 40 | 41 | # the nodes are clustered in a cluster called ejb and have names node1, node2 42 | remote.clusters=ejb 43 | remote.cluster.ejb.node.node1.username=test 44 | remote.cluster.ejb.node.node1.password=test 45 | remote.cluster.ejb.clusternode.selector=org.jboss.ejb.client.test.LastNodeToLeaveTestCase$TestSelector 46 | -------------------------------------------------------------------------------- /src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2010 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | # Additional logger names to configure (root logger is always configured) 20 | loggers=javax.security.sasl,org.xnio.ssl,org.xnio,org.jboss.ejb.client,javax.management 21 | 22 | # Root logger configuration 23 | logger.level=${test.level:INFO} 24 | logger.handlers=CONSOLE, FILE 25 | 26 | logger.javax.security.sasl.level=INFO 27 | logger.org.xnio.ssl.level=INFO 28 | logger.org.xnio.level=INFO 29 | logger.org.jboss.ejb.client.level=DEBUG 30 | logger.javax.management.level=INFO 31 | 32 | # Console handler configuration 33 | handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler 34 | handler.CONSOLE.properties=autoFlush 35 | handler.CONSOLE.level=${test.level:DEBUG} 36 | handler.CONSOLE.autoFlush=true 37 | handler.CONSOLE.formatter=PATTERN 38 | 39 | # File handler configuration 40 | handler.FILE=org.jboss.logmanager.handlers.FileHandler 41 | handler.FILE.level=${test.level:DEBUG} 42 | handler.FILE.properties=autoFlush,fileName 43 | handler.FILE.autoFlush=true 44 | handler.FILE.fileName=./target/test.log 45 | handler.FILE.formatter=PATTERN 46 | 47 | # Formatter pattern configuration 48 | formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter 49 | formatter.PATTERN.properties=pattern 50 | formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n 51 | 52 | -------------------------------------------------------------------------------- /src/test/resources/maximum-connected-nodes-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | remote.clusters=ejb1,ejb2 2 | remote.cluster.ejb2.max-allowed-connected-nodes=42 3 | -------------------------------------------------------------------------------- /src/test/resources/mixed-mode-wildfly-client.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/test/resources/no-protocol-jboss-ejb-client.properties: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2019 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 20 | 21 | remote.connections=one 22 | 23 | # connection to a node at protocol://host:port 24 | remote.connection.one.host=localhost 25 | remote.connection.one.port=6999 26 | remote.connection.one.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 27 | remote.connection.one.username=test 28 | remote.connection.one.password=test 29 | -------------------------------------------------------------------------------- /src/test/resources/org/jboss/ejb/client/test/byteman/BytemanTransactionTestCase.btm: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2022 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | RULE @1 get TransactionClientChannel.peerConnectionMap size 18 | CLASS org.wildfly.transaction.client.provider.remoting.RemotingRemoteTransactionHandle 19 | AT EXIT 20 | METHOD commit 21 | BIND handle:RemotingRemoteTransactionHandle = $0; 22 | IF TRUE 23 | DO System.setProperty("peerMapSize", Integer.toString(handle.channel.peerTransactionMap.size())); 24 | ENDRULE -------------------------------------------------------------------------------- /src/test/resources/org/jboss/ejb/client/test/byteman/OOMEInInvocationTestCase.btm: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2019 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | RULE @1 cause OOM 19 | CLASS org.jboss.marshalling.river.RiverMarshaller 20 | AT ENTRY 21 | METHOD doWriteObject 22 | IF TRUE 23 | DO 24 | throw new OutOfMemoryError("Byteman throwing OOM"); 25 | ENDRULE 26 | 27 | RULE @2 cause Exception 28 | CLASS org.jboss.ejb.client.EJBReceiverInvocationContext 29 | AT EXIT 30 | METHOD toString 31 | BIND result = $toString.toString() 32 | IF (result.contains("echo")) 33 | DO System.setProperty("echo", "true"); 34 | ENDRULE -------------------------------------------------------------------------------- /src/test/resources/org/jboss/ejb/client/test/byteman/TimeoutRetryTestCase.btm: -------------------------------------------------------------------------------- 1 | # 2 | # JBoss, Home of Professional Open Source. 3 | # Copyright 2019 Red Hat, Inc., and individual contributors 4 | # as indicated by the @author tags. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | RULE @1 delay invocation 19 | CLASS org.jboss.ejb.client.EJBClientInvocationContext 20 | AT ENTRY 21 | METHOD retryOperation 22 | IF TRUE 23 | DO 24 | Thread.sleep(3000) 25 | ENDRULE 26 | -------------------------------------------------------------------------------- /src/test/resources/wildfly-client.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | --------------------------------------------------------------------------------