I'm a salesforce newbie and I need to integrate java business logic with apex pages.
Is it possibile to do it without using vwmforce? Note that I have to include my own and third party libraries as well.
Is there any tutorial/resource about that?
Thanks in advance
You could perform callouts from Salesforce to your separate Java code (as long as it's exposed as webservice or at least can accept HTTP message).
Read about Integration on the Force.com platform, there are many possibilities and examples.
In the API documentation most of the time there are Java code snippets listed, for example for creation of new records (scroll down to the middle of the page, "#" anchors seem to be brokes so I cannot give a direct link).
Generally you can both "push" (send from Salesforce notifications when something happens, synchronously or not) and "pull" data (periodically ask from your Java application for changes or send INSERTS etc. whenever something happens on your side).
But if you want to run your Java on Salesforce server and not on your own machine - tough, vmforce might be the only option. I haven't tried this one yet.
In the end under the Apex, Visualforce etc. there are Oracle databases and Java (with JSP), but I doubt they'll grant access to it ;)
Related
tl;dr: Is Spring + Django back-end possible?
When I was new to industry and was still working my way around the office, I got interested in Django and created a very small, basic-level application using the framework. When I got to meet my team after a few weeks, they said to go for Spring framework. After spending half a year on the framework and the main proj, I finally started to get time to start working off-hours. But, I don't want to lose both the skills - My teammate(when we were still in office ;) ) once told me that they worked on a project that started with python code, and then later added features using Java. And I am unable to find any helpful google searches(mostly showing Spring vs Django).
How should I go about it? Is it too much to ask for? Is it worthwhile? Will I learn some new concepts of application architecture a noob like me would have missed. Please provide me with some insight.
Are there resources(docs) I can go through?
P.S. I'm not a diehard fan of either of the frameworks right now, just another coder testing waters.
You can't write java in python.
You can extend Python with C/C++ which is quite common: Extending Python with C or C++
And about the part that they told that they added features with java:
It's common to create different parts of a project using different languages and tools. Microservice architecture is a common architecture for these kinds of use cases. You basically code different parts of the project in a language you want and then you connect all the parts using different methods like REST APIs, gRPC and etc.
Imagine you are creating a website like youtube that lets others upload videos. There is a form that users upload their files and you store them in your storage and then you have to encode the video file for different qualities. You can code the form handler using Python and Django to store the files in your storage. Then you can code another service using java that handles the encoding part which is a heavy process. When an upload is completed, you send the file or file path to your java service using an internal REST API and tell the service to start encoding the video and notify the Django service and then the Django service will publish the video on the feed that can itself be written in another language.
I would say go for 1 framework and stick with it. For example Django if you want to code in python, and spring if you want to code in java. Learning both frameworks however brings a lot of value, because you can compare their benefits (eg. spring forces you to write clean code, django has build-in and simpler database management)
I like Django's build-in tooling a lot, you only need to know python for it to work. Spring requires a bit more knowledge of eg. hibernate for database management. However I predict Django will outgrow spring at some point, because of cloud valuing fast iteration over code and quick startup time (auto-scaling apps) over large overhead apps and long boot times. Hoever, if you like java, I can recommend JHipster for java/spring webapp development to get up to speed very fast and learning the ways of REST CRUD api fast.
To combine 2 programs: write your main logic in one app, and write a small service in the second language, making sure its independent of the first app (no back and forth communication and complicated logic, but simple independent request/response, as if the main app was never there). Add a REST api to the second app and use eg. http requests to communicate.
What's possible in terms of combining languages:
connect different applications with each other: by letting them communicate through their APIs. For example a python api developed with flask or django can send requests to a java api developed with spring, as long as they have a way to communicate (eg over http, or via some queue like rabbitmq)
connect a webapp to 2 different backends: by using a shared authentication system: For example a keycloak authentication server to handle tokens, that your backend applications know about.
What's not possible (and also not preferable):
combining java with python code in the same program: there are some hacky ways to get it to work, but its asking for trouble and not readable.
I built a large JAVA web application using SPRING & MongoDB,
In some scenarios, I want to allow my users to upload their own code, and the application will run it later on when necessary.
I called this operation "Plugin framework", the plugin is the user's code of course which I prefer to be in NodeJS for now.
There is any recommended / known architecture for that purpose?
I've read about pf4j and senecajs, but they quite different from my needs.
Thanks!
You loose complete control over code running on node. The uploaded code can access network, files, database, you name it. That is not a good plan.
I suggest to work with the embedded JS module in Java, called rhino. Here, you define which environment the code can access.
You find samples of using the scripting in Java here http://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/index.html for jdk7, the Javadocs https://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html and here some info on Java8 changes http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html
UPDATE:
On the comment below, you state that you think you are safe, if the code runs on the other server. Actually, the problem is still the same. Just it won't hit your application's server but the JS code server.
My advice stands. Implement a JS execution service using the built-in Javascript engine (Rhino or Nashorn) and restrict the running JS to a sandbox, you control the script's reach out of the box through carefully implemented env-access methods. It is actually pretty easy to get started, no more complicated than implementing a remote javascript implementation engine on top of node...
I am trying to implement a "Doctor Finder" application for android which will have a symptom checker facility like webMD. Since webMD don't have any API's I must create my own expert system (which takes a lot of time) or need to find something similar to webMD which offers public API. I found NIL API from National Library of Medicine US and I doubt it would be useful in my scenario.
Now the actual question, Is it possible to use webMD's online symptoms checker using an interface from android. I don't want to show the HTML page within my app but to send and receive information through it? If not is there any APIs available to serve this purpose?
You can do that by using "selenium".
Its a tool used for automated testing of web applications. you can navigate and enter information in the web page and get results using this.
http://www.seleniumhq.org/
This might be a basic question, but I tried googling it and couldn't find an answer.
I need to make a list of all the SQL Servers on a network. This is very easy to do using the .NET framework (System.Data.Sql.SqlDataSourceEnumerator), but is there also a relatively simple way to do this in java as well? While I was doing my research, I came across the possibility of listening in at different ports, but that seemed un-user friendly.
I've been told to use SQL Browser Service, but a) I couldn't find any information on how to call that from java, and b) does this service get automatically downloaded when you download SQL Server? Can I assume that every computer on the network I'm searching has access to this browser service? And if not, does that make a difference to my code?
Thank you all so much.
You can use SQLBrowseConnect function from ODBC API.
You can call COM components from java (with suitably crafted IDL), so you could use DMO or SMO (depending on your SQL Server version)
I ended up using the command line's osql -L command to list all the servers on the network.
I have found it pretty easy to find all SQL services (assuming appropriate level of perms) by enumerating the Windows services on servers using WMI. This "catches" different SQL Server suite- services like Reporting Services and Analysis Services that are not the relational engine, plus services that are not running at the moment. I use this for license auditing, via PowerShell. So, if that seems useful, it's a matter of how to call WMI from Java. This dude: http://www.vijaykandy.com/archives/121 made a list of some options.
I've been using the following web development stack for a few years:
java/spring/hibernate/mysql/jetty/wicket/jquery
For certain requirements, I'm considering switching to a NoSQL datastore with an AJAX frontend. I would probably build the frontend with jQuery and communicate with the web application middleware using JSON. I'm leaning toward MongoDB because of more dynamic query capabilities, but am still considering CouchDB.
I'm not sure what to use in the middle. Probably something RESTful? My preference is to stick with Java (or maybe Scala or Groovy) since I'm using tools like Drools for rules and Shiro for security. But then again, I want to pick something that is quick an easy to work with, so I'm open to other solutions.
If you are building ajax/json/nosql solutions, I'd like to hear details about what tools you are using and any pros/cons you've found to using them.
Pick whichever middleware you are most comfortable with.
CouchApp is very experimental at the moment. The main issue is being able to add security to your app without having a standard HTTP pop-up box. This is obviously a big issue for standard web apps.
Try and avoid parsing each DB request in the middleware and rebuilding the query for couchdb. You can make your middleware act like a proxy so most requests are forwarded on without modification. You can also add a security layer in the middlelayer on top of all requests that need authentication.
Pick a middleware/framework with good URL routing capabilities. For example you could route all requests that go to mydomain.com/db/ to couchdb.
If you go with CouchDB, you can use CouchApp which is a set of scripts for deploying an application directly to a CouchDB database. In essence, you skip the middleware and use CouchDB's views, lists, and show functions along with clientside JavaScript to implement the whole app. If your app works in this architecture, it's surprisingly refreshing, simple and cool.
Also if you like the idea of JSON/REST and sticking to JavaScript client to server, the newer generation of Persevere's core, Pintura is pure JS JSON/REST framework that is designed specifically to work well with NoSQL DBs.
I've been tinkering with a few. Ultimately, I'd like to move my controller layer of MVC to the jQuery/javascript frontend and use pure JSON/REST to talk with the backend. Though the backend will need strong security and, for my application some ability to do workflow, queries, and rules.
You also might want to look at:
1) Couldkit, which runs on Tokyo Cabinet. Supports JSONQuery and OAuth. Runs on Ruby/Rack may have enough functionality. Loks like a strong REST implementation.
2) Persevere, which is Java based and strongly supported in Dojo. It is REST-ish but also has some RPC type calls. Seems very powerful overall, with server-side java scripting, etc.
I wouldn't mind hearing how you're coming along.
Cheers,
Alex
I wrote a gem called Rack::JSON for exactly this purpose, it acts as a basic REST interface to a MongoDB db. It was inspired by Cloudkit and supports JSONQuery and also runs on Ruby/Rack. It allows you to store and then access/query JSON documents.