You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Pa...@b-m.pl on 2016/08/03 10:50:35 UTC

access DeltaSpike Data repository as EJB

Need to move my JPA and DeltaSpike repositories to EJB EAR module to allow 
access from two different WARs in the same EAR

What is recommnded approach to access DeltaSpike repository as EJB ?

For adhoc I created PersonService class annotated with @Stateless

@Stateless
public class PersonService {

        @Inject PersonRepository personRepository;

        public PersonRepository getRepository(){
                return personRepository;
        }
}

Do you have some other ideas ?

Paweł

Re: Re: access DeltaSpike Data repository as EJB

Posted by "John D. Ament" <jo...@apache.org>.
Agreed.  If you need transactions, you should be able to use our
@Transactional interceptor.  If you're trying to use a distributed
architecture using remote EJBs, I would recommend putting facades in front,
but maybe ideally expose a REST API instead?

John

On Wed, Aug 3, 2016 at 8:27 AM Rafael Pestano <rm...@gmail.com> wrote:

> Hi Paweł,
>
> just a 'dumb' question: does it needs to be an EJB? this information you
> need can't be exposed as a REST service? I'm saying that because I've been
> there and migrate lots of ears to wars and ejb modules to rest
> service...maybe it apples for your case too.
>
> 2016-08-03 9:21 GMT-03:00 <Pa...@b-m.pl>:
>
> > Hi John,
> >
> > It works as you said. I don't know how since it is in separate EJB module
> > but it works :)
> >
> > Just in case if the JPA / DeltaSpike module is in separate Server/JVM
> then
> > how to access the repositories as EJB ?
> >
> > best regards
> > Paweł
> >
> >
> >
> > Od:     "John D. Ament" <jo...@apache.org>
> > Do:     users@deltaspike.apache.org
> > Data:   2016-08-03 13:01
> > Temat:  Re: access DeltaSpike Data repository as EJB
> >
> >
> >
> > Hi Pawel,
> >
> > Creating them as EJBs shouldn't be required.  They're still CDI beans.
> In
> > the JAR that you expose, make sure the various deltaspike extensions are
> > activated in your javax.enterprise.inject.spi.Extension file.  Make sure
> > you have a valid beans.xml to discover all beans.
> >
> > At a minimum you need the repository extension and bean provider.  You
> > should then be able to inject them.  Please do post back if this gives
> you
> > some trouble, happy to help.
> >
> > John
> >
> > On Wed, Aug 3, 2016 at 6:50 AM <Pa...@b-m.pl> wrote:
> >
> > > Need to move my JPA and DeltaSpike repositories to EJB EAR module to
> > allow
> > > access from two different WARs in the same EAR
> > >
> > > What is recommnded approach to access DeltaSpike repository as EJB ?
> > >
> > > For adhoc I created PersonService class annotated with @Stateless
> > >
> > > @Stateless
> > > public class PersonService {
> > >
> > >         @Inject PersonRepository personRepository;
> > >
> > >         public PersonRepository getRepository(){
> > >                 return personRepository;
> > >         }
> > > }
> > >
> > > Do you have some other ideas ?
> > >
> > > Paweł
> >
> >
>
>
> --
> Att,
>
> Rafael M. Pestano
>
> Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> http://rpestano.wordpress.com/
> @realpestano
>

Re: Re: access DeltaSpike Data repository as EJB

Posted by Rafael Pestano <rm...@gmail.com>.
Hi Paweł,

just a 'dumb' question: does it needs to be an EJB? this information you
need can't be exposed as a REST service? I'm saying that because I've been
there and migrate lots of ears to wars and ejb modules to rest
service...maybe it apples for your case too.

2016-08-03 9:21 GMT-03:00 <Pa...@b-m.pl>:

> Hi John,
>
> It works as you said. I don't know how since it is in separate EJB module
> but it works :)
>
> Just in case if the JPA / DeltaSpike module is in separate Server/JVM then
> how to access the repositories as EJB ?
>
> best regards
> Paweł
>
>
>
> Od:     "John D. Ament" <jo...@apache.org>
> Do:     users@deltaspike.apache.org
> Data:   2016-08-03 13:01
> Temat:  Re: access DeltaSpike Data repository as EJB
>
>
>
> Hi Pawel,
>
> Creating them as EJBs shouldn't be required.  They're still CDI beans.  In
> the JAR that you expose, make sure the various deltaspike extensions are
> activated in your javax.enterprise.inject.spi.Extension file.  Make sure
> you have a valid beans.xml to discover all beans.
>
> At a minimum you need the repository extension and bean provider.  You
> should then be able to inject them.  Please do post back if this gives you
> some trouble, happy to help.
>
> John
>
> On Wed, Aug 3, 2016 at 6:50 AM <Pa...@b-m.pl> wrote:
>
> > Need to move my JPA and DeltaSpike repositories to EJB EAR module to
> allow
> > access from two different WARs in the same EAR
> >
> > What is recommnded approach to access DeltaSpike repository as EJB ?
> >
> > For adhoc I created PersonService class annotated with @Stateless
> >
> > @Stateless
> > public class PersonService {
> >
> >         @Inject PersonRepository personRepository;
> >
> >         public PersonRepository getRepository(){
> >                 return personRepository;
> >         }
> > }
> >
> > Do you have some other ideas ?
> >
> > Paweł
>
>


-- 
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano

ODP: Re: access DeltaSpike Data repository as EJB

Posted by Pa...@b-m.pl.
Hi John,

It works as you said. I don't know how since it is in separate EJB module 
but it works :)

Just in case if the JPA / DeltaSpike module is in separate Server/JVM then 
how to access the repositories as EJB ?

best regards
Paweł



Od:     "John D. Ament" <jo...@apache.org>
Do:     users@deltaspike.apache.org
Data:   2016-08-03 13:01
Temat:  Re: access DeltaSpike Data repository as EJB



Hi Pawel,

Creating them as EJBs shouldn't be required.  They're still CDI beans.  In
the JAR that you expose, make sure the various deltaspike extensions are
activated in your javax.enterprise.inject.spi.Extension file.  Make sure
you have a valid beans.xml to discover all beans.

At a minimum you need the repository extension and bean provider.  You
should then be able to inject them.  Please do post back if this gives you
some trouble, happy to help.

John

On Wed, Aug 3, 2016 at 6:50 AM <Pa...@b-m.pl> wrote:

> Need to move my JPA and DeltaSpike repositories to EJB EAR module to 
allow
> access from two different WARs in the same EAR
>
> What is recommnded approach to access DeltaSpike repository as EJB ?
>
> For adhoc I created PersonService class annotated with @Stateless
>
> @Stateless
> public class PersonService {
>
>         @Inject PersonRepository personRepository;
>
>         public PersonRepository getRepository(){
>                 return personRepository;
>         }
> }
>
> Do you have some other ideas ?
>
> Paweł


Re: access DeltaSpike Data repository as EJB

Posted by "John D. Ament" <jo...@apache.org>.
Hi Pawel,

Creating them as EJBs shouldn't be required.  They're still CDI beans.  In
the JAR that you expose, make sure the various deltaspike extensions are
activated in your javax.enterprise.inject.spi.Extension file.  Make sure
you have a valid beans.xml to discover all beans.

At a minimum you need the repository extension and bean provider.  You
should then be able to inject them.  Please do post back if this gives you
some trouble, happy to help.

John

On Wed, Aug 3, 2016 at 6:50 AM <Pa...@b-m.pl> wrote:

> Need to move my JPA and DeltaSpike repositories to EJB EAR module to allow
> access from two different WARs in the same EAR
>
> What is recommnded approach to access DeltaSpike repository as EJB ?
>
> For adhoc I created PersonService class annotated with @Stateless
>
> @Stateless
> public class PersonService {
>
>         @Inject PersonRepository personRepository;
>
>         public PersonRepository getRepository(){
>                 return personRepository;
>         }
> }
>
> Do you have some other ideas ?
>
> Paweł