Nature of Objects in Aspire - journal

satya - 8/19/2020, 11:27:26 AM

About

1. This is running notes on object creation facilities in Aspire

2. Related classes

3. Related factories

4. Objects are very often initiated from configuration file

satya - 8/19/2020, 11:29:41 AM

Objects in Aspire are often created from configuration files

1. Given an interface, instantiate its implementation from config file

2. So created objects are by default singletons

3. Can be made multiinstance at compile time by extending an interface (ISingleThreaded)

satya - 8/19/2020, 11:30:33 AM

Objects in Aspire are 2 kinds at a fundamental level

1. POJO like objects that can be singleton or multi instance

2. Functions that can be singleton or multi instance

satya - 8/19/2020, 11:32:57 AM

Functions can be composed in pipelines to call each other

1. Functions can create other objects like a factory

2. Functions can return data from databases

3. Functions can return hierarchical objects

4. Functions can read files, databases, json, xml etc.

satya - 8/19/2020, 11:34:55 AM

Aspire peels (naturally) configuration from logic

1. Aspire has a natural tendency to peel logic from configuration as most objects are driven by configuration

2. This enables declarative programming

3. This also provides significant out of the box backward compatibility

satya - 8/19/2020, 11:43:17 AM

Consider this


//consider a psuedo interface with methods
interface IFile {m1, m2, m3}

//Have a couple of implementations
SomeClass1 implements IFile {}
SomeClass2 implements IFile {}

//in a config file
request.file.classname=SomeClass1

//You can do this in code now
IFile file = AppObjects.getObject("file");
file.m1()

//AppObjects is a utility that  invokes the 
//underlying factory

//file is a singleton here.

You can  make it a multi instance

SomeClass1 implements IFile, ISingleThreaded {}

satya - 8/19/2020, 11:44:49 AM

AppObjects is a static class ...

1. it is a static class

2. it is a utility class

3. Has static methods that spin the Application level services such as configuration, logging, and factory that controls object instantiation.

4. See the source code of this class to see how it works and what methods it has

satya - 8/19/2020, 11:48:08 AM

Primary interfaces to control object instantiation

0. No interface all. Pure POJO (Singleton)

1. IInitializable //init method is called

2. ISingleThreaded //tag that says multi instance

3. ICreate //This object is a function

4. A combination of these interfaces control the behavior of the class being instantiated.

satya - 8/19/2020, 11:51:04 AM

How do you decide which interfaces to implement for your class?

1. Object: See first if you are an object that confirms to an interface with multiple methods. If so you don't want to be a function or you don't want to extend ICreate (there are some exceptions)

2. Function: See if your job is a single method that DOES something like reads or write, every time it is created or called. Then you want to extend ICreate

satya - 8/19/2020, 11:54:02 AM

There are some base classes and interfaces that tries to make this behavior variations formal

DBProcedure //function singleton

DBProcedureObject //function multi instance

DBJavaProcedure //function, like a stored proc i n java

DataObject //experimental object (not a function)

SimpleDataObject

DynamicDataObject

ServiceObject

IMultiInstanceObject //POJO object (not a function)

IFactoryPart //function. base class of pipelines

AFactoryPart //Mostly inherited

AFactoryPart1 //some specialized functioality

satya - 8/19/2020, 12:14:08 PM

Aspire as an AppServer or App relies on 3 interfaces


ILog //for logging
IConfig //for a hierarchical configuration files (basic, xml, json)
IFactory //a way to apply policies and instantiate objects
IApplication //a container for the above 3

satya - 8/19/2020, 12:14:35 PM

This article primarily focuses on the factory interface

This article primarily focuses on the factory interface

satya - 8/19/2020, 12:16:09 PM

There are multiple instances of IFactory implementations

1. Currently I use Factory4

2. You can write your own if you like

3. See the source code of Factory4 to tease out minute details of the behavior of objects created

satya - 8/19/2020, 12:16:26 PM

So look up the source code for Factory4

So look up the source code for Factory4

satya - 8/19/2020, 3:01:05 PM

On github "a" version of this factory4 is here

On github "a" version of this factory4 is here

satya - 8/19/2020, 3:01:47 PM

A number of other previous versions of the factory are here: in the default pkg for an application

A number of other previous versions of the factory are here: in the default pkg for an application