| /* | 
 |  * 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.s1asdev.jdbc.statementwrapper.ejb; | 
 |  | 
 | import jakarta.ejb.*; | 
 | import javax.naming.Context; | 
 | import javax.naming.InitialContext; | 
 | import javax.naming.NamingException; | 
 | import java.rmi.RemoteException; | 
 | import java.sql.Connection; | 
 |  | 
 | public class NestedBMPBean implements EntityBean { | 
 |  | 
 |     protected com.sun.appserv.jdbc.DataSource ds; | 
 |  | 
 |     public void setEntityContext(EntityContext entityContext) { | 
 |         Context context = null; | 
 |         try { | 
 |             context = new InitialContext(); | 
 |             ds = (com.sun.appserv.jdbc.DataSource) context.lookup("java:comp/env/DataSource"); | 
 |         } catch (NamingException e) { | 
 |             throw new EJBException("cant find datasource"); | 
 |         } | 
 |         System.out.println("[**SimpleBMPBean**] Done with setEntityContext...."); | 
 |     } | 
 |  | 
 |     public void unsetEntityContext() throws EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public boolean test1() { | 
 |         Connection conn = null; | 
 |         try { | 
 |             conn = ds.getConnection(); | 
 |             System.out.println("test-1() : " + ds.getConnection(conn)); | 
 |         } catch (Exception e) { | 
 |             return false; | 
 |         } finally { | 
 |             try { | 
 |                 if (conn != null) { | 
 |                     conn.close(); | 
 |                 } | 
 |             } catch (Exception e) { | 
 |             } | 
 |         } | 
 |         return true; | 
 |     } | 
 |  | 
 |     public void ejbRemove() throws RemoveException, EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public void ejbActivate() throws EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public void ejbPassivate() throws EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public void ejbLoad() throws EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public void ejbStore() throws EJBException, RemoteException { | 
 |     } | 
 |  | 
 |     public Integer ejbCreate() throws CreateException { | 
 |         return new Integer(1); | 
 |     } | 
 |  | 
 |     public void ejbPostCreate() { | 
 |     } | 
 |  | 
 | } |