Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:24:40+00:00 2026-06-02T09:24:40+00:00

I reviewed Netty docs, and found some comments in examples source Class: org.jboss.netty.example.factorial.FactorialServerHandler ,

  • 0

I reviewed Netty docs, and found some comments in examples source Class: org.jboss.netty.example.factorial.FactorialServerHandler , in this src, some comments:

    //##in org.jboss.netty.example.factorial.FactorialServerPipelineFactory
    ......
    // and then business logic.
    // Please note we create a handler for every new channel
    // because it has stateful properties.
    pipeline.addLast("handler", new FactorialServerHandler());

But, I recheck other examples, such as TelnetServerPipelineFactory, seems nothing difference, the handle is create by:

    // and then business logic. 
    pipeline.addLast("handler", new TelnetServerHandler());

All the handlers are created by pipeline with “new”? And all the examples in Netty are stateful? Obviously Echo/Telnet needn’t keep stateful prop.

In my old project, I use Netty to create a Http Server to act as RESTful server, my handler code is:

    public class HttpServerPipelineFactory  implements ChannelPipelineFactory {
        private final HttpServerHandler handler;
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = pipeline();
            pipeline.addLast("decoder", new HttpRequestDecoder());
            pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
            pipeline.addLast("encoder", new HttpResponseEncoder());
            pipeline.addLast("handler", handler); //singleton
            return pipeline;
        }
    }

My RESTful server is statefulless(which is one of REST meaning), so I used singleton handle. Was I right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:24:41+00:00Added an answer on June 2, 2026 at 9:24 am

    When the documentation says “stateful” it means that state informations are stored as fields in the ChannelHandler and thus its not possible to share the ChannelHandler between different Channels. If you have no state informations stored as fields you are ok to use it as Singelton.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just reviewed some code that looked like this before public class ProductChecker {
Recently I reviewed some C code and found something equivalent to the following: struct
I've reviewed all the documentation and Google results surrounding this and I think I
I've reviewed some posts about lazy loading but I believe my problem is a
We've reviewed XXX and determined that we cannot post this version of your iPhone
I have reviewed numerous reports of this error but the solutions I have seen
< I have reviewed the related questions shown by SO before posting this >
First of all, I reviewed this question , but I think I need a
This question has been asked before, but none that I have reviewed give a
I'm collecting some data via a Perl script. The data needs to be reviewed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.