How to reduce development cycles when building BlackBerry WebWorks or PhoneGap applications? - html

I'm interested in hearing how WebWorks developers are saving time during their development cycles by using any clever build processes / testing techniques.
What tips & tricks would you recommend to help reduce the amount of time it takes to build & test a WebWorks (or PhoneGap) application?
For example, here's a great suggestion (http://dborba.com/?p=274) from Demian Borba:
Build your app once, but configure it to load its start page from your dev web server
Make changes in that content, and they will be reflected when you re-launch your app (no need to recompile / redeploy the app)
Can even use Livereloader to make it even faster

If you use ant, here some target you will find useful:
<target name="zip" depends="init" description="Archive your files before building the bar" >
<zip
destfile="${build.dir}/${type.name}.zip"
basedir="${basedir}"
excludes="*.project,*.settings/,.*properties,*.svn,*.svn/*, builder/, .gitignore, .git/*"
includes="*,WebContent/"
/>
</target>
<target name="bar" depends="zip" description="create the bar file" >
<exec executable="${bbwp}">
<env key="JAVA_HOME" path="${sdk.JAVA_HOME}" />
<arg value="${build.dir}/${type.name}.zip"/>
<arg line="-o '${build.dir}'" />
<arg line="-v" />
<!-- Allows debugging on port 1337 -->
<arg line="-d" />
<!-- Sign to Appworld -->
<!-- <arg line="-g ${keyPass} - -buildId 10" /> -->
</exec>
</target>
<target name="install" depends="bar" description="Deploy the the .bar file to your simulator. The old application is automatically uninstalled." >
<java jar="${BarDeploy.dir}/BarDeploy.jar"
fork="true"
maxmemory="512M"
>
<env key="JAVA_HOME" path="${sdk.JAVA_HOME}" />
<arg value="-installApp" />
<arg value="-launchApp" />
<arg value="-password" />
<arg value="${password}" />
<arg value="-device" />
<arg value="${simIP}" />
<arg value="-package" />
<arg value="${bar.file}" />
</java>
</target>
<target name="uninstall" description="Uninstall an application from the Simulator. " >
<java jar="${BarDeploy.dir}/BarDeploy.jar"
fork="true"
maxmemory="512M"
>
<env key="JAVA_HOME" path="${sdk.JAVA_HOME}" />
<arg value="-uninstallApp" />
<arg value="-password" />
<arg value="${password}" />
<arg value="-device" />
<arg value="${simIP}" />
<arg value="-package" />
<arg value="${bar.file}" />
</java>
</target>
Here an exemple of the variable for a windows environment:
<property name="password" value=""/>
<property name="simIP" value="169.254.0.1" />
<property name="keyPass" value="" />
<property name="sdk.HOME" location="C:\Program Files\Research In Motion\BlackBerry 10 WebWorks SDK 1.0.1.8" />
<property name="build.dir" location="${basedir}\build" />
<property name="bar.file" location="${build.dir}\device\${type.name}.bar" />
<property name="sdk.JAVA_HOME" location="C:\Program Files\Java\jre6" />
<property name="bbwp" location="${sdk.HOME}\bbwp.bat" />
<property name="BarDeploy.dir" location="${sdk.HOME}\dependencies\tools\lib" />

Blackberry has just released the official Ant build script

Related

Creating json but sending XML out instead in WSO2 ESB

In WSO2 ESB 4.8.1, implemented an API, which receives json message, and will send new json payload to the backend. I debug the API and I saw that it is convert my json payload to xml and then send it to the backend.
FYI: I have un-commented the json stream formatter and builder in axis2 config files.
the api source is:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse" name="SdpProductStatus" context="/SdpServices/1/Aggregator/Product/Status">
<resource methods="POST">
<inSequence>
<property name="messageType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="ContentType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="productId" expression="json-eval($.productId)" scope="default" type="STRING" />
<property name="customerId" expression="json-eval($.customerId)" scope="default" type="STRING" />
<property name="description" expression="json-eval($.description)" scope="default" type="STRING" />
<property name="time" expression="json-eval($.time)" scope="default" type="STRING" />
<property name="state" expression="json-eval($.state)" scope="default" type="STRING" />
<log />
<property name="time" expression="concat(substring($ctx:time,1,4),'-',substring($ctx:time,5,2),'-',substring($ctx:time,7,2),' ',substring($ctx:time,10,2),':',substring($ctx:time,12,2),':',substring($ctx:time,14,2))" scope="default" type="STRING" />
<script language="js">mc.setProperty("state", mc.getProperty("state").replace("0","deactive")); mc.setProperty("state", mc.getProperty("state").replace("1","active"));</script>
<property name="POST_TO_URI" value="true" scope="axis2" />
<property name="REST_URL_POSTFIX" value="ActiveOrDeactive" scope="axis2" type="STRING" />
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2" type="STRING" />
<property name="messageType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<property name="ContentType" value="application/json; charset=utf-8;" scope="axis2" type="STRING" />
<header name="Accept" scope="transport" value="application/json" />
<header name="Content-Type" scope="transport" value="application/json" />
<header name="ContentType" scope="transport" value="application/json" />
<payloadFactory media-type="json">
<format>{"productID":"$1","CustomerID":"$2", "Time":"$3","State":"$4","tempData":"$5","Description":"$6","Username":"$7","Password":"$8", "Instruction":"$9"}</format>
<args>
<arg evaluator="xml" expression="$ctx:productId" />
<arg evaluator="xml" expression="$ctx:customerId" />
<arg evaluator="xml" expression="$ctx:time" />
<arg evaluator="xml" expression="$ctx:state" />
<arg evaluator="xml" value="temp" />
<arg evaluator="xml" expression="$ctx:description" />
<arg value="test1" />
<arg value="test1" />
<arg value="create" />
</args>
</payloadFactory>
<log>
<property name="body" expression="json-eval($.)" />
</log>
<send buildmessage="true">
<endpoint>
<address uri="http://10.8.10.10:8080/service1.svc/" />
</endpoint>
</send>
</inSequence>
<outSequence>
<log />
<property name="message" expression="json-eval($.MESSAGE)" scope="default" type="STRING" />
<filter source="json-eval($.STATUS)" regex="-?\d.*">
<then>
<property name="statusCode" value="200" scope="default" type="STRING" />
</then>
<else>
<property name="statusCode" expression="json-eval($.STATUS)" scope="default" type="STRING" />
</else>
</filter>
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<header name="Accept" scope="transport" value="application/json" />
<payloadFactory media-type="json">
<format>{"productId":$1,"id":"$2","customerId":"$3","status":{"statusCode":$4,"message":"$5"}}</format>
<args>
<arg evaluator="xml" expression="$ctx:productId" />
<arg evaluator="xml" value="55" />
<arg evaluator="xml" expression="$ctx:customerId" />
<arg evaluator="xml" expression="$ctx:statusCode" />
<arg evaluator="xml" expression="$ctx:message" />
</args>
</payloadFactory>
<header name="Content-Type" scope="transport" value="application/json" />
<send />
</outSequence>
</resource>
</api>
And this is what I get in the backend:
<jsonobject>....my payload converted to xml...</jsonobject>
Can you <header name="Content-Type" scope="transport" value="application/json" /> before building payloadFactory?
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<header name="Accept" scope="transport" value="application/json" />
<header name="Content-Type" scope="transport" value="application/json" />
OR
Try like following, here I skip the "evaluator="xml"".
<args>
<arg expression="$ctx:productId"/>
<arg value="55"/>
<arg expression="$ctx:customerId"/>
</args>

wso2 API Manager - How to publish an API using a template?

I have been experimenting with wso2 API Manager 1.8.0 to expose a back end(http/post) system as a REST API. I am able to get it working, but I had to edit the API configuration through the Service Bus source view as pasted below. I would like to have the same template used for all of the new APIs that get published using API Publisher to ensure that we don't have to edit the service bus source every time an API get created.
Please suggest any options that you may have used..
<inSequence>
<script language="js" key="transform_script" function="buildQueryString"/>
<property name="uri.query" expression="get-property('queryString')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<property name="Authorization"
expression="fn:concat('Basic ', base64Encode('testuser:testuser#1'))"
scope="transport"/>
<send>
<endpoint name="testuser--AddNumbers_APIsandboxEndpoint_0">
<http method="POST"
uri-template="https://testhost:8443/test/http/6731cc67-3850-4b9b-b486-62cf2a664b46?${uri.query}"/>
</endpoint>
</send>
<bam>
<serverProfile name="bam-profile">
<streamConfig name="org_wso2_apimgt_statistics_destination" version="1.0.0"/>
</serverProfile>
</bam>
</then>
<else>
<property name="Authorization"
expression="fn:concat('Basic ', base64Encode('testuser:testuser#1'))"
scope="transport"/>
<send>
<endpoint name="testuser--AddNumbers_APIsandboxEndpoint_0">
<http method="POST"
uri-template="https://testhost:8443/test/http/6731cc67-3850-4b9b-b486-62cf2a664b46?${uri.query}"/>
</endpoint>
</send>
<bam>
<serverProfile name="bam-profile">
<streamConfig name="org_wso2_apimgt_statistics_destination" version="1.0.0"/>
</serverProfile>
</bam>
</else>
</filter>
</inSequence>
<outSequence>
<payloadFactory media-type="json">
<format>
{
"apiName": "$1",
"apiVersion": "$2",
"runResponse":
{
"runId": "$3",
"runStart": "$4",
"runEnd": "$5",
"flowResponse": "$6",
"flowResult": "$7"
}
}
</format>
<args>
<arg evaluator="xml" expression="get-property('apiName')"/>
<arg evaluator="xml" expression="get-property('apiVersion')"/>
<arg evaluator="json" expression="$.runResponse.runReturn.item[0].value"/>
<arg evaluator="json" expression="$.runResponse.runReturn.item[3].value"/>
<arg evaluator="json" expression="$.runResponse.runReturn.item[4].value"/>
<arg evaluator="json" expression="$.runResponse.runReturn.item[5].value"/>
<arg evaluator="json" expression="$.runResponse.runReturn.item[6].value"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
There appears to be some documentation for the older versions of API Manager about the API template under <APIM_HOME>/repository/resources/api-templates/default_api_template.xml file.
With API Manager 1.8.0, I can not find the same documentation page but editing the velocity_template.xml works for non-prototype API definitions.
I am still trying to incorporate my requirements into it.
Actually you want to do some do some transformation for your message. APIM 1.8 supports mediation extension. where you can add your own in,out and fault sequence and have your transformation there. this mediation extension support for globally and per api basis. you can find the details here[1]
so if you create a global level sequence it will be applied to all apis.In your case you have to create one global insequnce to add basic oauth related stuff and one global out sequence to add payload factory related stuff
1.https://docs.wso2.com/display/AM180/Adding+Mediation+Extensions

java.lang.NoClassDefFoundError: org.eclipse.core.launcher.Main error while installing an EAR on Webshpere 8.0

I am trying to auto deploy an EAR using hudson on Websphere 8.0. I have written a script for it and while executing the script it shows the following error.
I am using hudson and have configured a job which executes the following build.xml. I tried to install the ear generated from admin console of websphere and it works fine when installed manually but fails when trying to install from hudson it throws the above error.
[wsInstallApp] Installing Application [C:\Users\.hudson\jobs\Websphere Deploy\workspace\ESREAR-1.0-SNAPSHOT.ear]...
[wsadmin] Exception in thread "main" java.lang.NoClassDefFoundError: org.eclipse.core.launcher.Main
[wsadmin] at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:371)
[wsadmin] at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:142)
[wsadmin] Caused by: java.lang.ClassNotFoundException: org.eclipse.core.launcher.Main
[wsadmin] at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
[wsadmin] at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:665)
[wsadmin] at java.lang.ClassLoader.loadClass(ClassLoader.java:644)
[wsadmin] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
[wsadmin] at java.lang.ClassLoader.loadClass(ClassLoader.java:627)
[wsadmin] ... 2 more
my build.xml is as follows
<?xml version="1.0" encoding="iso-8859-1" ?>
<project name="Auto Deployer for Jenkins" default="deploy" basedir=".">
<!-- Ant-Contrib (if, foreach, etc.) -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="C:/autobuild/WebSphere/Builder/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- WebSphere admin task -->
<taskdef name="wsAdmin" classname="com.ibm.websphere.ant.tasks.WsAdmin" />
<!-- Convert workspace path to forward slashes -->
<path id="toConvert1">
<pathelement location="${workspace}"/>
</path>
<pathconvert dirsep="/" property="workspaceConvert" refid="toConvert1"/>
<property name="wasroot" value="c:/opt/IBM/WebSphere/Profiles/base" />
<property name="user" value="iapawas01" />
<property name="password" value="IAPawas01" />
<target name="install">
<propertyregex property="appname" input="${earfile}"
regexp="([A-Za-z_]*)-(.*)"
select="\1"
defaultvalue=""
override="true"/>
<echo message="Application file ${earfile}"/>
<echo message="Application name ${appname}"/>
<echo message="Uninstalling application" />
<wsAdmin wasHome="${wasroot}" conntype="SOAP" host="${was_soaphost}" port="${was_soapport}" user="${user}" password="${password}" lang="jacl" script="deploy.jacl" failonError="false">
<arg value="uninstall"/>
<arg value="${workspaceConvert}"/>
<arg value="${appname}"/>
<arg value="${earfile}"/>
<arg value="${was_cell}"/>
<arg value="${was_node}"/>
<arg value="${was_server}"/>
<arg value="${was_vhost}"/>
</wsAdmin>
<echo message="Installing application" />
<wsAdmin wasHome="${wasroot}" conntype="SOAP" host="${was_soaphost}" port="${was_soapport}" user="${user}" password="${password}" lang="jacl" script="deploy.jacl" failonError="true">
<arg value="install"/>
<arg value="${workspaceConvert}"/>
<arg value="${appname}"/>
<arg value="${earfile}"/>
<arg value="${was_cell}"/>
<arg value="${was_node}"/>
<arg value="${was_server}"/>
<arg value="${was_vhost}"/>
</wsAdmin>
</target>
<target name="deploy">
<fileset dir="${workspace}" id="earfiles.list">
<include name="**/*.ear"/>
</fileset>
<pathconvert property="earfiles" refid="earfiles.list" pathsep=",">
<map from="${workspace}\" to=""/>
</pathconvert>
<foreach
list="${earfiles}"
target="install"
param="earfile"/>
</target>
</project>
What fix pack are you currently on?
There is a similar defect which was fixed in v8.0.0.3:
http://www-01.ibm.com/support/docview.wss?uid=swg1PM50904
If you're below 8.0.0.3 then you may want to try and apply fix pack 3 or even the latest release (fix pack 9) to see if it helps.

Example of using a TraceSource with Common.Logging

I've read this question and I know its possible:
Common.Logging for TraceSource
Can someone please post an example.
Also it could be helpfull if it can be configured to use the TraceSource in code instead of using the .config file.
Thanks
If your goal is to have Common.Logging forward messages to a TraceSource, then your logger name and tracesource name have to match.
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="ALL" />
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
<arg key="useTraceSource" value="true" />
</factoryAdapter>
</logging>
</common>
<system.diagnostics>
<sources>
<source name="SomeSourceName" switchName="YourSwitch">
<listeners>
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Application"/>
</listeners>
</source>
</sources>
<switches>
<add name="YourSwitch" value="Information"/>
</switches>
</system.diagnostics>
</configuration>
And from code you write:
var logger = Common.Logging.LogManager.GetLogger("SomeSourceName");
Hope this helps even though the post is 2 months old and the tracesouce is setup via .config.

How to build a SWC with documentation

UPDATE
solved: embed doc with swc
solved: weird param names: param0, param1, etc.
I created a swc lib using compc.
Then I created the lib doc with asdoc.
But I dont know how to bind them together, since when I use the .swc in another project params names are weird (like myMethod(param0:Number)) and there is no doc description.
I'm using Ant, this is my config file:
<?xml version="1.0" encoding="utf-8" ?>
<project name="uil" default="compile" basedir=".">
<property name="flexsdk" location="C:/sdks/flex_sdk_4.6/bin"/>
<property name="compc" location="${flexsdk}/compc.exe"/>
<property name="asdoc" location="${flexsdk}/asdoc.exe"/>
<property name="src" location="../src"/>
<property name="bin" location="../bin"/>
<target name="compile" depends="doc">
<exec executable="${compc}" failonerror="true">
<arg line="-debug=false" />
<arg line="-optimize=true" />
<arg line="-strict=true" />
<arg line="-locale=en_US" />
<arg line="-include-sources=${src}" />
<arg line="-output=${bin}/uil.swc" />
</exec>
</target>
<target name="doc">
<exec executable="${asdoc}" failonerror="true">
<arg line="-main-title 'UIL API Documentation'" />
<arg line="-window-title 'UIL API Documentation'" />
<arg line="-source-path ${src} -doc-sources ${src}" />
<arg line="-output ${bin}/uil-asdoc" />
</exec>
</target>
</project>
Edit: How it was solved
The line that make all the magic is this:
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
Then I replaced all my <exec> tags to <compc> and <asdoc> and everything worked. You can see the entire code here.
Try to use zip ant target as in the build.xml of the Starling framework:
<!-- call asdoc to generate dita xml files -->
<asdoc output="${temp.dir}" lenient="true" failonerror="true" keep-xml="true" skip-xsl="true" fork="true">
<compiler.source-path path-element="${basedir}/src" />
<doc-sources path-element="${basedir}/src" />
</asdoc>
<!-- update swc with asdoc xml -->
<zip destfile="${deploy.dir}/${ant.project.name}.swc" update="true">
<zipfileset dir="${temp.dir}/tempdita" prefix="docs">
<include name="*.*"/>
<exclude name="ASDoc_Config.xml" />
<exclude name="overviews.xml" />
</zipfileset>
</zip>