Connecting - JavaFX + Servlets(??) + design patterns

Hello
I'm a total noob in JEE world so I'm sorry if I'm asking for sth really basic.
I would like to connect my JavaFX application with a simplest there is JEE-server. My guess is - Servlets (a good guess?). But before I start, here are some obstructions I need to face. The general goal of this whole project is to test few (around 5) JEE design patterns. It's because of my science project: "The use/usage of JEE design patterns in creating web applications". So what's the JavaFX for? My promotor asked for an application that would be handy for my College. So again what is going to be done :
- connect the JFX app with JEE server
- test the whole project with Cobertura, Checkstyle, Apache JMeter, Findbug, Cobertura, PMD/CMd and so on
- refactor the project with 5 design patterns. I think I'll try to use: DAO, Intercepting Filter, any suggestions what more?
- test again
- compair test results. Make conclusion on the thesis.
As for now I've found JFX class that could be used to communicate:
http://java.sun.com/javafx/1.2/docs/api/javafx.io.http/javafx.io.http.HttpRequest.html and other from javafx.io.http
I'm looking for the simplest way because I don't have a lot of time! :(((( So, is there a book, tool or a tutorial explaining how to quickly and simply do the stuff above?
What I have installed:
- winXP SP3 (linux and Eclipse still are crappy with JFX)
- Netbeans 6.7.1 with JavaFX and now I've installed additionally:
     - Java Web Applications
     - Sun Java System Web Server 7.0
     - EJB and EAR
Anything else I need?

Why don't using ejb for remote client?
It can be simpliest, you avoid web tier dev in the server and http on the fx side.
Any version requieried for the JEE? With the sixth one, few annotations and just concentrate on your job, very nice.

Similar Messages

  • Design pattern of servlet context

    hi all
    can u please tell me what design pattern is used in servlet context.
    thanks

    http://www.google.com/search?hl=en&client=netscape-pp&rls=com.netscape%3Aen-US&q=design+pattern+for+servlet+&btnG=Search

  • Design Pattern for Servlets

    Hello,
    I am about to organize my huge servlet code. I have a web application which is currently running as a single servlet (I know bad bad design) and I want to filter out from there to a more manageable and appropriate design. I researched the internet and did not find a compelling design pattern or library that I can use to do the same. I would really appreciate if experienced folks could share what design patterns they use for the entry servlet to their web-app. Thanks in advance.
    Ravi.

    Check out the famous Struts.
    Regards,
    Reflex

  • SERVICE LOCATOR ?? Is it really an interesting Design pattern??

    Hi everybody,
    i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
    It is said that by making use of a Service Locator we can :
    - hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
    - multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
    But i would like to understand at which side should that service locator object reside??!!??
    If it is at server side then the clients need well an initial context in order to make a lookup on that object.
    Conclusion :
    the service locator doesn't hide the complexities of initial context!!
    Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
    If it is at client side, each client needs his own services locator object
    Conclusion :
    multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
    There is certainly something that i don't understand so help me please!! Thanks.

    Hi Yves,
    But i would like to understand at which side should
    that service locator object reside??!!??
    If it is at client side, each client needs his own
    services locator object
    Conclusion :
    multiple client don't reuse the same service locator.
    What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
    a singleton. Since it is possible that there could be multiple
    class loaders/JVMs on the client side, and therefore, multiple
    instances of the "singleton" service locator. This is typical
    in a distributed environment (e.g. servlets/JSPs in a web-tier
    cluster using service locator). Thus service locator is not
    a truly "distributed singleton" object. But, the empahsis
    is to design the service locator such that it does not hold
    any state that needs to be replicated across multiple
    instances across different JVMs as mentioned. Thus, there
    is no need for multiple clients to use the "same" service locator,
    but still the benefits of implementing this pattern is realized.
    By making it a singleton, and keeping it from holding state
    that needs to be replicated, we realize the benefits of this pattern.
    You may also want to visit the J2EE Pattern interest list
    and see these relevant discussions :
    Topic: Service Locator and passivation
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
    Topic: Caching EJBHome interfaces
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
    Topic: Using Service Locator for Data Source caching
    http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
    hope this helps,
    thanks,
    -deepak

  • Design Patterns/Best Practices etc...

    fellow WLI gurus,
    I am looking for design patterns/best practices especially in EAI / WLI.
    Books ? Links ?
    With patterns/best practices I mean f.i.
    * When to use asynchronous/synchronous application view calls
    * where to do validation (if your connecting 2 EIS, both EIS, only in WLI,
    * what if an EIS is unavailable? How to handle this in your workflow?
    * performance issues
    Anyone want to share his/her thoughts on this ?
    Kris

              Hi.
              I recently bought WROX Press book Professional J2EE EAI, which discusses Enterprise
              Integration. Maybe not on a Design Pattern-level (if there is one), but it gave
              me a good overview and helped me make some desig decisions. I´m not sure if its
              technical enough for those used to such decisions, but it proved useful to me.
              http://www.wrox.com/ACON11.asp?WROXEMPTOKEN=87620ZUwNF3Eaw3YLdhXRpuVzK&ISBN=186100544X
              HTH
              Oskar
              

  • The search for a perfect design pattern

    The search for a perfect design pattern
    I am searching tip to upgrade a labview program used. I am looking for the best approach to make
    my program more robust and scalable.Software and hardware. 
    Today the system consists of :
    GPS, weather station, ultrasound wind sensor, echosounder  and a  webcamera,  all connected to a computer.
    The computer OS is XP pro with Labview version 2009 installed. Except for the webcamera all peripherals have serial communication interface. 
    The webcamera  interface is ethernet.
    Device                           Data type                 Interval                    Interface
    GPS                                NMEA string                1 second                   Serial  rs232
    Ultrasound wind sensor   NMEA string                1 second                   Serial rs232
    Weather, temp,humid     NMEA string               35 seconds                 Serial rs232
    Echosounder                  NMEA string               500ms-5 seconds       Serial rs232
                                                                          (depending of depth)
    Webcamera                    Jpg                           Snapshot on demand  Ethernet
    The tasks to be solved
    All the data have to be stored.
    All the data have to be displayed in real time.
    Weather history data must be buffered to be plotted in a graph (pop-up windows).
    Absolute wind speed and direction have to be calculated.
    Option to send navigation data attached to email at desired time intervals.
    Image snapshot at desired time intervals.
    The data wich streams into the serial ports are not synchronized and vary in intervals . Would it be a good idea to put all the serial peripherals into a serial device server. Is it possible to let the server place a event in my software, to  trigger reading of the data, from the the server.  Or how could that be done in other ways?
    The perfect design pattern
    In version one of the software I use 4 parallel loops to read data at the serial ports, inside these loops the data was separated and outputted to a datasocket server.  I used datasocked read in other loops to present and store data. But it did not look good, and yes it was a mess, a really rat nest. I am looking for a better design pattern.
     Could some kind of producer/ consumer pattern be the way to go?
    Comments and tips are wanted.
    TIK

    Nice Project! Congratulations ;-)
    I am not an expert for large applications. But your project looks nice and manageable. Here my straightforward ideas:
    I would build a GUI, with menu bar, pop-up graph display thing.
    THen low level tasks with each one handling a RS232 device and feeding queues or fireing notifications.
    Maybe handle the snapshots in an event structure on the GUI blockdiagramm.
    When GUI and producer tasks are running, close the gap with a middle layer which captures the data and actualizes GUI by reference. For instance the graph-thing-dialogue triggers a "flush queue" and displays the last 200 entries of the array of data.
    I often run into issues when having defined too many userevent structures. I guess i am too stupid for that. Thats why i rather use queues (when i dont want to loose data) or notifiers (data is up-to-date). Nevertheless I like a "stop-all-tasks" user event...traditionally.
    My team is actually developing a large application. We are using LabVIEW classes and objects.
    So have fun!
    Yours
    RZM

  • Best architecture and design pattern to use

    I am currently designing a moderately sized LabView application and cannot decide on the best architecture/design pattern or combinations thereof to implement.
    The program basically polls an instrument connected to a serial port continuously at a 2-10Hz rate. When operator clicks a button to start a run, the polled data is then filtered, has math functions performed on the data, writes collected data to files, and produces reltime graphs and calculates point-by-point statistics. At the completion of a run, some additional data files are written. I pretty much know how to accomplish all these tasks.
    What is also required is main-vi front panel interaction by the operator to access a database (via a C# dll with .Net) to query for specifications to apply in order to determine pass/fail status. Setup conditions also need to be changed from time to time by the operator and applied to the data in real time (ie- a measurement offset). I have prototyped the database portion successfully thus far.
    For the main vi, I started off using the Top Level Application Using Events design pattern (Event structure within a while loop). Copious use of bundled clusters and shift registers keep the database data updated. I cannot figure out how to have the top level vi concurrently poll the serial device as outlined above. The Event structure is only active when defined control values change, and use of a timeout is no help since it prevent data from being collected while the user is accessing the database. All database and setup parameters must be applied to the data as it comes in from the serial port. Error trapping/recovery is a must.
    I believe what I need is two parallel processes running under my main vi (one for database and setup, the other for polling and data processing/display, but what would be the preferred choice here?
    Revert back to a polled loop in lieu of Events, use notifiers, occurrences, user-defined events, Producer-consumer loops?
    It�s been about 3 years since I have had an application on this level (which used a state machine architecture), and a lot has changed in LabView (using 7.1 Prof Devel). I am currently having a mental block while trying to digest a lot of features I have never used before.
    Suggestions Welcome!
    Thanks.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    I suggest a (3) state machine(s) architecture. The first is the user interface. Your main VI is a good start. Another state machine handles the instrument I/O (your serial polling). The third handles all data processing. The three loops run independently. Each has a wait to allow LV's scheduler to share CPU time among the loops. I like queues or functional globals for inter-loop communications.
    This allows a lot of flexibility. Each portion can be tested alone. Each can have different timing and priority.
    Spend some time thinking about what needs to be done and plan the structure carefully before you do any coding (except for little test programs to try new ideas).
    I also like Conway and Watts "A Software Engineering Approach to LabVIEW", published
    by Prentice Hall.
    Lynn

  • Best practices for JavaFX architecture and patterns?

    Hi,
    I want to write reusable, easy to maintain JavaFX code for a larger UI project and wonder what are the best practices doing so.
    1) Are there preferred UI patterns? MVC, MVP, Presentation Model, ...?
    2) Does it make sense to use FXML to separate View from Logic? Or should I use 2-3 Java classes instead (one for View, one for Logic, one for Domain Model, depending on the pattern)
    3) How to organize all the views? Should I use Dependency Injection? Or Singletons for each view? Spring or Guice framework, if at all?
    Currently I use singletons for most views, so that I can use them from anywhere in my application. If a window is closed and opened again, I use the same instance for that, which still resists in memory.
    For patterns, I try to lean on Presentation Model, since this is what I know from Flex development: Having a View layer, which contains all the UI stuff and an abstract view layer, which holds properties, that describe the View, e.g. submitButtonDisabledProperty. The View knows the abstract layer (Presentation Model), but not vice versa and the UI elements are bound to its properties.
    I am unsure if this is appropriate for JavaFX, too (for Flex or Silverlight it is).
    What are your recommendations / experiences for large UI projects?

    You are correct that in 'pure' MVP the View should know as little about it's presenter implementation as possible. The view should just notify one or more 'listeners' that something has happened.
    You can use event listeners for this, but I would highly recommend not exposing your Control-specific GUI events and instead create your own. So for example, don't expose ActionEvent or MouseEvent as these expose too much detail about your View's implementation, instead create 'semantic' events, so you might have something like 'sayHelloRequested' or 'printOptionSelected' (whatever naming system you want). This hides how the option is implemented, so you might have a 'print' button, a 'print' menu option, a CTRL+P print shortcut, or a double tap anywhere on your screen to print. The listener knows only that the view thinks 'print was requested by the user' - decoupling achieved.
    Once you start doing this however you end up with an explosion of event listener interfaces. So say a view has 10 callbacks it wants to notify about, then you end up with 10 interfaces, and if you're being really pure you also end up with 10 'Event' beans (or DTOs) to encapsulate the details of that event. It starts to get ungainly even for a semi-purist like me. So the logical progression from there is usually just to define all 10 callbacks in one interface and call it something like MyViewListener.
    There are two common ways to implement listeners, the traditional way is to allow an arbitrary number of listeners to be added. Whereas another option is to allow only a single listener to be added. In JFX you will notice that Button for example has a setOnAction() method not a addOnAction() method - it allows a single event handler only and let's face it this is generally fine in 95% of cases. For the remaining 5% you can just write your own aggregate event handler that dispatches the event to multiple listeners.
    So if we go down the road of single event listeners, using an interface for all of the callbacks and not bothering with full 'Event' objects, you end up with something like this:
    public interface MyViewListener {
        void printRequested();
        void doSomething(int someParam);   
        void doSomethingElse(String someOtherParam);   
    }And if you look closely at the 'Purist' option in my MVP pattern where I define interfaces for everything, then you will see that this is pretty much the exact interface I've created for the 'Presenter'. You could just as easily rename this interface to MyViewListener in this pattern and have the same outcome.
    So to wrap all that up, yes, the Presenter should be decoupled and I highly favour the 'purist' option in my blog and would definitely use it if FXML didn't dictate a impure design pattern (there are some ongoing discussions about this on the OpenJFX discussion group). And, yes, my 'purist' option could be even more pure if you went for the full-blown event callback model and if you go down that road you will have an extremely clean architecture but also an extremely large code-base - totally your call whether it's worth it.
    It's also worth remembering in all this, that there are a lot of people from a lot of different backgrounds using JFX and some people hate (passionately) even my semi-pure option - especially those coming from other, less heavy-weight languages. They just don't get why you wouldn't build it all into one class and reduce the overheads. So what you have in my blog is my thoughts on it, other people will most definitely differ. I'm a big fan of developer's choice, and that's why I did the smorgasboard approach even though I personally would never use some of those implementations.
    Also this video on GWT is an awesome reference on GUI design patterns: http://www.youtube.com/watch?v=PDuhR18-EdM
    JFX Flow draws a lot from GWT as I think it is a very clean architecture (just such a shame that they put all that effort into hiding the horrid, sordid mess that is the web+html+css, instead of making something proper, like JFX).
    Hope that helps,
    zonski

  • Finding instance from variable design pattern required

    Hello guys,
         In my appication I need to get instance of a class from its instance variable.
    Let me explain in deep.
    I have one class ServerConnection in which I accept connection from client as a SocketChannel..
    In the same class I pass this channel variable to new Player construcotr and create one Player class instance.
    Now each player has it's own channel.
    My problem is that when particular channel closed I have to identify particular Player from so many player..
    So how can I identify that instance..
    I can do this by comparing socket port but there are so many players instance so it is some burden some.
    I need some pattern which can help out me to identify particular player by simply passing Socketchannel as parameter..
    Please help me out.

    Hello Nina
    A very good introduction into design patterns is the book "Head First: Design Patterns". Here you will find many good reasons why and when to use the factory pattern.
    You should use the factory pattern when
    - you want to prevent "direct" instantiation (i.e. using a public CONSTRUCTOR method) by the developer
    - you want to hide the complexity of instantiation from the user of the class
    - the instantiation creates an implementation of an interface and you want to keep control of which implementing class is returned
    Regards
      Uwe

  • JDBC Design Patterns

    Hi All,
    I am new to patterns and have started understanding them using the Head First Series.
    I would like to know what all design patterns are there in JDBC?
    Can i say that JDBC uses a Facade design patterns as it hides the database specific details and provides us a interface which helps us to connect to a database. What other design patterns exist as part of the JDBC?
    Request you to clarify my doubts.
    Many thanks in advance

    I would really appreciate a good discussion on it
    rather than any spoon feeding.
    A typical JDBC code will appear as follows:
    try
    /* Load the jdbc-odbc driver
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    // Open a connection to data source
    con
    =DriverManager.getConnection("jdbc:odbc:DBName","","")
    // Get a statement from the connection
    Statement stmt = conn.createStatement() ;
    // Execute the query
    ResultSet rs = stmt.executeQuery( "select * from
    table_name" ) ;
    1. Is it ok to look into each statement of the above
    code snippet in terms of Design Patterns.it's ok, yes. not necessarily appropriate or worthwhile, though
    2. How can one dissect each line of the code in terms
    of various design patterns?you can't. design patterns exist at a higher level of abstraction than code. 'in terms of' is also disconcertingly vague.
    3. Is it correct to conclude that java.sql package
    overall uses Abstract Factory Pattern.
    As it uses lot of interfaces and implemetation is
    provided by the Vendors. yep. that sounds fair enough. not very useful, though
    4. Consider a particular package like
    java.sql.Statement,java.sql.Blob,java.sql.Connection
    etc. is is correct to conclude that
    its an example of a Factory Method Pattern as any
    client would instantiate. Here the client would be
    Statement object,
    Creator is Connection Interface and createStatement()
    is the factory method.possibly. there's little value in trying to define everything as a "design pattern", though. rather than thinking "oh, they must be using PATTERN X here", think "if I were writing this code, I think PATTERN X would be appropriate". or, more usefully, "is there a pattern that solves this problem?". there isn't, necessarily
    5. I am not able to understand if a statement like
    Class.forName() should be viewed only in terms of a
    programming instruction or
    any design patternit's a line of code, nothing more. stop trying to make everything into a pattern. until you realise where patterns are and aren't applicable, you'll never understand them
    6. Can "stmt.executeQuery()" can be viewed as A
    Strategy Pattern? nope. what makes you think that?
    I would really welcome a good discussion on the above
    questions.does the discussion have to involve design patterns? you know, of course, that design patterns aren't magic beans, right? I know you've just discovered patterns, and are all excited by them, but seriously, they're only ideas, not Infallible Solutions To All Software Problems ™. the most common mistake people make using design patterns is to see them everywhere, and try to bend every problem to fit a particular pattern
    for the record, nobody really views JDBC in terms of patterns. there's little value in viewing existing technologies in those terms, since the most you can "gain" is to have guessed what some other developer did, before.

  • A beginner to design pattern(Struct,Spring & Hibernate framework)

    Actually I am beginner to MVC2 Approach of complex application incorporated by design pattern as Struct,Spring & Hibernate framework.
    Currently I am learning JSP Concepts,I have one doubt.
    (1)What are the things I should grasp even before taking off to Design pattern?
    Help me anyone plz?
    With Regards,
    Stalin.G

    [email protected] wrote:
    Actually I am beginner to MVC2 Approach of complex application incorporated by design pattern as Struct,Spring & Hibernate framework.
    Currently I am learning JSP Concepts,I have one doubt.Just one?
    >
    (1)What are the things I should grasp even before taking off to Design pattern?You should understand core Java very, very well.
    You should know JSPs using JSTL without scriptlets.
    You should understand relational databases and SQL.
    You should understand HTML and HTTP.
    Personally I think Struts, Spring, and Hibernate all at once are well beyond any beginner.
    It's hard to advise you on what to do without knowing your capabilities and the problem you're trying to solve, but I think you should try it first using just JSPs, servlets, and JDBC. Get that to work and then refactor it to use the frameworks. You'll understand and appreciate them more that way.
    %

  • DAO design pattern & Transaction boundaries

    I am using a tool to generate a JDBC tier that applies the DAO design pattern. However, the generated code is based on "autocommit"-strategy, i.e. there is no conn.setautocommit(false)-statement in the code.
    I have added statement so that I can handle the transaction by myself. The DataAccessObject-implementation class does however close the connection before returning. I would like to execute the commit outside of the DAO-implementation.
    Anyone who have been experiencing the same problem?
    Best regards
    Lasse Bergstr�m

    I'm not sure if I fully understand your question.
    However, we usually implement such a scenario by doing autocommit false on the connection object and then passing it to the DAO. Finally do a commit on the connection in the calling class.

  • Possible design patterns for base function with possible additions

    I have various interfaces i have to implement. Let's assume ITypeA, ITypeB. They have following methods:
    ITypeA
    Connect
    Disconnect
    GetData
    SetData
    ClearData
    ITypeB
    Connect
    Disconnect
    GetData
    SetData
    Start
    Pause
    Stop
    They have some base functionality: Connect, Disconnect, GetData and SetData.
    If I want to add ITypeC in the future, it will have these base functionality too.
    I want to access to the base functionality and if there is additional functionality, I want to get this too. What design patterns are available that are capable of this situations?
    I found one here: Extension Interface. In this, you create a base
    interface and multiple extension interfaces that are implementing the additional functions. In the base interface you can ask for the available extension interfaces of the component. But this approach seems complicated: I have to create interfaces for each
    type, factories for the interfaces, I need some tables to save what Interface belongs to what Factory...
    What is the basic solution for this problem? Extension Interfaces? Are there any other possible alternatives for my problem?

    You may have more joy dividing your interfaces by behaviour and deciding on the types later.
    interface IConnectable
    Connect
    Disconnect
    interface IDataTransferrable
    GetData
    SetData
    interface IPlayable
    Start
    Pause
    Stop
    class TypeA : IConnectable, IDataTransferrable
    class TypeB : IConnectable, IDataTransferrable, IPlayable
    And then how can discover if your object supports these interfaces?
    here's one way:
    if (ob is IPlayable)
    Playback(ob);
    where you have a function:
    void Playback(IPlayable ob)

  • Cor design pattern

    I use cor design pattern little different than what I see in google.
    here is m y cor
         public static  abstract  class CORHandler    {
              CORHandler  nextHandler;
              public void process(){
                   if(canHandleRequest()){
                        handleRequest();
                   }else {
                        if(nextHandler!=null) nextHandler.process();
              protected abstract  boolean canHandleRequest();
              protected abstract void  handleRequest();
              public void setNextHandler(CORHandler  corHandler){
                   nextHandler=corHandler;
         }this serves most of my need and also I can override process method for change behaviour .
    this code helps me save lots of if/else conditions , I am not passing any object to the method here reason is I use this always as inner class inside a method so I can access all final fields
    advice me is this right when applying cor pattern?

    Making it a base class increases connectivity to no good purpose.
    It violates the concept of inheritance by making the objects COR classes which is not what they are.
    It violates the principal of COR in that the intent is to handle a responsibility not all responsibilities. This same problem obscures the pattern as well by eliminating the objects to be acted upon.

  • Design Pattern for multithreaded client server program

    I asked this question in another post, but with other stuff, so I'll distill this one.
    I am creating a multi-threaded client server program (just for learning - a chat program at this point). I built the server and client in swing, and I'm wondering what the best design pattern is for this setup. Right now all the swing stuff is in the MyServer class. In that class I have a loop accepting client connections to the serverSocket and creating a new MyServerThread (threaded client connection).
    The problem is that all the work of creating input streams, interacting with the server, all that stuff is done in the MyServerThread class, but I want that text to be written up to the Swing objects - which is in the MyServer class. So right now in the MyServerThread class I pass the MyServer object into it, but I'm not sure if that is really the most robust thing to do. Does anybody have any suggestions as to how this should be done. If somebody has an article they'd like to point to I'll check it out too. But if it's just the run-of-the-mill multithreaded client-server article, I've read alot and most don't specifically address my question.

    Thanks for the reply Kaj, and I think I'll keep my design for now, since it's just quick and dirty. I've read the MVC concept a while ago and I'll revisit it again when I get more serious. But I have a question, why should I be using a callback interface, why an interface at all? And then make MyServer implement that interface...why not just pass MyServer to the thread object? Or is there something down the line that I did not forsee?

Maybe you are looking for