简体   繁体   中英

How can we add a server-side Java code in Firebase?

Scenario:

I am planning to build a system that has 2 components. A Web App (Angular) that would push some data to Firebase. Before the data gets pushed , I want it to get validated by a server-side Java code. The data getting pushed to Firebase is fed to an Android application that consumes the data from Firebase. The Android user can perform some actions like changing the state of data. Before the data gets changed again there should be a server side code to validate it.

Question:

Where does the server-side code reside? Do we need a third party Web App hosting service other than Firebase?

If my code is in Java 7, what can be the possible options available?

If at all we use a third party server, how does the server communicate with a Firebase server?

Also can you please help me understand (if possible) how can we make sure that the data getting pushed to Firebase server gets validated by the server-side code before getting pushed?

firebaser here

You can interact with the Firebase Database through its Java SDK .

Firebase does not currently provide a way for you to run your (Java) code on our servers. We've covered this many times already, so I recommend reading up here: Server Side Calculation using Firebase

So you'll indeed have to host that code at a third party. Recommending a specific host is off-topic on Stack Overflow, but there are undoubtedly a lot of results of you search for Java hosting .

A common way to have server-side validation before sharing the data publicly is to have two separate lists.

moderationList
    -K.....1
        title: "how can we add a server side java code in firebase"
        body: "Scenario: I am planning to build a system..."
messageList
    -K.....2
        title: "Firebase and backend logic"
        body: "I am parse.com user, and now I look..."

Your users view messageList , but they write their items to moderationList . Your Java server code monitors this list, validates the item and then adds the item to messageList . This is a common queue pattern that we use a lot internally at Firebase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM