本文整理汇总了Java中javax.ejb.EJBLocalObject类的典型用法代码示例。如果您正苦于以下问题:Java EJBLocalObject类的具体用法?Java EJBLocalObject怎么用?Java EJBLocalObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EJBLocalObject类属于javax.ejb包,在下文中一共展示了EJBLocalObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapObjectInterface
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
private void mapObjectInterface(final Class intrface) {
if (intrface == BusinessLocalHome.class || intrface == BusinessRemoteHome.class || intrface == ServiceEndpoint.class) {
return;
}
final Method[] interfaceMethods = intrface.getMethods();
for (final Method method : interfaceMethods) {
final Class declaringClass = method.getDeclaringClass();
if (declaringClass == EJBObject.class || declaringClass == EJBLocalObject.class) {
continue;
}
try {
final Method beanMethod = beanClass.getMethod(method.getName(), method.getParameterTypes());
mapMethods(method, beanMethod);
} catch (final NoSuchMethodException nsme) {
throw new OpenEJBRuntimeException("Invalid method [" + method + "]. Not declared by " + beanClass.getName() + " class");
}
}
}
示例2: isValidInterface
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
/**
* Checks that the values specified via @Local and @Remote are *not*:
* <p/>
* - classes
* - derived from javax.ejb.EJBObject
* - derived from javax.ejb.EJBHome
* - derived from javax.ejb.EJBLocalObject
* - derived from javax.ejb.EJBLocalHome
*
* @param interfce
* @param validation
* @param ejbName
* @param annotationName
* @return
*/
private boolean isValidInterface(final Class interfce, final ValidationContext validation, final String ejbName, final String annotationName) {
if (!interfce.isInterface()) {
validation.fail(ejbName, "ann.notAnInterface", annotationName, interfce.getName());
return false;
} else if (EJBHome.class.isAssignableFrom(interfce)) {
validation.fail(ejbName, "ann.remoteOrLocal.ejbHome", annotationName, interfce.getName());
return false;
} else if (EJBObject.class.isAssignableFrom(interfce)) {
validation.fail(ejbName, "ann.remoteOrLocal.ejbObject", annotationName, interfce.getName());
return false;
} else if (EJBLocalHome.class.isAssignableFrom(interfce)) {
validation.fail(ejbName, "ann.remoteOrLocal.ejbLocalHome", annotationName, interfce.getName());
return false;
} else if (EJBLocalObject.class.isAssignableFrom(interfce)) {
validation.fail(ejbName, "ann.remoteOrLocal.ejbLocalObject", annotationName, interfce.getName());
return false;
}
return true;
}
示例3: getEJBLocalObject
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
doCheck(Call.getEJBLocalObject);
final ThreadContext threadContext = ThreadContext.getThreadContext();
final BeanContext di = threadContext.getBeanContext();
if (di.getLocalInterface() == null) {
throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a local interface");
}
final EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di, threadContext.getPrimaryKey(), InterfaceType.EJB_LOCAL, new ArrayList<Class>(), di.getLocalInterface());
try {
final Class[] interfaces = new Class[]{di.getLocalInterface(), IntraVmProxy.class};
return (EJBLocalObject) ProxyManager.newProxyInstance(interfaces, handler);
} catch (final IllegalAccessException iae) {
throw new InternalErrorException("Could not create IVM proxy for " + di.getLocalInterface() + " interface", iae);
}
}
示例4: getEjbProxy
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public static <Proxy extends EJBLocalObject> Proxy getEjbProxy(final BeanContext beanContext, final EntityBean entity) {
if (entity == null) {
return null;
}
// build the primary key
final Object primaryKey = getPrimaryKey(beanContext, entity);
// get the cmp container
if (!(beanContext.getContainer() instanceof CmpContainer)) {
throw new IllegalArgumentException("Proxy is not connected to a CMP container but is conect to " + beanContext.getContainer().getClass().getName());
}
final Proxy proxy = (Proxy) EjbObjectProxyHandler.createProxy(beanContext, primaryKey, InterfaceType.EJB_LOCAL_HOME, beanContext.getLocalInterface());
return proxy;
}
示例5: getEntityBeans
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
private static <Bean extends EntityBean> Set<Bean> getEntityBeans(final Collection<?> proxies, final Class type) {
if (proxies == null) {
return null;
}
final Set<Bean> entities = new HashSet<Bean>();
for (final Object value : proxies) {
if (type != null && !type.isInstance(value)) {
throw new IllegalArgumentException("Object is not an instance of " + type.getName() +
": " + (value == null ? "null" : value.getClass().getName()));
}
final Bean entity = Cmp2Util.<Bean>getEntityBean((EJBLocalObject) value);
if (entity == null) {
throw new IllegalArgumentException("Entity has been deleted");
}
entities.add(entity);
}
return entities;
}
示例6: log
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public void log() {
Principal principal = context.getCallerPrincipal();
Map<String, Object> contextData = context.getContextData();
EJBLocalHome ejbLocalHome = context.getEJBLocalHome();
EJBLocalObject ejbLocalObject = context.getEJBLocalObject();
Ejb21StateLocal stateLocalEngine = context.getBusinessObject(Ejb21StateLocal.class);
boolean isCallerInRole = context.isCallerInRole("admin");
logger.info("stateLocalEngineBean principal: " + principal);
logger.info("stateLocalEngineBean contextData:" + contextData);
logger.info("stateLocalEngineBean ejbLocalHome:" + ejbLocalHome);
logger.info("stateLocalEngineBean ejbLocalObject:" + ejbLocalObject);
logger.info("stateLocalEngineBean stateLocalEngineBean:" + stateLocalEngine);
logger.info("stateLocalEngineBean isCallerInRole:" + isCallerInRole);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:15,代码来源:Ejb21StateEngineLocalBean.java
示例7: log
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public void log() {
Principal principal = context.getCallerPrincipal();
Map<String, Object> contextData = context.getContextData();
EJBLocalHome ejbLocalHome = context.getEJBLocalHome();
EJBLocalObject ejbLocalObject = context.getEJBLocalObject();
Ejb21Local LocalEngine = context.getBusinessObject(Ejb21Local.class);
boolean isCallerInRole = context.isCallerInRole("admin");
logger.info("ejb21LocalEngineBean principal: " + principal);
logger.info("ejb21LocalEngineBean contextData:" + contextData);
logger.info("ejb21LocalEngineBean ejbLocalHome:" + ejbLocalHome);
logger.info("ejb21LocalEngineBean ejbLocalObject:" + ejbLocalObject);
logger.info("ejb21LocalEngineBean LocalEngineBean:" + LocalEngine);
logger.info("ejb21LocalEngineBean isCallerInRole:" + isCallerInRole);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:15,代码来源:Ejb21EngineLocalBean.java
示例8: removeSessionBeanInstance
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
/**
* Remove the given EJB instance.
* @param ejb the EJB instance to remove
* @see javax.ejb.EJBLocalObject#remove()
*/
protected void removeSessionBeanInstance(EJBLocalObject ejb) {
if (ejb != null && !this.homeAsComponent) {
try {
ejb.remove();
}
catch (Throwable ex) {
logger.warn("Could not invoke 'remove' on local EJB proxy", ex);
}
}
}
示例9: getInterfaceType
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public InterfaceType getInterfaceType(final Class clazz) {
final InterfaceType type = interfaces.get(clazz);
if (type != null) {
return type;
}
if (EJBLocalHome.class.isAssignableFrom(clazz)) {
return InterfaceType.EJB_LOCAL_HOME;
}
if (EJBLocalObject.class.isAssignableFrom(clazz)) {
return InterfaceType.EJB_LOCAL;
}
if (EJBHome.class.isAssignableFrom(clazz)) {
return InterfaceType.EJB_HOME;
}
if (EJBObject.class.isAssignableFrom(clazz)) {
return InterfaceType.EJB_OBJECT;
}
for (final Entry<Class, InterfaceType> entry : interfaces.entrySet()) { // for @Remote case where the loaded interface can be different from the stored one
if (entry.getKey().getName().equals(clazz.getName())) {
return entry.getValue();
}
}
return null;
}
示例10: containerMethod
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
private static boolean containerMethod(final Method method) {
return (method.getDeclaringClass() == EJBObject.class ||
method.getDeclaringClass() == EJBHome.class ||
method.getDeclaringClass() == EJBLocalObject.class ||
method.getDeclaringClass() == EJBLocalHome.class) &&
!method.getName().equals("remove");
}
示例11: isValidEjbInterface
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
private boolean isValidEjbInterface(final String b, final Class clazz, final String refName) {
if (!clazz.isInterface()) { //NOPMD
//It is not an interface. No validation necessary.
} else if (EJBObject.class.isAssignableFrom(clazz)) {
fail(b, "ann.ejb.ejbObject", clazz.getName(), refName);
return false;
} else if (EJBLocalObject.class.isAssignableFrom(clazz)) {
fail(b, "ann.ejb.ejbLocalObject", clazz.getName(), refName);
return false;
}
return true;
}
示例12: getEJBLocalObject
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public EJBLocalObject getEJBLocalObject() throws IllegalStateException {
doCheck(Call.getEJBLocalObject);
final ThreadContext threadContext = ThreadContext.getThreadContext();
final BeanContext di = threadContext.getBeanContext();
if (di.getLocalHomeInterface() == null) {
throw new IllegalStateException("Bean does not have an EJBLocalObject interface: " + di.getDeploymentID());
}
return (EJBLocalObject) EjbObjectProxyHandler.createProxy(di, threadContext.getPrimaryKey(), InterfaceType.EJB_LOCAL, di.getLocalInterface());
}
示例13: executeSelectQuery
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
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) {
// IllegalArgumentException means that the parameter with the
// 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;
}
示例14: executeUpdateQuery
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public int executeUpdateQuery(final BeanContext beanContext, final String signature, Object[] args) throws FinderException {
final EntityManager entityManager = getEntityManager(beanContext);
Query query = createNamedQuery(entityManager, signature);
if (query == null) {
final int parenIndex = signature.indexOf('(');
if (parenIndex > 0) {
final String shortName = signature.substring(0, parenIndex);
query = createNamedQuery(entityManager, shortName);
}
if (query == null) {
throw new FinderException("No query defined for method " + signature);
}
}
// 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);
}
query.setParameter(i + 1, arg);
}
final int result = query.executeUpdate();
return result;
}
示例15: contains
import javax.ejb.EJBLocalObject; //导入依赖的package包/类
public boolean contains(final Object o) {
if (relatedLocal.isInstance(o)) {
final Bean entity = getEntityBean((EJBLocalObject) o);
return entity != null && getRelatedBeans(false, false).contains(entity);
}
return false;
}