You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Rodolfo Dias <di...@gmail.com> on 2008/11/08 13:48:53 UTC
Re: binding.ejb and JBoss
Hi,
I access the EJB3 in JBOSS using this:
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://utrafe"
xmlns:sample="http://utrafe"
name="Classifier">
<service name="ClassifierService" promote="ClassifierServiceComponent"/>
<component name="ClassifierServiceComponent">
<implementation.java
class="gov.utrafe.esistafe.services.classifier.ClassifierService"/>
<!-- In SCA_AssemblyModelV100.pdf specifications the promote is
required, but don't has utility in here. -->
<reference name="classifierBO" promote=""/>
<reference name="fiscalYearQuery" promote=""/>
<reference name="fiscalYearBO" promote=""/>
</component>
<reference name="FiscalYearBO"
promote="ClassifierServiceComponent/fiscalYearBO">
<interface.java
interface="gov.utrafe.esistafe.core.fiscalyear.interfaces.IFiscalYearBO"/>
<binding.ejb name="fiscalyearbo-ejb"
uri="esistafe-core-ear/FiscalYearBO/remote" ejb-version="EJB3"/>
</reference>
<component name="ClassifierBO">
<implementation.java
class="gov.utrafe.esistafe.core.classifier.ClassifierBO"/>
</component>
<component name="FiscalYearQuery">
<implementation.java
class="gov.utrafe.esistafe.core.fiscalyear.FiscalYearQuery"/>
</component>
<wire source="ClassifierServiceComponent/classifierBO"
target="ClassifierBO"/>
<wire source="ClassifierServiceComponent/fiscalYearQuery"
target="FiscalYearQuery"/>
</composite>
My EJB3 implementations is:
@Stateless(name="FiscalYearBO")
@Remote(IFiscalYearBO.class)
@Interceptors(SistafeContextInterceptor.class)
public class FiscalYearEJB extends FiscalYearBO implements IFiscalYearBO,
IEntitySupported, ITransactionalSupported {
private EntityManager em;
@Resource
private SessionContext sessionContext;
@PersistenceContext(unitName = "Sistafe")
public void setEntityManager(EntityManager em) {
this.em = em;
}
public EntityManager getEntityManager() {
return em;
}
public SessionContext getSessionContext() {
return sessionContext;
}
}
And my package is:
esistafe-core-ear.ear
---> esistafe-ejb-core-1.0.0.jar (ejb module)
in JBOSS 4.2.1.GA
My Client is out container:
package gov.utrafe.esistafe.services.classifier;
import gov.utrafe.esistafe.classifier.entity.Scope;
import gov.utrafe.esistafe.core.classifier.interfaces.IClassifierBO;
import gov.utrafe.esistafe.core.context.SistafeContext;
import gov.utrafe.esistafe.core.exception.UserError;
import gov.utrafe.esistafe.core.fiscalyear.interfaces.IFiscalYearBO;
import gov.utrafe.esistafe.core.fiscalyear.interfaces.IFiscalYearQuery;
import gov.utrafe.esistafe.meta.entity.FiscalYear;
import org.osoa.sca.annotations.Reference;
public class ClassifierService implements IClassifierService {
private IFiscalYearQuery fiscalYearQuery;
private IClassifierBO classifierBO;
private IFiscalYearBO fiscalYearBO;
public ClassifierService() {
System.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.provider.url", "jnp://127.0.0.1:1099
");
System.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
}
public void create() throws UserError {
FiscalYear fiscalYear = new FiscalYear();
fiscalYear.setYear(2010);
Scope scope = new Scope();
scope.setCode("00002");
scope.setDescription("Description of scope 0002");
scope.setRemarks("Remarks of scope 002");
scope.setActive(true);
SistafeContext sistafeContext = new SistafeContext();
// try{
fiscalYear = fiscalYearBO.persist(sistafeContext, fiscalYear);
scope.setFiscalYear(fiscalYear);
classifierBO.persist(sistafeContext, scope);
// }catch(UserError e){
// e.printStackTrace();
// Bolar uma arquitetura para poder saber o que fazer em caso
// da disponibilidade da excecao
// see: http://www.infoq.com/articles/lublinsky-soa-exception
// }
System.out.println("Rodolfo");
}
@Reference
public void setFiscalYearQuery(IFiscalYearQuery fiscalYearQuery) {
this.fiscalYearQuery = fiscalYearQuery;
}
@Reference
public void setClassifierBO(IClassifierBO classifierBO) {
this.classifierBO = classifierBO;
}
@Reference
public void setFiscalYearBO(IFiscalYearBO fiscalYearBO) {
this.fiscalYearBO = fiscalYearBO;
}
}
My testCase is:
public class ClassifierTestCase extends TestCase{
private IClassifierService classifierService;
private SCADomain scaDomain;
@Override
protected void setUp() throws Exception {
scaDomain = SCADomain.newInstance("Classifier.composite");
classifierService = scaDomain.getService(ClassifierService.class,
"ClassifierServiceComponent");
}
@Override
protected void tearDown() throws Exception {
scaDomain.close();
}
public void testCreate() throws Exception{
classifierService.create();
}
}
This only overview to help you, but i can attached the .ear archive in here
if is necessary.
Sorry, I am not write english :(, But i try.
2008/11/4 Ruault Gaetan <gr...@sopragroup.com>
> Hello,
> I try to call an EJB3 on distant Jboss by SCA I have this configuration
> EJB :
>
> <session>
> <ejb-name>AuthBean</ejb-name>
> <home>fr.smacl.pocf.services.stub.AuthLocal</home>
> <remote>fr.smacl.pocf.services.stub.AuthRemote</remote>
> <ejb-class>fr.smacl.pocf.services.ejb.bean.AuthBean</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Bean</transaction-type>
> </session>
>
> and this for the composite file :
>
> <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
> xmlns:instance="http://www.w3.org/2004/08/wsdl-instance" xmlns="
> http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="
> http://tuscany.apache.org/xmlns/sca/1.0" name="AuthComponent"
> targetNamespace="AuthComponent">
> <sca:component name="AuthComponent">
> <sca:implementation.java
> class="fr.smacl.pocf.services.composite.impl.AuthServiceImpl"/>
> <sca:service name="AuthService">
> <sca:interface.java
> interface="fr.smacl.pocf.services.stub.AuthService"/>
> </sca:service>
> <sca:reference name="authService"/>
> </sca:component>
> <sca:service name="AuthService" promote="AuthComponent/AuthService"/>
> <sca:reference name="authService" promote="AuthComponent/authService">
> <sca:binding.ejb uri="AuthBean/remote" ejb-version="EJB3"/>
> </sca:reference>
> </sca:composite>
>
> How can i define that my ejb3 is on distant server(my sca client and my
> jbos is on different server) and use this context factory
>
> org.jnp.interfaces.NamingContextFactory
>
> and this provider
>
> jnp://localhost:1099
>
> thanks
> Gaetan
>
>
>
>
> ------------------------------
>
> Gaëtan RUAULT
> Ingenieur d'étude et développement
> Sopra group. 28, rue Léo Lagrange 79000 Niort
> Phone : +33 (0)5 49 77 38 20
> gruault@sopragroup.com - www.sopragroup.com
> Ce message peut contenir des informations confidentielles dont la
> divulgation est à ce titre rigoureusement interdite en l'absence
> d'autorisation explicite de l'émetteur. Dans l'hypothèse où vous auriez reçu
> par erreur ce message, merci de le renvoyer à l'émetteur et de détruire
> toute copie.
>
> P Pensez à l'environnement avant d'imprimer.
>