Author: bdaw
Date: 2007-03-15 09:50:51 -0400 (Thu, 15 Mar 2007)
New Revision: 6687
Modified:
trunk/common/src/main/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
trunk/common/src/main/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
trunk/identity/build.xml
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java
Log:
- some minor code cleanup
- JavaBeanModelMBeanBuilder fix to handle overriden methods properly + testcase
Modified: trunk/common/src/main/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2007-03-15
13:39:19 UTC (rev 6686)
+++
trunk/common/src/main/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -87,6 +87,9 @@
//
for (Class c = from;c != null && !c.equals(to);c = c.getSuperclass())
{
+ Map currentClassGetters = new HashMap();
+ Map currentClassSetters = new HashMap();
+
Method[] methods = c.getDeclaredMethods();
for (int i = 0; i < methods.length; i++)
{
@@ -105,20 +108,23 @@
methodName.length() > 3)
{
String propertyName = methodName.substring(3);
- Method beanSetter = (Method)beanSetters.get(propertyName);
+ Map setters = new HashMap();
+ setters.putAll(beanSetters);
+ setters.putAll(currentClassSetters);
+ Method beanSetter = (Method)setters.get(propertyName);
if (beanSetter != null &&
!beanSetter.getParameterTypes()[0].equals(returnType))
{
throw new IllegalArgumentException("Property " +
propertyName + " has a setter" +
" type " + beanSetter.getParameterTypes()[0] + "
different from the corresponding" +
" getter type " + returnType);
}
- Method beanGetter = (Method)beanGetters.get(propertyName);
+ Method beanGetter = (Method)currentClassGetters.get(propertyName);
if (beanGetter != null)
{
throw new IllegalArgumentException("Property " +
propertyName + " has two getters " +
beanGetter + " and " + method);
}
- beanGetters.put(propertyName, method);
+ currentClassGetters.put(propertyName, method);
}
else if (methodName.startsWith("is") &&
!void.class.equals(returnType) &&
@@ -126,7 +132,10 @@
methodName.length() > 2)
{
String propertyName = methodName.substring(2);
- Method beanSetter = (Method)beanSetters.get(propertyName);
+ Map setters = new HashMap();
+ setters.putAll(beanSetters);
+ setters.putAll(currentClassSetters);
+ Method beanSetter = (Method)setters.get(propertyName);
if (beanSetter != null &&
!beanSetter.getParameterTypes()[0].equals(returnType))
{
throw new IllegalArgumentException("Property " +
propertyName + " has a setter" +
@@ -139,7 +148,7 @@
throw new IllegalArgumentException("Property " +
propertyName + " has two getters " +
beanGetter + " and " + method);
}
- beanGetters.put(propertyName, method);
+ currentClassGetters.put(propertyName, method);
}
else if (methodName.startsWith("set") &&
void.class.equals(returnType) &&
@@ -147,7 +156,11 @@
methodName.length() > 3)
{
String propertyName = methodName.substring(3);
- Method beanGetter = (Method)beanGetters.get(propertyName);
+ Map getters = new HashMap();
+ getters.putAll(beanGetters);
+ getters.putAll(currentClassGetters);
+ Method beanGetter = (Method)getters.get(propertyName);
+
if (beanGetter != null &&
!beanGetter.getReturnType().equals(parameterTypes[0]))
{
throw new IllegalArgumentException("Property " +
propertyName + " has a setter" +
@@ -161,12 +174,15 @@
beanSetter + " and " + method);
}
beanSetters.put(propertyName, method);
+ currentClassSetters.put(propertyName, method);
}
//
beanMethods.add(method);
}
}
+ beanGetters.putAll(currentClassGetters);
+ beanSetters.putAll(currentClassSetters);
}
// Keep track of property accessors methods
Modified:
trunk/common/src/main/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2007-03-15
13:39:19 UTC (rev 6686)
+++
trunk/common/src/main/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -120,6 +120,11 @@
}
}
+ public void testGetterOverride() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new
JavaBeanModelMBeanBuilder(TestOverridenExtend.class, Object.class);
+ }
+
public void testAttributesAreNotCached() throws Exception
{
AttributesAreNotCached aanc = new AttributesAreNotCached();
@@ -418,4 +423,24 @@
return tmp.toString();
}
}
+
+ public class TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+
+
+ }
+
+ public class TestOverridenExtend extends TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
}
Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml 2007-03-15 13:39:19 UTC (rev 6686)
+++ trunk/identity/build.xml 2007-03-15 13:50:51 UTC (rev 6687)
@@ -439,7 +439,7 @@
- <target name="tests-dev" depends="init"
if="HAVE_JDK_1.5">
+ <target name="tests-dev" depends="init, package-tests"
if="HAVE_JDK_1.5">
<property name="proto-libs"
value="${project.root}/proto-libs"/>
<execute-tests>
<!--
@@ -452,15 +452,15 @@
<x-test>
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>-->
- <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>-->
- <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPUserProfileModuleTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtUserModuleTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtRoleModuleTestCase"/>-->
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtUserModuleTestCase"/>-->
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtRoleModuleTestCase"/>
</x-test>
<x-classpath>
<pathelement
location="${build.lib}/portal-identity-lib.jar"/>
Modified:
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-03-15
13:39:19 UTC (rev 6686)
+++
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -109,8 +109,6 @@
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- //TODO: make a dtd for config files.
-
//parse config files
IdentityConfigurationMetaData meta =
ConfigurationParser.parseIdentityConfiguration(configFile);
IdentityConfigurationMetaData defaultMeta =
ConfigurationParser.parseIdentityConfiguration(defaultConfigFile);
@@ -156,8 +154,6 @@
}
- //TODO:update meta options using defaultMeta options
-
//create detault modules set
//Map[implementation] --> Map[Type] --> ModuleMetaData
@@ -237,7 +233,6 @@
updateDatasourceWithDefaults(ds, defaultDatasources);
//generate initial options
- //TODO:presence of config tag should be forced in dtd
Map configOptions = ds.getConfig().getOptions();
Map optionMap = new HashMap();
for (Iterator iterator1 = configOptions.keySet().iterator();
iterator1.hasNext();)
Modified: trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java 2007-03-15
13:39:19 UTC (rev 6686)
+++ trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -36,8 +36,6 @@
public interface MembershipModule
{
- //TODO: add isUserInRole method - it could gain better performance
-
/**
* Return the set of role objects that a given user has.
*
Modified:
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-03-15
13:39:19 UTC (rev 6686)
+++
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -107,8 +107,6 @@
throw new UnsupportedOperationException("User management is not supported in
this implementation of UserModule");
}
-
- //TODO: offset limit
public Set findUsers(int offset, int limit) throws IdentityException,
IllegalArgumentException
{
return findUsersFilteredByUserName("*", offset, limit);
Modified:
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-03-15
13:39:19 UTC (rev 6686)
+++
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -380,7 +380,7 @@
}
- //TODO: Implement usage of conditions!
+ //TODO: Implement usage of conditions
public Set findRoleMembers(String roleName, int offset, int limit, String
userNameFilter) throws IdentityException
{
//throw new UnsupportedOperationException("Not yet implemented");
Modified: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java 2007-03-15
13:39:19 UTC (rev 6686)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java 2007-03-15
13:50:51 UTC (rev 6687)
@@ -41,9 +41,7 @@
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(LDAPUserImpl.class);
- //TODO: make setters to update the state of the entry
-
- //TODO:this is to enable user act like a fasade to identity modules calls
+ //this is to enable user act like a fasade to identity modules calls
IdentityContext identityContext;
private UserProfileModule userProfileModule;