├── .github ├── FUNDING.yml ├── workflows │ ├── maven.yml │ └── mavenpublish.yml └── ISSUE_TEMPLATE │ └── bug_report.md ├── modules ├── cpr │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── atmosphere │ │ │ │ ├── util │ │ │ │ ├── version.properties │ │ │ │ ├── UUIDProvider.java │ │ │ │ ├── DefaultUUIDProvider.java │ │ │ │ ├── analytics │ │ │ │ │ └── URLBuildingStrategy.java │ │ │ │ ├── VoidAnnotationProcessor.java │ │ │ │ ├── EndpointMapper.java │ │ │ │ ├── ServletContextFactory.java │ │ │ │ ├── ByteArrayAsyncWriter.java │ │ │ │ └── VoidServletConfig.java │ │ │ │ ├── inject │ │ │ │ ├── CDIProducer.java │ │ │ │ ├── AtmosphereConfigAware.java │ │ │ │ ├── AtmosphereConfigInjectable.java │ │ │ │ ├── annotation │ │ │ │ │ ├── ApplicationScoped.java │ │ │ │ │ └── RequestScoped.java │ │ │ │ ├── MetaBroadcasterInjectable.java │ │ │ │ ├── WebSocketFactoryInjectable.java │ │ │ │ ├── AtmosphereFrameworkInjectable.java │ │ │ │ ├── BroadcasterFactoryInjectable.java │ │ │ │ ├── AtmosphereResourceFactoryInjectable.java │ │ │ │ ├── AtmosphereResourceSessionFactoryInjectable.java │ │ │ │ ├── Injectable.java │ │ │ │ ├── InjectIntrospectorAdapter.java │ │ │ │ ├── InjectionListener.java │ │ │ │ ├── PostConstructIntrospector.java │ │ │ │ ├── InjectIntrospector.java │ │ │ │ ├── AtmosphereResourceIntrospector.java │ │ │ │ └── AtmosphereRequestIntrospector.java │ │ │ │ ├── interceptor │ │ │ │ ├── AllowInterceptor.java │ │ │ │ ├── OldBrowserPaddingInterceptor.java │ │ │ │ ├── WebSocketMessageSuspendInterceptor.java │ │ │ │ ├── NginxInterceptor.java │ │ │ │ ├── SessionCreationInterceptor.java │ │ │ │ └── InvokationOrder.java │ │ │ │ ├── cpr │ │ │ │ ├── AsyncSupportResolver.java │ │ │ │ ├── KeepOpenStreamAware.java │ │ │ │ ├── BroadcastFilterLifecycle.java │ │ │ │ ├── AtmosphereResourceHeartbeatEventListener.java │ │ │ │ ├── CompletionAware.java │ │ │ │ ├── BroadcasterCacheListener.java │ │ │ │ ├── AtmosphereFrameworkListenerAdapter.java │ │ │ │ ├── AtmosphereServletProcessor.java │ │ │ │ ├── AtmosphereMappingException.java │ │ │ │ ├── AtmosphereResourceListener.java │ │ │ │ ├── BroadcastFilterAdapter.java │ │ │ │ ├── AtmosphereResourceListenerAdapter.java │ │ │ │ ├── ClusterBroadcastFilter.java │ │ │ │ ├── Serializer.java │ │ │ │ ├── BroadcasterLifeCyclePolicyListenerAdapter.java │ │ │ │ ├── BroadcasterLifeCyclePolicyListener.java │ │ │ │ ├── HeartbeatAtmosphereResourceEvent.java │ │ │ │ ├── PerRequestBroadcastFilter.java │ │ │ │ ├── AsyncIOInterceptor.java │ │ │ │ ├── AsyncIOInterceptorAdapter.java │ │ │ │ ├── AtmosphereFrameworkListener.java │ │ │ │ ├── AtmosphereInterceptorAdapter.java │ │ │ │ ├── AtmosphereObjectFactory.java │ │ │ │ ├── AsyncIOWriterAdapter.java │ │ │ │ ├── AnnotationProcessor.java │ │ │ │ ├── AsyncSupportListenerAdapter.java │ │ │ │ ├── DefaultAtmosphereResourceSession.java │ │ │ │ └── AtmosphereResourceSessionFactory.java │ │ │ │ ├── config │ │ │ │ ├── service │ │ │ │ │ ├── Get.java │ │ │ │ │ ├── Put.java │ │ │ │ │ ├── BroadcasterListenerService.java │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── Delete.java │ │ │ │ │ ├── Singleton.java │ │ │ │ │ ├── BroadcasterCacheListenerService.java │ │ │ │ │ ├── Disconnect.java │ │ │ │ │ ├── Heartbeat.java │ │ │ │ │ ├── Resume.java │ │ │ │ │ ├── AtmosphereResourceListenerService.java │ │ │ │ │ ├── UUIDProviderService.java │ │ │ │ │ ├── EndpointMapperService.java │ │ │ │ │ ├── BroadcasterService.java │ │ │ │ │ ├── AsyncSupportService.java │ │ │ │ │ ├── AtmosphereFrameworkListenerService.java │ │ │ │ │ ├── BroadcasterCacheService.java │ │ │ │ │ ├── BroadcasterFactoryService.java │ │ │ │ │ ├── WebSocketFactoryService.java │ │ │ │ │ ├── WebSocketProtocolService.java │ │ │ │ │ ├── AsyncSupportListenerService.java │ │ │ │ │ ├── WebSocketProcessorService.java │ │ │ │ │ ├── AtmosphereResourceFactoryService.java │ │ │ │ │ ├── BroadcasterFilterService.java │ │ │ │ │ ├── BroadcasterCacheInspectorService.java │ │ │ │ │ ├── DeliverTo.java │ │ │ │ │ ├── PathParam.java │ │ │ │ │ ├── AtmosphereInterceptorService.java │ │ │ │ │ ├── Message.java │ │ │ │ │ └── Ready.java │ │ │ │ ├── AtmosphereHandlerProperty.java │ │ │ │ ├── FrameworkConfiguration.java │ │ │ │ ├── ApplicationConfiguration.java │ │ │ │ ├── AtmosphereAnnotation.java │ │ │ │ └── managed │ │ │ │ │ └── Decoder.java │ │ │ │ ├── websocket │ │ │ │ ├── WebSocketFactory.java │ │ │ │ ├── DefaultWebSocketFactory.java │ │ │ │ ├── WebSocketHandlerAdapter.java │ │ │ │ ├── WebSocketStreamingHandler.java │ │ │ │ ├── WebSocketPingPongListener.java │ │ │ │ └── WebSocketHandler.java │ │ │ │ ├── annotation │ │ │ │ ├── BroadcasterServiceProcessor.java │ │ │ │ ├── BroadcasterCacheServiceProcessor.java │ │ │ │ ├── WebSocketProtocolServiceProcessor.java │ │ │ │ ├── Processor.java │ │ │ │ ├── UUIDProviderServiceProcessor.java │ │ │ │ ├── BroadcastFilterServiceProcessor.java │ │ │ │ ├── EndpointMapperServiceProcessor.java │ │ │ │ ├── WebSocketFactoryServiceProcessor.java │ │ │ │ ├── AsyncSupportListenerServiceProcessor.java │ │ │ │ ├── AtmosphereFrameworkServiceProcessor.java │ │ │ │ ├── BroadcasterCacheListenererviceProcessor.java │ │ │ │ ├── BroadcasterFactoryServiceProcessor.java │ │ │ │ ├── BroadcasterCacheInspectorServiceProcessor.java │ │ │ │ ├── AsyncSupportServiceProcessor.java │ │ │ │ ├── AtmosphereInterceptorServiceProcessor.java │ │ │ │ ├── AtmosphereResourceFactoryServiceProcessor.java │ │ │ │ ├── AtmosphereResourceListenerServiceProcessor.java │ │ │ │ ├── WebSocketProcessorServiceProcessor.java │ │ │ │ └── BroadcasterListenerServiceProcessor.java │ │ │ │ ├── cache │ │ │ │ ├── BroadcasterCacheInspector.java │ │ │ │ ├── BroadcastMessage.java │ │ │ │ └── CacheMessage.java │ │ │ │ ├── handler │ │ │ │ ├── AnnotatedProxy.java │ │ │ │ └── AtmosphereHandlerAdapter.java │ │ │ │ └── pool │ │ │ │ └── BoundedApachePoolableProvider.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── services │ │ │ │ ├── org.atmosphere.inject.CDIProducer │ │ │ │ ├── jakarta.servlet.ServletContainerInitializer │ │ │ │ └── org.atmosphere.inject.Injectable │ │ │ ├── context.xml │ │ │ ├── atmosphere.xml.template │ │ │ └── atmosphere-web.xml.template │ │ └── test │ │ ├── resources │ │ ├── META-INF │ │ │ └── test-services │ │ │ │ └── org.atmosphere.cpr.AtmosphereFramework │ │ └── logback-test.xml │ │ └── java │ │ └── org │ │ └── atmosphere │ │ └── util │ │ ├── IOUtilsTest.java │ │ └── CookieUtilTest.java └── pom.xml ├── assembly ├── cpr │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ └── atmosphere │ │ │ │ └── voidClass │ │ │ │ └── VoidClass.java │ │ │ └── assembly │ │ │ └── distribution.xml │ └── pom.xml └── pom.xml ├── license └── README ├── SECURITY.md ├── scripts └── javadoc.sh └── .gitignore /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [atmosphere] 4 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/version.properties: -------------------------------------------------------------------------------- 1 | atmosphere.version=${project.version} -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/META-INF/services/org.atmosphere.inject.CDIProducer: -------------------------------------------------------------------------------- 1 | org.atmosphere.inject.AtmosphereProducers -------------------------------------------------------------------------------- /assembly/cpr/src/main/java/org/atmosphere/voidClass/VoidClass.java: -------------------------------------------------------------------------------- 1 | package org.atmosphere.voidClass; 2 | 3 | public class VoidClass { 4 | } 5 | -------------------------------------------------------------------------------- /modules/cpr/src/test/resources/META-INF/test-services/org.atmosphere.cpr.AtmosphereFramework: -------------------------------------------------------------------------------- 1 | INSTALL 2 | org.atmosphere.cpr.AtmosphereFrameworkTest$MyInterceptor -------------------------------------------------------------------------------- /license/README: -------------------------------------------------------------------------------- 1 | org.atmosphere.util.uri.* classes are under the CDDL license and comes from the Jersey Project. 2 | 3 | All other classes are released under the Apache 2 Licence. -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer: -------------------------------------------------------------------------------- 1 | org.atmosphere.cpr.AnnotationScanningServletContainerInitializer 2 | org.atmosphere.cpr.ContainerInitializer 3 | 4 | -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 2.5.x > | :white_check_mark: | 11 | | 2.4.x | :x: | 12 | 13 | 14 | ## Reporting a Vulnerability 15 | 16 | email: jfarcand@apache.org 17 | -------------------------------------------------------------------------------- /scripts/javadoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | # Update JXR and JavaDoc in gh-pages. 3 | # Author: Hubert Iwaniuk 4 | # Licence: ../LICENSE-2.0.txt 5 | 6 | git checkout master && \ 7 | git pull && \ 8 | mvn clean jxr:aggregate javadoc:aggregate && \ 9 | git checkout gh-pages && \ 10 | for x in apidocs xref; do rm -r $x && git rm -r $x && mv target/site/$x ./ && git add $x; done && \ 11 | git commit -m "JXR & JavaDoc update" && \ 12 | git push origin gh-pages && \ 13 | git checkout master 14 | -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/atmosphere.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *~ 3 | .*.swp 4 | .*.swo 5 | .loadpath 6 | .buildpath 7 | .checkstyle 8 | .pmd 9 | .pmdruleset 10 | .pmdruleset.xml 11 | .project 12 | .settings 13 | .classpath 14 | .metadata 15 | dependency-reduced-pom.xml 16 | .idea 17 | *.iml 18 | *.ipr 19 | *.iws 20 | nbproject 21 | .DS_Store 22 | target 23 | test-output 24 | nbactions.xml 25 | samples/gwt-demo/src/main/webapp/WEB-INF/classes/ 26 | samples/gwt-chat/src/main/webapp/WEB-INF/classes/ 27 | samples/gwt-conn-share/src/main/webapp/WEB-INF/classes/ 28 | atlassian-ide-plugin.xml 29 | -------------------------------------------------------------------------------- /modules/cpr/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %level [%thread] %logger{10} [%file:%line] %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: Atmopshere 3.x CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | java-version: [21, 22, 25] 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - name: Set up JDK ${{ matrix.java-version }} 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: ${{ matrix.java-version }} 24 | distribution: 'temurin' 25 | 26 | - name: Build with Maven 27 | run: mvn -B package --file pom.xml 28 | 29 | - name: Test with Maven 30 | run: mvn -B test --file pom.xml 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/UUIDProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | public interface UUIDProvider { 19 | 20 | String generateUuid(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/META-INF/services/org.atmosphere.inject.Injectable: -------------------------------------------------------------------------------- 1 | org.atmosphere.inject.AtmosphereConfigInjectable 2 | org.atmosphere.inject.AtmosphereFrameworkInjectable 3 | org.atmosphere.inject.AtmosphereResourceFactoryInjectable 4 | org.atmosphere.inject.AtmosphereResourceSessionFactoryInjectable 5 | org.atmosphere.inject.BroadcasterFactoryInjectable 6 | org.atmosphere.inject.MetaBroadcasterInjectable 7 | org.atmosphere.inject.WebSocketFactoryInjectable 8 | org.atmosphere.inject.PostConstructIntrospector 9 | org.atmosphere.inject.BroadcasterIntrospector 10 | org.atmosphere.inject.AtmosphereResourceIntrospector 11 | org.atmosphere.inject.AtmosphereRequestIntrospector 12 | org.atmosphere.inject.AtmosphereResponseIntrospector 13 | org.atmosphere.inject.AtmosphereResourceEventIntrospector 14 | org.atmosphere.inject.PathParamIntrospector -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: jfarcand 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Atmosphere Info** 14 | - version 15 | - atmosphere.js version 16 | - extensions used 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Screenshots** 22 | If applicable, add screenshots to help explain your problem. 23 | 24 | **Systems (please complete the following information):** 25 | - OS: [e.g. iOS] 26 | - Browser name and version [e.g. chrome 22] 27 | - Java version and distribution 28 | - Serveur name and version [e.g Tomcat/Jetty/Netty] 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /modules/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.atmosphere 5 | atmosphere-project 6 | 3.0.14 7 | 8 | 9 | 4.0.0 10 | org.atmosphere 11 | atmosphere-modules 12 | 3.0.14 13 | pom 14 | atmosphere-modules 15 | Atmosphere Framework modules 16 | https://github.com/Atmosphere/atmosphere 17 | 18 | 19 | cpr 20 | 21 | 22 | -------------------------------------------------------------------------------- /assembly/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.atmosphere 5 | atmosphere-project 6 | 3.0.14 7 | 8 | 9 | 4.0.0 10 | org.atmosphere 11 | atmosphere-assembly 12 | 3.0.14 13 | pom 14 | atmosphere-assembly 15 | Atmosphere Framework assembly 16 | https://github.com/Atmosphere/atmosphere 17 | 18 | 19 | cpr 20 | 21 | 22 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/CDIProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | /** 19 | * A simple marker interface for for the CDI extension. 20 | */ 21 | public interface CDIProducer extends AtmosphereConfigAware{ 22 | } 23 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/DefaultUUIDProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import java.util.UUID; 19 | 20 | public class DefaultUUIDProvider implements UUIDProvider { 21 | @Override 22 | public String generateUuid() { 23 | return UUID.randomUUID().toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/AllowInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | /** 19 | * A marker interface that does nothing except used by {@link org.atmosphere.cpr.AtmosphereInterceptor} to modify the default 20 | * behavior of any functionality. 21 | * 22 | * @author Jeanfrancois Arcand 23 | */ 24 | public interface AllowInterceptor { 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/mavenpublish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path 3 | 4 | name: Maven Package 5 | 6 | on: 7 | release: 8 | branches: 9 | - atmosphere-2.7.x 10 | types: [created] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 1.8 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 1.8 23 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 24 | settings-path: ${{ github.workspace }} # location for the settings.xml file 25 | 26 | - name: Build with Maven 27 | run: mvn -B package --file pom.xml 28 | 29 | - name: Publish to GitHub Packages Apache Maven 30 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml 31 | env: 32 | GITHUB_TOKEN: ${{ github.token }} 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/OldBrowserPaddingInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | /** 19 | * Old 8k Padding interceptor for Browser that needs whitespace when streaming is used. 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public class OldBrowserPaddingInterceptor extends PaddingAtmosphereInterceptor { 24 | 25 | public OldBrowserPaddingInterceptor() { 26 | super(8192); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereConfigAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | 20 | /** 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public interface AtmosphereConfigAware { 24 | /** 25 | * Configure an AtmosphereFramework object. 26 | * 27 | * @param config {@link org.atmosphere.cpr.AtmosphereConfig} 28 | */ 29 | void configure(AtmosphereConfig config); 30 | } 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AsyncSupportResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | /** 20 | * This interface is used by {@link AtmosphereFramework} to determine which AsyncSupport instance should be used 21 | * 22 | * @author Viktor Klang 23 | */ 24 | public interface AsyncSupportResolver { 25 | AsyncSupport resolve(final boolean useNativeIfPossible, final boolean defaultToBlocking, 26 | final boolean useWebsocketIfPossible); 27 | } 28 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/analytics/URLBuildingStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util.analytics; 17 | 18 | /** 19 | * Fork of https://code.google.com/p/jgoogleanalytics/ 20 | * Interface for the URL building strategy 21 | * 22 | * @author : Siddique Hameed 23 | * @version : 0.1 24 | */ 25 | public interface URLBuildingStrategy { 26 | 27 | String buildURL(FocusPoint focusPoint); 28 | 29 | void setRefererURL(String refererURL); 30 | } 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/KeepOpenStreamAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | 19 | /** 20 | * The KeepOpenStreamAware interface is used by a class implementing the {@link AsyncIOWriter} interface 21 | * to indicate the closing of the underlining stream is managed elsewhere and invoking the 22 | * {@link AsyncIOWriter#close(AtmosphereResponse)} method does not close the stream. In other words, 23 | * the underlining stream will be kept open until it is closed by other means. 24 | */ 25 | public interface KeepOpenStreamAware { 26 | } 27 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/BroadcastFilterLifecycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | /** 20 | * Add lifecycle method to the {@link BroadcastFilter} interface. 21 | * 22 | * @author Jeanfrancois Arcand 23 | */ 24 | public interface BroadcastFilterLifecycle extends BroadcastFilter { 25 | 26 | /** 27 | * Initialize the {@link BroadcastFilter}. 28 | */ 29 | void init(AtmosphereConfig config); 30 | 31 | /** 32 | * Destroy this {@link BroadcastFilter} and its internal resources. 33 | */ 34 | void destroy(); 35 | } -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResourceHeartbeatEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | /** 20 | * Receive notifications when heartbeat events occur. 21 | * 22 | * @author Guillaume DROUET 23 | * @version 1.0 24 | * @since 2.2 25 | */ 26 | public interface AtmosphereResourceHeartbeatEventListener { 27 | 28 | /** 29 | * Invoked when the remote connections send a heartbeat. 30 | * 31 | * @param event a {@link AtmosphereResourceEvent} 32 | */ 33 | void onHeartbeat(AtmosphereResourceEvent event); 34 | } 35 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Get.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. Annotate a method which will get invoked when an 25 | * HTTP GET is send. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Get { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Put.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. Annotate a method which will get invoked when an 25 | * HTTP PUT is sent. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Put { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for installing {@link org.atmosphere.cpr.BroadcasterListener} 26 | */ 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface BroadcasterListenerService { 31 | } 32 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Post.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. Annotate a method which will get invoked when an 25 | * HTTP POST is sent. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Post { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/CompletionAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | 19 | /** 20 | * The CompletionAware interface is used by a class implementing the {@link AtmosphereResponse} interface 21 | * to be notified when writing to the response has been completed. 22 | * This is indicated by the response object leaving the scope of HttpServlet.service method for synchronous calls 23 | * or the AsyncContext.complete method being invoked for asynchronous calls. 24 | */ 25 | public interface CompletionAware { 26 | void onComplete(); 27 | 28 | boolean completed(); 29 | } 30 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Delete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. Annotate a method which will get invoked when an 25 | * HTTP DELETE is sent. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Delete { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Singleton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * A class annotated with this annotation will be instantiated only once. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface Singleton { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterCacheListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for installing {@link org.atmosphere.cpr.BroadcasterListener} 26 | */ 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface BroadcasterCacheListenerService { 31 | } 32 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Disconnect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. Annotate a method which will get invoked when the 25 | * remote connection is closed. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Disconnect { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/BroadcasterCacheListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.atmosphere.cache.CacheMessage; 19 | 20 | /** 21 | * Listener for {@link org.atmosphere.cpr.BroadcasterCache} 22 | */ 23 | public interface BroadcasterCacheListener { 24 | 25 | /** 26 | * Invoked when a message is added to the cache 27 | */ 28 | void onAddCache(String broadcasterId, CacheMessage cacheMessage); 29 | 30 | /** 31 | * Invoked when a message is removed from the cache. 32 | */ 33 | void onRemoveCache(String broadcasterId, CacheMessage cacheMessage); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Heartbeat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Annotate a method that will get invoked when the client sends an heartbeat. {@link org.atmosphere.interceptor.HeartbeatInterceptor} 25 | * must be installed. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Heartbeat { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Resume.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Use this annotation with the {@link ManagedService} annotation. A method annotated with this annotation will be 25 | * executed and then the connection will be resumed. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(ElementType.METHOD) 31 | public @interface Resume { 32 | } 33 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AtmosphereResourceListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Install an {@link org.atmosphere.cpr.AtmosphereResourceListener} 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface AtmosphereResourceListenerService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/UUIDProviderService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation to use in order to replace the default {@link org.atmosphere.util.UUIDProvider} 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface UUIDProviderService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/EndpointMapperService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation to use in order to replace the default {@link org.atmosphere.util.EndpointMapper} 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface EndpointMapperService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.Broadcaster} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface BroadcasterService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AsyncSupportService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.AsyncSupport} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface AsyncSupportService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | import org.atmosphere.cpr.AtmosphereResource; 19 | 20 | /** 21 | * A factory for retrieving {@link WebSocket} 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public interface WebSocketFactory { 26 | 27 | /** 28 | * Retrieve the {@link WebSocket} associated with a uuid. The uuid could be the one returned by 29 | * the {@link AtmosphereResource#uuid()} or an application generated one. 30 | * 31 | * @param uuid a UUID associated 32 | * @return WebSocket 33 | */ 34 | WebSocket find(String uuid); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AtmosphereFrameworkListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for installing {@link org.atmosphere.cpr.AtmosphereFrameworkListener} 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface AtmosphereFrameworkListenerService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterCacheService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.BroadcasterCache} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface BroadcasterCacheService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.Broadcaster; 22 | 23 | @AtmosphereAnnotation(BroadcasterService.class) 24 | public class BroadcasterServiceProcessor implements Processor { 25 | 26 | @Override 27 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 28 | framework.setDefaultBroadcasterClassName(annotatedClass.getName()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cache/BroadcasterCacheInspector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cache; 17 | 18 | /** 19 | * Inspect {@link BroadcastMessage}s before they get added to the BroadcasterCache. Messages can also be modified 20 | * before they get added to the cache. 21 | * 22 | * @author Jeanfrancois Arcand 23 | */ 24 | public interface BroadcasterCacheInspector { 25 | /** 26 | * Inspect the {@link BroadcastMessage} and return true if the message can be cached, false if not. 27 | * @param message {@link BroadcastMessage} 28 | * @return true if allowed to be cached, false if not. 29 | */ 30 | boolean inspect(BroadcastMessage message); 31 | } 32 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterFactoryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.BroadcasterFactory} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface BroadcasterFactoryService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/WebSocketFactoryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.websocket.WebSocketFactory} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface WebSocketFactoryService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/WebSocketProtocolService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.websocket.WebSocketProtocol} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface WebSocketProtocolService { 33 | } 34 | -------------------------------------------------------------------------------- /assembly/cpr/src/main/assembly/distribution.xml: -------------------------------------------------------------------------------- 1 | 5 | distribution 6 | ${artifactId} 7 | false 8 | 9 | zip 10 | 11 | 12 | 13 | runtime 14 | lib/ 15 | 16 | * 17 | 18 | 19 | 20 | 21 | 22 | src/main/resources 23 | webapps/ 24 | 25 | 26 | src/main/conf 27 | 28 | *.xml 29 | 30 | conf 31 | 32 | 33 | src/main/scripts 34 | 35 | *.* 36 | 37 | bin 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AsyncSupportListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.AsyncSupportListener} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface AsyncSupportListenerService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/WebSocketProcessorService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.websocket.WebSocketProcessor} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface WebSocketProcessorService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereConfigInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.inject.annotation.ApplicationScoped; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | @ApplicationScoped 24 | public class AtmosphereConfigInjectable implements Injectable { 25 | 26 | @Override 27 | public boolean supportedType(Type t) { 28 | return (t instanceof Class) && AtmosphereConfig.class.isAssignableFrom((Class) t); 29 | } 30 | 31 | @Override 32 | public AtmosphereConfig injectable(AtmosphereConfig config) { 33 | return config; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/annotation/ApplicationScoped.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject.annotation; 17 | 18 | import org.atmosphere.inject.Injectable; 19 | 20 | import java.lang.annotation.Documented; 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 | * An annotation for {@link Injectable} used to decide when the injection must happens. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | @Target({ElementType.TYPE}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface ApplicationScoped { 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AtmosphereResourceFactoryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.AtmosphereResourceFactory} class to use by default. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface AtmosphereResourceFactoryService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterFilterService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere to add the {@link org.atmosphere.cpr.BroadcastFilter} to all created {@link org.atmosphere.cpr.Broadcaster} 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface BroadcasterFilterService { 33 | } 34 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereFrameworkListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Adapter for {@link org.atmosphere.cpr.AtmosphereFrameworkListener} 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public class AtmosphereFrameworkListenerAdapter implements AtmosphereFrameworkListener { 24 | @Override 25 | public void onPreInit(AtmosphereFramework f) { 26 | } 27 | 28 | @Override 29 | public void onPostInit(AtmosphereFramework f) { 30 | } 31 | 32 | @Override 33 | public void onPreDestroy(AtmosphereFramework f) { 34 | } 35 | 36 | @Override 37 | public void onPostDestroy(AtmosphereFramework f) { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterCacheServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterCacheService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.BroadcasterCache; 22 | 23 | @AtmosphereAnnotation(BroadcasterCacheService.class) 24 | public class BroadcasterCacheServiceProcessor implements Processor { 25 | 26 | @Override 27 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 28 | framework.setBroadcasterCacheClassName(annotatedClass.getName()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/BroadcasterCacheInspectorService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation used to mark a {@link org.atmosphere.cache.BroadcasterCacheInspector}. The class will be added 26 | * to the installed BroadcasterCache. 27 | * 28 | * @author Jeanfrancois Arcand 29 | */ 30 | @Target({ElementType.TYPE}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Documented 33 | public @interface BroadcasterCacheInspectorService { 34 | } 35 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/WebSocketProtocolServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.WebSocketProtocolService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.websocket.WebSocketProtocol; 22 | 23 | @AtmosphereAnnotation(WebSocketProtocolService.class) 24 | public class WebSocketProtocolServiceProcessor implements Processor { 25 | 26 | @Override 27 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 28 | framework.setWebSocketProtocolClassName(annotatedClass.getName()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/DefaultWebSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | import org.atmosphere.cpr.AtmosphereResource; 19 | import org.atmosphere.cpr.AtmosphereResourceFactory; 20 | import org.atmosphere.cpr.AtmosphereResourceImpl; 21 | 22 | import jakarta.inject.Inject; 23 | 24 | public class DefaultWebSocketFactory implements WebSocketFactory { 25 | 26 | @Inject 27 | private AtmosphereResourceFactory factory; 28 | 29 | @Override 30 | public WebSocket find(String uuid) { 31 | AtmosphereResource r = factory.find(uuid); 32 | if (r != null) { 33 | return ((AtmosphereResourceImpl) r).webSocket(); 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereServletProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | import jakarta.servlet.Servlet; 20 | import jakarta.servlet.ServletConfig; 21 | import jakarta.servlet.ServletException; 22 | 23 | /** 24 | * Simple interface that can be used to wrap a {@link Servlet} from an {@link AtmosphereHandler}. 25 | * 26 | * @author Jeanfrancois Arcand 27 | */ 28 | public interface AtmosphereServletProcessor extends AtmosphereHandler { 29 | 30 | /** 31 | * Initialize the {@link AtmosphereServletProcessor} using the {@link ServletConfig}. 32 | * @param config the {@link jakarta.servlet.ServletConfig} 33 | */ 34 | void init(AtmosphereConfig config) throws ServletException; 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/MetaBroadcasterInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.MetaBroadcaster; 20 | import org.atmosphere.inject.annotation.ApplicationScoped; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class MetaBroadcasterInjectable implements Injectable { 26 | 27 | @Override 28 | public boolean supportedType(Type t) { 29 | return (t instanceof Class) && MetaBroadcaster.class.isAssignableFrom((Class) t); 30 | } 31 | 32 | @Override 33 | public MetaBroadcaster injectable(AtmosphereConfig config) { 34 | return config.metaBroadcaster(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/WebSocketFactoryInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.inject.annotation.ApplicationScoped; 20 | import org.atmosphere.websocket.WebSocketFactory; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class WebSocketFactoryInjectable implements Injectable { 26 | @Override 27 | public boolean supportedType(Type t) { 28 | return (t instanceof Class) && WebSocketFactory.class.isAssignableFrom((Class) t); 29 | } 30 | 31 | @Override 32 | public WebSocketFactory injectable(AtmosphereConfig config) { 33 | return config.websocketFactory(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereMappingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Thrown when {@link AsynchronousProcessor} is unable to map the request to an {@link AtmosphereHandler}. 20 | */ 21 | public class AtmosphereMappingException extends RuntimeException { 22 | 23 | public AtmosphereMappingException() { 24 | super(); 25 | } 26 | 27 | public AtmosphereMappingException(java.lang.String s) { 28 | super(s); 29 | } 30 | 31 | public AtmosphereMappingException(java.lang.String s, java.lang.Throwable throwable) { 32 | super(s, throwable); 33 | } 34 | 35 | public AtmosphereMappingException(java.lang.Throwable throwable) { 36 | super(throwable); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResourceListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Listener for when {@link AtmosphereResource} gets suspended and disconnected. 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public interface AtmosphereResourceListener { 24 | 25 | /** 26 | * Ibnvoked when the {@link org.atmosphere.cpr.AtmosphereResource} gets suspended 27 | * 28 | * @param uuid {@link AtmosphereResource#uuid()} 29 | */ 30 | void onSuspended(String uuid); 31 | 32 | /** 33 | * Ibnvoked when the {@link org.atmosphere.cpr.AtmosphereResource} gets disconnected 34 | * 35 | * @param uuid {@link AtmosphereResource#uuid()} 36 | */ 37 | void onDisconnect(String uuid); 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/BroadcastFilterAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Adapter for {@link PerRequestBroadcastFilter}. Both methods return {@link BroadcastAction.ACTION#CONTINUE} with the message. 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public class BroadcastFilterAdapter implements PerRequestBroadcastFilter { 24 | 25 | @Override 26 | public BroadcastAction filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message) { 27 | return new BroadcastAction(message); 28 | } 29 | 30 | @Override 31 | public BroadcastAction filter(String broadcasterId, Object originalMessage, Object message) { 32 | return new BroadcastAction(message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereFrameworkInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.AtmosphereFramework; 20 | import org.atmosphere.inject.annotation.ApplicationScoped; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class AtmosphereFrameworkInjectable implements Injectable { 26 | 27 | @Override 28 | public boolean supportedType(Type t) { 29 | return (t instanceof Class) && AtmosphereFramework.class.isAssignableFrom((Class) t); 30 | } 31 | 32 | @Override 33 | public AtmosphereFramework injectable(AtmosphereConfig config) { 34 | return config.framework(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResourceListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | /** 23 | * Adapter for {@link AtmosphereResourceListener} 24 | * 25 | * @author Jeanfrancois Arcand 26 | */ 27 | public class AtmosphereResourceListenerAdapter implements AtmosphereResourceListener { 28 | private final static Logger logger = LoggerFactory.getLogger(AtmosphereResourceListenerAdapter.class); 29 | 30 | @Override 31 | public void onSuspended(String uuid) { 32 | logger.trace("Suspended {}", uuid); 33 | } 34 | 35 | @Override 36 | public void onDisconnect(String uuid) { 37 | logger.trace("Disconnected {}", uuid); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/BroadcasterFactoryInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.BroadcasterFactory; 20 | import org.atmosphere.inject.annotation.ApplicationScoped; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class BroadcasterFactoryInjectable implements Injectable { 26 | 27 | @Override 28 | public boolean supportedType(Type t) { 29 | return (t instanceof Class) && BroadcasterFactory.class.isAssignableFrom((Class) t); 30 | } 31 | 32 | @Override 33 | public BroadcasterFactory injectable(AtmosphereConfig config) { 34 | return config.getBroadcasterFactory(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/ClusterBroadcastFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | /** 20 | * Specialize {@link BroadcastFilter} used when clustering is enabled. 21 | * 22 | * @author Jeanfrancois Arcand 23 | */ 24 | public interface ClusterBroadcastFilter extends BroadcastFilterLifecycle { 25 | 26 | /** 27 | * Cluster's name or address. 28 | * 29 | * @param name 30 | */ 31 | void setUri(String name); 32 | 33 | /** 34 | * The {@link Broadcaster} to use. 35 | * 36 | * @param bc 37 | */ 38 | void setBroadcaster(Broadcaster bc); 39 | 40 | /** 41 | * Return the {@link Broadcaster}. 42 | * 43 | * @return the {@link Broadcaster} 44 | */ 45 | Broadcaster getBroadcaster(); 46 | } 47 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereResourceFactoryInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.AtmosphereResourceFactory; 20 | import org.atmosphere.inject.annotation.ApplicationScoped; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class AtmosphereResourceFactoryInjectable implements Injectable { 26 | 27 | @Override 28 | public boolean supportedType(Type t) { 29 | return (t instanceof Class) && AtmosphereResourceFactory.class.isAssignableFrom((Class) t); 30 | } 31 | 32 | @Override 33 | public AtmosphereResourceFactory injectable(AtmosphereConfig config) { 34 | return config.resourcesFactory(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | 18 | package org.atmosphere.cpr; 19 | 20 | import java.io.IOException; 21 | import java.io.OutputStream; 22 | 23 | /** 24 | * Serialize the {@link Object} that was used as parameter to {@link Broadcaster#broadcast}. 25 | *

26 | * IMPORTANT: This class isn't supported by the Atmosphere-Jersey extension. 27 | * 28 | * @author Paul Sandoz 29 | * @author Jeanfrancois Arcand 30 | */ 31 | public interface Serializer { 32 | 33 | /** 34 | * Serialize the {@link Object} using the {@link OutputStream}. 35 | * 36 | * @param os The {@link java.io.OutputStream} to use when writing 37 | * @param o The broacasted object 38 | * @throws IOException 39 | */ 40 | void write(OutputStream os, Object o) throws IOException; 41 | } 42 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cache/BroadcastMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cache; 17 | 18 | import java.util.UUID; 19 | 20 | /** 21 | * A wrapper around an object passed to {@link org.atmosphere.cpr.Broadcaster#broadcast(Object)} 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public final class BroadcastMessage { 26 | 27 | private final String id; 28 | private final Object message; 29 | 30 | public BroadcastMessage(String id, Object message) { 31 | this.id = id; 32 | this.message = message; 33 | } 34 | 35 | public BroadcastMessage(Object message) { 36 | this(UUID.randomUUID().toString(), message); 37 | } 38 | 39 | public String id() { 40 | return id; 41 | } 42 | 43 | public Object message() { 44 | return message; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/AtmosphereHandlerProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config; 17 | 18 | /** 19 | * @author Sebastien Dionne : sebastien.dionne@gmail.com 20 | */ 21 | public class AtmosphereHandlerProperty { 22 | 23 | private String name; 24 | private String value; 25 | 26 | public AtmosphereHandlerProperty(String name, String value) { 27 | this.name = name; 28 | this.value = value; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getValue() { 40 | return value; 41 | } 42 | 43 | public void setValue(String value) { 44 | this.value = value; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/DeliverTo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Broadcast the returned value only to the calling resource {@link DELIVER_TO#RESOURCE}, 25 | * to its associated Broadcaster {@link DELIVER_TO#BROADCASTER} 26 | * or to all created Broadcasters {@link DELIVER_TO#ALL} 27 | * 28 | * @author Guillaume Drouet 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.METHOD) 32 | public @interface DeliverTo { 33 | 34 | enum DELIVER_TO { RESOURCE, BROADCASTER, ALL} 35 | 36 | /** 37 | * @return the {@link DELIVER_TO} 38 | */ 39 | DELIVER_TO value(); 40 | } 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereResourceSessionFactoryInjectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.AtmosphereResourceSessionFactory; 20 | import org.atmosphere.inject.annotation.ApplicationScoped; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | @ApplicationScoped 25 | public class AtmosphereResourceSessionFactoryInjectable implements Injectable { 26 | 27 | @Override 28 | public boolean supportedType(Type t) { 29 | return (t instanceof Class) && AtmosphereResourceSessionFactory.class.isAssignableFrom((Class) t); 30 | } 31 | 32 | @Override 33 | public AtmosphereResourceSessionFactory injectable(AtmosphereConfig config) { 34 | return config.sessionFactory(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/WebSocketMessageSuspendInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | import org.atmosphere.cpr.Action; 19 | import org.atmosphere.cpr.AtmosphereInterceptorAdapter; 20 | import org.atmosphere.cpr.AtmosphereResource; 21 | import org.atmosphere.cpr.AtmosphereResourceImpl; 22 | import org.atmosphere.util.Utils; 23 | 24 | /** 25 | * Mark WebSocket Message as suspended. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | public class WebSocketMessageSuspendInterceptor extends AtmosphereInterceptorAdapter { 30 | 31 | @Override 32 | public Action inspect(AtmosphereResource r) { 33 | 34 | if (Utils.webSocketMessage(r)){ 35 | ((AtmosphereResourceImpl) r).action().type(Action.TYPE.SUSPEND_MESSAGE); 36 | } 37 | return Action.CONTINUE; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/annotation/RequestScoped.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject.annotation; 17 | 18 | import org.atmosphere.inject.InjectIntrospector; 19 | 20 | import jakarta.inject.Inject; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * An annotation for {@link InjectIntrospector} used to decide when the injection must happens. 29 | * 30 | * Classes using this annotation must be Thread safe. 31 | * 32 | * @author Jeanfrancois Arcand 33 | */ 34 | @Target({ElementType.TYPE}) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Documented 37 | public @interface RequestScoped { 38 | 39 | Class[] value() default { Inject.class }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/BroadcasterLifeCyclePolicyListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | /** 22 | * Simple adapter listener to be used to track {@link BroadcasterLifeCyclePolicy} events. 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public class BroadcasterLifeCyclePolicyListenerAdapter implements BroadcasterLifeCyclePolicyListener { 27 | 28 | private final Logger logger = LoggerFactory.getLogger(BroadcasterLifeCyclePolicyListenerAdapter.class); 29 | 30 | @Override 31 | public void onEmpty() { 32 | logger.trace("onEmpty"); 33 | } 34 | 35 | @Override 36 | public void onIdle() { 37 | logger.trace("onIdle"); 38 | } 39 | 40 | @Override 41 | public void onDestroy() { 42 | logger.trace("onDestroy"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/BroadcasterLifeCyclePolicyListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Simple listener to be used to track {@link BroadcasterLifeCyclePolicy} events. 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public interface BroadcasterLifeCyclePolicyListener { 24 | 25 | /** 26 | * Invoked when a {@link Broadcaster}'s list of {@link AtmosphereResource} becomes empty, eg. 27 | * the broadcaster has no longer resources associated with it. 28 | */ 29 | void onEmpty(); 30 | 31 | /** 32 | * Invoke when a {@link Broadcaster} has no activity. 33 | */ 34 | void onIdle(); 35 | 36 | /** 37 | * Both {@link org.atmosphere.cpr.Broadcaster#releaseExternalResources()} and {@link org.atmosphere.cpr.Broadcaster#destroy()} 38 | * are about to be invoked. 39 | */ 40 | void onDestroy(); 41 | } 42 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketHandlerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Simple Adapter for {@link WebSocketHandler} 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public class WebSocketHandlerAdapter implements WebSocketHandler { 26 | 27 | @Override 28 | public void onByteMessage(WebSocket webSocket, byte[] data, int offset, int length) { 29 | } 30 | 31 | @Override 32 | public void onTextMessage(WebSocket webSocket, String data) throws IOException { 33 | } 34 | 35 | @Override 36 | public void onOpen(WebSocket webSocket) throws IOException { 37 | } 38 | 39 | @Override 40 | public void onClose(WebSocket webSocket) { 41 | } 42 | 43 | @Override 44 | public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t) { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/PathParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.*; 19 | 20 | /** 21 | * Use this annotation with the {@link org.atmosphere.config.service.ManagedService} annotation. Annotate a field which will get appropriate value when 22 | * the service is instantiated for given path. The syntax of the path is the following 23 | * /whatever/{varX}/.../whatever/.../{varY}/... 24 | * The @PathVariable annotation may be given a name, otherwise verbatim name of field is used 25 | * The number of slashes in the matched and matching paths shall be equal, otherwise the result is undefined. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | @Documented 30 | public @interface PathParam { 31 | /** 32 | * The URI template variable to bind to. 33 | */ 34 | String value() default ""; 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/Processor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.cpr.AtmosphereFramework; 19 | 20 | /** 21 | * Class annotated with {@link org.atmosphere.config.AtmosphereAnnotation} must implement this interface in order to get invoked 22 | * when the {@link org.atmosphere.cpr.AtmosphereFramework#init()} executes. Classes implementing this interface will 23 | * have a chance to process annotated classes and take the appropriate action. 24 | */ 25 | public interface Processor { 26 | 27 | /** 28 | * Invoked by the {@link org.atmosphere.cpr.AnnotationHandler} when an annotation is detected. 29 | * 30 | * @param framework the {@link org.atmosphere.cpr.AtmosphereFramework} 31 | * @param annotatedClass the annotated classes. 32 | */ 33 | void handle(final AtmosphereFramework framework, final Class annotatedClass); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/FrameworkConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config; 17 | 18 | /** 19 | * @author Sebastien Dionne : sebastien.dionne@gmail.com 20 | */ 21 | public class FrameworkConfiguration { 22 | 23 | private String paramName; 24 | private String paramValue; 25 | 26 | public FrameworkConfiguration(String paramName, String paramValue) { 27 | this.paramName = paramName; 28 | this.paramValue = paramValue; 29 | } 30 | 31 | public String getParamName() { 32 | return paramName; 33 | } 34 | 35 | public void setParamName(String paramName) { 36 | this.paramName = paramName; 37 | } 38 | 39 | public String getParamValue() { 40 | return paramValue; 41 | } 42 | 43 | public void setParamValue(String paramValue) { 44 | this.paramValue = paramValue; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/HeartbeatAtmosphereResourceEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package org.atmosphere.cpr; 18 | 19 | import org.atmosphere.cpr.AtmosphereResourceEventImpl; 20 | import org.atmosphere.cpr.AtmosphereResourceImpl; 21 | 22 | /** 23 | *

24 | * Specifies to the observable that {@link org.atmosphere.cpr.AtmosphereResourceEventListener#onHeartbeat(org.atmosphere.cpr.AtmosphereResourceEvent)} 25 | * should be invoked when it fires event to observers. 26 | *

27 | * 28 | * @version 1.0 29 | * @author Guillaume DROUET 30 | * @since 2.2 31 | */ 32 | public class HeartbeatAtmosphereResourceEvent extends AtmosphereResourceEventImpl { 33 | 34 | /** 35 | *

36 | * Builds a new event. 37 | *

38 | * 39 | * @param resource the resource 40 | */ 41 | public HeartbeatAtmosphereResourceEvent(final AtmosphereResourceImpl resource) { 42 | super(resource); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/ApplicationConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config; 17 | 18 | /** 19 | * @author Sebastien Dionne : sebastien.dionne@gmail.com 20 | */ 21 | public class ApplicationConfiguration { 22 | 23 | private String paramName; 24 | private String paramValue; 25 | 26 | public ApplicationConfiguration(String paramName, String paramValue) { 27 | this.paramName = paramName; 28 | this.paramValue = paramValue; 29 | } 30 | 31 | public String getParamName() { 32 | return paramName; 33 | } 34 | 35 | public void setParamName(String paramName) { 36 | this.paramName = paramName; 37 | } 38 | 39 | public String getParamValue() { 40 | return paramValue; 41 | } 42 | 43 | public void setParamValue(String paramValue) { 44 | this.paramValue = paramValue; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/Injectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | 20 | import jakarta.inject.Inject; 21 | import java.lang.reflect.Type; 22 | 23 | /** 24 | * An Injectable class allow the {@link InjectableObjectFactory} to assign a value to a field annotated with the 25 | * {@link Inject} annotation. 26 | * 27 | * @param the Object to inject. 28 | * @author Jeanfrancois Arcand 29 | */ 30 | public interface Injectable { 31 | 32 | /** 33 | * Return true if this class support injection of this type. 34 | * @param t the field 35 | * @return true if this class support injection 36 | */ 37 | boolean supportedType(Type t); 38 | 39 | /** 40 | * Returns an instance of the T 41 | * @param config the {@link AtmosphereConfig} 42 | * @return Return an instance of the T 43 | */ 44 | T injectable(AtmosphereConfig config); 45 | } 46 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/VoidAnnotationProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import org.atmosphere.cpr.AnnotationProcessor; 19 | import org.atmosphere.cpr.AtmosphereConfig; 20 | 21 | import java.io.File; 22 | 23 | /** 24 | * An {@link org.atmosphere.cpr.AnnotationProcessor} that does nothing. 25 | * 26 | * @author Jeanfrancois Arcand 27 | */ 28 | public class VoidAnnotationProcessor implements AnnotationProcessor { 29 | @Override 30 | public AnnotationProcessor scan(File rootDir) { 31 | return this; 32 | } 33 | 34 | @Override 35 | public AnnotationProcessor scan(String packageName) { 36 | return this; 37 | } 38 | 39 | @Override 40 | public AnnotationProcessor scanAll() { 41 | return this; 42 | } 43 | 44 | @Override 45 | public void destroy() { 46 | 47 | } 48 | 49 | @Override 50 | public void configure(AtmosphereConfig config) { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/AtmosphereAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config; 17 | 18 | import java.lang.annotation.Annotation; 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * This annotation is scanned by Atmosphere at runtime to determine {@link org.atmosphere.annotation.Processor} implementation. 27 | * Application that wants to define their own annotation can annotate their class with this annotation. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | @Target({ElementType.TYPE}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface AtmosphereAnnotation { 35 | /** 36 | * Return the handled annotation associated with the {@link org.atmosphere.annotation.Processor} 37 | */ 38 | Class value(); 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/UUIDProviderServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.UUIDProviderService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.util.UUIDProvider; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(UUIDProviderService.class) 26 | public class UUIDProviderServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(UUIDProviderServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.uuidProvider(framework.newClassInstance(UUIDProvider.class, annotatedClass)); 34 | } catch (Throwable e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/resources/atmosphere-web.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 15 | Atmosphere 16 | Atmosphere 17 | 18 | AtmosphereServlet 19 | AtmosphereServlet 20 | org.atmosphere.cpr.AtmosphereServlet 21 | 24 | 0 25 | 26 | 27 | 28 | AtmosphereServlet 29 | ADD-HERE 30 | 31 | 32 | 25 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /modules/cpr/src/test/java/org/atmosphere/util/IOUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import org.testng.annotations.Test; 19 | 20 | import static org.testng.Assert.assertEquals; 21 | 22 | /** 23 | * Created by Romain on 17/03/14. 24 | */ 25 | public class IOUtilsTest { 26 | 27 | @Test 28 | public void testGetCleanedServletPath() { 29 | String testFullPath; 30 | String testCleanedPath; 31 | 32 | testFullPath = "/foo/bar/*"; 33 | testCleanedPath = IOUtils.getCleanedServletPath(testFullPath); 34 | assertEquals(testCleanedPath, "/foo/bar"); 35 | 36 | testFullPath = "foo/bar/**/*"; 37 | testCleanedPath = IOUtils.getCleanedServletPath(testFullPath); 38 | assertEquals(testCleanedPath, "/foo/bar/**"); 39 | 40 | testFullPath = "/com.zyxabc.abc.Abc/gwtCometEvent*"; 41 | testCleanedPath = IOUtils.getCleanedServletPath(testFullPath); 42 | assertEquals(testCleanedPath, "/com.zyxabc.abc.Abc/gwtCometEvent"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcastFilterServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterFilterService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.BroadcastFilter; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(BroadcasterFilterService.class) 26 | public class BroadcastFilterServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(BroadcastFilterServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.broadcasterFilters(framework.newClassInstance(BroadcastFilter.class, annotatedClass)); 34 | } catch (Exception e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/EndpointMapperServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.EndpointMapperService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.util.EndpointMapper; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(EndpointMapperService.class) 26 | public class EndpointMapperServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(EndpointMapperServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.endPointMapper((EndpointMapper) framework.newClassInstance(EndpointMapper.class, annotatedClass)); 34 | } catch (Throwable e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/WebSocketFactoryServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.WebSocketFactoryService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.websocket.WebSocketFactory; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(WebSocketFactoryService.class) 26 | public class WebSocketFactoryServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(WebSocketFactoryServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.webSocketFactory(framework.newClassInstance(WebSocketFactory.class, annotatedClass)); 34 | } catch (Throwable e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketStreamingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.io.Reader; 21 | 22 | /** 23 | * A Streaming Interface for WebSocket. When implemented, the {@link WebSocketProcessor} will invoke this class 24 | * instead of reading bytes in memory. 25 | * 26 | * @author Jeanfrancois Arcand 27 | */ 28 | public interface WebSocketStreamingHandler extends WebSocketHandler { 29 | 30 | /** 31 | * Invoked when a byte message is received. 32 | * 33 | * @param webSocket a {@link WebSocket} 34 | * @param inputStream 35 | */ 36 | void onBinaryStream(WebSocket webSocket, InputStream inputStream) throws IOException; 37 | 38 | /** 39 | * Invoked when a String message is received 40 | * 41 | * @param webSocket a {@link WebSocket} 42 | * @param reader 43 | */ 44 | void onTextStream(WebSocket webSocket, Reader reader) throws IOException; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/AtmosphereInterceptorService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An annotation for telling Atmosphere which {@link org.atmosphere.cpr.AtmosphereInterceptor} class to use by default. 26 | * 27 | * A class annotated with this annotation will be invoked during the {@link org.atmosphere.cpr.AtmosphereConfig#startupHook(org.atmosphere.cpr.AtmosphereConfig.StartupHook)} 28 | * execution. Thus, do not invoke that method from an {@link org.atmosphere.cpr.AtmosphereInterceptor#configure(org.atmosphere.cpr.AtmosphereConfig)} to avoid unpredictable behaviors. 29 | * 30 | * @author Jeanfrancois Arcand 31 | */ 32 | @Target({ElementType.TYPE}) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Documented 35 | public @interface AtmosphereInterceptorService { 36 | } 37 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/handler/AnnotatedProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.handler; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.AtmosphereHandler; 20 | 21 | /** 22 | * Marker class for an {@link org.atmosphere.cpr.AtmosphereHandler} proxy of a POJO object. 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public interface AnnotatedProxy extends AtmosphereHandler { 27 | 28 | /** 29 | * The Object the {@link org.atmosphere.cpr.AtmosphereHandler} is proxying. 30 | * 31 | * @return 32 | */ 33 | Object target(); 34 | 35 | /** 36 | * Return true if {@link org.atmosphere.config.service.PathParam} are supported. 37 | * 38 | * @return true if {@link org.atmosphere.config.service.PathParam} are supported. 39 | */ 40 | boolean pathParams(); 41 | 42 | /** 43 | * Configure the proxy. 44 | * @param config 45 | * @param c 46 | * @return 47 | */ 48 | AnnotatedProxy configure(AtmosphereConfig config, Object c); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AsyncSupportListenerServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AsyncSupportListenerService; 20 | import org.atmosphere.cpr.AsyncSupportListener; 21 | import org.atmosphere.cpr.AtmosphereFramework; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(AsyncSupportListenerService.class) 26 | public class AsyncSupportListenerServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(AsyncSupportListenerServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.asyncSupportListener(framework.newClassInstance(AsyncSupportListener.class, annotatedClass)); 34 | } catch (Throwable e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Message.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import org.atmosphere.config.managed.Decoder; 19 | import org.atmosphere.config.managed.Encoder; 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 | * Annotate a method that will get invoked when String messages are broadcasted using the {@link org.atmosphere.cpr.Broadcaster} 28 | * associated with the class where the annotation is associated. 29 | * 30 | * @author Jeanfrancois Arcand 31 | */ 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Target(ElementType.METHOD) 34 | public @interface Message { 35 | 36 | /** 37 | * A list of {@link org.atmosphere.config.managed.Encoder} 38 | */ 39 | Class>[] encoders() default {}; 40 | 41 | /** 42 | * A list of {@link org.atmosphere.config.managed.Decoder} 43 | */ 44 | Class>[] decoders() default {}; 45 | } 46 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/InjectIntrospectorAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereConfig; 19 | import org.atmosphere.cpr.AtmosphereResource; 20 | 21 | import java.lang.reflect.Field; 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | 25 | /** 26 | * Adapter class for {@link InjectIntrospector} 27 | * 28 | * @param 29 | * @author Jeanfrancois Arcand 30 | */ 31 | public class InjectIntrospectorAdapter implements InjectIntrospector { 32 | 33 | @Override 34 | public boolean supportedType(Type t) { 35 | return false; 36 | } 37 | 38 | @Override 39 | public void introspectField(Class clazz, Field f) { 40 | } 41 | 42 | @Override 43 | public void introspectMethod(Method m, Object instance) { 44 | } 45 | 46 | @Override 47 | public Object injectable(AtmosphereResource resource) { 48 | return null; 49 | } 50 | 51 | @Override 52 | public T injectable(AtmosphereConfig config) { 53 | return null; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/PerRequestBroadcastFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * An extended {@link BroadcastFilter} that can be used to filter based on {@link AtmosphereResource}. 20 | * 21 | * @author Jean-francois Arcand 22 | */ 23 | public interface PerRequestBroadcastFilter extends BroadcastFilter { 24 | 25 | /** 26 | * Transform or filter a message per {@link AtmosphereResource}. Be careful when setting headers on the 27 | * {@link AtmosphereResponse} as the headers may have been already sent back to the browser. 28 | * 29 | * 30 | * @param broadcasterId the {@link org.atmosphere.cpr.Broadcaster#getID()} 31 | * @param r the {@link org.atmosphere.cpr.AtmosphereResource} 32 | * @param originalMessage The original message used when calling {@link org.atmosphere.cpr.Broadcaster#broadcast(Object)} 33 | * @param message a message 34 | * @return a {@link BroadcastAction} 35 | */ 36 | BroadcastAction filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message); 37 | } 38 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AsyncIOInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * A filter-like API that allow an {@link AtmosphereInterceptor} to intercept the response before it gets written back 22 | * to the client. An AsyncIOInterceptor can only be used with an {@link AtmosphereInterceptorWriter}. 23 | *

24 | * An implementation of this class must make sure the data is written inside the intercept method because otherwise it 25 | * will be lost. 26 | * 27 | * @author Jeanfrancois Arcand 28 | */ 29 | public interface AsyncIOInterceptor { 30 | 31 | void prePayload(AtmosphereResponse response, byte[] data, int offset, int length); 32 | 33 | byte[] transformPayload(AtmosphereResponse response, byte[] responseDraft, byte[] data) throws IOException; 34 | 35 | void postPayload(AtmosphereResponse response, byte[] data, int offset, int length); 36 | 37 | byte[] error(AtmosphereResponse response, int statusCode, String reasonPhrase); 38 | 39 | void redirect(AtmosphereResponse response, String location); 40 | } 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AtmosphereFrameworkServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AtmosphereFrameworkListenerService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.AtmosphereFrameworkListener; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(AtmosphereFrameworkListenerService.class) 26 | public class AtmosphereFrameworkServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(AtmosphereFrameworkServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.frameworkListener(framework.newClassInstance(AtmosphereFrameworkListener.class, annotatedClass)); 34 | } catch (Exception e) { 35 | logger.error("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterCacheListenererviceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterCacheListenerService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.BroadcasterCacheListener; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(BroadcasterCacheListenerService.class) 26 | public class BroadcasterCacheListenererviceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(BroadcasterCacheListenererviceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.addBroadcasterCacheListener(framework.newClassInstance(BroadcasterCacheListener.class, annotatedClass)); 34 | } catch (Exception e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterFactoryServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterFactoryService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.BroadcasterFactory; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(BroadcasterFactoryService.class) 26 | public class BroadcasterFactoryServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(BroadcasterFactoryServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.setBroadcasterFactory(framework.newClassInstance(BroadcasterFactory.class, annotatedClass)); 34 | framework.configureBroadcasterFactory(); 35 | } catch (Throwable e) { 36 | logger.warn("", e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AsyncIOInterceptorAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * An Adapter for {@link AsyncIOInterceptor}. 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public class AsyncIOInterceptorAdapter implements AsyncIOInterceptor { 26 | 27 | @Override 28 | public void prePayload(AtmosphereResponse response, byte[] data, int offset, int length) { 29 | } 30 | 31 | @Override 32 | public byte[] transformPayload(AtmosphereResponse response, byte[] responseDraft, byte[] data) throws IOException { 33 | return responseDraft; 34 | } 35 | 36 | @Override 37 | public void postPayload(AtmosphereResponse response, byte[] data, int offset, int length) { 38 | } 39 | 40 | @Override 41 | public byte[] error(AtmosphereResponse response, int statusCode, String reasonPhrase) { 42 | return ("ERROR: " + statusCode + ":" + reasonPhrase).getBytes(); 43 | } 44 | 45 | @Override 46 | public void redirect(AtmosphereResponse response, String location) { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/InjectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import java.lang.reflect.Field; 19 | import java.lang.reflect.Method; 20 | import java.util.LinkedHashSet; 21 | 22 | /** 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public interface InjectionListener { 26 | 27 | void preFieldInjection(Field field, U instance, Class clazz); 28 | 29 | void postFieldInjection(Field field, U instance, Class clazz); 30 | 31 | void preMethodInjection(Method method, U instance, Class clazz); 32 | 33 | void postMethodInjection(Method method, U instance, Class clazz); 34 | 35 | void nullFieldInjectionFor(Field field, U instance, Class clazz); 36 | 37 | void injectionFailed(LinkedHashSet pushBackInjection); 38 | 39 | void fieldInjectionException(Field field, U instance, Class clazz, Exception ex); 40 | 41 | void methodInjectionException(Method method, U instance, Class clazz, Exception ex); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterCacheInspectorServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.cache.BroadcasterCacheInspector; 19 | import org.atmosphere.config.AtmosphereAnnotation; 20 | import org.atmosphere.config.service.BroadcasterCacheInspectorService; 21 | import org.atmosphere.cpr.AtmosphereFramework; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(BroadcasterCacheInspectorService.class) 26 | public class BroadcasterCacheInspectorServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(BroadcasterCacheInspectorServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | framework.addBroadcasterCacheInjector(framework.newClassInstance(BroadcasterCacheInspector.class, annotatedClass)); 34 | } catch (Throwable e) { 35 | logger.warn("", e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/handler/AtmosphereHandlerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.handler; 17 | 18 | import org.atmosphere.cpr.AtmosphereHandler; 19 | import org.atmosphere.cpr.AtmosphereResource; 20 | import org.atmosphere.cpr.AtmosphereResourceEvent; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.io.IOException; 25 | 26 | /** 27 | * An implementation of {@link AtmosphereHandler} that does nothing. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | public class AtmosphereHandlerAdapter implements AtmosphereHandler { 32 | 33 | private static final Logger logger = LoggerFactory.getLogger(AtmosphereHandlerAdapter.class); 34 | 35 | @Override 36 | public void onRequest(AtmosphereResource resource) throws IOException { 37 | logger.trace("onRequest {}", resource.uuid()); 38 | } 39 | 40 | @Override 41 | public void onStateChange(AtmosphereResourceEvent event) throws IOException { 42 | logger.trace("onRequest {}", event.getResource().uuid()); 43 | } 44 | 45 | @Override 46 | public void destroy() { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/PostConstructIntrospector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.inject.annotation.ApplicationScoped; 19 | import org.atmosphere.inject.annotation.RequestScoped; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import jakarta.annotation.PostConstruct; 24 | import java.lang.reflect.Method; 25 | 26 | /** 27 | * PostConstruct implementation support. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | @ApplicationScoped 32 | @RequestScoped 33 | public class PostConstructIntrospector extends InjectIntrospectorAdapter { 34 | private final Logger logger = LoggerFactory.getLogger(PostConstructIntrospector.class); 35 | 36 | @Override 37 | public void introspectMethod(Method m, Object instance) { 38 | if (!m.isAnnotationPresent(PostConstruct.class)) return; 39 | 40 | try { 41 | m.setAccessible(true); 42 | m.invoke(instance); 43 | } catch (Exception e) { 44 | logger.error("", e); 45 | } finally { 46 | m.setAccessible(false); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketPingPongListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | /** 19 | * WebSocket Ping/Pong Listener. Use this interface with {@link org.atmosphere.websocket.WebSocketProcessor} 20 | * or {@link org.atmosphere.websocket.WebSocketHandler} or {@link org.atmosphere.websocket.WebSocketStreamingHandler} 21 | * 22 | * @author Jeanfrancois Arcand 23 | */ 24 | public interface WebSocketPingPongListener { 25 | /** 26 | * Handle WebSocket PONG 27 | * 28 | * @param webSocket {@link org.atmosphere.websocket.WebSocket} 29 | * @param payload the received bytes 30 | * @param offset the offset 31 | * @param length the length 32 | */ 33 | void onPong(WebSocket webSocket, byte[] payload, int offset, int length); 34 | 35 | /** 36 | * Handle WebSocket PING 37 | * 38 | * @param webSocket {@link org.atmosphere.websocket.WebSocket} 39 | * @param payload the received bytes 40 | * @param offset the offset 41 | * @param length the length 42 | */ 43 | void onPing(WebSocket webSocket, byte[] payload, int offset, int length); 44 | } 45 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AsyncSupportServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AsyncSupportService; 20 | import org.atmosphere.cpr.AsyncSupport; 21 | import org.atmosphere.cpr.AtmosphereFramework; 22 | import org.atmosphere.cpr.AtmosphereResource; 23 | import org.atmosphere.cpr.DefaultAsyncSupportResolver; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | @AtmosphereAnnotation(AsyncSupportService.class) 28 | public class AsyncSupportServiceProcessor implements Processor> { 29 | 30 | private static final Logger logger = LoggerFactory.getLogger(AsyncSupportServiceProcessor.class); 31 | 32 | @Override 33 | public void handle(AtmosphereFramework framework, Class> annotatedClass) { 34 | try { 35 | framework.setAsyncSupport(new DefaultAsyncSupportResolver(framework.getAtmosphereConfig()).newCometSupport(annotatedClass.getName())); 36 | } catch (Throwable e) { 37 | logger.warn("", e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AtmosphereInterceptorServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AtmosphereInterceptorService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.AtmosphereInterceptor; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(AtmosphereInterceptorService.class) 26 | public class AtmosphereInterceptorServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(AtmosphereInterceptorServiceProcessor.class); 29 | 30 | @Override 31 | public void handle(final AtmosphereFramework framework, Class annotatedClass) { 32 | try { 33 | final AtmosphereInterceptor a = framework.newClassInstance(AtmosphereInterceptor.class, annotatedClass); 34 | framework.getAtmosphereConfig().startupHook(framework1 -> framework1.interceptor(a)); 35 | } catch (Throwable e) { 36 | logger.warn("", e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/service/Ready.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.service; 17 | 18 | import org.atmosphere.config.managed.Encoder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Use this annotation with the {@link ManagedService} annotation. A method annotated with this annotation will be 27 | * invoked when the connection has been suspended and ready. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target(ElementType.METHOD) 33 | public @interface Ready { 34 | 35 | /** 36 | * Use {@link DeliverTo.DELIVER_TO} instead. 37 | * 38 | * @deprecated 39 | */ 40 | enum DELIVER_TO { RESOURCE, BROADCASTER, ALL} 41 | 42 | /** 43 | * Use {@link DeliverTo} annotation instead. 44 | * 45 | * @deprecated 46 | */ 47 | DELIVER_TO value() default DELIVER_TO.RESOURCE; 48 | 49 | /** 50 | * A list of {@link org.atmosphere.config.managed.Encoder} 51 | */ 52 | Class>[] encoders() default {}; 53 | } 54 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/EndpointMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import org.atmosphere.cpr.AtmosphereRequest; 19 | import org.atmosphere.inject.AtmosphereConfigAware; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * This class is responsible for mapping request to handler like {@link org.atmosphere.cpr.AtmosphereHandler} 25 | * or {@link org.atmosphere.websocket.WebSocketHandler} 26 | * 27 | * @param 28 | * @author Jeanfrancois Arcand 29 | */ 30 | public interface EndpointMapper extends AtmosphereConfigAware { 31 | 32 | /** 33 | * Mape the request to its associated endpoint. 34 | * 35 | * @param req an {@link AtmosphereRequest} 36 | * @param handlers a map used for mapping the request to. 37 | * @return U the result, or null if not mapped 38 | */ 39 | U map(AtmosphereRequest req, Map handlers); 40 | 41 | 42 | /** 43 | * Mape the request to its associated endpoint. 44 | * 45 | * @param path a URI 46 | * @param handlers a map used for mapping the request to. 47 | * @return U the result, or null if not mapped 48 | */ 49 | U map(String path, Map handlers); 50 | } 51 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereFrameworkListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Lifecycle listener for {@link org.atmosphere.cpr.AtmosphereFramework} 20 | * 21 | * @author Jeanfrancois Arcand 22 | */ 23 | public interface AtmosphereFrameworkListener { 24 | /** 25 | * Invoked before {@link AtmosphereFramework#init()} gets invoked 26 | * 27 | * @param f an {@link org.atmosphere.cpr.AtmosphereFramework} 28 | */ 29 | void onPreInit(AtmosphereFramework f); 30 | 31 | /** 32 | * Invoked after {@link AtmosphereFramework#init()} gets invoked 33 | * 34 | * @param f an {@link org.atmosphere.cpr.AtmosphereFramework} 35 | */ 36 | void onPostInit(AtmosphereFramework f); 37 | 38 | /** 39 | * Invoked before {@link AtmosphereFramework#destroy()} gets invoked 40 | * 41 | * @param f an {@link org.atmosphere.cpr.AtmosphereFramework} 42 | */ 43 | void onPreDestroy(AtmosphereFramework f); 44 | 45 | /** 46 | * Invoked after {@link AtmosphereFramework#destroy()} gets invoked 47 | * 48 | * @param f an {@link org.atmosphere.cpr.AtmosphereFramework} 49 | */ 50 | void onPostDestroy(AtmosphereFramework f); 51 | } 52 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/ServletContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import jakarta.servlet.ServletContext; 19 | 20 | /** 21 | * A simple Factory to get access to the {@linl ServletContext}. This factory won't work if more than one Servlet is deployed inside the same war. 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public class ServletContextFactory { 26 | 27 | private ServletContext servletContext; 28 | private static ServletContextFactory servletContextFactory; 29 | 30 | private ServletContextFactory() { 31 | } 32 | 33 | /** 34 | * Set the ServletContext 35 | * 36 | * @param servletContext ServletContext 37 | */ 38 | public void init(ServletContext servletContext) { 39 | this.servletContext = servletContext; 40 | } 41 | 42 | public ServletContext getServletContext() { 43 | if (servletContext != null) { 44 | return servletContext; 45 | } 46 | return null; 47 | } 48 | 49 | public static ServletContextFactory getDefault() { 50 | if (servletContextFactory == null) servletContextFactory = new ServletContextFactory(); 51 | return servletContextFactory; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AtmosphereResourceFactoryServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AtmosphereResourceFactoryService; 20 | import org.atmosphere.config.service.BroadcasterFactoryService; 21 | import org.atmosphere.cpr.AtmosphereFramework; 22 | import org.atmosphere.cpr.AtmosphereResourceFactory; 23 | import org.atmosphere.cpr.BroadcasterFactory; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | @AtmosphereAnnotation(AtmosphereResourceFactoryService.class) 28 | public class AtmosphereResourceFactoryServiceProcessor implements Processor { 29 | 30 | private static final Logger logger = LoggerFactory.getLogger(AtmosphereResourceFactoryServiceProcessor.class); 31 | 32 | @Override 33 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 34 | try { 35 | framework.setAndConfigureAtmosphereResourceFactory(framework.newClassInstance(AtmosphereResourceFactory.class, annotatedClass)); 36 | } catch (Throwable e) { 37 | logger.warn("", e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/AtmosphereResourceListenerServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.AsyncSupportListenerService; 20 | import org.atmosphere.config.service.AtmosphereResourceListenerService; 21 | import org.atmosphere.cpr.AsyncSupportListener; 22 | import org.atmosphere.cpr.AtmosphereFramework; 23 | import org.atmosphere.cpr.AtmosphereResourceListener; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | @AtmosphereAnnotation(AtmosphereResourceListenerService.class) 28 | public class AtmosphereResourceListenerServiceProcessor implements Processor { 29 | 30 | private static final Logger logger = LoggerFactory.getLogger(AtmosphereResourceListenerServiceProcessor.class); 31 | 32 | @Override 33 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 34 | try { 35 | framework.atmosphereResourceListener(framework.newClassInstance(AtmosphereResourceListener.class, annotatedClass)); 36 | } catch (Throwable e) { 37 | logger.warn("", e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/WebSocketProcessorServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.WebSocketProcessorService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.websocket.WebSocketProcessor; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | @AtmosphereAnnotation(WebSocketProcessorService.class) 26 | public class WebSocketProcessorServiceProcessor implements Processor { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(WebSocketProcessorServiceProcessor.class); 29 | 30 | private boolean hasBeenSet; 31 | 32 | @Override 33 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 34 | try { 35 | if (!hasBeenSet) { 36 | hasBeenSet = true; 37 | framework.setWebsocketProcessorClassName(annotatedClass.getName()); 38 | } else { 39 | logger.warn("WebSocketProcessor already configured"); 40 | } 41 | } catch (Throwable e) { 42 | logger.warn("", e); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/NginxInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | import org.atmosphere.cpr.Action; 19 | import org.atmosphere.cpr.AtmosphereInterceptorAdapter; 20 | import org.atmosphere.cpr.AtmosphereResource; 21 | import org.atmosphere.cpr.AtmosphereResponse; 22 | import org.atmosphere.util.Utils; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * Add proper header for Nginx's buffering http://wiki.nginx.org/HttpProxyModule#proxy_buffering 28 | *
29 | * This interceptor set the 'X-Accel-Buffering : No' on the {@link AtmosphereResponse} before it gets suspended. 30 | * 31 | * @author Jeanfrancois Arcand 32 | */ 33 | public class NginxInterceptor extends AtmosphereInterceptorAdapter { 34 | 35 | private final static Logger logger = LoggerFactory.getLogger(NginxInterceptor.class); 36 | 37 | @Override 38 | public Action inspect(AtmosphereResource r) { 39 | 40 | if (Utils.webSocketMessage(r)) return Action.CONTINUE; 41 | 42 | try { 43 | r.getResponse().addHeader("X-Accel-Buffering", "No"); 44 | } catch (Throwable t) { 45 | logger.trace("", t); 46 | } 47 | return Action.CONTINUE; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /modules/cpr/src/test/java/org/atmosphere/util/CookieUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | import jakarta.servlet.http.Cookie; 22 | 23 | import org.testng.annotations.Test; 24 | 25 | import static org.testng.Assert.assertEquals; 26 | 27 | public class CookieUtilTest { 28 | private static final String[] COOKIES1 = {"theme=light; sessionToken=abc123", "name=atmosphere"}; 29 | 30 | @Test 31 | public void testDecodeServerCookies() throws Exception { 32 | Set cookies = new HashSet(); 33 | for (String cookieHeader : COOKIES1) { 34 | CookieUtil.ServerCookieDecoder.STRICT.decode(cookieHeader, cookies); 35 | } 36 | 37 | assertEquals(cookies.size(), 3); 38 | for (Cookie cookie : cookies) { 39 | if ("theme".equals(cookie.getName())) { 40 | assertEquals(cookie.getValue(), "light"); 41 | } else if ("sessionToken".equals(cookie.getName())) { 42 | assertEquals(cookie.getValue(), "abc123"); 43 | } else if ("name".equals(cookie.getName())) { 44 | assertEquals(cookie.getValue(), "atmosphere"); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /assembly/cpr/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.atmosphere 5 | atmosphere-project 6 | 3.0.14 7 | ../../pom.xml 8 | 9 | 4.0.0 10 | org.atmosphere 11 | atmosphere-runtime-libs 12 | atmosphere-runtime-libs 13 | Atmosphere runtime libraries distribution 14 | 3.0.14 15 | pom 16 | 17 | 18 | 19 | org.atmosphere 20 | atmosphere-runtime 21 | 3.0.14 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | distro-assembly 31 | package 32 | 33 | single 34 | 35 | 36 | 37 | maven-assembly-plugin 38 | 2.3 39 | 40 | 41 | src/main/assembly/distribution.xml 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereInterceptorAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.atmosphere.interceptor.InvokationOrder; 19 | 20 | /** 21 | * A Simple {@link AtmosphereInterceptor} that creates an {@link AtmosphereInterceptorWriter} and sets it as 22 | * the default {@link AsyncIOWriter} on an {@link AtmosphereResponse}. 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public abstract class AtmosphereInterceptorAdapter implements AtmosphereInterceptor, InvokationOrder { 27 | 28 | @Override 29 | public void configure(AtmosphereConfig config) { 30 | } 31 | 32 | @Override 33 | public Action inspect(AtmosphereResource r) { 34 | AtmosphereResponse res = r.getResponse(); 35 | if (res.getAsyncIOWriter() == null) { 36 | res.asyncIOWriter(new AtmosphereInterceptorWriter()); 37 | } 38 | return Action.CONTINUE; 39 | } 40 | 41 | @Override 42 | public void postInspect(AtmosphereResource r) { 43 | } 44 | 45 | @Override 46 | public void destroy() { 47 | } 48 | 49 | @Override 50 | public PRIORITY priority() { 51 | return InvokationOrder.AFTER_DEFAULT; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return getClass().getName(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/InjectIntrospector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereResource; 19 | 20 | import java.lang.reflect.Field; 21 | import java.lang.reflect.Method; 22 | 23 | /** 24 | * An Injectable class allow the {@link InjectableObjectFactory} to inspect fields and methods before they get injected or executed. 25 | * This interface supports application scoped {@link @ApplicationScoped} and request scoped {@link @RequestScoped} injection. 26 | * 27 | * @param the Object to inject. 28 | * @author Jeanfrancois Arcand 29 | */ 30 | public interface InjectIntrospector extends Injectable { 31 | 32 | enum WHEN { DEPLOY, RUNTIME } 33 | 34 | /** 35 | * Introspect the field 36 | * 37 | * @param f the field 38 | * @param clazz 39 | */ 40 | void introspectField(Class clazz, Field f); 41 | 42 | /** 43 | * Introspect the method 44 | * 45 | * @param m the method 46 | * @param instance the object to invoke the method on 47 | */ 48 | void introspectMethod(Method m, Object instance); 49 | 50 | /** 51 | * Returns an instance of the T 52 | * @param resource the {@link AtmosphereResource} 53 | * @return Return an instance of the T 54 | */ 55 | T injectable(AtmosphereResource resource); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereObjectFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.atmosphere.inject.AtmosphereConfigAware; 19 | 20 | /** 21 | * Customization point for Atmosphere to instantiate classes. 22 | * Useful when using a DI framework. 23 | * 24 | * @author Norman Franke 25 | * @author Jeanfrancois Arcand 26 | */ 27 | public interface AtmosphereObjectFactory extends AtmosphereConfigAware { 28 | 29 | /** 30 | * Delegate the creation of Object to the underlying object provider like Spring, Guice, etc. 31 | * 32 | * When creating a class, it is important to check if the class can be configured via its implementation 33 | * of the {@link org.atmosphere.inject.AtmosphereConfigAware}. {@link org.atmosphere.inject.AtmosphereConfigAware#configure(AtmosphereConfig)} 34 | * should be called in that case. 35 | * 36 | * @param classType The class' type to be created 37 | * @param defaultType a class to be created @return an instance of T 38 | */ 39 | T newClassInstance(Class classType, Class defaultType) throws InstantiationException, IllegalAccessException; 40 | 41 | /** 42 | * Pass information to the underlying Dependency Injection Implementation 43 | * @param z an Z 44 | * @return this 45 | */ 46 | AtmosphereObjectFactory allowInjectionOf(Z z); 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/ByteArrayAsyncWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import org.atmosphere.cpr.AsyncIOWriter; 19 | import org.atmosphere.cpr.AsyncIOWriterAdapter; 20 | import org.atmosphere.cpr.AtmosphereResponse; 21 | 22 | import java.io.ByteArrayOutputStream; 23 | import java.io.IOException; 24 | 25 | /** 26 | * An {@link AsyncIOWriter} backed by an {@link ByteArrayOutputStream} 27 | * 28 | * @author Jeanfrancois Arcand 29 | */ 30 | public class ByteArrayAsyncWriter extends AsyncIOWriterAdapter { 31 | 32 | ByteArrayOutputStream o = new ByteArrayOutputStream(); 33 | 34 | @Override 35 | public AsyncIOWriter write(AtmosphereResponse r, String data) throws IOException { 36 | o.write(data.getBytes(r.getCharacterEncoding())); 37 | return this; 38 | } 39 | 40 | @Override 41 | public AsyncIOWriter write(AtmosphereResponse r, byte[] data) throws IOException { 42 | o.write(data); 43 | return this; 44 | } 45 | 46 | @Override 47 | public AsyncIOWriter write(AtmosphereResponse r, byte[] data, int offset, int length) throws IOException { 48 | o.write(data, offset, length); 49 | return this; 50 | } 51 | 52 | public ByteArrayOutputStream stream() { 53 | return o; 54 | } 55 | 56 | @Override 57 | public void close(AtmosphereResponse r) { 58 | o.reset(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AsyncIOWriterAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Adapter class for {@link AsyncIOWriter}. 22 | * 23 | * @author Jeanfrancois Arcand 24 | */ 25 | public class AsyncIOWriterAdapter implements AsyncIOWriter { 26 | 27 | public AsyncIOWriterAdapter() { 28 | } 29 | 30 | @Override 31 | public AsyncIOWriter redirect(AtmosphereResponse r, String location) throws IOException { 32 | return this; 33 | } 34 | 35 | @Override 36 | public AsyncIOWriter writeError(AtmosphereResponse r, int errorCode, String message) throws IOException { 37 | return this; 38 | } 39 | 40 | @Override 41 | public AsyncIOWriter write(AtmosphereResponse r, String data) throws IOException { 42 | return this; 43 | } 44 | 45 | @Override 46 | public AsyncIOWriter write(AtmosphereResponse r, byte[] data) throws IOException { 47 | return this; 48 | } 49 | 50 | @Override 51 | public AsyncIOWriter write(AtmosphereResponse r, byte[] data, int offset, int length) throws IOException { 52 | return this; 53 | } 54 | 55 | @Override 56 | public void close(AtmosphereResponse r) throws IOException { 57 | } 58 | 59 | @Override 60 | public AsyncIOWriter flush(AtmosphereResponse r) throws IOException { 61 | return this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AnnotationProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.atmosphere.inject.AtmosphereConfigAware; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | 23 | /** 24 | * An annotation processor for configuring the {@link AtmosphereFramework}. 25 | * 26 | * @author Jeanfrancois Arcand 27 | */ 28 | public interface AnnotationProcessor extends AtmosphereConfigAware{ 29 | 30 | /** 31 | * Scan the {@link File} looking for classes annotated with Atmosphere's Service annotation. 32 | * 33 | * @param rootDir a directory where annotation can possibly be defined 34 | * @return this 35 | */ 36 | AnnotationProcessor scan(File rootDir) throws IOException; 37 | 38 | /** 39 | * Scan the package looking for classes annotated with Atmosphere's Service annotation. 40 | * 41 | * @param packageName package name 42 | * @return this 43 | */ 44 | AnnotationProcessor scan(String packageName) throws IOException; 45 | 46 | /** 47 | * Scan all classes on the classpath looking for classes annotated with Atmosphere's Service annotation. 48 | * 49 | * @return this 50 | */ 51 | AnnotationProcessor scanAll() throws IOException; 52 | 53 | /** 54 | * Destroy all resources associated with this object. Once destroyed, this object can no longer be used. 55 | */ 56 | void destroy(); 57 | } 58 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/annotation/BroadcasterListenerServiceProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.annotation; 17 | 18 | import org.atmosphere.config.AtmosphereAnnotation; 19 | import org.atmosphere.config.service.BroadcasterListenerService; 20 | import org.atmosphere.cpr.AtmosphereFramework; 21 | import org.atmosphere.cpr.Broadcaster; 22 | import org.atmosphere.cpr.BroadcasterListener; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | import java.util.Collection; 27 | 28 | @AtmosphereAnnotation(BroadcasterListenerService.class) 29 | public class BroadcasterListenerServiceProcessor implements Processor { 30 | 31 | private static final Logger logger = LoggerFactory.getLogger(BroadcasterListenerServiceProcessor.class); 32 | 33 | @Override 34 | public void handle(AtmosphereFramework framework, Class annotatedClass) { 35 | try { 36 | BroadcasterListener l = framework.newClassInstance(BroadcasterListener.class, annotatedClass); 37 | framework.addBroadcasterListener(l); 38 | // We must reconfigure all existing Broadcaster 39 | Collection c = framework.getBroadcasterFactory().lookupAll(); 40 | for (Broadcaster b : c) { 41 | l.onPostCreate(b); 42 | } 43 | } catch (Throwable e) { 44 | logger.warn("", e); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cache/CacheMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cache; 17 | 18 | import java.io.Serializable; 19 | 20 | public class CacheMessage implements Serializable { 21 | private static final long serialVersionUID = -126253550299206646L; 22 | 23 | private final Object message; 24 | 25 | private final String id; 26 | private final long createTime; 27 | private final String uuid; 28 | 29 | public CacheMessage(String id, Object message, String uuid) { 30 | this.id = id; 31 | this.message = message; 32 | this.createTime = System.nanoTime(); 33 | this.uuid = uuid; 34 | } 35 | 36 | public CacheMessage(String id, Long now, Object message, String uuid) { 37 | this.id = id; 38 | this.message = message; 39 | this.createTime = now; 40 | this.uuid = uuid; 41 | } 42 | 43 | public Object getMessage() { 44 | return message; 45 | } 46 | 47 | public String getId() { 48 | return id; 49 | } 50 | 51 | public String toString() { 52 | return message.toString(); 53 | } 54 | 55 | public long getCreateTime() { 56 | return createTime; 57 | } 58 | 59 | /** 60 | * Return the {@link org.atmosphere.cpr.AtmosphereResource#uuid()} 61 | * @return {@link org.atmosphere.cpr.AtmosphereResource#uuid()} 62 | */ 63 | public String uuid(){ 64 | return uuid; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/config/managed/Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.config.managed; 17 | 18 | /** 19 | * Decode a message in order to invoke a class annotated with {@link org.atmosphere.config.service.ManagedService} with a method 20 | * annotated with {@link org.atmosphere.config.service.Message}. For example: 21 | *
22 | 
23 |      public final class StringBufferDecoder implements Decoder {
24 | 
25 |          @Override
26 |          public StringBuffer decode(String s) {
27 |              return  new StringBuffer(s);
28 |          }
29 |      }
30 |  * 
31 | * will decode a String into a StringBuffer. The decoded object will then be used to invoke a method annotated with @Message 32 | *
33 | 
34 |      @Message(decoders = {StringBufferDecoder.class})
35 |      public void message(StringBuffer m) {
36 |          message.set(m.toString());
37 |      }
38 |  * 
39 | * You can chain Decoders. They will be invoked in the order they are defined and the last decoded value will be used to invoke the 40 | * @Message annotated method. 41 | * @param 42 | * @param 43 | * @author Jeanfrancois Arcand 44 | */ 45 | public interface Decoder { 46 | /** 47 | * Decode the specified object of type U into object of type T 48 | * 49 | * @param s a object of type U 50 | * @return a new object of type T 51 | */ 52 | T decode(U s); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereResourceIntrospector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereResource; 19 | import org.atmosphere.inject.annotation.RequestScoped; 20 | import org.atmosphere.util.ThreadLocalInvoker; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Proxy; 24 | import java.lang.reflect.Type; 25 | 26 | /** 27 | * {@link }AtmosphereResource} injection implementation support. 28 | * 29 | * @author Jeanfrancois Arcand 30 | */ 31 | @RequestScoped 32 | public class AtmosphereResourceIntrospector extends InjectIntrospectorAdapter { 33 | 34 | @Override 35 | public boolean supportedType(Type t) { 36 | return (t instanceof Class) && AtmosphereResource.class.isAssignableFrom((Class) t); 37 | } 38 | 39 | @Override 40 | public AtmosphereResource injectable(final AtmosphereResource r) { 41 | return (AtmosphereResource) Proxy.newProxyInstance(this.getClass().getClassLoader(), 42 | new Class[]{AtmosphereResource.class}, new ThreadLocalInvoker() { 43 | { 44 | set(r); 45 | } 46 | 47 | @Override 48 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 49 | return method.invoke(r, args); 50 | } 51 | }); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.websocket; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * A very simple interface adapter class that implements all methods and expose a WebSocket API 22 | * close to the JavaScript Counterpart. 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public interface WebSocketHandler { 27 | 28 | /** 29 | * Invoked when a byte message is received. 30 | * 31 | * @param webSocket a {@link WebSocket} 32 | * @param data 33 | * @param offset 34 | * @param length 35 | */ 36 | void onByteMessage(WebSocket webSocket, byte[] data, int offset, int length) throws IOException; 37 | 38 | /** 39 | * Invoked when a String message is received 40 | * 41 | * @param webSocket a {@link WebSocket} 42 | * @param data 43 | */ 44 | void onTextMessage(WebSocket webSocket, String data) throws IOException; 45 | 46 | /** 47 | * Invoked when a {@link WebSocket} is opened. 48 | * 49 | * @param webSocket 50 | */ 51 | void onOpen(WebSocket webSocket) throws IOException; 52 | 53 | /** 54 | * Invoked when a {@link WebSocket} is closed. 55 | * 56 | * @param webSocket 57 | */ 58 | void onClose(WebSocket webSocket); 59 | 60 | /** 61 | * Invoked when a {@link WebSocket} produces an error. 62 | * 63 | * @param webSocket 64 | */ 65 | void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t); 66 | } 67 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/SessionCreationInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | import org.atmosphere.cpr.Action; 19 | import org.atmosphere.cpr.AtmosphereInterceptorAdapter; 20 | import org.atmosphere.cpr.AtmosphereResource; 21 | import org.atmosphere.util.Utils; 22 | 23 | import java.util.concurrent.ConcurrentLinkedQueue; 24 | 25 | /** 26 | * An interceptor that create an {@link jakarta.servlet.http.HttpSession} on the fist received request so transport like long-polling 27 | * can share the session with request coming after the suspend operation. Without this and because 28 | * with long-polling cookies aren't read by the browser until the response is resumed, the session id will not 29 | * be the same so session couldn't be used. 30 | * 31 | * @author Jeanfrancois Arcand 32 | */ 33 | public class SessionCreationInterceptor extends AtmosphereInterceptorAdapter { 34 | 35 | // This can cause memory leak. 36 | private final ConcurrentLinkedQueue ids = new ConcurrentLinkedQueue<>(); 37 | 38 | @Override 39 | public Action inspect(AtmosphereResource r) { 40 | 41 | if (Utils.webSocketMessage(r)) return Action.CONTINUE; 42 | 43 | if (r.session(false) == null 44 | && !ids.remove(r.uuid()) 45 | && r.getRequest().getMethod().equalsIgnoreCase("GET")) { 46 | r.session(true); 47 | ids.offer(r.uuid()); 48 | return Action.CANCELLED; 49 | } 50 | return Action.CONTINUE; 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/pool/BoundedApachePoolableProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.pool; 17 | 18 | import org.atmosphere.cpr.ApplicationConfig; 19 | import org.atmosphere.cpr.Broadcaster; 20 | import org.atmosphere.cpr.DefaultBroadcaster; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.util.concurrent.TimeUnit; 25 | 26 | import static org.atmosphere.cpr.ApplicationConfig.BROADCASTER_FACTORY_POOL_SIZE; 27 | 28 | /** 29 | * An Bounder Broadcaster Pool Provider of {@link org.atmosphere.cpr.Broadcaster}. The default size is 200. 30 | * 31 | * @author Jean-Francois Arcand 32 | */ 33 | public class BoundedApachePoolableProvider extends UnboundedApachePoolableProvider { 34 | private final Logger logger = LoggerFactory.getLogger(BoundedApachePoolableProvider.class); 35 | private long waitFor = 10000; 36 | 37 | @Override 38 | protected void configureGenericObjectPoolConfig() { 39 | poolConfig.setMaxTotal(config.getInitParameter(BROADCASTER_FACTORY_POOL_SIZE, 200)); 40 | waitFor = TimeUnit.SECONDS.toMillis(config.getInitParameter(ApplicationConfig.BROADCASTER_FACTORY_EMPTY_WAIT_TIME_IN_SECONDS, 10000)); 41 | } 42 | 43 | @Override 44 | public Broadcaster borrowBroadcaster(Object id) { 45 | try { 46 | return ((DefaultBroadcaster) genericObjectPool.borrowObject(waitFor)).rename(id.toString()); 47 | } catch (Exception e) { 48 | logger.error("", e); 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AsyncSupportListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | /** 22 | * A default implementation of {@link AsyncSupportListener} 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public class AsyncSupportListenerAdapter implements AsyncSupportListener { 27 | 28 | private final Logger logger = LoggerFactory.getLogger(AsyncSupportListenerAdapter.class); 29 | 30 | @Override 31 | public void onSuspend(AtmosphereRequest request, AtmosphereResponse response) { 32 | logger.trace("Suspended resource {} for request {}", request.resource(), request); 33 | } 34 | 35 | @Override 36 | public void onResume(AtmosphereRequest request, AtmosphereResponse response) { 37 | logger.trace("Resume resource {} for request {}", request.resource(), request); 38 | } 39 | 40 | @Override 41 | public void onTimeout(AtmosphereRequest request, AtmosphereResponse response) { 42 | logger.trace("Timeout resource {} for request {}", request.resource(), request); 43 | } 44 | 45 | @Override 46 | public void onClose(AtmosphereRequest request, AtmosphereResponse response) { 47 | logger.trace("Closing resource {} for request {}", request.resource(), request); 48 | } 49 | 50 | @Override 51 | public void onDestroyed(AtmosphereRequest request, AtmosphereResponse response) { 52 | logger.trace("Destroyed resource {} for request {}", request.resource(), request); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/DefaultAtmosphereResourceSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | import java.util.Collection; 19 | import java.util.Collections; 20 | import java.util.concurrent.ConcurrentHashMap; 21 | import java.util.concurrent.ConcurrentMap; 22 | 23 | /** 24 | * @author uklance (https://github.com/uklance) 25 | */ 26 | public class DefaultAtmosphereResourceSession implements AtmosphereResourceSession { 27 | private final ConcurrentMap attributes = new ConcurrentHashMap(); 28 | private volatile boolean valid = true; 29 | 30 | @Override 31 | public Object setAttribute(String name, Object value) { 32 | checkValid(); 33 | return attributes.put(name, value); 34 | } 35 | 36 | @Override 37 | public Object getAttribute(String name) { 38 | checkValid(); 39 | return attributes.get(name); 40 | } 41 | 42 | @Override 43 | public T getAttribute(String name, Class type) { 44 | return type.cast(getAttribute(name)); 45 | } 46 | 47 | @Override 48 | public Collection getAttributeNames() { 49 | checkValid(); 50 | return Collections.unmodifiableSet(attributes.keySet()); 51 | } 52 | 53 | @Override 54 | public void invalidate() { 55 | checkValid(); 56 | valid = false; 57 | attributes.clear(); 58 | } 59 | 60 | protected void checkValid() { 61 | if (!valid) { 62 | throw new IllegalStateException("Session is invalid"); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/interceptor/InvokationOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.interceptor; 17 | 18 | /** 19 | * A simple marker class to use with {@link org.atmosphere.cpr.AtmosphereInterceptor} in order to determine in which 20 | * position in the interceptor's chain the AtmosphereInterceptor must be installed. 21 | *

22 | * Normally all {@link org.atmosphere.cpr.AtmosphereInterceptor} are installed using the {@link InvokationOrder.PRIORITY#AFTER_DEFAULT} 23 | * 24 | * @author Jeanfrancois Arcand 25 | */ 26 | public interface InvokationOrder { 27 | 28 | enum PRIORITY { 29 | /** 30 | * The AtmosphereInterceptor must be executed after the default set of AtmosphereInterceptor 31 | */ 32 | AFTER_DEFAULT, 33 | /** 34 | * The AtmosphereInterceptor must be executed before the default set of AtmosphereInterceptor. You can only 35 | * add one instance per {@link org.atmosphere.cpr.AtmosphereInterceptor} 36 | */ 37 | BEFORE_DEFAULT, 38 | /** 39 | * The AtmosphereInterceptor must be executed at first, before any AtmosphereInterceptor. 40 | */ 41 | FIRST_BEFORE_DEFAULT 42 | } 43 | 44 | PRIORITY AFTER_DEFAULT = PRIORITY.AFTER_DEFAULT; 45 | PRIORITY BEFORE_DEFAULT = PRIORITY.BEFORE_DEFAULT; 46 | PRIORITY FIRST_BEFORE_DEFAULT = PRIORITY.FIRST_BEFORE_DEFAULT; 47 | 48 | /** 49 | * Return the priority an AtmosphereInterceptor must be executed. 50 | * 51 | * @return PRIORITY 52 | */ 53 | PRIORITY priority(); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/util/VoidServletConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.util; 17 | 18 | import jakarta.servlet.ServletConfig; 19 | import jakarta.servlet.ServletContext; 20 | import java.lang.reflect.InvocationHandler; 21 | import java.lang.reflect.Method; 22 | import java.lang.reflect.Proxy; 23 | import java.util.Collections; 24 | import java.util.Enumeration; 25 | import java.util.Map; 26 | 27 | public class VoidServletConfig implements ServletConfig { 28 | public final static String ATMOSPHERE_SERVLET = "AtmosphereServlet"; 29 | 30 | private final Map initParams; 31 | 32 | public VoidServletConfig() { 33 | initParams = Collections.emptyMap(); 34 | } 35 | 36 | public VoidServletConfig(Map initParams) { 37 | this.initParams = initParams; 38 | } 39 | 40 | @Override 41 | public String getServletName() { 42 | return ATMOSPHERE_SERVLET; 43 | } 44 | 45 | @Override 46 | public ServletContext getServletContext() { 47 | return (ServletContext) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{ServletContext.class}, 48 | (proxy, method, args) -> ServletProxyFactory.getDefault().proxy(proxy, method, args) 49 | ); 50 | } 51 | 52 | @Override 53 | public String getInitParameter(String name) { 54 | return initParams.get(name); 55 | } 56 | 57 | @Override 58 | public Enumeration getInitParameterNames() { 59 | return Collections.enumeration(initParams.values()); 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResourceSessionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.cpr; 17 | 18 | /** 19 | * Factory for {@link AtmosphereResourceSession} instances 20 | * 21 | * @author uklance (https://github.com/uklance) 22 | */ 23 | public interface AtmosphereResourceSessionFactory { 24 | 25 | /** 26 | * Returns the current session associated with the 27 | * {@link AtmosphereResource} or, if there is no current session and create 28 | * is true, returns a new session. 29 | *

30 | * If create is false and the request has no valid HttpSession, this method 31 | * returns null. 32 | * 33 | * @param resource An {@link AtmosphereResource} 34 | * @param create true to create a new session if necessary; false to return 35 | * null if there's no current session 36 | * @return the session associated with this request or null if create is 37 | * false and the resource has no valid session 38 | */ 39 | AtmosphereResourceSession getSession(AtmosphereResource resource, boolean create); 40 | 41 | /** 42 | * Returns the current session associated with the 43 | * {@link AtmosphereResource}, or creates one if it does not yet exist. 44 | * 45 | * @param resource An {@link AtmosphereResource} 46 | * @return the current session associated with the 47 | * {@link AtmosphereResource}, or creates one if it does not yet 48 | * exist. 49 | */ 50 | AtmosphereResourceSession getSession(AtmosphereResource resource); 51 | 52 | void destroy(); 53 | } 54 | -------------------------------------------------------------------------------- /modules/cpr/src/main/java/org/atmosphere/inject/AtmosphereRequestIntrospector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2025 Async-IO.org 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.atmosphere.inject; 17 | 18 | import org.atmosphere.cpr.AtmosphereRequest; 19 | import org.atmosphere.cpr.AtmosphereResource; 20 | import org.atmosphere.inject.annotation.RequestScoped; 21 | import org.atmosphere.util.ThreadLocalInvoker; 22 | 23 | import java.lang.reflect.Method; 24 | import java.lang.reflect.Proxy; 25 | import java.lang.reflect.Type; 26 | 27 | /** 28 | * {@link }AtmosphereResource} injection implementation support. 29 | * 30 | * @author Jeanfrancois Arcand 31 | */ 32 | @RequestScoped 33 | public class AtmosphereRequestIntrospector extends InjectIntrospectorAdapter { 34 | 35 | @Override 36 | public boolean supportedType(Type t) { 37 | return (t instanceof Class) && AtmosphereRequest.class.isAssignableFrom((Class) t); 38 | } 39 | 40 | @Override 41 | public AtmosphereRequest injectable(AtmosphereResource r) { 42 | final AtmosphereRequest request = r.getRequest(); 43 | 44 | return (AtmosphereRequest) Proxy.newProxyInstance(this.getClass().getClassLoader(), 45 | new Class[]{AtmosphereRequest.class}, new ThreadLocalInvoker() { 46 | { 47 | set(request); 48 | } 49 | 50 | @Override 51 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 52 | return method.invoke(request, args); 53 | } 54 | }); 55 | } 56 | 57 | } 58 | --------------------------------------------------------------------------------