Skip to content

Commit

Permalink
oops, forgot one
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@461 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Dec 7, 2008
1 parent b252be1 commit 02542e4
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions webbeans-ri/src/main/java/org/jboss/webbeans/util/Names.java
@@ -1,20 +1,28 @@
package org.jboss.webbeans.util;

import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.contexts.ApplicationContext;
import org.jboss.webbeans.ejb.EjbMetaData;
import org.jboss.webbeans.test.beans.Chicken;
import org.jboss.webbeans.test.ejb.model.valid.Laika;

/**
* Utility class to produce friendly names e.g. for debugging
*
* @author Pete Muir
*
*
*/
public class Names
{

private static Pattern CAPITAL_LETTERS = Pattern.compile("\\p{Upper}{1}\\p{Lower}*");

public static String scopeTypeToString(Class<? extends Annotation> scopeType)
{
String scopeName = scopeType.getSimpleName();
Expand All @@ -26,4 +34,36 @@ public static String scopeTypeToString(Class<? extends Annotation> scopeType)
}
return result.toString();
}

public static String ejbTypeFromMetaData(EjbMetaData<?> ejbMetaData)
{
if (ejbMetaData.isMessageDriven())
{
return "message driven";
}
else if (ejbMetaData.isSingleton())
{
return "singleton";
}
else if (ejbMetaData.isStateful())
{
return "stateful";
}
else if (ejbMetaData.isStateless())
{
return "stateless";
}
return "unknown";
}

public static int count(Iterable<?> iterable)
{
int count = 0;
for (Iterator<?> i = iterable.iterator(); i.hasNext();)
{
count++;
}
return count;
}

}

0 comments on commit 02542e4

Please sign in to comment.