Author: painter Date: Tue Dec 11 14:53:48 2018 New Revision: 1848689 URL: http://svn.apache.org/viewvc?rev=1848689&view=rev Log: Code cleanup, preparing for release, see changes.xml for more
Modified: turbine/fulcrum/trunk/yaafi/pom.xml turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentImpl.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/service/AdviceServiceTest.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/service/ReconfigurationTest.java turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/service/ServiceManagerServiceTest.java turbine/fulcrum/trunk/yaafi/xdocs/changes.xml Modified: turbine/fulcrum/trunk/yaafi/pom.xml URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/pom.xml?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/pom.xml (original) +++ turbine/fulcrum/trunk/yaafi/pom.xml Tue Dec 11 14:53:48 2018 @@ -1,115 +1,128 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, 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. + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + 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. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <artifactId>turbine-parent</artifactId> - <groupId>org.apache.turbine</groupId> - <version>5</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.fulcrum</groupId> - <artifactId>fulcrum-yaafi</artifactId> - <version>1.0.8-SNAPSHOT</version> - <name>Fulcrum YAAFI</name> - <inceptionYear>2004</inceptionYear> - <description>A light-weight Avalon container</description> - <url>http://turbine.apache.org/fulcrum/fulcrum-yaafi</url> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>turbine-parent</artifactId> + <groupId>org.apache.turbine</groupId> + <version>5</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.fulcrum</groupId> + <artifactId>fulcrum-yaafi</artifactId> + <version>1.0.8-SNAPSHOT</version> + <name>Fulcrum YAAFI</name> + <inceptionYear>2004</inceptionYear> + <description>A light-weight Avalon container</description> + <url>http://turbine.apache.org/fulcrum/fulcrum-yaafi</url> + + <scm> + <connection>scm:svn:http://svn.apache.org/repos/asf/turbine/fulcrum/trunk/yaafi/</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/yaafi/</developerConnection> + <url>http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/</url> + </scm> + + <developers> + <developer> + <name>Jeffery Painter</name> + <id>painter</id> + <email>pain...@apache.org</email> + <organization>Apache</organization> + <roles> + <role>Java Developer</role> + </roles> + </developer> + <developer> + <name>Siegfried Goeschl</name> + <id>sgoeschl</id> + <email>sgoes...@apache.org</email> + <organization>Apache</organization> + <roles> + <role>Java Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.8.1</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.6</version> + </dependency> - <scm> - <connection>scm:svn:http://svn.apache.org/repos/asf/turbine/fulcrum/trunk/yaafi/</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/yaafi/</developerConnection> - <url>http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/</url> - </scm> - - <developers> - <developer> - <name>Siegfried Goeschl</name> - <id>sgoeschl</id> - <email>sgoes...@apache.org</email> - <organization>Apache</organization> - <roles> - <role>Java Developer</role> - </roles> - </developer> - </developers> - - <dependencies> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>3.8.1</version> - </dependency> - - <!-- Avalon depedencies --> - <dependency> - <groupId>org.apache.avalon.framework</groupId> - <artifactId>avalon-framework-api</artifactId> - <version>4.3.1</version> - </dependency> - <dependency> - <groupId>org.apache.avalon.framework</groupId> - <artifactId>avalon-framework-impl</artifactId> - <version>4.3.1</version> - </dependency> - <!-- Optional decrytpion of configuration files --> - <dependency> - <groupId>org.apache.fulcrum</groupId> - <artifactId>fulcrum-yaafi-crypto</artifactId> - <version>1.0.7</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>com.jamonapi</groupId> - <artifactId>jamon</artifactId> - <version>2.81</version> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>com.hazelcast</groupId> - <artifactId>hazelcast-all</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.javasimon</groupId> - <artifactId>javasimon-core</artifactId> - <version>4.1.4</version> - <optional>true</optional> - </dependency> - <!-- Testing dependencies --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <sourceDirectory>${basedir}/src/java</sourceDirectory> - <testSourceDirectory>${basedir}/src/test</testSourceDirectory> - </build> - - <properties> - <turbine.site.path>fulcrum/fulcrum-yaafi</turbine.site.path> - </properties> + <!-- Avalon depedencies --> + <dependency> + <groupId>org.apache.avalon.framework</groupId> + <artifactId>avalon-framework-api</artifactId> + <version>4.3.1</version> + </dependency> + <dependency> + <groupId>org.apache.avalon.framework</groupId> + <artifactId>avalon-framework-impl</artifactId> + <version>4.3.1</version> + </dependency> + <!-- Optional decrytpion of configuration files --> + <dependency> + <groupId>org.apache.fulcrum</groupId> + <artifactId>fulcrum-yaafi-crypto</artifactId> + <version>1.0.7</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.jamonapi</groupId> + <artifactId>jamon</artifactId> + <version>2.81</version> + <optional>true</optional> + <exclusions> + <exclusion> + <groupId>com.hazelcast</groupId> + <artifactId>hazelcast-all</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.javasimon</groupId> + <artifactId>javasimon-core</artifactId> + <version>4.1.4</version> + <optional>true</optional> + </dependency> + <!-- Testing dependencies --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + </dependency> + </dependencies> + + <build> + <sourceDirectory>${basedir}/src/java</sourceDirectory> + <testSourceDirectory>${basedir}/src/test</testSourceDirectory> + </build> + + <properties> + <turbine.site.path>fulcrum/fulcrum-yaafi</turbine.site.path> + </properties> </project> Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java Tue Dec 11 14:53:48 2018 @@ -20,7 +20,7 @@ package org.apache.fulcrum.yaafi.cli; */ /** -* Extremely simply command line parsing class. +* Extremely simple command line parsing class. */ public class Getopt Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java Tue Dec 11 14:53:48 2018 @@ -26,242 +26,216 @@ import org.apache.fulcrum.yaafi.framewor * under the License. */ - /** * Interface exposed by the ServiceContainerImpl * * @author <a href="mailto:siegfried.goes...@it20one.at">Siegfried Goeschl</a> */ -public class RoleEntryImpl implements RoleEntry -{ - /** the name of the service component to be used for the service lookup */ - private String name; - - /** the name of the implementation class of the service component */ - private String implementationClazzName; - - /** the short name of the service component to lookup the configuration */ - private String shorthand; - - /** do we incarnate the instance of the service component during start-up? */ - private boolean isEarlyInit; - - /** a description for the service component if any */ - private String description; - - /** the type of service component, e.g. "avalon" */ - private String componentType; - - /** the type of service component if any, e.g. "merlin", "phoenix" or "fortress*/ - private String componentFlavour; - - /** do we use a dynamic proxy when invoking the service */ - private boolean hasDynamicProxy; - - /** the list of interceptors to be invoked when using a dynamic proxy */ - private ArrayList interceptorList; - - /** the optional category for creating a logger */ - private String logCategory; - - /** - * YAAFI role entry - * - * @param name the name of the service component to be used for the service lookup - * @param defaultClass the name of the implementation class of the service component - * @param shorthand the short name of the service component - * @param earlyInit do we incarnate the instance of the service component during start-up? - * @param description a description for the service component if any - * @param componentType the type of service component - * @param componentFlavour the flavour of the gicen component type - * @param hasProxy create a dynamic proxy - * @param interceptorList the list of service interceptor to be invoked - * @param logCategory the category for creating the logger - */ - public RoleEntryImpl( String name, - String defaultClass, - String shorthand, - boolean earlyInit, - String description, - String componentType, - String componentFlavour, - boolean hasProxy, - ArrayList interceptorList, - String logCategory - ) - { - Validate.notEmpty(name,"name"); - Validate.notEmpty(defaultClass,"defaultClass"); - Validate.notEmpty(shorthand,"shorthand"); - Validate.notEmpty(componentType,"componentType"); - Validate.notEmpty(componentFlavour,"componentFlavour"); - Validate.notNull(interceptorList,"interceptorList"); - Validate.notEmpty(logCategory,"logCategory"); - - this.name = name; - this.implementationClazzName = defaultClass; - this.shorthand = shorthand; - this.isEarlyInit = earlyInit; - this.description = description; - this.componentType = componentType; - this.componentFlavour = componentFlavour; - this.hasDynamicProxy = hasProxy; - this.interceptorList = interceptorList; - this.logCategory = logCategory; - } - - /** - * @return Returns the componentType. - */ - public String getComponentType() - { - return componentType; - } - - /** - * @return Returns the description. - */ - public String getDescription() - { - return description; - } - - /** - * @return Returns the implementationClazzName. - */ - public String getImplementationClazzName() - { - return implementationClazzName; - } - - /** - * @return Returns the isEarlyInit. - */ - public boolean isEarlyInit() - { - return isEarlyInit; - } - - /** - * @return Returns the name. - */ - public String getName() - { - return name; - } - - /** - * @return Returns the shorthand. - */ - public String getShorthand() - { - return shorthand; - } - - /** - * @return Returns the componentFlavour. - */ - public String getComponentFlavour() - { - return componentFlavour; - } - - /** - * @return Returns the hasDynamicProxy. - */ - public boolean hasDynamicProxy() - { - return hasDynamicProxy; - } - - /** - * @param hasProxy The hasDynamicProxy to set. - */ - public void setHasDynamicProxy(boolean hasProxy) - { - this.hasDynamicProxy = hasProxy; - } - - /** - * Determines if the given name of the interceptor is already defined. - * - * @param interceptorName the name of the interceptor - * @return true if it is already defined - */ - public boolean hasInterceptor( String interceptorName ) - { - String currInterceptorName = null; - Iterator iterator = this.interceptorList.iterator(); - - while( iterator.hasNext() ) - { - currInterceptorName = (String) iterator.next(); - - if( currInterceptorName.equals(interceptorName) ) - { - return true; - } - } - - return false; - } - - /** - * Adds all given interceptors but avoiding duplicates. - * - * @param collection the interceptors to be added - */ - public void addInterceptors( Collection collection ) - { - String currInterceptorName = null; - Iterator iterator = collection.iterator(); - - while( iterator.hasNext() ) - { - currInterceptorName = (String) iterator.next(); - - if( this.hasInterceptor(currInterceptorName) == false ) - { - this.interceptorList.add(currInterceptorName); - } - } - } - - /** - * @return Returns the interceptorList. - */ - public String[] getInterceptorList() - { - return (String[]) interceptorList.toArray( - new String[interceptorList.size()] - ); - } - - /** - * @return Returns the logCategory. - */ - public String getLogCategory() - { - return logCategory; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - ToStringBuilder toStringBuilder = new ToStringBuilder(this); - toStringBuilder.append("name",this.name); - toStringBuilder.append("shorthand",this.shorthand); - toStringBuilder.append("implementationClazzName",this.implementationClazzName); - toStringBuilder.append("isEarlyInit",this.isEarlyInit); - toStringBuilder.append("hasDynamicProxy",this.hasDynamicProxy); - toStringBuilder.append("componentType",this.componentType); - toStringBuilder.append("componentFlavour",this.componentFlavour); - toStringBuilder.append("interceptorList",this.interceptorList); - toStringBuilder.append("logCategory",this.logCategory); - toStringBuilder.append("description",this.description); - return toStringBuilder.toString(); - } +public class RoleEntryImpl implements RoleEntry { + /** the name of the service component to be used for the service lookup */ + private String name; + + /** the name of the implementation class of the service component */ + private String implementationClazzName; + + /** the short name of the service component to lookup the configuration */ + private String shorthand; + + /** do we incarnate the instance of the service component during start-up? */ + private boolean isEarlyInit; + + /** a description for the service component if any */ + private String description; + + /** the type of service component, e.g. "avalon" */ + private String componentType; + + /** + * the type of service component if any, e.g. "merlin", "phoenix" or "fortress + */ + private String componentFlavour; + + /** do we use a dynamic proxy when invoking the service */ + private boolean hasDynamicProxy; + + /** the list of interceptors to be invoked when using a dynamic proxy */ + private ArrayList<String> interceptorList; + + /** the optional category for creating a logger */ + private String logCategory; + + /** + * YAAFI role entry + * + * @param name the name of the service component to be used for the + * service lookup + * @param defaultClass the name of the implementation class of the service + * component + * @param shorthand the short name of the service component + * @param earlyInit do we incarnate the instance of the service component + * during start-up? + * @param description a description for the service component if any + * @param componentType the type of service component + * @param componentFlavour the flavour of the gicen component type + * @param hasProxy create a dynamic proxy + * @param interceptorList the list of service interceptor to be invoked + * @param logCategory the category for creating the logger + */ + public RoleEntryImpl(String name, String defaultClass, String shorthand, boolean earlyInit, String description, + String componentType, String componentFlavour, boolean hasProxy, ArrayList<String> interceptorList, + String logCategory) { + Validate.notEmpty(name, "name"); + Validate.notEmpty(defaultClass, "defaultClass"); + Validate.notEmpty(shorthand, "shorthand"); + Validate.notEmpty(componentType, "componentType"); + Validate.notEmpty(componentFlavour, "componentFlavour"); + Validate.notNull(interceptorList, "interceptorList"); + Validate.notEmpty(logCategory, "logCategory"); + + this.name = name; + this.implementationClazzName = defaultClass; + this.shorthand = shorthand; + this.isEarlyInit = earlyInit; + this.description = description; + this.componentType = componentType; + this.componentFlavour = componentFlavour; + this.hasDynamicProxy = hasProxy; + this.interceptorList = interceptorList; + this.logCategory = logCategory; + } + + /** + * @return Returns the componentType. + */ + public String getComponentType() { + return componentType; + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @return Returns the implementationClazzName. + */ + public String getImplementationClazzName() { + return implementationClazzName; + } + + /** + * @return Returns the isEarlyInit. + */ + public boolean isEarlyInit() { + return isEarlyInit; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @return Returns the shorthand. + */ + public String getShorthand() { + return shorthand; + } + + /** + * @return Returns the componentFlavour. + */ + public String getComponentFlavour() { + return componentFlavour; + } + + /** + * @return Returns the hasDynamicProxy. + */ + public boolean hasDynamicProxy() { + return hasDynamicProxy; + } + + /** + * @param hasProxy The hasDynamicProxy to set. + */ + public void setHasDynamicProxy(boolean hasProxy) { + this.hasDynamicProxy = hasProxy; + } + + /** + * Determines if the given name of the interceptor is already defined. + * + * @param interceptorName the name of the interceptor + * @return true if it is already defined + */ + public boolean hasInterceptor(String interceptorName) { + String currInterceptorName = null; + Iterator<String> iterator = this.interceptorList.iterator(); + + while (iterator.hasNext()) { + currInterceptorName = iterator.next(); + + if (currInterceptorName.equals(interceptorName)) { + return true; + } + } + + return false; + } + + /** + * Adds all given interceptors but avoiding duplicates. + * + * @param collection the interceptors to be added + */ + public void addInterceptors(Collection collection) { + String currInterceptorName = null; + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) { + currInterceptorName = (String) iterator.next(); + + if (this.hasInterceptor(currInterceptorName) == false) { + this.interceptorList.add(currInterceptorName); + } + } + } + + /** + * @return Returns the interceptorList. + */ + public String[] getInterceptorList() { + return interceptorList.toArray(new String[interceptorList.size()]); + } + + /** + * @return Returns the logCategory. + */ + public String getLogCategory() { + return logCategory; + } + + /** + * @see java.lang.Object#toString() + */ + public String toString() { + ToStringBuilder toStringBuilder = new ToStringBuilder(this); + toStringBuilder.append("name", this.name); + toStringBuilder.append("shorthand", this.shorthand); + toStringBuilder.append("implementationClazzName", this.implementationClazzName); + toStringBuilder.append("isEarlyInit", this.isEarlyInit); + toStringBuilder.append("hasDynamicProxy", this.hasDynamicProxy); + toStringBuilder.append("componentType", this.componentType); + toStringBuilder.append("componentFlavour", this.componentFlavour); + toStringBuilder.append("interceptorList", this.interceptorList); + toStringBuilder.append("logCategory", this.logCategory); + toStringBuilder.append("description", this.description); + return toStringBuilder.toString(); + } } Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java Tue Dec 11 14:53:48 2018 @@ -22,6 +22,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; +import org.apache.commons.lang3.StringUtils; + /** * <p>Assists in validating arguments.</p> * @@ -42,14 +44,11 @@ import java.util.Map; */ public class Validate { - // Validate has no dependencies on other classes in Commons Lang at present - /** * Constructor. This class should not normally be instantiated. */ public Validate() { - // nothing to do } // isTrue @@ -392,10 +391,8 @@ public class Validate */ public static void notEmpty(String string, String message) { - if (string == null || string.length() == 0) - { + if ( StringUtils.isEmpty(string) ) throw new IllegalArgumentException( message ); - } } /** @@ -413,10 +410,8 @@ public class Validate */ public static void notEmpty(String string) { - if (string == null || string.length() == 0) - { + if ( StringUtils.isEmpty(string) ) throw new IllegalArgumentException( "The validated string is empty" ); - } } // notNullElements array Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java Tue Dec 11 14:53:48 2018 @@ -21,7 +21,9 @@ package org.apache.fulcrum.yaafi.interce import java.io.File; import java.io.FileOutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Writer; import java.lang.reflect.Method; import org.apache.avalon.framework.activity.Disposable; @@ -35,290 +37,263 @@ import org.apache.fulcrum.yaafi.framewor import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl; /** - * A service using JAMon for performance monitoring. The implementation - * relies on reflection to invoke JAMON to avoid compile-time coupling. + * A service using JAMon for performance monitoring. The implementation relies + * on reflection to invoke JAMON to avoid compile-time coupling. * * @author <a href="mailto:siegfried.goes...@it20one.at">Siegfried Goeschl</a> */ -public class JamonInterceptorServiceImpl - extends BaseInterceptorServiceImpl - implements JamonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable -{ +public class JamonInterceptorServiceImpl extends BaseInterceptorServiceImpl + implements JamonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable { /** are the JAMon classes in the classpath */ private boolean isJamonAvailable; - /** the file to hold the report */ - private File reportFile; + /** the file to hold the report */ + private File reportFile; - /** the time in ms between two reports */ - private long reportTimeout; + /** the time in ms between two reports */ + private long reportTimeout; - /** do we create a report during disposal of the service */ - private boolean reportOnExit; + /** do we create a report during disposal of the service */ + private boolean reportOnExit; - /** the time when the next report is due */ - private long nextReportTimestamp; - - /** the implementation class name for the performance monitor */ - private String performanceMonitorClassName; - - /** the implementation class name for the performance monitor */ - private Class performanceMonitorClass; - - /** the class name of the JAMon MonitorFactory */ - private static final String MONITORFACTORY_CLASSNAME = "com.jamonapi.MonitorFactory"; - - /** the class name of the JAMon MonitorFactory */ - private static final String DEFAULT_PERFORMANCEMONITOR_CLASSNAME = "org.apache.fulcrum.yaafi.interceptor.jamon.Jamon2PerformanceMonitorImpl"; - - ///////////////////////////////////////////////////////////////////////// - // Avalon Service Lifecycle Implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * Constructor - */ - public JamonInterceptorServiceImpl() - { - super(); - } - - /** - * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) - */ - public void configure(Configuration configuration) throws ConfigurationException - { - super.configure(configuration); - this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0); - - // parse the performance monitor class name - this.performanceMonitorClassName = configuration.getChild("performanceMonitorClassName").getValue(DEFAULT_PERFORMANCEMONITOR_CLASSNAME); - - // parse the report file name - String reportFileName = configuration.getChild("reportFile").getValue("./jamon.html"); - this.reportFile = this.makeAbsoluteFile( reportFileName ); - - // determine when to create the next report - this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout; - - // do we create a report on disposal - this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false); - } - - /** - * @see org.apache.avalon.framework.activity.Initializable#initialize() - */ - public void initialize() throws Exception - { - ClassLoader classLoader = this.getClassLoader(); - - if (!Clazz.hasClazz(classLoader, MONITORFACTORY_CLASSNAME)) - { - String msg = "The JamonInterceptorService is disabled since the JAMON classes are not found in the classpath"; - this.getLogger().warn(msg); - this.isJamonAvailable = false; - return; - } - - if (!Clazz.hasClazz(classLoader, this.performanceMonitorClassName)) - { - String msg = "The JamonInterceptorService is disabled since the performance monitor class is not found in the classpath"; - this.getLogger().warn(msg); - this.isJamonAvailable = false; - return; - } - - // load the performance monitor class - this.performanceMonitorClass = Clazz.getClazz(this.getClassLoader(), this.performanceMonitorClassName); - - // check if we can create an instance of the performance monitor class - JamonPerformanceMonitor testMonitor = this.createJamonPerformanceMonitor(null, null, true); - if(testMonitor == null) - { - String msg = "The JamonInterceptorService is disabled since the performance monitor can't be instantiated"; - this.getLogger().warn(msg); - this.isJamonAvailable = false; - return; - } - - this.getLogger().debug("The JamonInterceptorService is enabled"); - this.isJamonAvailable = true; - } - - /** - * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration) - */ - public void reconfigure(Configuration configuration) throws ConfigurationException - { - super.reconfigure(configuration); - this.configure(configuration); - } - - /** - * @see org.apache.avalon.framework.activity.Disposable#dispose() - */ - public void dispose() - { - if( this.reportOnExit ) - { - this.run(); - } - - this.reportFile = null; - } - - ///////////////////////////////////////////////////////////////////////// - // Service interface implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext) - */ - public void onEntry(AvalonInterceptorContext interceptorContext) - { - if( this.isJamonAvailable() ) - { - this.writeReport(); - - String serviceShortHand = interceptorContext.getServiceShorthand(); - Method serviceMethod = interceptorContext.getMethod(); - boolean isEnabled = this.isServiceMonitored(interceptorContext ); - JamonPerformanceMonitor monitor = this.createJamonPerformanceMonitor(serviceShortHand, serviceMethod, isEnabled); - monitor.start(); - interceptorContext.getRequestContext().put(this.getServiceName(), monitor); - } - } - - /** - * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Object) - */ - public void onExit(AvalonInterceptorContext interceptorContext, Object result) - { - if( this.isJamonAvailable() ) - { - JamonPerformanceMonitor monitor; - monitor = (JamonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName()); - monitor.stop(); - } - } - - /** - * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, java.lang.Throwable) - */ - public void onError(AvalonInterceptorContext interceptorContext,Throwable t) - { - if( this.isJamonAvailable() ) - { - JamonPerformanceMonitor monitor; - monitor = (JamonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName()); - monitor.stop(t); - } - } - - /** - * Writes the JAMON report to the file system. - * - * @see java.lang.Runnable#run() - */ - public void run() - { - this.writeReport(this.reportFile); - } - - ///////////////////////////////////////////////////////////////////////// - // Service Implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * @return Returns true if JAMon is availble. - */ - protected final boolean isJamonAvailable() - { - return this.isJamonAvailable; - } - - /** - * Factory method for creating an implementation of a JamonPerformanceMonitor. - * - * @param serviceName the service name - * @param method the method - * @param isEnabled is the monitor enabled - * @return the instance or <b>null</b> if the creation failed - */ - protected JamonPerformanceMonitor createJamonPerformanceMonitor(String serviceName, Method method, boolean isEnabled) - { - JamonPerformanceMonitor result = null; - - try - { - Class[] signature = { String.class, Method.class, Boolean.class }; - Object[] args = { serviceName, method, (isEnabled) ? Boolean.TRUE : Boolean.FALSE}; - result = (JamonPerformanceMonitor) Clazz.newInstance(this.performanceMonitorClass, signature, args); - return result; - } - catch(Exception e) - { - String msg = "Failed to create a performance monitor instance : " + this.performanceMonitorClassName; - this.getLogger().error(msg, e); - return result; - } - } - - /** - * Write a report file - */ - protected void writeReport() - { - if( this.reportTimeout > 0 ) - { - long currTimestamp = System.currentTimeMillis(); - - if( currTimestamp > this.nextReportTimestamp ) - { - this.nextReportTimestamp = currTimestamp + this.reportTimeout; - this.writeReport(this.reportFile); - } - } - } - - /** - * Write the HTML report to the given destination. - * - * @param reportFile the report destination - */ - protected void writeReport( File reportFile ) - { - PrintWriter printWriter = null; - - if( this.isJamonAvailable() ) - { - try - { - if( this.getLogger().isDebugEnabled() ) - { - this.getLogger().debug( "Writing JAMOM report to " + reportFile.getAbsolutePath() ); - } - - FileOutputStream fos = new FileOutputStream( reportFile ); - printWriter = new PrintWriter( fos ); - JamonPerformanceMonitor monitor = this.createJamonPerformanceMonitor(null, null, true); - String report = monitor.createReport(); - printWriter.write( report ); - printWriter.close(); - } - catch( Throwable t ) - { - String msg = "Generating the JAMON report failed for " + reportFile.getAbsolutePath(); - this.getLogger().error(msg,t); - } - finally - { - if( printWriter != null ) - { - printWriter.close(); - } - } - } - } + /** the time when the next report is due */ + private long nextReportTimestamp; + + /** the implementation class name for the performance monitor */ + private String performanceMonitorClassName; + + /** the implementation class name for the performance monitor */ + private Class performanceMonitorClass; + + /** the class name of the JAMon MonitorFactory */ + private static final String MONITORFACTORY_CLASSNAME = "com.jamonapi.MonitorFactory"; + + /** the class name of the JAMon MonitorFactory */ + private static final String DEFAULT_PERFORMANCEMONITOR_CLASSNAME = "org.apache.fulcrum.yaafi.interceptor.jamon.Jamon2PerformanceMonitorImpl"; + + ///////////////////////////////////////////////////////////////////////// + // Avalon Service Lifecycle Implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * Constructor + */ + public JamonInterceptorServiceImpl() { + super(); + } + + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ + public void configure(Configuration configuration) throws ConfigurationException { + super.configure(configuration); + this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0); + + // parse the performance monitor class name + this.performanceMonitorClassName = configuration.getChild("performanceMonitorClassName") + .getValue(DEFAULT_PERFORMANCEMONITOR_CLASSNAME); + + // parse the report file name + String reportFileName = configuration.getChild("reportFile").getValue("./jamon.html"); + this.reportFile = this.makeAbsoluteFile(reportFileName); + + // determine when to create the next report + this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout; + + // do we create a report on disposal + this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false); + } + + /** + * @see org.apache.avalon.framework.activity.Initializable#initialize() + */ + public void initialize() throws Exception { + ClassLoader classLoader = this.getClassLoader(); + + if (!Clazz.hasClazz(classLoader, MONITORFACTORY_CLASSNAME)) { + String msg = "The JamonInterceptorService is disabled since the JAMON classes are not found in the classpath"; + this.getLogger().warn(msg); + this.isJamonAvailable = false; + return; + } + + if (!Clazz.hasClazz(classLoader, this.performanceMonitorClassName)) { + String msg = "The JamonInterceptorService is disabled since the performance monitor class is not found in the classpath"; + this.getLogger().warn(msg); + this.isJamonAvailable = false; + return; + } + + // load the performance monitor class + this.performanceMonitorClass = Clazz.getClazz(this.getClassLoader(), this.performanceMonitorClassName); + + // check if we can create an instance of the performance monitor class + JamonPerformanceMonitor testMonitor = this.createJamonPerformanceMonitor(null, null, true); + if (testMonitor == null) { + String msg = "The JamonInterceptorService is disabled since the performance monitor can't be instantiated"; + this.getLogger().warn(msg); + this.isJamonAvailable = false; + return; + } + + this.getLogger().debug("The JamonInterceptorService is enabled"); + this.isJamonAvailable = true; + } + + /** + * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration) + */ + public void reconfigure(Configuration configuration) throws ConfigurationException { + super.reconfigure(configuration); + this.configure(configuration); + } + + /** + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ + public void dispose() { + if (this.reportOnExit) { + this.run(); + } + + this.reportFile = null; + } + + ///////////////////////////////////////////////////////////////////////// + // Service interface implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext) + */ + public void onEntry(AvalonInterceptorContext interceptorContext) { + if (this.isJamonAvailable()) { + this.writeReport(); + + String serviceShortHand = interceptorContext.getServiceShorthand(); + Method serviceMethod = interceptorContext.getMethod(); + boolean isEnabled = this.isServiceMonitored(interceptorContext); + JamonPerformanceMonitor monitor = this.createJamonPerformanceMonitor(serviceShortHand, serviceMethod, + isEnabled); + monitor.start(); + interceptorContext.getRequestContext().put(this.getServiceName(), monitor); + } + } + + /** + * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, + * java.lang.Object) + */ + public void onExit(AvalonInterceptorContext interceptorContext, Object result) { + if (this.isJamonAvailable()) { + JamonPerformanceMonitor monitor; + monitor = (JamonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName()); + monitor.stop(); + } + } + + /** + * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext, + * java.lang.Throwable) + */ + public void onError(AvalonInterceptorContext interceptorContext, Throwable t) { + if (this.isJamonAvailable()) { + JamonPerformanceMonitor monitor; + monitor = (JamonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName()); + monitor.stop(t); + } + } + + /** + * Writes the JAMON report to the file system. + * + * @see java.lang.Runnable#run() + */ + public void run() { + this.writeReport(this.reportFile); + } + + ///////////////////////////////////////////////////////////////////////// + // Service Implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * @return Returns true if JAMon is availble. + */ + protected final boolean isJamonAvailable() { + return this.isJamonAvailable; + } + + /** + * Factory method for creating an implementation of a JamonPerformanceMonitor. + * + * @param serviceName the service name + * @param method the method + * @param isEnabled is the monitor enabled + * @return the instance or <b>null</b> if the creation failed + */ + @SuppressWarnings("rawtypes") + protected JamonPerformanceMonitor createJamonPerformanceMonitor(String serviceName, Method method, + boolean isEnabled) { + JamonPerformanceMonitor result = null; + + try { + Class[] signature = { String.class, Method.class, Boolean.class }; + Object[] args = { serviceName, method, (isEnabled) ? Boolean.TRUE : Boolean.FALSE }; + result = (JamonPerformanceMonitor) Clazz.newInstance(this.performanceMonitorClass, signature, args); + return result; + } catch (Exception e) { + String msg = "Failed to create a performance monitor instance : " + this.performanceMonitorClassName; + this.getLogger().error(msg, e); + return result; + } + } + + /** + * Write a report file + */ + protected void writeReport() { + if (this.reportTimeout > 0) { + long currTimestamp = System.currentTimeMillis(); + + if (currTimestamp > this.nextReportTimestamp) { + this.nextReportTimestamp = currTimestamp + this.reportTimeout; + this.writeReport(this.reportFile); + } + } + } + + /** + * Write the HTML report to the given destination. + * + * @param reportFile the report destination + */ + protected void writeReport(File reportFile) { + PrintWriter printWriter = null; + + if (this.isJamonAvailable()) { + try { + if (this.getLogger().isDebugEnabled()) { + this.getLogger().debug("Writing JAMOM report to " + reportFile.getAbsolutePath()); + } + + // Update to eliminate reliance on default encoding (DM_DEFAULT_ENCODING) + Writer w = new OutputStreamWriter(new FileOutputStream(reportFile), "UTF-8"); + printWriter = new PrintWriter(w); + + JamonPerformanceMonitor monitor = this.createJamonPerformanceMonitor(null, null, true); + String report = monitor.createReport(); + printWriter.write(report); + printWriter.close(); + } catch (Throwable t) { + String msg = "Generating the JAMON report failed for " + reportFile.getAbsolutePath(); + this.getLogger().error(msg, t); + } finally { + if (printWriter != null) { + printWriter.close(); + } + } + } + } } Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java Tue Dec 11 14:53:48 2018 @@ -21,7 +21,9 @@ package org.apache.fulcrum.yaafi.interce import java.io.File; import java.io.FileOutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Writer; import java.lang.reflect.Method; import org.apache.avalon.framework.activity.Disposable; @@ -65,7 +67,7 @@ public class JavaSimonInterceptorService private String performanceMonitorClassName; /** the implementation class name for the performance monitor */ - private Class performanceMonitorClass; + private Class<?> performanceMonitorClass; /** the class name of the JavaSimon factory */ private static final String MONITORFACTORY_CLASSNAME = "org.javasimon.SimonManager"; @@ -176,7 +178,6 @@ public class JavaSimonInterceptorService /** * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(AvalonInterceptorContext) */ - @SuppressWarnings("unchecked") public void onEntry(AvalonInterceptorContext interceptorContext) { if( this.isJavaSimonAvailable() ) @@ -248,7 +249,8 @@ public class JavaSimonInterceptorService * @param isEnabled is the monitor enabled * @return the instance or <b>null</b> if the creation failed */ - protected JavaSimonPerformanceMonitor createJavaSimonPerformanceMonitor(String serviceName, Method method, boolean isEnabled) + @SuppressWarnings("rawtypes") + protected JavaSimonPerformanceMonitor createJavaSimonPerformanceMonitor(String serviceName, Method method, boolean isEnabled) { JavaSimonPerformanceMonitor result = null; @@ -302,8 +304,10 @@ public class JavaSimonInterceptorService this.getLogger().debug( "Writing JavaSimon report to " + reportFile.getAbsolutePath() ); } - FileOutputStream fos = new FileOutputStream( reportFile ); - printWriter = new PrintWriter( fos ); + // Update to eliminate reliance on default encoding (DM_DEFAULT_ENCODING) + Writer w = new OutputStreamWriter(new FileOutputStream(reportFile), "UTF-8"); + printWriter = new PrintWriter( w ); + // JavaSimonPerformanceMonitor monitor = this.createJavaSimonPerformanceMonitor(null, null, true); String report = "Not implemented yet ..."; printWriter.write( report ); Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java Tue Dec 11 14:53:48 2018 @@ -28,10 +28,10 @@ import org.apache.avalon.framework.confi import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorContext; import org.apache.fulcrum.yaafi.framework.reflection.Clazz; import org.apache.fulcrum.yaafi.interceptor.baseservice.BaseInterceptorServiceImpl; +import org.apache.fulcrum.yaafi.interceptor.util.ArgumentToStringBuilderImpl; import org.apache.fulcrum.yaafi.interceptor.util.DefaultToStringBuilderImpl; import org.apache.fulcrum.yaafi.interceptor.util.InterceptorToStringBuilder; import org.apache.fulcrum.yaafi.interceptor.util.MethodToStringBuilderImpl; -import org.apache.fulcrum.yaafi.interceptor.util.ArgumentToStringBuilderImpl; import org.apache.fulcrum.yaafi.interceptor.util.StopWatch; /** @@ -61,7 +61,7 @@ public class LoggingInterceptorServiceIm private boolean monitorAllExceptions; /** the ReflectionToStringBuilder class */ - private Class toStringBuilderClass; + private Class<?> toStringBuilderClass; ///////////////////////////////////////////////////////////////////////// // Avalon Service Lifecycle Implementation @@ -236,7 +236,7 @@ public class LoggingInterceptorServiceIm /** * @return Returns the toStringBuilderClass. */ - protected Class getToStringBuilderClass() + protected Class<?> getToStringBuilderClass() { return toStringBuilderClass; } Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java Tue Dec 11 14:53:48 2018 @@ -38,203 +38,177 @@ import org.apache.fulcrum.yaafi.framewor /** * Simple service providing interceptor advices for ordinary POJOs. Since the - * implementation uses Dynamic Proxies only methods invoked by an interface - * can be advised. + * implementation uses Dynamic Proxies only methods invoked by an interface can + * be advised. * * @author <a href="mailto:siegfried.goes...@it20one.at">Siegfried Goeschl</a> */ -public class AdviceServiceImpl - extends AbstractLogEnabled - implements AdviceService, Serviceable, Contextualizable, Reconfigurable -{ - /** the service manager supplied by the Avalon framework */ - private ServiceManager serviceManager; - - /** the list of default interceptors */ - private String[] defaultInterceptorList; - - ///////////////////////////////////////////////////////////////////////// - // Avalon Service Lifecycle Implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) - */ - public void service(ServiceManager serviceManager) throws ServiceException - { - this.serviceManager = serviceManager; - } - - /** - * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) - */ - public void contextualize(Context context) throws ContextException - { - // nothing to do - } - - /** - * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) - */ - public void configure(Configuration configuration) throws ConfigurationException - { - Configuration[] interceptorConfigList = configuration.getChild("interceptors").getChildren("interceptor"); - this.defaultInterceptorList = new String[interceptorConfigList.length]; - - for( int i=0; i<interceptorConfigList.length; i++ ) - { - this.defaultInterceptorList[i] = interceptorConfigList[i].getValue(); - } - } - - /** - * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration) - */ - public void reconfigure(Configuration configuration) throws ConfigurationException - { - this.configure(configuration); - } - - ///////////////////////////////////////////////////////////////////////// - // Service interface implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.Object) - */ - public Object advice(Object object) - { - Validate.notNull(object,"object"); - return this.advice( this.getDefaultInterceptorList(), object ); - } - - /** - * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String, java.lang.Object) - */ - public Object advice(String name, Object object) - { - Validate.notNull(object,"object"); - return this.doAdvice( name, this.getDefaultInterceptorList(), object ); - } - - /** - * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String[], java.lang.Object) - */ - public Object advice(String [] interceptorList, Object object) - { - Validate.notNull(object,"object"); - String className = object.getClass().getName(); - return this.doAdvice(className, interceptorList, object); - } - - /** - * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String, java.lang.String[], java.lang.Object) - */ - public Object advice(String name, String [] interceptorList, Object object ) - { - Validate.notNull(object,"object"); - return this.doAdvice(name, interceptorList, object); - } - - /** - * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#isAdviced(java.lang.Object) - */ - public boolean isAdviced(Object object) - { - InvocationHandler invocationHandler = null; - - if ((object != null ) && Proxy.isProxyClass(object.getClass())) - { - invocationHandler = Proxy.getInvocationHandler(object); - return invocationHandler instanceof AvalonInterceptorInvocationHandler; - } - - return false; - } - - ///////////////////////////////////////////////////////////////////////// - // Service implementation - ///////////////////////////////////////////////////////////////////////// - - /** - * Does the actual work of advising the object. - * - * @param name the name of the object to be advised - * @param interceptorList the list of interceptor services to advise the object - * @param object the object to be advised - * @return the advised object. - */ - protected Object doAdvice(String name, String [] interceptorList, Object object ) - { - Validate.notEmpty(name,"name"); - Validate.notNull(interceptorList,"interceptorList"); - Validate.notNull(object,"object"); - - Object result = null; - String clazzName = object.getClass().getName(); - - // do nothing if no interceptor services are requested - - if( interceptorList.length == 0 ) - { - if( this.getLogger().isInfoEnabled() ) - { - String msg = "Skipping creation of dynamic proxy since no interceptors are requested : " + name; - this.getLogger().info(msg); - } - - return object; - } - - // skip creating a dynamic proxy if it is already advised - - if( this.isAdviced(object) ) - { - if( this.getLogger().isInfoEnabled() ) - { - String msg = "Skipping creation of dynamic proxy since it is already advised : " + name; - this.getLogger().info(msg); - } - - return object; - } - - // create the advised object - - try - { - result = AvalonInterceptorFactory.create( - clazzName, - name, - this.getServiceManager(), - interceptorList, - object - ); - } - catch (ServiceException e) - { - String msg = "Unable to advice the object : " + name; - this.getLogger().error(msg,e); - throw new IllegalArgumentException(msg); - } - - return result; - } - - /** - * @return Returns the serviceManager. - */ - private ServiceManager getServiceManager() - { - return serviceManager; - } - - /** - * @return Returns the defaultInterceptorList. - */ - private String[] getDefaultInterceptorList() - { - return defaultInterceptorList; - } +public class AdviceServiceImpl extends AbstractLogEnabled + implements AdviceService, Serviceable, Contextualizable, Reconfigurable { + /** the service manager supplied by the Avalon framework */ + private ServiceManager serviceManager; + + /** the list of default interceptors */ + private String[] defaultInterceptorList; + + ///////////////////////////////////////////////////////////////////////// + // Avalon Service Lifecycle Implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) + */ + public void service(ServiceManager serviceManager) throws ServiceException { + this.serviceManager = serviceManager; + } + + /** + * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) + */ + public void contextualize(Context context) throws ContextException { + // nothing to do + } + + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ + public void configure(Configuration configuration) throws ConfigurationException { + Configuration[] interceptorConfigList = configuration.getChild("interceptors").getChildren("interceptor"); + this.defaultInterceptorList = new String[interceptorConfigList.length]; + for (int i = 0; i < interceptorConfigList.length; i++) { + this.defaultInterceptorList[i] = interceptorConfigList[i].getValue(); + } + } + + /** + * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration) + */ + public void reconfigure(Configuration configuration) throws ConfigurationException { + this.configure(configuration); + } + + ///////////////////////////////////////////////////////////////////////// + // Service interface implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.Object) + */ + public Object advice(Object object) { + Validate.notNull(object, "object"); + return this.advice(this.getDefaultInterceptorList(), object); + } + + /** + * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String, + * java.lang.Object) + */ + public Object advice(String name, Object object) { + Validate.notNull(object, "object"); + return this.doAdvice(name, this.getDefaultInterceptorList(), object); + } + + /** + * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String[], + * java.lang.Object) + */ + public Object advice(String[] interceptorList, Object object) { + Validate.notNull(object, "object"); + String className = object.getClass().getName(); + return this.doAdvice(className, interceptorList, object); + } + + /** + * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#advice(java.lang.String, + * java.lang.String[], java.lang.Object) + */ + public Object advice(String name, String[] interceptorList, Object object) { + Validate.notNull(object, "object"); + return this.doAdvice(name, interceptorList, object); + } + + /** + * @see org.apache.fulcrum.yaafi.service.advice.AdviceService#isAdviced(java.lang.Object) + */ + public boolean isAdviced(Object object) { + InvocationHandler invocationHandler = null; + + if ((object != null) && Proxy.isProxyClass(object.getClass())) { + invocationHandler = Proxy.getInvocationHandler(object); + return invocationHandler instanceof AvalonInterceptorInvocationHandler; + } + + return false; + } + + ///////////////////////////////////////////////////////////////////////// + // Service implementation + ///////////////////////////////////////////////////////////////////////// + + /** + * Does the actual work of advising the object. + * + * @param name the name of the object to be advised + * @param interceptorList the list of interceptor services to advise the object + * @param object the object to be advised + * @return the advised object. + */ + protected Object doAdvice(String name, String[] interceptorList, Object object) { + Validate.notEmpty(name, "name"); + Validate.notNull(interceptorList, "interceptorList"); + Validate.notNull(object, "object"); + + Object result = null; + String clazzName = object.getClass().getName(); + + // do nothing if no interceptor services are requested + + if (interceptorList.length == 0) { + if (this.getLogger().isInfoEnabled()) { + String msg = "Skipping creation of dynamic proxy since no interceptors are requested : " + name; + this.getLogger().info(msg); + } + + return object; + } + + // skip creating a dynamic proxy if it is already advised + + if (this.isAdviced(object)) { + if (this.getLogger().isInfoEnabled()) { + String msg = "Skipping creation of dynamic proxy since it is already advised : " + name; + this.getLogger().info(msg); + } + + return object; + } + + // create the advised object + + try { + result = AvalonInterceptorFactory.create(clazzName, name, this.getServiceManager(), interceptorList, + object); + } catch (ServiceException e) { + String msg = "Unable to advice the object : " + name; + this.getLogger().error(msg, e); + throw new IllegalArgumentException(msg); + } + + return result; + } + + /** + * @return Returns the serviceManager. + */ + private ServiceManager getServiceManager() { + return serviceManager; + } + + /** + * @return Returns the defaultInterceptorList. + */ + private String[] getDefaultInterceptorList() { + return defaultInterceptorList; + } } Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java Tue Dec 11 14:53:48 2018 @@ -25,8 +25,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.MessageDigest; +import java.util.Arrays; import org.apache.avalon.framework.logger.Logger; +import org.apache.commons.io.IOUtils; import org.apache.fulcrum.yaafi.framework.util.InputStreamLocator; /** @@ -35,254 +37,191 @@ import org.apache.fulcrum.yaafi.framewor * @author <a href="mailto:siegfried.goes...@it20one.at">Siegfried Goeschl</a> */ -public class ReconfigurationEntry -{ - /** buffer size for copy() */ - private static final int BUF_SIZE = 1024; - - /** the location to monitor for changes */ - private String location; - - /** the list of services to be reconfigured */ - private String[] serviceList; - - /** the last message digest of the location */ - private byte[] digest; - - /** the locator to load the monitored resource */ - private InputStreamLocator locator; - - /** keep a notice for the very first invocation */ - private boolean isFirstInvocation; - - /** the logger to be used */ - private Logger logger; - - /** - * Constructor - * - * @param logger the logger to use - * @param applicationDir the home directory of the application - * @param location the location to monitor for changes - * @param serviceList the list of services to be reconfigured - */ - public ReconfigurationEntry( Logger logger, File applicationDir, String location, String[] serviceList ) - { - this.isFirstInvocation = true; - this.location = location; - this.locator = new InputStreamLocator( applicationDir ); - this.logger = logger; - this.serviceList = serviceList; - } - - /** - * @return has the monitored location changed - */ - public boolean hasChanged() - { - boolean result = false; - InputStream is = null; - byte[] currDigest = null; - - try - { - // get a grip on our resource - - is = this.locate(); - - if( is == null ) - { - String msg = "Unable to find the following resource : " + this.getLocation(); - this.getLogger().warn(msg); - } - else - { - // calculate a SHA-1 digest - - currDigest = this.getDigest(is); - is.close(); - is = null; - - if( this.isFirstInvocation() == true ) - { - isFirstInvocation = false; - this.getLogger().debug( "Storing SHA-1 digest of " + this.getLocation() ); - this.setDigest( currDigest ); - } - else - { - if( equals( this.digest, currDigest ) == false ) - { - this.getLogger().debug( "The following resource has changed : " + this.getLocation() ); - this.setDigest( currDigest ); - result = true; - } - } - } - - return result; - } - catch(Exception e) - { - String msg = "The ShutdownService encountered an internal error"; - this.getLogger().error(msg,e); - return false; - } - finally - { - if( is != null ) - { - try - { - is.close(); - } - catch (Exception e) - { - String msg = "Can't close the InputStream during error recovery"; - this.getLogger().error(msg,e); - } - } - } - - } - - /** - * @return Returns the serviceList. - */ - public String [] getServiceList() - { - return serviceList; - } - - /** - * @return Returns the isFirstInvocation. - */ - private boolean isFirstInvocation() - { - return isFirstInvocation; - } - - /** - * @return Returns the location. - */ - private String getLocation() - { - return location; - } - - /** - * @return Returns the locator. - */ - private InputStreamLocator getLocator() - { - return locator; - } - - /** - * Creates an InputStream. - * @return the input stream - * @throws IOException the creation failed - */ - public InputStream locate() throws IOException - { - return this.getLocator().locate(this.getLocation()); - } - - /** - * Creates a message digest. - * - * @param is the input stream as input for the message digest - * @return the message digest - * @throws Exception the creation failed - */ - private byte[] getDigest( InputStream is ) - throws Exception - { - byte[] result = null; - byte[] content = null; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - copy( is, baos ); - content = baos.toByteArray(); - baos.close(); - - MessageDigest sha1 = MessageDigest.getInstance( "SHA1" ); - sha1.update( content ); - result = sha1.digest(); - - return result; - } - - /** - * @param digest The digest to set. - */ - private void setDigest(byte [] digest) - { - this.digest = digest; - } - - /** - * Compares two byte[] for equality - * - * @param lhs the left-hand side - * @param rhs the right-hand side - * @return true if the byte[] are equal - */ - private static boolean equals(byte[] lhs, byte[] rhs) - { - if( lhs == rhs ) - { - return true; - } - else if( lhs.length != rhs.length ) - { - return false; - } - else - { - for( int i=0; i<lhs.length; i++ ) - { - if( lhs[i] != rhs[i] ) - { - return false; - } - } - } - - return true; - } - - /** - * Pumps the input stream to the output stream. - * - * @param is the source input stream - * @param os the target output stream - * @throws IOException the copying failed - */ - private static void copy( InputStream is, OutputStream os ) - throws IOException - { - byte[] buf = new byte[BUF_SIZE]; - int n = 0; - int total = 0; - - while ((n = is.read(buf)) > 0) - { - os.write(buf, 0, n); - total += n; - } - - is.close(); - - os.flush(); - os.close(); - } - - /** - * @return Returns the logger. - */ - private Logger getLogger() - { - return logger; - } +public class ReconfigurationEntry { + + /** the location to monitor for changes */ + private String location; + + /** the list of services to be reconfigured */ + private String[] serviceList; + + /** the last message digest of the location */ + private byte[] digest; + + /** the locator to load the monitored resource */ + private InputStreamLocator locator; + + /** keep a notice for the very first invocation */ + private boolean isFirstInvocation; + + /** the logger to be used */ + private Logger logger; + + /** + * Constructor + * + * @param logger the logger to use + * @param applicationDir the home directory of the application + * @param location the location to monitor for changes + * @param serviceList the list of services to be reconfigured + */ + public ReconfigurationEntry(Logger logger, File applicationDir, String location, String[] serviceList) { + this.isFirstInvocation = true; + this.location = location; + this.locator = new InputStreamLocator(applicationDir); + this.logger = logger; + this.serviceList = serviceList; + } + + /** + * @return has the monitored location changed + */ + public boolean hasChanged() { + boolean result = false; + InputStream is = null; + byte[] currDigest = null; + + try { + // get a grip on our resource + + is = this.locate(); + + if (is == null) { + String msg = "Unable to find the following resource : " + this.getLocation(); + this.getLogger().warn(msg); + } else { + // calculate a SHA-1 digest + currDigest = this.getDigest(is); + is.close(); + is = null; + + if (this.isFirstInvocation() == true) { + isFirstInvocation = false; + this.getLogger().debug("Storing SHA-1 digest of " + this.getLocation()); + this.setDigest(currDigest); + } else { + if (equals(this.digest, currDigest) == false) { + this.getLogger().debug("The following resource has changed : " + this.getLocation()); + this.setDigest(currDigest); + result = true; + } + } + } + + return result; + } catch (Exception e) { + String msg = "The ShutdownService encountered an internal error"; + this.getLogger().error(msg, e); + return false; + } finally { + if (is != null) { + try { + is.close(); + } catch (Exception e) { + String msg = "Can't close the InputStream during error recovery"; + this.getLogger().error(msg, e); + } + } + } + + } + + /** + * @return Returns the serviceList. + */ + public String[] getServiceList() { + return serviceList; + } + + /** + * @return Returns the isFirstInvocation. + */ + private boolean isFirstInvocation() { + return isFirstInvocation; + } + + /** + * @return Returns the location. + */ + private String getLocation() { + return location; + } + + /** + * @return Returns the locator. + */ + private InputStreamLocator getLocator() { + return locator; + } + + /** + * Creates an InputStream. + * + * @return the input stream + * @throws IOException the creation failed + */ + public InputStream locate() throws IOException { + return this.getLocator().locate(this.getLocation()); + } + + /** + * Creates a message digest. + * + * @param is the input stream as input for the message digest + * @return the message digest + * @throws Exception the creation failed + */ + private byte[] getDigest(InputStream is) throws Exception { + byte[] result = null; + byte[] content = null; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + copy(is, baos); + content = baos.toByteArray(); + baos.close(); + + MessageDigest sha1 = MessageDigest.getInstance("SHA1"); + sha1.update(content); + result = sha1.digest(); + + return result; + } + + /** + * @param digest The digest to set. + */ + private void setDigest(byte[] digest) { + this.digest = digest; + } + + /** + * Compares two byte[] for equality + * + * @param lhs the left-hand side + * @param rhs the right-hand side + * @return true if the byte[] are equal + */ + private static boolean equals(byte[] lhs, byte[] rhs) { + // JDK provided method + return Arrays.equals(lhs, rhs); + } + + /** + * Pumps the input stream to the output stream. + * + * @param is the source input stream + * @param os the target output stream + * @throws IOException the copying failed + */ + private static void copy(InputStream is, OutputStream os) throws IOException { + // Use commons managed code + IOUtils.copy(is, os); + } + + /** + * @return Returns the logger. + */ + private Logger getLogger() { + return logger; + } } Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java Tue Dec 11 14:53:48 2018 @@ -116,7 +116,7 @@ public class ReconfigurationServiceImpl // parse the resources to monitor - Configuration entry = null; + // Configuration entry = null; Configuration services = null; Configuration[] serviceEntries = null; Configuration[] entryList = configuration.getChildren("entry"); @@ -126,10 +126,9 @@ public class ReconfigurationServiceImpl String[] serviceNameList = null; ReconfigurationEntry reconfigurationEntry = null; ReconfigurationEntry[] list = new ReconfigurationEntry[entryList.length]; - - for( int i=0; i<entryList.length; i++ ) + int listIndex = 0; + for ( Configuration entry : entryList ) { - entry = entryList[i]; location = entry.getChild("location").getValue(); services = entry.getChild("services",false); @@ -154,7 +153,7 @@ public class ReconfigurationServiceImpl serviceNameList ); - list[i] = reconfigurationEntry; + list[listIndex++] = reconfigurationEntry; } this.getLogger().debug( "Monitoring " + list.length + " resources" ); @@ -167,20 +166,14 @@ public class ReconfigurationServiceImpl */ public void initialize() throws Exception { - // request a SHA-1 to make sure that it is supported - + // request a SHA-1 to make sure that it is supported MessageDigest.getInstance( "SHA1" ); - // check that the ServiceManager inplements Reconfigurable - + // check that the ServiceManager implements Reconfigurable if( (this.serviceManager instanceof ServiceLifecycleManager) == false ) - { - String msg = "The ServiceManager instance does not implement ServiceLifecycleManager?!"; - throw new IllegalArgumentException( msg ); - } - + throw new IllegalArgumentException( "The ServiceManager instance does not implement ServiceLifecycleManager!" ); + // create the worker thread polling the target - this.workerThread = new Thread( this, "ReconfigurationService" ); } @@ -237,23 +230,16 @@ public class ReconfigurationServiceImpl */ public void run() { - ReconfigurationEntry reconfigurationEntry = null; ReconfigurationEntry[] list = null; - while( this.terminateNow == false ) { list = this.getReconfigurationEntryList(); - try { - for( int i=0; i<list.length; i++ ) + for ( ReconfigurationEntry reconfigurationEntry : list ) { - reconfigurationEntry = list[i]; - if( reconfigurationEntry.hasChanged() ) - { this.onReconfigure( reconfigurationEntry ); - } } Thread.sleep( this.interval ); @@ -288,7 +274,6 @@ public class ReconfigurationServiceImpl if( reconfigurationEntry.getServiceList() == null ) { // reconfigure the whole container using Avalon Lifecycle Spec - InputStream is = reconfigurationEntry.locate(); DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); Configuration configuration = builder.build(is); Modified: turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentImpl.java Tue Dec 11 14:53:48 2018 @@ -38,7 +38,7 @@ public class DependentTestComponentImpl /** out test component */ private TestComponent testComponent; - /** + /* (non-Javadoc) * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) */ public void service(ServiceManager serviceManager) throws ServiceException @@ -46,6 +46,9 @@ public class DependentTestComponentImpl this.testComponent = (TestComponent) serviceManager.lookup(TestComponent.ROLE); } + /* (non-Javadoc) + * @see org.apache.fulcrum.yaafi.DependentTestComponent#test() + */ public void test() { this.testComponent.test(); Modified: turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java (original) +++ turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java Tue Dec 11 14:53:48 2018 @@ -45,7 +45,7 @@ public class DependentTestComponentTest * DependentTestComponentImpl uses a TestComponent which. Make * sure that the container resolves this cyclic dependency. * - * @throws Exception + * @throws Exception generic exception */ public void testDependentTestComponent() throws Exception { Modified: turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java (original) +++ turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java Tue Dec 11 14:53:48 2018 @@ -82,15 +82,17 @@ public interface TestComponent String getUrnAvalonPartition(); /** - * Alwayas throws an exception + * Always throws an exception + * @param reason reason for exception + * @param caller the method or class calling the exception */ void createException(String reason, Object caller); /** * Do something for the given time * - * @param millis - * @param arg + * @param millis time in miliseconds + * @param arg arguments */ public void doSomething(long millis, Object arg); } Modified: turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java?rev=1848689&r1=1848688&r2=1848689&view=diff ============================================================================== --- turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java (original) +++ turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java Tue Dec 11 14:53:48 2018 @@ -56,12 +56,18 @@ public class TestComponentImpl public boolean decomissioned; public String componentName; + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Initializable#initialize() + */ public void initialize() throws Exception { getLogger().debug("initialize() was called"); decomissioned = false; } + /* (non-Javadoc) + * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) + */ public void contextualize(Context context) throws ContextException { this.urnAvaloneHome = (File) context.get( "urn:avalon:home" ); @@ -71,28 +77,43 @@ public class TestComponentImpl this.urnAvalonClassLoader = (ClassLoader) context.get( "urn:avalon:classloader" ); } + /* (non-Javadoc) + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ public void configure(Configuration configuration) throws ConfigurationException { this.foo = configuration.getChild("FOO").getValue("FOO Not Found?!"); } + /* (non-Javadoc) + * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration) + */ public void reconfigure(Configuration configuration) throws ConfigurationException { this.configure(configuration); } + /* (non-Javadoc) + * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters) + */ public void parameterize(Parameters parameters) throws ParameterException { this.bar = parameters.getParameter("BAR", "BAR Not Found?!"); } + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ public void dispose() { getLogger().debug("dispose() was called"); this.decomissioned=true; } + /* (non-Javadoc) + * @see org.apache.fulcrum.yaafi.TestComponent#test() + */ public void test() { setupLogger(this, "TestComponent"); @@ -168,14 +189,17 @@ public class TestComponentImpl return urnAvalonPartition; } - /** - * @see org.apache.fulcrum.yaafi.TestComponent#createException(String,Object) + /* (non-Javadoc) + * @see org.apache.fulcrum.yaafi.TestComponent#createException(java.lang.String, java.lang.Object) */ public void createException(String reason, Object caller) { throw new RuntimeException(reason); } + /* (non-Javadoc) + * @see org.apache.fulcrum.yaafi.TestComponent#doSomething(long, java.lang.Object) + */ public void doSomething(long millis, Object arg) { try