Skip to content

Getting Started

Gautam edited this page Jun 30, 2017 · 16 revisions

Getting started

Goals

  • Optimize productivity The primary goal of AppOps is to optimize development productivity while retaining high performance of the backend and to make thing overall simpler. We intend to use instrumentation wherever possible to simply stuff such as using a generator to generate it's client TypeScript interface from a Java Service interface.

  • Keep it simple Our next goal is to keep backend development as simple as possible. DI frameworks such as Google Guice already provide simplified component / application development. As of now we bring on top a very simple service architecture that allows you to develop backend services in minutes and invoke them from client.

  • eliminate tech baggage Our last goal is to make sure resulting application code base have much longer life by guiding them into using best practices and patterns. Thus resulting in easy to maintain codebases. Re usability of code also has a bearing on this goal, thus AppOps strives to provide high level of reuse of user code developed.

Project structure

AppOps client projects are typically maven multi module projects consisting of multiple service projects and one or more ui projects where your webserver along with client codebases such as Angular + Typescript + html + css code, reside.

Step 1 - Create a maven multi module project

We take an example of gims ( stands for Great information management system - available in this repo as a sample)

Step 2 - Create a child web project

Once you have the parent project setup with packaging type of POM create a web project as a child. Lets call it gims-web.

Add all the following AppOps dependencies in this project. ( In a future release all the projects below will be available through a single dependency. For now you will need to add the dependencies separately.

Step 3 - Create as many service projects as you need

This helps you organise your code very easily by domain design. Service projects only need the following dependencies.

Step 4 - Now follow the steps below to define your services.

Define a Service

To illustrate, we'll build a Library service. it is an interface that becomes my service interface to be invoked from the client and Library service contain method declarations. This is implemented by LibraryServiceImpl class.

Design your service interface

This is the interface client code will invoke using TypeScript or other client technologies e.g.

public interface LibraryService { public List<Book> getAllBooks() ; }

Add @Service annotation

@Service public interface LibraryService { public List<Book> getAllBooks() ; }

Implement the Service class

public interface LibraryServiceImpl implements LibraryService { public List<Book> getAllBooks(){ ArrayList<Book> someBooks ; // fetch book list and assign to someBooks return someBooks ; } }

Define service binding in module

public class LibraryModule extends AbstractModule { public void configure(){ bind(LibraryService.class).to(LibraryServiceImpl.class); } }

Lets you define a service with all it's bindings. You can bind multiple Services to their implementations in a single module. You can also have as many modules as you need in a single service project. This module is a straightforward google Guice module. So please refer to Guice documentation for more further details.

Step 5 - Add the service as a dependency to the gims-ui

Once you are ready with this. All you need to do is package this project as a jar and add its dependency to the gims-ui project.

Step 6 - Configure maven plugin's to help generate typescript client interfaces for your project. As shown below

Please note the path elements in the plugin configuration. This is where you might struggle a bit so please pay attention.

Once properly configured you will be able to run the ts goal and bingo - it will generate the client interfaces + pojo's participating in those interface methods as a .d.ts file. This becomes your client typescript interface.

You can also take help of the Http.d.ts file from us to seamlessly invoke these interfaces from the client side. We also have gwt binding that we are using with our internal projects. Let us know if you need those.

You can reach me through my business website www.ainosoft.com or mail me at debasish [@] ainosoft.com. Just use the messaging feature on the site and send me a message with subject of AppOps support needed. I shall be happy to help.

Pull requests are more then welcome. Please fork and send me PR as you please against the nightly. I will be happy to review and merge as feasible.

If you have any special requirements I will be happy to build it for you. Just get in touch.

Do some benchmarking on the method invocation cycle. You will be pleasantly surprised at the performance of the framework. We have been able to fetch more then 20k of data in a single call within 100ms using an i5 / windows configuration. On linux boxes this number should be well under 60 milliseconds.

Let me know what you think and feel free to create issues and tag me .

Wish you a great time using AppOps. I shall be happy to have your contributions.

Once your services are defined you can generate TypeScript contracts for your service automatically and invoke them through simple annotations. Refer to generating TypeScript Contracts page for more details.