From: erik Date: Thu, 15 Apr 2010 22:00:38 +0000 (+0000) Subject: updated coding rules. X-Git-Tag: wamblee-utils-0.2.2^2~90 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=81fe8784a2182e25f92a7591ec5b0fba00afb828;p=utils updated coding rules. No longer using underscores for private variables. --- diff --git a/security/src/main/java/org/wamblee/security/authorization/AllOperation.java b/security/src/main/java/org/wamblee/security/authorization/AllOperation.java index c76d00ca..f5b5a7f1 100644 --- a/security/src/main/java/org/wamblee/security/authorization/AllOperation.java +++ b/security/src/main/java/org/wamblee/security/authorization/AllOperation.java @@ -26,14 +26,14 @@ public class AllOperation implements Operation { /** * Operation name. */ - private String _name; + private String name; /** * Constructs an all operation. * */ public AllOperation() { - _name = OPERATION; + name = OPERATION; } /** @@ -42,14 +42,14 @@ public class AllOperation implements Operation { * @param aName Name of the operation. This name must be unique among all operations. */ protected AllOperation(String aName) { - _name = aName; + name = aName; } /* (non-Javadoc) * @see org.wamblee.security.authorization.Operation#getName() */ public String getName() { - return _name; + return name; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/AuthorizationException.java b/security/src/main/java/org/wamblee/security/authorization/AuthorizationException.java index d7a81fd5..a9c930db 100644 --- a/security/src/main/java/org/wamblee/security/authorization/AuthorizationException.java +++ b/security/src/main/java/org/wamblee/security/authorization/AuthorizationException.java @@ -24,21 +24,21 @@ package org.wamblee.security.authorization; */ public class AuthorizationException extends RuntimeException { - private Object _resource; - private Operation _operation; + private Object resource; + private Operation operation; public AuthorizationException(Object aResource, Operation aOperation) { super("Operation '" + aOperation + "' not allowed on '" + aResource + "'"); - _resource = aResource; - _operation = aOperation; + resource = aResource; + operation = aOperation; } public Object getResource() { - return _resource; + return resource; } public Operation getOperation() { - return _operation; + return operation; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java b/security/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java index b3dc524d..1d6499e0 100644 --- a/security/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java +++ b/security/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java @@ -37,17 +37,17 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A /** * List of ordered authorization rules. */ - private List _rules; + private List rules; /** * User accessor used to obtain the current user. */ - private UserAccessor _userAccessor; + private UserAccessor userAccessor; /** * Name for this instance of the authorization service. */ - private String _name; + private String name; /** * Constructs the service. @@ -55,18 +55,18 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A * @param aName Name of this instance of the service. */ public DefaultAuthorizationService(UserAccessor aAccessor, String aName) { - _rules = new ArrayList(); - _userAccessor = aAccessor; - _name = aName; + rules = new ArrayList(); + userAccessor = aAccessor; + name = aName; } /** * Constructs the authorization service. */ public DefaultAuthorizationService() { - _rules = new ArrayList(); - _userAccessor = null; - _name = null; + rules = new ArrayList(); + userAccessor = null; + name = null; } /** @@ -74,15 +74,15 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A * @param aUserAccessor User accessor. */ public void setUserAccessor(UserAccessor aUserAccessor) { - _userAccessor = aUserAccessor; + userAccessor = aUserAccessor; } /* (non-Javadoc) * @see org.wamblee.security.authorization.AuthorizationService#isAllowed(java.lang.Object, org.wamblee.security.authorization.Operation) */ public boolean isAllowed(Object aResource, Operation aOperation) { - User user = _userAccessor.getCurrentUser(); - for (AuthorizationRule rule: _rules) { + User user = userAccessor.getCurrentUser(); + for (AuthorizationRule rule: rules) { switch ( rule.isAllowed(aResource, aOperation, user)) { case DENIED: { return false; } case GRANTED: { return true; } @@ -102,39 +102,39 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A } protected String getName() { - return _name; + return name; } public void setName(String aName) { - _name = aName; + name = aName; } /* (non-Javadoc) * @see org.wamblee.security.authorization.AuthorizationService#getRules() */ public AuthorizationRule[] getRules() { - return _rules.toArray(new AuthorizationRule[0]); + return rules.toArray(new AuthorizationRule[0]); } /* (non-Javadoc) * @see org.wamblee.security.authorization.AuthorizationService#appendRule(org.wamblee.security.authorization.AuthorizationRule) */ public void appendRule(AuthorizationRule aRule) { - _rules.add(aRule); + rules.add(aRule); } /* (non-Javadoc) * @see org.wamblee.security.authorization.AuthorizationService#insertRuleAfter(int, org.wamblee.security.authorization.AuthorizationRule) */ public void insertRuleAfter(int aIndex, AuthorizationRule aRule) { - _rules.add(aIndex, aRule); + rules.add(aIndex, aRule); } /* (non-Javadoc) * @see org.wamblee.security.authorization.AuthorizationService#removeRule(int) */ public void removeRule(int aIndex) { - _rules.remove(aIndex); + rules.remove(aIndex); } /** @@ -142,7 +142,7 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A * @return The rules. */ protected List getMappedRules() { - return _rules; + return rules; } /** @@ -150,6 +150,6 @@ public class DefaultAuthorizationService extends AbstractPersistent implements A * @param aRules The rules. */ protected void setMappedRules(List aRules) { - _rules = aRules; + rules = aRules; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java b/security/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java index 0a240923..472b2dac 100644 --- a/security/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java +++ b/security/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java @@ -29,12 +29,12 @@ import java.util.TreeMap; */ public class DefaultOperationRegistry implements OperationRegistry { - private Map _operations; + private Map operations; public DefaultOperationRegistry(Operation[] aOperations) { - _operations = new TreeMap(); + operations = new TreeMap(); for (Operation operation: aOperations) { - _operations.put(operation.getName(), operation); + operations.put(operation.getName(), operation); } } @@ -42,7 +42,7 @@ public class DefaultOperationRegistry implements OperationRegistry { * @see org.wamblee.security.authorization.OperationRegistry#getOperations(java.lang.Class) */ public Operation[] getOperations(Class aResourceClass) { - return _operations.values().toArray(new Operation[0]); + return operations.values().toArray(new Operation[0]); } /* (non-Javadoc) @@ -76,7 +76,7 @@ public class DefaultOperationRegistry implements OperationRegistry { String[] names = aOperationsString.split(","); ArrayList result = new ArrayList(); for (String name: names) { - Operation operation = _operations.get(name); + Operation operation = operations.get(name); if ( operation == null ) { throw new IllegalArgumentException("Unknown operation '" + name + "'"); } diff --git a/security/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java b/security/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java index 8949fc76..c0e91896 100644 --- a/security/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java +++ b/security/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java @@ -29,14 +29,14 @@ public class GroupUserCondition extends AbstractPersistent implements UserCondit /** * Group the user must be in. */ - private String _group; + private String group; /** * Constructs the condition. * @param aGroup Group the user must be in. */ public GroupUserCondition(String aGroup) { - _group = aGroup; + group = aGroup; } /** @@ -44,28 +44,28 @@ public class GroupUserCondition extends AbstractPersistent implements UserCondit * */ protected GroupUserCondition() { - _group = null; + group = null; } /* (non-Javadoc) * @see org.wamblee.security.authorization.UserCondition#matches(org.wamblee.usermgt.UserAccessor) */ public boolean matches(User aUser) { - return aUser.isInGroup(_group); + return aUser.isInGroup(group); } /** - * @return Returns the _group. + * @return Returns the group. */ protected String getGroup() { - return _group; + return group; } /** - * @param _group The _group to set. + * @param group The group to set. */ protected void setGroup(String aGroup) { - _group = aGroup; + group = aGroup; } /* (non-Javadoc) @@ -73,7 +73,7 @@ public class GroupUserCondition extends AbstractPersistent implements UserCondit */ @Override public String toString() { - return "GroupUserCondition(group=" + _group + ")"; + return "GroupUserCondition(group=" + group + ")"; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java b/security/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java index e5a4d686..b738b5dd 100644 --- a/security/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java +++ b/security/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java @@ -27,7 +27,7 @@ public class IsaOperationCondition extends AbstractPersistent implements /** * Operation that the other operation must be a subclass of. */ - private Class _operation; + private Class operation; /** * Constructs the condition. @@ -36,7 +36,7 @@ public class IsaOperationCondition extends AbstractPersistent implements * Operation that an operation must be an instance of. */ public IsaOperationCondition(Class aOperation) { - _operation = aOperation; + operation = aOperation; } /** @@ -44,7 +44,7 @@ public class IsaOperationCondition extends AbstractPersistent implements * */ public IsaOperationCondition() { - _operation = null; + operation = null; } /* @@ -53,7 +53,7 @@ public class IsaOperationCondition extends AbstractPersistent implements * @see org.wamblee.security.authorization.OperationCondition#matches(org.wamblee.security.authorization.Operation) */ public boolean matches(Operation aOperation) { - return _operation.isInstance(aOperation); + return operation.isInstance(aOperation); } /** @@ -62,10 +62,10 @@ public class IsaOperationCondition extends AbstractPersistent implements * @return Operation string. */ protected String getOperationString() { - if (_operation == null) { + if (operation == null) { return null; } - return _operation.getName(); + return operation.getName(); } /** @@ -79,7 +79,7 @@ public class IsaOperationCondition extends AbstractPersistent implements return; } try { - _operation = (Class)Class.forName(aOperation); + operation = (Class)Class.forName(aOperation); } catch (Exception e) { throw new IllegalArgumentException("Unknown class '" + aOperation + "'"); } @@ -92,7 +92,7 @@ public class IsaOperationCondition extends AbstractPersistent implements */ @Override public String toString() { - return "IsaOperationCondition(operation=" + _operation.getName() + ")"; + return "IsaOperationCondition(operation=" + operation.getName() + ")"; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java b/security/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java index 5c373e84..2cde6808 100644 --- a/security/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java +++ b/security/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java @@ -28,14 +28,14 @@ public class RegexpPathCondition extends AbstractPersistent implements PathCondi /** * String the path must start with. */ - private String _pattern; + private String pattern; /** * Constructs the condition. * @param aPattern String the path must start with. */ public RegexpPathCondition(String aPattern) { - _pattern = aPattern; + pattern = aPattern; } /** @@ -43,28 +43,28 @@ public class RegexpPathCondition extends AbstractPersistent implements PathCondi * */ protected RegexpPathCondition() { - _pattern = null; + pattern = null; } /* (non-Javadoc) * @see org.wamblee.security.authorization.PathCondition#matches(java.lang.String) */ public boolean matches(String aPath) { - return aPath.matches(_pattern); + return aPath.matches(pattern); } /** * @return Returns the _path. */ protected String getPattern() { - return _pattern; + return pattern; } /** * @param aPattern The _path to set. */ protected void setPattern(String aPattern) { - _pattern = aPattern; + pattern = aPattern; } /* (non-Javadoc) @@ -72,6 +72,6 @@ public class RegexpPathCondition extends AbstractPersistent implements PathCondi */ @Override public String toString() { - return "RegexpCondition(pattern = '" + _pattern + "')"; + return "RegexpCondition(pattern = '" + pattern + "')"; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java b/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java index 0d22d1ca..a3184968 100644 --- a/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java +++ b/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java @@ -55,27 +55,27 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements /** * Result that the rule will return in case there is a match. */ - private AuthorizationResult _result; + private AuthorizationResult result; /** * A condition which specifies which users the rule is for. */ - private UserCondition _userCondition; + private UserCondition userCondition; /** * Path the rule applies for. */ - private PathCondition _pathCondition; + private PathCondition pathCondition; /** * Resource class that the rule applies for. */ - private Class _resourceClass; + private Class resourceClass; /** * Operation that this rule is for. */ - private OperationCondition _operationCondition; + private OperationCondition operationCondition; /** * Constructs an authorization rule. @@ -91,11 +91,11 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements if ( !aResult.equals(GRANTED) && !aResult.equals(DENIED)) { throw new IllegalArgumentException("Only GRANTED or DENIED may be used: " + aResult); } - _result = aResult; - _userCondition = aUserCondition; - _pathCondition = aPathCondition; - _resourceClass = aResourceClass; - _operationCondition = aOperationCondition; + result = aResult; + userCondition = aUserCondition; + pathCondition = aPathCondition; + resourceClass = aResourceClass; + operationCondition = aOperationCondition; } /** @@ -103,11 +103,11 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * */ protected UrlAuthorizationRule(Class aResourceClass) { - _result = null; - _userCondition = null; - _pathCondition = null; - _resourceClass = aResourceClass; - _operationCondition = null; + result = null; + userCondition = null; + pathCondition = null; + resourceClass = aResourceClass; + operationCondition = null; } /** @@ -115,11 +115,11 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * */ protected UrlAuthorizationRule() { - _result = null; - _userCondition = null; - _pathCondition = null; - _resourceClass = null; - _operationCondition = null; + result = null; + userCondition = null; + pathCondition = null; + resourceClass = null; + operationCondition = null; } @@ -129,7 +129,7 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * @see org.wamblee.security.authorization.AuthorizationRule#getSupportedTypes() */ public Class[] getSupportedTypes() { - return new Class[] { _resourceClass }; + return new Class[] { resourceClass }; } /* @@ -139,7 +139,7 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * org.wamblee.security.authorization.Operation) */ public AuthorizationResult isAllowed(Object aResource, Operation anOperation, User aUser) { - if ( ! _resourceClass.isInstance(aResource)) { + if ( ! resourceClass.isInstance(aResource)) { return UNSUPPORTED_RESOURCE; } String path = getResourcePath(aResource); @@ -154,22 +154,22 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * @return Authorization result, */ protected AuthorizationResult isAllowed(String aPath, Operation aOperation, User aUser) { - if ( ! _pathCondition.matches(aPath) ) { + if ( ! pathCondition.matches(aPath) ) { return UNDECIDED; } - if ( !_operationCondition.matches(aOperation) ) { + if ( !operationCondition.matches(aOperation) ) { return UNDECIDED; } - if ( !_userCondition.matches(aUser)) { + if ( !userCondition.matches(aUser)) { return UNDECIDED; } - return _result; + return result; } /** * Gets the path of the resource. * @param aResource Resource, guaranteed to be an instance of - * {@link #_resourceClass}. + * {@link #resourceClass}. * @return Path of the resource. */ protected abstract String getResourcePath(Object aResource); @@ -179,10 +179,10 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements */ @Override public String toString() { - return "UrlAUthorizationRule(result = " + _result + - ", pathCondition = " + _pathCondition + - ", userCondition = " + _userCondition + - ", resourceClass = " + _resourceClass + ")"; + return "UrlAUthorizationRule(result = " + result + + ", pathCondition = " + pathCondition + + ", userCondition = " + userCondition + + ", resourceClass = " + resourceClass + ")"; } /** @@ -190,10 +190,10 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * @return Result. */ protected String getAuthorizationResultString() { - if ( _result == null ) { + if ( result == null ) { return null; } - return _result.toString(); + return result.toString(); } /** @@ -201,19 +201,19 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * @param aResult Result. */ protected void setAuthorizationResultString(String aResult) { - _result = AuthorizationResult.valueOf(aResult); + result = AuthorizationResult.valueOf(aResult); } protected String getResourceClassName() { - if ( _resourceClass == null ) { + if ( resourceClass == null ) { return ""; } - return _resourceClass.getName(); + return resourceClass.getName(); } protected void setResourceClassName(String aResourceClass) { try { - _resourceClass = Class.forName(aResourceClass); + resourceClass = Class.forName(aResourceClass); } catch (ClassNotFoundException e) { LOGGER.error("Cannot find resource class '" + aResourceClass + "'", e); throw new IllegalArgumentException(e.getMessage(), e); @@ -221,44 +221,44 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements } /** - * @return Returns the _operationCondition. + * @return Returns the operationCondition. */ public OperationCondition getOperationCondition() { - return _operationCondition; + return operationCondition; } /** - * @param aOperationCondition The _operationCondition to set. + * @param aOperationCondition The operationCondition to set. */ protected void setOperationCondition(OperationCondition aOperationCondition) { - _operationCondition = aOperationCondition; + operationCondition = aOperationCondition; } /** - * @return Returns the _pathCondition. + * @return Returns the pathCondition. */ public PathCondition getPathCondition() { - return _pathCondition; + return pathCondition; } /** - * @param aPathCondition The _pathCondition to set. + * @param aPathCondition The pathCondition to set. */ protected void setPathCondition(PathCondition aPathCondition) { - _pathCondition = aPathCondition; + pathCondition = aPathCondition; } /** - * @return Returns the _userCondition. + * @return Returns the userCondition. */ public UserCondition getUserCondition() { - return _userCondition; + return userCondition; } /** - * @param aUserCondition The _userCondition to set. + * @param aUserCondition The userCondition to set. */ protected void setUserCondition(UserCondition aUserCondition) { - _userCondition = aUserCondition; + userCondition = aUserCondition; } } diff --git a/security/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java b/security/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java index dfe2439c..895e77e6 100644 --- a/security/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java +++ b/security/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java @@ -50,32 +50,32 @@ public class PersistentAuthorizationService extends AbstractPersistent /** * Authorization service to use. */ - private DefaultAuthorizationService _service; + private DefaultAuthorizationService service; /** * Hibernate template to use. */ - private HibernateTemplate _template; + private HibernateTemplate template; /** * User accessor. */ - private UserAccessor _userAccessor; + private UserAccessor userAccessor; /** * Name of the service. */ - private String _name; + private String name; /** * Refresh interval in milliseconds. */ - private final long _refreshInterval; + private final long refreshInterval; /** * Last refresh time. */ - private long _lastRefreshTime; + private long lastRefreshTime; /** * Constructs the persistent service. @@ -93,34 +93,34 @@ public class PersistentAuthorizationService extends AbstractPersistent public PersistentAuthorizationService(String aName, HibernateTemplate aTemplate, UserAccessor aAccessor, long aRefreshInterval) { - _template = aTemplate; - _refreshInterval = aRefreshInterval; - _lastRefreshTime = System.currentTimeMillis(); - _userAccessor = aAccessor; - _name = aName; + template = aTemplate; + refreshInterval = aRefreshInterval; + lastRefreshTime = System.currentTimeMillis(); + userAccessor = aAccessor; + name = aName; } /** * Initialize service if needed. */ private void initialize() { - if (_service == null) { - List result = _template + if (service == null) { + List result = template .findByNamedQueryAndNamedParam(FIND_QUERY, NAME_PARAM, - _name); + name); if (result.size() > 1) { throw new IllegalArgumentException( - "Returned more than one service for name '" + _name + "Returned more than one service for name '" + name + "' (" + result.size() + ")"); } if (result.size() == 0) { - _service = new DefaultAuthorizationService(_userAccessor, _name); - _template.persist(_service); + service = new DefaultAuthorizationService(userAccessor, name); + template.persist(service); } else { - _service = result.get(0); - _service.setUserAccessor(_userAccessor); + service = result.get(0); + service.setUserAccessor(userAccessor); } } } @@ -134,7 +134,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public boolean isAllowed(Object aResource, Operation aOperation) { initialize(); refresh(); - return _service.isAllowed(aResource, aOperation); + return service.isAllowed(aResource, aOperation); } /* (non-Javadoc) @@ -143,7 +143,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public T check(T aResource, Operation aOperation) { initialize(); refresh(); - return _service.check(aResource, aOperation); + return service.check(aResource, aOperation); } /* @@ -154,7 +154,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public AuthorizationRule[] getRules() { initialize(); refresh(); - return _service.getRules(); + return service.getRules(); } /* @@ -165,7 +165,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public void appendRule(AuthorizationRule aRule) { initialize(); refresh(); - _service.appendRule(aRule); + service.appendRule(aRule); save(); } @@ -177,7 +177,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public void removeRule(int aIndex) { initialize(); refresh(); - _service.removeRule(aIndex); + service.removeRule(aIndex); save(); } @@ -190,7 +190,7 @@ public class PersistentAuthorizationService extends AbstractPersistent public void insertRuleAfter(int aIndex, AuthorizationRule aRule) { initialize(); refresh(); - _service.insertRuleAfter(aIndex, aRule); + service.insertRuleAfter(aIndex, aRule); save(); } @@ -200,9 +200,9 @@ public class PersistentAuthorizationService extends AbstractPersistent */ private synchronized void refresh() { long time = System.currentTimeMillis(); - if ( time - _lastRefreshTime > _refreshInterval ) { - _template.refresh(_service); - _lastRefreshTime = time; + if ( time - lastRefreshTime > refreshInterval ) { + template.refresh(service); + lastRefreshTime = time; } } @@ -210,6 +210,6 @@ public class PersistentAuthorizationService extends AbstractPersistent * Saves any changes to the service state if necessary. */ private void save() { - HibernateSupport.merge(_template, _service); + HibernateSupport.merge(template, service); } } diff --git a/security/src/main/java/org/wamblee/usermgt/AbstractUserSet.java b/security/src/main/java/org/wamblee/usermgt/AbstractUserSet.java index 1a3096f7..b000d687 100644 --- a/security/src/main/java/org/wamblee/usermgt/AbstractUserSet.java +++ b/security/src/main/java/org/wamblee/usermgt/AbstractUserSet.java @@ -28,18 +28,18 @@ public abstract class AbstractUserSet implements UserSet { /** * Password validator. */ - private NameValidator _passwordValidator; + private NameValidator passwordValidator; /** * Password encoder. */ - private MessageDigester _passwordEncoder; + private MessageDigester passwordEncoder; protected AbstractUserSet(NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) { - _passwordValidator = aPasswordValidator; - _passwordEncoder = aPasswordEncoder; + passwordValidator = aPasswordValidator; + passwordEncoder = aPasswordEncoder; } /** @@ -47,15 +47,15 @@ public abstract class AbstractUserSet implements UserSet { * @param aUser User. */ protected void setPasswordInfo(User aUser) { - aUser.setPasswordValidator(_passwordValidator); - aUser.setPasswordEncoder(_passwordEncoder); + aUser.setPasswordValidator(passwordValidator); + aUser.setPasswordEncoder(passwordEncoder); } /* (non-Javadoc) * @see org.wamblee.usermgt.UserSet#createUser(java.lang.String, java.lang.String, org.wamblee.usermgt.Group) */ public User createUser(String aUsername, String aPassword, Group aGroup) throws UserMgtException { - User user = new User(aUsername, aPassword, aGroup, _passwordValidator, _passwordEncoder); + User user = new User(aUsername, aPassword, aGroup, passwordValidator, passwordEncoder); if (contains(user)) { throw new UserMgtException(DUPLICATE_USER, user); } diff --git a/security/src/main/java/org/wamblee/usermgt/Group.java b/security/src/main/java/org/wamblee/usermgt/Group.java index 1e7a3f59..a8535417 100644 --- a/security/src/main/java/org/wamblee/usermgt/Group.java +++ b/security/src/main/java/org/wamblee/usermgt/Group.java @@ -30,7 +30,7 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl /** * Group name. */ - private String _name; + private String name; /** * Constructs the group. @@ -38,17 +38,17 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl */ Group(String aName) { super(); - _name = aName; + name = aName; } public Group(Group aGroup) { super(aGroup); - _name = aGroup._name; + name = aGroup.name; } protected Group() { super(); - _name = null; + name = null; } /** @@ -56,7 +56,7 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl * @return Group name. */ public String getName() { - return _name; + return name; } /** @@ -64,7 +64,7 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl * @param aName Group name. */ void setName(String aName) { - _name = aName; + name = aName; } /* (non-Javadoc) @@ -75,7 +75,7 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl if ( !( aGroup instanceof Group )) { return false; } - return _name.equals(((Group)aGroup)._name); + return name.equals(((Group)aGroup).name); } /* (non-Javadoc) @@ -83,14 +83,14 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl */ @Override public int hashCode() { - return _name.hashCode(); + return name.hashCode(); } /* (non-Javadoc) * @see java.lang.Comparable#compareTo(T) */ public int compareTo(Object aGroup) { - return _name.compareTo(((Group)aGroup)._name); + return name.compareTo(((Group)aGroup).name); } /* (non-Javadoc) @@ -98,6 +98,6 @@ public class Group extends AbstractPersistent implements Serializable, Comparabl */ @Override public String toString() { - return "Group(pk = " + getPrimaryKey() + ", name=" + _name + ")"; + return "Group(pk = " + getPrimaryKey() + ", name=" + name + ")"; } } diff --git a/security/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java b/security/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java index 2d2cb85f..b9d133ab 100644 --- a/security/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java +++ b/security/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java @@ -29,28 +29,28 @@ public class InMemoryGroupSet implements GroupSet { /** * Groups. */ - private Set _groups; + private Set groups; /** * Constructs an empty group set. */ public InMemoryGroupSet() { - _groups = new TreeSet(); + groups = new TreeSet(); } /* (non-Javadoc) * @see org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group) */ public void groupModified(Group aGroup) { - _groups.remove(aGroup); - _groups.add(aGroup); + groups.remove(aGroup); + groups.add(aGroup); } /* (non-Javadoc) * @see org.wamblee.usermgt.GroupSet#find(java.lang.String) */ public Group find(String aName) { - for (Group group: _groups) { + for (Group group: groups) { if ( group.getName().equals(aName)) { return new Group(group); } @@ -62,21 +62,21 @@ public class InMemoryGroupSet implements GroupSet { * @see org.wamblee.usermgt.GroupSet#contains(org.wamblee.usermgt.Group) */ public boolean contains(Group aGroup) { - return _groups.contains(aGroup); + return groups.contains(aGroup); } /* (non-Javadoc) * @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group) */ public boolean add(Group aGroup) { - return _groups.add(aGroup); + return groups.add(aGroup); } /* (non-Javadoc) * @see org.wamblee.usermgt.GroupSet#remove(org.wamblee.usermgt.Group) */ public boolean remove(Group aGroup) { - return _groups.remove(aGroup); + return groups.remove(aGroup); } /* (non-Javadoc) @@ -84,7 +84,7 @@ public class InMemoryGroupSet implements GroupSet { */ public Set list() { Set list = new TreeSet(); - for (Group group: _groups) { + for (Group group: groups) { list.add(new Group(group)); } return list; @@ -94,7 +94,7 @@ public class InMemoryGroupSet implements GroupSet { * @see org.wamblee.usermgt.GroupSet#size() */ public int size() { - return _groups.size(); + return groups.size(); } } diff --git a/security/src/main/java/org/wamblee/usermgt/InMemoryUserSet.java b/security/src/main/java/org/wamblee/usermgt/InMemoryUserSet.java index 6d25dc11..380d92c9 100644 --- a/security/src/main/java/org/wamblee/usermgt/InMemoryUserSet.java +++ b/security/src/main/java/org/wamblee/usermgt/InMemoryUserSet.java @@ -31,14 +31,14 @@ public class InMemoryUserSet extends AbstractUserSet { /** * Users. All users in this set have their password validator and encoder set. */ - private Set _users; + private Set users; /** * Constructs an empty user set. */ public InMemoryUserSet(NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) { super(aPasswordValidator, aPasswordEncoder); - _users = new TreeSet(); + users = new TreeSet(); } /* @@ -47,9 +47,9 @@ public class InMemoryUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#userModified(org.wamblee.usermgt.User) */ public void userModified(User aUser) { - _users.remove(aUser); + users.remove(aUser); setPasswordInfo(aUser); - _users.add(aUser); + users.add(aUser); } /* @@ -58,7 +58,7 @@ public class InMemoryUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#find(java.lang.String) */ public User find(String aName) { - for (User user : _users) { + for (User user : users) { if (user.getName().equals(aName)) { return new User(user); } @@ -73,7 +73,7 @@ public class InMemoryUserSet extends AbstractUserSet { */ public boolean add(User aUser) { setPasswordInfo(aUser); - return _users.add(aUser); + return users.add(aUser); } /* @@ -82,7 +82,7 @@ public class InMemoryUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#contains(org.wamblee.usermgt.User) */ public boolean contains(User aUser) { - return _users.contains(aUser); + return users.contains(aUser); } /* @@ -91,7 +91,7 @@ public class InMemoryUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#remove(org.wamblee.usermgt.User) */ public boolean remove(User aUser) { - return _users.remove(aUser); + return users.remove(aUser); } /* @@ -101,7 +101,7 @@ public class InMemoryUserSet extends AbstractUserSet { */ public Set list() { Set list = new TreeSet(); - for (User user : _users) { + for (User user : users) { list.add(new User(user)); } return list; @@ -114,7 +114,7 @@ public class InMemoryUserSet extends AbstractUserSet { */ public Set list(Group aGroup) { Set result = new TreeSet(); - for (User user : _users) { + for (User user : users) { if (user.getGroups().contains(aGroup)) { result.add(new User(user)); } @@ -126,7 +126,7 @@ public class InMemoryUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#size() */ public int size() { - return _users.size(); + return users.size(); } } diff --git a/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java b/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java index f353e3b1..8102b82f 100644 --- a/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java +++ b/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java @@ -33,12 +33,12 @@ public class JaasUserAccessor implements UserAccessor { /** * User administration to use. */ - private UserAdministration _admin; + private UserAdministration admin; /** * Class of the JAAS user principal. */ - private Class _userPrincipalClass; + private Class userPrincipalClass; /** * Constructs user accessor. @@ -46,10 +46,10 @@ public class JaasUserAccessor implements UserAccessor { * @param aUserClassName Class name of the user principal. */ public JaasUserAccessor(UserAdministration aAdmin, String aUserClassName) { - _admin = aAdmin; + admin = aAdmin; try { - _userPrincipalClass = Class.forName(aUserClassName); - if ( !Principal.class.isAssignableFrom(_userPrincipalClass)) { + userPrincipalClass = Class.forName(aUserClassName); + if ( !Principal.class.isAssignableFrom(userPrincipalClass)) { throw new IllegalArgumentException("Specified class '" + aUserClassName + "' is not a subclass of '" + Principal.class.getName()); } @@ -70,7 +70,7 @@ public class JaasUserAccessor implements UserAccessor { } Principal userPrincipal = getUserPrincipal(subject); - return _admin.getUser(userPrincipal.getName()); + return admin.getUser(userPrincipal.getName()); } /** @@ -83,17 +83,17 @@ public class JaasUserAccessor implements UserAccessor { Set principals = subject.getPrincipals(); Principal userPrincipal = null; for ( Principal principal: principals) { - if ( principal.getClass().equals(_userPrincipalClass)) { + if ( principal.getClass().equals(userPrincipalClass)) { if ( userPrincipal != null ) { throw new IllegalArgumentException( - "Multiple principals for class '" + _userPrincipalClass + "', subject: " + subject); + "Multiple principals for class '" + userPrincipalClass + "', subject: " + subject); } userPrincipal = principal; } } if ( userPrincipal == null ) { throw new IllegalArgumentException( - "No user principal found for class '" + _userPrincipalClass + "', subject: " + subject); + "No user principal found for class '" + userPrincipalClass + "', subject: " + subject); } return userPrincipal; } diff --git a/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java b/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java index 8acf1158..9d1421b4 100644 --- a/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java +++ b/security/src/main/java/org/wamblee/usermgt/RegexpNameValidator.java @@ -38,17 +38,17 @@ public class RegexpNameValidator implements NameValidator { /** * Pattern to use. */ - private String _pattern; + private String pattern; /** * Reason to use when validation fails. */ - private Reason _reason; + private Reason reason; /** * Message to report. */ - private String _message; + private String message; /** * Validates a regular expression. @@ -57,9 +57,9 @@ public class RegexpNameValidator implements NameValidator { * @param aMessage Message to report. */ public RegexpNameValidator(String aPattern, Reason aReason, String aMessage) { - _pattern = aPattern; - _reason = aReason; - _message = aMessage; + pattern = aPattern; + reason = aReason; + message = aMessage; } /** @@ -77,8 +77,8 @@ public class RegexpNameValidator implements NameValidator { * @see org.wamblee.usermgt.NameValidator#validate(java.lang.String) */ public void validate(String aName) throws UserMgtException { - if ( !aName.matches(_pattern)) { - throw new UserMgtException(_reason, _message); + if ( !aName.matches(pattern)) { + throw new UserMgtException(reason, message); } } diff --git a/security/src/main/java/org/wamblee/usermgt/User.java b/security/src/main/java/org/wamblee/usermgt/User.java index f239c141..0a69cef9 100644 --- a/security/src/main/java/org/wamblee/usermgt/User.java +++ b/security/src/main/java/org/wamblee/usermgt/User.java @@ -35,27 +35,27 @@ public class User extends AbstractPersistent implements Serializable, Comparable /** * User name. */ - private String _name; + private String name; /** * Password. */ - private String _password; + private String password; /** * Groups the user belongs to. */ - private Set _groups; + private Set groups; /** * Password validator. */ - private NameValidator _passwordValidator; + private NameValidator passwordValidator; /** * Password encoder. */ - private MessageDigester _passwordEncoder; + private MessageDigester passwordEncoder; /** * Constructs the user. @@ -66,34 +66,34 @@ public class User extends AbstractPersistent implements Serializable, Comparable User(String aName, String aPassword, Group aGroup, NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) throws UserMgtException { super(); - _name = aName; + name = aName; aPasswordValidator.validate(aPassword); - _password = aPasswordEncoder.hash(aPassword); - _groups = new TreeSet(); - _groups.add(aGroup); - _passwordValidator = aPasswordValidator; - _passwordEncoder = aPasswordEncoder; + password = aPasswordEncoder.hash(aPassword); + groups = new TreeSet(); + groups.add(aGroup); + passwordValidator = aPasswordValidator; + passwordEncoder = aPasswordEncoder; } public User(User aUser) { super(aUser); - _name = aUser._name; - _password = aUser._password; - _groups = new TreeSet(); - for (Group group: aUser._groups) { - _groups.add(new Group(group)); + name = aUser.name; + password = aUser.password; + groups = new TreeSet(); + for (Group group: aUser.groups) { + groups.add(new Group(group)); } - _passwordValidator = aUser._passwordValidator; - _passwordEncoder = aUser._passwordEncoder; + passwordValidator = aUser.passwordValidator; + passwordEncoder = aUser.passwordEncoder; } User() { super(); - _name = null; - _password = null; - _groups = null; - _passwordValidator = null; - _passwordEncoder = null; + name = null; + password = null; + groups = null; + passwordValidator = null; + passwordEncoder = null; } /** @@ -101,7 +101,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @param aPasswordValidator Validator. */ public void setPasswordValidator(NameValidator aPasswordValidator) { - _passwordValidator = aPasswordValidator; + passwordValidator = aPasswordValidator; } /** @@ -109,14 +109,14 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @param aPasswordEncoder Encoder. */ public void setPasswordEncoder(MessageDigester aPasswordEncoder) { - _passwordEncoder = aPasswordEncoder; + passwordEncoder = aPasswordEncoder; } /** - * @return Returns the _password. + * @return Returns the password. */ String getPassword() { - return _password; + return password; } /** @@ -125,8 +125,8 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @throws UserMgtException In case the password is incorrect. */ public void checkPassword(String aPassword) throws UserMgtException { - String encoded = _passwordEncoder.hash(aPassword); - if ( !_password.equals(encoded) ) { + String encoded = passwordEncoder.hash(aPassword); + if ( !password.equals(encoded) ) { throw new UserMgtException(Reason.INVALID_PASSWORD, this); } } @@ -139,7 +139,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable */ public void changePassword(String aOldPassword, String aNewPassword) throws UserMgtException { checkPassword(aOldPassword); - _passwordValidator.validate(aNewPassword); + passwordValidator.validate(aNewPassword); setPassword(aNewPassword); } @@ -148,8 +148,8 @@ public class User extends AbstractPersistent implements Serializable, Comparable * The password to set. */ public void setPassword(String aPassword) throws UserMgtException { - _passwordValidator.validate(aPassword); - _password = _passwordEncoder.hash(aPassword); + passwordValidator.validate(aPassword); + password = passwordEncoder.hash(aPassword); } /** @@ -157,7 +157,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @return Password. */ protected String getPasswordString() { - return _password; + return password; } /** @@ -165,14 +165,14 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @param aPassword Password. */ protected void setPasswordString(String aPassword) { - _password = aPassword; + password = aPassword; } /** * @return Returns the _user. */ public String getName() { - return _name; + return name; } /** @@ -180,7 +180,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * The username to set. */ void setName(String aName) { - _name = aName; + name = aName; } /** @@ -189,7 +189,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable */ public Set getGroups() { Set result = new TreeSet(); - result.addAll(_groups); + result.addAll(groups); return result; } @@ -199,7 +199,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @return True if the user belongs to the group. */ public boolean isInGroup(Group aGroup) { - return _groups.contains(aGroup); + return groups.contains(aGroup); } /** @@ -208,7 +208,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @return True if the user belongs to the group. */ public boolean isInGroup(String aGroup) { - return _groups.contains(new Group(aGroup)); + return groups.contains(new Group(aGroup)); } /** @@ -216,7 +216,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @return set of groups. */ Set getGroupSet() { - return _groups; + return groups; } /** @@ -224,7 +224,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @param aGroups Groups. */ void setGroupSet(Set aGroups) { - _groups = aGroups; + groups = aGroups; } /** @@ -233,10 +233,10 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @throws UserMgtException In case the user already belongs to the group. */ void addGroup(Group aGroup) throws UserMgtException { - if (_groups.contains(aGroup)) { + if (groups.contains(aGroup)) { throw new UserMgtException(Reason.USER_ALREADY_IN_GROUP, aGroup); } - _groups.add(aGroup); + groups.add(aGroup); } /** @@ -245,13 +245,13 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @throws UserMgtException In case the user does not belong to the group. */ void removeGroup(Group aGroup) throws UserMgtException { - if (!_groups.contains(aGroup)) { + if (!groups.contains(aGroup)) { throw new UserMgtException(Reason.USER_NOT_IN_GROUP, this, aGroup); } - if ( _groups.size() == 1 ) { + if ( groups.size() == 1 ) { throw new UserMgtException(Reason.USER_MUST_BE_IN_A_GROUP, this, aGroup); } - _groups.remove(aGroup); + groups.remove(aGroup); } /* (non-Javadoc) @@ -263,7 +263,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable return false; } User user = (User)aUser; - return _name.equals(user._name); + return name.equals(user.name); } /* (non-Javadoc) @@ -271,7 +271,7 @@ public class User extends AbstractPersistent implements Serializable, Comparable */ @Override public int hashCode() { - return _name.hashCode(); + return name.hashCode(); } /* (non-Javadoc) @@ -279,8 +279,8 @@ public class User extends AbstractPersistent implements Serializable, Comparable */ @Override public String toString() { - String result = "User(name=" + _name + ", password=" + _password; - for (Group group: _groups) { + String result = "User(name=" + name + ", password=" + password; + for (Group group: groups) { result += ", group=" + group; } return result + ")"; @@ -290,6 +290,6 @@ public class User extends AbstractPersistent implements Serializable, Comparable * @see java.lang.Comparable#compareTo(T) */ public int compareTo(Object aUser) { - return _name.compareTo(((User)aUser)._name); + return name.compareTo(((User)aUser).name); } } diff --git a/security/src/main/java/org/wamblee/usermgt/UserAdministrationImpl.java b/security/src/main/java/org/wamblee/usermgt/UserAdministrationImpl.java index dceca930..55793da6 100644 --- a/security/src/main/java/org/wamblee/usermgt/UserAdministrationImpl.java +++ b/security/src/main/java/org/wamblee/usermgt/UserAdministrationImpl.java @@ -35,22 +35,22 @@ public class UserAdministrationImpl implements UserAdministration { /** * All known users. */ - private UserSet _users; + private UserSet users; /** * All known groups. */ - private GroupSet _groups; + private GroupSet groups; /** * Validator for user names. */ - private NameValidator _userValidator; + private NameValidator userValidator; /** * Validator for group names. */ - private NameValidator _groupValidator; + private NameValidator groupValidator; /** * Constructs empty user administration. @@ -58,10 +58,10 @@ public class UserAdministrationImpl implements UserAdministration { */ public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups, NameValidator aUserValidator, NameValidator aGroupValidator) { - _users = aUsers; - _groups = aGroups; - _userValidator = aUserValidator; - _groupValidator = aGroupValidator; + users = aUsers; + groups = aGroups; + userValidator = aUserValidator; + groupValidator = aGroupValidator; } /* @@ -72,9 +72,9 @@ public class UserAdministrationImpl implements UserAdministration { */ public User createUser(String aUser, String aPassword, Group aGroup) throws UserMgtException { - _userValidator.validate(aUser); + userValidator.validate(aUser); checkGroup(aGroup); - User user = _users.createUser(aUser, aPassword, aGroup); + User user = users.createUser(aUser, aPassword, aGroup); return new User(user); } @@ -84,12 +84,12 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#createGroup(java.lang.String) */ public Group createGroup(String aName) throws UserMgtException { - _groupValidator.validate(aName); + groupValidator.validate(aName); Group group = new Group(aName); - if (_groups.contains(group)) { + if (groups.contains(group)) { throw new UserMgtException(DUPLICATE_GROUP, group); } - _groups.add(group); + groups.add(group); return new Group(group); } @@ -99,7 +99,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#userModified(org.wamblee.usermgt.User) */ public void userModified(User aUser) { - _users.userModified(aUser); + users.userModified(aUser); } /* @@ -108,7 +108,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#groupModified(org.wamblee.usermgt.Group) */ public void groupModified(Group aGroup) { - _groups.groupModified(aGroup); + groups.groupModified(aGroup); } /* @@ -117,7 +117,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getUser(java.lang.String) */ public User getUser(String aName) { - return _users.find(aName); + return users.find(aName); } /* @@ -126,7 +126,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getGroup(java.lang.String) */ public Group getGroup(String aName) { - return _groups.find(aName); + return groups.find(aName); } /* @@ -135,7 +135,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getUsers() */ public Set getUsers() { - return _users.list(); + return users.list(); } /* @@ -144,7 +144,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getUsers(org.wamblee.usermgt.Group) */ public Set getUsers(Group aGroup) { - return _users.list(aGroup); + return users.list(aGroup); } /* @@ -153,7 +153,7 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getGroups() */ public Set getGroups() { - return _groups.list(); + return groups.list(); } /* @@ -163,7 +163,7 @@ public class UserAdministrationImpl implements UserAdministration { */ public void removeUser(User aUser) throws UserMgtException { checkUser(aUser); - _users.remove(aUser); + users.remove(aUser); } /* @@ -176,7 +176,7 @@ public class UserAdministrationImpl implements UserAdministration { if (getUsers(aGroup).size() > 0) { throw new UserMgtException(GROUP_STILL_OCCUPIED, aGroup); } - _groups.remove(aGroup); + groups.remove(aGroup); } /* @@ -191,15 +191,15 @@ public class UserAdministrationImpl implements UserAdministration { if (aUser.getName().equals(aUserName)) { throw new UserMgtException(TRIVIAL_RENAME, aUser); } - if (_users.find(aUserName) != null) { + if (users.find(aUserName) != null) { throw new UserMgtException(DUPLICATE_USER, aUser); } - _userValidator.validate(aUserName); + userValidator.validate(aUserName); // we are modifying the user so we should re-insert it into the set // after renaming it. - _users.remove(aUser); + users.remove(aUser); aUser.setName(aUserName); - _users.add(aUser); + users.add(aUser); } /* @@ -214,15 +214,15 @@ public class UserAdministrationImpl implements UserAdministration { if (aGroup.getName().equals(aGroupName)) { throw new UserMgtException(TRIVIAL_RENAME, aGroup); } - if (_groups.find(aGroupName) != null) { + if (groups.find(aGroupName) != null) { throw new UserMgtException(DUPLICATE_GROUP, aGroup); } - _groupValidator.validate(aGroupName); + groupValidator.validate(aGroupName); // we are renaming the group so we should re-insert it into the set // after renaming it. - _groups.remove(aGroup); + groups.remove(aGroup); aGroup.setName(aGroupName); - _groups.add(aGroup); + groups.add(aGroup); } /* @@ -236,7 +236,7 @@ public class UserAdministrationImpl implements UserAdministration { checkUser(aUser); checkGroup(aGroup); aUser.addGroup(aGroup); - _users.userModified(aUser); + users.userModified(aUser); } /* @@ -250,7 +250,7 @@ public class UserAdministrationImpl implements UserAdministration { checkUser(aUser); checkGroup(aGroup); aUser.removeGroup(aGroup); - _users.userModified(aUser); + users.userModified(aUser); } /** @@ -258,7 +258,7 @@ public class UserAdministrationImpl implements UserAdministration { * @throws UserMgtException */ private void checkUser(User aUser) throws UserMgtException { - if (!_users.contains(aUser)) { + if (!users.contains(aUser)) { throw new UserMgtException(UNKNOWN_USER, aUser); } } @@ -268,7 +268,7 @@ public class UserAdministrationImpl implements UserAdministration { * @throws UserMgtException */ private void checkGroup(Group aGroup) throws UserMgtException { - if (!_groups.contains(aGroup)) { + if (!groups.contains(aGroup)) { throw new UserMgtException(UNKNOWN_GROUP, aGroup); } } @@ -277,13 +277,13 @@ public class UserAdministrationImpl implements UserAdministration { * @see org.wamblee.usermgt.UserAdministration#getUserCount() */ public int getUserCount() { - return _users.size(); + return users.size(); } /* (non-Javadoc) * @see org.wamblee.usermgt.UserAdministration#getGroupCount() */ public int getGroupCount() { - return _groups.size(); + return groups.size(); } } diff --git a/security/src/main/java/org/wamblee/usermgt/UserMgtException.java b/security/src/main/java/org/wamblee/usermgt/UserMgtException.java index 6a96e618..e2f057c0 100644 --- a/security/src/main/java/org/wamblee/usermgt/UserMgtException.java +++ b/security/src/main/java/org/wamblee/usermgt/UserMgtException.java @@ -69,37 +69,37 @@ public class UserMgtException extends Exception { /** * Cause of the exception. */ - private Reason _cause; + private Reason cause; /** * User or null if no user is relevant for the problem. */ - private User _user; + private User user; /** * Group or null if no group is relevant for the problem. */ - private Group _group; + private Group group; public UserMgtException(Reason aCause, String aMessage) { super(MESSAGES.get(aCause) + ": " + aMessage); - _cause = aCause; + cause = aCause; } public UserMgtException(Reason aCause, User aUser) { this(aCause, "for user '" + aUser.getName() + "'"); - _user = aUser; + user = aUser; } public UserMgtException(Reason aCause, Group aGroup) { this(aCause, "for group '" + aGroup.getName() + "'"); - _group = aGroup; + group = aGroup; } public UserMgtException(Reason aCause, User aUser, Group aGroup) { this(aCause, "for user '" + aUser.getName() + "' and group '" + aGroup.getName() + "'"); - _user = aUser; - _group = aGroup; + user = aUser; + group = aGroup; } /** @@ -107,7 +107,7 @@ public class UserMgtException extends Exception { * @return Cause. */ public Reason getReason() { - return _cause; + return cause; } /** @@ -115,7 +115,7 @@ public class UserMgtException extends Exception { * @return User or null if not applicable. */ public User getUser() { - return _user; + return user; } /** @@ -123,6 +123,6 @@ public class UserMgtException extends Exception { * @return Group or null if not applicable. */ public Group getGroup() { - return _group; + return group; } } diff --git a/security/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java b/security/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java index 8bc1db58..df13cac1 100644 --- a/security/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java +++ b/security/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java @@ -48,12 +48,12 @@ public class HibernateUserSet extends AbstractUserSet { /** * Cache of users. Every user in the cache has its password validator and encoder set. */ - private Cache _cache; + private Cache cache; /** * Spring hibernate support. */ - private HibernateSupport _hibernateSupport; + private HibernateSupport hibernateSupport; /** * Constructs a user set backed by the database. @@ -62,8 +62,8 @@ public class HibernateUserSet extends AbstractUserSet { public HibernateUserSet(Cache aCache, NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) { super(aPasswordValidator, aPasswordEncoder); - _cache = aCache; - _hibernateSupport = new HibernateSupport(); + cache = aCache; + hibernateSupport = new HibernateSupport(); } /** @@ -71,7 +71,7 @@ public class HibernateUserSet extends AbstractUserSet { * @param aFactory Session factory. */ public void setSessionFactory(SessionFactory aFactory) { - _hibernateSupport.setSessionFactory(aFactory); + hibernateSupport.setSessionFactory(aFactory); } /** @@ -79,7 +79,7 @@ public class HibernateUserSet extends AbstractUserSet { * @return Hibernate template. */ private HibernateTemplate getHibernateTemplate() { - return _hibernateSupport.getHibernateTemplate(); + return hibernateSupport.getHibernateTemplate(); } /* @@ -89,10 +89,10 @@ public class HibernateUserSet extends AbstractUserSet { */ public void userModified(User aUser) { assert aUser.getPrimaryKey() != null; - _hibernateSupport.merge(aUser); - _cache.remove(aUser.getName()); + hibernateSupport.merge(aUser); + cache.remove(aUser.getName()); setPasswordInfo(aUser); - _cache.put(aUser.getName(), new User(aUser)); + cache.put(aUser.getName(), new User(aUser)); } /* @@ -101,7 +101,7 @@ public class HibernateUserSet extends AbstractUserSet { * @see org.wamblee.usermgt.UserSet#find(java.lang.String) */ public User find(String aName) { - User user = _cache.get(aName); + User user = cache.get(aName); if (user != null) { return user; } @@ -116,7 +116,7 @@ public class HibernateUserSet extends AbstractUserSet { } user = (User) result.get(0); setPasswordInfo(user); - _cache.put(aName, user); + cache.put(aName, user); return new User(user); } @@ -141,7 +141,7 @@ public class HibernateUserSet extends AbstractUserSet { } getHibernateTemplate().saveOrUpdate(aUser); setPasswordInfo(aUser); - _cache.put(aUser.getName(), aUser); + cache.put(aUser.getName(), aUser); return true; } @@ -159,7 +159,7 @@ public class HibernateUserSet extends AbstractUserSet { getHibernateTemplate().delete(user); aUser.setPersistedVersion(-1); aUser.setPrimaryKey(null); - _cache.remove(aUser.getName()); + cache.remove(aUser.getName()); return true; } diff --git a/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java b/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java index 66e3850f..b6da3380 100644 --- a/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java +++ b/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java @@ -53,14 +53,14 @@ public class UserAdministrationComponent extends DefaultContainer { mappingFilesConfig.getSetterConfig().initAllSetters(); addComponent("mappingFiles", new UsermgtHibernateMappingFiles(), mappingFilesConfig); - Component _hibernate = new HibernateComponent("hibernate"); - addComponent(_hibernate); + Component hibernate = new HibernateComponent("hibernate"); + addComponent(hibernate); - Component _repository = new UserGroupRepositoryComponent("usersgroups"); - addComponent(_repository); + Component repository = new UserGroupRepositoryComponent("usersgroups"); + addComponent(repository); - Component _usermgt = new UserAdministrationLightComponent("usermgtlight"); - addComponent(_usermgt); + Component usermgt = new UserAdministrationLightComponent("usermgtlight"); + addComponent(usermgt); addRequiredInterface(new DefaultRequiredInterface("datasource", DataSource.class)); diff --git a/security/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java b/security/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java index 151dbd7e..5ec36f7e 100644 --- a/security/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java +++ b/security/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java @@ -29,13 +29,13 @@ import org.wamblee.usermgt.UserAccessor; */ public class AuthorizationServiceTest extends TestCase { - private AuthorizationRule _rule1; - private AuthorizationRule _rule2; - private AuthorizationRule _rule3; - private AuthorizationService _service; + private AuthorizationRule rule1; + private AuthorizationRule rule2; + private AuthorizationRule rule3; + private AuthorizationService service; protected AuthorizationService getService() { - return _service; + return service; } /* (non-Javadoc) @@ -45,20 +45,20 @@ public class AuthorizationServiceTest extends TestCase { protected void setUp() throws Exception { super.setUp(); - _rule1 = createRule(GRANTED, "users", "/oni/", AllOperation.class); - _rule2 = createRule(DENIED, "users", "/abc/", ReadOperation.class); - _rule3 = createRule(GRANTED, "users", "/abc/", AllOperation.class); + rule1 = createRule(GRANTED, "users", "/oni/", AllOperation.class); + rule2 = createRule(DENIED, "users", "/abc/", ReadOperation.class); + rule3 = createRule(GRANTED, "users", "/abc/", AllOperation.class); - _service = createService(); - _service.appendRule(_rule1); - _service.appendRule(_rule2); - _service.appendRule(_rule3); + service = createService(); + service.appendRule(rule1); + service.appendRule(rule2); + service.appendRule(rule3); } protected void resetTestRules() { - ((TestAuthorizationRule)_rule1).reset(); - ((TestAuthorizationRule)_rule2).reset(); - ((TestAuthorizationRule)_rule3).reset(); + ((TestAuthorizationRule)rule1).reset(); + ((TestAuthorizationRule)rule2).reset(); + ((TestAuthorizationRule)rule3).reset(); } protected UserAccessor createUserAccessor() { @@ -96,16 +96,16 @@ public class AuthorizationServiceTest extends TestCase { * */ public void testFirstRuleGrants() { - assertTrue( _service.isAllowed(createResource("/oni/xyz.jpg"), new ReadOperation())); - checkMatchCount(1, _rule1); - assertTrue(_service.isAllowed(createResource("/oni/xyz.jpg"), new WriteOperation())); - checkMatchCount(2, _rule1); - assertTrue(_service.isAllowed(createResource("/oni/xyz.jpg"), new DeleteOperation())); - checkMatchCount(3, _rule1); - assertTrue(_service.isAllowed(createResource("/oni/xyz.jpg"), new CreateOperation())); - checkMatchCount(4, _rule1); - checkMatchCount(0, _rule2); - checkMatchCount(0, _rule3); + assertTrue( service.isAllowed(createResource("/oni/xyz.jpg"), new ReadOperation())); + checkMatchCount(1, rule1); + assertTrue(service.isAllowed(createResource("/oni/xyz.jpg"), new WriteOperation())); + checkMatchCount(2, rule1); + assertTrue(service.isAllowed(createResource("/oni/xyz.jpg"), new DeleteOperation())); + checkMatchCount(3, rule1); + assertTrue(service.isAllowed(createResource("/oni/xyz.jpg"), new CreateOperation())); + checkMatchCount(4, rule1); + checkMatchCount(0, rule2); + checkMatchCount(0, rule3); } /** @@ -113,10 +113,10 @@ public class AuthorizationServiceTest extends TestCase { * */ public void testSecondRuleDenies() { - assertFalse(_service.isAllowed(createResource("/abc/xyz.jpg"), new ReadOperation())); - checkMatchCount(0, _rule1); - checkMatchCount(1, _rule2); - checkMatchCount(0, _rule3); + assertFalse(service.isAllowed(createResource("/abc/xyz.jpg"), new ReadOperation())); + checkMatchCount(0, rule1); + checkMatchCount(1, rule2); + checkMatchCount(0, rule3); } /** @@ -124,10 +124,10 @@ public class AuthorizationServiceTest extends TestCase { * */ public void testThirdRuleGrants() { - assertTrue(_service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); - checkMatchCount(0, _rule1); - checkMatchCount(0, _rule2); - checkMatchCount(1, _rule3); + assertTrue(service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); + checkMatchCount(0, rule1); + checkMatchCount(0, rule2); + checkMatchCount(1, rule3); } /** @@ -136,9 +136,9 @@ public class AuthorizationServiceTest extends TestCase { */ public void testRemoveRule() { checkRuleCount(3); - assertTrue(_service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); - _service.removeRule(2); - assertFalse(_service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); + assertTrue(service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); + service.removeRule(2); + assertFalse(service.isAllowed(createResource("/abc/xyz.jpg"), new WriteOperation())); checkRuleCount(2); } @@ -148,9 +148,9 @@ public class AuthorizationServiceTest extends TestCase { */ public void testInsertRule() { checkRuleCount(3); - assertFalse(_service.isAllowed(createResource("/janse/xyz.jpg"), new WriteOperation())); - _service.appendRule(createRule(GRANTED, "users", "/janse/", WriteOperation.class)); - assertTrue(_service.isAllowed(createResource("/janse/xyz.jpg"), new WriteOperation())); + assertFalse(service.isAllowed(createResource("/janse/xyz.jpg"), new WriteOperation())); + service.appendRule(createRule(GRANTED, "users", "/janse/", WriteOperation.class)); + assertTrue(service.isAllowed(createResource("/janse/xyz.jpg"), new WriteOperation())); checkRuleCount(4); } @@ -160,7 +160,7 @@ public class AuthorizationServiceTest extends TestCase { * */ public void testGetRules() { - AuthorizationRule[] rules = _service.getRules(); + AuthorizationRule[] rules = service.getRules(); assertEquals(3, rules.length); } @@ -169,9 +169,9 @@ public class AuthorizationServiceTest extends TestCase { * */ public void testNoRulesSupportResource() { - assertFalse(_service.isAllowed(createResource("/xyxyxyxy"), new ReadOperation())); - checkMatchCount(0, _rule1); - checkMatchCount(0, _rule2); - checkMatchCount(0, _rule3); + assertFalse(service.isAllowed(createResource("/xyxyxyxy"), new ReadOperation())); + checkMatchCount(0, rule1); + checkMatchCount(0, rule2); + checkMatchCount(0, rule3); } } diff --git a/security/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java b/security/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java index 3dcfe2d2..a1023ac6 100644 --- a/security/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java +++ b/security/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java @@ -25,7 +25,7 @@ import junit.framework.TestCase; */ public class DefaultOperationRegistryTest extends TestCase { - private OperationRegistry _registry; + private OperationRegistry registry; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() @@ -33,7 +33,7 @@ public class DefaultOperationRegistryTest extends TestCase { @Override protected void setUp() throws Exception { - _registry = new DefaultOperationRegistry(new Operation[] { + registry = new DefaultOperationRegistry(new Operation[] { new AllOperation(), new ReadOperation(), new WriteOperation(), @@ -47,8 +47,8 @@ public class DefaultOperationRegistryTest extends TestCase { * */ public void testEncodeDecodeNooperations() { - assertEquals("", _registry.encode(new Operation[0])); - assertEquals(0, _registry.decode(Object.class, "").length); + assertEquals("", registry.encode(new Operation[0])); + assertEquals(0, registry.decode(Object.class, "").length); } /** @@ -56,7 +56,7 @@ public class DefaultOperationRegistryTest extends TestCase { * */ public void testEncode() { - assertEquals("read,write", _registry.encode(new Operation[] { new ReadOperation(), new WriteOperation() })); + assertEquals("read,write", registry.encode(new Operation[] { new ReadOperation(), new WriteOperation() })); } /** @@ -64,7 +64,7 @@ public class DefaultOperationRegistryTest extends TestCase { * */ public void testDecode() { - Operation[] operations = _registry.decode(Object.class, "read,write"); + Operation[] operations = registry.decode(Object.class, "read,write"); assertTrue( operations[0] instanceof ReadOperation); assertTrue( operations[1] instanceof WriteOperation); } @@ -76,7 +76,7 @@ public class DefaultOperationRegistryTest extends TestCase { */ public void testDecodeUnknownOperation() { try { - _registry.decode(Object.class, "bla"); + registry.decode(Object.class, "bla"); fail(); } catch (IllegalArgumentException e) { // ok diff --git a/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java b/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java index 93141fde..3644dc83 100644 --- a/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java +++ b/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java @@ -31,7 +31,7 @@ public class TestAuthorizationRule extends UrlAuthorizationRule { /** * Counts the number of matches. */ - private int _matches = 0; + private int matches = 0; public TestAuthorizationRule( AuthorizationResult aResult, String aGroup, String aPath, Class aOperation) { @@ -59,17 +59,17 @@ public class TestAuthorizationRule extends UrlAuthorizationRule { AuthorizationResult result = super.isAllowed(aResource, anOperation, aUser); if ( result.equals(GRANTED) || result.equals(DENIED)) { - _matches++; + matches++; } return result; } public int getMatchCount() { - return _matches; + return matches; } public void reset() { - _matches = 0; + matches = 0; } } diff --git a/security/src/test/java/org/wamblee/security/authorization/TestResource.java b/security/src/test/java/org/wamblee/security/authorization/TestResource.java index a0edd898..4712c42c 100644 --- a/security/src/test/java/org/wamblee/security/authorization/TestResource.java +++ b/security/src/test/java/org/wamblee/security/authorization/TestResource.java @@ -23,13 +23,13 @@ package org.wamblee.security.authorization; */ public class TestResource { - private String _path; + private String path; public TestResource(String aPath) { - _path = aPath; + path = aPath; } public String getPath() { - return _path; + return path; } } diff --git a/security/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java b/security/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java index f55fc293..b1a36934 100644 --- a/security/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java +++ b/security/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java @@ -59,61 +59,61 @@ public class PersistentAuthorizationServiceTest extends private static final String PATHCOND_TABLE = "PATH_CONDITIONS"; private static final String USERCOND_TABLE = "USER_CONDITIONS"; - private DefaultContainer _container; - private Scope _scope; + private DefaultContainer container; + private Scope scope; - private DatabaseTesterComponent _databaseTester; - private UserAccessor _userAccessor; - private HibernateTemplate _hibernateTemplate; - private AuthorizationService _authorizationService; + private DatabaseTesterComponent databaseTester; + private UserAccessor userAccessor; + private HibernateTemplate hibernateTemplate; + private AuthorizationService authorizationService; @Override protected void setUp() throws Exception { - _container = new DefaultContainer("top"); - DatabaseComponentFactory.addDatabaseConfig(_container); - _container.addComponent(new DatasourceComponent("datasource")); + container = new DefaultContainer("top"); + DatabaseComponentFactory.addDatabaseConfig(container); + container.addComponent(new DatasourceComponent("datasource")); ClassConfiguration useraccessorConfig = new ClassConfiguration( TestUserAccessor.class); useraccessorConfig.getObjectConfig().getSetterConfig().initAllSetters(); - _container.addComponent("userAccessor", useraccessorConfig); - _container.addComponent(new AuthorizationComponent("authorization", + container.addComponent("userAccessor", useraccessorConfig); + container.addComponent(new AuthorizationComponent("authorization", true)); ClassConfiguration dbtesterConfig = new ClassConfiguration( DatabaseTesterComponent.class); dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters(); - _container.addComponent("databaseTester", dbtesterConfig); + container.addComponent("databaseTester", dbtesterConfig); ObjectConfiguration config = new ObjectConfiguration( PersistentAuthorizationServiceTest.class); config.getSetterConfig().clear().add("setUserAccessor").add( "setDatabaseTester").add("setHibernateTemplate").add( "setAuthorizationService"); - _container.addComponent("testcase", this, config); + container.addComponent("testcase", this, config); - _scope = _container.start(); + scope = container.start(); - _databaseTester.cleanDatabase(); + databaseTester.cleanDatabase(); super.setUp(); } public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) { - _databaseTester = aDatabaseTester; + databaseTester = aDatabaseTester; } public void setUserAccessor(UserAccessor aUserAccessor) { - _userAccessor = aUserAccessor; + userAccessor = aUserAccessor; } public void setHibernateTemplate(HibernateTemplate aHibernateTemplate) { - _hibernateTemplate = aHibernateTemplate; + hibernateTemplate = aHibernateTemplate; } public void setAuthorizationService( AuthorizationService aAuthorizationService) { - _authorizationService = aAuthorizationService; + authorizationService = aAuthorizationService; } /* @@ -126,7 +126,7 @@ public class PersistentAuthorizationServiceTest extends @Override protected AuthorizationService createService() { PersistentAuthorizationService service = new PersistentAuthorizationService( - "DEFAULT", _hibernateTemplate, createUserAccessor(), 10000); + "DEFAULT", hibernateTemplate, createUserAccessor(), 10000); return service; } @@ -140,13 +140,13 @@ public class PersistentAuthorizationServiceTest extends @Override protected void checkRuleCount(int aCount) { try { - assertEquals(1, _databaseTester.getTableSize(SERVICE_TABLE)); - assertEquals(aCount, _databaseTester.getTableSize(RULES_TABLE)); - assertEquals(aCount, _databaseTester + assertEquals(1, databaseTester.getTableSize(SERVICE_TABLE)); + assertEquals(aCount, databaseTester.getTableSize(RULES_TABLE)); + assertEquals(aCount, databaseTester .getTableSize(SERVICE_RULES_TABLE)); - assertEquals(aCount, _databaseTester.getTableSize(USERCOND_TABLE)); - assertEquals(aCount, _databaseTester.getTableSize(PATHCOND_TABLE)); - assertEquals(aCount, _databaseTester + assertEquals(aCount, databaseTester.getTableSize(USERCOND_TABLE)); + assertEquals(aCount, databaseTester.getTableSize(PATHCOND_TABLE)); + assertEquals(aCount, databaseTester .getTableSize(OPERATIONCOND_TABLE)); } catch (SQLException e) { throw new RuntimeException(e); diff --git a/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java b/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java index 2ea11905..03329d1d 100644 --- a/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java +++ b/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java @@ -27,7 +27,7 @@ import junit.framework.TestCase; */ public class InMemoryGroupSetTest extends TestCase { - protected GroupSet _groups; + protected GroupSet groups; /** * This method must be overriden in subclasses. @@ -43,7 +43,7 @@ public class InMemoryGroupSetTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - _groups = createGroupSet(); + groups = createGroupSet(); checkGroupCount(0); } @@ -70,7 +70,7 @@ public class InMemoryGroupSetTest extends TestCase { * @param aSize Expected number of groups. */ protected void checkGroupCount(int aSize) throws SQLException { - assertEquals(aSize, _groups.size()); + assertEquals(aSize, groups.size()); } /** @@ -80,13 +80,13 @@ public class InMemoryGroupSetTest extends TestCase { */ public void testAdd() throws SQLException { Group group = new Group("group1"); - assertTrue( _groups.add(group) ); + assertTrue( groups.add(group) ); checkGroupExists(group.getName()); checkGroupCount(1); - Group group2 = _groups.find("group1"); + Group group2 = groups.find("group1"); assertNotNull(group2); assertEquals(group.getName(), group2.getName()); - Set set = _groups.list(); + Set set = groups.list(); assertEquals(1, set.size()); assertTrue(set.contains(group)); } @@ -99,12 +99,12 @@ public class InMemoryGroupSetTest extends TestCase { public void testFindUnknownGroup() throws SQLException { Group group1 = new Group("group1"); Group group2 = new Group("group2"); - _groups.add(group1); - _groups.add(group2); + groups.add(group1); + groups.add(group2); checkGroupExists(group1.getName()); checkGroupExists(group2.getName()); - assertNull( _groups.find("group3") ); + assertNull( groups.find("group3") ); checkGroupNotExists("group3"); } @@ -113,13 +113,13 @@ public class InMemoryGroupSetTest extends TestCase { */ public void testAddDuplicateGroup() throws SQLException { Group group1 = new Group("group1"); - _groups.add(group1); + groups.add(group1); - assertEquals(1, _groups.list().size()); - assertTrue(_groups.contains(group1)); + assertEquals(1, groups.list().size()); + assertTrue(groups.contains(group1)); group1 = new Group("group1"); - assertFalse(_groups.add(group1)); - assertEquals(1, _groups.list().size()); + assertFalse(groups.add(group1)); + assertEquals(1, groups.list().size()); checkGroupExists(group1.getName()); checkGroupCount(1); @@ -132,14 +132,14 @@ public class InMemoryGroupSetTest extends TestCase { */ public void testRemoveGroup() throws SQLException { Group group1 = new Group("group1"); - _groups.add(group1); - assertTrue(_groups.contains(group1)); + groups.add(group1); + assertTrue(groups.contains(group1)); checkGroupCount(1); - assertTrue(_groups.remove(group1)); - assertFalse(_groups.contains(group1)); - assertNull(_groups.find(group1.getName())); - assertEquals(0, _groups.list().size()); + assertTrue(groups.remove(group1)); + assertFalse(groups.contains(group1)); + assertNull(groups.find(group1.getName())); + assertEquals(0, groups.list().size()); checkGroupCount(0); } @@ -150,14 +150,14 @@ public class InMemoryGroupSetTest extends TestCase { */ public void testRemoveNonExistingGroup() throws SQLException { Group group1 = new Group("group1"); - _groups.add(group1); + groups.add(group1); checkGroupCount(1); Group nonExistingGroup = new Group("group2"); nonExistingGroup.setPrimaryKey(new Long(1000)); nonExistingGroup.setPersistedVersion(1000); - assertFalse(_groups.remove(nonExistingGroup)); - assertTrue(_groups.contains(group1)); - assertEquals(1, _groups.list().size()); + assertFalse(groups.remove(nonExistingGroup)); + assertTrue(groups.contains(group1)); + assertEquals(1, groups.list().size()); checkGroupCount(1); } @@ -170,15 +170,15 @@ public class InMemoryGroupSetTest extends TestCase { Group group1 = new Group("group1"); Group group2 = new Group("group2"); Group group3 = new Group("group3"); - assertTrue(_groups.add(group1)); - assertTrue(_groups.add(group2)); - assertTrue(_groups.add(group3)); + assertTrue(groups.add(group1)); + assertTrue(groups.add(group2)); + assertTrue(groups.add(group3)); checkGroupExists(group1.getName()); checkGroupExists(group2.getName()); checkGroupExists(group3.getName()); - Set set = _groups.list(); + Set set = groups.list(); assertTrue(set.contains(group1)); assertTrue(set.contains(group2)); assertTrue(set.contains(group3)); diff --git a/security/src/test/java/org/wamblee/usermgt/InMemoryUserSetTest.java b/security/src/test/java/org/wamblee/usermgt/InMemoryUserSetTest.java index 8d60d433..76eadebb 100644 --- a/security/src/test/java/org/wamblee/usermgt/InMemoryUserSetTest.java +++ b/security/src/test/java/org/wamblee/usermgt/InMemoryUserSetTest.java @@ -32,10 +32,10 @@ public class InMemoryUserSetTest extends TestCase { protected static final String PASSWORD = "abc123"; - private UserSet _users; - private GroupSet _groups; + private UserSet users; + private GroupSet groups; - private Group _group; + private Group group; /** * This method must be overriden in subclasses. @@ -60,20 +60,20 @@ public class InMemoryUserSetTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - _users = createUserSet(); - _groups = createGroupSet(); - _group = new Group("group0"); - _groups.add(_group); + users = createUserSet(); + groups = createGroupSet(); + group = new Group("group0"); + groups.add(group); checkUserCount(0); } protected UserSet getUsers() { - return _users; + return users; } protected GroupSet getGroups() { - return _groups; + return groups; } protected Group createGroup(String aName) { @@ -113,7 +113,7 @@ public class InMemoryUserSetTest extends TestCase { * @param aSize Expected number of users. */ protected void checkUserCount(int aSize) throws SQLException { - assertEquals(aSize, _users.size()); + assertEquals(aSize, users.size()); } /** @@ -147,14 +147,14 @@ public class InMemoryUserSetTest extends TestCase { * */ public void testAdd() throws SQLException, UserMgtException { - User user = createUser("user1", PASSWORD, _group); - assertTrue( _users.add(user) ); + User user = createUser("user1", PASSWORD, group); + assertTrue( users.add(user) ); checkUserExists(user.getName()); checkUserCount(1); - User user2 = _users.find("user1"); + User user2 = users.find("user1"); assertNotNull(user2); assertEquals(user.getName(), user2.getName()); - Set set = _users.list(); + Set set = users.list(); assertEquals(1, set.size()); assertTrue(set.contains(user)); } @@ -165,14 +165,14 @@ public class InMemoryUserSetTest extends TestCase { * */ public void testFindUnknownUser() throws SQLException, UserMgtException { - User user1 = createUser("user1", PASSWORD, _group); - User user2 = createUser("user2", PASSWORD, _group); - _users.add(user1); - _users.add(user2); + User user1 = createUser("user1", PASSWORD, group); + User user2 = createUser("user2", PASSWORD, group); + users.add(user1); + users.add(user2); checkUserExists(user1.getName()); checkUserExists(user2.getName()); - assertNull( _users.find("user3") ); + assertNull( users.find("user3") ); checkUserNotExists("user3"); } @@ -180,14 +180,14 @@ public class InMemoryUserSetTest extends TestCase { * Adds duplicate user. Verifies that the existing user is left untouched. */ public void testAddDuplicateUser() throws SQLException, UserMgtException { - User user1 = createUser("user1", PASSWORD, _group); - _users.add(user1); + User user1 = createUser("user1", PASSWORD, group); + users.add(user1); - assertEquals(1, _users.list().size()); - assertTrue(_users.contains(user1)); - user1 = createUser("user1", PASSWORD, _group); - assertFalse(_users.add(user1)); - assertEquals(1, _users.list().size()); + assertEquals(1, users.list().size()); + assertTrue(users.contains(user1)); + user1 = createUser("user1", PASSWORD, group); + assertFalse(users.add(user1)); + assertEquals(1, users.list().size()); checkUserExists(user1.getName()); checkUserCount(1); @@ -199,15 +199,15 @@ public class InMemoryUserSetTest extends TestCase { * */ public void testRemoveUser() throws SQLException, UserMgtException { - User user1 = createUser("user1", PASSWORD, _group); - _users.add(user1); - assertTrue(_users.contains(user1)); + User user1 = createUser("user1", PASSWORD, group); + users.add(user1); + assertTrue(users.contains(user1)); checkUserCount(1); - assertTrue(_users.remove(user1)); - assertFalse(_users.contains(user1)); - assertNull(_users.find(user1.getName())); - assertEquals(0, _users.list().size()); + assertTrue(users.remove(user1)); + assertFalse(users.contains(user1)); + assertNull(users.find(user1.getName())); + assertEquals(0, users.list().size()); checkUserCount(0); } @@ -217,15 +217,15 @@ public class InMemoryUserSetTest extends TestCase { * */ public void testRemoveNonExistingUser() throws SQLException, UserMgtException { - User user1 = createUser("user1", PASSWORD, _group); - _users.add(user1); + User user1 = createUser("user1", PASSWORD, group); + users.add(user1); checkUserCount(1); - User nonExistingUser = createUser("user2", PASSWORD, _group); + User nonExistingUser = createUser("user2", PASSWORD, group); nonExistingUser.setPrimaryKey(new Long(1000)); nonExistingUser.setPersistedVersion(10); - assertFalse(_users.remove(nonExistingUser)); - assertTrue(_users.contains(user1)); - assertEquals(1, _users.list().size()); + assertFalse(users.remove(nonExistingUser)); + assertTrue(users.contains(user1)); + assertEquals(1, users.list().size()); checkUserCount(1); } @@ -235,18 +235,18 @@ public class InMemoryUserSetTest extends TestCase { * */ public void testList() throws SQLException, UserMgtException { - User user1 = createUser("user1", PASSWORD, _group); - User user2 = createUser("user2", PASSWORD, _group); - User user3 = createUser("user3", PASSWORD, _group); - assertTrue(_users.add(user1)); - assertTrue(_users.add(user2)); - assertTrue(_users.add(user3)); + User user1 = createUser("user1", PASSWORD, group); + User user2 = createUser("user2", PASSWORD, group); + User user3 = createUser("user3", PASSWORD, group); + assertTrue(users.add(user1)); + assertTrue(users.add(user2)); + assertTrue(users.add(user3)); checkUserExists(user1.getName()); checkUserExists(user2.getName()); checkUserExists(user3.getName()); - Set set = _users.list(); + Set set = users.list(); assertTrue(set.contains(user1)); assertTrue(set.contains(user2)); assertTrue(set.contains(user3)); @@ -264,9 +264,9 @@ public class InMemoryUserSetTest extends TestCase { Group group1 = new Group("group1"); Group group2 = new Group("group2"); Group group3 = new Group("group3"); - _groups.add(group1); - _groups.add(group2); - _groups.add(group3); + groups.add(group1); + groups.add(group2); + groups.add(group3); // user1 user2 user3 // group1 y @@ -279,9 +279,9 @@ public class InMemoryUserSetTest extends TestCase { User user2 = createUser("user2", PASSWORD, group2); user2.addGroup(group3); User user3 = createUser("user3", PASSWORD, group3); - _users.add(user1); - _users.add(user2); - _users.add(user3); + users.add(user1); + users.add(user2); + users.add(user3); checkUserExists(user1.getName()); checkUserExists(user2.getName()); @@ -294,16 +294,16 @@ public class InMemoryUserSetTest extends TestCase { checkUserCount(3); checkGroupCount(3+1); // also count the group that was created in the setUp(). - Set list = _users.list(group1); + Set list = users.list(group1); assertTrue(list.contains(user1)); assertEquals(1, list.size()); - list = _users.list(group2); + list = users.list(group2); assertTrue(list.contains(user1)); assertTrue(list.contains(user2)); assertEquals(2, list.size()); - list = _users.list(group3); + list = users.list(group3); assertTrue(list.contains(user1)); assertTrue(list.contains(user2)); assertTrue(list.contains(user3)); diff --git a/security/src/test/java/org/wamblee/usermgt/UserAdministrationImplTest.java b/security/src/test/java/org/wamblee/usermgt/UserAdministrationImplTest.java index 055828d6..bdf4f205 100644 --- a/security/src/test/java/org/wamblee/usermgt/UserAdministrationImplTest.java +++ b/security/src/test/java/org/wamblee/usermgt/UserAdministrationImplTest.java @@ -46,7 +46,7 @@ public class UserAdministrationImplTest extends TestCase { private static final String GROUP2 = "runners"; - private UserAdministration _admin; + private UserAdministration admin; /* @@ -57,7 +57,7 @@ public class UserAdministrationImplTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - _admin = createAdmin(); + admin = createAdmin(); } protected UserAdministration createAdmin() { @@ -79,10 +79,10 @@ public class UserAdministrationImplTest extends TestCase { * Constructs the admin, verify it contains no users and no groups. */ public void testConstruct() { - assertEquals(0, _admin.getUsers().size()); - assertEquals(0, _admin.getGroups().size()); - assertEquals(0, _admin.getUserCount()); - assertEquals(0, _admin.getGroupCount()); + assertEquals(0, admin.getUsers().size()); + assertEquals(0, admin.getGroups().size()); + assertEquals(0, admin.getUserCount()); + assertEquals(0, admin.getGroupCount()); } /** @@ -91,24 +91,24 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testCreateGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); assertNotNull(group); assertEquals(GROUP1, group.getName()); - Set groups = _admin.getGroups(); + Set groups = admin.getGroups(); assertEquals(1, groups.size()); - assertEquals(1, _admin.getGroupCount()); + assertEquals(1, admin.getGroupCount()); assertTrue(groups.contains(group)); } private void createInvalidGroup(String aUsername) { try { - _admin.createGroup(aUsername); + admin.createGroup(aUsername); fail(); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.INVALID_GROUPNAME, e .getReason()); - assertEquals(0, _admin.getGroupCount()); + assertEquals(0, admin.getGroupCount()); } } @@ -132,12 +132,12 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testCreateDuplicateGroup() throws UserMgtException { - _admin.createGroup(GROUP1); + admin.createGroup(GROUP1); try { - _admin.createGroup(GROUP1); + admin.createGroup(GROUP1); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.DUPLICATE_GROUP, e.getReason()); - assertEquals(1, _admin.getGroupCount()); + assertEquals(1, admin.getGroupCount()); return; } fail(); @@ -149,26 +149,26 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testCreateUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); assertNotNull(user); assertEquals(USER1, user.getName()); user.checkPassword(PASS1); - Set users = _admin.getUsers(); + Set users = admin.getUsers(); assertEquals(1, users.size()); - assertEquals(1, _admin.getUserCount()); + assertEquals(1, admin.getUserCount()); assertTrue(users.contains(user)); } private void createInvalidUser(String aUsername, Group aGroup) { try { - _admin.createUser(aUsername, "pass", aGroup); + admin.createUser(aUsername, "pass", aGroup); fail(); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.INVALID_USERNAME, e .getReason()); - assertEquals(0, _admin.getUserCount()); + assertEquals(0, admin.getUserCount()); } } @@ -178,7 +178,7 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testCreateInvalidUserName() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); createInvalidUser("", group); createInvalidUser("0abc", group); // should not start with digits createInvalidUser("a b", group); // should not contain spaces @@ -192,14 +192,14 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testCreateDuplicateUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + admin.createUser(USER1, PASS1, group); try { - _admin.createUser(USER1, PASS2, group); + admin.createUser(USER1, PASS2, group); fail(); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.DUPLICATE_USER, e.getReason()); - assertEquals(1, _admin.getUserCount()); + assertEquals(1, admin.getUserCount()); } } @@ -209,11 +209,11 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testGetUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); - User user2 = _admin.getUser(USER1); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); + User user2 = admin.getUser(USER1); assertTrue(user.equals(user2)); - assertNull(_admin.getUser(USER2)); + assertNull(admin.getUser(USER2)); } /** @@ -222,10 +222,10 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testGetGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - Group group2 = _admin.getGroup(GROUP1); + Group group = admin.createGroup(GROUP1); + Group group2 = admin.getGroup(GROUP1); assertTrue(group.equals(group2)); - assertNull(_admin.getGroup(GROUP2)); + assertNull(admin.getGroup(GROUP2)); } /** @@ -236,21 +236,21 @@ public class UserAdministrationImplTest extends TestCase { */ public void testAddUserToGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); - Group group2 = _admin.createGroup(GROUP2); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); + Group group2 = admin.createGroup(GROUP2); assertTrue(user.isInGroup(group)); assertFalse(user.isInGroup(group2)); - _admin.addUserToGroup(user, group2); + admin.addUserToGroup(user, group2); assertTrue(user.isInGroup(group)); assertTrue(user.isInGroup(group2)); - Set users = _admin.getUsers(group2); + Set users = admin.getUsers(group2); assertNotNull(users); assertEquals(1, users.size()); assertTrue(users.contains(user)); try { - _admin.addUserToGroup(user, group); + admin.addUserToGroup(user, group); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.USER_ALREADY_IN_GROUP, e .getReason()); @@ -265,10 +265,10 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testAddUserToGroupUnknownUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); User user = createUser(USER1, PASS1, group); try { - _admin.addUserToGroup(user, group); + admin.addUserToGroup(user, group); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_USER, e.getReason()); return; @@ -282,11 +282,11 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testAddUserToGroupUnknownGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); Group group2 = new Group(GROUP2); try { - _admin.addUserToGroup(user, group2); + admin.addUserToGroup(user, group2); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_GROUP, e.getReason()); return; @@ -300,17 +300,17 @@ public class UserAdministrationImplTest extends TestCase { * user not part of the group or if the user is only part of one group. */ public void testRemoveUserFromGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); - Group group2 = _admin.createGroup(GROUP2); - _admin.addUserToGroup(user, group2); + User user = admin.createUser(USER1, PASS1, group); + Group group2 = admin.createGroup(GROUP2); + admin.addUserToGroup(user, group2); Set groups = user.getGroups(); assertEquals(2, groups.size()); assertTrue(groups.contains(group)); assertTrue(groups.contains(group2)); - _admin.removeUserFromGroup(user, group); + admin.removeUserFromGroup(user, group); groups = user.getGroups(); assertEquals(1, groups.size()); assertTrue(groups.contains(group2)); @@ -323,10 +323,10 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRemoveUserFromGroupUnknownUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); User user = createUser(USER1, GROUP1, group); try { - _admin.removeUserFromGroup(user, group); + admin.removeUserFromGroup(user, group); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_USER, e.getReason()); } @@ -338,11 +338,11 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRemoveUserFromGroupUnknownGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); Group group2 = new Group(GROUP2); try { - _admin.removeUserFromGroup(user, group2); + admin.removeUserFromGroup(user, group2); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_GROUP, e.getReason()); } @@ -353,10 +353,10 @@ public class UserAdministrationImplTest extends TestCase { * Verifies that an exception is thrown. */ public void testRemoveUserFromGroupOnlyGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); try { - _admin.removeUserFromGroup(user, group); + admin.removeUserFromGroup(user, group); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.USER_MUST_BE_IN_A_GROUP, e .getReason()); @@ -370,19 +370,19 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testGetUsersAndGroups() throws UserMgtException { - Group group1 = _admin.createGroup(GROUP1); - Group group2 = _admin.createGroup(GROUP2); + Group group1 = admin.createGroup(GROUP1); + Group group2 = admin.createGroup(GROUP2); - User user1 = _admin.createUser(USER1, PASS1, group1); - _admin.addUserToGroup(user1, group2); - User user2 = _admin.createUser(USER2, PASS2, group2); + User user1 = admin.createUser(USER1, PASS1, group1); + admin.addUserToGroup(user1, group2); + User user2 = admin.createUser(USER2, PASS2, group2); - Set users = _admin.getUsers(); + Set users = admin.getUsers(); assertEquals(2, users.size()); assertTrue(users.contains(user1)); assertTrue(users.contains(user2)); - Set groups = _admin.getGroups(); + Set groups = admin.getGroups(); assertEquals(2, groups.size()); assertTrue(groups.contains(group1)); assertTrue(groups.contains(group2)); @@ -406,22 +406,22 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRenameUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user1 = _admin.createUser(USER1, PASS1, group); - _admin.renameUser(user1, USER2); + Group group = admin.createGroup(GROUP1); + User user1 = admin.createUser(USER1, PASS1, group); + admin.renameUser(user1, USER2); assertEquals(USER2, user1.getName()); - assertEquals(user1, _admin.getUser(USER2)); + assertEquals(user1, admin.getUser(USER2)); - _admin.createUser(USER1, PASS1, group); + admin.createUser(USER1, PASS1, group); try { - _admin.renameUser(user1, USER1); + admin.renameUser(user1, USER1); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.DUPLICATE_USER, e.getReason()); // do a trivial reanem try { - _admin.renameUser(user1, user1.getName()); + admin.renameUser(user1, user1.getName()); } catch (UserMgtException e2) { assertEquals(UserMgtException.Reason.TRIVIAL_RENAME, e2 .getReason()); @@ -438,10 +438,10 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRenameUserInvalidUsername() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user1 = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user1 = admin.createUser(USER1, PASS1, group); try { - _admin.renameUser(user1, USER2); + admin.renameUser(user1, USER2); } catch (UserMgtException e) { assertEquals(e.getReason(), Reason.INVALID_USERNAME); } @@ -454,20 +454,20 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRenameGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - _admin.renameGroup(group, GROUP2); + Group group = admin.createGroup(GROUP1); + admin.renameGroup(group, GROUP2); assertEquals(GROUP2, group.getName()); - assertEquals(group, _admin.getGroup(GROUP2)); + assertEquals(group, admin.getGroup(GROUP2)); - _admin.createGroup(GROUP1); + admin.createGroup(GROUP1); try { - _admin.renameGroup(group, GROUP1); + admin.renameGroup(group, GROUP1); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.DUPLICATE_GROUP, e.getReason()); // do a trivial reanem try { - _admin.renameGroup(group, group.getName()); + admin.renameGroup(group, group.getName()); } catch (UserMgtException e2) { assertEquals(UserMgtException.Reason.TRIVIAL_RENAME, e2 .getReason()); @@ -485,9 +485,9 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRenameGroupInvalidGroupname() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); try { - _admin.renameGroup(group, "a b"); + admin.renameGroup(group, "a b"); } catch (UserMgtException e) { assertEquals(e.getReason(), Reason.INVALID_GROUPNAME); } @@ -499,20 +499,20 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRemoveUser() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); - assertEquals(1, _admin.getUserCount()); - _admin.removeUser(user); - assertEquals(0, _admin.getUserCount()); + assertEquals(1, admin.getUserCount()); + admin.removeUser(user); + assertEquals(0, admin.getUserCount()); - _admin.createUser(USER1, PASS1, group); - assertEquals(1, _admin.getUserCount()); + admin.createUser(USER1, PASS1, group); + assertEquals(1, admin.getUserCount()); User user2 = createUser(USER2, PASS2, group); try { - _admin.removeUser(user2); + admin.removeUser(user2); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_USER, e.getReason()); } @@ -525,15 +525,15 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRemoveGroup() throws UserMgtException { - Group group1 = _admin.createGroup(GROUP1); - assertEquals(1, _admin.getGroupCount()); - _admin.removeGroup(group1); - assertEquals(0, _admin.getGroupCount()); - group1 = _admin.createGroup(GROUP1); + Group group1 = admin.createGroup(GROUP1); + assertEquals(1, admin.getGroupCount()); + admin.removeGroup(group1); + assertEquals(0, admin.getGroupCount()); + group1 = admin.createGroup(GROUP1); - _admin.createUser(USER1, PASS1, group1); + admin.createUser(USER1, PASS1, group1); try { - _admin.removeGroup(group1); + admin.removeGroup(group1); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.GROUP_STILL_OCCUPIED, e .getReason()); @@ -547,10 +547,10 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testRemoveGroupUnknownGroup() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); + Group group = admin.createGroup(GROUP1); Group group2 = new Group(GROUP2); try { - _admin.removeGroup(group2); + admin.removeGroup(group2); } catch (UserMgtException e) { assertEquals(UserMgtException.Reason.UNKNOWN_GROUP, e.getReason()); } @@ -562,12 +562,12 @@ public class UserAdministrationImplTest extends TestCase { * @throws UserMgtException */ public void testChangePassword() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - User user = _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + User user = admin.createUser(USER1, PASS1, group); user.changePassword(PASS1, PASS2); // retrieve the user and verifies the password hasn't changed. - User user2 = _admin.getUser(USER1); + User user2 = admin.getUser(USER1); try { user2.checkPassword(PASS2); fail(); // password should not have changed already. @@ -576,9 +576,9 @@ public class UserAdministrationImplTest extends TestCase { } // now notify the admin of the change in the user - _admin.userModified(user); + admin.userModified(user); - user2 = _admin.getUser(USER1); + user2 = admin.getUser(USER1); user2.checkPassword(PASS2); // this time it should succeed. } @@ -588,13 +588,13 @@ public class UserAdministrationImplTest extends TestCase { * */ public void testPerformanceFindUserByName() throws UserMgtException { - Group group = _admin.createGroup(GROUP1); - _admin.createUser(USER1, PASS1, group); + Group group = admin.createGroup(GROUP1); + admin.createUser(USER1, PASS1, group); int n = 1000; long time = System.currentTimeMillis(); for (int i = 0; i < n; i++) { - _admin.getUser(USER1); + admin.getUser(USER1); } LOGGER.info("Looked up a user " + n + " times in " + (float) (System.currentTimeMillis() - time) / 1000.0); diff --git a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java index fa80b1a4..43bf8c89 100644 --- a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java +++ b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java @@ -40,41 +40,41 @@ public class HibernateGroupSetTest extends InMemoryGroupSetTest { private static final String GROUP_QUERY = "select * from " + GROUP_TABLE + " where name = ?"; - private DefaultContainer _container; - private Scope _scope; + private DefaultContainer container; + private Scope scope; - private DatabaseTesterComponent _databaseTester; - private GroupSet _groupSet; + private DatabaseTesterComponent databaseTester; + private GroupSet groupSet; @Override protected void setUp() throws Exception { - _container = new UserMgtRepositoryTestContainer("top"); + container = new UserMgtRepositoryTestContainer("top"); ObjectConfiguration config = new ObjectConfiguration( HibernateGroupSetTest.class); config.getSetterConfig().clear().add( "setGroupSet").add("setDatabaseTester"); - _container.addComponent("testcase", this, config); + container.addComponent("testcase", this, config); - _scope = _container.start(); + scope = container.start(); - _databaseTester.cleanDatabase(); + databaseTester.cleanDatabase(); super.setUp(); } @Override protected void tearDown() throws Exception { - _container.stop(_scope); + container.stop(scope); super.tearDown(); } public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) { - _databaseTester = aDatabaseTester; + databaseTester = aDatabaseTester; } public void setGroupSet(GroupSet aGroupSet) { - _groupSet = aGroupSet; + groupSet = aGroupSet; } /* (non-Javadoc) @@ -82,9 +82,9 @@ public class HibernateGroupSetTest extends InMemoryGroupSetTest { */ @Override protected void checkGroupCount(int aSize) throws SQLException { - _databaseTester.flush(); + databaseTester.flush(); super.checkGroupCount(aSize); - assertEquals(aSize, _databaseTester.getTableSize(GROUP_TABLE)); + assertEquals(aSize, databaseTester.getTableSize(GROUP_TABLE)); } /* (non-Javadoc) @@ -92,17 +92,17 @@ public class HibernateGroupSetTest extends InMemoryGroupSetTest { */ @Override protected void checkGroupExists(final String aGroup) throws SQLException { - _databaseTester.flush(); + databaseTester.flush(); Map result = - _databaseTester.executeTransaction(new TestTransactionCallback() { + databaseTester.executeTransaction(new TestTransactionCallback() { /* (non-Javadoc) * @see org.wamblee.test.TestTransactionCallback#execute() */ @Override public Map execute() throws Exception { - ResultSet result = _databaseTester.executeQuery(GROUP_QUERY, aGroup); + ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup); Map res = new HashMap(); - res.put("result", _databaseTester.countResultSet(result)); + res.put("result", databaseTester.countResultSet(result)); return res; } }); @@ -116,9 +116,9 @@ public class HibernateGroupSetTest extends InMemoryGroupSetTest { */ @Override protected void checkGroupNotExists(String aGroup) throws SQLException { - _databaseTester.flush(); - ResultSet result = _databaseTester.executeQuery(GROUP_QUERY, aGroup); - assertEquals(0, _databaseTester.countResultSet(result)); + databaseTester.flush(); + ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup); + assertEquals(0, databaseTester.countResultSet(result)); } /* (non-Javadoc) @@ -126,7 +126,7 @@ public class HibernateGroupSetTest extends InMemoryGroupSetTest { */ @Override protected GroupSet createGroupSet() { - return _groupSet; + return groupSet; } } diff --git a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java index f707dba0..08ec4ae9 100644 --- a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java +++ b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java @@ -46,12 +46,12 @@ public class HibernateUserAdministrationTest extends UserAdministrationImplTest private static final Log LOG = LogFactory.getLog(HibernateUserAdministrationTest.class); - private DefaultContainer _container; - private Scope _scope; + private DefaultContainer container; + private Scope scope; - private DatabaseTesterComponent _databaseTester; - private EhCache _userCache; - private UserAdministration _userAdmin; + private DatabaseTesterComponent databaseTester; + private EhCache userCache; + private UserAdministration userAdmin; /* (non-Javadoc) @@ -60,44 +60,44 @@ public class HibernateUserAdministrationTest extends UserAdministrationImplTest @Override protected void setUp() throws Exception { - _container = new DefaultContainer("top"); - DatabaseComponentFactory.addDatabaseConfig(_container); - _container.addComponent(new DatasourceComponent("datasource")); - _container.addComponent(new UserAdministrationComponent("admin", true)); + container = new DefaultContainer("top"); + DatabaseComponentFactory.addDatabaseConfig(container); + container.addComponent(new DatasourceComponent("datasource")); + container.addComponent(new UserAdministrationComponent("admin", true)); ClassConfiguration dbtesterConfig = new ClassConfiguration(DatabaseTesterComponent.class); dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters(); - _container.addComponent("databaseTester", dbtesterConfig); + container.addComponent("databaseTester", dbtesterConfig); ObjectConfiguration config = new ObjectConfiguration( HibernateUserAdministrationTest.class); config.getSetterConfig().clear().add( "setUserCache").add("setDatabaseTester").add("setUserAdmin"); - _container.addComponent("testcase", this, config); + container.addComponent("testcase", this, config); - _scope = _container.start(); + scope = container.start(); - _databaseTester.cleanDatabase(); + databaseTester.cleanDatabase(); super.setUp(); clearUserCache(); } public void setUserCache(EhCache aUserCache) { - _userCache = aUserCache; + userCache = aUserCache; } public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) { - _databaseTester = aDatabaseTester; + databaseTester = aDatabaseTester; } public void setUserAdmin(UserAdministration aUserAdmin) { - _userAdmin = aUserAdmin; + userAdmin = aUserAdmin; } @Override protected void tearDown() throws Exception { - _container.stop(_scope); + container.stop(scope); super.tearDown(); } @@ -108,7 +108,7 @@ public class HibernateUserAdministrationTest extends UserAdministrationImplTest */ @Override protected UserAdministration createAdmin() { - return _userAdmin; + return userAdmin; } public void testAllTestsInASeparateTransaction() throws SQLException { @@ -116,9 +116,9 @@ public class HibernateUserAdministrationTest extends UserAdministrationImplTest Method[] methods = UserAdministrationImplTest.class.getMethods(); for (final Method method : methods) { if (method.getName().startsWith("test")) { - _databaseTester.cleanDatabase(); + databaseTester.cleanDatabase(); clearUserCache(); - _databaseTester.executeTransaction(new TestTransactionCallbackWithoutResult() { + databaseTester.executeTransaction(new TestTransactionCallbackWithoutResult() { public void execute() throws Exception { LOG.info("Running test " + method.getName()); try { @@ -141,6 +141,6 @@ public class HibernateUserAdministrationTest extends UserAdministrationImplTest * */ private void clearUserCache() { - _userCache.clear(); + userCache.clear(); } } diff --git a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java index 82588b3b..46e80fb3 100644 --- a/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java +++ b/security/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java @@ -48,13 +48,13 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { private static final String GROUP_QUERY = "select * from " + GROUP_TABLE + " where name = ?"; - private DefaultContainer _container; - private Scope _scope; + private DefaultContainer container; + private Scope scope; - private UserSet _userset; - private GroupSet _groupset; - private EhCache _userCache; - private DatabaseTesterComponent _databaseTester; + private UserSet userset; + private GroupSet groupset; + private EhCache userCache; + private DatabaseTesterComponent databaseTester; /* * (non-Javadoc) @@ -64,41 +64,41 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { @Override protected void setUp() throws Exception { - _container = new UserMgtRepositoryTestContainer("top"); + container = new UserMgtRepositoryTestContainer("top"); ObjectConfiguration config = new ObjectConfiguration( HibernateUserSetTest.class); config.getSetterConfig().clear().add("setUserset").add( "setGroupset").add("setDatabaseTester").add("setUserCache"); - _container.addComponent("testcase", this, config); + container.addComponent("testcase", this, config); - _scope = _container.start(); + scope = container.start(); clearUserCache(); - _databaseTester.cleanDatabase(); + databaseTester.cleanDatabase(); super.setUp(); } public void setUserset(UserSet aUserset) { - _userset = aUserset; + userset = aUserset; } public void setGroupset(GroupSet aGroupset) { - _groupset = aGroupset; + groupset = aGroupset; } public void setUserCache(EhCache aUserCache) { - _userCache = aUserCache; + userCache = aUserCache; } public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) { - _databaseTester = aDatabaseTester; + databaseTester = aDatabaseTester; } @Override protected void tearDown() throws Exception { - _container.stop(_scope); + container.stop(scope); super.tearDown(); } @@ -106,7 +106,7 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { * Clears the user cache. */ private void clearUserCache() { - _userCache.clear(); + userCache.clear(); } /* @@ -116,9 +116,9 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkUserCount(int aSize) throws SQLException { - _databaseTester.flush(); + databaseTester.flush(); super.checkUserCount(aSize); - assertEquals(aSize, _databaseTester.getTableSize(USER_TABLE)); + assertEquals(aSize, databaseTester.getTableSize(USER_TABLE)); } /* @@ -128,9 +128,9 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkUserExists(String aUser) throws SQLException { - _databaseTester.flush(); - ResultSet result = _databaseTester.executeQuery(USER_QUERY, aUser); - assertEquals(1, _databaseTester.countResultSet(result)); + databaseTester.flush(); + ResultSet result = databaseTester.executeQuery(USER_QUERY, aUser); + assertEquals(1, databaseTester.countResultSet(result)); } /* @@ -140,9 +140,9 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkUserNotExists(String aUser) throws SQLException { - _databaseTester.flush(); - ResultSet result = _databaseTester.executeQuery(USER_QUERY, aUser); - assertEquals(0, _databaseTester.countResultSet(result)); + databaseTester.flush(); + ResultSet result = databaseTester.executeQuery(USER_QUERY, aUser); + assertEquals(0, databaseTester.countResultSet(result)); } /* @@ -152,8 +152,8 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkGroupCount(int aSize) throws SQLException { - _databaseTester.flush(); - assertEquals(aSize, _databaseTester.getTableSize(GROUP_TABLE)); + databaseTester.flush(); + assertEquals(aSize, databaseTester.getTableSize(GROUP_TABLE)); } /* @@ -163,10 +163,10 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkGroupExists(String aGroup) throws SQLException { - _databaseTester.flush(); + databaseTester.flush(); - ResultSet result = _databaseTester.executeQuery(GROUP_QUERY, aGroup); - assertEquals(1, _databaseTester.countResultSet(result)); + ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup); + assertEquals(1, databaseTester.countResultSet(result)); } /* @@ -176,9 +176,9 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected void checkGroupNotExists(String aGroup) throws SQLException { - _databaseTester.flush(); - ResultSet result = _databaseTester.executeQuery(GROUP_QUERY, aGroup); - assertEquals(0, _databaseTester.countResultSet(result)); + databaseTester.flush(); + ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup); + assertEquals(0, databaseTester.countResultSet(result)); } /* @@ -188,7 +188,7 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected UserSet createUserSet() { - return _userset; + return userset; } /* @@ -198,7 +198,7 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { */ @Override protected GroupSet createGroupSet() { - return _groupset; + return groupset; } /** @@ -207,7 +207,7 @@ public class HibernateUserSetTest extends InMemoryUserSetTest { * group2. */ public void testVerifyAddRemove() throws SQLException, UserMgtException { - _databaseTester.cleanDatabase(); // just to be sure. + databaseTester.cleanDatabase(); // just to be sure. GroupSet groups = getGroups(); assertEquals(0, groups.size()); Group group1 = createGroup("group1"); diff --git a/support/general/src/main/java/org/wamblee/cache/CachedObject.java b/support/general/src/main/java/org/wamblee/cache/CachedObject.java index 58daf8c9..f844c728 100644 --- a/support/general/src/main/java/org/wamblee/cache/CachedObject.java +++ b/support/general/src/main/java/org/wamblee/cache/CachedObject.java @@ -51,17 +51,17 @@ public class CachedObject _cache; + private Cache cache; /** * Key of the object in the cache. */ - private KeyType _objectKey; + private KeyType objectKey; /** * Computation used to obtain the object if it is not found in the cache. */ - private Computation _computation; + private Computation computation; /** * Constructs the cached object. @@ -76,9 +76,9 @@ public class CachedObject aCache, KeyType aObjectKey, Computation aComputation) { - _cache = aCache; - _objectKey = aObjectKey; - _computation = aComputation; + cache = aCache; + objectKey = aObjectKey; + computation = aComputation; } /** @@ -88,7 +88,7 @@ public class CachedObject _map; + private HashMap map; /** * Constructs the cache. * */ public ForeverCache() { - _map = new HashMap(); + map = new HashMap(); } /* @@ -47,7 +47,7 @@ public class ForeverCache _readers; + private HashSet readers; /** * The thread that has acquired the lock for writing or null if no such * thread exists currently. */ - private Thread _writer; + private Thread writer; /** * Constructs read-write lock. */ public ReadWriteLock() { - _readers = new HashSet(); - _writer = null; + readers = new HashSet(); + writer = null; } /** @@ -55,19 +55,19 @@ public class ReadWriteLock { * already acquired. */ public synchronized void acquireRead() { - if (_readers.contains(Thread.currentThread())) { + if (readers.contains(Thread.currentThread())) { throw new IllegalStateException( "Read lock already acquired by current thread: " + Thread.currentThread()); } - if (_writer == Thread.currentThread()) { + if (writer == Thread.currentThread()) { throw new IllegalStateException( "Trying to acquire the read lock while already holding a write lock: " + Thread.currentThread()); } - while (_writer != null) { + while (writer != null) { try { wait(); } catch (InterruptedException e) { @@ -75,7 +75,7 @@ public class ReadWriteLock { } } - _readers.add(Thread.currentThread()); + readers.add(Thread.currentThread()); } /** @@ -86,12 +86,12 @@ public class ReadWriteLock { * this thread. */ public synchronized void releaseRead() { - if (!_readers.remove(Thread.currentThread())) { + if (!readers.remove(Thread.currentThread())) { throw new IllegalStateException( "Cannot release read lock because current thread has not acquired it."); } - if (_readers.size() == 0) { + if (readers.size() == 0) { notifyAll(); } } @@ -104,13 +104,13 @@ public class ReadWriteLock { * already acquired. */ public synchronized void acquireWrite() { - if (_writer == Thread.currentThread()) { + if (writer == Thread.currentThread()) { throw new IllegalStateException( "Trying to acquire a write lock while already holding the write lock: " + Thread.currentThread()); } - if (_readers.contains(Thread.currentThread())) { + if (readers.contains(Thread.currentThread())) { throw new IllegalStateException( "Trying to acquire a write lock while already holding the read lock: " + Thread.currentThread()); @@ -118,7 +118,7 @@ public class ReadWriteLock { // wait until there are no more writers and no more // readers - while ((_writer != null) || (_readers.size() > 0)) { + while ((writer != null) || (readers.size() > 0)) { try { wait(); } catch (InterruptedException e) { @@ -126,7 +126,7 @@ public class ReadWriteLock { } } - _writer = Thread.currentThread(); + writer = Thread.currentThread(); // notification not necessary since all writers and // readers are now blocked by this thread. @@ -138,12 +138,12 @@ public class ReadWriteLock { * @throws IllegalStateException Thrown when the lock was not acquired. */ public synchronized void releaseWrite() { - if (_writer != Thread.currentThread()) { + if (writer != Thread.currentThread()) { throw new IllegalStateException( "Cannot release write lock because it was not acquired. "); } - _writer = null; + writer = null; notifyAll(); } } diff --git a/support/general/src/main/java/org/wamblee/conditions/AndCondition.java b/support/general/src/main/java/org/wamblee/conditions/AndCondition.java index 50898739..52b53950 100644 --- a/support/general/src/main/java/org/wamblee/conditions/AndCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/AndCondition.java @@ -26,7 +26,7 @@ import java.util.List; */ public class AndCondition implements Condition { - private List> _conditions; + private List> conditions; /** * Constructs the condition. @@ -37,9 +37,9 @@ public class AndCondition implements Condition { * Second condition. */ public AndCondition(Condition aCondition1, Condition aCondition2) { - _conditions = new ArrayList>(); - _conditions.add(aCondition1); - _conditions.add(aCondition2); + conditions = new ArrayList>(); + conditions.add(aCondition1); + conditions.add(aCondition2); } /** @@ -49,7 +49,7 @@ public class AndCondition implements Condition { * List of conditions to use in the logical and. */ public AndCondition(List> aConditions) { - _conditions = aConditions; + conditions = aConditions; } /* @@ -58,7 +58,7 @@ public class AndCondition implements Condition { * @see org.wamblee.crawler.kiss.ProgramMatcher#matches(org.wamblee.crawler.kiss.Program) */ public boolean matches(T aObject) { - for (Condition condition : _conditions) { + for (Condition condition : conditions) { if (!condition.matches(aObject)) { return false; } diff --git a/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java b/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java index eff83b1b..d9848d7c 100644 --- a/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java @@ -23,21 +23,21 @@ package org.wamblee.conditions; */ public class FixedCondition implements Condition { - private boolean _value; + private boolean value; /** * Constructs the condition. * @param aValue Fixed value of the condition. */ public FixedCondition(boolean aValue) { - _value = aValue; + value = aValue; } /* (non-Javadoc) * @see org.wamblee.conditions.Condition#matches(T) */ public boolean matches(T aObject) { - return _value; + return value; } } diff --git a/support/general/src/main/java/org/wamblee/conditions/OrCondition.java b/support/general/src/main/java/org/wamblee/conditions/OrCondition.java index 0840c78b..a15b4eff 100644 --- a/support/general/src/main/java/org/wamblee/conditions/OrCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/OrCondition.java @@ -26,7 +26,7 @@ import java.util.List; */ public class OrCondition implements Condition { - private List> _conditions; + private List> conditions; /** * Constructs the condition. @@ -37,9 +37,9 @@ public class OrCondition implements Condition { * Second condition. */ public OrCondition(Condition aCondition1, Condition aCondition2) { - _conditions = new ArrayList>(); - _conditions.add(aCondition1); - _conditions.add(aCondition2); + conditions = new ArrayList>(); + conditions.add(aCondition1); + conditions.add(aCondition2); } /** @@ -49,7 +49,7 @@ public class OrCondition implements Condition { * List of conditions to use in the logical or. */ public OrCondition(List> aConditions) { - _conditions = aConditions; + conditions = aConditions; } /* @@ -58,7 +58,7 @@ public class OrCondition implements Condition { * @see org.wamblee.crawler.kiss.ProgramMatcher#matches(org.wamblee.crawler.kiss.Program) */ public boolean matches(T aObject) { - for (Condition condition : _conditions) { + for (Condition condition : conditions) { if (condition.matches(aObject)) { return true; } diff --git a/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java b/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java index 2ce7a0e9..cfc1e165 100644 --- a/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java @@ -33,17 +33,17 @@ public class PropertyRegexCondition implements Condition { /** * Property name. */ - private String _property; + private String property; /** * Regular expression. */ - private Pattern _regex; + private Pattern regex; /** * Whether or not to convert the value to lowercase before matching. */ - private boolean _tolower; + private boolean tolower; /** * Constructs the condition. @@ -52,9 +52,9 @@ public class PropertyRegexCondition implements Condition { * @param aTolower Whether or not to convert the value to lowercase before matching. */ public PropertyRegexCondition(String aProperty, String aRegex, boolean aTolower) { - _property = aProperty; - _regex = Pattern.compile(aRegex); - _tolower = aTolower; + property = aProperty; + regex = Pattern.compile(aRegex); + tolower = aTolower; } /* (non-Javadoc) @@ -62,11 +62,11 @@ public class PropertyRegexCondition implements Condition { */ public boolean matches(T aObject) { try { - String value = PropertyUtils.getProperty(aObject, _property) + ""; - if ( _tolower ) { + String value = PropertyUtils.getProperty(aObject, property) + ""; + if ( tolower ) { value = value.toLowerCase(); } - Matcher matcher = _regex.matcher(value); + Matcher matcher = regex.matcher(value); return matcher.matches(); } catch (IllegalAccessException e) { throw new RuntimeException(e.getMessage(), e); diff --git a/support/general/src/main/java/org/wamblee/general/Pair.java b/support/general/src/main/java/org/wamblee/general/Pair.java index 2d90387f..bf5e589c 100644 --- a/support/general/src/main/java/org/wamblee/general/Pair.java +++ b/support/general/src/main/java/org/wamblee/general/Pair.java @@ -31,9 +31,9 @@ package org.wamblee.general; */ public class Pair { - private T _t; + private T t; - private U _u; + private U u; /** * Constructs the pair. @@ -44,8 +44,8 @@ public class Pair { * Second object. */ public Pair(T aT, U aU) { - _t = aT; - _u = aU; + t = aT; + u = aU; } /** @@ -55,8 +55,8 @@ public class Pair { * Pair to copy. */ public Pair(Pair aPair) { - _t = aPair._t; - _u = aPair._u; + t = aPair.t; + u = aPair.u; } /** @@ -65,7 +65,7 @@ public class Pair { * @return First object. */ public T getFirst() { - return _t; + return t; } /** @@ -74,7 +74,7 @@ public class Pair { * @return Second object. */ public U getSecond() { - return _u; + return u; } } diff --git a/support/general/src/main/java/org/wamblee/io/ClassPathResource.java b/support/general/src/main/java/org/wamblee/io/ClassPathResource.java index 32014a10..7ecdcc97 100644 --- a/support/general/src/main/java/org/wamblee/io/ClassPathResource.java +++ b/support/general/src/main/java/org/wamblee/io/ClassPathResource.java @@ -25,7 +25,7 @@ public class ClassPathResource implements InputResource { /** * Resource name. */ - private String _resource; + private String resource; /** * Construct the class path resource. @@ -34,7 +34,7 @@ public class ClassPathResource implements InputResource { * Resource */ public ClassPathResource(String aResource) { - _resource = aResource; + resource = aResource; } /* @@ -44,9 +44,9 @@ public class ClassPathResource implements InputResource { */ public InputStream getInputStream() throws IOException { InputStream stream = Thread.currentThread().getContextClassLoader() - .getResourceAsStream(_resource); + .getResourceAsStream(resource); if (stream == null) { - throw new IOException("Class path resource '" + _resource + throw new IOException("Class path resource '" + resource + "' not found."); } return stream; @@ -58,6 +58,6 @@ public class ClassPathResource implements InputResource { * @see java.lang.Object#toString() */ public String toString() { - return "ClassPathResource(" + _resource + ")"; + return "ClassPathResource(" + resource + ")"; } } diff --git a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java index 029f33ef..3f5488b0 100644 --- a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java +++ b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java @@ -45,21 +45,21 @@ public class DirectoryMonitor { void fileDeleted(File aFile); }; - private File _directory; - private FileFilter _filter; - private Listener _listener; - private Map _contents; + private File directory; + private FileFilter filter; + private Listener listener; + private Map contents; public DirectoryMonitor(File aDirectory, FileFilter aFilefilter, Listener aListener) { - _directory = aDirectory; - if (!_directory.isDirectory()) { - throw new IllegalArgumentException("Directory '" + _directory + directory = aDirectory; + if (!directory.isDirectory()) { + throw new IllegalArgumentException("Directory '" + directory + "' does not exist"); } - _filter = aFilefilter; - _listener = aListener; - _contents = new HashMap(); + filter = aFilefilter; + listener = aListener; + contents = new HashMap(); } /** @@ -68,41 +68,41 @@ public class DirectoryMonitor { * the next call to this method will invoked the listeners again for the same changes. */ public void poll() { - LOG.debug("Polling " + _directory); + LOG.debug("Polling " + directory); Map newContents = new HashMap(); - File[] files = _directory.listFiles(_filter); + File[] files = directory.listFiles(filter); // Check deleted files. - Set deletedFiles = new HashSet(_contents.keySet()); + Set deletedFiles = new HashSet(contents.keySet()); for (File file : files) { if (file.isFile()) { - if (_contents.containsKey(file)) { + if (contents.containsKey(file)) { deletedFiles.remove(file); } } } for (File file : deletedFiles) { - _listener.fileDeleted(file); + listener.fileDeleted(file); } for (File file : files) { if (file.isFile()) { - if (_contents.containsKey(file)) { - Date oldDate = _contents.get(file); + if (contents.containsKey(file)) { + Date oldDate = contents.get(file); if (file.lastModified() != oldDate.getTime()) { - _listener.fileChanged(file); + listener.fileChanged(file); } else { // No change. } newContents.put(file, new Date(file.lastModified())); } else { - _listener.fileCreated(file); + listener.fileCreated(file); newContents.put(file, new Date(file.lastModified())); } } } - _contents = newContents; + contents = newContents; } } diff --git a/support/general/src/main/java/org/wamblee/io/FileResource.java b/support/general/src/main/java/org/wamblee/io/FileResource.java index 4f8c0ad9..fd64001a 100644 --- a/support/general/src/main/java/org/wamblee/io/FileResource.java +++ b/support/general/src/main/java/org/wamblee/io/FileResource.java @@ -30,7 +30,7 @@ public class FileResource implements InputResource { /** * File to read. */ - private File _file; + private File file; /** * Constructs the resource. @@ -39,7 +39,7 @@ public class FileResource implements InputResource { * File to read. */ public FileResource(File aFile) { - _file = aFile; + file = aFile; } /* @@ -48,6 +48,6 @@ public class FileResource implements InputResource { * @see org.wamblee.io.InputResource#getInputStream() */ public InputStream getInputStream() throws IOException { - return new BufferedInputStream(new FileInputStream(_file)); + return new BufferedInputStream(new FileInputStream(file)); } } diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index d4f7b16b..74438644 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -32,30 +32,30 @@ public class SimpleProcess { private static final Log LOG = LogFactory.getLog(SimpleProcess.class); - private File _directory; + private File directory; - private String[] _cmd; + private String[] cmd; - private String _stdout; - private String _stderr; + private String stdout; + private String stderr; public SimpleProcess(File aDirectory, String[] aCmd) { - _directory = aDirectory; - _cmd = aCmd; + directory = aDirectory; + cmd = aCmd; } /** * @return the stdout */ public String getStdout() { - return _stdout; + return stdout; } /** * @return the stderr */ public String getStderr() { - return _stderr; + return stderr; } /** @@ -72,22 +72,22 @@ public class SimpleProcess { private int runImpl() throws IOException { try { String fullcmd = ""; - for (String part: _cmd) { + for (String part: cmd) { fullcmd += " " + part; } - LOG.debug("Executing '" + fullcmd + "' in directory '" + _directory + LOG.debug("Executing '" + fullcmd + "' in directory '" + directory + "'"); - java.lang.Process proc = Runtime.getRuntime().exec(_cmd, null, _directory); + java.lang.Process proc = Runtime.getRuntime().exec(cmd, null, directory); // Read standard output and error in separate threads to avoid // deadlock. - StringWriter stdout = new StringWriter(); - StringWriter stderr = new StringWriter(); + StringWriter myStdout = new StringWriter(); + StringWriter myStderr = new StringWriter(); Thread stdoutReader = readAndLogStream("STDOUT> ", proc - .getInputStream(), stdout); + .getInputStream(), myStdout); Thread stderrReader = readAndLogStream("STDERR> ", proc - .getErrorStream(), stderr); + .getErrorStream(), myStderr); try { proc.waitFor(); @@ -100,8 +100,8 @@ public class SimpleProcess { waitForReader(stdoutReader); waitForReader(stderrReader); - _stdout = stdout.toString(); - _stderr = stderr.toString(); + stdout = myStdout.toString(); + stderr = myStderr.toString(); if (proc.exitValue() != 0) { LOG.warn("Exit value was non-zero: " + this); @@ -160,9 +160,9 @@ public class SimpleProcess { @Override public String toString() { String fullcmd = ""; - for (String part: _cmd) { + for (String part: cmd) { fullcmd += part + " "; } - return "process(dir = '" + _directory + "', cmd = '" + fullcmd + "')"; + return "process(dir = '" + directory + "', cmd = '" + fullcmd + "')"; } } diff --git a/support/general/src/main/java/org/wamblee/io/StreamResource.java b/support/general/src/main/java/org/wamblee/io/StreamResource.java index e3291aeb..7df7ba20 100644 --- a/support/general/src/main/java/org/wamblee/io/StreamResource.java +++ b/support/general/src/main/java/org/wamblee/io/StreamResource.java @@ -27,7 +27,7 @@ public class StreamResource implements InputResource { /** * Input stream to read. */ - private InputStream _stream; + private InputStream stream; /** * Constructs a resource. @@ -36,7 +36,7 @@ public class StreamResource implements InputResource { * Input stream to read. */ public StreamResource(InputStream aStream) { - _stream = aStream; + stream = aStream; } /* @@ -45,6 +45,6 @@ public class StreamResource implements InputResource { * @see InputResource#getInputStream() */ public InputStream getInputStream() throws IOException { - return _stream; + return stream; } } diff --git a/support/general/src/main/java/org/wamblee/observer/Observable.java b/support/general/src/main/java/org/wamblee/observer/Observable.java index 2980afaf..820db38c 100644 --- a/support/general/src/main/java/org/wamblee/observer/Observable.java +++ b/support/general/src/main/java/org/wamblee/observer/Observable.java @@ -34,22 +34,22 @@ public class Observable { /** * Observable. */ - private ObservableType _observable; + private ObservableType observable; /** * Used to notify observers. */ - private ObserverNotifier _notifier; + private ObserverNotifier notifier; /** * Map of subscription to observer. */ - private Map> _observers; + private Map> observers; /** * Counter for subscriptions. Holds the next subscription. */ - private long _counter; + private long counter; /** * Constructs the observable. @@ -61,10 +61,10 @@ public class Observable { */ public Observable(ObservableType aObservable, ObserverNotifier aNotifier) { - _observable = aObservable; - _notifier = aNotifier; - _observers = new TreeMap>(); - _counter = 0; + observable = aObservable; + notifier = aNotifier; + observers = new TreeMap>(); + counter = 0; } /** @@ -75,9 +75,9 @@ public class Observable { * @return Event Event to send. */ public synchronized long subscribe(Observer aObserver) { - long subscription = _counter++; // integer rage is so large it will + long subscription = counter++; // integer rage is so large it will // never roll over. - _observers.put(subscription, aObserver); + observers.put(subscription, aObserver); return subscription; } @@ -90,7 +90,7 @@ public class Observable { * In case the subscription is not known. */ public synchronized void unsubscribe(long aSubscription) { - Object obj = _observers.remove(aSubscription); + Object obj = observers.remove(aSubscription); if (obj == null) { throw new IllegalArgumentException("Subscription '" + aSubscription + "'"); @@ -103,7 +103,7 @@ public class Observable { * @return Number of subscribed observers. */ public int getObserverCount() { - return _observers.size(); + return observers.size(); } /** @@ -116,12 +116,12 @@ public class Observable { // Make sure we do the notification while not holding the lock to avoid // potential deadlock // situations. - List> observers = new ArrayList>(); + List> myObservers = new ArrayList>(); synchronized (this) { - observers.addAll(_observers.values()); + myObservers.addAll(observers.values()); } - for (Observer observer : observers) { - _notifier.update(observer, _observable, aEvent); + for (Observer observer : myObservers) { + notifier.update(observer, observable, aEvent); } } @@ -132,10 +132,10 @@ public class Observable { */ @Override protected void finalize() throws Throwable { - if (_observers.size() > 0) { + if (observers.size() > 0) { LOGGER .error("Still observers registered at finalization of observer!"); - for (Observer observer : _observers.values()) { + for (Observer observer : observers.values()) { LOGGER.error(" observer: " + observer); } } diff --git a/support/general/src/main/java/org/wamblee/persistence/AbstractPersistent.java b/support/general/src/main/java/org/wamblee/persistence/AbstractPersistent.java index 4eee3a02..c4b63c3f 100644 --- a/support/general/src/main/java/org/wamblee/persistence/AbstractPersistent.java +++ b/support/general/src/main/java/org/wamblee/persistence/AbstractPersistent.java @@ -28,20 +28,20 @@ public abstract class AbstractPersistent implements Persistent { /** * Primary key. */ - private Serializable _primaryKey; + private Serializable primaryKey; /** * Version. */ - private int _version; + private int version; /** * Constructs the object. * */ protected AbstractPersistent() { - _primaryKey = null; - _version = -1; + primaryKey = null; + version = -1; } /** @@ -49,35 +49,35 @@ public abstract class AbstractPersistent implements Persistent { * @param aPersistent Object to copy. */ protected AbstractPersistent(AbstractPersistent aPersistent) { - _primaryKey = aPersistent._primaryKey; - _version = aPersistent._version; + primaryKey = aPersistent.primaryKey; + version = aPersistent.version; } /* (non-Javadoc) * @see org.wamblee.persistence.Persistent#getPrimaryKey() */ public Serializable getPrimaryKey() { - return _primaryKey; + return primaryKey; } /* (non-Javadoc) * @see org.wamblee.persistence.Persistent#setPrimaryKey(java.io.Serializable) */ public void setPrimaryKey(Serializable aKey) { - _primaryKey = aKey; + primaryKey = aKey; } /* (non-Javadoc) * @see org.wamblee.persistence.Persistent#getPersistedVersion() */ public int getPersistedVersion() { - return _version; + return version; } /* (non-Javadoc) * @see org.wamblee.persistence.Persistent#setPersistedVersion(int) */ public void setPersistedVersion(int aVersion) { - _version = aVersion; + version = aVersion; } } diff --git a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java index fb3d3052..0e9ffee4 100644 --- a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java +++ b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java @@ -43,7 +43,7 @@ import org.wamblee.io.FileResource; */ public class XslTransformer { - private TransformerFactory _factory; + private TransformerFactory factory; /** * Constructs the URL resolver. @@ -52,8 +52,8 @@ public class XslTransformer { * URI resolver to use. */ public XslTransformer(URIResolver aResolver) { - _factory = TransformerFactory.newInstance(); - _factory.setURIResolver(aResolver); + factory = TransformerFactory.newInstance(); + factory.setURIResolver(aResolver); } /** @@ -61,7 +61,7 @@ public class XslTransformer { * */ public XslTransformer() { - _factory = TransformerFactory.newInstance(); + factory = TransformerFactory.newInstance(); } /** @@ -71,7 +71,7 @@ public class XslTransformer { * @throws TransformerException In case the XSLT cannot be found. */ public Source resolve(String aXslt) throws TransformerException { - URIResolver resolver = _factory.getURIResolver(); + URIResolver resolver = factory.getURIResolver(); if (resolver == null) { if (new File(aXslt).canRead()) { try { @@ -166,7 +166,7 @@ public class XslTransformer { public void transform(Source aSource, Result aResult, Source aXslt) throws IOException, TransformerException { try { - Transformer transformer = _factory.newTransformer(aXslt); + Transformer transformer = factory.newTransformer(aXslt); transformer.transform(aSource, aResult); } catch (TransformerConfigurationException e) { throw new TransformerException( diff --git a/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java b/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java index da6e1be6..70d1b7af 100644 --- a/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java +++ b/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java @@ -38,8 +38,8 @@ public class CachedObjectTest extends TestCase { private static final int OBJECT_KEY = 10; - private CachedObject.Computation _computation; - private int _ncomputations; + private CachedObject.Computation computation; + private int ncomputations; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() @@ -47,13 +47,13 @@ public class CachedObjectTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - _computation = new CachedObject.Computation() { + computation = new CachedObject.Computation() { public Integer getObject(Integer aObjectKey) { - _ncomputations++; + ncomputations++; return compute(aObjectKey); }; }; - _ncomputations = 0; + ncomputations = 0; } private int compute(int aValue) { @@ -61,7 +61,7 @@ public class CachedObjectTest extends TestCase { } private CachedObject createCached(Cache aCache) { - return new CachedObject(aCache, OBJECT_KEY, _computation); + return new CachedObject(aCache, OBJECT_KEY, computation); } /** @@ -73,18 +73,18 @@ public class CachedObjectTest extends TestCase { CachedObject cached = createCached(new ZeroCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); } public void testInvalidateCache() { CachedObject cached = createCached(new ForeverCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); cached.invalidate(); value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(2, _ncomputations); + assertEquals(2, ncomputations); } public void testBehaviorEhCache() throws CacheException, IOException { @@ -94,28 +94,28 @@ public class CachedObjectTest extends TestCase { assertTrue( cache == cached.getCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); // The value must still be cached. value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); // Cache expiry. TimingUtils.sleep(6000); value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(2, _ncomputations); + assertEquals(2, ncomputations); // Should still be cached now. value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(2, _ncomputations); + assertEquals(2, ncomputations); // explicit invalidation. cached.invalidate(); value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(3, _ncomputations); + assertEquals(3, ncomputations); } @@ -126,22 +126,22 @@ public class CachedObjectTest extends TestCase { assertTrue( cache == cached.getCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); // The value must still be cached. value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); // Cache expiry. TimingUtils.sleep(6000); value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(2, _ncomputations); + assertEquals(2, ncomputations); // Should still be cached now. value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(2, _ncomputations); + assertEquals(2, ncomputations); } @@ -150,11 +150,11 @@ public class CachedObjectTest extends TestCase { CachedObject cached = createCached(new ForeverCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); for (int ncomp = 2; ncomp <= 100; ncomp++) { value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); } } @@ -162,15 +162,15 @@ public class CachedObjectTest extends TestCase { CachedObject cached = createCached(new ZeroCache()); int value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(1, _ncomputations); + assertEquals(1, ncomputations); for (int ncomp = 2; ncomp <= 100; ncomp++) { value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(ncomp, _ncomputations); + assertEquals(ncomp, ncomputations); } cached.invalidate(); value = cached.get(); assertEquals(compute(OBJECT_KEY), value); - assertEquals(101, _ncomputations); + assertEquals(101, ncomputations); } } diff --git a/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java b/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java index 39cec11a..6c9df461 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java +++ b/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java @@ -36,7 +36,7 @@ public abstract class AbstractLockTestCase extends TestCase { protected static final String RELEASED = "released"; - private EventTracker _tracker; + private EventTracker tracker; /* * (non-Javadoc) @@ -45,11 +45,11 @@ public abstract class AbstractLockTestCase extends TestCase { */ @Override protected void setUp() throws Exception { - _tracker = new EventTracker(); + tracker = new EventTracker(); } protected EventTracker getTracker() { - return _tracker; + return tracker; } /** @@ -69,21 +69,21 @@ public abstract class AbstractLockTestCase extends TestCase { Thread t2 = runThread(); TimingUtils.sleep(SLEEP_TIME / 10); // give threads a chance to start // up. - assertEquals(2, _tracker.getEventCount(STARTED)); // both threads + assertEquals(2, tracker.getEventCount(STARTED)); // both threads // should have // started. - assertEquals(1, _tracker.getEventCount(ACQUIRED)); // one thread has + assertEquals(1, tracker.getEventCount(ACQUIRED)); // one thread has // acquired the // lock. TimingUtils.sleep(SLEEP_TIME); - assertEquals(2, _tracker.getEventCount(ACQUIRED)); // now the other + assertEquals(2, tracker.getEventCount(ACQUIRED)); // now the other // thread could also // acquire the lock - assertEquals(1, _tracker.getEventCount(RELEASED)); // and the first + assertEquals(1, tracker.getEventCount(RELEASED)); // and the first // thread has // released it. TimingUtils.sleep(SLEEP_TIME); - assertEquals(2, _tracker.getEventCount(RELEASED)); // both threads + assertEquals(2, tracker.getEventCount(RELEASED)); // both threads // should be // finished. t1.join(); diff --git a/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java index e14ca9ba..8475f198 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java @@ -25,7 +25,7 @@ import org.wamblee.test.TimingUtils; */ public class JvmLockTest extends AbstractLockTestCase { - private JvmLock _lock; + private JvmLock lock; /* * (non-Javadoc) @@ -35,17 +35,17 @@ public class JvmLockTest extends AbstractLockTestCase { @Override protected void setUp() throws Exception { super.setUp(); - _lock = new JvmLock(); + lock = new JvmLock(); } protected Thread runThread() { Thread t = new Thread(new Runnable() { public void run() { getTracker().eventOccurred(STARTED); - _lock.acquire(); + lock.acquire(); getTracker().eventOccurred(ACQUIRED); TimingUtils.sleep(SLEEP_TIME); - _lock.release(); + lock.release(); getTracker().eventOccurred(RELEASED); }; }); diff --git a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java index 40302f76..e0d22f77 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java @@ -38,9 +38,9 @@ public class ReadWriteLockTest extends TestCase { * */ private static final int TWO_SECONDS = 2000; - private ReadWriteLock _lock; - private int _nReaders; - private int _nWriters; + private ReadWriteLock lock; + private int nReaders; + private int nWriters; /** * Constructor for ReadWriteLockTest. @@ -52,27 +52,27 @@ public class ReadWriteLockTest extends TestCase { } private synchronized int getReaderCount() { - return _nReaders; + return nReaders; } private synchronized int getWriterCount() { - return _nWriters; + return nWriters; } synchronized void incrementReaderCount() { - _nReaders++; + nReaders++; } synchronized void incrementWriterCount() { - _nWriters++; + nWriters++; } synchronized void decrementReaderCount() { - _nReaders--; + nReaders--; } synchronized void decrementWriterCount() { - _nWriters--; + nWriters--; } /* @@ -80,14 +80,14 @@ public class ReadWriteLockTest extends TestCase { */ protected void setUp() throws Exception { super.setUp(); - _lock = new ReadWriteLock(); + lock = new ReadWriteLock(); } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { - _lock = null; + lock = null; super.tearDown(); } @@ -95,16 +95,16 @@ public class ReadWriteLockTest extends TestCase { * Acquire and release a read lock. */ public void testRead() { - _lock.acquireRead(); - _lock.releaseRead(); + lock.acquireRead(); + lock.releaseRead(); } /** * Acquire and release a write lock. */ public void testWrite() { - _lock.acquireWrite(); - _lock.releaseWrite(); + lock.acquireWrite(); + lock.releaseWrite(); } /** @@ -113,7 +113,7 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testMultipleReaders() throws InterruptedException { - Runnable runnable = new ReadLocker(_lock, this, TWO_SECONDS); + Runnable runnable = new ReadLocker(lock, this, TWO_SECONDS); Thread t1 = new Thread(runnable); t1.start(); @@ -132,7 +132,7 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testSingleWriter() throws InterruptedException { - WriteLocker writer = new WriteLocker(_lock, this, ONE_SECOND); + WriteLocker writer = new WriteLocker(lock, this, ONE_SECOND); Thread t1 = new Thread(writer); Thread t2 = new Thread(writer); @@ -151,8 +151,8 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testMultipleWriters() throws InterruptedException { - WriteLocker writer1 = new WriteLocker(_lock, this, HALF_SECOND + ONE_SECOND); - WriteLocker writer2 = new WriteLocker(_lock, this, ONE_SECOND); + WriteLocker writer1 = new WriteLocker(lock, this, HALF_SECOND + ONE_SECOND); + WriteLocker writer2 = new WriteLocker(lock, this, ONE_SECOND); Thread t1 = new Thread(writer1); Thread t2 = new Thread(writer2); @@ -180,9 +180,9 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testReadWrite1() throws InterruptedException { - ReadLocker readLocker = new ReadLocker(_lock, this, TWO_SECONDS); + ReadLocker readLocker = new ReadLocker(lock, this, TWO_SECONDS); Thread t1 = new Thread(readLocker); - WriteLocker writeLocker = new WriteLocker(_lock, this, TWO_SECONDS); + WriteLocker writeLocker = new WriteLocker(lock, this, TWO_SECONDS); Thread t2 = new Thread(writeLocker); t1.start(); // acquire read lock @@ -213,11 +213,11 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testReadWrite2() throws InterruptedException { - ReadLocker readLocker1 = new ReadLocker(_lock, this, TWO_SECONDS + HALF_SECOND); - ReadLocker readLocker2 = new ReadLocker(_lock, this, TWO_SECONDS + HALF_SECOND); + ReadLocker readLocker1 = new ReadLocker(lock, this, TWO_SECONDS + HALF_SECOND); + ReadLocker readLocker2 = new ReadLocker(lock, this, TWO_SECONDS + HALF_SECOND); Thread t1 = new Thread(readLocker1); Thread t2 = new Thread(readLocker2); - WriteLocker writeLocker = new WriteLocker(_lock, this, TWO_SECONDS); + WriteLocker writeLocker = new WriteLocker(lock, this, TWO_SECONDS); Thread t3 = new Thread(writeLocker); t1.start(); // acquire read lock [0, 2.5] @@ -259,9 +259,9 @@ public class ReadWriteLockTest extends TestCase { * @throws InterruptedException May not occur. */ public void testReadWrite3() throws InterruptedException { - ReadLocker readLocker = new ReadLocker(_lock, this, TWO_SECONDS); + ReadLocker readLocker = new ReadLocker(lock, this, TWO_SECONDS); Thread t1 = new Thread(readLocker); - WriteLocker writeLocker = new WriteLocker(_lock, this, TWO_SECONDS); + WriteLocker writeLocker = new WriteLocker(lock, this, TWO_SECONDS); Thread t2 = new Thread(writeLocker); t2.start(); // acquire write lock @@ -306,12 +306,12 @@ public class ReadWriteLockTest extends TestCase { try { t1 = new Thread(new Runnable() { public void run() { - ReadWriteLockTest.this._lock.acquireRead(); + ReadWriteLockTest.this.lock.acquireRead(); } }); t1.start(); Thread.sleep(ONE_SECOND); // wait until thread is started - _lock.releaseRead(); // release lock from wrong thread. + lock.releaseRead(); // release lock from wrong thread. } catch (RuntimeException e) { return; // ok } finally { @@ -333,12 +333,12 @@ public class ReadWriteLockTest extends TestCase { try { t1 = new Thread(new Runnable() { public void run() { - ReadWriteLockTest.this._lock.acquireWrite(); + ReadWriteLockTest.this.lock.acquireWrite(); } }); t1.start(); Thread.sleep(ONE_SECOND); // wait until thread is started - _lock.releaseWrite(); // release lock from wrong thread. + lock.releaseWrite(); // release lock from wrong thread. } catch (RuntimeException e) { return; // ok } finally { @@ -354,8 +354,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireReadTwice() { try { - _lock.acquireRead(); - _lock.acquireRead(); + lock.acquireRead(); + lock.acquireRead(); } catch (RuntimeException e) { // ok return; @@ -370,8 +370,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireWriteTwice() { try { - _lock.acquireWrite(); - _lock.acquireWrite(); + lock.acquireWrite(); + lock.acquireWrite(); } catch (RuntimeException e) { return; // ok } @@ -385,8 +385,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireReadFollowedByWrite() { try { - _lock.acquireRead(); - _lock.acquireWrite(); + lock.acquireRead(); + lock.acquireWrite(); } catch (RuntimeException e) { return; // ok } @@ -400,8 +400,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireWriteFollowedByRead() { try { - _lock.acquireWrite(); - _lock.acquireRead(); + lock.acquireWrite(); + lock.acquireRead(); } catch (RuntimeException e) { return; // ok } @@ -415,8 +415,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireReadFollowedByReleaseaWrite() { try { - _lock.acquireRead(); - _lock.releaseWrite(); + lock.acquireRead(); + lock.releaseWrite(); } catch (RuntimeException e) { return; // ok } @@ -430,8 +430,8 @@ public class ReadWriteLockTest extends TestCase { */ public void testAcquireWriteFollowedByReleaseRead() { try { - _lock.acquireWrite(); - _lock.releaseRead(); + lock.acquireWrite(); + lock.releaseRead(); } catch (RuntimeException e) { return; // ok } @@ -447,30 +447,30 @@ public class ReadWriteLockTest extends TestCase { * lock, and performs a callback after the lock has been released. */ class ReadLocker implements Runnable { - private ReadWriteLock _lock; - private ReadWriteLockTest _lockTest; - private int _sleepTime; + private ReadWriteLock lock; + private ReadWriteLockTest lockTest; + private int sleepTime; public ReadLocker(ReadWriteLock aLock, ReadWriteLockTest aLockTest, int aSleepTime) { - _lock = aLock; - _lockTest = aLockTest; - _sleepTime = aSleepTime; + lock = aLock; + lockTest = aLockTest; + sleepTime = aSleepTime; } public void run() { - _lock.acquireRead(); - _lockTest.incrementReaderCount(); + lock.acquireRead(); + lockTest.incrementReaderCount(); try { - Thread.sleep(_sleepTime); + Thread.sleep(sleepTime); } catch (InterruptedException e) { Assert.fail("ReadLocker thread was interrupted." + Thread.currentThread()); } - _lock.releaseRead(); - _lockTest.decrementReaderCount(); + lock.releaseRead(); + lockTest.decrementReaderCount(); } } @@ -481,29 +481,29 @@ class ReadLocker implements Runnable { * lock, and performs a callback after the lock has been released. */ class WriteLocker implements Runnable { - private ReadWriteLock _lock; - private ReadWriteLockTest _lockTest; - private int _sleepTime; + private ReadWriteLock lock; + private ReadWriteLockTest lockTest; + private int sleepTime; public WriteLocker(ReadWriteLock aLock, ReadWriteLockTest aLockTest, int aSleepTime) { - _lock = aLock; - _lockTest = aLockTest; - _sleepTime = aSleepTime; + lock = aLock; + lockTest = aLockTest; + sleepTime = aSleepTime; } public void run() { - _lock.acquireWrite(); - _lockTest.incrementWriterCount(); + lock.acquireWrite(); + lockTest.incrementWriterCount(); try { - Thread.sleep(_sleepTime); + Thread.sleep(sleepTime); } catch (InterruptedException e) { Assert.fail("WriteLocker thread was interrupted: " + Thread.currentThread()); } - _lock.releaseWrite(); - _lockTest.decrementWriterCount(); + lock.releaseWrite(); + lockTest.decrementWriterCount(); } } diff --git a/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java b/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java index bdb95897..decdb53b 100644 --- a/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java +++ b/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java @@ -23,17 +23,17 @@ package org.wamblee.conditions; */ public class GreaterThanCondition implements Condition { - private int _value; + private int value; public GreaterThanCondition(int aValue) { - _value = aValue; + value = aValue; } /* (non-Javadoc) * @see org.wamblee.conditions.Condition#matches(T) */ public boolean matches(Integer aObject) { - return aObject > _value; + return aObject > value; } } diff --git a/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java b/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java index 06ab192a..4f8e419c 100644 --- a/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java +++ b/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java @@ -23,17 +23,17 @@ package org.wamblee.conditions; */ public class LessThanCondition implements Condition { - private int _value; + private int value; public LessThanCondition(int aValue) { - _value = aValue; + value = aValue; } /* (non-Javadoc) * @see org.wamblee.conditions.Condition#matches(T) */ public boolean matches(Integer aObject) { - return aObject < _value; + return aObject < value; } } diff --git a/support/general/src/test/java/org/wamblee/conditions/TestBean.java b/support/general/src/test/java/org/wamblee/conditions/TestBean.java index 7bcd6d20..24c26dea 100644 --- a/support/general/src/test/java/org/wamblee/conditions/TestBean.java +++ b/support/general/src/test/java/org/wamblee/conditions/TestBean.java @@ -23,17 +23,17 @@ package org.wamblee.conditions; */ public class TestBean { - private String _value; + private String value; public TestBean(String aValue) { - _value = aValue; + value = aValue; } public String getValue() { - return _value; + return value; } private String getPrivateValue() { - return _value; + return value; } } diff --git a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java index 12db916e..e0048c08 100644 --- a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java +++ b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java @@ -25,94 +25,94 @@ public class DirectoryMonitorTest extends TestCase { private static final String REGEX = "^.*\\.txt$"; private static final String FILE1 = "file1.txt"; - private TestData _data; - private DirectoryMonitor.Listener _listener; + private TestData data; + private DirectoryMonitor.Listener listener; - private DirectoryMonitor _monitor; + private DirectoryMonitor monitor; @Override protected void setUp() throws Exception { super.setUp(); - _data = new TestData(this); - _data.clean(); - _listener = mock(DirectoryMonitor.Listener.class); - _monitor = new DirectoryMonitor(_data.getRoot(), new AwkFilenameFilter( - REGEX), _listener); + data = new TestData(this); + data.clean(); + listener = mock(DirectoryMonitor.Listener.class); + monitor = new DirectoryMonitor(data.getRoot(), new AwkFilenameFilter( + REGEX), listener); } public void testEmptyDir() { // Nothing is expected to be called. for (int i = 0; i < 10; i++) { - _monitor.poll(); - verifyNoMoreInteractions(_listener); + monitor.poll(); + verifyNoMoreInteractions(listener); } } public void testFileCreated() { - _data.createFile(FILE1, "hello"); - _monitor.poll(); - verify(_listener).fileCreated(_data.getFile(FILE1)); + data.createFile(FILE1, "hello"); + monitor.poll(); + verify(listener).fileCreated(data.getFile(FILE1)); } public void testFileDeleted() { - _data.createFile(FILE1, "hello"); - _monitor.poll(); - reset(_listener); + data.createFile(FILE1, "hello"); + monitor.poll(); + reset(listener); - _data.deleteFile(FILE1); - _monitor.poll(); + data.deleteFile(FILE1); + monitor.poll(); - verify(_listener).fileDeleted(_data.getFile(FILE1)); - verifyNoMoreInteractions(_listener); + verify(listener).fileDeleted(data.getFile(FILE1)); + verifyNoMoreInteractions(listener); } public void testFileChanged() throws InterruptedException { - _data.createFile(FILE1, "hello"); - _monitor.poll(); - reset(_listener); + data.createFile(FILE1, "hello"); + monitor.poll(); + reset(listener); Thread.sleep(2000); - _data.deleteFile(FILE1); - _data.createFile(FILE1, "bla"); + data.deleteFile(FILE1); + data.createFile(FILE1, "bla"); - _monitor.poll(); - verify(_listener).fileChanged(_data.getFile(FILE1)); - verifyNoMoreInteractions(_listener); + monitor.poll(); + verify(listener).fileChanged(data.getFile(FILE1)); + verifyNoMoreInteractions(listener); } public void testFileFilterIsUsed() { - _monitor.poll(); + monitor.poll(); - _data.createFile("file.xml", "hello"); - _monitor.poll(); - verifyNoMoreInteractions(_listener); + data.createFile("file.xml", "hello"); + monitor.poll(); + verifyNoMoreInteractions(listener); } public void testDirectoryIsIgnored() { - _monitor.poll(); - _data.createDir(FILE1); - _monitor.poll(); - verifyNoMoreInteractions(_listener); + monitor.poll(); + data.createDir(FILE1); + monitor.poll(); + verifyNoMoreInteractions(listener); } public void testExceptionsWIllLeadToRepeatedNotifications() { - _monitor.poll(); - _data.createFile(FILE1, "hello"); + monitor.poll(); + data.createFile(FILE1, "hello"); - stubVoid(_listener).toThrow(new RuntimeException()).on(). - fileCreated(_data.getFile(FILE1)); + stubVoid(listener).toThrow(new RuntimeException()).on(). + fileCreated(data.getFile(FILE1)); try { - _monitor.poll(); + monitor.poll(); } catch (RuntimeException e) { - reset(_listener); + reset(listener); // polling again should lead to the same filecreated call. // this time no exception is thrown. - _monitor.poll(); - verify(_listener).fileCreated(_data.getFile(FILE1)); - verifyNoMoreInteractions(_listener); + monitor.poll(); + verify(listener).fileCreated(data.getFile(FILE1)); + verifyNoMoreInteractions(listener); return; } fail(); // should not get here. diff --git a/support/general/src/test/java/org/wamblee/io/TestData.java b/support/general/src/test/java/org/wamblee/io/TestData.java index 58bea68e..1418f6b1 100644 --- a/support/general/src/test/java/org/wamblee/io/TestData.java +++ b/support/general/src/test/java/org/wamblee/io/TestData.java @@ -34,8 +34,8 @@ import junit.framework.Assert; */ public final class TestData { - private Object _testcase; - private File _root; + private Object testcase; + private File root; /** * Test data to be constructed in the setUp of a test. {@link #clean()} must @@ -43,9 +43,9 @@ public final class TestData { * test. */ public TestData(Object aTestcase) { - _testcase = aTestcase; - _root = getTestRootDir(aTestcase); - FileSystemUtils.createDir(_root); + testcase = aTestcase; + root = getTestRootDir(aTestcase); + FileSystemUtils.createDir(root); } /** @@ -59,7 +59,7 @@ public final class TestData { public void createFile(String aRelative, String aFile, InputStream aContents) { FileSystemUtils - .createFile(new File(_root, aRelative), aFile, aContents); + .createFile(new File(root, aRelative), aFile, aContents); } public void createFile(String aFile, String aContents) { @@ -68,7 +68,7 @@ public final class TestData { public void createFile(String aRelative, String aFile, String aContents) { InputStream is = new ByteArrayInputStream(aContents.getBytes()); - FileSystemUtils.createFile(new File(_root, aRelative), aFile, is); + FileSystemUtils.createFile(new File(root, aRelative), aFile, is); } public void deleteFile(String aFile) { @@ -76,7 +76,7 @@ public final class TestData { } public void deleteFile(String aRelative, String aFile) { - FileSystemUtils.delete(new File(_root, aFile)); + FileSystemUtils.delete(new File(root, aFile)); } /** @@ -85,15 +85,15 @@ public final class TestData { * @return Temporary directory. */ public File getTmpDir() { - return new File(_root, "tmpdir"); + return new File(root, "tmpdir"); } /** * Cleans up the test output directory. */ public void clean() { - FileSystemUtils.deleteDirRecursively(_root); - FileSystemUtils.createDir(_root); + FileSystemUtils.deleteDirRecursively(root); + FileSystemUtils.createDir(root); } /** @@ -103,7 +103,7 @@ public final class TestData { * Source directory to copy. */ public void copyDir(File aSrc) { - FileSystemUtils.copyDir(aSrc, _root); + FileSystemUtils.copyDir(aSrc, root); } /** @@ -118,7 +118,7 @@ public final class TestData { public void copyResource(String aResource, String aRelativePath) { try { InputStream is = new ClassPathResource(aResource).getInputStream(); - FileOutputStream fos = new FileOutputStream(new File(_root, + FileOutputStream fos = new FileOutputStream(new File(root, aRelativePath)); FileSystemUtils.copyStream(is, fos); } catch (IOException e) { @@ -139,7 +139,7 @@ public final class TestData { } public void createDir(String aRelative) { - FileSystemUtils.createDir(new File(_root, aRelative)); + FileSystemUtils.createDir(new File(root, aRelative)); } /** @@ -150,7 +150,7 @@ public final class TestData { * cannot be removed. */ public void delete(String aRelative) { - FileSystemUtils.delete(new File(_root, aRelative)); + FileSystemUtils.delete(new File(root, aRelative)); } /** @@ -160,7 +160,7 @@ public final class TestData { * Relative path. */ public void deleteDir(String aRelative) { - FileSystemUtils.deleteDir(new File(_root, aRelative)); + FileSystemUtils.deleteDir(new File(root, aRelative)); } /** @@ -170,7 +170,7 @@ public final class TestData { * Relative path. */ public void deleteDirRecursively(String aRelative) { - FileSystemUtils.deleteDir(new File(_root, aRelative)); + FileSystemUtils.deleteDir(new File(root, aRelative)); } /** @@ -179,13 +179,13 @@ public final class TestData { * @return Root of the test output. */ public File getRoot() { - return _root; + return root; } /** * Gets a file object for a relative path. */ public File getFile(String aRelative) { - return new File(_root, aRelative); + return new File(root, aRelative); } } diff --git a/support/general/src/test/java/org/wamblee/observer/ObservableTest.java b/support/general/src/test/java/org/wamblee/observer/ObservableTest.java index 8a060e89..e26571a4 100644 --- a/support/general/src/test/java/org/wamblee/observer/ObservableTest.java +++ b/support/general/src/test/java/org/wamblee/observer/ObservableTest.java @@ -36,8 +36,8 @@ public class ObservableTest extends TestCase { private static final String UPDATE = "send"; - private Integer _observed; - private Observable _observable; + private Integer observed; + private Observable observable; /* * (non-Javadoc) @@ -47,8 +47,8 @@ public class ObservableTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - _observed = new Integer(1); - _observable = new Observable(_observed, + observed = new Integer(1); + observable = new Observable(observed, new DefaultObserverNotifier()); } @@ -59,20 +59,20 @@ public class ObservableTest extends TestCase { final Observer mockObserver = mock(Observer.class); InOrder order = inOrder(mockObserver); - long subscription = _observable.subscribe(mockObserver); + long subscription = observable.subscribe(mockObserver); - assertEquals(1, _observable.getObserverCount()); + assertEquals(1, observable.getObserverCount()); final String message = "hallo"; - _observable.send(message); + observable.send(message); - order.verify(mockObserver).send(_observed, message); + order.verify(mockObserver).send(observed, message); verifyNoMoreInteractions(mockObserver); - _observable.unsubscribe(subscription); - assertEquals(0, _observable.getObserverCount()); + observable.unsubscribe(subscription); + assertEquals(0, observable.getObserverCount()); - _observable.send(message); + observable.send(message); verifyNoMoreInteractions(mockObserver); } @@ -90,30 +90,30 @@ public class ObservableTest extends TestCase { for (int i = 0; i < nsubscribers; i++) { mocks[i] = mock(Observer.class); order[i] = inOrder(mocks[i]); - long subscription = _observable.subscribe(mocks[i]); + long subscription = observable.subscribe(mocks[i]); assertTrue(subscriptions.add(subscription)); } - assertEquals(nsubscribers, _observable.getObserverCount()); + assertEquals(nsubscribers, observable.getObserverCount()); final String message = "hallo"; - _observable.send(message); + observable.send(message); for (int i = 0; i < nsubscribers; i++) { - order[i].verify(mocks[i]).send(_observed, message); + order[i].verify(mocks[i]).send(observed, message); } for (int i = nsubscribers / 2; i < nsubscribers; i++) { - _observable.unsubscribe(subscriptions.get(i)); + observable.unsubscribe(subscriptions.get(i)); } assertEquals(nsubscribers - (nsubscribers - nsubscribers / 2), - _observable.getObserverCount()); + observable.getObserverCount()); final String message2 = "blabla"; - _observable.send(message2); + observable.send(message2); for (int i = 0; i < nsubscribers / 2; i++) { - order[i].verify(mocks[i]).send(_observed, message2); + order[i].verify(mocks[i]).send(observed, message2); } for (int i = nsubscribers/2; i < nsubscribers; i++) { verifyNoMoreInteractions(mocks[i]); @@ -129,12 +129,12 @@ public class ObservableTest extends TestCase { public void testUnsubscribeWithWrongSubscription() { Observer observer = mock(Observer.class); - long subscription = _observable.subscribe(observer); + long subscription = observable.subscribe(observer); - assertEquals(1, _observable.getObserverCount()); + assertEquals(1, observable.getObserverCount()); try { - _observable.unsubscribe(subscription + 1); + observable.unsubscribe(subscription + 1); } catch (IllegalArgumentException e) { return; // ok } diff --git a/support/general/src/test/java/org/wamblee/test/EventTracker.java b/support/general/src/test/java/org/wamblee/test/EventTracker.java index 333da1e7..9e9c472d 100644 --- a/support/general/src/test/java/org/wamblee/test/EventTracker.java +++ b/support/general/src/test/java/org/wamblee/test/EventTracker.java @@ -47,7 +47,7 @@ public class EventTracker { /** * Map of Thread object to a list of events. */ - private Map> _events; + private Map> events; /** * Constructs the event tracker. @@ -58,7 +58,7 @@ public class EventTracker { } public void clear() { - _events = new HashMap>(); + events = new HashMap>(); } /** @@ -70,12 +70,12 @@ public class EventTracker { public synchronized void eventOccurred(Event aEvent) { LOG.info("Event '" + aEvent + "' sent."); Thread current = Thread.currentThread(); - List events = _events.get(current); - if (events == null) { - events = new ArrayList(); - _events.put(current, events); + List eventList = events.get(current); + if (eventList == null) { + eventList = new ArrayList(); + events.put(current, eventList); } - events.add(aEvent); + eventList.add(aEvent); } /** @@ -88,11 +88,11 @@ public class EventTracker { * @return Whether or not the event was sent. */ public synchronized boolean isEventSent(Thread aThread, Event aEvent) { - List events = _events.get(aThread); - if (events == null) { + List eventList = events.get(aThread); + if (eventList == null) { return false; } - return events.contains(aEvent); + return eventList.contains(aEvent); } /** @@ -104,11 +104,11 @@ public class EventTracker { * events were sent. */ public synchronized List getEvents(Thread aThread) { - List events = _events.get(aThread); - if (events == null) { - events = Collections.emptyList(); + List eventList = events.get(aThread); + if (eventList == null) { + eventList = Collections.emptyList(); } - return Collections.unmodifiableList(events); + return Collections.unmodifiableList(eventList); } /** @@ -121,9 +121,9 @@ public class EventTracker { */ public synchronized int getEventCount(Event aEvent) { int count = 0; - for (Thread thread : _events.keySet()) { - List events = _events.get(thread); - for (Event event : events) { + for (Thread thread : events.keySet()) { + List eventList = events.get(thread); + for (Event event : eventList) { if (event.equals(aEvent)) { count++; } @@ -138,8 +138,8 @@ public class EventTracker { */ public synchronized int getEventCount() { int count = 0; - for (Thread thread: _events.keySet()) { - count += _events.get(thread).size(); + for (Thread thread: events.keySet()) { + count += events.get(thread).size(); } return count; } diff --git a/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java b/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java index 39280c60..bd8dddd4 100644 --- a/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java +++ b/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java @@ -36,14 +36,14 @@ import org.wamblee.io.FileSystemUtils; */ public class ClasspathUriResolverTest extends TestCase { - private URIResolver _resolver; + private URIResolver resolver; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @Override protected void setUp() throws Exception { - _resolver = new ClasspathUriResolver(); + resolver = new ClasspathUriResolver(); } /** @@ -52,7 +52,7 @@ public class ClasspathUriResolverTest extends TestCase { * @throws IOException */ public void testResolveExistingFile() throws TransformerException, IOException { - Source source = _resolver.resolve("org/wamblee/xml/reportToHtml.xsl", ""); + Source source = resolver.resolve("org/wamblee/xml/reportToHtml.xsl", ""); assertTrue(source instanceof StreamSource); String resolved = FileSystemUtils.read(((StreamSource)source).getInputStream()); @@ -67,7 +67,7 @@ public class ClasspathUriResolverTest extends TestCase { */ public void testResolveNonExistingFile() { try { - Source source = _resolver.resolve("org/wamblee/xml/reportToHtml-nonexisting.xsl", ""); + Source source = resolver.resolve("org/wamblee/xml/reportToHtml-nonexisting.xsl", ""); } catch (TransformerException e) { return; // ok } diff --git a/support/spring/src/main/java/org/wamblee/concurrency/spring/LockAdvice.java b/support/spring/src/main/java/org/wamblee/concurrency/spring/LockAdvice.java index 61bd98ae..a20a9f65 100644 --- a/support/spring/src/main/java/org/wamblee/concurrency/spring/LockAdvice.java +++ b/support/spring/src/main/java/org/wamblee/concurrency/spring/LockAdvice.java @@ -30,25 +30,25 @@ public class LockAdvice implements MethodInterceptor { /** * Lock to use. */ - private Lock _lock; + private Lock lock; /** * Constructs lock advice. * @param aLock Lock to use. */ public LockAdvice(Lock aLock) { - _lock = aLock; + lock = aLock; } /* (non-Javadoc) * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ public Object invoke(MethodInvocation aInvocation) throws Throwable { - _lock.acquire(); + lock.acquire(); try { return aInvocation.proceed(); } finally { - _lock.release(); + lock.release(); } } diff --git a/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java b/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java index e01f0865..56efedc3 100644 --- a/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java +++ b/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java @@ -31,7 +31,7 @@ import org.wamblee.general.BeanKernel; */ public class SpringBeanFactory implements BeanFactory { - private BeanFactoryReference _factoryReference; + private BeanFactoryReference factoryReference; /** * Constructs the bean factory. @@ -45,7 +45,7 @@ public class SpringBeanFactory implements BeanFactory { try { BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator .getInstance(aSelector); - _factoryReference = locator.useBeanFactory(aFactoryName); + factoryReference = locator.useBeanFactory(aFactoryName); } catch (BeansException e) { throw new BeanFactoryException( "Could not load bean factory: selector = '" + aSelector @@ -79,7 +79,7 @@ public class SpringBeanFactory implements BeanFactory { */ public T find(String aId, Class aClass) { try { - Object obj = _factoryReference.getFactory().getBean(aId, aClass); + Object obj = factoryReference.getFactory().getBean(aId, aClass); assert obj != null; return aClass.cast(obj); } catch (BeansException e) { @@ -92,7 +92,7 @@ public class SpringBeanFactory implements BeanFactory { * @return Spring bean factory. */ public org.springframework.beans.factory.BeanFactory getSpringBeanFactory() { - return _factoryReference.getFactory(); + return factoryReference.getFactory(); } } diff --git a/support/spring/src/main/java/org/wamblee/persistence/hibernate/HibernateSupport.java b/support/spring/src/main/java/org/wamblee/persistence/hibernate/HibernateSupport.java index 8425facd..5012b02f 100644 --- a/support/spring/src/main/java/org/wamblee/persistence/hibernate/HibernateSupport.java +++ b/support/spring/src/main/java/org/wamblee/persistence/hibernate/HibernateSupport.java @@ -48,18 +48,18 @@ public class HibernateSupport extends HibernateDaoSupport { * */ private static final class ObjectElem { - private Object _object; + private Object object; public ObjectElem(Object aObject) { - _object = aObject; + object = aObject; } public boolean equals(Object aObj) { - return ((ObjectElem) aObj)._object == _object; + return ((ObjectElem) aObj).object == object; } public int hashCode() { - return _object.hashCode(); + return object.hashCode(); } } diff --git a/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java b/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java index b56beacd..9257f7d7 100644 --- a/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java +++ b/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java @@ -36,7 +36,7 @@ public class LockAdviceTest extends AbstractLockTestCase { } } - private Runnable _target; + private Runnable target; /* * (non-Javadoc) @@ -54,7 +54,7 @@ public class LockAdviceTest extends AbstractLockTestCase { support.setInterfaces(new Class[]{ Runnable.class }); support.setTarget(runner); support.addAdvice(advice); - _target = (Runnable)support.getObject(); + target = (Runnable)support.getObject(); } @@ -69,7 +69,7 @@ public class LockAdviceTest extends AbstractLockTestCase { public void run() { try { getTracker().eventOccurred(STARTED); - _target.run(); + target.run(); getTracker().eventOccurred(RELEASED); } catch (Throwable e) { throw new RuntimeException(e); diff --git a/support/spring/src/test/java/org/wamblee/test/spring/TestSpringBeanFactory.java b/support/spring/src/test/java/org/wamblee/test/spring/TestSpringBeanFactory.java index a7cc6fe6..d604e166 100644 --- a/support/spring/src/test/java/org/wamblee/test/spring/TestSpringBeanFactory.java +++ b/support/spring/src/test/java/org/wamblee/test/spring/TestSpringBeanFactory.java @@ -27,10 +27,10 @@ import org.wamblee.general.BeanFactoryException; */ public class TestSpringBeanFactory implements BeanFactory { - private ApplicationContext _context; + private ApplicationContext context; public TestSpringBeanFactory(ApplicationContext aContext) { - _context = aContext; + context = aContext; } /* (non-Javadoc) @@ -52,7 +52,7 @@ public class TestSpringBeanFactory implements BeanFactory { */ public T find(String aId, Class aClass) { try { - Object obj = _context.getBean(aId, aClass); + Object obj = context.getBean(aId, aClass); assert obj != null; return aClass.cast(obj); } catch (BeansException e) { diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java index 0fee7aca..a686f88c 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java @@ -32,8 +32,8 @@ import org.wamblee.system.core.Scope; public class ClassConfiguration { private Class _class; - private ConstructorConfiguration _constructorConfig; - private ObjectConfiguration _objectConfig; + private ConstructorConfiguration constructorConfig; + private ObjectConfiguration objectConfig; /** * Constructs the configuration. By default no constructor is selected and @@ -43,16 +43,16 @@ public class ClassConfiguration { */ public ClassConfiguration(Class aClass) { _class = aClass; - _constructorConfig = new ConstructorConfiguration(aClass); - _objectConfig = new ObjectConfiguration(aClass); + constructorConfig = new ConstructorConfiguration(aClass); + objectConfig = new ObjectConfiguration(aClass); } public ConstructorConfiguration getConstructorConfig() { - return _constructorConfig; + return constructorConfig; } public ObjectConfiguration getObjectConfig() { - return _objectConfig; + return objectConfig; } /** @@ -61,7 +61,7 @@ public class ClassConfiguration { * @return object. */ public Object create(Scope aScope) { - return _constructorConfig.create(aScope); + return constructorConfig.create(aScope); } /** @@ -70,7 +70,7 @@ public class ClassConfiguration { * @param aScope Scope in which injection takes place. */ public void inject(Scope aScope, Object aObject) { - _objectConfig.inject(aScope, aObject); + objectConfig.inject(aScope, aObject); } public List getProvidedInterfaces() { @@ -81,8 +81,8 @@ public class ClassConfiguration { public List getRequiredInterfaces() { List result = new ArrayList(); - result.addAll(_constructorConfig.getRequiredInterfaces()); - result.addAll(_objectConfig.getRequiredInterfaces()); + result.addAll(constructorConfig.getRequiredInterfaces()); + result.addAll(objectConfig.getRequiredInterfaces()); return result; } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java index 7a5c259d..9050b955 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ConstructorConfiguration.java @@ -44,10 +44,10 @@ import org.wamblee.system.core.SystemAssemblyException; * */ public class ConstructorConfiguration { - private Class _class; - private Constructor _constructor; - private ParameterValues _values; - private boolean _publicOnly; + private Class clazz; + private Constructor constructor; + private ParameterValues values; + private boolean publicOnly; /** * Constructs the configuration. By default the public constructor with the @@ -55,9 +55,9 @@ public class ConstructorConfiguration { * @param aClass Class to construct. */ public ConstructorConfiguration(Class aClass) { - _class = aClass; - _constructor = null; - _publicOnly = true; + clazz = aClass; + constructor = null; + publicOnly = true; } /** @@ -67,9 +67,9 @@ public class ConstructorConfiguration { * @return */ public ConstructorConfiguration setNonPublic(boolean aNonPublic) { - _publicOnly = !aNonPublic; - _constructor = null; - _values = null; + publicOnly = !aNonPublic; + constructor = null; + values = null; return this; } @@ -80,7 +80,7 @@ public class ConstructorConfiguration { */ public ConstructorConfiguration select(Class... aTypes) { try { - _constructor = _class.getDeclaredConstructor(aTypes); + constructor = clazz.getDeclaredConstructor(aTypes); } catch (Exception e) { throw new SystemAssemblyException(e.getMessage(), e); } @@ -95,9 +95,9 @@ public class ConstructorConfiguration { * identified. */ public ConstructorConfiguration greedy() { - Constructor[] declared = _class.getDeclaredConstructors(); + Constructor[] declared = clazz.getDeclaredConstructors(); if (declared.length == 0) { - throw new SystemAssemblyException("Class '" + _class + throw new SystemAssemblyException("Class '" + clazz + " is an interface, primitive type, or array"); } int max = -1; @@ -106,7 +106,7 @@ public class ConstructorConfiguration { new Condition>() { @Override public boolean matches(Constructor aObject) { - if ( !_publicOnly ) { + if ( !publicOnly ) { return true; } else { return Modifier.isPublic(aObject.getModifiers()); @@ -132,22 +132,22 @@ public class ConstructorConfiguration { throw new SystemAssemblyException( "Greediest constructor cannot be uniquely determined"); } - _constructor = longest.get(0); + constructor = longest.get(0); resetValues(); return this; } public ParameterValues getParameters() { getConstructor(); // initialize constructor if needed. - return _values; + return values; } /** * Resets the values. */ private void resetValues() { - _constructor.setAccessible(true); - _values = new ParameterValues(_constructor.getParameterTypes()); + constructor.setAccessible(true); + values = new ParameterValues(constructor.getParameterTypes()); } /** @@ -156,24 +156,24 @@ public class ConstructorConfiguration { * @return object. */ public Object create(Scope aScope) { - Object[] values = _values.values(aScope); + Object[] valueArray = values.values(aScope); try { - return getConstructor().newInstance(values); + return getConstructor().newInstance(valueArray); } catch (Exception e) { throw new SystemAssemblyException("Could not construct object " - + getConstructor() + " " + Arrays.asList(values), e); + + getConstructor() + " " + Arrays.asList(valueArray), e); } } public List getRequiredInterfaces() { getConstructor(); // initialize constructor if needed. - return _values.getRequiredInterfaces(); + return values.getRequiredInterfaces(); } private Constructor getConstructor() { - if (_constructor == null ) { + if (constructor == null ) { greedy(); } - return _constructor; + return constructor; } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ObjectAdapter.java b/system/general/src/main/java/org/wamblee/system/adapters/ObjectAdapter.java index ff2fa0a2..f8259030 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ObjectAdapter.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ObjectAdapter.java @@ -28,27 +28,27 @@ import org.wamblee.system.core.Scope; */ public class ObjectAdapter extends AbstractComponent { - private ObjectConfiguration _objectConfig; - private Object _object; + private ObjectConfiguration objectConfig; + private Object object; public ObjectAdapter(String aName, Object aObject, ObjectConfiguration aObjectConfig) { super(aName, new ProvidedInterface[] { new DefaultProvidedInterface(aName, aObject.getClass()) }, aObjectConfig.getRequiredInterfaces().toArray(new RequiredInterface[0])); - _objectConfig = aObjectConfig; - _object = aObject; + objectConfig = aObjectConfig; + object = aObject; } @Override protected Object doStart(Scope aScope) { - _objectConfig.inject(aScope, _object); + objectConfig.inject(aScope, object); for (ProvidedInterface provided: getProvidedInterfaces()) { - addInterface(provided, _object, aScope); + addInterface(provided, object, aScope); } - return _object; + return object; } @Override diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java index 22df0491..0efa2275 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java @@ -29,11 +29,11 @@ import org.wamblee.system.core.Scope; public class ObjectConfiguration { private Class _class; - private SetterConfiguration _setterConfig; + private SetterConfiguration setterConfig; public ObjectConfiguration(Class aClass) { _class = aClass; - _setterConfig = new SetterConfiguration(aClass); + setterConfig = new SetterConfiguration(aClass); } /** @@ -43,16 +43,16 @@ public class ObjectConfiguration { * @param aObject Object. */ public void inject(Scope aScope, Object aObject) { - _setterConfig.inject(aScope, aObject); + setterConfig.inject(aScope, aObject); } public SetterConfiguration getSetterConfig() { - return _setterConfig; + return setterConfig; } public List getRequiredInterfaces() { List result = new ArrayList(); - result.addAll(_setterConfig.getRequiredInterfaces()); + result.addAll(setterConfig.getRequiredInterfaces()); return result; } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ParameterValues.java b/system/general/src/main/java/org/wamblee/system/adapters/ParameterValues.java index 17789818..fa0f008e 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ParameterValues.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ParameterValues.java @@ -29,9 +29,9 @@ import org.wamblee.system.core.Scope; * @author Erik Brakkee */ public class ParameterValues { - private String[] _names; - private Class[] _types; - private ValueProvider[] _values; + private String[] names; + private Class[] types; + private ValueProvider[] values; /** * Constructs the configuration. By default no constructor is selected and @@ -40,11 +40,11 @@ public class ParameterValues { * @param aClass Class to construct. */ public ParameterValues(Class[] aTypes) { - _names = new String[aTypes.length]; + names = new String[aTypes.length]; for (int i = 0; i < aTypes.length; i++) { - _names[i] = "arg" + i; + names[i] = "arg" + i; } - _types = aTypes; + types = aTypes; resetValues(); } @@ -57,8 +57,8 @@ public class ParameterValues { */ public ParameterValues(String[] aNames, Class[] aTypes) { assert aNames.length == aTypes.length; - _names = aNames; - _types = aTypes; + names = aNames; + types = aTypes; resetValues(); } @@ -67,7 +67,7 @@ public class ParameterValues { * @return Types. */ public Class[] getTypes() { - return _types; + return types; } /** @@ -75,8 +75,8 @@ public class ParameterValues { * @param aArg Argument to set. */ public ParameterValues setOptional(int aArg) { - _values[aArg] = new RequiredInterfaceProvider(new DefaultRequiredInterface( - "arg" + aArg, _types[aArg], true)); + values[aArg] = new RequiredInterfaceProvider(new DefaultRequiredInterface( + "arg" + aArg, types[aArg], true)); return this; } @@ -86,7 +86,7 @@ public class ParameterValues { * @param aValue Value. */ public ParameterValues setValue(int aArg, Object aValue) { - _values[aArg] = new FixedValueProvider(aValue); + values[aArg] = new FixedValueProvider(aValue); return this; } @@ -94,10 +94,10 @@ public class ParameterValues { * Resets the values. */ private void resetValues() { - _values = new ValueProvider[_types.length]; - for (int i = 0; i < _values.length; i++) { - _values[i] = new RequiredInterfaceProvider(new DefaultRequiredInterface( - _names[i], _types[i])); + values = new ValueProvider[types.length]; + for (int i = 0; i < values.length; i++) { + values[i] = new RequiredInterfaceProvider(new DefaultRequiredInterface( + names[i], types[i])); } } @@ -108,7 +108,7 @@ public class ParameterValues { */ public List getRequiredInterfaces() { List result = new ArrayList(); - for (ValueProvider provider: _values) { + for (ValueProvider provider: values) { if ( provider instanceof RequiredInterfaceProvider) { result.add( ((RequiredInterfaceProvider)provider).getRequiredInterface()); } @@ -122,11 +122,11 @@ public class ParameterValues { * @return Values. */ public Object[] values(Scope aScope) { - Object[] values = new Object[_values.length]; - for (int i = 0; i < _values.length; i++) { - values[i] = _values[i].getValue(aScope); + Object[] valueArray = new Object[values.length]; + for (int i = 0; i < values.length; i++) { + valueArray[i] = values[i].getValue(aScope); } - return values; + return valueArray; } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/RequiredInterfaceProvider.java b/system/general/src/main/java/org/wamblee/system/adapters/RequiredInterfaceProvider.java index 56170aed..c6d70372 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/RequiredInterfaceProvider.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/RequiredInterfaceProvider.java @@ -25,23 +25,23 @@ import org.wamblee.system.core.Scope; */ class RequiredInterfaceProvider implements ValueProvider { - private RequiredInterface _required; + private RequiredInterface required; /** * Constructs the provider * @param aRequired Required interface. */ public RequiredInterfaceProvider(RequiredInterface aRequired) { - _required = aRequired; + required = aRequired; } @Override public Object getValue(Scope aScope) { - return aScope.getInterfaceImplementation(_required.getProvider(), Object.class); + return aScope.getInterfaceImplementation(required.getProvider(), Object.class); } public RequiredInterface getRequiredInterface() { - return _required; + return required; } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java index 57323a54..77fd9720 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java @@ -47,9 +47,9 @@ import org.wamblee.system.core.SystemAssemblyException; public class SetterConfiguration { private Class _class; - private boolean _publicOnly; + private boolean publicOnly; - private Map _setters; + private Map setters; /** * Constructs the setter configuration. By default no setters are added. @@ -59,17 +59,17 @@ public class SetterConfiguration { */ public SetterConfiguration(Class aClass) { _class = aClass; - _publicOnly = true; - _setters = new HashMap(); + publicOnly = true; + setters = new HashMap(); } /** * Makes sure that all available setters are used. */ public SetterConfiguration initAllSetters() { - _setters.clear(); - for (Method method: getAllSetters(_class, _publicOnly) ) { - _setters.put(method, createParameterValues(method)); + setters.clear(); + for (Method method: getAllSetters(_class, publicOnly) ) { + setters.put(method, createParameterValues(method)); } return this; } @@ -82,7 +82,7 @@ public class SetterConfiguration { * Non public flag. */ public SetterConfiguration setNonPublic(boolean aIsNonPublic) { - _publicOnly = !aIsNonPublic; + publicOnly = !aIsNonPublic; return this; } @@ -92,7 +92,7 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration clear() { - _setters.clear(); + setters.clear(); return this; } @@ -104,9 +104,9 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration remove(String aName) { - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.getName().equals(aName)) { - _setters.remove(method); + setters.remove(method); return this; } } @@ -123,9 +123,9 @@ public class SetterConfiguration { if ( !aMethod.getDeclaringClass().isAssignableFrom(_class) ) { throw new RuntimeException("Method " + aMethod + " not found in class " + _class + " or its superclasses"); } - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.equals(aMethod)) { - _setters.remove(method); + setters.remove(method); return this; } } @@ -140,9 +140,9 @@ public class SetterConfiguration { * @return Reference to the current object to allow call chaining. */ public SetterConfiguration add(final String aName) { - int oldlen = _setters.size(); + int oldlen = setters.size(); List methods = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, _publicOnly), methods, + CollectionFilter.filter(getAllSetters(_class, publicOnly), methods, new Condition() { @Override public boolean matches(Method aObject) { @@ -156,7 +156,7 @@ public class SetterConfiguration { } // TODO is it possible to get more than one setter here in case the subclass overrides // the baseclass method? - _setters.put(methods.get(0), createParameterValues(methods.get(0))); + setters.put(methods.get(0), createParameterValues(methods.get(0))); return this; } @@ -173,7 +173,7 @@ public class SetterConfiguration { */ public SetterConfiguration addSetter(final Class aType) { List result = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, _publicOnly), result, + CollectionFilter.filter(getAllSetters(_class, publicOnly), result, new Condition() { @Override public boolean matches(Method aObject) { @@ -199,7 +199,7 @@ public class SetterConfiguration { + setters); } Method method = result.get(0); - _setters.put(method, createParameterValues(method)); + setters.put(method, createParameterValues(method)); return this; } @@ -244,8 +244,8 @@ public class SetterConfiguration { */ public List getRequiredInterfaces() { List result = new ArrayList(); - for (Method method : _setters.keySet()) { - result.addAll(_setters.get(method).getRequiredInterfaces()); + for (Method method : setters.keySet()) { + result.addAll(setters.get(method).getRequiredInterfaces()); } return result; } @@ -263,8 +263,8 @@ public class SetterConfiguration { throw new IllegalArgumentException("Object '" + aObject + "' is not an instance of " + _class.getName()); } - for (Method method : _setters.keySet()) { - ParameterValues values = _setters.get(method); + for (Method method : setters.keySet()) { + ParameterValues values = setters.get(method); try { method.invoke(aObject, values.values(aScope)); @@ -288,9 +288,9 @@ public class SetterConfiguration { * @return Parameter values. */ public ParameterValues values(String aMethod) { - for (Method method : _setters.keySet()) { + for (Method method : setters.keySet()) { if (method.getName().equals(aMethod)) { - return _setters.get(method); + return setters.get(method); } } throw new IllegalArgumentException("No setter method '" + aMethod @@ -298,6 +298,6 @@ public class SetterConfiguration { } public List getSetters() { - return new ArrayList(_setters.keySet()); + return new ArrayList(setters.keySet()); } } diff --git a/system/general/src/main/java/org/wamblee/system/components/ORMappingConfig.java b/system/general/src/main/java/org/wamblee/system/components/ORMappingConfig.java index 880e869e..24e0a11d 100644 --- a/system/general/src/main/java/org/wamblee/system/components/ORMappingConfig.java +++ b/system/general/src/main/java/org/wamblee/system/components/ORMappingConfig.java @@ -42,20 +42,20 @@ public class ORMappingConfig { } }; - private boolean _schemaUpdate; - private DatabaseType _type; + private boolean schemaUpdate; + private DatabaseType type; public ORMappingConfig(boolean aSchemaUpdate, DatabaseType aType) { - _schemaUpdate = aSchemaUpdate; - _type = aType; + schemaUpdate = aSchemaUpdate; + type = aType; } public boolean isSchemaUpdate() { - return _schemaUpdate; + return schemaUpdate; } public DatabaseType getType() { - return _type; + return type; } } diff --git a/system/general/src/main/java/org/wamblee/system/components/PropertyComponent.java b/system/general/src/main/java/org/wamblee/system/components/PropertyComponent.java index d3c7e070..48ef0e38 100644 --- a/system/general/src/main/java/org/wamblee/system/components/PropertyComponent.java +++ b/system/general/src/main/java/org/wamblee/system/components/PropertyComponent.java @@ -37,7 +37,7 @@ public class PropertyComponent extends AbstractComponent { private static ProvidedInterface PROPS = new DefaultProvidedInterface("props", Properties.class); - private Properties _props; + private Properties props; public PropertyComponent(String aName, InputResource aResource) throws IOException { this(aName, readProps(aResource)); @@ -51,15 +51,15 @@ public class PropertyComponent extends AbstractComponent { public PropertyComponent(String aName, Properties aProps) { super(aName); - _props = aProps; + props = aProps; addProvidedInterface(PROPS); } @Override protected Properties doStart(Scope aScope) { - addInterface(PROPS, _props, aScope); - return _props; + addInterface(PROPS, props, aScope); + return props; } @Override diff --git a/system/general/src/main/java/org/wamblee/system/container/Container.java b/system/general/src/main/java/org/wamblee/system/container/Container.java index 9669cb21..cb7a0981 100644 --- a/system/general/src/main/java/org/wamblee/system/container/Container.java +++ b/system/general/src/main/java/org/wamblee/system/container/Container.java @@ -45,9 +45,9 @@ public class Container extends AbstractComponent { private static final Log LOG = LogFactory.getLog(Container.class); - private List _components; - private CompositeEdgeFilter _edgeFilter; - private boolean _sealed; + private List components; + private CompositeEdgeFilter edgeFilter; + private boolean sealed; /** * Constructs the container @@ -64,10 +64,10 @@ public class Container extends AbstractComponent { public Container(String aName, Component[] aComponents, List aProvided, List aRequired) { super(aName, aProvided, aRequired); - _components = new ArrayList(); + components = new ArrayList(); - _edgeFilter = new CompositeEdgeFilter(); - _sealed = false; + edgeFilter = new CompositeEdgeFilter(); + sealed = false; for (Component component : aComponents) { addComponent(component); } @@ -107,7 +107,7 @@ public class Container extends AbstractComponent { throw new SystemAssemblyException("Duplicate component '" + aComponent.getName() + "'"); } - _components.add(aComponent); + components.add(aComponent); aComponent.addContext(getQualifiedName()); return this; } @@ -146,7 +146,7 @@ public class Container extends AbstractComponent { + aProvidedInterface + "'"); } } - _edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface)); + edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface)); } /** @@ -176,7 +176,7 @@ public class Container extends AbstractComponent { + aExternalRequiredInterface + "'"); } } - _edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter( + edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter( aComponent, aRequiredInterface, aExternalRequiredInterface)); } @@ -202,7 +202,7 @@ public class Container extends AbstractComponent { + aExternalProvided + "'"); } } - _edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface)); + edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface)); } @@ -223,7 +223,7 @@ public class Container extends AbstractComponent { @Override public void addContext(String aContext) { super.addContext(aContext); - for (Component component : _components) { + for (Component component : components) { component.addContext(aContext); } } @@ -246,7 +246,7 @@ public class Container extends AbstractComponent { * be added. */ public void seal() { - _sealed = true; + sealed = true; } /** @@ -255,7 +255,7 @@ public class Container extends AbstractComponent { * @return True iff the container is sealed. */ public boolean isSealed() { - return _sealed; + return sealed; } /** @@ -296,7 +296,7 @@ public class Container extends AbstractComponent { LOG.info("Starting '" + getQualifiedName() + "'"); List started = new ArrayList(); - for (Component component : _components) { + for (Component component : components) { try { // Start the service. if (!aDryRun) { @@ -321,14 +321,14 @@ public class Container extends AbstractComponent { for (RequiredInterface req : getRequiredInterfaces()) { graph.addRequiredInterface(this, req); } - for (Component comp : _components) { + for (Component comp : components) { graph.addComponent(comp); } for (ProvidedInterface prov: getProvidedInterfaces()) { graph.addProvidedInterface(this, prov); } - graph.addEdgeFilter(_edgeFilter); + graph.addEdgeFilter(edgeFilter); return graph; } @@ -349,15 +349,15 @@ public class Container extends AbstractComponent { @Override protected void doStop(Scope aScope) { - for (int i = _components.size() - 1; i >= 0; i--) { - Component component = _components.get(i); + for (int i = components.size() - 1; i >= 0; i--) { + Component component = components.get(i); Object runtime = aScope.getRuntime(component); component.stop(runtime); } } private void checkSealed() { - if (_sealed) { + if (sealed) { throw new SystemAssemblyException("Container is sealed"); } } @@ -368,7 +368,7 @@ public class Container extends AbstractComponent { * @return Component or null if not found. */ public Component findComponent(String aName) { - for (Component component: _components) { + for (Component component: components) { if ( component.getName().equals(aName)) { return component; } diff --git a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java index d2cf69fe..579fd274 100644 --- a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java +++ b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java @@ -30,12 +30,12 @@ public abstract class AbstractComponent implements Component { private static final Log LOG = LogFactory.getLog(AbstractComponent.class); - private ThreadLocal> _remaining; + private ThreadLocal> remaining; - private String _context; - private String _name; - private List _provided; - private List _required; + private String context; + private String name; + private List provided; + private List required; /** * Constructs the subsystem. @@ -49,11 +49,11 @@ public abstract class AbstractComponent implements Component { */ protected AbstractComponent(String aName, List aProvided, List aRequired) { - _remaining = new ThreadLocal>(); - _context = null; - _name = aName; - _provided = new ArrayList(aProvided); - _required = new ArrayList(aRequired); + remaining = new ThreadLocal>(); + context = null; + name = aName; + provided = new ArrayList(aProvided); + required = new ArrayList(aRequired); } /** @@ -76,71 +76,71 @@ public abstract class AbstractComponent implements Component { } public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { - _provided.add(aProvided); + provided.add(aProvided); return this; } public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { - _required.add(aRequired); + required.add(aRequired); return this; } @Override public final String getName() { - return _name; + return name; } @Override public void addContext(String aContext) { - if (_context == null) { - _context = aContext; + if (context == null) { + context = aContext; } else { - _context = aContext + "." + _context; + context = aContext + "." + context; } } @Override public String getContext() { - return _context; + return context; } @Override public String getQualifiedName() { - if (_context == null) { + if (context == null) { return getName(); } - return _context + "." + getName(); + return context + "." + getName(); } @Override public final List getProvidedInterfaces() { - return Collections.unmodifiableList(_provided); + return Collections.unmodifiableList(provided); } @Override public final List getRequiredInterfaces() { - return Collections.unmodifiableList(_required); + return Collections.unmodifiableList(required); } @Override public final Type start(Scope aScope) { LOG.info("Initialization starting '" + getQualifiedName() + "'"); - List oldRemaining = _remaining.get(); - _remaining.set(new ArrayList(getProvidedInterfaces())); + List oldRemaining = remaining.get(); + remaining.set(new ArrayList(getProvidedInterfaces())); try { Type runtime = doStart(aScope); checkNotStartedInterfaces(); LOG.info("Initialization finished '" + getQualifiedName() + "'"); return runtime; } finally { - _remaining.set(oldRemaining); + remaining.set(oldRemaining); } } private void checkNotStartedInterfaces() { - if (_remaining.get().size() > 0) { + if (remaining.get().size() > 0) { String notProvided = ""; - for (ProvidedInterface provided : _remaining.get()) { + for (ProvidedInterface provided : remaining.get()) { notProvided += "\nComponent " + getQualifiedName() + " did not start interface " + provided; } @@ -171,7 +171,7 @@ public abstract class AbstractComponent implements Component { Object aService, Scope aScope) { LOG.info("Interface '" + getQualifiedName() + "." + aDescriptor.getName() + "' started."); - if ( !_remaining.get().remove(aDescriptor) ) { + if ( !remaining.get().remove(aDescriptor) ) { throw new SystemAssemblyException("Component '" + getQualifiedName() + "' started an unexpected interface '" + aDescriptor + "' that was not registerd as a provided interface before"); } diff --git a/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java b/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java index c7905673..d30a8c15 100644 --- a/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java +++ b/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java @@ -28,8 +28,8 @@ import java.util.List; */ public class DefaultProvidedInterface implements ProvidedInterface { - private String _name; - private Class[] _interfaces; + private String name; + private Class[] interfaces; /** * Constructs the descriptor. @@ -40,18 +40,18 @@ public class DefaultProvidedInterface implements ProvidedInterface { } public DefaultProvidedInterface(String aName, Class[] aInterfaces) { - _name = aName; - _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length); + name = aName; + interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length); } @Override public String getName() { - return _name; + return name; } @Override public Class[] getInterfaceTypes() { - return _interfaces; + return interfaces; } @Override @@ -59,7 +59,7 @@ public class DefaultProvidedInterface implements ProvidedInterface { StringBuffer buf = new StringBuffer(); buf.append(getName()); buf.append(":"); - for (Class intf: _interfaces) { + for (Class intf: interfaces) { buf.append(" " + intf.getName()); } return buf.toString(); @@ -94,7 +94,7 @@ public class DefaultProvidedInterface implements ProvidedInterface { private String getEqualsRepresentation() { List result = new ArrayList(); - for (Class cls: _interfaces) { + for (Class cls: interfaces) { result.add(cls.getName()); } Collections.sort(result); diff --git a/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java b/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java index 4e0db74b..80c3d135 100644 --- a/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java +++ b/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java @@ -21,10 +21,10 @@ import org.wamblee.reflection.ReflectionUtils; public class DefaultRequiredInterface implements RequiredInterface { - private String _name; - private boolean _optional; - private Class[] _required; - private ProvidedInterface _provider; + private String name; + private boolean optional; + private Class[] required; + private ProvidedInterface provider; public DefaultRequiredInterface(String aName, Class aInterface) { this(aName, new Class[] { aInterface }); @@ -40,26 +40,26 @@ public class DefaultRequiredInterface implements RequiredInterface { public DefaultRequiredInterface(String aName, Class[] aInterfaces, boolean aIsOptional) { - _name = aName; - _optional = aIsOptional; - _required = aInterfaces; + name = aName; + optional = aIsOptional; + required = aInterfaces; } @Override public String getName() { - return _name; + return name; } @Override public boolean isOptional() { - return _optional; + return optional; } @Override public boolean implementedBy(ProvidedInterface aDescriptor) { Class[] provided = aDescriptor.getInterfaceTypes(); - for (Class required : _required) { - if ( !serviceProvided(required, provided)) { + for (Class requiredIntf : required) { + if ( !serviceProvided(requiredIntf, provided)) { return false; } } @@ -89,14 +89,14 @@ public class DefaultRequiredInterface implements RequiredInterface { @Override public ProvidedInterface getProvider() { - return _provider; + return provider; } @Override public void setProvider(ProvidedInterface aProvider) { assert aProvider != null; assert implementedBy(aProvider); - _provider = aProvider; + provider = aProvider; } @Override @@ -111,14 +111,14 @@ public class DefaultRequiredInterface implements RequiredInterface { return false; } DefaultRequiredInterface descr = (DefaultRequiredInterface)obj; - if ( _required.length != descr._required.length ) { + if ( required.length != descr.required.length ) { return false; } - String[] interfaces1 = new String[_required.length]; - String[] interfaces2 = new String[_required.length]; - for (int i = 0; i < _required.length; i++) { - interfaces1[i] = _required[i].getName(); - interfaces2[i] = descr._required[i].getName(); + String[] interfaces1 = new String[required.length]; + String[] interfaces2 = new String[required.length]; + for (int i = 0; i < required.length; i++) { + interfaces1[i] = required[i].getName(); + interfaces2[i] = descr.required[i].getName(); } Arrays.sort(interfaces1); Arrays.sort(interfaces2); @@ -127,14 +127,14 @@ public class DefaultRequiredInterface implements RequiredInterface { @Override public int hashCode() { - return _required.hashCode(); + return required.hashCode(); } @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("." + getName() + ":"); - for (Class intf: _required) { + for (Class intf: required) { buf.append("." + intf.getName()); } return buf.toString(); diff --git a/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java b/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java index 50c6cc3b..3e15ea9c 100644 --- a/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java +++ b/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java @@ -24,11 +24,11 @@ import java.util.Map; public class DefaultScope implements Scope { - private List _parents; - private Map _properties; - private Map _runtimes; - private Map _provided; - private List _externallyProvided; + private List parents; + private Map properties; + private Map runtimes; + private Map provided; + private List externallyProvided; public DefaultScope(ListaExternallyProvided) { this(aExternallyProvided.toArray(new ProvidedInterface[0])); @@ -44,48 +44,48 @@ public class DefaultScope implements Scope { public DefaultScope(ProvidedInterface[] aExternallyProvided, List aParent) { - _parents = new ArrayList(aParent); - _properties = new HashMap(); - _runtimes = new HashMap(); - _provided = new HashMap(); - _externallyProvided = new ArrayList(); - _externallyProvided.addAll(Arrays.asList(aExternallyProvided)); + parents = new ArrayList(aParent); + properties = new HashMap(); + runtimes = new HashMap(); + provided = new HashMap(); + externallyProvided = new ArrayList(); + externallyProvided.addAll(Arrays.asList(aExternallyProvided)); } @Override public List getProvidedInterfaces() { - return Collections.unmodifiableList(_externallyProvided); + return Collections.unmodifiableList(externallyProvided); } @Override public Object get(String aKey) { - return _properties.get(aKey); + return properties.get(aKey); } @Override public void put(String aKey, Object aValue) { - _properties.put(aKey, aValue); + properties.put(aKey, aValue); } @Override public void addRuntime(Component aComponent, Object aRuntime) { - _runtimes.put(aComponent.getName(), aRuntime); + runtimes.put(aComponent.getName(), aRuntime); } @Override public Object getRuntime(Component aComponent) { - return _runtimes.get(aComponent.getName()); + return runtimes.get(aComponent.getName()); } @Override public Object getRuntime(String aName) { - return _runtimes.get(aName); + return runtimes.get(aName); } @Override synchronized public void publishInterface(ProvidedInterface aInterface, Object aImplementation) { - _provided.put(aInterface, new ProvidedInterfaceImplementation(aInterface, + provided.put(aInterface, new ProvidedInterfaceImplementation(aInterface, aImplementation)); } @@ -95,9 +95,9 @@ public class DefaultScope implements Scope { if ( aInterface == null ) { return null; } - ProvidedInterfaceImplementation provided = _provided.get(aInterface); - if (provided == null) { - for (Scope parent : _parents) { + ProvidedInterfaceImplementation providedIntf = provided.get(aInterface); + if (providedIntf == null) { + for (Scope parent : parents) { T impl = parent.getInterfaceImplementation(aInterface, aType); if ( impl != null ) { return impl; @@ -105,7 +105,7 @@ public class DefaultScope implements Scope { } return null; } else { - return provided.getImplementation(aType); + return providedIntf.getImplementation(aType); } } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/CompositeEdgeFilter.java b/system/general/src/main/java/org/wamblee/system/graph/CompositeEdgeFilter.java index 692c881f..b919e908 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/CompositeEdgeFilter.java +++ b/system/general/src/main/java/org/wamblee/system/graph/CompositeEdgeFilter.java @@ -20,19 +20,19 @@ import java.util.List; public class CompositeEdgeFilter implements EdgeFilter { - private List _filters; + private List filters; public CompositeEdgeFilter() { - _filters = new ArrayList(); + filters = new ArrayList(); } public void add(EdgeFilter aFilter) { - _filters.add(aFilter); + filters.add(aFilter); } @Override public boolean isViolated(Edge aEdge) { - for (EdgeFilter filter: _filters) { + for (EdgeFilter filter: filters) { if ( filter.isViolated(aEdge) ) { return true; } diff --git a/system/general/src/main/java/org/wamblee/system/graph/DefaultEdge.java b/system/general/src/main/java/org/wamblee/system/graph/DefaultEdge.java index 35d648ff..29220498 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/DefaultEdge.java +++ b/system/general/src/main/java/org/wamblee/system/graph/DefaultEdge.java @@ -24,27 +24,27 @@ package org.wamblee.system.graph; */ public class DefaultEdge implements Edge { - private Node _from; - private Node _to; + private Node from; + private Node to; public DefaultEdge(Node aFrom, Node aTo) { - _from = aFrom; - _to = aTo; + from = aFrom; + to = aTo; } @Override public Node getFrom() { - return _from; + return from; } @Override public Node getTo() { - return _to; + return to; } @Override public String toString() { - return "Edge(" + _from.getName() + ", " + _to.getName() + ")"; + return "Edge(" + from.getName() + ", " + to.getName() + ")"; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/DefaultNode.java b/system/general/src/main/java/org/wamblee/system/graph/DefaultNode.java index 925c08c1..df61e97e 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/DefaultNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/DefaultNode.java @@ -23,14 +23,14 @@ package org.wamblee.system.graph; */ public class DefaultNode implements Node { - private String _name; + private String name; /** * Constructs the node. * @param aName Node name. */ public DefaultNode(String aName) { - _name = aName; + name = aName; } /** @@ -38,7 +38,7 @@ public class DefaultNode implements Node { */ @Override public String getName() { - return _name; + return name; } @Override @@ -47,11 +47,11 @@ public class DefaultNode implements Node { return false; } Node node = (Node)aObj; - return _name.equals(node.getName()); + return name.equals(node.getName()); } @Override public int hashCode() { - return _name.hashCode(); + return name.hashCode(); } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/EdgeSelector.java b/system/general/src/main/java/org/wamblee/system/graph/EdgeSelector.java index c49f82c1..fca26ffb 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/EdgeSelector.java +++ b/system/general/src/main/java/org/wamblee/system/graph/EdgeSelector.java @@ -21,16 +21,16 @@ public class EdgeSelector { void execute(FromType aFrom, ToType aTo); } - private Class _fromType; - private Class _toType; + private Class fromType; + private Class toType; public EdgeSelector(Class aFrom, Class aTo) { - _fromType = aFrom; - _toType = aTo; + fromType = aFrom; + toType = aTo; } public void execute(Selector aSelector, Edge aEdge) { - if ( _fromType.isInstance(aEdge.getFrom()) && _toType.isInstance(aEdge.getTo())) { + if ( fromType.isInstance(aEdge.getFrom()) && toType.isInstance(aEdge.getTo())) { aSelector.execute((FromType)aEdge.getFrom(), (ToType)aEdge.getTo()); } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/Graph.java b/system/general/src/main/java/org/wamblee/system/graph/Graph.java index 0e4f6ccb..ddfd2cf7 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/Graph.java +++ b/system/general/src/main/java/org/wamblee/system/graph/Graph.java @@ -26,15 +26,15 @@ import java.util.List; */ public class Graph { - private List _nodes; - private List _edges; + private List nodes; + private List edges; /** * Constructs the graph. */ public Graph() { - _nodes = new ArrayList(); - _edges = new ArrayList(); + nodes = new ArrayList(); + edges = new ArrayList(); } /** @@ -47,11 +47,11 @@ public class Graph { * using equals. */ public void addNode(Node aNode) { - if (_nodes.contains(aNode)) { + if (nodes.contains(aNode)) { throw new IllegalArgumentException("Node '" + aNode.getName() + "' already exists"); } - _nodes.add(aNode); + nodes.add(aNode); } /** @@ -62,7 +62,7 @@ public class Graph { * @return Node or null if not found. */ public Node findNode(String aName) { - for (Node node : _nodes) { + for (Node node : nodes) { if (node.getName().equals(aName)) { return node; } @@ -85,7 +85,7 @@ public class Graph { + aNode.getName() + "' because it is connected to one or more edges"); } - return _nodes.remove(aNode); + return nodes.remove(aNode); } /** @@ -113,19 +113,19 @@ public class Graph { * {@link #equals(Object)} is already a part of the graph. */ public void addEdge(Edge aEdge) { - if (_edges.contains(aEdge)) { + if (edges.contains(aEdge)) { throw new IllegalArgumentException("Edge '" + aEdge + "' already exists"); } - if (!_nodes.contains(aEdge.getFrom())) { + if (!nodes.contains(aEdge.getFrom())) { throw new IllegalArgumentException("From node '" + aEdge.getFrom() + "' from edge '" + aEdge + "' is not part of the graph"); } - if (!_nodes.contains(aEdge.getTo())) { + if (!nodes.contains(aEdge.getTo())) { throw new IllegalArgumentException("To node '" + aEdge.getTo() + "' from edge '" + aEdge + "' is not part of the graph"); } - _edges.add(aEdge); + edges.add(aEdge); } /** @@ -134,7 +134,7 @@ public class Graph { * @return True if the edge was removed. */ public boolean removeEdge(Edge aEdge) { - return _edges.remove(aEdge); + return edges.remove(aEdge); } /** @@ -152,7 +152,7 @@ public class Graph { * @return Copy of the list of nodes of the graph. */ public List getNodes() { - return new ArrayList(_nodes); + return new ArrayList(nodes); } /** @@ -160,7 +160,7 @@ public class Graph { * @return Copy of the list of edges of the graph. */ public List getEdges() { - return new ArrayList(_edges); + return new ArrayList(edges); } /** @@ -169,9 +169,9 @@ public class Graph { * @param aFactory Edge factory. */ public void extend(EdgeFactory aFactory) { - for (Node from : _nodes) { - for (Node to : _nodes) { - _edges.addAll(aFactory.create(from, to)); + for (Node from : nodes) { + for (Node to : nodes) { + edges.addAll(aFactory.create(from, to)); } } } @@ -181,7 +181,7 @@ public class Graph { * @param aFilter Filter to apply. */ public void applyFilter(EdgeFilter aFilter) { - for (Iterator edge = _edges.iterator(); edge.hasNext(); ) { + for (Iterator edge = edges.iterator(); edge.hasNext(); ) { if (aFilter.isViolated(edge.next())) { edge.remove(); } @@ -196,7 +196,7 @@ public class Graph { */ public List findOutgoing(Node aNode) { List result = new ArrayList(); - for (Edge edge : _edges) { + for (Edge edge : edges) { if (edge.getFrom().getName().equals(aNode.getName())) { result.add(edge); } @@ -213,7 +213,7 @@ public class Graph { */ public List findIncoming(Node aNode) { List result = new ArrayList(); - for (Edge edge : _edges) { + for (Edge edge : edges) { if (edge.getTo().getName().equals(aNode.getName())) { result.add(edge); } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java index c921630b..b63a03b5 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java @@ -32,14 +32,14 @@ import org.wamblee.system.graph.Visitor; */ public class CheckExternallyProvidedVisitor implements Visitor { - private Graph _graph; + private Graph graph; /** * Constructs the visitor. * @param aGraph Component graph. */ public CheckExternallyProvidedVisitor(Graph aGraph) { - _graph = aGraph; + graph = aGraph; } @Override @@ -51,7 +51,7 @@ public class CheckExternallyProvidedVisitor implements Visitor { public void visitNode(Node aNode) { if ( aNode instanceof ExternalProvidedInterfaceNode) { ExternalProvidedInterfaceNode provided = (ExternalProvidedInterfaceNode) aNode; - List edges = _graph.findOutgoing(provided); + List edges = graph.findOutgoing(provided); if ( edges.size() > 2 ) { createDuplicateException("External provided interfaces has multiple internal matches", aNode, edges); } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java index 1ce53d07..4ab72426 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java @@ -36,10 +36,10 @@ public class CheckExternallyRequiredVisitor implements Visitor { private Log LOG = LogFactory.getLog(CheckExternallyRequiredVisitor.class); - private Graph _graph; + private Graph graph; public CheckExternallyRequiredVisitor(Graph aGraph) { - _graph = aGraph; + graph = aGraph; } @Override @@ -57,7 +57,7 @@ public class CheckExternallyRequiredVisitor implements Visitor { + ": External required interface is not provided"); } - List edges = _graph.findIncoming(aNode); + List edges = graph.findIncoming(aNode); if (edges.isEmpty()) { LOG.warn(aNode + ": Superfluous required interface"); diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java index 608dfc16..58cd2cf5 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java @@ -38,10 +38,10 @@ import org.wamblee.system.graph.Visitor; */ public class CheckRequiredProvidedMultiplicityVisitor implements Visitor { - private Graph _graph; + private Graph graph; public CheckRequiredProvidedMultiplicityVisitor(Graph aGraph) { - _graph = aGraph; + graph = aGraph; } @Override @@ -53,7 +53,7 @@ public class CheckRequiredProvidedMultiplicityVisitor implements Visitor { public void visitNode(Node aNode) { if (aNode instanceof RequiredInterfaceNode) { RequiredInterfaceNode required = (RequiredInterfaceNode) aNode; - List edges = _graph.findOutgoing(aNode); + List edges = graph.findOutgoing(aNode); if (edges.size() > 1) { createDuplicateException("Multiple providers of required interface found", aNode, edges); } @@ -63,7 +63,7 @@ public class CheckRequiredProvidedMultiplicityVisitor implements Visitor { + ": mandatpory required interface not provided by other components started earlier"); } } else if ( aNode instanceof ExternalProvidedInterfaceNode) { - List edges = _graph.findOutgoing(aNode); + List edges = graph.findOutgoing(aNode); if ( edges.size() > 1) { createDuplicateException("multiple internal matches for externally provided interface", aNode, edges); } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckStartupDependenciesVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckStartupDependenciesVisitor.java index 61f4e704..d18db799 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckStartupDependenciesVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckStartupDependenciesVisitor.java @@ -32,16 +32,16 @@ import org.wamblee.system.graph.Visitor; */ public class CheckStartupDependenciesVisitor implements Visitor { - private Graph _graph; - private List _available; + private Graph graph; + private List available; /** * Constructs the visitor. * @param aGraph Graph. */ public CheckStartupDependenciesVisitor(Graph aGraph) { - _graph = aGraph; - _available = new ArrayList(); + graph = aGraph; + available = new ArrayList(); } @Override @@ -51,17 +51,17 @@ public class CheckStartupDependenciesVisitor implements Visitor { @Override public void visitNode(Node aNode) { - List edges = _graph.findOutgoing(aNode); + List edges = graph.findOutgoing(aNode); // check dependencies. for (Edge edge: edges) { Node dep = edge.getTo(); - if ( !_available.contains(dep)) { + if ( !available.contains(dep)) { throw new SystemAssemblyException(aNode + ": required dependency '" + dep + "' was not started"); } } - _available.add(aNode); + available.add(aNode); } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java index b41c41c8..f772299b 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java @@ -36,15 +36,15 @@ import org.wamblee.system.graph.Node; */ public class ComponentGraph extends Graph { - private boolean _isLinked; - private CompositeEdgeFilter _edgeFilter; + private boolean isLinked; + private CompositeEdgeFilter edgeFilter; /** * Constructs an empty component graph. */ public ComponentGraph() { - _isLinked = false; - _edgeFilter = new CompositeEdgeFilter(); + isLinked = false; + edgeFilter = new CompositeEdgeFilter(); } /** @@ -73,7 +73,7 @@ public class ComponentGraph extends Graph { */ public void validate() { extend(new RequiredProvidedEdgeFactory()); - applyFilter(_edgeFilter); + applyFilter(edgeFilter); accept(new CheckRequiredProvidedMultiplicityVisitor(this)); accept(new CheckExternallyRequiredVisitor(this)); accept(new CheckExternallyProvidedVisitor(this)); @@ -85,11 +85,11 @@ public class ComponentGraph extends Graph { * model based on the graph model. */ public void link() { - if ( _isLinked ) { + if ( isLinked ) { return; } accept(new LinkVisitor()); - _isLinked = true; + isLinked = true; } /** @@ -149,6 +149,6 @@ public class ComponentGraph extends Graph { } public void addEdgeFilter(CompositeEdgeFilter aEdgeFilter) { - _edgeFilter.add(aEdgeFilter); + edgeFilter.add(aEdgeFilter); } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentNode.java index dc344268..2ba12614 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentNode.java @@ -25,18 +25,18 @@ import org.wamblee.system.graph.Node; */ public class ComponentNode implements Node { - private Component _component; + private Component component; public ComponentNode(Component aComponent) { - _component = aComponent; + component = aComponent; } @Override public String getName() { - return _component.getQualifiedName(); + return component.getQualifiedName(); } public Component getComponent() { - return _component; + return component; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedFilter.java b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedFilter.java index 1007ae70..578bc72f 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedFilter.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedFilter.java @@ -27,22 +27,22 @@ import org.wamblee.system.graph.EdgeFilter; */ public class ConnectExternalProvidedProvidedFilter implements EdgeFilter { - private String _externalProvided; - private String _component; - private String _provided; + private String externalProvided; + private String component; + private String provided; public ConnectExternalProvidedProvidedFilter(String aExternalProvided, String aComponent, String aProvided) { - _externalProvided = aExternalProvided; - _component = aComponent; - _provided = aProvided; - if ( _externalProvided == null ) { + externalProvided = aExternalProvided; + component = aComponent; + provided = aProvided; + if ( externalProvided == null ) { throw new IllegalArgumentException("External provided interface name must be specified."); } - if ( _component == null ) { + if ( component == null ) { throw new IllegalArgumentException("Component name must be specified"); } - if ( _provided == null ) { + if ( provided == null ) { throw new IllegalArgumentException("Provided interface name of internal component must be specified"); } } @@ -59,11 +59,11 @@ public class ConnectExternalProvidedProvidedFilter implements EdgeFilter { private boolean isViolated(ExternalProvidedInterfaceNode aFrom, ProvidedInterfaceNode aTo) { - if ( !aFrom.getName().equals(_externalProvided)) { + if ( !aFrom.getName().equals(externalProvided)) { return false; // wrong provided interface. } - if ( aTo.getComponent().getName().equals(_component) && - aTo.getProvided().getName().equals(_provided) ) { + if ( aTo.getComponent().getName().equals(component) && + aTo.getProvided().getName().equals(provided) ) { return false; // ok } return true; diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilter.java b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilter.java index c7084028..4c5404b9 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilter.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilter.java @@ -27,22 +27,22 @@ import org.wamblee.system.graph.EdgeFilter; */ public class ConnectRequiredExternallyRequiredEdgeFilter implements EdgeFilter { - private String _client; - private String _required; - private String _externalRequired; + private String client; + private String required; + private String externalRequired; public ConnectRequiredExternallyRequiredEdgeFilter(String aClient, String aRequired, String aExternalRequired) { - _client = aClient; - _required = aRequired; - _externalRequired = aExternalRequired; - if ( _client == null ) { + client = aClient; + required = aRequired; + externalRequired = aExternalRequired; + if ( client == null ) { throw new IllegalArgumentException("Client component must be specified"); } - if ( _required == null ) { + if ( required == null ) { throw new IllegalArgumentException("Required interface must be specified"); } - if ( _externalRequired == null ) { + if ( externalRequired == null ) { throw new IllegalArgumentException("External required interface must be specified"); } } @@ -59,13 +59,13 @@ public class ConnectRequiredExternallyRequiredEdgeFilter implements EdgeFilter { private boolean isViolated(RequiredInterfaceNode aFrom, ExternalRequiredInterfaceNode aTo) { - if ( !aFrom.getComponent().getName().equals(_client)) { + if ( !aFrom.getComponent().getName().equals(client)) { return false; // wrong component. } - if ( !(_required == null || aFrom.getRequired().getName().equals(_required))) { + if ( !(required == null || aFrom.getRequired().getName().equals(required))) { return false; // wrong interface } - if ( !aTo.getRequired().getName().equals(_externalRequired)) { + if ( !aTo.getRequired().getName().equals(externalRequired)) { return true; // wrong externally required interface. } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilter.java b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilter.java index a1d2481f..a3c3f6d5 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilter.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilter.java @@ -27,18 +27,18 @@ import org.wamblee.system.graph.EdgeFilter; */ public class ConnectRequiredProvidedEdgeFilter implements EdgeFilter { - private String _client; - private String _required; - private String _server; - private String _provided; + private String client; + private String required; + private String server; + private String provided; public ConnectRequiredProvidedEdgeFilter(String aClient, String aRequired, String aServer, String aProvided) { - _client = aClient; - _required = aRequired; - _server = aServer; - _provided = aProvided; - if ( _client == null ) { + client = aClient; + required = aRequired; + server = aServer; + provided = aProvided; + if ( client == null ) { throw new IllegalArgumentException("Client component must be specified"); } } @@ -55,15 +55,15 @@ public class ConnectRequiredProvidedEdgeFilter implements EdgeFilter { private boolean isViolated(RequiredInterfaceNode aFrom, ProvidedInterfaceNode aTo) { - if (_client.equals(aFrom.getComponent().getName()) - && (_required == null || _required.equals(aFrom.getRequired() + if (client.equals(aFrom.getComponent().getName()) + && (required == null || required.equals(aFrom.getRequired() .getName()))) { // From part matches. - if ( _server == null ) { + if ( server == null ) { return true; // all connections are eliminated } - if (_server.equals(aTo.getComponent().getName()) - && (_provided == null || _provided.equals(aTo.getProvided() + if (server.equals(aTo.getComponent().getName()) + && (provided == null || provided.equals(aTo.getProvided() .getName()))) { // to part matches also return false; diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java index c7fd7d0b..d4cef89a 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java @@ -26,29 +26,29 @@ import org.wamblee.system.graph.Node; */ public class ExternalProvidedInterfaceNode implements Node { - private Component _component; - private ProvidedInterface _provided; + private Component component; + private ProvidedInterface provided; public ExternalProvidedInterfaceNode(Component aComponent, ProvidedInterface aProvided) { - _component = aComponent; - _provided = aProvided; + component = aComponent; + provided = aProvided; } @Override public String getName() { - return _provided.getName(); + return provided.getName(); } public Component getComponent() { - return _component; + return component; } public ProvidedInterface getProvided() { - return _provided; + return provided; } @Override public String toString() { - return _component.getQualifiedName() + ":" + _provided; + return component.getQualifiedName() + ":" + provided; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalRequiredInterfaceNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalRequiredInterfaceNode.java index 5c65ebdb..6b71ffea 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalRequiredInterfaceNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalRequiredInterfaceNode.java @@ -26,29 +26,29 @@ import org.wamblee.system.graph.Node; */ public class ExternalRequiredInterfaceNode implements Node { - private Component _component; - private RequiredInterface _required; + private Component component; + private RequiredInterface required; public ExternalRequiredInterfaceNode(Component aComponent, RequiredInterface aRequired) { - _component = aComponent; - _required = aRequired; + component = aComponent; + required = aRequired; } @Override public String getName() { - return _required.getName(); + return required.getName(); } public Component getComponent() { - return _component; + return component; } public RequiredInterface getRequired() { - return _required; + return required; } @Override public String toString() { - return _component.getQualifiedName() + ":" + _required; + return component.getQualifiedName() + ":" + required; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ProvidedInterfaceNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/ProvidedInterfaceNode.java index 2fb2c0f7..206bdc9f 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ProvidedInterfaceNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ProvidedInterfaceNode.java @@ -25,29 +25,29 @@ import org.wamblee.system.graph.Node; */ public class ProvidedInterfaceNode implements Node { - private Component _component; - private ProvidedInterface _provided; + private Component component; + private ProvidedInterface provided; public ProvidedInterfaceNode(Component aComponent, ProvidedInterface aProvided) { - _component = aComponent; - _provided = aProvided; + component = aComponent; + provided = aProvided; } @Override public String getName() { - return _component.getQualifiedName() + ":" + _provided.getName(); + return component.getQualifiedName() + ":" + provided.getName(); } public ProvidedInterface getProvided() { - return _provided; + return provided; } public Component getComponent() { - return _component; + return component; } @Override public String toString() { - return _component.getQualifiedName() + ":" + _provided; + return component.getQualifiedName() + ":" + provided; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/RequiredInterfaceNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/RequiredInterfaceNode.java index b1540512..bdf4f89e 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/RequiredInterfaceNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/RequiredInterfaceNode.java @@ -26,29 +26,29 @@ import org.wamblee.system.graph.Node; */ public class RequiredInterfaceNode implements Node { - private Component _component; - private RequiredInterface _required; + private Component component; + private RequiredInterface required; public RequiredInterfaceNode(Component aComponent, RequiredInterface aRequired) { - _component = aComponent; - _required = aRequired; + component = aComponent; + required = aRequired; } @Override public String getName() { - return _component.getQualifiedName() + ":" + _required.getName(); + return component.getQualifiedName() + ":" + required.getName(); } public RequiredInterface getRequired() { - return _required; + return required; } public Component getComponent() { - return _component; + return component; } @Override public String toString() { - return _component.getQualifiedName() + ":" + _required; + return component.getQualifiedName() + ":" + required; } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java b/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java index cf67b247..6dca8fe7 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java @@ -24,14 +24,14 @@ import junit.framework.TestCase; public class AdapterTestCase extends TestCase { - protected Scope _scope; + protected Scope scope; static EventTracker EVENT_TRACKER; @Override protected void setUp() throws Exception { super.setUp(); EVENT_TRACKER = new EventTracker(); - _scope = new DefaultScope(new ProvidedInterface[0]); + scope = new DefaultScope(new ProvidedInterface[0]); } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java index 8d5703dd..da5ff6f8 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java @@ -41,8 +41,8 @@ public class ClassConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); - classConfig.create(_scope); + scope.publishInterface(provided, "hello"); + classConfig.create(scope); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) @@ -67,10 +67,10 @@ public class ClassConfigurationTest extends AdapterTestCase { required.get(0).setProvider(providedBoolean); required.get(1).setProvider(providedHost); - _scope.publishInterface(providedBoolean, true); - _scope.publishInterface(providedHost, "host.name.org"); + scope.publishInterface(providedBoolean, true); + scope.publishInterface(providedHost, "host.name.org"); - Object obj = classConfig.create(_scope); + Object obj = classConfig.create(scope); assertTrue(obj instanceof X7); X7 x7 = (X7)obj; assertNotNull(x7.getBoolean()); @@ -78,7 +78,7 @@ public class ClassConfigurationTest extends AdapterTestCase { assertNull(x7.getHost()); assertNull(x7.getPort()); - classConfig.inject(_scope, obj); + classConfig.inject(scope, obj); assertEquals("host.name.org", x7.getHost()); assertEquals(10, x7.getPort().intValue()); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java index 0cec6fba..fe0ece62 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java @@ -37,8 +37,8 @@ public class ConstructorConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); - config.create(_scope); + scope.publishInterface(provided, "hello"); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); @@ -65,8 +65,8 @@ public class ConstructorConfigurationTest extends AdapterTestCase { assertEquals(1, required.size()); required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); - config.create(_scope); + scope.publishInterface(provided, "hello"); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x2(hello)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); @@ -77,7 +77,7 @@ public class ConstructorConfigurationTest extends AdapterTestCase { .greedy(); config.getParameters().setValue(0, "bla"); - config.create(_scope); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(bla)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); @@ -94,8 +94,8 @@ public class ConstructorConfigurationTest extends AdapterTestCase { assertEquals(1, required.size()); required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); - config.create(_scope); + scope.publishInterface(provided, "hello"); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); @@ -107,7 +107,7 @@ public class ConstructorConfigurationTest extends AdapterTestCase { config.getParameters().setOptional(0); assertTrue(config.getRequiredInterfaces().get(0).isOptional()); - config.create(_scope); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(null)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); @@ -132,8 +132,8 @@ public class ConstructorConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); - config.create(_scope); + scope.publishInterface(provided, "hello"); + config.create(scope); AssertionUtils.assertEquals(new String[] { "x3(hello)" }, AdapterTestCase.EVENT_TRACKER .getEvents(Thread.currentThread()).toArray()); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java index aebdc3df..ce0a8d89 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java @@ -41,11 +41,11 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); + scope.publishInterface(provided, "hello"); X5 obj = new X5(); assertNull(obj.getValue()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getValue()); } @@ -69,18 +69,18 @@ public class SetterConfigurationTest extends AdapterTestCase { "janse", String.class); assertTrue(required.get(0).implementedBy(providedString)); required.get(0).setProvider(providedString); - _scope.publishInterface(providedString, "hello"); + scope.publishInterface(providedString, "hello"); ProvidedInterface providedInt = new DefaultProvidedInterface("xxx", Integer.class); assertTrue(required.get(1).implementedBy(providedInt)); required.get(1).setProvider(providedInt); - _scope.publishInterface(providedInt, 100); + scope.publishInterface(providedInt, 100); X5 obj = new X5(); assertNull(obj.getValue()); assertNull(obj.getXyz()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getValue()); assertEquals(100, obj.getXyz().intValue()); } @@ -106,25 +106,25 @@ public class SetterConfigurationTest extends AdapterTestCase { "janse", Boolean.class); assertTrue(required.get(0).implementedBy(providedBoolean)); required.get(0).setProvider(providedBoolean); - _scope.publishInterface(providedBoolean, true); + scope.publishInterface(providedBoolean, true); ProvidedInterface providedString = new DefaultProvidedInterface( "janse", String.class); assertTrue(required.get(1).implementedBy(providedString)); required.get(1).setProvider(providedString); - _scope.publishInterface(providedString, "hello"); + scope.publishInterface(providedString, "hello"); ProvidedInterface providedInt = new DefaultProvidedInterface("xxx", Integer.class); assertTrue(required.get(2).implementedBy(providedInt)); required.get(2).setProvider(providedInt); - _scope.publishInterface(providedInt, 100); + scope.publishInterface(providedInt, 100); X9 obj = new X9(); assertNull(obj.getValue()); assertNull(obj.getXyz()); assertFalse(obj.isFlag()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getValue()); assertEquals(100, obj.getXyz().intValue()); assertTrue(obj.isFlag()); @@ -141,18 +141,18 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); - _scope.publishInterface(provided0, "hello"); + scope.publishInterface(provided0, "hello"); ProvidedInterface provided1 = new DefaultProvidedInterface("port", Integer.class); required.get(1).setProvider(provided1); - _scope.publishInterface(provided1, 10); + scope.publishInterface(provided1, 10); X6 obj = new X6(); assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getHost()); assertEquals(10, obj.getPort().intValue()); } @@ -166,13 +166,13 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided); - _scope.publishInterface(provided, "hello"); + scope.publishInterface(provided, "hello"); final X6 obj = new X6(); AssertionUtils.assertException(new AssertionUtils.ErroneousCode() { @Override public void run() throws Exception { - config.inject(_scope, obj); + config.inject(scope, obj); } }, IllegalArgumentException.class); } @@ -186,7 +186,7 @@ public class SetterConfigurationTest extends AdapterTestCase { X5 obj = new X5(); assertNull(obj.getValue()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("bladibla", obj.getValue()); } @@ -201,7 +201,7 @@ public class SetterConfigurationTest extends AdapterTestCase { assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertNull(obj.getHost()); assertNull(obj.getPort()); @@ -218,13 +218,13 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); - _scope.publishInterface(provided0, "hello"); + scope.publishInterface(provided0, "hello"); X6 obj = new X6(); assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getHost()); assertNull(obj.getPort()); } @@ -240,13 +240,13 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); - _scope.publishInterface(provided0, "hello"); + scope.publishInterface(provided0, "hello"); X6 obj = new X6(); assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getHost()); assertNull(obj.getPort()); } @@ -307,13 +307,13 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); - _scope.publishInterface(provided0, "hello"); + scope.publishInterface(provided0, "hello"); X6 obj = new X6(); assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getHost()); assertNull(obj.getPort()); } @@ -329,13 +329,13 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); - _scope.publishInterface(provided0, "hello"); + scope.publishInterface(provided0, "hello"); X6 obj = new X6(); assertNull(obj.getHost()); assertNull(obj.getPort()); - config.inject(_scope, obj); + config.inject(scope, obj); assertEquals("hello", obj.getHost()); assertNull(obj.getPort()); } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X4.java b/system/general/src/test/java/org/wamblee/system/adapters/X4.java index 8d086a8b..8471ca97 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X4.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X4.java @@ -17,14 +17,14 @@ package org.wamblee.system.adapters; public class X4 { - private X1 _x1; + private X1 x1; public X4(X1 aX1) { AdapterTestCase.EVENT_TRACKER.eventOccurred("x4(x1)"); - _x1 = aX1; + x1 = aX1; } public X1 getX1() { - return _x1; + return x1; } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X5.java b/system/general/src/test/java/org/wamblee/system/adapters/X5.java index c0a82449..c411b59e 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X5.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X5.java @@ -17,8 +17,8 @@ package org.wamblee.system.adapters; public class X5 { - private String _value; - private Integer _xyz; + private String value; + private Integer xyz; public X5() { @@ -26,11 +26,11 @@ public class X5 { public void setValue(String aValue) { AdapterTestCase.EVENT_TRACKER.eventOccurred("x5.setValue(" + aValue + ")"); - _value = aValue; + value = aValue; } public String getValue() { - return _value; + return value; } public void doSomething() { @@ -38,10 +38,10 @@ public class X5 { } private void setXyz(int aXyz) { - _xyz = aXyz; + xyz = aXyz; } public Integer getXyz() { - return _xyz; + return xyz; } } \ No newline at end of file diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X6.java b/system/general/src/test/java/org/wamblee/system/adapters/X6.java index 06b7b5f5..9535b358 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X6.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X6.java @@ -17,26 +17,26 @@ package org.wamblee.system.adapters; public class X6 { - private String _host; - private Integer _port; + private String host; + private Integer port; public X6() { } public Integer getPort() { - return _port; + return port; } public void setPort(Integer aPort) { - _port = aPort; + port = aPort; } public String getHost() { - return _host; + return host; } public void setHost(String aHost) { - _host = aHost; + host = aHost; } } \ No newline at end of file diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X7.java b/system/general/src/test/java/org/wamblee/system/adapters/X7.java index 50520183..390011d4 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X7.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X7.java @@ -17,31 +17,31 @@ package org.wamblee.system.adapters; public class X7 { - private String _host; - private Integer _port; - private Boolean _boolean; + private String host; + private Integer port; + private Boolean flag; public X7(Boolean aBoolean) { - _boolean = aBoolean; + flag = aBoolean; } public Boolean getBoolean() { - return _boolean; + return flag; } public Integer getPort() { - return _port; + return port; } public void setPort(Integer aPort) { - _port = aPort; + port = aPort; } public String getHost() { - return _host; + return host; } public void setHost(String aHost) { - _host = aHost; + host = aHost; } } \ No newline at end of file diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X8.java b/system/general/src/test/java/org/wamblee/system/adapters/X8.java index 84b450f1..ebfedc37 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X8.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X8.java @@ -17,24 +17,24 @@ package org.wamblee.system.adapters; public class X8 { - private X1 _x1; - private X4 _x4; + private X1 x1; + private X4 x4; public X8(X1 aX1) { AdapterTestCase.EVENT_TRACKER.eventOccurred("x8(x1)"); - _x1 = aX1; + x1 = aX1; } public void setX4(X4 aX4) { AdapterTestCase.EVENT_TRACKER.eventOccurred("x8.setX4(x4)"); - _x4 = aX4; + x4 = aX4; } public X4 getX4() { - return _x4; + return x4; } public X1 getX1() { - return _x1; + return x1; } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X9.java b/system/general/src/test/java/org/wamblee/system/adapters/X9.java index 6b30541a..d11a7cb5 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X9.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X9.java @@ -2,17 +2,17 @@ package org.wamblee.system.adapters; public class X9 extends X5 { - private boolean _flag; + private boolean flag; public X9() { } public boolean isFlag() { - return _flag; + return flag; } public void setFlag(boolean aFlag) { - _flag = aFlag; + flag = aFlag; } } diff --git a/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java b/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java index afcc581a..10e67958 100644 --- a/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java +++ b/system/general/src/test/java/org/wamblee/system/components/DatabaseComponent.java @@ -29,36 +29,36 @@ public class DatabaseComponent extends AbstractComponent { private static ProvidedInterface DB_PROPS = new DefaultProvidedInterface("dbProps", Properties.class); - private Database _database; + private Database database; public DatabaseComponent(String aName, Database aDatabase) { super(aName); - _database = aDatabase; + database = aDatabase; addProvidedInterface(DB_PROPS); } @Override protected Database doStart(Scope aScope) { - _database.start(); + database.start(); Properties props = new Properties(); - if ( _database instanceof DerbyDatabase ) { + if ( database instanceof DerbyDatabase ) { props.put("database.type", DatabaseType.DERBY.toString()); } else { - throw new IllegalArgumentException("Unknown database type " + _database); + throw new IllegalArgumentException("Unknown database type " + database); } - //props.put("database.driver", _database.getDriverClassName()); - props.put("database.url", _database.getJdbcUrl()); - props.put("database.username", _database.getUsername()); - props.put("database.password", _database.getPassword()); + //props.put("database.driver", database.getDriverClassName()); + props.put("database.url", database.getJdbcUrl()); + props.put("database.username", database.getUsername()); + props.put("database.password", database.getPassword()); addInterface(DB_PROPS, props, aScope); - return _database; + return database; } @Override protected void doStop(Database aRuntime) { - _database.stop(); + database.stop(); } } diff --git a/system/general/src/test/java/org/wamblee/system/container/Application.java b/system/general/src/test/java/org/wamblee/system/container/Application.java index 9392974f..e6b09215 100644 --- a/system/general/src/test/java/org/wamblee/system/container/Application.java +++ b/system/general/src/test/java/org/wamblee/system/container/Application.java @@ -36,10 +36,10 @@ public class Application extends AbstractComponent { return required(aOptional, ""); } - private EventTracker _tracker; - private String _string; - private Integer _integer; - private double _random; + private EventTracker tracker; + private String string; + private Integer integer; + private double random; public Application() { this("application"); @@ -52,7 +52,7 @@ public class Application extends AbstractComponent { public Application(String aName, String aPrefix) { super(aName, new ProvidedInterface[0], required(false, aPrefix)); - _random = Math.random(); + random = Math.random(); } public Application(boolean aIsOptinal) { @@ -61,40 +61,40 @@ public class Application extends AbstractComponent { public Application(EventTracker aTracker) { this(); - _tracker = aTracker; + tracker = aTracker; } @Override public Object doStart(Scope aScope) { track("start." + getName()); - _string = aScope.getInterfaceImplementation(getRequiredInterfaces() + string = aScope.getInterfaceImplementation(getRequiredInterfaces() .get(0).getProvider(), String.class); - _integer = aScope.getInterfaceImplementation(getRequiredInterfaces() + integer = aScope.getInterfaceImplementation(getRequiredInterfaces() .get(1).getProvider(), Integer.class); - return _random; + return random; } public String getString() { - return _string; + return string; } public Integer getInteger() { - return _integer; + return integer; } @Override public void doStop(Object aRuntime) { track("stop." + getName()); - if (_random != (Double) aRuntime) { + if (random != (Double) aRuntime) { throw new IllegalArgumentException("Wrong runtime: expected " - + _random + " but got " + aRuntime); + + random + " but got " + aRuntime); } } private void track(String aString) { - if (_tracker == null) { + if (tracker == null) { return; } - _tracker.eventOccurred(aString); + tracker.eventOccurred(aString); } } diff --git a/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java b/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java index a7589fe4..bda07b21 100644 --- a/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java +++ b/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java @@ -37,12 +37,12 @@ import org.wamblee.test.EventTracker; public class ContainerTest extends TestCase { - private EventTracker _tracker; + private EventTracker tracker; @Override protected void setUp() throws Exception { super.setUp(); - _tracker = new EventTracker(); + tracker = new EventTracker(); } private static class MyMultiple implements Serializable, Runnable { @@ -63,15 +63,15 @@ public class ContainerTest extends TestCase { } public void testEnvironmentApplication() { - Environment environment = new Environment(_tracker); - Application application = new Application(_tracker); + Environment environment = new Environment(tracker); + Application application = new Application(tracker); Container container = new Container("root", new Component[] { environment, application }, new ProvidedInterface[0], new RequiredInterface[0]); Scope scope = container.start(); assertTrue(container.isSealed()); AssertionUtils.assertEquals(new String[] { "start.environment", - "start.application" }, _tracker.getEvents( + "start.application" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); assertEquals(0, scope.getProvidedInterfaces().size()); @@ -81,14 +81,14 @@ public class ContainerTest extends TestCase { } public void testEnvironmentApplicationSimpleConstructor() { - Environment environment = new Environment(_tracker); - Application application = new Application(_tracker); + Environment environment = new Environment(tracker); + Application application = new Application(tracker); Container container = new Container("root").addComponent(environment) .addComponent(application); Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "start.environment", - "start.application" }, _tracker.getEvents( + "start.application" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); assertEquals(0, scope.getProvidedInterfaces().size()); @@ -113,9 +113,9 @@ public class ContainerTest extends TestCase { } public void testComposite() { - Component environment = new Environment(_tracker); - Component application = new Application(_tracker); - assertEquals(0, _tracker.getEventCount()); + Component environment = new Environment(tracker); + Component application = new Application(tracker); + assertEquals(0, tracker.getEventCount()); Container system = new Container("all", new Component[] { environment, application }, new ProvidedInterface[0], @@ -127,13 +127,13 @@ public class ContainerTest extends TestCase { assertEquals(0, provided.size()); AssertionUtils.assertEquals(new String[] { "start.environment", - "start.application" }, _tracker.getEvents( + "start.application" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); - _tracker.clear(); + tracker.clear(); system.stop(runtime); AssertionUtils.assertEquals(new String[] { "stop.application", - "stop.environment" }, _tracker + "stop.environment" }, tracker .getEvents(Thread.currentThread()).toArray(new String[0])); } @@ -276,7 +276,7 @@ public class ContainerTest extends TestCase { public void testEnvironmentApplicationRollbackOnException() throws Exception { - Environment environment = new Environment(_tracker); + Environment environment = new Environment(tracker); Application application = new Application() { @Override public Object doStart(Scope aScope) { @@ -292,7 +292,7 @@ public class ContainerTest extends TestCase { container.start(); } catch (RuntimeException e) { AssertionUtils.assertEquals(new String[] { "start.environment", - "stop.environment" }, _tracker.getEvents( + "stop.environment" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); return; } @@ -302,7 +302,7 @@ public class ContainerTest extends TestCase { public void testEnvironmentApplicationRollbackOnExceptionWithExceptionOnStop() throws Exception { - Environment environment = new Environment(_tracker); + Environment environment = new Environment(tracker); // Application 1 will throw an exception while stopping. Application application1 = new Application("app1") { @Override @@ -326,7 +326,7 @@ public class ContainerTest extends TestCase { container.start(); } catch (RuntimeException e) { AssertionUtils.assertEquals(new String[] { "start.environment", - "stop.environment" }, _tracker.getEvents( + "stop.environment" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); return; } @@ -542,7 +542,7 @@ public class ContainerTest extends TestCase { } public void testProvidedInterfaces() { - Environment env = new Environment(_tracker); + Environment env = new Environment(tracker); Container envcontainer = new Container("0").addComponent(env) .addProvidedInterface( new DefaultProvidedInterface("string", String.class)) @@ -551,21 +551,21 @@ public class ContainerTest extends TestCase { Scope scope = envcontainer.start(); AssertionUtils.assertEquals(new String[] { "start.environment" }, - _tracker.getEvents(Thread.currentThread()).toArray( + tracker.getEvents(Thread.currentThread()).toArray( new String[0])); envcontainer.stop(scope); } public void testCoupleTwoContainers() { - Environment env = new Environment(_tracker); + Environment env = new Environment(tracker); Container envcontainer = new Container("0").addComponent(env) .addProvidedInterface( new DefaultProvidedInterface("string", String.class)) .addProvidedInterface( new DefaultProvidedInterface("integer", Integer.class)); - Application app = new Application(_tracker); + Application app = new Application(tracker); Container appcontainer = new Container("1").addComponent(app) .addRequiredInterface( new DefaultRequiredInterface("string", String.class)) @@ -577,7 +577,7 @@ public class ContainerTest extends TestCase { top.start(); AssertionUtils.assertEquals(new String[] { "start.environment", - "start.application" }, _tracker.getEvents( + "start.application" }, tracker.getEvents( Thread.currentThread()).toArray(new String[0])); } diff --git a/system/general/src/test/java/org/wamblee/system/core/Environment.java b/system/general/src/test/java/org/wamblee/system/core/Environment.java index 4b791d05..c202d1ab 100644 --- a/system/general/src/test/java/org/wamblee/system/core/Environment.java +++ b/system/general/src/test/java/org/wamblee/system/core/Environment.java @@ -33,9 +33,9 @@ public class Environment extends AbstractComponent { private static int COUNT = 0; - private EventTracker _tracker; - private double _random; - private int _integer; + private EventTracker tracker; + private double random; + private int integer; public Environment() { this("environment"); @@ -47,19 +47,19 @@ public class Environment extends AbstractComponent { public Environment(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); - _random = Math.random(); - _integer = COUNT++; + random = Math.random(); + integer = COUNT++; } public Environment(EventTracker aTracker) { this(); - _tracker = aTracker; + tracker = aTracker; } public Integer getInteger() { - return _integer; + return integer; } public String getString() { @@ -71,22 +71,22 @@ public class Environment extends AbstractComponent { addInterface(getProvidedInterfaces().get(0), getString(), aScope); addInterface(getProvidedInterfaces().get(1), getInteger(), aScope); track("start." + getName()); - return _random; + return random; } @Override protected void doStop(Object aRuntime) { track("stop." + getName()); - if (_random != (Double) aRuntime) { + if (random != (Double) aRuntime) { throw new IllegalArgumentException("Wrong runtime: expected " - + _random + " but got " + aRuntime); + + random + " but got " + aRuntime); } } private void track(String aString) { - if (_tracker == null) { + if (tracker == null) { return; } - _tracker.eventOccurred(aString); + tracker.eventOccurred(aString); } } diff --git a/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java b/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java index acf683fe..23685e4e 100644 --- a/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java +++ b/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java @@ -30,8 +30,8 @@ public class IntegerComponent extends AbstractComponent { new DefaultProvidedInterface(aPrefix + "integer", Integer.class) }; } - private EventTracker _tracker; - private double _random; + private EventTracker tracker; + private double random; public IntegerComponent() { this("environment"); @@ -43,14 +43,14 @@ public class IntegerComponent extends AbstractComponent { public IntegerComponent(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); - _random = Math.random(); + random = Math.random(); } public IntegerComponent(EventTracker aTracker) { this(); - _tracker = aTracker; + tracker = aTracker; } public Integer getInteger() { @@ -61,22 +61,22 @@ public class IntegerComponent extends AbstractComponent { protected Object doStart(Scope aScope) { addInterface(getProvidedInterfaces().get(1), getInteger(), aScope); track("start." + getName()); - return _random; + return random; } @Override protected void doStop(Object aRuntime) { track("stop." + getName()); - if (_random != (Double) aRuntime) { + if (random != (Double) aRuntime) { throw new IllegalArgumentException("Wrong runtime: expected " - + _random + " but got " + aRuntime); + + random + " but got " + aRuntime); } } private void track(String aString) { - if (_tracker == null) { + if (tracker == null) { return; } - _tracker.eventOccurred(aString); + tracker.eventOccurred(aString); } } diff --git a/system/general/src/test/java/org/wamblee/system/core/StringComponent.java b/system/general/src/test/java/org/wamblee/system/core/StringComponent.java index 7701c20b..a55d68de 100644 --- a/system/general/src/test/java/org/wamblee/system/core/StringComponent.java +++ b/system/general/src/test/java/org/wamblee/system/core/StringComponent.java @@ -30,8 +30,8 @@ public class StringComponent extends AbstractComponent { new DefaultProvidedInterface(aPrefix + "datasource", String.class) }; } - private EventTracker _tracker; - private double _random; + private EventTracker tracker; + private double random; public StringComponent() { this("environment"); @@ -43,14 +43,14 @@ public class StringComponent extends AbstractComponent { public StringComponent(String aName, String aPrefix) { super(aName, provided(aPrefix), new RequiredInterface[0]); - _random = Math.random(); + random = Math.random(); } public StringComponent(EventTracker aTracker) { this(); - _tracker = aTracker; + tracker = aTracker; } public Integer getInteger() { @@ -65,22 +65,22 @@ public class StringComponent extends AbstractComponent { protected Object doStart(Scope aScope) { addInterface(getProvidedInterfaces().get(0), getString(), aScope); track("start." + getName()); - return _random; + return random; } @Override protected void doStop(Object aRuntime) { track("stop." + getName()); - if (_random != (Double) aRuntime) { + if (random != (Double) aRuntime) { throw new IllegalArgumentException("Wrong runtime: expected " - + _random + " but got " + aRuntime); + + random + " but got " + aRuntime); } } private void track(String aString) { - if (_tracker == null) { + if (tracker == null) { return; } - _tracker.eventOccurred(aString); + tracker.eventOccurred(aString); } } diff --git a/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java b/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java index c76ff97e..96fd009a 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java +++ b/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java @@ -28,8 +28,8 @@ import org.wamblee.system.graph.component.ProvidedInterfaceNode; import org.wamblee.system.graph.component.RequiredInterfaceNode; public class CompositeEdgeFilterTest extends TestCase { - private Application _app = new Application(); - private Environment _env = new Environment(); + private Application app = new Application(); + private Environment env = new Environment(); private Edge createEdge(Component aClient, RequiredInterface aRequired, Component aServer, ProvidedInterface aProvided) { @@ -40,8 +40,8 @@ public class CompositeEdgeFilterTest extends TestCase { public void testEmpty() { EdgeFilter restriction = new CompositeEdgeFilter(); - assertFalse(restriction.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertFalse(restriction.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); } private void configureRestriction(EdgeFilter base, boolean aResult) { @@ -57,14 +57,14 @@ public class CompositeEdgeFilterTest extends TestCase { configureRestriction(base, false); - assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertFalse(composite.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); // Second let the base return true and verify the result. configureRestriction(base, true); - assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertTrue(composite.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); } @@ -80,22 +80,22 @@ public class CompositeEdgeFilterTest extends TestCase { configureRestriction(base1, false); configureRestriction(base2, false); - assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertFalse(composite.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); // 2. base 1 not violated but base 2 violated -> violated configureRestriction(base1, false); configureRestriction(base2, true); - assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertTrue(composite.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); // 3. base 1 violated -> violated and base 2 not called. configureRestriction(base1, true); // base 2 should not be called. - assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0), - _env, _env.getProvidedInterfaces().get(0)))); + assertTrue(composite.isViolated(createEdge(app, app.getRequiredInterfaces().get(0), + env, env.getProvidedInterfaces().get(0)))); } } diff --git a/system/general/src/test/java/org/wamblee/system/graph/MyNode.java b/system/general/src/test/java/org/wamblee/system/graph/MyNode.java index 0090c3f9..9b5e2e46 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/MyNode.java +++ b/system/general/src/test/java/org/wamblee/system/graph/MyNode.java @@ -17,14 +17,14 @@ package org.wamblee.system.graph; public class MyNode extends DefaultNode { - private String[] _ports; + private String[] ports; public MyNode(String aName, String[] aPorts) { super(aName); - _ports = aPorts; + ports = aPorts; } public String[] getPorts() { - return _ports; + return ports; } } diff --git a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java index 5f45f551..eb4deaff 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java +++ b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java @@ -28,64 +28,64 @@ import org.wamblee.system.graph.EdgeFilter; public class ConnectExternalProvidedProvidedEdgeFilterTest extends TestCase { - private Container _container; - private Component _internal; - private String _externalInterfaceName; - private String _internalComponentName; - private String _internalInterfaceName; - private Edge _edge; + private Container container; + private Component internal; + private String externalInterfaceName; + private String internalComponentName; + private String internalInterfaceName; + private Edge edge; @Override protected void setUp() throws Exception { - _container = new Container("container") + container = new Container("container") .addProvidedInterface(new DefaultProvidedInterface("string", String.class)); - _internal = new Environment("env1"); + internal = new Environment("env1"); - _externalInterfaceName = _container.getProvidedInterfaces().get(0) + externalInterfaceName = container.getProvidedInterfaces().get(0) .getName(); - _internalComponentName = _internal.getName(); - _internalInterfaceName = _internal.getProvidedInterfaces().get(0).getName(); + internalComponentName = internal.getName(); + internalInterfaceName = internal.getProvidedInterfaces().get(0).getName(); - _edge = new DefaultEdge(new ExternalProvidedInterfaceNode(_container, - _container.getProvidedInterfaces().get(0)), - new ProvidedInterfaceNode(_internal, _internal + edge = new DefaultEdge(new ExternalProvidedInterfaceNode(container, + container.getProvidedInterfaces().get(0)), + new ProvidedInterfaceNode(internal, internal .getProvidedInterfaces().get(0))); } public void testWrongExternal() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( - _externalInterfaceName + "x", _internalComponentName, - _internalInterfaceName); - assertFalse(filter.isViolated(_edge)); + externalInterfaceName + "x", internalComponentName, + internalInterfaceName); + assertFalse(filter.isViolated(edge)); } public void testRightExternalWrongComponent() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( - _externalInterfaceName, _internalComponentName + "x", - _internalInterfaceName); - assertTrue(filter.isViolated(_edge)); + externalInterfaceName, internalComponentName + "x", + internalInterfaceName); + assertTrue(filter.isViolated(edge)); } public void testRightExternalWrongInternal() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( - _externalInterfaceName, _internalComponentName, - _internalInterfaceName + "x"); - assertTrue(filter.isViolated(_edge)); + externalInterfaceName, internalComponentName, + internalInterfaceName + "x"); + assertTrue(filter.isViolated(edge)); } public void testEverythingRight() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( - _externalInterfaceName, _internalComponentName, - _internalInterfaceName); - assertFalse(filter.isViolated(_edge)); + externalInterfaceName, internalComponentName, + internalInterfaceName); + assertFalse(filter.isViolated(edge)); } public void testWrongEdgeType() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( - _externalInterfaceName, _internalComponentName, - _internalInterfaceName); + externalInterfaceName, internalComponentName, + internalInterfaceName); DefaultEdge edge = new DefaultEdge(new DefaultNode("x"), new DefaultNode("y")); assertFalse(filter.isViolated(edge)); diff --git a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java index 7e8e02ce..bca6303a 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java +++ b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java @@ -29,58 +29,58 @@ import org.wamblee.system.graph.Node; public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase { - private Component _comp; - private Container _container; - private Edge _edge; + private Component comp; + private Container container; + private Edge edge; @Override protected void setUp() throws Exception { - _comp = new Application(); - _container = new Container("container") + comp = new Application(); + container = new Container("container") .addRequiredInterface(new DefaultRequiredInterface("x", String.class)); - Node req = new RequiredInterfaceNode(_comp, _comp + Node req = new RequiredInterfaceNode(comp, comp .getRequiredInterfaces().get(0)); - Node external = new ExternalRequiredInterfaceNode(_container, - _container.getRequiredInterfaces().get(0)); - _edge = new DefaultEdge(req, external); + Node external = new ExternalRequiredInterfaceNode(container, + container.getRequiredInterfaces().get(0)); + edge = new DefaultEdge(req, external); } public void testRightComponentRightInterface() { EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( - _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(), - _container.getRequiredInterfaces().get(0).getName()); - assertFalse(filter.isViolated(_edge)); + comp.getName(), comp.getRequiredInterfaces().get(0).getName(), + container.getRequiredInterfaces().get(0).getName()); + assertFalse(filter.isViolated(edge)); } public void testWrongInterface() { EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( - _comp.getName(), _comp.getRequiredInterfaces().get(0).getName() - + "xx", _container.getRequiredInterfaces().get(0).getName()); - assertFalse(filter.isViolated(_edge)); + comp.getName(), comp.getRequiredInterfaces().get(0).getName() + + "xx", container.getRequiredInterfaces().get(0).getName()); + assertFalse(filter.isViolated(edge)); } public void testWrongComponent() { EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( - _comp.getName() + "xx", _comp.getRequiredInterfaces().get(0) - .getName(), _container.getRequiredInterfaces().get(0) + comp.getName() + "xx", comp.getRequiredInterfaces().get(0) + .getName(), container.getRequiredInterfaces().get(0) .getName()); - assertFalse(filter.isViolated(_edge)); + assertFalse(filter.isViolated(edge)); } public void testWrongExternalInterface() { EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( - _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(), - _container.getRequiredInterfaces().get(0).getName() + "xx"); - assertTrue(filter.isViolated(_edge)); + comp.getName(), comp.getRequiredInterfaces().get(0).getName(), + container.getRequiredInterfaces().get(0).getName() + "xx"); + assertTrue(filter.isViolated(edge)); } public void testWrongEdgeType() { DefaultEdge edge = new DefaultEdge(new DefaultNode("x"), new DefaultNode("y")); EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( - _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(), - _container.getRequiredInterfaces().get(0).getName()); + comp.getName(), comp.getRequiredInterfaces().get(0).getName(), + container.getRequiredInterfaces().get(0).getName()); assertFalse(filter.isViolated(edge)); } } diff --git a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java index 0cb9013b..88f29b8d 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java +++ b/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java @@ -31,11 +31,11 @@ import junit.framework.TestCase; public class ConnectRequiredProvidedEdgeFilterTest extends TestCase { - private Application _app1 = new Application("app1", "pf1."); - private Application _app2 = new Application("app2", "pf2."); + private Application app1 = new Application("app1", "pf1."); + private Application app2 = new Application("app2", "pf2."); - private Environment _env1 = new Environment("env1", "pf3."); - private Environment _env2 = new Environment("env2", "pf4."); + private Environment env1 = new Environment("env1", "pf3."); + private Environment env2 = new Environment("env2", "pf4."); private void compare(Boolean[] aExpected, EdgeFilter aRestriction) { @@ -48,8 +48,8 @@ public class ConnectRequiredProvidedEdgeFilterTest extends TestCase { // env1, app2 // env2, app1 // env2, app2 - for (Environment env: new Environment[] { _env1, _env2} ) { - for (Application app: new Application[] { _app1, _app2} ) { + for (Environment env: new Environment[] { env1, env2} ) { + for (Application app: new Application[] { app1, app2} ) { Node from = new RequiredInterfaceNode( app, app.getRequiredInterfaces().get(0)); Node to = new ProvidedInterfaceNode( @@ -90,10 +90,10 @@ public class ConnectRequiredProvidedEdgeFilterTest extends TestCase { } public void testExplicitConfig() { - _app1 = new Application("app1"); - _app2 = new Application("app2"); - _env1 = new Environment("env1"); - _env2 = new Environment("env2"); + app1 = new Application("app1"); + app2 = new Application("app2"); + env1 = new Environment("env1"); + env2 = new Environment("env2"); EdgeFilter restriction = new ConnectRequiredProvidedEdgeFilter( "app2", "string", "env1", "datasource"); diff --git a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java index 88746a5e..0e4c62eb 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java @@ -46,11 +46,11 @@ public class SpringComponent extends AbstractComponent { static final ThreadLocal THIS = new ThreadLocal(); static final ThreadLocal SCOPE = new ThreadLocal(); - private Properties _properties; - private String[] _configFiles; - private Map _provided; - private Map _required; - private Map _propertyObjects; + private Properties properties; + private String[] configFiles; + private Map provided; + private Map required; + private Map propertyObjects; /** * Constructs a spring system. @@ -73,11 +73,11 @@ public class SpringComponent extends AbstractComponent { Map aRequired) { super(aName, aProvided.values().toArray(new ProvidedInterface[0]), aRequired.keySet().toArray(new RequiredInterface[0])); - _properties = new Properties(); - _configFiles = aConfigFiles; - _provided = aProvided; - _required = aRequired; - _propertyObjects = new HashMap(); + properties = new Properties(); + configFiles = aConfigFiles; + provided = aProvided; + required = aRequired; + propertyObjects = new HashMap(); } @@ -90,7 +90,7 @@ public class SpringComponent extends AbstractComponent { * Property value. */ public void setProperty(String aKey, String aValue) { - _properties.put(aKey, aValue); + properties.put(aKey, aValue); } public void addProperties(Properties aProperties) { @@ -100,11 +100,11 @@ public class SpringComponent extends AbstractComponent { } public void addProperties(String aBeanname, Properties aProperties) { - _propertyObjects.put(aBeanname, aProperties); + propertyObjects.put(aBeanname, aProperties); } public Properties getProperties(String aBeanname) { - return _propertyObjects.get(aBeanname); + return propertyObjects.get(aBeanname); } @Override @@ -128,7 +128,7 @@ public class SpringComponent extends AbstractComponent { AbstractApplicationContext context = parseConfigFiles(parentContext); context - .addBeanFactoryPostProcessor(new PropertySetter(_properties)); + .addBeanFactoryPostProcessor(new PropertySetter(properties)); context.refresh(); exposeProvidedServices(context, aExternalScope); @@ -147,31 +147,31 @@ public class SpringComponent extends AbstractComponent { private void exposeProvidedServices(AbstractApplicationContext aContext, Scope aScope) { // Call addService for each provided service. - for (String name : _provided.keySet()) { + for (String name : provided.keySet()) { Object svc = aContext.getBean(name); if (svc == null) { throw new IllegalArgumentException(getQualifiedName() + ": service '" + name + "' is null"); } - addInterface(_provided.get(name), svc, aScope); - System.out.println("addService " + _provided.get(name) + " " + svc); + addInterface(provided.get(name), svc, aScope); + System.out.println("addService " + provided.get(name) + " " + svc); } } private AbstractApplicationContext parseConfigFiles(GenericApplicationContext aParentContext) { // Parse spring config files - return new ClassPathXmlApplicationContext((String[]) _configFiles, + return new ClassPathXmlApplicationContext((String[]) configFiles, false, aParentContext); } private void registerRequiredServices(GenericApplicationContext aParentContext) { // Register required services in a parent context - for (RequiredInterface required: getRequiredInterfaces()) { - String beanName = _required.get(required); + for (RequiredInterface requiredIntf: getRequiredInterfaces()) { + String beanName = required.get(requiredIntf); if ( beanName != null && beanName.length() > 0) { ConstructorArgumentValues cargs = new ConstructorArgumentValues(); - cargs.addGenericArgumentValue(required.getName()); + cargs.addGenericArgumentValue(requiredIntf.getName()); BeanDefinition definition = new RootBeanDefinition( RequiredServiceBean.class, cargs, new MutablePropertyValues()); @@ -183,9 +183,9 @@ public class SpringComponent extends AbstractComponent { } private void registerPropertyObjects(GenericApplicationContext aParentContext) { - for (String beanName: _propertyObjects.keySet()) { + for (String beanName: propertyObjects.keySet()) { ConstructorArgumentValues cargs = new ConstructorArgumentValues(); - cargs.addGenericArgumentValue(PropertySetter.createPropertyFile(_propertyObjects.get(beanName))); + cargs.addGenericArgumentValue(PropertySetter.createPropertyFile(propertyObjects.get(beanName))); BeanDefinition definition = new RootBeanDefinition( ConfiguredProperties.class, cargs, new MutablePropertyValues()); diff --git a/system/spring/src/test/java/org/wamblee/system/spring/BlaService.java b/system/spring/src/test/java/org/wamblee/system/spring/BlaService.java index 5bbafa1d..5715460a 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/BlaService.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/BlaService.java @@ -16,17 +16,17 @@ package org.wamblee.system.spring; public class BlaService { - private HelloService _hello; + private HelloService hello; public BlaService(HelloService aService) { if ( aService == null ) { throw new IllegalArgumentException("helloService is null"); } - _hello = aService; + hello = aService; } public String execute() { - return _hello.say(); + return hello.say(); } public void stop() { diff --git a/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java b/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java index cfa5bae6..d3b5b121 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java @@ -17,14 +17,14 @@ package org.wamblee.system.spring; public class HelloService { - private String _msg; + private String msg; public HelloService(String aMsg) { SpringComponentTest.EVENT_TRACKER.eventOccurred(aMsg); - _msg = aMsg; + msg = aMsg; } public String say() { - return _msg; + return msg; } } diff --git a/system/spring/src/test/java/org/wamblee/system/spring/HelloService2.java b/system/spring/src/test/java/org/wamblee/system/spring/HelloService2.java index e9c77080..4273ca01 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/HelloService2.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/HelloService2.java @@ -19,13 +19,13 @@ import java.util.Properties; public class HelloService2 { - private Properties _props; + private Properties props; public HelloService2(Properties aProps) { - _props = aProps; + props = aProps; } public Properties getProperties() { - return _props; + return props; } } diff --git a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java index 1cc95c11..ff3aeb24 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java @@ -44,13 +44,13 @@ public class SpringComponentTest extends TestCase { public static EventTracker EVENT_TRACKER; - private Scope _externalScope; + private Scope externalScope; @Override protected void setUp() throws Exception { super.setUp(); EVENT_TRACKER = new EventTracker(); - _externalScope = new DefaultScope(new ProvidedInterface[0]); + externalScope = new DefaultScope(new ProvidedInterface[0]); } public void testBlackboxSystem() { @@ -59,8 +59,8 @@ public class SpringComponentTest extends TestCase { new HashMap(), new HashMap()); - Scope runtime = system.start(_externalScope); - assertEquals(0, _externalScope.getProvidedInterfaces().size()); + Scope runtime = system.start(externalScope); + assertEquals(0, externalScope.getProvidedInterfaces().size()); system.stop(runtime); } @@ -73,7 +73,7 @@ public class SpringComponentTest extends TestCase { SpringComponent system = new SpringComponent("system", new String[] { HELLO_SERVICE_SPRING_XML }, provided, new HashMap()); - Scope runtime = system.start(_externalScope); + Scope runtime = system.start(externalScope); List services = runtime.getProvidedInterfaces(); assertEquals(1, services.size()); @@ -83,7 +83,7 @@ public class SpringComponentTest extends TestCase { // BUG; Provided services should be made available in the external // scope. - Object service2 = _externalScope.getInterfaceImplementation(provided + Object service2 = externalScope.getInterfaceImplementation(provided .get("helloService"), Object.class); assertSame(service, service2); @@ -102,7 +102,7 @@ public class SpringComponentTest extends TestCase { props.load(new ClassPathResource(PROPERTY_FILE).getInputStream()); system.addProperties(props); - Scope scope = system.start(_externalScope); + Scope scope = system.start(externalScope); // BUG: Hello service was constructed multiple times. Once with the // unprocessed property // and another time with the processed property. @@ -123,7 +123,7 @@ public class SpringComponentTest extends TestCase { props.load(new ClassPathResource(PROPERTY_FILE).getInputStream()); system.addProperties("properties", props); - Scope scope = system.start(_externalScope); + Scope scope = system.start(externalScope); List services = scope.getProvidedInterfaces(); @@ -138,7 +138,7 @@ public class SpringComponentTest extends TestCase { new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML }, new HashMap(), new HashMap()); - system.start(_externalScope); + system.start(externalScope); } catch (SystemAssemblyException e) { // e.printStackTrace(); return; @@ -208,7 +208,7 @@ public class SpringComponentTest extends TestCase { new String[] { HELLO_SERVICE_SPRING_XML }, provided, new HashMap()); - Scope runtime = system.start(_externalScope); + Scope runtime = system.start(externalScope); List services = runtime.getProvidedInterfaces(); assertEquals(2, services.size()); @@ -218,11 +218,11 @@ public class SpringComponentTest extends TestCase { // BUG; Provided services should be made available in the external // scope. - Object service2 = _externalScope.getInterfaceImplementation(provided + Object service2 = externalScope.getInterfaceImplementation(provided .get("helloService"), Object.class); assertSame(service, service2); - Object floatsvc = _externalScope.getInterfaceImplementation(system + Object floatsvc = externalScope.getInterfaceImplementation(system .getProvidedInterfaces().get(1), Object.class); assertTrue(floatsvc instanceof Float); assertTrue((((Float) floatsvc).floatValue() - 100.345f) < 0.00001); diff --git a/system/spring/src/test/java/org/wamblee/system/spring/component/DatabaseTesterComponent.java b/system/spring/src/test/java/org/wamblee/system/spring/component/DatabaseTesterComponent.java index b988107b..ac9d6f6f 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/component/DatabaseTesterComponent.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/component/DatabaseTesterComponent.java @@ -73,27 +73,27 @@ public class DatabaseTesterComponent { /** * Cached spring application context. */ - private ApplicationContext _context; + private ApplicationContext context; - private HibernateTemplate _hibernateTemplate; + private HibernateTemplate hibernateTemplate; - private PlatformTransactionManager _transactionManager; + private PlatformTransactionManager transactionManager; - private DataSource _dataSource; + private DataSource dataSource; public DatabaseTesterComponent(HibernateTemplate aHibernateTemplate, PlatformTransactionManager aTransactionManager, DataSource aDataSource) { - _hibernateTemplate = aHibernateTemplate; - _transactionManager = aTransactionManager; - _dataSource = aDataSource; + hibernateTemplate = aHibernateTemplate; + transactionManager = aTransactionManager; + dataSource = aDataSource; } /** * @return Hibernate session factory. */ protected SessionFactory getSessionFactory() { - return _hibernateTemplate.getSessionFactory(); + return hibernateTemplate.getSessionFactory(); } /** @@ -124,7 +124,7 @@ public class DatabaseTesterComponent { * @return Transaction manager */ protected PlatformTransactionManager getTransactionManager() { - return _transactionManager; + return transactionManager; } /** @@ -144,7 +144,7 @@ public class DatabaseTesterComponent { * @return Hibernate template. */ public HibernateTemplate getTemplate() { - return _hibernateTemplate; + return hibernateTemplate; } /** @@ -490,7 +490,7 @@ public class DatabaseTesterComponent { * @return Returns the dataSource. */ public DataSource getDataSource() { - return _dataSource; + return dataSource; } /** diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaCustomizer.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaCustomizer.java index fc6ecc7c..8822a6e4 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaCustomizer.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaCustomizer.java @@ -7,27 +7,27 @@ import org.dbunit.dataset.filter.ITableFilterSimple; public class CompositeJpaCustomizer implements JpaCustomizer { - private List _customizers; - private CompositeJpaTables _tables; + private List customizers; + private CompositeJpaTables tables; public CompositeJpaCustomizer(List aCustomizers) { - _customizers = aCustomizers; - _tables = new CompositeJpaTables(); - for (JpaCustomizer customizer: _customizers) { - _tables.add(customizer.getJpaTables()); + customizers = aCustomizers; + tables = new CompositeJpaTables(); + for (JpaCustomizer customizer: customizers) { + tables.add(customizer.getJpaTables()); } } @Override public void customize(PersistenceUnitDescription aPersistenceUnit, Map aJpaProperties) { - for (JpaCustomizer customizer: _customizers) { + for (JpaCustomizer customizer: customizers) { customizer.customize(aPersistenceUnit, aJpaProperties); } } @Override public ITableFilterSimple getJpaTables() { - return _tables; + return tables; } } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaTables.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaTables.java index 7a7e8de6..a7ff59de 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaTables.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/CompositeJpaTables.java @@ -8,19 +8,19 @@ import org.dbunit.dataset.filter.ITableFilterSimple; public class CompositeJpaTables implements ITableFilterSimple { - private List _tables; + private List tables; public CompositeJpaTables() { - _tables = new ArrayList(); + tables = new ArrayList(); } public void add(ITableFilterSimple aFilter) { - _tables.add(aFilter); + tables.add(aFilter); } @Override public boolean accept(String aTableName) throws DataSetException { - for (ITableFilterSimple filter: _tables) { + for (ITableFilterSimple filter: tables) { if (filter.accept(aTableName)) { return true; } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java index 44294e35..2fe0683a 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java @@ -24,7 +24,7 @@ public class DatabaseStarter { /** * Database class which encapsulates management of the database. */ - private Class _databaseClass; + private Class databaseClass; /** * Execution as a main program. Commandline @@ -64,7 +64,7 @@ public class DatabaseStarter { + aClass.getName( ) + "' is not a subclass of Database" ); } - _databaseClass = aClass; + databaseClass = aClass; } /** @@ -82,7 +82,7 @@ public class DatabaseStarter { * @throws Exception */ public void start( ) throws Exception { - Database lDatabase = (Database) _databaseClass.newInstance( ); + Database lDatabase = (Database) databaseClass.newInstance( ); lDatabase.start( ); System.out.println( "Database has been started. " ); System.out.println( );