Dynamic list of contexts and singletons

88 views
Skip to first unread message

pkc...@gmail.com

unread,
Apr 27, 2013, 11:51:49 PM4/27/13
to activate-p...@googlegroups.com
First, congrats on the nice performance results at http://databen.ch/

Ok, now my question.  If each context must be a singleton and accessed with an import statement, how can I instantiate a lists of separate contexts of the same type on start up? 

I have a program that reads in a list of Oracle data sources and then finds differences between records in a specific table in each database.

I see that there is a default storage for each context and you can have additional storages based on entity class but I think I need a list of contexts where each on has its own default storage. 


Flavio W. Brasil

unread,
Apr 28, 2013, 8:27:05 AM4/28/13
to pkc...@gmail.com, activate-p...@googlegroups.com
Hi.

Normally the persistence context is a singleton, but it can be instantiated as a normal class too. It is necessary to specify which entities each context will persist: http://activate-framework.org/documentation/persistence-context/#multiple_contexts.
There is an important limitation for now. It is not possible bind the same entity class for more than one context or storage.
Your approach to merge the storages information will use the same entity class persisted in more than one storage?


Cheers,

-- 
Flávio W. Brasil

--
You received this message because you are subscribed to the Google Groups "Activate Persistence Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

pkc...@gmail.com

unread,
Apr 28, 2013, 8:38:46 PM4/28/13
to activate-p...@googlegroups.com, pkc...@gmail.com
It should use the same entity class in all storages.  The applications reads the same table from each db, then creates a new table in memory that compares the data.  The in memory table has one extra column specifying the db source.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persistence+unsub...@googlegroups.com.

Flavio W. Brasil

unread,
Apr 29, 2013, 10:25:38 PM4/29/13
to pkc...@gmail.com, activate-p...@googlegroups.com
Hi Paul.

Unfortunately your usage scenario is not supported for now. It probably will be supported in the next versions by the entity partitioning feature.

Regards,

-- 
Flávio W. Brasil

To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.

leonard....@gmail.com

unread,
Apr 10, 2014, 9:59:37 PM4/10/14
to activate-p...@googlegroups.com, pkc...@gmail.com
Hi,

I have the same need here to be able to support multi-tenancy in a application. Each tenant has a different database name. So I need either a context with multiple storages or multiple contexts. I don't need to manipulate data from one tenant to another. Currently, it seems storage "routing" is done through Entity type, Entity java Class to be precise. I can have Entities defined as inner classes of a Model, and instantiate a model for each tenant, but this information is not retained by java Class object. I wonder if there is a reason (other than being used from Java world?) not to use Scala Types (http://www.scala-lang.org/api/2.10.2/index.html#scala.reflect.api.Universe) instead of Java classes, as they retain much more information and would easily enable these use cases. Also, if somebody could give some guidance on how Entity classes are used for storage "routing", I'm ready to give a try to modifying code to try Scala Types (well, if this is indeed a good idea).

BR,


Leo

leonard....@gmail.com

unread,
Apr 10, 2014, 11:02:09 PM4/10/14
to activate-p...@googlegroups.com, pkc...@gmail.com, leonard....@gmail.com
BTW, can you tell more about Entity partitioning?

Flavio W. Brasil

unread,
Apr 17, 2014, 2:51:13 AM4/17/14
to leonard....@gmail.com, activate-p...@googlegroups.com
Hi Leo,

I’m really sorry for the late reply. I hope to be yet on time to answer.

Multi-tenancy is something not supported by Activate yet. I think use Scala Types to “bind” the entities to different contexts can be an alternative, but this approach requires to have multiple context instances.

I think the ideal solution is to extend the polyglot mechanism to allow routing the entities to a specific storage. Using this approach, it is possible to have only one persistence context instance. It is also relatively simple to implement.

Let me know if you are wiling to work on this, so we can discuss in detail. Another alternative is to open a github issue so it can be prioritized in the roadmap.

Cheers,

-- 
Flavio W. Brasil

--
You received this message because you are subscribed to the Google Groups "Activate Persistence Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Léonard Schneider

unread,
Apr 17, 2014, 9:48:53 AM4/17/14
to activate-p...@googlegroups.com, leonard....@gmail.com
Hi Flavio,

Thanks for the reply. And yes, this is still something I'm looking to solve. And if it is relatively easy, this is a good news, since adding columns for multi-tenant in an existing schema impacts the whole application and will cost me much more rather than working a little to get a DB for each. It is also much more flexible and scalable.

I've already forked the Github project and just joined the Google group. Just need some guidance on how to reach the objective.

BR,


Leo
Reply all
Reply to author
Forward
0 new messages