/** * Returns a new instance of the bean class or a subclass of the bean class. * * @return the new instance */ public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
/** * Returns a new instance of the bean class or a subclass of the bean class. * * @return the new instance * * @throws Exception */ public Object createBeanClassInstance () throws Exception { return con.getBeanClass ().newInstance (); }
/** * Returns a new instance of the bean class or a subclass of the bean class. * * @return the new instance * * @throws Exception */ public Object createBeanClassInstance () throws Exception { return con.getBeanClass ().newInstance (); }
public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
private void createMethodCache(Method[] methods) throws NoSuchMethodException { // Create cache of create methods Class beanClass = con.getBeanClass(); for(int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if(name.startsWith("create")) { Class[] types = methods[i].getParameterTypes(); try { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Method beanMethod = beanClass.getMethod("ejb" + nameSuffix, types); createMethods.put(methods[i], beanMethod); beanMethod = beanClass.getMethod("ejbPost" + nameSuffix, types); postCreateMethods.put(methods[i], beanMethod); } catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); } } } }
/** * create the service, do expensive operations etc */ protected void createService() throws Exception { this.beans = new HashMap(1000); String ejbName = con.getBeanMetaData ().getEjbName (); idField = con.getBeanClass ().getField ("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
try createMethods.put(methods[i], con.getBeanClass().getMethod("ejb" + nameSuffix, methods[i].getParameterTypes())); log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); postCreateMethods.put(methods[i], con.getBeanClass().getMethod("ejbPost" + nameSuffix, methods[i].getParameterTypes())); log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; finderMethods.put(methods[i], con.getBeanClass().getMethod("ejbF" + methods[i].getName().substring(1), methods[i].getParameterTypes()));
/** * create the service, do expensive operations etc */ public void create () throws Exception { BeanMetaData bmd = con.getBeanMetaData(); ClusterConfigMetaData ccmd = bmd.getClusterConfigMetaData (); String partitionName = ccmd.getPartitionName(); String name = "jboss:service=DistributedState,partitionName="+partitionName; ds = (DistributedState)org.jboss.system.Registry.lookup (name); String ejbName = bmd.getEjbName(); this.DS_CATEGORY = "CMPClusteredInMemoryPersistenceManager-" + ejbName; idField = con.getBeanClass ().getField ("id"); try { isModified = con.getBeanClass ().getMethod ("isModified", new Class[0]); if (!isModified.getReturnType ().equals (Boolean.TYPE)) isModified = null; // Has to have "boolean" as return type! } catch (NoSuchMethodException ignored) { } }
idField = con.getBeanClass().getField("id"); log.debug("Using id field: " + idField); isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) {
public void create() throws Exception { ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]); ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]); ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]); ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]); ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]); // Create cache of create methods if (con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache( methods ); } if (con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache( methods ); } try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) isModified = null; // Has to have "boolean" as return type! } catch (NoSuchMethodException ignored) {} }
public InstanceFactory(JDBCStoreManager2 manager, JDBCEntityBridge2 entity) throws Exception { EntityContainer theContainer = manager.getContainer(); beanClass = theContainer.getBeanClass(); fieldMap = createFieldMap(entity); selectorMap = createSelectorMap(entity, manager.getQueryFactory()); // use proxy generator to create one implementation EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); Class[] classes = new Class[]{beanClass}; ClassLoader classLoader = beanClass.getClassLoader(); Object o = Proxy.newProxyInstance(classLoader, classes, handler); // steal the constructor from the object beanProxyConstructor = o.getClass().getConstructor(new Class[]{InvocationHandler.class}); // now create one to make sure everything is cool newInstance(); }
public JDBCCreateBeanClassInstanceCommand(JDBCStoreManager manager) throws Exception { EntityContainer theContainer = manager.getContainer(); entityBridge = (JDBCEntityBridge) manager.getEntityBridge(); beanClass = theContainer.getBeanClass(); fieldMap = createFieldMap(); selectorMap = createSelectorMap(); // use proxy generator to create one implementation EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); Class[] classes = new Class[]{beanClass}; ClassLoader classLoader = beanClass.getClassLoader(); Object o = Proxy.newProxyInstance(classLoader, classes, handler); // steal the constructor from the object beanProxyConstructor = o.getClass().getConstructor(new Class[]{InvocationHandler.class}); // now create one to make sure everything is cool execute(); }