Saturday, April 12, 2014

Usergrid sub-projects information

This is a small article that uses the readMe files in the stack project of Apache Usergrid so that enthusiasts can get the information from one location without going through the file structure. 

Keep in mind that the files may have been changed by the time you are reading this though.
This will help you get the basic idea. Enjoy !

User- Grid- Stack

The user-grid-stack consists of a parent maven project with the following modules.

Modules:

Built-tools

Holds key configuration files for build plugins (Contains resources like the checkstyle.xml).

 

Config

Runtime config resources of Usergrid system are contained here.

 

Core

This contains the core services for Usergrid system.
Usergrid-core contains the persistence layer [m1] [Mm2] and shared utilities for powering the Usergrid service. The services layer is contained in Usergrid-services and exposes a higher-level API that's used by the Usergrid-rest web services tier.

Launcher

Usergrid Launcher is a graphical server launcher.
The launcher is a simple Java app that provides a GUI for running the server as a desktop app.

 

Mongo emulator

This provides the Mongo emulation layer for the Usergrid system[m3] [Mm4] . This is still experimental and incomplete implementation of Mongo emulation layer so Mongo clients can connect to Usergrid.
There are a number of drivers and tools for talking to Mongo DB, which has a data model that is very similar to that of Usergrid. In order to make it easier for people to get started quickly with Usergrid, it's desirable for them to be able to integrate it very quickly into their existing applications.
The goal here is to support the Mongo native wire protocol and to map enough of the query and CRUD operations so that this can happen.

Rest

This contains the REST web services for Usergrid system (Usergrid REST API Web App).
This installs as a web-app in Tomcat and has not been extensively tested in other web containers.
See Usergrid-standalone for an example of running inside Grizzly.

Services

This contains the Service layer for Usergrid system.
This is where most of the high-level functionality for accessing Usergrid data is performed. It functions as the glue between the REST API as exposed by Jersey and the entity management functionality in Usergrid-core. This is also where security and account management functionality is contained.
The security model of Usergrid is implemented with Apache Shiro: http://shiro.apache.org/
The services model for Usergrid involves converting the REST web service requests into collection queries and routing these to a set of collection handlers.  [m5] [Mm6] This provides a "virtual collection" layer on top of the actual collections that are exposed in the persistence tier.  This makes it possible to:
- implement logic behaviour on top of persistent objects
- enforce object and property visibility
- perform fine-grained permission checks

 

Test-utils

This contains the test utilities for Usergrid system as implied by the name.

 

Tools

This contains the command line tools for Usergrid system as implied by the name.
The Usergrid Tools are a set of Java programs that can be run from a command-line console.

Websocket

This contains the WebSocket API for Usergrid system. It is still an experimental (incomplete) implementation of Websocket API.  Websockets info can be found at http://en.wikipedia.org/wiki/WebSockets
The Websocket API will allow for asynchronous communications with the Usergrid API.
OAuth credentials are put in the query string of the initial GET request since the JavaScript Websocket API provides no mechanism for specifying header contents.
Once a connection is established, there are two mechanisms of usage.
Async Request/Response
The first is to simply access the API the same way as the REST interface provides, except over the open websocket connection. The benefit is there is much less overhead than with the REST API since there is no processing of individual HTTP requests and authentication credentials are checked at the time the websocket is opened as opposed to per-request as is necessary with the stateless REST API.

Subscriptions
The second is to issue subscribe requests against entities and collections and be notified asynchronously as those are updated. Subscriptions against the activity inbox and message queue collections for either users, groups, or the entire application allow connected applications to get real-time updates.
Connecting to an inbox or queue in the websocket URL will automatically start a subscription to that collection. For example, the following websocket URL will listen to a specific user's inbox:
ws://api.usergrid.com:8088/chatapp/users/johndoe/inbox
This is the real-time equivalent of making a regular REST GET request to:
http://api.usergrid.com/chatapp/users/edanuff/inbox
Usergrid listens to websockets on an alternate port than it does standard HTTP requests. Although websockets can coexist on the same ports 80 or 443, Tomcat and other Java servlet containers don't do a particularly great job of handling open async socket connections despite what they claim. For our purposes, we're using a bare metal Netty websocket server that listens on port 8088. This is going to be much more performant that trying to integrate it into Tomcat and allows us to move the websocket servers onto different machines.


Sunday, January 12, 2014

NSInvalidArgumentException that propagated all the way to my main class.

If you are here, you  probably got a NSInvalidArgumentException. Below is what I got, and even if your one is not the same, hopefully the explanation will help you solve yours:



Here is why this came all the way up:
- My application uses a documentInteractionController

  • It resides in a class
  • Helps to figure out 3rd party applications on my iOS device I can use to open certain files from my application
  • once it does and I go back to my application... bang ! my app exists, mugshot of the culprit is above
This is because the documentInteractionController fires callbacks, and unfortunately in my application the class was released and no longer available. Since the class is no where to be found, the OS cannot call the callback methods and we get the above error. (callbacks are methods that fire after certain events, in this case the method "didEndSendingToApplication" fires to let us know that the 3rd party application got my file)

-To rectify:
  • I had to retain the documentInteractionController (and also the parent view due to some specifics of my application)
  • Release it after the callbacks were fired.
Read a bit on memory management in iOS and ARC (automatic reference counting)


You basically the 'retain' keyword to keep your objects around and then 'release' it after you are done. 
Make sure you cover all paths if you do so, you are interfering with the memory management, so cover your tracks well and avoid memory leaks. Even though you might not see any visible side effects,  we should always write quality code :) 

Hope this helps someone :)

iOS 7 has added a background colour to your table cell


In iOS 7 we noticed a white background for the UITableView we were using. Whereas on iOS 6 the same code gave us a transparent background, thus enabling the background image to be visible as required by the App's owner.
This was a change done in iOS 7, so if you want to support it, do a version check and something similar to the following:  

//  (iOS 6 cell is transparent by default not on iOS 7).

      //do a version check, if it is iOS 7 run the below code
        cell.backgroundColor = [UIColor clearColor];
    


You can use a callback method such as the one below to add your code if you are not sure where to place it:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
     if([AppDelegate iSIOS7OrAbove]){  // iSIOS7OrAbove is not a method that comes out of the box. write the logic you want in a custom method to do the check.
        cell.backgroundColor = [UIColor clearColor];
    }

}


Hope this helped someone :)

Tuesday, July 30, 2013

Blackberry Application Resource Monitor Shut Down

Hello,

If you wind up on this page you must be getting a Blackberry Application Resource Monitor (ARM) Shut Down and have no idea why.
ARM, if I am not mistaken was introduced from 7.0 on-wards. This monitors the applications and can be configured. If there is too much activity from your application when it is in the background, or when the screen is locked, it will give you warnings and shut down your application. This way there is no unnecessary background activity and it saves the device resources like the battery.

I was unable to find the cause for such warning in my application. Hunted down every thread I had that was doing work, debugged and was at constant battle to find the cause, but the threads seem fine. That is when I came across the Class BasicFilteredList, this has a method 'setMinimumRefreshInterval'. This basically refreshes the data set according to the given interval. Even when the application was in the background or the screen was locked the refresh still happened. As a work around I detected when the application is going to the background and when the screen is locked and set a larger value to the refresh interval. Then decreased the interval again when I noticed the application in the foreground. Maybe this is your issue as well, putting it on the blog so it might help someone else as well.

Useful links:

http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/collection/util/BasicFilteredList.html#setMinimumRefreshInterval(long)

http://devblog.blackberry.com/2012/05/application-resource-monitor/


Monday, May 6, 2013

Changes/deprecations (without additions) from API 16 to 17 - Android 4.1 to 4.2

Hello,

This post is nothing much, I have just used the reference: http://developer.android.com/sdk/api_diff/17/changes.html to get the changes/ deprecations without the additions from Android API 16 to 17.  Using this you should be able to see the changes/deprecations without actually having to click on the individual links. However if you find what you are looking for in this post, go to the above link and verify just to be sure and to do a quality job. I captured it to the best of my ability :) .
This post will be useful if you are looking at setting your code target to 17 and do not want to see any deprecations. Hope this helps :) 

Class android.app.PendingIntent


Changed Methods
String getTargetPackage()
Now deprecated.

Class android.appwidget.AppWidgetProviderInfo


Changed Methods
AppWidgetProviderInfo clone()
Change in return type from Object toAppWidgetProviderInfo.
Change in exceptions thrown from
java.lang.CloneNotSupportedException to no exceptions.
Method was inherited from 
java.lang.Object, but is now defined locally. Change of visibility from protected to public.



Class android.bluetooth.BluetoothA2dp


Changed Methods
void finalize()
Change in exceptions thrown from java.lang.Throwable to no exceptions.
Method was inherited from 
java.lang.Object, but is now defined locally. Change of visibility from protected to public.



Class android.content.Context

Changed Fields
Now deprecated.

Now deprecated.

Class android.content.IntentSender


Changed Methods
String getTargetPackage()
Now deprecated.

 

Class android.database.DatabaseUtils.InsertHelper

Removed Fields
int TABLE_INFO_PRAGMA_DEFAULT_INDEX


 

Class android.hardware.Sensor

Change from non-final to final.

Class android.location.LocationProvider


Changed Methods
int getAccuracy()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean hasMonetaryCost()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean requiresNetwork()
Changed from abstract to non-abstract.

boolean requiresSatellite()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean supportsBearing()
Changed from abstract to non-abstract.

boolean supportsSpeed()
Changed from abstract to non-abstract.

Class android.net.LocalSocket

Added interface java.io.Closeable.



Class android.os.PowerManager


Changed Fields
Now deprecated.

Now deprecated.


Class android.os.PowerManager.WakeLock

Change from non-final to final.

Class android.provider.Settings.Secure


Changed Fields
String ADB_ENABLED
Now deprecated.

String BLUETOOTH_ON
Now deprecated.

String DATA_ROAMING
Now deprecated.

Now deprecated.

Now deprecated.

String HTTP_PROXY
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

String WIFI_ON
Now deprecated.

Now deprecated.


Class android.provider.Settings.System


Changed Methods
boolean getShowGTalkServiceStatus(ContentResolver)
Now deprecated.

void setShowGTalkServiceStatus(ContentResolver,boolean)
Now deprecated.


Changed Fields
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

String DEBUG_APP
Now deprecated.

String DIM_SCREEN
Now deprecated.

String MODE_RINGER
Now deprecated.

Now deprecated.

String RADIO_CELL
Now deprecated.

String RADIO_NFC
Now deprecated.

String RADIO_WIFI
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.


Class android.text.format.DateFormat

Changed Methods
Change from final to non-final.

char[] getDateFormatOrder(Context)
Change from final to non-final.

DateFormat getLongDateFormat(Context)
Change from final to non-final.

DateFormat getMediumDateFormat(Context)
Change from final to non-final.

DateFormat getTimeFormat(Context)
Change from final to non-final.

CharSequence format(CharSequence,Calendar)
Change from final to non-final.

CharSequence format(CharSequence, Date)
Change from final to non-final.

CharSequence format(CharSequence, long)
Change from final to non-final.


Class android.text.format.DateUtils

Changed Methods
String getAMPMString(int)
Now deprecated.

String getDayOfWeekString(int, int)
Now deprecated.

String getMonthString(int, int)
Now deprecated.


Changed Fields
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.



Class android.view.Display

 

Changed Methods
Now deprecated.
           

Class android.view.Surface

Changed Methods
void unlockCanvas(Canvas)
Now deprecated.


Class android.view.View


Removed Fields
int TEXT_ALIGNMENT_RESOLVED_DEFAULT



Class android.view.WindowManager.LayoutParams

Changed Fields
Now deprecated.



Package android.webkit

Removed Classes
CacheManager

CacheManager.CacheResult


Changed Classes







Class android.webkit.WebChromeClient

Changed Methods
boolean onJsTimeout()
Now deprecated.

 

Class android.webkit.WebHistoryItem

Removed Methods
int getId()


Class android.webkit.WebSettings

Removed Methods
boolean getNavDump()

boolean getUseDoubleTree()

boolean getUseWebViewBackgroundForOverscrollBackground()

int getUserAgent()

void setNavDump(boolean)

void setUseDoubleTree(boolean)

void setUseWebViewBackgroundForOverscrollBackground(boolean)

void setUserAgent(int)


Changed Methods
Now deprecated.

Now deprecated.


Changed Fields
Now deprecated.


Class android.webkit.WebView

Changed Constructors
WebView(Context, AttributeSet, int,boolean)
Now deprecated.


Removed Methods
void debugDump()

void disablePlatformNotifications()

void emulateShiftHeld()

void enablePlatformNotifications()

int getVisibleTitleHeight()

boolean restorePicture(Bundle, File)

boolean savePicture(Bundle, File)


Changed Methods
boolean canZoomIn()
Now deprecated.

boolean canZoomOut()
Now deprecated.

float getScale()
Now deprecated.

void setCertificate(SslCertificate)
Now deprecated.

Now deprecated.


 

Class android.webkit.WebViewDatabase

Removed Fields
String LOGTAG


Class android.widget.CheckedTextView

Removed Methods
void onPaddingChanged(int)


Class android.widget.DigitalClock

Now deprecated.

Class android.widget.SlidingDrawer

Now deprecated.

Class android.widget.TextView

Removed Methods
void resetResolvedDrawables()

void resolveDrawables()


Changed Methods
void setPaddingRelative(int, int, int,int)
Method was locally defined, but is now inherited from View.


Class android.widget.TwoLineListItem

Now deprecated.