Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 95b7539

Browse files
author
hboutemy
committed
o removed unused imports
o used Java 5 generics
1 parent e6dc529 commit 95b7539

File tree

6 files changed

+26
-41
lines changed

6 files changed

+26
-41
lines changed

plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/StaticComponentManager.java

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.codehaus.plexus.lifecycle.LifecycleHandler;
44
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
55
import org.codehaus.plexus.component.repository.ComponentDescriptor;
6-
import org.codehaus.plexus.component.factory.ComponentInstantiationException;
76
import org.codehaus.plexus.MutablePlexusContainer;
87
import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException;
98
import org.codehaus.plexus.classworlds.realm.ClassRealm;

plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@
1111
* author and want to create a custom source of configuration for the components in your application then you would most
1212
* likely want to create a chained configuration source where you can decide the order of processing, but still have the
1313
* container perform its default behavior.
14-
*
14+
*
1515
* @author Jason van Zyl
1616
*/
1717
public class ChainedConfigurationSource
1818
implements ConfigurationSource
1919
{
20-
private List configurationSources;
20+
private List<ConfigurationSource> configurationSources;
2121

22-
public ChainedConfigurationSource( List configurationSources )
22+
public ChainedConfigurationSource( List<ConfigurationSource> configurationSources )
2323
{
2424
this.configurationSources = configurationSources;
2525
}
2626

2727
public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescriptor )
2828
{
29-
for ( Iterator i = configurationSources.iterator(); i.hasNext(); )
29+
for ( ConfigurationSource configurationSource : configurationSources )
3030
{
31-
ConfigurationSource configurationSource = (ConfigurationSource) i.next();
32-
3331
PlexusConfiguration configuration = configurationSource.getConfiguration( componentDescriptor );
3432

3533
if ( configuration != null )
@@ -41,7 +39,7 @@ public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescri
4139
return null;
4240
}
4341

44-
public List getConfigurationSources()
42+
public List<ConfigurationSource> getConfigurationSources()
4543
{
4644
return configurationSources;
4745
}

plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
public abstract class AbstractLifecycleHandler
2929
implements LifecycleHandler
3030
{
31-
private List beginSegment;
31+
private List<Phase> beginSegment;
3232

33-
private List endSegment;
33+
private List<Phase> endSegment;
3434

3535
// ----------------------------------------------------------------------
3636
// Begin Segment
@@ -40,13 +40,13 @@ public void addBeginSegment( Phase phase )
4040
{
4141
if ( beginSegment == null )
4242
{
43-
beginSegment = new ArrayList();
43+
beginSegment = new ArrayList<Phase>();
4444
}
4545

4646
beginSegment.add( phase );
4747
}
4848

49-
public List getBeginSegment()
49+
public List<Phase> getBeginSegment()
5050
{
5151
return beginSegment;
5252
}
@@ -55,13 +55,13 @@ public void addEndSegment( Phase phase )
5555
{
5656
if ( endSegment == null )
5757
{
58-
endSegment = new ArrayList();
58+
endSegment = new ArrayList<Phase>();
5959
}
6060

6161
endSegment.add( phase );
6262
}
6363

64-
public List getEndSegment()
64+
public List<Phase> getEndSegment()
6565
{
6666
return endSegment;
6767
}
@@ -90,10 +90,8 @@ public void start( Object component, ComponentManager manager, ClassRealm realm
9090
return;
9191
}
9292

93-
for ( Iterator i = getBeginSegment().iterator(); i.hasNext(); )
93+
for ( Phase phase : getBeginSegment() )
9494
{
95-
Phase phase = (Phase) i.next();
96-
9795
phase.execute( component, manager, realm );
9896
}
9997
}
@@ -119,15 +117,13 @@ public void end( Object component, ComponentManager manager, ClassRealm contextR
119117
return;
120118
}
121119

122-
for ( Iterator i = getEndSegment().iterator(); i.hasNext(); )
120+
for ( Phase phase : getEndSegment() )
123121
{
124-
Phase phase = (Phase) i.next();
125-
126122
phase.execute( component, manager, contextRealm );
127123
}
128124
}
129125

130-
private boolean segmentIsEmpty( List segment )
126+
private boolean segmentIsEmpty( List<Phase> segment )
131127
{
132128
if ( segment == null || segment.size() == 0 )
133129
{

plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/phase/AbstractPhase.java

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
import org.codehaus.plexus.classworlds.realm.ClassRealm;
20-
import org.codehaus.plexus.component.manager.ComponentManager;
21-
import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException;
22-
2319
public abstract class AbstractPhase implements Phase
2420
{
2521
}

plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
2020

2121
import java.util.HashMap;
22-
import java.util.Iterator;
2322
import java.util.Locale;
2423
import java.util.Map;
2524

@@ -33,7 +32,7 @@ public abstract class BaseLoggerManager
3332
extends AbstractLoggerManager implements Initializable
3433
{
3534
/** */
36-
private Map loggerCache = new HashMap();
35+
private Map<String, Logger> loggerCache = new HashMap<String, Logger>();
3736

3837
private String threshold = "info";
3938

@@ -100,9 +99,8 @@ public void setThresholds( int currentThreshold )
10099
{
101100
this.currentThreshold = currentThreshold;
102101

103-
for ( Iterator logs = loggerCache.values().iterator(); logs.hasNext(); )
102+
for ( Logger logger : loggerCache.values() )
104103
{
105-
Logger logger = (Logger) logs.next();
106104
logger.setThreshold( currentThreshold );
107105
}
108106
}

plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* </logger>
3939
* </logging>
4040
* </pre>
41-
*
41+
*
4242
* @author Jason van Zyl
4343
* @author <a href="mailto:[email protected]">Trygve Laugst&oslash;l</a>
4444
* @version $Id$
@@ -48,16 +48,16 @@ public class ConsoleLoggerManager
4848
implements LoggerManager, Initializable
4949
{
5050
/**
51-
* Message of this level or higher will be logged.
52-
*
51+
* Message of this level or higher will be logged.
52+
*
5353
* This field is set by the plexus container thus the name is 'threshold'. The field
5454
* currentThreshold contains the current setting of the threshold.
5555
*/
5656
private String threshold = "info";
5757

5858
private int currentThreshold;
5959

60-
private Map loggers;
60+
private Map<String, Logger> loggers;
6161

6262
/** The number of active loggers in use. */
6363
private int loggerCount;
@@ -93,7 +93,7 @@ public void initialize()
9393
currentThreshold = Logger.LEVEL_DEBUG;
9494
}
9595

96-
loggers = new HashMap();
96+
loggers = new HashMap<String, Logger>();
9797
}
9898

9999
public void setThreshold( int currentThreshold )
@@ -105,9 +105,8 @@ public void setThresholds( int currentThreshold )
105105
{
106106
this.currentThreshold = currentThreshold;
107107

108-
for ( Iterator logs = loggers.values().iterator(); logs.hasNext(); )
108+
for ( Logger logger : loggers.values() )
109109
{
110-
Logger logger = (Logger) logs.next();
111110
logger.setThreshold( currentThreshold );
112111
}
113112
}
@@ -159,14 +158,13 @@ public Logger createLogger(int threshold, String name)
159158

160159
public Logger getLoggerForComponent( String role, String roleHint )
161160
{
162-
Logger logger;
163-
String name;
164-
165-
name = toMapKey( role, roleHint );
166-
logger = (Logger)loggers.get( name );
161+
String name = toMapKey( role, roleHint );
162+
Logger logger = (Logger)loggers.get( name );
167163

168164
if ( logger != null )
165+
{
169166
return logger;
167+
}
170168

171169
debug( "Creating logger '" + name + "' " + this.hashCode() + "." );
172170
logger = createLogger( getThreshold(), name );

0 commit comments

Comments
 (0)