Will WebSocket achieve what I'm trying to do? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm creating a simple java application made in swing that communicates with a database. Multiple people will be using the application at the same time. As they are able to change things at the same time, if someone for example, adds a new user, and a different person is on that same page, I want the person who did not make the change to be notified that changes were made to the database since they last loaded it.
My lecturer in college advised me that WebSockets would be the way to go to achieve this, however after some reading about WebSockets in Java, it seems it is based to work with web browsers instead of between Java applications.
Can using WebSockets achieve what I am trying? Or, if not, what would be a way to achieve this?

Simple answer is Yes you can achieve what you needed
WebSocket is a communication protocol(#see RFC 6455) & it is not a must to use a Web browser.
You can achieve what you want to do with your app, it is just a matter of writing a custom WebSocket server to facilitate your requirements in your case sending database changes to the other clients(Which is called Server push)
There are several java libraries to get the work done,
netty WebSocket (My favorite)
jWebsocket
Atmosphere
Webbit
Netty WebSocket is a good one to start with and you can find examples in its project to write a custom client and a server

Related

Is it possible to register a Domino Server with the Java API or C API? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
We are well on our way to Dockerizing Domino. In fact, we have a Domino Docker running in IBM Cloud (bluemix) that replicates with on prem.
What we want to be able to do is automate the standing up of a Domino server.
In our script, we are thinking of calling a custom program we can build that will use either the C API or Java API to register a new server, deploy a XPages (JSF) application to it, and start the server, replicate over the common user directory (names.nsf) from the master server.
Currently, we started the Domino Container in CentOS in listener mode. We registered the server on prem, and copied over a bunch of files (server.id is one of them) and edited confirmation to manually configure it. We want to automate this process.
Any insights on how this can be better accomplished? any api references you can share to get us most of the way there?
Yes, this is possible. We have done this in Lotusscript using LS2CAPI.
As we are accesing API functions, this is also possible using Java. Not sure, if domino-jna already includes the needed Api calls, but this can be implemented. Take a look at github for Karsten Lehmann and domino-jna.
domino-jna can be used from XPages as well.

Can you give me an advice about MVC client-server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm going to create a desktop application (Swing) using the MVC. It will be chat and i have some questions. Which classes should be located on client? (View - its logical) Model? Controller? or both classes should be on the server side?
And which classes have to process my database?
If you are planning to have server-client and database access, this sounds like a typical 3-tier distributed system.
Database - represented as DBMS and located potentially on a separate machine. This should provide easy API for queries and updates from the server.
Server - this is where Model is located, again potentially on a different machine than database. Server however has means of working with the database, ideally via the aforementioned API.
Client - contains View and Controller. View is essentially the UI aspect of the Model located on the server. Controller processes user interaction and sends to the server in the processed (clean) form that the server can understand. This is done to reduce server load. The client has no means of accessing the database directly.
If it's all the same to you, I'd recommend to have a look at JavaFX, its MVC is much easier to implement and just plain simple to work with

Enabling a completed Java app on the web [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am not a Java pro. I need to enable my completed java applications to ONLINE-Versions. Kindly give me the simplest way.
I have tried to go the JSP and Servlet way, but seems exceedingly tiresome,there surely ought to be a direct way.
When you use a typical web application what do you think is happening? You're in a browser and it's displaying some pages. You click around and some server does some work, for example Amazon shows you a list of books you could buy, the server is passing data to the browser for it to display.
That's a big difference from your current Java Application where everything is happening in the same computer.
This split between the UI part of the application, in the Browser, and the server part that's doing the real business is one reason why Web programming is so different from simple Java programming.
Servlets and JSPs are the traditional Java way of doing things, but modern web apps make much greater use of JavaScript for all the UI and all the Java (or any other server technology) does is provide the data displayed by JavaScript.
Bottom line: Sorry, but there is a whole lot more to learn. My recommendation would be to grit your teeth and forget about what you've done so far and start studying JavaScript and HTML.

Java to a web service and mysql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm here to pose a kinda noob question, so please no hate here mates.
The java application I'm trying to create has the following structure.
login request via net Validation(same machine)
**JAVA PROGRAM** ---------------------------------> **WebService** ---------------------------------------> **db**
Response Response
**db** --------------> **WebService** ----------------> **JAVA PROGRAM**
But my doubt is on how to build that webservice.
I've watched several glassfish tutorials, but none of them seem to explain how to actually create this type of connections.
Thank you!
You should divide your problem into several sub-problems and then tackle them one by one. I'm not sure if I understood your setup correctly, but to me it seems like you need the following:
Client Java application and the application logic
Server Java application and the application logic
Database
Connection from the server application to the database
Connection from the client Java application to the server application
In addition, you need to decide what kind of a connection you are going to use between your client and a server. Would it be a SOAP-based web service, a ReST service, plain HTML, just a simple POST/GET, or something else? Also, what kind of frameworks are you using? Spring, perhaps? Wicket? Something else?
Do you have any of those decided or done yet? Feel free to start a new question, I foresee this one being closed in the near future, because it's not clear what you are asking. Do study the What topics can I ask about here? page. If you can show any code in your question, you are much more likely to get answers.
Anyway, to give at least some kind of an answer to your question, I'd use the Spring Framework. Google for spring sql tutorial and then either spring restful web services tutorial, spring servlet tutorial or spring soap web service tutorial based on your technology of choice.
Your database interaction will be same as normal does. You just need to broadcast your Validator class as a WebService.
Below links will help you to do so.
For connecting java class with MySql
For broadcasting your class as Webservice.

Communication Java to NodeJS? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am exploring various ways that allow Java to connect and communicate with NodeJS. An example of what I am trying to achieve, is for example call Java methods from NodeJS, while allowing the Java method to manipulate Javascript objects. I know the JSObject class is helpful for this purpose. I have also heard so far of Dnode and ZeroMQ. Have you heard of or do you have experience in doing something similar? Would you suggest a way on how this communication Java to NodejS can be done?
I would go with an agnostic implementation.
A rest server on node js, maybe using restify listening for messages
A http client on the java side as httpclient to send messages to node.
this will also make it dead easy to test node implementation with curl and static requests; will enable you to implement authentication later on using any standard mechanism from oauth to basic and will let you change the client and the dispatcher independently later on
also you will be able to put any kind of standard load balancer in between, should you need the node app to scale.

Categories