Re: How to get domain from context

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 02 2009 - 03:54:11 EDT

  • Next message: akira: "Re: How to get domain from context"

    Hi akira,

    If you need explicit access to the domain, you will have to cast you
    ObjectContext to DataContext and use 'getParentDataDomain':

    DataDomain domain = ((DataContext) context).getParentDataDomain();

    Andrus

    On Sep 2, 2009, at 10:45 AM, akira wrote:

    > Hi, i'm getting my context this way: ObjectContext context =
    > DataContext.getThreadObjectContext(). How to know the domain that
    > the context is using? If i get context as a DataContext type i can
    > obtain the domain using : getParentDataDomain().getName() right? On
    > my app i have to change the domain under certain circumstancies and
    > on my code i'm trying to do something like this:
    > ObjectContext context = DataContext.getThreadObjectContext()
    > if (context.getDomain() == domainToQueryNow) {
    > return context;
    > } else {
    > DataContext.createDataContext(domainToQueryNow);
    > }
    >
    > TIA.



    This archive was generated by hypermail 2.0.0 : Wed Sep 02 2009 - 04:06:23 EDT