Author Topic: Accessing the running instance of EA from Java  (Read 3743 times)

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Accessing the running instance of EA from Java
« on: February 12, 2009, 12:45:25 am »
Does someone know what the Java equivalent is for the follwing code:

using System.Runtime.InteropServices;
...
object obj = Marshal.GetActiveObject("EA.App");
EA.App app = obj as EA.App;
EA.Repository rep = app.Repository;

This is supposed to get a reference to the running instance of EA.

Thanks! :exclamation

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Accessing the running instance of EA from Java
« Reply #1 on: February 12, 2009, 02:31:12 am »
From a quick glance at my code:

Code: [Select]

org.sparx.EARepository eaRepository = new org.sparx.Repository();
if (eaRepository == null)
            {
                //error handling here...
                return false;
            }

        if (!eaRepository.OpenFile(CONNECTION))
        {
             //error handling here...
            return false;
        }

Note that this will not give you access to a running instance but opens a new instance (defined in the connection string). AFAIK there is no way to access the running instance from JAVA via the DCOM bridge.

Oliver

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Accessing the running instance of EA from Java
« Reply #2 on: February 12, 2009, 03:25:40 am »
Thanks for your reply Oliver, but this seems to throw me an error when I do a Repository.GetModels().
I get an "Internal application error".
If I open a Repository through openFile...I have no Issues (not always at least), but I would like to get the Models for the open instance of EA.

My plan is to open a network repository and then use it as if it where sitting on my local machine...for this I need a current running EA instance
reference.

Thanks!

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Accessing the running instance of EA from Java
« Reply #3 on: February 12, 2009, 03:56:36 am »
Quote
If I open a Repository through openFile...I have no Issues (not always at least), but I would like to get the Models for the open instance of EA.

As I said above- afaik you can not access an already open instance from the JAVA API.
I'd be glad if someone can prove me wrong here as I need that functionality, too.

Oliver

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Accessing the running instance of EA from Java
« Reply #4 on: February 12, 2009, 08:08:18 am »
Sorry, it's not currently possible.