use of javax.ejb.EJBLocalObject in project Payara by payara.
the class EJBHashSet method remove.
/**
* Removes the given element from this set if it is present.
*
* @param o object to be removed from this set, if present.
* @return <tt>true</tt> if the set contained the specified element.
* @see java.util.HashSet
*/
public boolean remove(Object o) {
// NOI18N
logger.finest("---EJBHashSet.remove---");
assertIsValid();
assertInTransaction();
helper.assertInstanceOfLocalInterfaceImpl(o);
EJBLocalObject lo = (EJBLocalObject) o;
return pcSet.remove(helper.convertEJBLocalObjectToPC(lo, pm, true));
}
use of javax.ejb.EJBLocalObject in project Payara by payara.
the class JDOEJB20HelperImpl method convertPCToEJBLocalObject.
/**
* Converts persistence-capable instance to EJBLocalObject. Returns null if
* the instance is already removed via cascade-delete operation.
* @param pc the persistence-capable instance to be converted as an Object.
* @param pm the associated instance of PersistenceManager.
* @param context the EJBContext of the calling bean.
* @return instance of EJBLocalObject.
*/
public EJBLocalObject convertPCToEJBLocalObject(Object pc, PersistenceManager pm, EJBContext context) {
if (pc == null)
return null;
Object jdoObjectId = pm.getObjectId(pc);
Object key = convertObjectIdToPrimaryKey(jdoObjectId);
try {
return CMPHelper.getEJBLocalObject(key, getContainer(), context);
} catch (Exception ex) {
EJBException e = new EJBException(I18NHelper.getMessage(messages, "EXC_ConvertPCToEJBLocalObjectCtx", key.toString()), // NOI18N
ex);
// NOI18N
logger.throwing("JDOEJB20HelperImpl", "convertPCToEJBLocalObjectCtx", e);
throw e;
}
}
use of javax.ejb.EJBLocalObject in project Payara by payara.
the class SunContainerHelper method getContainer.
/**
* Get a Container helper instance that will be passed unchanged to the
* required methods.
* This is SunContainerHelper specific code.
*
* The info argument is an Object array that consistes of a class to use
* for the class loader and concreteImpl bean class name.
* @see getEJBObject(Object, Object)
* @see getEJBLocalObject(Object, Object)
* @see getEJBLocalObject(Object, Object, EJBObject)
* @see removeByEJBLocalObject(EJBLocalObject, Object)
* @see removeByPK(Object, Object)
* @param info Object with the request information that is application server
* specific.
* @return a Container helper instance as an Object.
*/
public Object getContainer(Object info) {
Object[] params = (Object[]) info;
String appName = (String) params[0];
ServiceLocator habitat = Globals.getDefaultHabitat();
ApplicationRegistry reg = habitat.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = reg.get(appName);
Application app = appInfo.getMetaData(Application.class);
EjbDescriptor desc = app.getEjbByName((String) params[1]);
return habitat.<EjbContainerUtil>getService(EjbContainerUtil.class).getContainer(desc.getUniqueId());
}
use of javax.ejb.EJBLocalObject in project spring-framework by spring-projects.
the class LocalSlsbInvokerInterceptor method invokeInContext.
/**
* This implementation "creates" a new EJB instance for each invocation.
* Can be overridden for custom invocation strategies.
* <p>Alternatively, override {@link #getSessionBeanInstance} and
* {@link #releaseSessionBeanInstance} to change EJB instance creation,
* for example to hold a single shared EJB instance.
*/
@Override
public Object invokeInContext(MethodInvocation invocation) throws Throwable {
Object ejb = null;
try {
ejb = getSessionBeanInstance();
Method method = invocation.getMethod();
if (method.getDeclaringClass().isInstance(ejb)) {
// directly implemented
return method.invoke(ejb, invocation.getArguments());
} else {
// not directly implemented
Method ejbMethod = ejb.getClass().getMethod(method.getName(), method.getParameterTypes());
return ejbMethod.invoke(ejb, invocation.getArguments());
}
} catch (InvocationTargetException ex) {
Throwable targetEx = ex.getTargetException();
if (logger.isDebugEnabled()) {
logger.debug("Method of local EJB [" + getJndiName() + "] threw exception", targetEx);
}
if (targetEx instanceof CreateException) {
throw new EjbAccessException("Could not create local EJB [" + getJndiName() + "]", targetEx);
} else {
throw targetEx;
}
} catch (NamingException ex) {
throw new EjbAccessException("Failed to locate local EJB [" + getJndiName() + "]", ex);
} catch (IllegalAccessException ex) {
throw new EjbAccessException("Could not access method [" + invocation.getMethod().getName() + "] of local EJB [" + getJndiName() + "]", ex);
} finally {
if (ejb instanceof EJBLocalObject) {
releaseSessionBeanInstance((EJBLocalObject) ejb);
}
}
}
use of javax.ejb.EJBLocalObject in project tomee by apache.
the class JpaCmpEngine method executeSelectQuery.
private List<Object> executeSelectQuery(final Query query, Object[] args) {
// process args
if (args == null) {
args = NO_ARGS;
}
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
// ejb proxies need to be swapped out for real instance classes
if (arg instanceof EJBObject) {
arg = Cmp2Util.getEntityBean((EJBObject) arg);
}
if (arg instanceof EJBLocalObject) {
arg = Cmp2Util.getEntityBean((EJBLocalObject) arg);
}
try {
query.getParameter(i + 1);
} catch (final IllegalArgumentException e) {
// specified position does not exist
continue;
}
query.setParameter(i + 1, arg);
}
// todo results should not be iterated over, but should instead
// perform all work in a wrapper list on demand by the application code
final List results = query.getResultList();
for (final Object value : results) {
if (value instanceof EntityBean) {
// todo don't activate beans already activated
final EntityBean entity = (EntityBean) value;
cmpCallback.setEntityContext(entity);
cmpCallback.ejbActivate(entity);
}
}
// noinspection unchecked
return results;
}
Aggregations