/** * Setting up the test fixture. */ private void init() throws Exception { Context ctx = ContextHelper.getContext(); times = new long[4]; try { Object object = PortableRemoteObject.narrow(ctx.lookup(PBSessionHome.JNDI_NAME), EJBHome.class); bean = ((PBSessionHome) object).create(); } catch(Exception e) { e.printStackTrace(System.err); throw e; } }
/** * Setting up the test fixture. */ private void init() throws Exception { Context ctx = ContextHelper.getContext(); times = new long[4]; try { Object object = PortableRemoteObject.narrow(ctx.lookup(ODMGSessionHome.JNDI_NAME), EJBHome.class); bean = ((ODMGSessionHome) object).create(); } catch(Exception e) { e.printStackTrace(System.err); throw e; } }
public void test39_returnEJBHomeArray() { try { final EncBmpHome[] expected = new EncBmpHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean"); expected[i] = (EncBmpHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void Xtest03_copyHandleBySerialize() { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ejbHomeHandle); oos.flush(); oos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); final HomeHandle copy = (HomeHandle) ois.readObject(); assertNotNull("The HomeHandle copy is null", copy); final EJBHome home = copy.getEJBHome(); assertNotNull("The EJBHome is null", home); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void Xtest39_returnEJBHomeArray() { try { final EncCmpHome[] expected = new EncCmpHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean"); expected[i] = (EncCmpHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void test39_returnEJBHomeArray() { try { final EncCmpHome[] expected = new EncCmpHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean"); expected[i] = (EncCmpHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void test39_returnEJBHomeArray() { try { final EncStatefulHome[] expected = new EncStatefulHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/stateful/EncBean"); expected[i] = (EncStatefulHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void test39_returnEJBHomeArray() { try { final EncStatelessHome[] expected = new EncStatelessHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/stateless/EncBean"); expected[i] = (EncStatelessHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void test39_returnEJBHomeArray() { try { final EncSingletonHome[] expected = new EncSingletonHome[3]; for (int i = 0; i < expected.length; i++) { final Object obj = initialContext.lookup("client/tests/singleton/EncBean"); expected[i] = (EncSingletonHome) obj; assertNotNull("The EJBHome returned from JNDI is null", expected[i]); } final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected); assertNotNull("The EJBHome array returned is null", actual); assertEquals(expected.length, actual.length); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
/** * 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; }
private void check_homeInterfaceMethods(final RemoteBean b) { Class home = null; Class bean = null; try { home = loadClass(b.getHome()); bean = loadClass(b.getEjbClass()); } catch (final OpenEJBException e) { return; } if (!EJBHome.class.isAssignableFrom(home)) { return; } if (check_hasCreateMethod(b, bean, home)) { check_createMethodsAreImplemented(b, bean, home); // ejbPostCreate methods are now automatically generated // check_postCreateMethodsAreImplemented(b, bean, home); } }
public ProxyFactory(final BeanContext beanContext) { this.beanContext = beanContext; keyGenerator = beanContext.getKeyGenerator(); remoteInterface = beanContext.getRemoteInterface(); if (remoteInterface != null) { final EJBHome homeProxy = beanContext.getEJBHome(); remoteHandler = (EntityEjbHomeHandler) ProxyManager.getInvocationHandler(homeProxy); } else { remoteHandler = null; } localInterface = beanContext.getLocalInterface(); if (localInterface != null) { final EJBLocalHome localHomeProxy = beanContext.getEJBLocalHome(); localHandler = (EntityEjbHomeHandler) ProxyManager.getInvocationHandler(localHomeProxy); } else { localHandler = null; } }
@Override public void log() throws RemoteException { Principal principal = context.getCallerPrincipal(); Map<String, Object> contextData = context.getContextData(); EJBHome ejbHome = context.getEJBHome(); EJBObject ejbObject = context.getEJBObject(); Ejb21Remote RemoteEngine = context.getBusinessObject(Ejb21Remote.class); boolean isCallerInRole = context.isCallerInRole("admin"); logger.info("ejb21RemoteEngineBean principal: " + principal); logger.info("ejb21RemoteEngineBean contextData:" + contextData); logger.info("ejb21RemoteEngineBean ejbHome:" + ejbHome); logger.info("ejb21RemoteEngineBean ejbObject:" + ejbObject); logger.info("ejb21RemoteEngineBean RemoteEngineBean:" + RemoteEngine); logger.info("ejb21RemoteEngineBean isCallerInRole:" + isCallerInRole); }
@Override public void log() throws RemoteException { Principal principal = context.getCallerPrincipal(); Map<String, Object> contextData = context.getContextData(); EJBHome ejbHome = context.getEJBHome(); EJBObject ejbObject = context.getEJBObject(); Ejb21StateRemote stateRemoteEngine = context.getBusinessObject(Ejb21StateRemote.class); boolean isCallerInRole = context.isCallerInRole("admin"); logger.info("stateRemoteEngineBean principal: " + principal); logger.info("stateRemoteEngineBean contextData:" + contextData); logger.info("stateRemoteEngineBean ejbHome:" + ejbHome); logger.info("stateRemoteEngineBean ejbObject:" + ejbObject); logger.info("stateRemoteEngineBean stateRemoteEngineBean:" + stateRemoteEngine); logger.info("stateRemoteEngineBean isCallerInRole:" + isCallerInRole); }
/** * Check for EJB3-style home object that serves as EJB component directly. */ @Override protected Method getCreateMethod(Object home) throws EjbAccessException { if (this.homeAsComponent) { return null; } if (!(home instanceof EJBHome)) { // An EJB3 Session Bean... this.homeAsComponent = true; return null; } return super.getCreateMethod(home); }
private static synchronized EJBHome getRemoteHome( String ejbContainerTagName, String jndiName, Class<?> className, String key) throws java.rmi.RemoteException, ClassNotFoundException { Context ctx; if (logger.isDebugEnabled()) { logger.debug("--getRemoteHome--"); logger.debug("ejbContainerTagName:" + ejbContainerTagName); logger.debug("jndiName:" + jndiName); logger.debug("className:" + className); logger.debug("key:" + key); } try { if (ejbContainerTagName == null || ejbContainerTagName.equals("")) { ctx = ContainerUtil.getRemoteEJBContainerContext(); if (logger.isDebugEnabled()) { logger.debug("call:getRemoteEJBContainerContext()"); } } else { ctx = ContainerUtil .getRemoteEJBContainerContext(ejbContainerTagName); if (logger.isDebugEnabled()) { logger.debug("call:getRemoteEJBContainerContext(" + ejbContainerTagName + ")"); } } Object ref = ctx.lookup(jndiName.trim()); EJBHome ejbHome = (EJBHome) PortableRemoteObject.narrow(ref, className); HOME_INTERFACES_REMOTE.put(key, ejbHome); return ejbHome; } catch (NamingException e) { throw new RemoteException("getRemoteHome err", e); } }
/** * Obtiene el Home remoto del ejb * El acceso a este m�todo �nicamente puede hacerse a partir de la instancia del singleton: * <code>EJB2ServiceLocator.getInstance().getLocalHome(jndiName,"com.acme.ejb.MyHome");</code> * @param jndiContextProviderURL url del provider de contexto JNDI * @param jndiName Nombre jndi del ejb * @param homeClassName Nombre de la Clase (Class) para devolver el objeto tipado * @return El objeto tipado */ public EJBHome getRemoteHome(final String jndiContextProviderURL, final String jndiName,final String homeClassName) { EJBHome home = null; try { home = this.getRemoteHome(jndiContextProviderURL, jndiName,Reflection.type(homeClassName).getType()); } catch (ReflectionException cnfEx) { // TODO logging String err = Strings.of("NO se ha encontrado la clase {} para hacer un narrow del objeto home > {}") .customizeWith(homeClassName,cnfEx.getMessage()).asString(); System.out.println(err); } return home; }
protected void init() { Context ctx = ContextHelper.getContext(); try { Object object = PortableRemoteObject.narrow(ctx.lookup(PBSessionHome.JNDI_NAME), EJBHome.class); bean = ((PBSessionHome) object).create(); } catch (Exception e) { e.printStackTrace(); } }
protected void init() throws Exception { try { Object object = PortableRemoteObject.narrow( ContextHelper.getContext().lookup(PersonArticleManagerPBHome.JNDI_NAME), EJBHome.class); bean = (PersonArticleManagerPBRemote) ((PersonArticleManagerPBHome) object).create(); System.out.println("Bean found: " + bean); } catch (Exception e) { e.printStackTrace(); throw e; } }
protected void init() { Context ctx = ContextHelper.getContext(); try { Object object = PortableRemoteObject.narrow(ctx.lookup(RollbackHome.JNDI_NAME), EJBHome.class); rollbackBean = ((RollbackHome) object).create(); } catch (Exception e) { e.printStackTrace(); } }
protected void init() { Context ctx = ContextHelper.getContext(); try { Object object = PortableRemoteObject.narrow(ctx.lookup(PBSessionHome.JNDI_NAME), EJBHome.class); bean = ((PBSessionHome) object).create(); } catch(Exception e) { e.printStackTrace(); throw new OJBRuntimeException("Can't lookup bean: " + PBSessionHome.JNDI_NAME, e); } }
protected void init() throws Exception { try { Object object = PortableRemoteObject.narrow( ContextHelper.getContext().lookup(ArticleManagerPBHome.JNDI_NAME), EJBHome.class); pbArticleBean = ((ArticleManagerPBHome) object).create(); } catch (Exception e) { e.printStackTrace(); throw e; } }
protected void init() { Context ctx = ContextHelper.getContext(); try { Object object = PortableRemoteObject.narrow(ctx.lookup(ODMGSessionHome.JNDI_NAME), EJBHome.class); bean = ((ODMGSessionHome) object).create(); } catch(Exception e) { e.printStackTrace(); throw new OJBRuntimeException("Can't lookup bean: " + ODMGSessionHome.JNDI_NAME, e); } }
protected void init() throws Exception { try { Object object = PortableRemoteObject.narrow( ContextHelper.getContext().lookup(ArticleManagerODMGHome.JNDI_NAME), EJBHome.class); odmgArticleBean = ((ArticleManagerODMGHome) object).create(); } catch (Exception e) { e.printStackTrace(); throw e; } }
protected void init() { Context ctx = ContextHelper.getContext(); try { Object object = PortableRemoteObject.narrow(ctx.lookup(ODMGSessionHome.JNDI_NAME), EJBHome.class); sampleBean = ((ODMGSessionHome) object).create(); } catch (Exception e) { e.printStackTrace(); } }
protected void init() throws Exception { try { Object object = PortableRemoteObject.narrow( ContextHelper.getContext().lookup(PersonArticleManagerODMGHome.JNDI_NAME), EJBHome.class); bean = ((PersonArticleManagerODMGHome) object).create(); } catch (Exception e) { e.printStackTrace(); throw e; } }
/** * Do the look up for the EJB Home in the JNDI. * @param jndiName name in the JNDI * @param classEjbHome Class of home interface of the EJB * @return return the EJBHome object narrowed * @throws NamingException */ public EJBHome getHome(String jndiName, Class classEjbHome) throws NamingException { // find the Advice bean using JNDI Object obj = context.lookup(jndiName); // narrow the obj EJBHome ejbHome = (EJBHome) PortableRemoteObject.narrow(obj, classEjbHome); return ejbHome; }
/** * Do the look up for the EJB Home in the JNDI. * @param jndiName name in the JNDI * @param classEjbHome Class of home interface of the EJB * @return return the EJBHome object narrowed * @throws NamingException */ public static EJBHome getHome(String jndiName, Class classEjbHome) throws NamingException { // gets the entry point into the JNDI naming service Context ctx = new InitialContext(); // find the Advice bean using JNDI Object obj = ctx.lookup(jndiName); // narrow the obj EJBHome ejbHome = (EJBHome) PortableRemoteObject.narrow(obj, classEjbHome); return ejbHome; }
/** * Do the look up for the EJB Home in the JNDI. * @param jndiName name in the JNDI * @param classEjbHome Class of home interface of the EJB * @return return the EJBHome object narrowed * @throws NamingException */ //@SuppressWarnings("rawtypes") public EJBHome getHome(String jndiName, Class classEjbHome) throws NamingException { // find the Advice bean using JNDI Object obj = context.lookup(jndiName); // narrow the obj EJBHome ejbHome = (EJBHome) PortableRemoteObject.narrow(obj, classEjbHome); return ejbHome; }
@Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { final byte version = in.readByte(); // future use homeClass = (Class) in.readObject(); remoteClass = (Class) in.readObject(); keyClass = (Class) in.readObject(); ejbHomeProxy = (EJBHome) in.readObject(); type = in.readByte(); deploymentID = in.readUTF(); deploymentCode = in.readShort(); for (int i = in.readShort(); i > 0; i--) { businessClasses.add((Class) in.readObject()); } if (businessClasses.size() > 0) { primaryKey = in.readObject(); } if (version > 2) { mainInterface = (Class) in.readObject(); } if (version > 1) { final byte typeIndex = in.readByte(); interfaceType = InterfaceType.values()[typeIndex]; } for (int i = in.readInt(); i > 0; i--) { asynchronousMethods.add((String) in.readObject()); } final boolean hasProperties = in.readBoolean(); if (hasProperties) { final int bufferLength = in.readInt(); final byte[] buffer = new byte[bufferLength]; in.read(buffer); final ByteArrayInputStream bais = new ByteArrayInputStream(buffer); properties.load(bais); } }
public EJBInvocationHandler(final EJBMetaDataImpl ejb, final ServerMetaData server, final ClientMetaData client, final JNDIContext.AuthenticationInfo auth) { this.ejb = ejb; this.server = server; this.client = client; this.authenticationInfo = auth; final Class remoteInterface = ejb.getRemoteInterfaceClass(); remote = remoteInterface != null && (EJBObject.class.isAssignableFrom(remoteInterface) || EJBHome.class.isAssignableFrom(remoteInterface)); }
public void test01_getEJBHome() { try { final EJBHome home = ejbHomeHandle.getEJBHome(); assertNotNull("The EJBHome is null", home); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }
public void test01_getEJBHome() { try { final EJBHome home = ejbMetaData.getEJBHome(); assertNotNull("The EJBHome is null", home); } catch (final Exception e) { fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } }