Posts

Showing posts with the label Java

Scala Hexagon Tessellation

Image
I've committed myself for 2015 to learn Scala , and I wish I did that earlier after 20 years of Java (wow, that makes me sound old :-).  I've placed on Github a simple Scala based library to compute the row/column pair of a planar x/y value on a hexagonal grid. Will be using that library in following posts... In the meantime, like usual, all the source code is available here .

MongoDB + Spring + Mobile Flex API for ArcGIS = Harmonie

Image
I've used MongoDB on a project for the City of Chicago with great success.  I was impressed with the fact that we can store JSON documents in one giant collection, scale horizontally by just adding new nodes, the plethora of language APIs (Java,AS3) that can talk to it, run MapReduce tasks, and my favorite is that you can create a true spatial index on a document property.  This is not some BTree index on a compounded x/y properties, but a true spatial index that can be used to perform spatial operation such as near and within.  Today, Mongo only supports point geometries, but I understand that they are working on storing and spatially indexing lines and polygons and enabling other spatial operations. I've experimented with great success in an intranet in consuming BSON object directly from Mongo into a Flex based application, but the direct socket connection is a problem in a web or mobile environment. In addition, what I wanted was some middle tier that can turn my ...

How Oracle Can Improve Java

Found this great article "15 Ways Oracle Can Make Java Better (and Improve Its Stance with Developers)" - here is my "in the weed" take: Keep JavaONE - with heavy focus on developers. Embrace OSGi down in the core VM. Kill JavaFx - Work closer with Adobe on Flex / BlazeDS / LCDS . Improve Dynamic Language Support - groovy / scala / JRuby / Jython /etc... Talk to Google about ME (seriously?) / Android Kill NetBeans - Eclipse may be King, but IntelliJ is God ! Introduce new language primitives XML / Function / JSON. Improve language - set/get bean, native String ( switch myString {case "foo": ...}) as for casting. LINQ for Java - LCDS can help here. Talk to the Spring folks - there-is-only-one-framework-zuul :-) No "Effing" store ! So....what do you think ?

GoogleAppEngine and BlazeDS

Google released a java version of the AppEngine . So I was very excited and wanted to see if I can host an application based on the Spring BlazeDS Integration framework. All was fine until I deployed the application and got a "Class Not Found" Exception. Looking at the log found the following: java.lang.management.ManagementFactory is a restricted class. Please see the Google App Engine developer's guide for more details. Check the docs and there is a list of "white-list" classes, and java.lang.management is not there :-(. Was so close! oh well, back to EC2 :-)

Serializing Geometries To BlazeDS

Was asked if there is a way to serialize the geometries of a Flex client application using for example BlazeDS . And the answer is 'yes'. All geometries are tagged with a [RemoteClass] metadata. Here is the break down (BTW - this is subject to change in the next version): SpatialReference com.esri.ags.ASSpatialReference MapPoint com.esri.ags.geometry.ASPoint Polyline com.esri.ags.geometry.ASPolyline Polygon com.esri.ags.geometry.ASPolygon Here is for example the Java side of MapPoint : package com.esri.ags.geometry; import com.esri.ags.ASSpatialReference; public class ASPoint implements IASGeometry { public double x; public double y; public ASSpatialReference spatialReference; } The following is a very simple client application that calls a RemoteObject to save a MapPoint instance: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout=...

Generate AS3 VOs from Jar file

A lot of AS3 value object generators assume that you have the source code. However sometimes you are not privy to this information :-( So here is a java program that reads the content of a jar file and creates AS3 VOs. Like this post, I'm using StringTemplate to generate the files. And this other post was very helpful too. I'm using IntelliJ as my IDE and it lets me generate an executable jar. The following is the usage: java -jar class2as3.jar jarPath packageName outputPath You can download the source code from here .

SpringSource Application Platform

The SpringSource folks announced the beta release of an Application Platform . This is very cool, where in the past you had to have a web server to start up Spring. And if you are a big fan of OSGi and Spring-DM (like I am) you know what a pain it was to wedge all that together. And if you think about it, it was a chicken and egg problem. Well no more, this platform does it "right", where it starts the JVM, the OSGi platform ( Equinox ), the new Dynamic Module Kernel™ (dm-Kernel) and then the bundles. Remember back when SpringSource bought or aligned (do not remember which) with the Tomcat folks, well Tomcat is now a web bundle. This is very cool - next is to move it onto EC2 .

Glassfish on OSGi

Not to say that I predicted this at the last JavaONE - but JBoss is going to be based on OSGi and now so is Glassfish . Too cool - you will see more and more web servers will be based on OSGi and with Spring-DM to wire your POJOs - That is how you write enterprise software. Blogged with the Flock Browser

Java To AS3 on AIR

Image
Found this great project that enables me to convert Java code to ActionScript3 code, or at least get me close enough that I can do minor manual tweaks to get code to compile (granted that compiled code does not mean that it runs :-). However, in its current format, it was a laborious process as I can only process one file at the time, and had to copy and paste the generated code from the text area into a file. There must be a better way ! And yes there is a better way using Adobe AIR . AIR enables me to read from and write to the local file system. So, I took the core Converter class and wrapped it with the AIR File api. A user can now select the output folder and upon the selection of the input folder, all the java files will be read, converted and written to the output folder. In addition, you can drag and drop onto the output or input button the output or input folder. Download the AIR file from here . BTW - this is using the latest beta3 version :-)

Granite Data Services

I love Life Cycle Data Services . As a developer, IMHO, I think it is worth its weight in gold. However, I do get customers that want to do remoting with it :-( So...since HTTPService and WebService are first class citizens in Flex, I recommend that they SOAP enable their server side services, or come up with some kind of XML representation and XML over HTTP since XML is a native type in AS3. But the serialization/deserializtion is costly, and it would be great if we can use the flash native binary format (AMF) to transfer objects around. Thus enters Granite . Quoting from the introduction "Granite Data Services (GDS) is a free, open source (LGPL'd), alternative to Adobe® LiveCycle® (Flex™ 2) Data Services for J2EE application servers. It is not, however, a drop-in replacement: you won't be able to simply deploy a Flex 2 Data Services application into a Granite Data Services server without modifications. The main goal of this project is to provide a framework for Flex 2/EJ...

IntelliJ 7 Rocks

I've been using IDEA since I do not remember when.   Just got a license to the latest version .  It has great Spring support, and now you can see your web.xml files in this wizard cool panes.  In addition, there is support of AS3, I mean with auto-completion and refactoring. Too cool ! Blogged with Flock

Cairngorm and the Framework

People have been asking me to show them how to use Cairngorm with the AWX Framework that is loosely based on OSGi. The interaction will most likely come in an ICommand implementation or a Delegate.  Here is an example that shows how to use the Find Service. First, make sure that you have registered with the Framework the FindActivator. <Framework apiKey="[your-api-key]">   <FindActivator/> </Framework> Next, since a Command is always created and executed by the CairngormEventDispatcher,  you can always get a reference to the Framework through its static function getInstance() and then get a reference to systemBundleContext which is an IBundleContext implementation. package com.esri.awx {     import com.adobe.cairngorm.commands.ICommand;     import com.adobe.cairngorm.control.CairngormEvent;     import com.esri.aws.osgi.framework.Framework;     import com.esri.aws.osgi.framework.IBundleContext; ...

Flex and OSGi

The AWX framework is based on a simplified OSGi implementation in AS3. The advent of flex modules made this implementation possible. The following is a simple walk-through that showcases how to use this solution. The idea is to define an interface whose implementation can be defined and discovered at runtime. Using FlexBuilder as a project manager makes things a bit easier. Create a flex library project named "FooAPI" to define the following interface. A SWC "FooAPI.swc" is generated upon the build in the "bin" directory. package com.esri.awx { public interface IFoo { function doFoo( text : String ) : String; } } Create a flex actionscript project named "FooBundle" - make sure to add the AWX swc as a project library and the "FooAPI" project. Modify the FooBundle.as class as follows: package { import com.esri.aws.osgi.framework.IBundleActivator; import com.esri.aws.osgi.framework.IBundleContext; import com.esri.awx.FooImpl; import ...