Package org.jboss.metadata

Examples of org.jboss.metadata.EntityMetaData


    * @jmx:managed-operation
    */
   public void remove(String id)
      throws Exception
   {
      EntityMetaData metaData = (EntityMetaData) m_container.getBeanMetaData();
      String primKeyClass = metaData.getPrimaryKeyClass();
      Object key = PropertyEditors.convertValue(id, primKeyClass);
      remove(key);
   }
View Full Code Here


      Object instance = ctx.getInstance();
      Class ejbClass = instance.getClass();
      Field cmpField;
      Class cmpFieldType;

      EntityMetaData metaData = (EntityMetaData)con.getBeanMetaData();
      Iterator i = metaData.getCMPFields();

      while (i.hasNext())
      {
         // get the field declaration
         try
View Full Code Here

   public void setContainer(Container container)
   {
      super.setContainer(container);
      if (container != null)
      {
         EntityMetaData meta = (EntityMetaData) container.getBeanMetaData();
         reentrant = meta.isReentrant();
      }
   }
View Full Code Here

         // This is an entity bean (lifespan: persistent)
         beanServantRegistry =
            servantRegistries.getServantRegistry(registryWithPersistentPOA);

         Class pkClass;
         EntityMetaData metaData = (EntityMetaData)container.getBeanMetaData();
         String pkClassName = metaData.getPrimaryKeyClass();
         try {
            if (pkClassName != null)
               pkClass = container.getClassLoader().loadClass(pkClassName);
            else
               pkClass = container.getClassLoader().loadClass(
                     metaData.getEjbClass()).getField(
                           metaData.getPrimKeyField()).getClass();
         }
         catch (NoSuchFieldException e) {
            logger.error("Unable to identify Bean's Primary Key class! "
                         + "Did you specify a primary key class and/or field? "
                         + "Does that field exist?");
View Full Code Here

      log = Logger.getLogger(getClass().getName() + "." + tableName);

      this.schema = schema;
      this.tableId = tableId;

      final EntityMetaData entityMetaData = ((EntityMetaData)entity.getContainer().getBeanMetaData());
      final ConfigurationMetaData containerConf = entityMetaData.getContainerConfiguration();
      dontFlushCreated = containerConf.isInsertAfterEjbPostCreate();

      // create cache
      final Element cacheConf = containerConf.getContainerCacheConf();
      final Element cachePolicy = cacheConf == null ? null : MetaData.getOptionalChild(cacheConf, "cache-policy-conf");

      int minCapacity;
      int maxCapacity;
      if(cachePolicy != null)
      {
         String str = MetaData.getOptionalChildContent(cachePolicy, "min-capacity");
         minCapacity = (str == null ? 1000 : Integer.parseInt(str));
         str = MetaData.getOptionalChildContent(cachePolicy, "max-capacity");
         maxCapacity = (str == null ? 10000 : Integer.parseInt(str));
      }
      else
      {
         minCapacity = 1000;
         maxCapacity = 10000;
      }

      final Element otherConf = cacheConf == null ? null : MetaData.getOptionalChild(cacheConf, "cache-policy-conf-other");

      int partitionsTotal;
      final boolean invalidable;
      final Element batchCommitStrategy;
      if(otherConf != null)
      {
         String str = MetaData.getOptionalChildContent(otherConf, "partitions");
         partitionsTotal = (str == null ? 10 : Integer.parseInt(str));
         batchCommitStrategy = MetaData.getOptionalChild(otherConf, "batch-commit-strategy");
         invalidable = MetaData.getOptionalChild(otherConf, "invalidable") == null ? false : true;
      }
      else
      {
         partitionsTotal = 10;
         batchCommitStrategy = null;
         invalidable = false;
      }

      if(cachePolicy != null)
      {
         cache = new PartitionedTableCache(minCapacity, maxCapacity, partitionsTotal);

         String periodStr = MetaData.getOptionalChildContent(cachePolicy, "overager-period");
         String maxAgeStr = MetaData.getOptionalChildContent(cachePolicy, "max-bean-age");
         if(periodStr != null && maxAgeStr == null || maxAgeStr != null && periodStr == null)
         {
            throw new DeploymentException(
               "Failed to initialize age-out thread for entity " + entity.getEntityName() +
               ": overager-period or max-bean-age is missing!");
         }
         else if(periodStr != null && maxAgeStr != null)
         {
            long period = Long.parseLong(periodStr);
            long maxAge = Long.parseLong(maxAgeStr);
            ((PartitionedTableCache)cache).initOverager(period, maxAge, entity.getEntityName() + " overager");

            if(log.isTraceEnabled())
            {
               log.trace("initialized age-out thread for " + entity.getEntityName() +
                  ": overager-period=" + period + ", max-bean-age=" + maxAge);
            }
         }

         final MBeanServer server = MBeanServerLocator.locateJBoss();
         serviceController = (ServiceControllerMBean)
            MBeanProxyExt.create(ServiceControllerMBean.class,
               ServiceControllerMBean.OBJECT_NAME,
               server);
         try
         {
            cacheName =
               new ObjectName("jboss.cmp:service=tablecache,ejbname=" + metadata.getName() + ",table=" + tableName);
            server.registerMBean(cache, cacheName);
            serviceController.create(cacheName);
         }
         catch(Exception e)
         {
            throw new DeploymentException("Failed to register table cache for " + tableName, e);
         }
      }
      else
      {
         cache = Cache.NONE;
      }

      if(invalidable)
      {
         String groupName = entityMetaData.getDistributedCacheInvalidationConfig().getInvalidationGroupName();
         String imName = entityMetaData.getDistributedCacheInvalidationConfig().getInvalidationManagerName();

         InvalidationManagerMBean im = (InvalidationManagerMBean) Registry.lookup(imName);
         InvalidationGroup invalidationGroup = im.getInvalidationGroup(groupName);

         cacheInvalidator = new CacheInvalidator(cache, entity.getContainer().getTransactionManager(), invalidationGroup);
View Full Code Here

     
      EntityBeanMetaData entity = (EntityBeanMetaData) specMetaData.getEnterpriseBean("EjbName");
      assertNotNull(entity);
      assertTrue(entity.isCMP1x());
     
      EntityMetaData emd = (EntityMetaData) old.getBeanByEjbName("EjbName");
      assertNotNull(emd);
      assertTrue(emd.isCMP1x());

      JBossMetaData jbossMetaData = unmarshal("JBoss30_entityConfig.xml", JBossMetaData.class, null);
      JBossMetaData mergedMetaData = new JBossMetaData();
      mergedMetaData.merge(jbossMetaData, specMetaData);
View Full Code Here

      assertTrue(securityIdentityMetaData.getUseCallerIdentity());
     
      assertNullEntity("entity0", applicationMetaData);
      assertFullEntity("entity1", applicationMetaData, mode);
      assertFullEntity("entity2", applicationMetaData, mode);
      EntityMetaData entity = assertEntity("entity3EjbName", applicationMetaData);
      assertTrue(entity.isBMP());
      entity = assertEntity("entity4EjbName", applicationMetaData);
      assertFalse(entity.isReentrant());
      entity = assertEntity("entity5EjbName", applicationMetaData);
      assertTrue(entity.isCMP1x());
      assertTrue(entity.isCMP1x());
     
      assertNullMDB("mdb0", applicationMetaData);
      assertFullMDB("mdb1", applicationMetaData, mode);
      assertFullMDB("mdb2", applicationMetaData, mode);
   }
View Full Code Here

      return entity;
   }

   private EntityMetaData assertFullEntity(String ejbName, ApplicationMetaData applicationMetaData, Mode mode)
   {
      EntityMetaData entity = assertEntity(ejbName + "EjbName", applicationMetaData);
      assertEquals(ejbName + "Home", entity.getHome());
      assertEquals(ejbName + "Remote", entity.getRemote());
      assertEquals(ejbName + "LocalHome", entity.getLocalHome());
      assertEquals(ejbName + "Local",entity.getLocal());
      assertEquals(ejbName + "EjbClass", entity.getEjbClass());
      assertTrue(entity.isCMP());
      assertEquals(ejbName + "PrimKeyClass", entity.getPrimaryKeyClass());
      assertTrue(entity.isReentrant());
      assertTrue(entity.isCMP2x());
      assertFalse(entity.isCMP1x());
      assertEquals(ejbName + "AbstractSchemaName", entity.getAbstractSchemaName());
      assertCmpFields(ejbName, 2, entity.getCMPFields());
      assertEquals(ejbName + "PrimKeyField",entity.getPrimKeyField());
      assertEnvironment(ejbName, entity, true, mode);
      assertMethodAttributes(ejbName, entity);
      assertMethodPermissions(ejbName, 7, entity);
      assertExcludedMethods(ejbName, entity.getExcludedMethods());
      assertSecurityRoleRefs(ejbName, 2, entity.getSecurityRoleReferences());
      assertSecurityIdentity(ejbName, "SecurityIdentity", entity.getSecurityIdentityMetaData(), true);
      assertQueries(ejbName, 3, entity.getQueries());
     
      return entity;
   }
View Full Code Here

      return entity;
   }

   private EntityMetaData assertNullEntity(String ejbName, ApplicationMetaData applicationMetaData)
   {
      EntityMetaData entity = assertEntity(ejbName + "EjbName", applicationMetaData);
      assertEquals(ejbName+"EjbClass", entity.getEjbClass());
      assertEquals(ejbName+"EjbKeyClass", entity.getPrimaryKeyClass());

      assertNull(entity.getHome());
      assertNull(entity.getRemote());
      assertNull(entity.getLocalHome());
      assertNull(entity.getLocal());
      assertTrue(entity.isCMP());
      assertFalse(entity.isReentrant());
      if(applicationMetaData.isEJB2x())
         assertTrue(entity.isCMP2x());
      else
         assertFalse(entity.isCMP2x());
      assertFalse(entity.isCMP1x());
      assertNull(entity.getAbstractSchemaName());
      assertEmptyIterator(entity.getCMPFields());
      assertNull(entity.getPrimKeyField());
      assertNullEnvironment(entity);
      assertDefaultMethodAttributes(ejbName, entity);
      assertEmptyIterator(entity.getPermissionMethods());
      assertEmptyIterator(entity.getExcludedMethods());
      assertEmptyIterator(entity.getSecurityRoleReferences());
      assertNotNull(entity.getSecurityIdentityMetaData());
      assertEmptyIterator(entity.getQueries());
     
      return entity;
   }
View Full Code Here

      return entity;
   }
  
   protected EntityMetaData assertEntity(String ejbName, ApplicationMetaData applicationMetaData)
   {
      EntityMetaData entity = assertEnterpriseBean(ejbName, applicationMetaData, EntityMetaData.class);
      assertFalse(entity.isSession());
      assertTrue(entity.isEntity());
      assertFalse(entity.isMessageDriven());
      return entity;
   }
View Full Code Here

TOP

Related Classes of org.jboss.metadata.EntityMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.