blob: d698f5b5ccab772fe09e2f622817b072b74c371c [file] [log] [blame]
/*
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.s1peqe.transaction.txstressreadonly.ejb.beanA;
import jakarta.ejb.SessionBean;
import jakarta.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import jakarta.transaction.UserTransaction;
import java.rmi.RemoteException;
import com.sun.s1peqe.transaction.txstressreadonly.ejb.beanB.*;
public class TxBeanA implements SessionBean {
private TxRemoteHomeB home = null;
private UserTransaction tx = null;
private SessionContext context = null;
// ------------------------------------------------------------------------
// Container Required Methods
// ------------------------------------------------------------------------
public void ejbCreate() throws RemoteException {
Class homeClass = TxRemoteHomeB.class;
System.out.println("ejbCreate in BeanA");
try {
Context ic = new InitialContext();
java.lang.Object obj = ic.lookup("java:comp/env/ejb/TxBeanB");
home = (TxRemoteHomeB) PortableRemoteObject.narrow(obj, homeClass);
} catch (Exception ex) {
System.out.println("Exception in ejbCreate: " + ex.toString());
ex.printStackTrace();
}
}
public void setSessionContext(SessionContext sc) {
System.out.println("setSessionContext in BeanA");
this.context = sc;
}
public void ejbRemove() {
System.out.println("ejbRemove in BeanA");
}
public void ejbDestroy() {
System.out.println("ejbDestroy in BeanA");
}
public void ejbActivate() {
System.out.println("ejbActivate in BeanA");
}
public void ejbPassivate() {
System.out.println("ejbPassivate in BeanA");
}
// ------------------------------------------------------------------------
// Business Logic Methods
// ------------------------------------------------------------------------
public void txCommit(int identity) throws RemoteException {
System.out.println("txCommit in BeanA");
try {
TxRemoteB beanB = home.create();
beanB.insert("A1001", 3000,identity);
beanB.remove();
System.out.println("After beanB Remove call");
} catch (Exception ex) {
System.out.println("Exception in txCommit: " + ex.toString());
ex.printStackTrace();
}
}
}