mcconnell 2002/12/15 09:48:40 Modified: assembly/src/java/org/apache/avalon/assembly/profile ProfileManager.java assembly/src/java/org/apache/avalon/assembly/service ServiceManager.java assembly/src/java/org/apache/avalon/assembly/type TypeManager.java assembly/src/test/org/apache/avalon/playground TerminalComponent.xinfo Log: Enhancements to logging information. Revision Changes Path 1.6 +50 -20 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java Index: ProfileManager.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ProfileManager.java 12 Dec 2002 00:32:32 -0000 1.5 +++ ProfileManager.java 15 Dec 2002 17:48:39 -0000 1.6 @@ -215,7 +215,8 @@ * Add a set of profiles to the manager. * @param profiles the deployment profiles to added to the manager * @exception DuplicateProfileException if a profile of the same name - * is already registered with the manager + * is already registered with the manager and the supplied profile + * is a equal or lower in priority * @exception ProfileException if a profile verification failure occurs * @see #createProfile */ @@ -229,15 +230,30 @@ } /** - * Add a profile to the manager. + * Add or replace profile to the manager. * @param profile the deployment profile to add to the manager * @exception DuplicateProfileException if a profile of the same name - * is already registered with the manager + * is already registered with the manager and the replacement policy is true * @exception ProfileException if a profile verification failure occurs * @see #createProfile */ public void addProfile( Profile profile ) throws DuplicateProfileException, ProfileException { + addProfile( profile, true ); + } + + /** + * Add a profile to the manager using the supplied profile and replacement policy + * @param profile the deployment profile to add to the manager + * @exception DuplicateProfileException if a profile of the same name + * is already registered with the manager and the replacement policy is true + * @exception ProfileException if a profile verification failure occurs + * @see #createProfile + */ + public void addProfile( Profile profile, boolean replace ) + throws DuplicateProfileException, ProfileException + { + boolean flag = false; if( profile == null ) { throw new NullPointerException("profile"); @@ -251,32 +267,46 @@ try { getNamedProfile( profile.getName() ); - throw new DuplicateProfileException( - profile.getType().getInfo().getClassname() - + "/" + profile.getName() ); + if( !replace ) + { + throw new DuplicateProfileException( + profile.getType().getInfo().getClassname() + + "/" + profile.getName() ); + } + flag = true; } catch( UnknownProfileException upe ) { - try - { - verify( profile ); - } - catch( Throwable e ) + // continue + } + + try + { + verify( profile ); + } + catch( Throwable e ) + { + final String error = + "Could not register the profile: " + profile + + " due to a verification failure."; + throw new ProfileException( error, e ); + } + + if( getLogger().isDebugEnabled() ) + { + if( flag ) { - final String error = - "Could not register the profile: " + profile - + " due to a verification failure."; - throw new ProfileException( error, e ); + getLogger().debug( + "replace: " + profile ); } - - if( getLogger().isDebugEnabled() ) + else { getLogger().debug( "add: " + profile ); } - - m_profiles.put( profile.getName(), profile ); } + + m_profiles.put( profile.getName(), profile ); } /** 1.3 +4 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/service/ServiceManager.java Index: ServiceManager.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/service/ServiceManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServiceManager.java 7 Dec 2002 09:34:28 -0000 1.2 +++ ServiceManager.java 15 Dec 2002 17:48:40 -0000 1.3 @@ -265,6 +265,7 @@ if( getLogger().isDebugEnabled() ) { + /* StringBuffer buffer = new StringBuffer(); buffer.append( "add: " + classname ); buffer.append( "/" + service.getVersion() ); @@ -275,7 +276,8 @@ String value = service.getAttribute( name ); buffer.append( "\n attribute " + name + " = " + value ); } - getLogger().debug( buffer.toString() ); + */ + getLogger().debug( "add: " + service ); } map.put( version, service ); 1.3 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/type/TypeManager.java Index: TypeManager.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/type/TypeManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TypeManager.java 7 Dec 2002 09:34:29 -0000 1.2 +++ TypeManager.java 15 Dec 2002 17:48:40 -0000 1.3 @@ -240,7 +240,7 @@ if( getLogger().isDebugEnabled() ) { - getLogger().debug("add: " + classname ); + getLogger().debug("add: " + type ); } m_types.put( classname, type ); 1.2 +1 -1 avalon-sandbox/assembly/src/test/org/apache/avalon/playground/TerminalComponent.xinfo Index: TerminalComponent.xinfo =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/playground/TerminalComponent.xinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TerminalComponent.xinfo 24 Nov 2002 12:50:46 -0000 1.1 +++ TerminalComponent.xinfo 15 Dec 2002 17:48:40 -0000 1.2 @@ -6,7 +6,7 @@ <type> <info> - <name>terminal-component</name> + <name>terminal</name> </info> <services>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>