Monday, September 22, 2014

gradle wsdl2java plugin released

In one of my earlier posts, I described how you can use gradle to generate java source-code from wsdls. This included writing your own tasks, managing dependency etc.

Now, I have written a plugin for this, available at the gradle plugin portal. Go fetch it while it's fresh!

Gradle plugin portal: http://plugins.gradle.org/plugin/no.nils.wsdl2java
How to use the plugin: https://github.com/nilsmagnus/wsdl2java/blob/master/README.md

If you have any issues, please register them at https://github.com/nilsmagnus/wsdl2java/issues

Saturday, September 13, 2014

Dropwizard + gradle + heroku

Note: all source code is available at https://github.com/nilsmagnus/gradledwheroku

Since the gradle build pack for heroku is still in beta, it is sometimes not straight forward to use gradle with heroku. This is how I did it with gradle, dropwizard and heroku.
  • Use gradle wrapper, the built in gradle in heroku is still using version 1.0-beta or something. When you use the wrapper, you decide the gradle version yourself. 
  • Use the gradle application plugin
  • For some reason, you must have the dropwizard as a submodule in your gradle project.
  • When deploying the app to heroku, you must tell the app to use the $PORT specified by heroku to listen to http traffic. You set this configuration by setting the WEBAPP_OPTS variable on heroku. This variable is used by the gradle application plugin when launching your java app. The value might vary, depending on your conf.yaml-file. 
heroku config:set WEBAPP_OPTS-Ddw.server.applicationConnectors[0].port='$PORT'
  • The Procfile must point to the shell script generated by the application plugin and the arguments for your application
web: webapp/build/install/webapp/bin/webapp server conf.yaml

  • The dropwizard application itself does not need to have any special config to run on heroku. You can even connect to a mongodb hosted at mongolab without any problems. 


If you want a working starting point for your application, have a look at my github project https://github.com/nilsmagnus/gradledwheroku which is "heroku-ready". Clone it, change it, make it your own and deploy to heroku. 

Monday, April 28, 2014

Cxf wsdl2Java: using binding file to rename a complextype

Sometimes there is need to rename a complextype from the wsdl when you use wsdl2java. For example if you want the generated code to be put in a specific package (-p option) and you do not want to use the '-autoNameResolution' option. Then the external bindings file comes to the rescue! Here is the file I have used to rename "VatNumber_Exception" into "VatNumException"
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[1]">
<jxb:bindings node="//xs:complexType[@name='VatNumber_exception']">
<jxb:class name="VatNumException"/>
</jxb:bindings>
</jaxws:bindings>
</jaxws:bindings>
view raw bindings.xml hosted with ❤ by GitHub
Happy copying!

Sunday, February 16, 2014

Setting up a moving background with Corona SDK

I just created a simple moving background written in lua for Corona SDK. The source is as follows:
-- TODO: add your own image-file, I have used a file called bg1.png
local scrollSpeed = 2
-- Add First Background
local bg1 = display.newImageRect("bg1.png", display.contentWidth, display.contentHeight)
bg1.x = 0; bg1.y = display.contentHeight/2;
local bg2 = display.newImageRect("bg1.png", display.contentWidth, display.contentHeight)
bg2.x = display.contentWidth; bg2.y = display.contentHeight/2;
-- Add Third Background
local bg3 = display.newImageRect("bg1.png", display.contentWidth, display.contentHeight)
bg3.x = display.contentWidth*2; bg3.y = display.contentHeight/2;
local function moveBg(event)
-- move backgrounds to the left by scrollSpeed, default is 8
bg1.x = bg1.x - scrollSpeed
bg2.x = bg2.x - scrollSpeed
bg3.x = bg3.x - scrollSpeed
-- Set up listeners so when backgrounds hits a certain point off the screen,
-- move the background to the right off screen
if (bg1.x ) < -display.contentWidth then
bg1:translate( display.contentWidth*3, 0 )
end
if (bg2.x ) < -display.contentWidth then
bg2:translate( display.contentWidth*3, 0 )
end
if (bg3.x ) < -display.contentWidth then
bg3:translate( display.contentWidth*3, 0 )
end
end
-- Create a runtime event to move backgrounds
Runtime:addEventListener( "enterFrame", moveBg )
view raw movingbg.lua hosted with ❤ by GitHub
Use it as you wish!