4 Replies Latest reply on Apr 7, 2011 12:43 AM by drathnow

    Getting inside the "container"

    drathnow

      My application has a web interface that takes advantage of all the features offered by the JBoss container but it's main function is to act as a "concentrator" for remote field devices that send data into our system.  This data arrives via TCP/UDP and is handled by my own code: I have a thread listening on a TCP port that accepts a connection and processes the socket and another that accepts UDP packets and dispatches them for processing.  The data is not HTTP requests.

       

      Since this code excutes outside the normal HTTP request handling, I can't take advantage of the same features available to my web requests.  I can do JNDI lookups for object but I also would like to add in some AOP in to this same execution path.

       

      Is there an easy way to do this?  Is there some way to get from a socket (UDP or TCP) into the "container" so DI and AOP will work as it normally does with other JBoss components?

       

      Thanks

      Dave.

        • 1. Getting inside the "container"
          philani

          Socket listening inside the container is nor recommended, but you could do socket listening inside the init() method of a servlet.

          • 2. Re: Getting inside the "container"
            drathnow

            Well, I think that's my point.  I'm listening outside the container and would like to get back inside the container when a connection/datagram arrives.

             

            Can you expand a little on why listening inside the container is a bad idea?  I've been running this application in Jboss for 3 years and haven't had any problems with the approach I'm using.

            • 3. Getting inside the "container"
              genman

              I've done many services that only spoke TCP (not HTTP).

               

              By DI, I assume you mean CDI. And so this is more of a CDI/Weld question, but I'll try to answer.

               

              Basically, what the container does is activate CDI contexts as part of HTTP request handling. You can do this yourself by obtaining a reference to the BeanManager through JNDI. I don't really know much more than this. I suppose you can look at the source code (get yourself a stack trace) and see how, say, RequestScope is activated.

              1 of 1 people found this helpful
              • 4. Getting inside the "container"
                drathnow

                Okay.  So lets say I get the BeanManager and then use it to get some object and all it's dependent objects.  What are the ramifications of then passing that object to another thread?