How would I build Rest + EJB using Weblogic?
I have a need to build 1 restful web service using weblogic. This web service will have parameters to select a what data the service should return. Like 'customer', or 'product'.
Now I want to deploy the 'customer' and 'product' code as a separate deployable applications, so that I can add or remove new code without redeploying all the code each time there is a change.
So I want one generic webservice to call this business logic.
My question is, what is the best way to structure this? Can I deploy separate EJBs for my business logic and have the web service invoke the EJBs based on the passed parameters?
Or should I have the business components as a shared library and call them that way? I am looking for a way to get the best performance.
I will have about 20 different business modules written by other programers. Like I said I don't want all the modules in the same EAR or WAR file. They need to be separately de开发者_如何转开发ployable.
Any thoughts?
WebLogic 10.3.4 includes new Java EE6 API support including JAX-RS 1.1 with Jersey. We recently did a webcast on this functionality and Webcast #4 covers JAX-RS. Here's the link: http://www.oracle.com/technetwork/middleware/weblogic/learnmore/weblogic-javaee6-webcasts-358613.html There is also an example application on this called Oracle Parcel Service and you can download the code here: https://www.samplecode.oracle.com/sf/projects/oracle-parcel-svc/.
If you use JAXB you can marshall from JSON and XML into the same Java object. The challenge here is that the JAXB generated classes are not serializeable by default so if you wanted to access a remote EJB from the JAX-RS service then you would have a problem.
Since you can't have the modules in the same EAR, there is another option. You could possibly use Java EE shared libraries. Then you could deploy your EJB's as a Java EE Shared library and reference that library in your REST client. Here is an example:
In your EJB module, include something like the following in your manifest:
Extension-Name: ops-util
Implementation-Title: OPS 2.0 Utils Library EXAMPLE_ONLY
Implementation-Vendor: Oracle
Implementation-Vendor-Id: com.oracle
Implementation-Version: 2.0.1
Specification-Title: Oracle Parcel Service 2.0 Utils Library
Specification-Vendor: Oracle
Specification-Version: 2.0
Then reference the shared library in weblogic.xml (WAR) or weblogic-application.xml (EAR):
<wls:weblogic-application
xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<!-- server-version: 10.3 -->
<wls:library-ref>
<wls:library-name>ops-util</wls:library-name>
<wls:specification-version>2.0</wls:specification-version>
<wls:implementation-version>2.0.1</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
</wls:weblogic-application>
精彩评论