|
|
In my previous post I shared an example showing data paging for flex. The most important subfeatures of our ‘managed data paging’ feature are:
We put together another example visualizing how memory management work. The example works with a database table containing 2.6 million records. Any time a page of data is loaded or removed from memory, the visualization component reflects it by drawing or removing a line. You can see the example in action in the video below. The source code and the database script are available at the bottom of the post. Enjoy! Source code and database: This post documents a pre-requisite step for the JavaScript Integration Course, but it is also useful if you’re doing Java development with Eclipse and WebORB. The instructions in this post will help you configure your development environment so you can develop Java services with Eclipse and have them deployed into Tomcat. Once deployed, your Java services can be consumed (methods can be invoked) by any client supported by WebORB, that is JavaScript, iOS, Android, Flex/AIR, Flash and Silverlight. To get started, make sure to download and install Eclipse IDE for Java EE Developers. Also, you will need an installation of WebORB for Java. When you download WebORB, you get an installer packaged as a JAR file. Make sure to run the installer and accept all the default settings in the installation. Finally, install the Tomcat server. This post assumes you have the latest version of Eclipse (Eclipse Juno v. 4.2), Tomcat 7.0 and WebORB version 5, however, the instructions are applicable to the older versions of the software as well. Registering Tomcat as s ServerLocate buy cheap cialis the “Servers” tan in Eclipse and define a new server using the wizard:
In the “New Server Wizard”, expand the “Apache” node and select “Tomcat 7.0 Server” as shown below:
Click “Next >”. In the next step you need to specify the location of your Tomcat 7 installation. Click the Browse button and locate the root directory of the Tomcat installation:
Click “Finish” to complete the Tomcat configuration. The server should appear in the Servers tab as shown below:
Configuring a Web ProjectThe next step is to configure an Eclipse project. The project will contain the code for the services which will be deployed into Tomcat/WebORB. From the Eclipse’s main menu select File > New > Dynamic Web Project. Assign the name to the project (these instructions assume the project name is PhonebookService. Also make sure the target runtime is “Apache Tomcat v7.0″ (the server runtime was configured in the previous step). Finally, make sure “Default Configuration for Apache Tomcat v.7.0″ is selected in the drop down box in the Configuration section:
Click “Next >”. There are no changes in the next step, so click “Next >” again. Click the “Generate web.xml deployment descriptor” checkbox:
Click “Finish” to finalize project creation. Adding WebORB to the ProjectTo streamline the development WebORB should be added to the project and become a part of the web application. Adding WebORB to the project consists of three to four simple steps:
Register WebORB servletLocate and expand the WebContent folder in the project’s structure in Project Explorer. The folder should have the web.xml file which is a deployment descriptor for the web application. Right-click the file and select Open With > Text Editor. Eclipse opens the file for editing. Make sure to modify the file to look as shown below:
<br /><br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /><br />
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;3.0&quot;&gt;<br /><br />
&lt;display-name&gt;PhonebookService&lt;/display-name&gt;<br /><br />
&lt;listener&gt;<br /><br />
&lt;listener-class&gt;weborb.ORBServletContextListener&lt;/listener-class&gt;<br /><br />
&lt;/listener&gt;<br /><br />
&lt;servlet&gt;<br /><br />
&lt;servlet-name&gt;weborb&lt;/servlet-name&gt;<br /><br />
&lt;servlet-class&gt;weborb.ORBServlet&lt;/servlet-class&gt;<br /><br />
&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br /><br />
&lt;/servlet&gt;<br /><br />
&lt;servlet&gt;<br /><br />
&lt;servlet-name&gt;download&lt;/servlet-name&gt;<br /><br />
&lt;servlet-class&gt;weborb.DownloadServlet&lt;/servlet-class&gt;<br /><br />
&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br /><br />
&lt;/servlet&gt;<br /><br />
&lt;servlet-mapping&gt;<br /><br />
&lt;servlet-name&gt;weborb&lt;/servlet-name&gt;<br /><br />
&lt;url-pattern&gt;*.wo&lt;/url-pattern&gt;<br /><br />
&lt;/servlet-mapping&gt;<br /><br />
&lt;servlet-mapping&gt;<br /><br />
&lt;servlet-name&gt;download&lt;/servlet-name&gt;<br /><br />
&lt;url-pattern&gt;/codegen.wo&lt;/url-pattern&gt;<br /><br />
&lt;/servlet-mapping&gt;<br /><br />
&lt;welcome-file-list&gt;<br /><br />
&lt;welcome-file&gt;weborbconsole.html&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;default.html&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;<br /><br />
&lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;<br /><br />
&lt;/welcome-file-list&gt;<br /><br />
&lt;/web-app&gt;<br /><br />
Add Configuration FilesRight-click the WEB-INF folder under WebContent in the project structure and select New > Folder. Type “flex” for the folder name and click Finish. Eclipse creates a new folder under WEB-INF. Right click the new flex folder and select the Import menu option. In the Import window that appear select File System under General. Click “Next >” to continue. Click Browse and navigate to the WebORB installation directory. From there navigate further to webapp/WEB-INF/flex and click “Open”. Select all the files as shown below and click “Finish”.
The next step is adding the main WebORB configuration files. The files will eventually reside in the WEB-INF/classes directory of the deployed web application, but since eclipse rewrites that directory every time when it runs Tomcat, the files must be placed into the “src” folder. Locate and expand the “Java Resources” node in the root of the project structure. Right click the “src” node and select the “Import” menu item. Select “File System” under “General” and click “Next >”. Click “Browse” and navigate to the WebORB’s installation directory. From there navigate further to webapp/WEB-INF/classes and click “Open”. Select weborb-config.xml and weborb-acl.xml as shown below and click “Finish”:
Add WebORB Jar fileIn the minimal deployment WebORB requires only one jar file – weborb.jar. Additional jar files should be added by following the same steps depending on the functionality used by the services and/or WebORB. The example reviewed in this post connects to a MySQL database, therefore two jar files will be added – weborb.jar and the mysql database driver library. Locate and right-click the lib node under WebContent\WEB-INF node in the project structure. Select the “Import” menu item. Select “File System” under “General” and click “Next >”. Click “Browse” and navigate to the WebORB’s installation directory. From there navigate further to webapp/WEB-INF/lib. Click “Open” and select “mysql-connector-java-5.1.13-bin.jar” and “weborb.jar” as shown below. Click “Finish” to import the files.
Add WebORB Console (optional, but recommended)Right-click the WebContent node in the project structure. Select New > Folder and create a folder “console”. Right click the newly created “console” folder and select the “Import” menu item. Select “File System” under “General” and click “Next >”. Click “Browse” and navigate to the WebORB’s installation directory. From there navigate further to the “webapp/console” directory. Select all the files as shown below and click “Finish”.
Finally import “weborbconsole.html” from [WEBORB INSTALL DIR]/webapp/ into the WebContent node in the project structure (the import steps are the same as described earlier). Once all the configuration, JAR and console files are added, the project structure should look as shown below:
Adding Web Application to TomcatAt this point the project contains the minimally required configuration for WebORB. In order to deploy the project into the Tomcat server configured at the beginning of this post, locate and right-click “Tomcat v7.0 Server at localhost” in the Servers tab. Select the “Add and Remove” menu option:
In the “Add and Remove” window select “PhonebookService” in the “Available” column and click “Add >” to move it to the “Confgured” column as shown below. Click “Finish” to continue.
Adding Java ServiceTo add a Java service to the project locate and right-click the “src” node under “Java Resources”. Select the New > Package menu item and enter com.tmc.blog for the package name. The next step is add to a class to the package. This post uses the Java Backend Service provided in the JavaScript Integration Course post. Right-click the com.tmc.blog node and select the New > Class menu item. Enter Phonebook for the class name and click “Finish” to finalize class creation. Replace the contents of the created class with the code from the Java Backend Service post. Running Tomcat and WebORBClick the “Start the server” button (green circle with a white triangle) in the “Servers” tab. Eclipse launches an instance of Tomcat and deploys the PhonebookService web application into it. You should see the logging output from WebORB as well in the “Console” tab. Once Tomcat starts, open a browser and enter http://localhost:8080/PhonebookService/weborb.wo to open the WebORB Management Console. Once the console starts up, select the Services tab in the WebORB Management Console, expand the WEB-INF/classes node and navigate to the Phonebook service (you will need to expand the “com”, “tmc” and “blog” nodes as well). The Phonebook node represents the class with the same name and contains the methods of the class. Expand the Phonebook node and click the “createListing” method. Enter values for the “name” and “phonenumber” arguments and click “Invoke”. The console invokes the method via WebORB and the service creates a record in the database (see the service’s code for details). Now you can click the “getListings” node and click Invoke. The console invokes the method and displays the results of the method invocation.
The subsequent post will review other development/deployment options, for instance, developing with IntelliJ IDEA and deploying into the standalone version of WebORB. After that, the series will continue with the development of the JavaScript client for the Phonebook service. This post continues the Java Integration Course. See the introduction post for an overview as well as instructions for setting up the database. In this post we add a very simple Java backend service which will be used by the JavaScript client in the subsequent development steps. Take a look at the Java code below:
<br />
package com.tmc.blog;</p>
<p>import java.sql.*;</p>
<p>public class Phonebook<br />
{<br />
/*<br />
The connectionURL consists of 3 to 4 parts, depending on if you have<br />
permissions set up for your mySQL database.</p>
<p> Part 1: "jdbc:mysql://localhost" refers to the url of your mySQL server.<br />
Part 2: "3306" refers to the port that mySQL server is running on.<br />
3306 is the default port for mySQL.<br />
Part 3: "phonebook" this is the name of the database that we will be<br />
interacting with.<br />
Part 4: "?username=blah&password=blah" - Optional.<br />
This query string is used for passing the username and password<br />
*/<br />
private String connectionURL = "jdbc:mysql://localhost:3306/phonebook?user=phonebookuser&password=password";<br />
private Connection conn;<br />
private Statement statement;</p>
<p> public Phonebook()<br />
{<br />
try<br />
{<br />
Class.forName( "com.mysql.jdbc.Driver" ).newInstance();<br />
this.conn = DriverManager.getConnection( connectionURL );<br />
this.statement = conn.createStatement();<br />
}<br />
catch( Exception ex )<br />
{<br />
ex.printStackTrace();<br />
}<br />
}</p>
<p> public ResultSet getListings() throws SQLException<br />
{<br />
try<br />
{<br />
String sql = "SELECT id, name, phonenumber FROM listing";<br />
ResultSet listings = statement.executeQuery( sql );</p>
<p> return listings;<br />
}<br />
catch( SQLException ex )<br />
{<br />
// handle any errors<br />
System.out.println( "SQLException: " + ex.getMessage() );<br />
System.out.println( "SQLState: " + ex.getSQLState() );<br />
System.out.println( "VendorError: " + ex.getErrorCode() );</p>
<p> throw ex;<br />
}<br />
}</p>
<p> public void createListing( String name, String phonenumber ) throws Exception<br />
{<br />
try<br />
{<br />
String sql = "insert into listing set name = ?, phonenumber = ?";<br />
PreparedStatement statement = conn.prepareStatement( sql );<br />
statement.setString( 1, name <a href='http://1buycialisonline.org/' title='buy cialis'>buy cialis</a> );<br />
statement.setString( 2, phonenumber );<br />
statement.execute();<br />
}<br />
catch( SQLException exception )<br />
{<br />
exception.printStackTrace();<br />
throw exception;<br />
}<br />
}<br />
}<br />
At this point the service can do the following:
The code assumes you created the user with the “phonebookuser” name and assigned “password” as the user’s password. Over the course of the subsequent posts in this series, the code will get enhanced and expanded with additional functionality, but at this point, we will keep it as simple as possible until we get some basic integration in place. The next post will focus on configuring IDEA and Eclipse to compile and deploy the service into WebORB as well as validating that the service works. WebORB is very well known for its integration capabilities for Flex and Flash clients, but is is an equally powerful integration server for the JavaScript clients as well (both mobile and desktop). In the next series of posts I’d like to demonstrate how easy it is to build a JavaScript application and integrate it with the backend service using WebORB as the integration server. The application I am going to build and document via a series of blog posts is rather simple, but it is representative of a lot of use-cases developers run into when building enterprise or consumer apps. The application will demonstrate basic buy cialis online remote procedure calls (RPC) between JavaScript and Java/.NET, asynchronous calls, retrieving data from a database, updating/deleting/creating database records. Later on I will show how to build the same application using WebORB’s data management framework. Finally, I will delve into publish/subscribe messaging for the JavaScript clients and show how to use JavaScript WebSockets with the WebORB’s messaging APIs. To start you will need to install the MySQL database server and execute the following script which creates a database used by the application:
<br /> -- MySQL Administrator dump 1.4<br /> --<br /> -- ------------------------------------------------------<br /> -- Server version 5.1.38</p> <p>/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;<br /> /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;<br /> /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;<br /> /*!40101 SET NAMES utf8 */;</p> <p>/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;<br /> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;<br /> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;</p> <p>--<br /> -- Create schema phonebook<br /> --</p> <p>CREATE DATABASE IF NOT EXISTS phonebook;<br /> USE phonebook;</p> <p>--<br /> -- Definition of table `phonebook`.`Listing`<br /> --</p> <p>DROP TABLE IF EXISTS `phonebook`.`Listing`;<br /> CREATE TABLE `phonebook`.`Listing` (<br /> `id` int(11) NOT NULL AUTO_INCREMENT,<br /> `name` varchar(100) DEFAULT NULL,<br /> `phonenumber` varchar(15) DEFAULT NULL,<br /> PRIMARY KEY (`id`)<br /> ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;</p> <p> You can also download the script from: http://examples.themidnightcoders.com/blog/phonebook.sql Once the database is created, it is important to create a database user with the username “phonebookuser” and the password set to “password”. Grant all the privileges to the “phonebook” schema to the “phonebookuser” user. Once the database is setup, you will need to configure your development environment:
The next post will explore the server-side code. You will compile and deploy the backend service and try invoking the methods with the WebORB management console.
A complete list of changes is available in the Release History.
A complete list of features and bug fixes is available on the WebORB for Java Release History page. Enjoy! In Shanghai, when you enjoy a Nuru Massage, you can uncover essentially the most pleasurable at last when you are moist, so you should also prepare to use a warm, steamy shower or bath for your partner. Just take your time, and tease every other with erotic foreplay. If you finish, don’t dry your bodies off, but think about the Nuru Gel from the water and pour some in to the bowl beside the area precisely wherever you’ve determined on to complete the sensual massage in Shanghai. Best Elements: You may check out spreading vinyl sheets above your bed or even the place wherever you would prefer to do the therapeutic massage in acquiring the perfect slippery sensation. You should not do the massage on something with a delicate finish. To start this kind of massage: Let your partner relax in the comfy place with their head to the towel. Ordinarily folks favor to rest with their manage pointing to 1 aspect or even the other, and their arms relaxed at their sides. Sleek the warm blend of Nuru Gel and water above their physique in tiny handfuls, making it possible for it to run all more than their physique and yours as effectively. There are many sauna club in Shanghai can provide the Nuru therapeutic massage such as the following. 1. Hot sea sauna center If you develop with Flash Builder and use WebORB, read on, you will greatly enjoy this new functionality. The functionality is not entirely new, we had the plugin for quite some time. The main problem most users have encountered with the plugin was the installation process. We have fully reimplemented the plugin and added better integration support in the product itself. The plugin now can be installed using Eclipse’s standard plugin installation process. To get started, make sure to download and install the latest nightly build of the product (or version 4.5 once it becomes available). To install the plugin:
For the instructions on how to use the plugin, see WebORB documentation: We have updated our product build system to deliver nightly product builds to you. When you login to our download center and select WebORB for .NET or WebORB for Java, you will see a list of the nightly builds available for download. The nightly builds deliver all the latest updates and bug fixes we’re adding while working toward the next product release. Please keep in mind that the nightly builds are not certified by our QA as “production ready” code, however, the code delivered through the nightly builds does pass our minimally required set of tests. We need your feedback |