}
public Interceptor create(final InterceptorFactoryContext context) {
return new AbstractEJBInterceptor() {
public Object processInvocation(final InterceptorContext context) throws Exception {
final CmpEntityBeanComponent component = getComponent(context, CmpEntityBeanComponent.class);
final Object primaryKey = context.getPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY);
if (primaryKey == null) {
throw new NoSuchEJBException("Invocation was not associated with an instance, primary key was null, instance may have been removed");
}
final CmpEntityBeanComponentInstance instance = (CmpEntityBeanComponentInstance) component.getCache().get(primaryKey);
//Call the ejbRemove method
Method oldMethod = context.getMethod();
try {
context.putPrivateData(ComponentInstance.class, instance);
context.setMethod(ejbRemove);
context.setTarget(instance.getInstance());
instance.getInterceptor(ejbRemove).processInvocation(context);
} finally {
context.setMethod(oldMethod);
context.setTarget(null);
context.putPrivateData(ComponentInstance.class, null);
}
// Invoke CMP remove
component.getStoreManager().removeEntity(instance.getEjbContext());
instance.setRemoved(true);
instance.removeAllTimers();
return null;
}
};