On 31 August 2012 12:36, Minto van der sluis <[email protected]> wrote:

> Hi,
>
> Being an ISIS newby


A belated welcome!  It's good to see you here, and thanks for your interest
in our project.



> I have a question about integrating ISIS into
> existing code.



>
> We did some modelling with ISIS. Now we would like to integrate this
> into an existing application and have ISIS take care of storing and and
> loading data.
>
> Today I heard that the embedder is phased out. Is there any other way to
> achieve this?
>

In fact, the main bit of the embedded runtime module, namely the
IsisMetaModel, has been promoted up into core, as
org.apache.isis.core.progmodel.app.IsisMetaModel and so it hasn't been
phased out at all.  The bit that has been removed had very little value.

But let me step back a bit...

You can think of (I think of) Isis as being in four layers:
1. a viewer
2. a metamodel
3. a runtime
4. a back-end persistence mechanism / object store.

What the embedded module aimed to do was to extract out just (2).    This
is what the org.apache.isis.core.progmodel.app.IsisMetaModel  represents.

However, what you seem to want is (2) through (4).

If you look at the builder that IsisMetaModel provides
(IsisMetaModel#builder() ) , you can see that it takes two interfaces, the
org.apache.isis.core.metamodel.runtimecontext.RuntimeContext, and
the org.apache.isis.core.metamodel.progmodel.ProgrammingModel.

The RuntimeContext is a facade into (3); you need to provide an
implementation.  You could, if you want, use
the 
org.apache.isis.runtimes.dflt.runtime.persistence.internal.RuntimeContextFromSession,
which basically provides implementations of (3) and (4).  To do this,
you'll need to ensure that the runtime is bootstrapped each web request;
this can be using a filter:

    <filter>
        <filter-name>IsisSessionFilter</filter-name>

<filter-class>org.apache.isis.runtimes.dflt.webapp.IsisSessionFilter</filter-class>
        ...
    </filter>
    <filter-mapping>
        <filter-name>IsisSessionFilter</filter-name>
        <servlet-name>xxx</servlet-name>
    </filter-mapping>

Then, all you need is some means to provide an AuthenticationSession to the
filter.

~~~
As a variation to explicitly bootstrapping using IsisMetaModel, you could
just bootstrap using the techniques used by the current viewers.  This
doesn't give you an IsisMetaModel, but something broadly equivalent, and
IsisSystem.  (At some point we should dogfood this; for now though there
remain two different ways of doing the bootstrapping).

At any rate, what you do is add the following listener:

    <listener>

<listener-class>org.apache.isis.runtimes.dflt.webapp.IsisWebAppBootstrapper</listener-class>
    </listener>

>From the IsisSystem, you have an IsisSessionFactory and a bunch of other
stuff.  Either way, though, what you end up doing is reaching into
IsisContext (yes, service locator pattern, sorry about that) to get the
components you need.

~~~
Whichever approach you use for bootstrapping, if you are writing a custom
viewer (1) then you'll need to get familiar with the Isis API, namely
ObjectSpecification, ObjectAdapter, OneToOneAssociation,
OneToManyAssociation, ObjectAction and so on.  A particularly useful
utility class
is org.apache.isis.core.metamodel.interactions.InteractionUtils, which
helps enforce the business rules.

If you don't want to deal with the Isis API, then an alternative is to wrap
the pojos using the wrapping logic that the junit test support has.
Basically this boils down to
using 
org.apache.isis.progmodel.wrapper.metamodel.DomainObjectContainerWrapperFactory.
   Then you get a pojo which is wrapped with cglib and which will throw
exceptions if any business rules are violated (hidden, disabled,
validation).

You can provide this either in the IsisMetaModel's builders, or if using
the IsisSystem bootstrapping then you can provide an entry into
isis.properties ("isis.persistor.domain-object-container";
see 
org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract#createContainer(...)
method.

~~~
Hope all that is of some help, though I'm sure you'll have further
questions if you decide to go this route.

Cheers
Dan



>
> Regards,
>
> Minto
>

Reply via email to