From dec278a67997ea8e85d10662e31548afd8890ed3 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 17 Jul 2010 12:10:54 +0000 Subject: [PATCH] code style improvements. --- TODO.txt | 12 +++---- support/cdi/.classpath | 4 +-- .../cdi/.settings/org.eclipse.jdt.core.prefs | 2 +- .../adapters/ConstructorConfiguration.java | 5 ++- .../system/adapters/SetterConfiguration.java | 34 ++++++------------- .../system/core/AbstractComponent.java | 16 ++++----- .../org/wamblee/system/core/DefaultScope.java | 5 ++- .../system/core/ProvidedInterface.java | 1 - .../java/org/wamblee/system/graph/Graph.java | 8 ++--- .../ConnectRequiredProvidedEdgeFilter.java | 12 +++---- .../system/graph/component/LinkVisitor.java | 1 - .../system/graph/component/package-info.java | 3 -- .../system/adapters/ObjectAdapterTest.java | 6 ---- .../system/container/ContainerTest.java | 12 +++---- .../org/wamblee/system/core/Environment.java | 7 ---- .../wamblee/system/core/IntegerComponent.java | 7 ---- .../wamblee/system/core/StringComponent.java | 7 ---- ...xternalProvidedProvidedEdgeFilterTest.java | 4 +-- ...uiredExternallyRequiredEdgeFilterTest.java | 4 +-- .../wamblee/system/spring/PropertySetter.java | 6 ++-- .../spring/component/DatasourceComponent.java | 16 +++------ .../spring/component/HibernateComponent.java | 21 ++++-------- 22 files changed, 59 insertions(+), 134 deletions(-) diff --git a/TODO.txt b/TODO.txt index 9efb3863..24837472 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,21 +1,17 @@ - -* Styling of the site based on http://svn.apache.org/repos/asf/maven/skins/tags/maven-stylus-skin-1.2 +* Add and test the JtaRequestCycle. +* Rename packages under test to org.wamblee.test.general/persistence/jndi +* Add JTA testing support to the test lib. * DatabaseUtils: deletion of tables must be more generic First drop all constraints then drop all tables. Or use JPA to drop the tables but that is a short-term solution -* Get rid of use of detached objects in security - - Use only basic types in UserAdministration - - Put API in separate package -* add cdi subproject + * update mythtv project for java ee 6 * reimplement photos application using wicket * change tracking for all projects with changes plugin -* complete presentation of all wamblee stuff on wamblee.org. -* maven sites for each subproject accessible through wamblee.org * overview pages for separate areas * create user mgt application diff --git a/support/cdi/.classpath b/support/cdi/.classpath index 845a6b53..7c3d14f8 100644 --- a/support/cdi/.classpath +++ b/support/cdi/.classpath @@ -1,9 +1,9 @@ - + - + diff --git a/support/cdi/.settings/org.eclipse.jdt.core.prefs b/support/cdi/.settings/org.eclipse.jdt.core.prefs index dda55440..c3ed9b62 100644 --- a/support/cdi/.settings/org.eclipse.jdt.core.prefs +++ b/support/cdi/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Wed Jul 14 20:45:46 CEST 2010 +#Sat Jul 17 14:01:46 CEST 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 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 b0057b5b..874d7951 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 @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.system.adapters; import org.wamblee.collections.CollectionFilter; @@ -121,9 +121,8 @@ public class ConstructorConfiguration { public boolean matches(Constructor aObject) { if (!publicOnly) { return true; - } else { - return Modifier.isPublic(aObject.getModifiers()); } + return Modifier.isPublic(aObject.getModifiers()); } }); 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 fffd828c..7c7adda3 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 @@ -15,34 +15,20 @@ */ package org.wamblee.system.adapters; -import org.wamblee.collections.CollectionFilter; - -import org.wamblee.conditions.Condition; -import org.wamblee.conditions.FixedCondition; - -import org.wamblee.general.Pair; - -import org.wamblee.reflection.ReflectionUtils; - -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.DefaultRequiredInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; -import org.wamblee.system.core.Scope; -import org.wamblee.system.core.SystemAssemblyException; - -import java.awt.CompositeContext; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; - import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; + +import org.wamblee.collections.CollectionFilter; +import org.wamblee.conditions.Condition; +import org.wamblee.reflection.ReflectionUtils; +import org.wamblee.system.core.RequiredInterface; +import org.wamblee.system.core.Scope; +import org.wamblee.system.core.SystemAssemblyException; /** * Represents the configuration for exposing the setters of a class as required @@ -221,15 +207,15 @@ public class SetterConfiguration { } if (result.size() > 1) { - StringBuffer setters = new StringBuffer(); + StringBuffer settersString = new StringBuffer(); for (Method method : result) { - setters.append((method.getName() + " ")); + settersString.append((method.getName() + " ")); } throw new IllegalArgumentException( "Multiple setters found in class '" + clazz.getName() + - " that accept type '" + aType.getName() + "': " + setters); + " that accept type '" + aType.getName() + "': " + settersString); } Method method = result.get(0); 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 1bf835a8..c7145cdf 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 @@ -157,9 +157,9 @@ public abstract class AbstractComponent implements Component { if (remaining.get().size() > 0) { StringBuffer notProvided = new StringBuffer(); - for (ProvidedInterface provided : remaining.get()) { + for (ProvidedInterface providedIntf : remaining.get()) { notProvided.append("\nComponent " + getQualifiedName() + - " did not start interface " + provided); + " did not start interface " + providedIntf); } throw new SystemAssemblyException(notProvided.toString()); @@ -218,9 +218,9 @@ public abstract class AbstractComponent implements Component { } public ProvidedInterface findProvidedInterface(String aName) { - for (ProvidedInterface provided : getProvidedInterfaces()) { - if (provided.getName().equals(aName)) { - return provided; + for (ProvidedInterface providedIntf : getProvidedInterfaces()) { + if (providedIntf.getName().equals(aName)) { + return providedIntf; } } @@ -228,9 +228,9 @@ public abstract class AbstractComponent implements Component { } public RequiredInterface findRequiredInterface(String aName) { - for (RequiredInterface required : getRequiredInterfaces()) { - if (required.getName().equals(aName)) { - return required; + for (RequiredInterface requiredIntf : getRequiredInterfaces()) { + if (requiredIntf.getName().equals(aName)) { + return requiredIntf; } } 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 e0de6790..d3f62a7b 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 @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.system.core; import java.util.ArrayList; @@ -132,8 +132,7 @@ public class DefaultScope implements Scope { } return null; - } else { - return providedIntf.getImplementation(aType); } + return providedIntf.getImplementation(aType); } } diff --git a/system/general/src/main/java/org/wamblee/system/core/ProvidedInterface.java b/system/general/src/main/java/org/wamblee/system/core/ProvidedInterface.java index 86875115..b40011a5 100644 --- a/system/general/src/main/java/org/wamblee/system/core/ProvidedInterface.java +++ b/system/general/src/main/java/org/wamblee/system/core/ProvidedInterface.java @@ -15,7 +15,6 @@ */ package org.wamblee.system.core; -import java.util.Collection; /** * Represents an interface provided by a component. Different component objects 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 1fe3fcfd..d01bc405 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 @@ -262,17 +262,17 @@ public class Graph { * Visitor. */ public void accept(Visitor aVisitor) { - List nodes = getNodes(); // copy to make sure the visitor can + List allNodes = getNodes(); // copy to make sure the visitor can // modify the // list of nodes as part of the loop. - List edges = getEdges(); // copy ..... (see above). + List allEdges = getEdges(); // copy ..... (see above). - for (Node node : nodes) { + for (Node node : allNodes) { aVisitor.visitNode(node); } - for (Edge edge : edges) { + for (Edge edge : allEdges) { aVisitor.visitEdge(edge); } } 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 a2f91877..4984b7d8 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 @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.system.graph.component; import org.wamblee.system.graph.Edge; @@ -76,13 +76,11 @@ public class ConnectRequiredProvidedEdgeFilter implements EdgeFilter { .getName()))) { // to part matches also return false; - } else { - // From matches and to doesn't so edgefilter is violated. - return true; } - } else { - // From part does not match, restriction does not apply. - return false; + // From matches and to doesn't so edgefilter is violated. + return true; } + // From part does not match, restriction does not apply. + return false; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/LinkVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/LinkVisitor.java index ca8eda3f..79f021c5 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/LinkVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/LinkVisitor.java @@ -17,7 +17,6 @@ package org.wamblee.system.graph.component; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.SystemAssemblyException; -import org.wamblee.system.graph.DefaultEdge; import org.wamblee.system.graph.Edge; import org.wamblee.system.graph.Node; import org.wamblee.system.graph.Visitor; diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/package-info.java b/system/general/src/main/java/org/wamblee/system/graph/component/package-info.java index e906c601..d0651340 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/package-info.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/package-info.java @@ -15,7 +15,4 @@ */ package org.wamblee.system.graph.component; -import org.wamblee.system.core.Component; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java index 23c3bd9c..a0e477cf 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java @@ -17,17 +17,11 @@ package org.wamblee.system.adapters; import org.wamblee.system.container.Container; import org.wamblee.system.core.Component; -import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; -import org.wamblee.system.core.RequiredInterfaceComparator; import org.wamblee.system.core.Scope; - import org.wamblee.test.AssertionUtils; -import java.util.Collections; -import java.util.List; - /** * * @author $author$ 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 2721c511..01f8a35f 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 @@ -15,11 +15,13 @@ */ package org.wamblee.system.container; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + import junit.framework.TestCase; -import org.junit.internal.requests.IgnoredClassRunner; import org.wamblee.general.Pair; - import org.wamblee.system.core.Component; import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.DefaultRequiredInterface; @@ -30,15 +32,9 @@ import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; import org.wamblee.system.core.StringComponent; import org.wamblee.system.core.SystemAssemblyException; - import org.wamblee.test.AssertionUtils; import org.wamblee.test.EventTracker; -import java.io.Serializable; - -import java.util.ArrayList; -import java.util.List; - /** * * @author $author$ 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 6a39b645..901801bc 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 @@ -15,15 +15,8 @@ */ package org.wamblee.system.core; -import org.wamblee.system.core.AbstractComponent; -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; - import org.wamblee.test.EventTracker; -import javax.sql.DataSource; - /** * * @author $author$ 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 c560d6e6..20b5a625 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 @@ -15,15 +15,8 @@ */ package org.wamblee.system.core; -import org.wamblee.system.core.AbstractComponent; -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; - import org.wamblee.test.EventTracker; -import javax.sql.DataSource; - /** * * @author $author$ 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 e79a394d..46777c49 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 @@ -15,15 +15,8 @@ */ package org.wamblee.system.core; -import org.wamblee.system.core.AbstractComponent; -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; - import org.wamblee.test.EventTracker; -import javax.sql.DataSource; - /** * * @author $author$ 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 0ba053b5..1c5358fb 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 @@ -93,8 +93,8 @@ public class ConnectExternalProvidedProvidedEdgeFilterTest extends TestCase { public void testWrongEdgeType() { EdgeFilter filter = new ConnectExternalProvidedProvidedFilter( externalInterfaceName, internalComponentName, internalInterfaceName); - DefaultEdge edge = new DefaultEdge(new DefaultNode("x"), + DefaultEdge edge1 = new DefaultEdge(new DefaultNode("x"), new DefaultNode("y")); - assertFalse(filter.isViolated(edge)); + assertFalse(filter.isViolated(edge1)); } } 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 167d5caa..bf92e093 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 @@ -82,11 +82,11 @@ public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase { } public void testWrongEdgeType() { - DefaultEdge edge = new DefaultEdge(new DefaultNode("x"), + DefaultEdge edge1 = new DefaultEdge(new DefaultNode("x"), new DefaultNode("y")); EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter( comp.getName(), comp.getRequiredInterfaces().get(0).getName(), container.getRequiredInterfaces().get(0).getName()); - assertFalse(filter.isViolated(edge)); + assertFalse(filter.isViolated(edge1)); } } diff --git a/system/spring/src/main/java/org/wamblee/system/spring/PropertySetter.java b/system/spring/src/main/java/org/wamblee/system/spring/PropertySetter.java index 5483968b..7653dd0a 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/PropertySetter.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/PropertySetter.java @@ -15,12 +15,10 @@ */ package org.wamblee.system.spring; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; - import java.util.Properties; +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; + /** * Bean that provides postprocessing of the bean factory based on a given set of * properties. diff --git a/system/spring/src/main/java/org/wamblee/system/spring/component/DatasourceComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/component/DatasourceComponent.java index 2b21a37b..f0aa825a 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/component/DatasourceComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/component/DatasourceComponent.java @@ -15,10 +15,11 @@ */ package org.wamblee.system.spring.component; -import org.springframework.core.io.ClassPathResource; +import java.util.Properties; -import org.springframework.jdbc.datasource.DriverManagerDataSource; +import javax.sql.DataSource; +import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.wamblee.system.components.ORMappingConfig; import org.wamblee.system.components.ORMappingConfig.DatabaseType; import org.wamblee.system.core.AbstractComponent; @@ -27,15 +28,6 @@ import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; -import org.wamblee.system.spring.SpringComponent; - -import java.io.IOException; - -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; - -import javax.sql.DataSource; /** * @@ -57,7 +49,7 @@ public class DatasourceComponent extends AbstractComponent { * * */ - public DatasourceComponent(String aName) throws IOException { + public DatasourceComponent(String aName) { super(aName); addRequiredInterface(PROPS); diff --git a/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java index 3f172094..9d5bb83b 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java @@ -15,17 +15,18 @@ */ package org.wamblee.system.spring.component; -import org.hibernate.SessionFactory; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import javax.sql.DataSource; + +import org.hibernate.SessionFactory; import org.hibernate.dialect.DerbyDialect; import org.hibernate.dialect.MySQLInnoDBDialect; - import org.springframework.orm.hibernate3.HibernateTemplate; - import org.springframework.transaction.PlatformTransactionManager; - import org.wamblee.persistence.hibernate.HibernateMappingFiles; - import org.wamblee.system.components.ORMappingConfig; import org.wamblee.system.components.ORMappingConfig.DatabaseType; import org.wamblee.system.core.DefaultProvidedInterface; @@ -35,14 +36,6 @@ import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; import org.wamblee.system.spring.SpringComponent; -import java.io.IOException; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javax.sql.DataSource; - /** * * @author $author$ @@ -65,7 +58,7 @@ public class HibernateComponent extends SpringComponent { * * */ - public HibernateComponent(String aName) throws IOException { + public HibernateComponent(String aName) { super(aName, new String[] { HIBERNATE_SPRING_CONFIG }, createProvided(), createRequired()); -- 2.31.1