1
2
3
4
5
6
7
8 package org.apache.maven.settings;
9
10
11
12
13
14
15
16
17 public class Settings
18 extends TrackableBase
19 implements java.io.Serializable
20 {
21
22
23
24
25
26
27
28
29
30
31
32
33 private String localRepository;
34
35
36
37
38
39
40
41
42
43 private boolean interactiveMode = true;
44
45
46
47
48
49
50
51
52
53 private boolean usePluginRegistry = false;
54
55
56
57
58
59
60
61
62
63 private boolean offline = false;
64
65
66
67
68 private java.util.List<Proxy> proxies;
69
70
71
72
73 private java.util.List<Server> servers;
74
75
76
77
78 private java.util.List<Mirror> mirrors;
79
80
81
82
83 private java.util.List<Profile> profiles;
84
85
86
87
88 private java.util.List<String> activeProfiles;
89
90
91
92
93 private java.util.List<String> pluginGroups;
94
95
96
97
98 private String modelEncoding = "UTF-8";
99
100
101
102
103
104
105
106
107
108
109
110 public void addActiveProfile( String string )
111 {
112 if ( !(string instanceof String) )
113 {
114 throw new ClassCastException( "Settings.addActiveProfiles(string) parameter must be instanceof " + String.class.getName() );
115 }
116 getActiveProfiles().add( string );
117 }
118
119
120
121
122
123
124 public void addMirror( Mirror mirror )
125 {
126 if ( !(mirror instanceof Mirror) )
127 {
128 throw new ClassCastException( "Settings.addMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() );
129 }
130 getMirrors().add( mirror );
131 }
132
133
134
135
136
137
138 public void addPluginGroup( String string )
139 {
140 if ( !(string instanceof String) )
141 {
142 throw new ClassCastException( "Settings.addPluginGroups(string) parameter must be instanceof " + String.class.getName() );
143 }
144 getPluginGroups().add( string );
145 }
146
147
148
149
150
151
152 public void addProfile( Profile profile )
153 {
154 if ( !(profile instanceof Profile) )
155 {
156 throw new ClassCastException( "Settings.addProfiles(profile) parameter must be instanceof " + Profile.class.getName() );
157 }
158 getProfiles().add( profile );
159 }
160
161
162
163
164
165
166 public void addProxy( Proxy proxy )
167 {
168 if ( !(proxy instanceof Proxy) )
169 {
170 throw new ClassCastException( "Settings.addProxies(proxy) parameter must be instanceof " + Proxy.class.getName() );
171 }
172 getProxies().add( proxy );
173 }
174
175
176
177
178
179
180 public void addServer( Server server )
181 {
182 if ( !(server instanceof Server) )
183 {
184 throw new ClassCastException( "Settings.addServers(server) parameter must be instanceof " + Server.class.getName() );
185 }
186 getServers().add( server );
187 }
188
189
190
191
192
193
194 public java.util.List<String> getActiveProfiles()
195 {
196 if ( this.activeProfiles == null )
197 {
198 this.activeProfiles = new java.util.ArrayList<String>();
199 }
200
201 return this.activeProfiles;
202 }
203
204
205
206
207
208
209 public String getLocalRepository()
210 {
211 return this.localRepository;
212 }
213
214
215
216
217
218
219 public java.util.List<Mirror> getMirrors()
220 {
221 if ( this.mirrors == null )
222 {
223 this.mirrors = new java.util.ArrayList<Mirror>();
224 }
225
226 return this.mirrors;
227 }
228
229
230
231
232
233
234
235 public String getModelEncoding()
236 {
237 return modelEncoding;
238 }
239
240
241
242
243
244
245 public java.util.List<String> getPluginGroups()
246 {
247 if ( this.pluginGroups == null )
248 {
249 this.pluginGroups = new java.util.ArrayList<String>();
250 }
251
252 return this.pluginGroups;
253 }
254
255
256
257
258
259
260 public java.util.List<Profile> getProfiles()
261 {
262 if ( this.profiles == null )
263 {
264 this.profiles = new java.util.ArrayList<Profile>();
265 }
266
267 return this.profiles;
268 }
269
270
271
272
273
274
275 public java.util.List<Proxy> getProxies()
276 {
277 if ( this.proxies == null )
278 {
279 this.proxies = new java.util.ArrayList<Proxy>();
280 }
281
282 return this.proxies;
283 }
284
285
286
287
288
289
290 public java.util.List<Server> getServers()
291 {
292 if ( this.servers == null )
293 {
294 this.servers = new java.util.ArrayList<Server>();
295 }
296
297 return this.servers;
298 }
299
300
301
302
303
304
305
306 public boolean isInteractiveMode()
307 {
308 return this.interactiveMode;
309 }
310
311
312
313
314
315
316
317 public boolean isOffline()
318 {
319 return this.offline;
320 }
321
322
323
324
325
326
327
328 public boolean isUsePluginRegistry()
329 {
330 return this.usePluginRegistry;
331 }
332
333
334
335
336
337
338 public void removeActiveProfile( String string )
339 {
340 if ( !(string instanceof String) )
341 {
342 throw new ClassCastException( "Settings.removeActiveProfiles(string) parameter must be instanceof " + String.class.getName() );
343 }
344 getActiveProfiles().remove( string );
345 }
346
347
348
349
350
351
352 public void removeMirror( Mirror mirror )
353 {
354 if ( !(mirror instanceof Mirror) )
355 {
356 throw new ClassCastException( "Settings.removeMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() );
357 }
358 getMirrors().remove( mirror );
359 }
360
361
362
363
364
365
366 public void removePluginGroup( String string )
367 {
368 if ( !(string instanceof String) )
369 {
370 throw new ClassCastException( "Settings.removePluginGroups(string) parameter must be instanceof " + String.class.getName() );
371 }
372 getPluginGroups().remove( string );
373 }
374
375
376
377
378
379
380 public void removeProfile( Profile profile )
381 {
382 if ( !(profile instanceof Profile) )
383 {
384 throw new ClassCastException( "Settings.removeProfiles(profile) parameter must be instanceof " + Profile.class.getName() );
385 }
386 getProfiles().remove( profile );
387 }
388
389
390
391
392
393
394 public void removeProxy( Proxy proxy )
395 {
396 if ( !(proxy instanceof Proxy) )
397 {
398 throw new ClassCastException( "Settings.removeProxies(proxy) parameter must be instanceof " + Proxy.class.getName() );
399 }
400 getProxies().remove( proxy );
401 }
402
403
404
405
406
407
408 public void removeServer( Server server )
409 {
410 if ( !(server instanceof Server) )
411 {
412 throw new ClassCastException( "Settings.removeServers(server) parameter must be instanceof " + Server.class.getName() );
413 }
414 getServers().remove( server );
415 }
416
417
418
419
420
421
422
423
424 public void setActiveProfiles( java.util.List<String> activeProfiles )
425 {
426 this.activeProfiles = activeProfiles;
427 }
428
429
430
431
432
433
434
435 public void setInteractiveMode( boolean interactiveMode )
436 {
437 this.interactiveMode = interactiveMode;
438 }
439
440
441
442
443
444
445 public void setLocalRepository( String localRepository )
446 {
447 this.localRepository = localRepository;
448 }
449
450
451
452
453
454
455 public void setMirrors( java.util.List<Mirror> mirrors )
456 {
457 this.mirrors = mirrors;
458 }
459
460
461
462
463
464
465 public void setModelEncoding( String modelEncoding )
466 {
467 this.modelEncoding = modelEncoding;
468 }
469
470
471
472
473
474
475
476 public void setOffline( boolean offline )
477 {
478 this.offline = offline;
479 }
480
481
482
483
484
485
486
487 public void setPluginGroups( java.util.List<String> pluginGroups )
488 {
489 this.pluginGroups = pluginGroups;
490 }
491
492
493
494
495
496
497
498 public void setProfiles( java.util.List<Profile> profiles )
499 {
500 this.profiles = profiles;
501 }
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517 public void setProxies( java.util.List<Proxy> proxies )
518 {
519 this.proxies = proxies;
520 }
521
522
523
524
525
526
527
528
529
530
531 public void setServers( java.util.List<Server> servers )
532 {
533 this.servers = servers;
534 }
535
536
537
538
539
540
541
542 public void setUsePluginRegistry( boolean usePluginRegistry )
543 {
544 this.usePluginRegistry = usePluginRegistry;
545 }
546
547
548
549 public Boolean getInteractiveMode()
550 {
551 return Boolean.valueOf( isInteractiveMode() );
552 }
553
554 private Proxy activeProxy;
555
556
557
558
559 public void flushActiveProxy()
560 {
561 this.activeProxy = null;
562 }
563
564
565
566
567 public synchronized Proxy getActiveProxy()
568 {
569 if(activeProxy == null)
570 {
571 java.util.List proxies = getProxies();
572 if ( proxies != null && !proxies.isEmpty() )
573 {
574 for ( java.util.Iterator it = proxies.iterator(); it.hasNext(); )
575 {
576 Proxy proxy = (Proxy) it.next();
577 if ( proxy.isActive() )
578 {
579 activeProxy = proxy;
580 break;
581 }
582 }
583 }
584 }
585
586 return activeProxy;
587 }
588
589 public Server getServer( String serverId )
590 {
591 Server match = null;
592
593 java.util.List servers = getServers();
594 if ( servers != null && serverId != null )
595 {
596 for ( java.util.Iterator it = servers.iterator(); it.hasNext(); )
597 {
598 Server server = (Server) it.next();
599 if ( serverId.equals( server.getId() ) )
600 {
601 match = server;
602 break;
603 }
604 }
605 }
606
607 return match;
608 }
609
610 public Mirror getMirrorOf( String repositoryId )
611 {
612 Mirror match = null;
613
614 java.util.List mirrors = getMirrors();
615 if ( mirrors != null && repositoryId != null )
616 {
617 for ( java.util.Iterator it = mirrors.iterator(); it.hasNext(); )
618 {
619 Mirror mirror = (Mirror) it.next();
620 if ( repositoryId.equals( mirror.getMirrorOf() ) )
621 {
622 match = mirror;
623 break;
624 }
625 }
626 }
627
628 return match;
629 }
630
631 private java.util.Map profileMap;
632
633
634
635
636 public void flushProfileMap()
637 {
638 this.profileMap = null;
639 }
640
641
642
643
644
645 public java.util.Map getProfilesAsMap()
646 {
647 if ( profileMap == null )
648 {
649 profileMap = new java.util.LinkedHashMap();
650
651 if ( getProfiles() != null )
652 {
653 for ( java.util.Iterator it = getProfiles().iterator(); it.hasNext(); )
654 {
655 Profile profile = (Profile) it.next();
656
657 profileMap.put( profile.getId(), profile );
658 }
659 }
660 }
661
662 return profileMap;
663 }
664
665 private RuntimeInfo runtimeInfo;
666
667 public void setRuntimeInfo( RuntimeInfo runtimeInfo )
668 {
669 this.runtimeInfo = runtimeInfo;
670 }
671
672 public RuntimeInfo getRuntimeInfo()
673 {
674 return runtimeInfo;
675 }
676
677
678 }