javax.ejb.RemoveException Java Examples

The following examples show how to use javax.ejb.RemoveException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicBmpBean.java    From tomee with Apache License 2.0 6 votes vote down vote up
/**
 * A container invokes this method before it removes the EJB object
 * that is currently associated with the instance. This method
 * is invoked when a client invokes a remove operation on the
 * enterprise Bean's home interface or the EJB object's remote interface.
 * This method transitions the instance from the ready state to the pool
 * of available instances.
 */
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
    try {
        final InitialContext jndiContext = new InitialContext();
        final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
        final Connection con = ds.getConnection();

        try {
            final PreparedStatement stmt = con.prepareStatement("delete from entity where id = ?");
            try {
                stmt.setInt(1, primaryKey);
                stmt.executeUpdate();
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }

    } catch (final Exception e) {
        e.printStackTrace();
        throw new javax.ejb.EJBException(e);
    }
}
 
Example #2
Source File: BasicBmp2DataSourcesBean.java    From tomee with Apache License 2.0 6 votes vote down vote up
/**
 * A container invokes this method before it removes the EJB object
 * that is currently associated with the instance. This method
 * is invoked when a client invokes a remove operation on the
 * enterprise Bean's home interface or the EJB object's remote interface.
 * This method transitions the instance from the ready state to the pool
 * of available instances.
 */
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
    try {
        final InitialContext jndiContext = new InitialContext();
        final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
        final Connection con = ds.getConnection();
        try {
            final PreparedStatement stmt = con.prepareStatement("delete from entity where id = ?");
            try {
                final Integer primaryKey = (Integer) ejbContext.getPrimaryKey();
                stmt.setInt(1, primaryKey.intValue());
                stmt.executeUpdate();
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }

    } catch (final Exception e) {
        e.printStackTrace();
        throw new javax.ejb.EJBException(e);
    }
}
 
Example #3
Source File: Ideas_2010_10_11.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@ExpectWarning("BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY")
public void cascadeDelete(Collection value) throws RemoveException
{
   if(!value.isEmpty())
   {
      EJBLocalObject[] locals = (EJBLocalObject[])value.toArray();
      for(int i = 0; i < locals.length; ++i)
      {
         locals[i].remove();
      }
   }
}
 
Example #4
Source File: JpaCmpEngine.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void beforeDelete(final LifecycleEvent lifecycleEvent) {
    eventOccurred(lifecycleEvent);
    try {
        final Object bean = lifecycleEvent.getSource();
        cmpCallback.ejbRemove((EntityBean) bean);
    } catch (final RemoveException e) {
        throw new PersistenceException(e);
    }
}
 
Example #5
Source File: CmpContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void ejbRemove(final EntityBean entityBean) throws RemoveException {
    if (entityBean == null) {
        throw new NullPointerException("entityBean is null");
    }
    if (isDeleted(entityBean)) {
        return;
    }

    final ThreadContext callContext = createThreadContext(entityBean);
    callContext.setCurrentOperation(Operation.REMOVE);

    final ThreadContext oldCallContext = ThreadContext.enter(callContext);
    try {
        entityBean.ejbRemove();
    } catch (final RemoteException e) {
        throw new EJBException(e);
    } finally {
        // clear relationships
        // todo replace with interface call when CmpEntityBean interface is added
        try {
            entityBean.getClass().getMethod("OpenEJB_deleted").invoke(entityBean);
        } catch (final Exception ignored) {
            // no-op
        }
        cancelTimers(callContext);
        ThreadContext.exit(oldCallContext);
    }
}
 
Example #6
Source File: CheckNoCreateMethodsTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
}
 
Example #7
Source File: StatelessEjbHomeHandler.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
protected Object removeByPrimaryKey(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
    throw new RemoveException("Session objects are private resources and do not have primary keys");
}
 
Example #8
Source File: ABean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #9
Source File: BBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #10
Source File: ABean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #11
Source File: BBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #12
Source File: ABean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #13
Source File: BBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #14
Source File: ABean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #15
Source File: SingletonEjbHomeHandler.java    From tomee with Apache License 2.0 4 votes vote down vote up
protected Object removeByPrimaryKey(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
    throw new RemoveException("Session objects are private resources and do not have primary keys");
}
 
Example #16
Source File: CmpContainer.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void ejbRemove(final EntityBean entity) throws RemoveException {
    CmpContainer.this.ejbRemove(entity);
}
 
Example #17
Source File: SimpleCmpTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException, EJBException,
        RemoteException {
    // no-op
}
 
Example #18
Source File: CheckNoCreateMethodsTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
}
 
Example #19
Source File: CheckMissingClassTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
}
 
Example #20
Source File: CheckMissingClassTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
}
 
Example #21
Source File: AddressEJB.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #22
Source File: OrderBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #23
Source File: HoldingBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #24
Source File: AccountProfileBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #25
Source File: AccountBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #26
Source File: QuoteBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #27
Source File: KeyGenBean.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #28
Source File: JPACMDIntegrationTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}
 
Example #29
Source File: JPACMDIntegrationTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
}
 
Example #30
Source File: LegacyInterfaceTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void ejbRemove() throws RemoveException {
}