[Google Android Client Platform] Extending the Platform
Last modified by sasindarukshan on 2012/08/04 14:11
Please refer to platform user guide for basic information about the platform.
Extending Data Access Layer
Data.RDB
Adding a new Table/Entity to Database.
In the org.xwiki.android.data.rdb.EntityManager
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource)
{
try {
Log.i(EntityManager.class.getSimpleName(), "onCreate(): create Database");
add TableUtils.createTable(connectionSource, MyEntity.class); for all your entities
TableUtils.createTable(connectionSource, User.class);
TableUtils.createTable(connectionSource, FSDocumentReference.class);
TableUtils.createTable(connectionSource, SyncOutEntity.class);
TableUtils.createTable(connectionSource, OurNewEntity.class);
} catch (SQLException e) {
Log.e(EntityManager.class.getName(), "Can't create database", e);
throw new RuntimeException(e);
}
}
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource)
{
try {
Log.i(EntityManager.class.getSimpleName(), "onCreate(): create Database");
add TableUtils.createTable(connectionSource, MyEntity.class); for all your entities
TableUtils.createTable(connectionSource, User.class);
TableUtils.createTable(connectionSource, FSDocumentReference.class);
TableUtils.createTable(connectionSource, SyncOutEntity.class);
TableUtils.createTable(connectionSource, OurNewEntity.class);
} catch (SQLException e) {
Log.e(EntityManager.class.getName(), "Can't create database", e);
throw new RuntimeException(e);
}
}
Extending Xwiki Application Context
The XWiki Application Context is there to provide IoC. API users are advised to use it to get concrete instances for their dependencies on major components. We do this to keep our flexibility.
Add a method to create an instance of such a component when there can be more than one implementations for it.
Conventions
ctx.getComponent() when you may receive the same component again and again
ctx.newComponent() you receive a new instance of the component.
Example.
We have provided
public class XWikiApplicationContext extends Application implements XWikiApplicationContextAPI
{
...
public FileStoreManager getFileStoreManager()
{ ...
public RESTfulManager newRESTfulManager()
{ ...
{
...
public FileStoreManager getFileStoreManager()
{ ...
public RESTfulManager newRESTfulManager()
{ ...