or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

annotations.mdbroadcasting.mdcaching.mdcore-framework.mdindex.mdinterceptors.mdwebsocket.md
tile.json

tessl/maven-org-atmosphere--atmosphere-runtime

The Atmosphere Framework runtime providing comprehensive support for building real-time, event-driven web applications with transparent transport protocol support including WebSockets, Server Sent Events, Long-Polling, HTTP Streaming, and JSONP.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.atmosphere/atmosphere-runtime@3.0.x

To install, run

npx @tessl/cli install tessl/maven-org-atmosphere--atmosphere-runtime@3.0.0

index.mddocs/

Atmosphere Runtime

The Atmosphere Framework runtime provides comprehensive support for building real-time, event-driven web applications with transparent transport protocol support including WebSockets, Server Sent Events, Long-Polling, HTTP Streaming, and JSONP. It enables scalable real-time applications with automatic protocol fallback and cross-platform compatibility across all Servlet-based servers.

Package Information

  • Package Name: atmosphere-runtime
  • Package Type: maven
  • Language: Java
  • Group ID: org.atmosphere
  • Artifact ID: atmosphere-runtime
  • Installation: Add to Maven pom.xml:
    <dependency>
      <groupId>org.atmosphere</groupId>
      <artifactId>atmosphere-runtime</artifactId>
      <version>3.0.13</version>
    </dependency>

Core Imports

import org.atmosphere.cpr.*;
import org.atmosphere.config.service.*;
import org.atmosphere.websocket.*;

Common patterns:

import org.atmosphere.cpr.AtmosphereFramework;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereHandler;
import org.atmosphere.cpr.Broadcaster;
import org.atmosphere.config.service.AtmosphereHandlerService;
import org.atmosphere.config.service.ManagedService;

Basic Usage

AtmosphereHandler Approach

import org.atmosphere.cpr.*;
import org.atmosphere.config.service.AtmosphereHandlerService;

@AtmosphereHandlerService(path = "/chat")
public class ChatHandler implements AtmosphereHandler {
    
    @Override
    public void onRequest(AtmosphereResource resource) throws IOException {
        // Suspend the connection for real-time updates
        resource.suspend();
    }
    
    @Override
    public void onStateChange(AtmosphereResourceEvent event) throws IOException {
        // Handle broadcast messages
        if (event.getMessage() != null) {
            event.getResource().write(event.getMessage().toString());
        }
    }
    
    @Override
    public void destroy() {
        // Cleanup resources
    }
}

Managed Service Approach

import org.atmosphere.config.service.*;

@ManagedService(path = "/managed-chat")
public class ManagedChatService {
    
    @Get
    public void onOpen(AtmosphereResource resource) {
        resource.suspend();
    }
    
    @Message
    public void onMessage(String message) {
        // Handle incoming message
        // Broadcast to other connected clients
    }
    
    @Disconnect
    public void onDisconnect(AtmosphereResourceEvent event) {
        // Handle client disconnection
    }
}

Broadcasting Messages

import org.atmosphere.cpr.*;

// Get broadcaster factory and create/lookup broadcaster
BroadcasterFactory factory = BroadcasterFactory.getDefault();
Broadcaster broadcaster = factory.lookup("/chat", true);

// Broadcast message to all connected resources
broadcaster.broadcast("Hello, everyone!");

// Broadcast to specific resource
broadcaster.broadcast("Private message", atmosphereResource);

Architecture

The Atmosphere Framework is built around several core components:

  • AtmosphereFramework: Central configuration and management hub
  • AtmosphereResource: Represents a suspended HTTP connection with broadcast capabilities
  • Broadcaster: Message distribution system supporting multiple scopes and policies
  • AtmosphereHandler: Request processing interface for custom application logic
  • Transport Abstraction: Automatic fallback between WebSocket, SSE, Long-Polling, and other transports
  • Annotation-Based Configuration: Declarative service configuration with lifecycle management
  • Interceptor Pipeline: Request/response processing and protocol adaptation
  • Caching System: Message persistence and replay for connection recovery

Capabilities

Core Framework

Central framework management including configuration, resource handling, and the primary AtmosphereResource interface for managing suspended connections and broadcasting.

public class AtmosphereFramework {
    public AtmosphereFramework init();
    public void destroy();
    public AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler handler);
    public BroadcasterFactory getBroadcasterFactory();
    public AtmosphereConfig getAtmosphereConfig();
}

public interface AtmosphereResource {
    public AtmosphereResource suspend();
    public AtmosphereResource suspend(long timeout);
    public AtmosphereResource resume();
    public boolean isSuspended();
    public Broadcaster getBroadcaster();
    public AtmosphereResource setBroadcaster(Broadcaster broadcaster);
    public AtmosphereRequest getRequest();
    public AtmosphereResponse getResponse();
    public TRANSPORT transport();
}

Core Framework

Broadcasting System

Message distribution system with support for multiple scopes, policies, and targeted broadcasting. Includes factory management and meta-broadcasting capabilities.

public interface Broadcaster {
    public Future<Object> broadcast(Object msg);
    public Future<Object> broadcast(Object msg, AtmosphereResource resource);
    public Broadcaster addAtmosphereResource(AtmosphereResource resource);
    public Broadcaster removeAtmosphereResource(AtmosphereResource resource);
    public void destroy();
    public Broadcaster setScope(SCOPE scope);
}

public interface BroadcasterFactory {
    public Broadcaster lookup(Object id, boolean createIfNull);
    public void destroy();
    public Collection<Broadcaster> lookupAll();
}

Broadcasting System

Annotation-Based Services

Declarative service configuration using annotations for HTTP method mapping, event handling, parameter injection, and component registration.

@AtmosphereHandlerService(path = "/example")
@ManagedService(path = "/managed")
@Get @Post @Put @Delete
@Message @Ready @Disconnect @Resume @Heartbeat
@PathParam("param")
@BroadcasterService @AtmosphereInterceptorService

Annotation Services

WebSocket Support

Complete WebSocket integration including connection management, protocol handling, message processing, and custom protocol implementations.

public interface WebSocket {
    public WebSocket write(String data);
    public void close();
    public boolean isOpen();
    public AtmosphereResource resource();
}

public interface WebSocketHandler {
    public void onOpen(WebSocket webSocket);
    public void onClose(WebSocket webSocket);
    public void onTextMessage(WebSocket webSocket, String message);
    public void onByteMessage(WebSocket webSocket, byte[] message);
}

WebSocket Support

Caching System

Message caching and replay capabilities for connection recovery, with multiple cache implementations and inspection utilities.

public interface BroadcasterCache {
    public void addToCache(String broadcasterId, String uuid, BroadcastMessage message);
    public List<Object> retrieveFromCache(String broadcasterId, String uuid);
    public void clearCache(String broadcasterId, String uuid);
}

Caching System

Interceptor System

Request/response processing pipeline with built-in interceptors for CORS, heartbeat, protocol handling, and custom processing logic.

public interface AtmosphereInterceptor {
    public Action intercept(AtmosphereResource resource);
    public void postInspect(AtmosphereResource resource);
    public int priority();
}

Interceptor System

Transport Types

public enum TRANSPORT {
    POLLING,
    LONG_POLLING, 
    STREAMING,
    WEBSOCKET,
    JSONP,
    SSE,
    AJAX,
    HTMLFILE,
    CLOSE,
    UNDEFINED
}

Core Enums and Constants

public enum SCOPE {
    REQUEST,     // Current request only
    APPLICATION, // Current web application  
    VM          // Entire JVM
}

public enum POLICY {
    FIFO,   // First In, First Out
    REJECT  // Reject new resources when limit reached
}