You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2012/10/12 10:32:19 UTC

Re: isis service inject in version 0.3.1 snapshot

On 12 October 2012 09:04, 张峰昌 <al...@gmail.com> wrote:

> Dear All
>
> Hi Alain, and welcome.

This question might be best directled to isis-users, so I've cc'ed this
reply  there.

fyi, I suggest that you subscribe to that list (mailto:
isis-users-subscribe@incubator.apache.org).  But by all means subscribe to
this list too (mailto:isis-dev-subscribe@incubator.apache.org) if you are
interested in contributing to Isis in the future.




> Can anyone tell me how to inject service into another one? For example I
> want to inject OrgnizationRepository into ProductRepositoryInMemory.
>
> I have follewd the instruction according to the doc online which said about
> inject service into domain object by provided the  public setXXX, while it
> can not work when I inject inject OrgnizationRepository into
> ProductRepositoryInMemory. The exception is:
>
> org.apache.isis.core.metamodel.spec.ObjectSpecificationException: Service
> object com.thingray.product.dom.ProductRegisterService should have no
> fields, but has: organizationRepository, productRepository
>
>
The short answer is: you do need a setter, but must have no public getter
for that injected service.  The fix is simply either to remove that getter,
or to mark it as protected, package or private visibility.

If that doesn't fix things (or you don't have a public getter but even so
are still having the exception), then let us know.

Thx
Dan