OW2 Consortium jonas

Rev

Rev 22396 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15325 alitokmen 1
/**
2
 * JOnAS Configurator
19752 alitokmen 3
 * Copyright (C) 2008-2010 Bull S.A.S.
4
 * Copyright (C) 2008-2010 France Telecom R&D
15325 alitokmen 5
 * Contact: jonas-team@ow2.org
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20
 * USA
21
 *
22
 * --------------------------------------------------------------------------
23
 * $Id: Jonas53.java 22426 2012-05-04 17:05:04Z cazauxj $
24
 * --------------------------------------------------------------------------
25
 */
15455 alitokmen 26
package org.ow2.jonas.tools.configurator.impl;
15325 alitokmen 27
 
28
import java.io.File;
21900 alitokmen 29
import java.io.FileInputStream;
15558 alitokmen 30
import java.io.IOException;
21900 alitokmen 31
import java.io.InputStream;
15558 alitokmen 32
import java.io.OutputStream;
33
import java.io.PrintStream;
21899 alitokmen 34
import java.lang.reflect.Method;
35
import java.lang.reflect.Modifier;
22222 cazauxj 36
import java.net.MalformedURLException;
21899 alitokmen 37
import java.net.URISyntaxException;
38
import java.net.URL;
39
import java.net.URLClassLoader;
22151 cazauxj 40
import java.util.ArrayList;
21899 alitokmen 41
import java.util.Enumeration;
22151 cazauxj 42
import java.util.List;
22153 cazauxj 43
import java.util.Map;
21899 alitokmen 44
import java.util.Properties;
45
import java.util.SortedSet;
46
import java.util.TreeSet;
47
import java.util.jar.JarEntry;
48
import java.util.jar.JarFile;
18553 alitokmen 49
import java.util.logging.Logger;
15325 alitokmen 50
 
51
import org.apache.tools.ant.Project;
15535 rbresson 52
import org.apache.tools.ant.listener.TimestampedLogger;
21899 alitokmen 53
import org.ow2.jonas.antmodular.cluster.clusterdaemon.ClusterDaemon;
54
import org.ow2.jonas.antmodular.cmi.Cmi;
55
import org.ow2.jonas.antmodular.jonasbase.bootstrap.JOnASBaseTask;
56
import org.ow2.jonas.antmodular.jonasbase.bootstrap.JonasProperties;
57
import org.ow2.jonas.antmodular.jonasbase.bootstrap.Services;
58
import org.ow2.jonas.antmodular.jonasbase.carol.Carol;
59
import org.ow2.jonas.antmodular.jonasbase.db.base.Db;
60
import org.ow2.jonas.antmodular.jonasbase.db.h2.DbH2;
61
import org.ow2.jonas.antmodular.jonasbase.discovery.multicast.DiscoveryMulticast;
62
import org.ow2.jonas.antmodular.jonasbase.ha.Ha;
63
import org.ow2.jonas.antmodular.jonasbase.jms.Jms;
64
import org.ow2.jonas.antmodular.jonasbase.mail.Mail;
65
import org.ow2.jonas.antmodular.jonasbase.resource.JdbcXml;
22151 cazauxj 66
import org.ow2.jonas.antmodular.jonasbase.security.User;
67
import org.ow2.jonas.antmodular.jonasbase.security.Jaas;
68
import org.ow2.jonas.antmodular.jonasbase.smartclient.SmartClient;
69
import org.ow2.jonas.antmodular.jonasbase.web.tomcat.TomcatSessionManager;
21899 alitokmen 70
import org.ow2.jonas.antmodular.jonasbase.wsdl.WsdlPublish;
71
import org.ow2.jonas.antmodular.web.base.Ajp;
22151 cazauxj 72
import org.ow2.jonas.antmodular.web.base.Connectors;
21899 alitokmen 73
import org.ow2.jonas.antmodular.web.base.Http;
74
import org.ow2.jonas.antmodular.web.base.Https;
22149 cazauxj 75
import org.ow2.jonas.antmodular.web.base.SessionReplication;
21899 alitokmen 76
import org.ow2.jonas.antmodular.web.base.WebContainer;
19752 alitokmen 77
import org.ow2.jonas.tools.configurator.api.JDBCConfiguration;
22151 cazauxj 78
import org.ow2.jonas.tools.configurator.api.JdbcXMLConfiguration;
15459 alitokmen 79
import org.ow2.jonas.tools.configurator.api.JonasConfigurator;
15325 alitokmen 80
 
81
/**
21899 alitokmen 82
 * JonasConfigurator implementation for Jonas 5.3.x
15325 alitokmen 83
 *
21899 alitokmen 84
 * @author S. Ali Tokmen
22151 cazauxj 85
 * @author Jeremy Cazaux (support to extensible parameters according to a specific implementation)
15325 alitokmen 86
 */
21899 alitokmen 87
public class Jonas53 extends FileReplacerHelper implements JonasConfigurator {
15325 alitokmen 88
 
89
    /**
15672 alitokmen 90
     * JONAS_BASE
91
     */
92
    private File jonasFileBase;
93
 
94
    /**
15325 alitokmen 95
     * Link to the jonas ant task
96
     */
97
    private JOnASBaseTask jonasBase;
98
 
99
    /**
22256 cazauxj 100
     * To configure databases service
101
     */
102
    private DbH2 db;
103
 
104
    /**
15670 alitokmen 105
     * The cluster daemon configuration
15325 alitokmen 106
     */
15665 alitokmen 107
    private ClusterDaemon clusterDaemon;
15325 alitokmen 108
 
109
    /**
110
     * Configuration logger
111
     */
21899 alitokmen 112
    private static Logger logger = Logger.getLogger(Jonas53.class.getName());
15325 alitokmen 113
 
114
    /**
115
     * To configure protocols
116
     */
117
    private Carol carol;
118
 
119
    /**
15660 alitokmen 120
     * Has JOnAS protocols list been set?
121
     */
122
    private boolean isProtocolsListSet = false;
123
 
124
    /**
15325 alitokmen 125
     * To configure discovery sevice
126
     */
21899 alitokmen 127
    private DiscoveryMulticast discovery;
15325 alitokmen 128
 
129
    /**
22151 cazauxj 130
     * JDBC resources
15325 alitokmen 131
     */
22151 cazauxj 132
    private List<JdbcXml> jdbcXmlList;
15325 alitokmen 133
 
134
    /**
135
     * To configure jms
136
     */
137
    private Jms jms;
138
 
139
    /**
140
     * To configure jonas global properties
141
     */
142
    private JonasProperties jonasProperties;
143
 
144
    /**
22151 cazauxj 145
     * To configure mails
15325 alitokmen 146
     */
22151 cazauxj 147
    private List<Mail> mails;
15325 alitokmen 148
 
149
    /**
150
     * To configure active services
151
     */
152
    private Services services;
153
 
154
    /**
155
     * To configure web container
156
     */
21899 alitokmen 157
    private String webContainer;
15325 alitokmen 158
 
159
    /**
21899 alitokmen 160
     * To configure web container
15325 alitokmen 161
     */
21899 alitokmen 162
    private String jvmRoute;
15325 alitokmen 163
 
164
    /**
22151 cazauxj 165
     * To configure the algorithm of the web session replication
15325 alitokmen 166
     */
22151 cazauxj 167
    private String sessionReplicationAlgorithm;
15325 alitokmen 168
 
169
    /**
22151 cazauxj 170
     * Cluster name of the web session replication
15325 alitokmen 171
     */
22151 cazauxj 172
    private String sessionReplicationClusterName;
15325 alitokmen 173
 
174
    /**
22151 cazauxj 175
     * Multicast address usefull to configure the web session replication
15325 alitokmen 176
     */
22151 cazauxj 177
    private String sessionReplicationMulticastAddress;
15325 alitokmen 178
 
179
    /**
22151 cazauxj 180
     * Multicast port usefull to configure the web session replication
15325 alitokmen 181
     */
22151 cazauxj 182
    private String sessionReplicationMulticastPort;
15325 alitokmen 183
 
184
    /**
22151 cazauxj 185
     * Listen port usefull to configure the web session replication
186
     */
187
    private String sessionReplicationListenPort;
188
 
189
    /**
18562 alitokmen 190
     * To configure wsdl wsdlPublisherFile
15325 alitokmen 191
     */
21899 alitokmen 192
    private org.ow2.jonas.antmodular.jonasbase.wsdl.File wsdlPublisherFile;
15325 alitokmen 193
 
194
    /**
15655 alitokmen 195
     * To configure WSDL publishing
15325 alitokmen 196
     */
197
    private WsdlPublish wsdlPublish;
198
 
199
    /**
200
     * To configure ejb clustering
201
     */
15604 rbresson 202
    private Cmi cmi;
15325 alitokmen 203
 
204
    /**
15535 rbresson 205
     * To configure ha cluster
206
     */
15604 rbresson 207
    private Ha ha;
15535 rbresson 208
 
209
    /**
22151 cazauxj 210
     * To configure the smartclient service
211
     */
212
    private SmartClient smartClient;
213
 
214
    /**
215
     * To configure the security
216
     */
217
    private Jaas security;
218
 
219
    /**
15363 rbresson 220
     * The project, not really usefull, only to have a project to pass to ant
221
     * task.
222
     */
223
    private Project project;
224
 
225
    /**
15604 rbresson 226
     * Is jonas root set
15363 rbresson 227
     */
15604 rbresson 228
    private boolean isJonasRootSet = false;
15363 rbresson 229
 
230
    /**
15604 rbresson 231
     * Is jonas base set
15363 rbresson 232
     */
15604 rbresson 233
    private boolean isJonasBaseSet = false;
15363 rbresson 234
 
235
    /**
15560 rbresson 236
     * Is http webservice activated
237
     */
22151 cazauxj 238
    private Boolean isHttpActivated = false;
15560 rbresson 239
 
240
    /**
241
     * Is https webservice activated
242
     */
243
    private Boolean isHttpsActivated = false;
244
 
245
    /**
246
     * Is ajp webservice activated
247
     */
248
    private Boolean isAjpActivated = false;
249
 
250
    /**
251
     * Is http replication webservice activated
252
     */
253
    private Boolean isHttpReplicationActivated = false;
254
 
255
    /**
22151 cazauxj 256
     * Is http session manager activated (only usefull for tomcat7 currently)
257
     */
258
    private Boolean isHttpSessionManagerActivated = false;
259
 
260
    /**
261
     * Is web on demand activated
262
     */
263
    private Boolean isWebOnDemandActivated = false;
264
 
265
    /**
266
     * Web ondemand redirect port
267
     */
268
    private String webOnDemandRedirectPort;
269
 
270
    /**
271
     * The http port to configure
272
     */
273
    private String httpPort;
274
 
275
    /**
276
     * The max http threads to configure
277
     */
278
    private String httpMaxThreads;
279
 
280
    /**
281
     * The min spare threads to configure
282
     */
283
    private String httpMinSpareThreads;
284
 
285
    /**
286
     * The enable http lookups property to configure
287
     */
288
    private Boolean httpEnableLookups;
289
 
290
    /**
291
     * The http connection timeout to configure
292
     */
293
    private String httpConnectionTimeout;
294
 
295
    /**
296
     * The http accept count to configure
297
     */
298
    private String httpAcceptCount;
299
 
300
    /**
301
     * The max keep alive http request
302
     */
303
    private String httpMaxKeepAliveRequest;
304
 
305
    /**
306
     * The http compression
307
     */
308
    private String httpCompression;
309
 
310
    /**
311
     * The http redirect port
312
     */
313
    private String httpRedirectPort;
314
 
315
    /**
316
     * The https port
317
     */
318
    private String httpsPort;
319
 
320
    /**
321
     * The max https threads
322
     */
323
    private String httpsMaxThreads;
324
 
325
    /**
326
     * The min spare https threads
327
     */
328
    private String httpsMinSpareThreads;
329
 
330
    /**
331
     * The enable https lookups property to configure
332
     */
333
    private Boolean httpsEnableLookups;
334
 
335
    /**
336
     * The https connection timeout
337
     */
338
    private String httpsConnectionTimeout;
339
 
340
    /**
341
     * The https accept count
342
     */
343
    private String httpsAcceptCount;
344
 
345
    /**
346
     * The max keep alive https requests
347
     */
348
    private String httpsMaxKeepAliveRequest;
349
 
350
    /**
351
     * The https compression
352
     */
353
    private String httpsCompression;
354
 
355
    /**
356
     * The https redirect port
357
     */
358
    private String httpsRedirectPort;
359
 
360
    /**
361
     * The https keystore file
362
     */
363
    private String httpsKeystoreFile;
364
 
365
    /**
366
     * The https keystore password
367
     */
368
    private String httpsKeystorePass;
369
 
370
    /**
371
     * The ajp port
372
     */
373
    private String ajpPort;
374
 
375
    /**
376
     * The max ajp threads
377
     */
378
    private String ajpMaxThreads;
379
 
380
    /**
381
     * The min spare ajp threads
382
     */
383
    private String ajpMinSpareThreads;
384
 
385
    /**
386
     * The enable ajp lookups property to configure
387
     */
388
    private Boolean ajpEnableLookups;
389
 
390
    /**
391
     * The ajp connection timeout
392
     */
393
    private String ajpConnectionTimeout;
394
 
395
    /**
396
     * The ajp accept count
397
     */
398
    private String ajpAcceptCount;
399
 
400
    /**
401
     * The ajp redirect port
402
     */
403
    private String ajpRedirectPort;
404
 
405
    /**
406
     * Max active web sessions
407
     */
408
    private String maxActiveSession;
409
 
410
    /**
411
     * Database id
412
     */
413
    private String dbId;
414
 
415
    /**
416
     * List of users
417
     */
418
    List<User> users;
419
 
420
    /**
421
     * List of admins
422
     */
423
    List<User> admins;
424
 
425
    /**
22222 cazauxj 426
     * Wrapper Configurator api
427
     */
428
    JOnASWrapper wrapper;
429
 
430
    /**
15325 alitokmen 431
     * Derfault constructor
432
     */
21899 alitokmen 433
    public Jonas53() {
22256 cazauxj 434
        this.createProject();
15325 alitokmen 435
        this.jonasBase = new JOnASBaseTask();
15363 rbresson 436
        this.jonasBase.setProject(this.project);
22426 cazauxj 437
        this.jonasBase.setSkipOptionalDeployablesCopy(true);
15325 alitokmen 438
 
439
        this.jonasProperties = new JonasProperties();
22256 cazauxj 440
        this.jonasProperties.setProject(this.project);
15325 alitokmen 441
 
442
        this.services = new Services();
21899 alitokmen 443
        this.services.setProject(this.project);
444
 
22256 cazauxj 445
        this.carol = new Carol();
446
        this.carol.setProject(this.project);
21899 alitokmen 447
 
22256 cazauxj 448
        this.security = new Jaas();
449
        this.security.setProject(this.project);
15325 alitokmen 450
 
22256 cazauxj 451
        this.jdbcXmlList = new ArrayList<JdbcXml>();
452
        this.mails = new ArrayList<Mail>();
22151 cazauxj 453
 
454
        this.users = new ArrayList<User>();
455
        this.admins = new ArrayList<User>();
15649 rbresson 456
 
21899 alitokmen 457
        Jonas53.logger.finest("Created the JOnAS 5 configurator instance");
15325 alitokmen 458
    }
459
 
15363 rbresson 460
    /**
461
     * Create the project
462
     */
463
    private void createProject() {
464
        this.project = new Project();
465
        this.project.init();
466
        this.project.initProperties();
15558 alitokmen 467
 
18553 alitokmen 468
        TimestampedLogger logger = new TimestampedLogger();
469
        logger.setMessageOutputLevel(Project.MSG_DEBUG);
15669 alitokmen 470
 
18553 alitokmen 471
        logger.setOutputPrintStream(new PrintStream(new OutputStream() {
472
            StringBuffer buf = new StringBuffer();
473
 
474
            @Override
475
            public void write(final int b) throws IOException {
476
                if (b == '\n' || b == '\r') {
477
                    if (this.buf.length() > 0) {
21899 alitokmen 478
                        Jonas53.logger.finest(this.buf.toString());
18553 alitokmen 479
                        this.buf.setLength(0);
15558 alitokmen 480
                    }
18553 alitokmen 481
                } else {
482
                    this.buf.append((char) b);
15558 alitokmen 483
                }
18553 alitokmen 484
            }
485
        }));
15669 alitokmen 486
 
18553 alitokmen 487
        this.project.addBuildListener(logger);
15363 rbresson 488
    }
489
 
15325 alitokmen 490
    /* ------------------------------- */
491
    /* Jonas global parameters */
492
    /**
493
     * {@inheritDoc}
494
     */
495
    public void setJdk(final String jdk) {
21899 alitokmen 496
        Jonas53.logger.finest("[GlobalParameters] setting jdk : " + jdk);
18708 alitokmen 497
        NotApplicableHelper.notApplicable("GlobalParameters.Jdk");
15325 alitokmen 498
    }
499
 
500
    /**
501
     * {@inheritDoc}
502
     */
503
    public void setJavaOpts(final String javaOpts) {
21899 alitokmen 504
        Jonas53.logger.finest("[GlobalParameters] setting java opts : " + javaOpts);
505
        NotApplicableHelper.notApplicable("GlobalParameters.JavaOpts");
15325 alitokmen 506
    }
507
 
508
    /**
509
     * {@inheritDoc}
510
     */
511
    public void setJonasRoot(final String jonasRoot) {
21899 alitokmen 512
        Jonas53.logger.finest("[GlobalParameters] setting jonas root : " + jonasRoot);
513
        this.project.setProperty("jonas.root", jonasRoot);
15363 rbresson 514
 
15604 rbresson 515
        this.isJonasRootSet = true;
15325 alitokmen 516
    }
517
 
518
    /**
519
     * {@inheritDoc}
520
     */
521
    public void setJonasBase(final String jonasBase) {
21899 alitokmen 522
        Jonas53.logger.finest("[GlobalParameters] setting jonas base : " + jonasBase);
15672 alitokmen 523
        this.jonasFileBase = new File(jonasBase);
18432 alitokmen 524
        this.project.setProperty("jonas.base", jonasBase);
15363 rbresson 525
 
15604 rbresson 526
        this.isJonasBaseSet = true;
15325 alitokmen 527
    }
528
 
529
    /**
530
     * {@inheritDoc}
531
     */
22151 cazauxj 532
    public void isJOnASBaseToUpdate(final Boolean update) {
533
        Jonas53.logger.finest("[GlobalParameters] setting isJonasBaseToUpdate : " + update);
534
        if (update != null) {
22390 cazauxj 535
            this.jonasBase.setUpdate(update);
22151 cazauxj 536
        }
537
    }
538
 
539
    /**
540
     * {@inheritDoc}
541
     */
15325 alitokmen 542
    public void setJonasName(final String jonasName) {
21899 alitokmen 543
        Jonas53.logger.finest("[GlobalParameters] setting jonas name : " + jonasName);
18429 alitokmen 544
        this.addReplacement("jonas.properties", "jonas.name    jonas", "jonas.name    " + jonasName);
15325 alitokmen 545
    }
546
 
547
    /**
548
     * {@inheritDoc}
549
     */
550
    public void setJonasDomain(final String jonasDomain) {
21899 alitokmen 551
        Jonas53.logger.finest("[GlobalParameters] setting jonas domain : " + jonasDomain);
18430 alitokmen 552
        this.addReplacement("jonas.properties", "domain.name    jonas", "domain.name    " + jonasDomain);
15325 alitokmen 553
    }
554
 
555
    /**
556
     * {@inheritDoc}
557
     */
558
    public void setHost(final String jonasHost) {
21899 alitokmen 559
        Jonas53.logger.finest("[GlobalParameters] setting host : " + jonasHost);
22151 cazauxj 560
        NotApplicableHelper.notApplicable("Host.");
15325 alitokmen 561
    }
562
 
18553 alitokmen 563
    /**
564
     * {@inheritDoc}
565
     */
566
    public void setJonasDevelopment(final boolean development) {
567
        logger.finest("[GlobalParameters] setting jonas.development : " + development);
21899 alitokmen 568
        this.jonasProperties.setDevelopment(development);
18553 alitokmen 569
    }
570
 
22151 cazauxj 571
    /**
572
     * {@inheritDoc}
573
     */
574
    public void setLogConfigFile(final String logConfigFile) {
575
        this.jonasProperties.setConfigfile(logConfigFile);
576
    }
577
 
578
    /**
579
     * {@inheritDoc}
580
     */
581
    public void setMaster(final Boolean isMaster) {
582
        this.jonasProperties.setMaster(isMaster);
583
    }
584
 
585
    /**
586
     * {@inheritDoc}
587
     */
588
    public void setSecurityPropagation(final Boolean securityPropagation) {
589
        this.jonasProperties.setSecurityPropagation(securityPropagation);
590
    }
591
 
592
    /**
593
     * {@inheritDoc}
594
     */
595
    public void setTransactionPropagation(final Boolean transactionPropagation) {
596
        this.jonasProperties.setTransactionPropagation(transactionPropagation);
597
    }
598
 
599
    /**
600
     * {@inheritDoc}
601
     */
602
    public void setCsiv2Propagation(final Boolean csiv2Propagation) {
603
        this.jonasProperties.setCsiv2Propagation(csiv2Propagation);
604
    }
605
 
15325 alitokmen 606
    /* ------------------------------- */
607
 
608
    /* ------------------------------- */
609
    /* Jonas protocols configuation */
610
    /**
611
     * {@inheritDoc}
612
     */
613
    public void setProtocolsList(final String protocolsList) {
19131 alitokmen 614
        if (protocolsList != null && protocolsList.contains("cmi")) {
19752 alitokmen 615
            throw new IllegalArgumentException("In JOnAS 5, CMI has become a service. To enable CMI, follow these steps:"
616
                + "\n\t1) In the CAROL protocols list, use JRMP, IIOP and/or IRMI as usual"
617
                + "\n\t2) In the JOnAS services list, add the \"cmi\" service");
19131 alitokmen 618
        }
619
 
21899 alitokmen 620
        Jonas53.logger.finest("[Protocols configuration] setting protocols list : " + protocolsList);
15325 alitokmen 621
        this.carol.setProtocols(protocolsList);
15660 alitokmen 622
        this.isProtocolsListSet = true;
15325 alitokmen 623
    }
624
 
625
    /**
626
     * {@inheritDoc}
627
     */
15556 rbresson 628
    public void setProtocolsIrmiPort(final String irmiPort) {
21899 alitokmen 629
        Jonas53.logger.finest("[Protocols configuration] setting irmi port : " + irmiPort);
15556 rbresson 630
        this.carol.setIrmiPort(irmiPort);
15325 alitokmen 631
    }
632
 
633
    /**
634
     * {@inheritDoc}
635
     */
15556 rbresson 636
    public void setProtocolsIiopPort(final String iiopPort) {
21899 alitokmen 637
        Jonas53.logger.finest("[Protocols configuration] setting iiop port : " + iiopPort);
15556 rbresson 638
        this.carol.setIiopPort(iiopPort);
639
    }
640
 
641
    /**
642
     * {@inheritDoc}
643
     */
15325 alitokmen 644
    public void setProtocolsJrmpPort(final String jrmpPort) {
21899 alitokmen 645
        Jonas53.logger.finest("[Protocols configuration] setting jrmp port : " + jrmpPort);
15325 alitokmen 646
        this.carol.setJrmpPort(jrmpPort);
647
    }
648
 
649
    /**
650
     * {@inheritDoc}
651
     */
22151 cazauxj 652
    public void setProtocolsJrmLocalRegistry(final Boolean localRegistry) {
653
        Jonas53.logger.finest("[Protocols configuration] setting jrmp local registry : " + localRegistry);
654
        this.carol.setLocalRegistry(localRegistry);
655
    }
656
 
657
    /**
658
     * {@inheritDoc}
659
     */
660
    public void setCarolHost(final String host) {
661
        Jonas53.logger.finest("[Protocols configuration] setting host : " + host);
662
        this.carol.setHost(host);
663
    }
664
 
665
    /**
666
     * {@inheritDoc}
667
     */
15700 alitokmen 668
    public void setProtocolsCmiPort(final String cmiPort) {
21899 alitokmen 669
        Jonas53.logger.finest("[Protocols configuration] setting cmi port : " + cmiPort);
19133 alitokmen 670
        NotApplicableHelper.notApplicable("Protocols.CmiPort");
15700 alitokmen 671
    }
672
 
673
    /**
674
     * {@inheritDoc}
675
     */
15325 alitokmen 676
    public void setProtocolsLocalCallOptimized(final Boolean localCallOptimized) {
21899 alitokmen 677
        Jonas53.logger.finest("[Protocols configuration] setting jndi local call optimisation : " + localCallOptimized);
15325 alitokmen 678
        this.carol.setJrmpOptimization(localCallOptimized);
679
    }
680
 
681
    /* ------------------------------- */
682
 
683
    /* ------------------------------- */
684
    /* Active services */
685
    /**
686
     * {@inheritDoc}
687
     */
688
    public void setServices(final String services) {
21899 alitokmen 689
        Jonas53.logger.finest("setting actives services list : " + services);
15325 alitokmen 690
        this.services.setNames(services);
691
        this.jonasProperties.setServices(services);
692
    }
693
 
694
    /* ------------------------------- */
695
 
696
    /* ------------------------------- */
697
    /* Service web configuration */
698
    /**
699
     * {@inheritDoc}
700
     */
21899 alitokmen 701
    public void setWebcontainer(final String webContainer) {
702
        Jonas53.logger.finest("[Web configuration] setting webContainer : " + webContainer);
703
        this.webContainer = webContainer;
704
    }
705
 
706
    /**
707
     * {@inheritDoc}
708
     */
22151 cazauxj 709
    public void setHttpConnectorActivation(final Boolean activation) {
710
        Jonas53.logger.finest("[Web configuration] setting isHttpActivated : " + activation);
711
        this.isHttpActivated = activation;
712
    }
713
 
714
    /**
715
     * {@inheritDoc}
716
     */
15325 alitokmen 717
    public void setHttpsConnectorActivation(final Boolean activation) {
21899 alitokmen 718
        Jonas53.logger.finest("[Web configuration] setting isHttpsActivated : " + activation);
15560 rbresson 719
        this.isHttpsActivated = activation;
15325 alitokmen 720
    }
721
 
722
    /**
723
     * {@inheritDoc}
724
     */
725
    public void setAjpConnectorActivation(final Boolean activation) {
21899 alitokmen 726
        Jonas53.logger.finest("[Web configuration] setting isAjpActivated : " + activation);
15560 rbresson 727
        this.isAjpActivated = activation;
15325 alitokmen 728
    }
729
 
730
    /**
731
     * {@inheritDoc}
732
     */
733
    public void setHttpSessionReplicationActivation(final Boolean activation) {
21899 alitokmen 734
        Jonas53.logger.finest("[Web configuration] setting isHttpReplicationActivated : " + activation);
15560 rbresson 735
        this.isHttpReplicationActivated = activation;
15325 alitokmen 736
    }
737
 
738
    /**
739
     * {@inheritDoc}
740
     */
22151 cazauxj 741
    public void setHttpSessionManagerActivation(final Boolean activation) {
742
        Jonas53.logger.finest("[Web configuration] setting isHttpSessionManagerActivated : " + activation);
743
        this.isHttpSessionManagerActivated = activation;
744
    }
745
 
746
    /**
747
     * {@inheritDoc}
748
     */
749
    public void setWebOndemandActivation(final Boolean activation) {
750
        Jonas53.logger.finest("[Web configuration] setting isWebOnDemandActivated : " + activation);
751
        this.isWebOnDemandActivated = activation;
752
    }
753
 
754
    /**
755
     * {@inheritDoc}
756
     */
757
    public void setWebOndemandRedirectPort(final String redirectPort) {
758
        Jonas53.logger.finest("[Web configuration] setting ondemand redirect port : " + redirectPort);
759
        this.webOnDemandRedirectPort = redirectPort;
760
    }
761
 
762
    /**
763
     * {@inheritDoc}
764
     */
15325 alitokmen 765
    public void setHttpPort(final String httpPort) {
21899 alitokmen 766
        Jonas53.logger.finest("[Web configuration] setting http port : " + httpPort);
22151 cazauxj 767
        this.httpPort = httpPort;
15325 alitokmen 768
    }
769
 
770
    /**
771
     * {@inheritDoc}
772
     */
773
    public void setHttpMaxThreads(final String httpMaxThreads) {
21899 alitokmen 774
        Jonas53.logger.finest("[Web configuration] setting max http threads : " + httpMaxThreads);
22151 cazauxj 775
        this.httpMaxThreads = httpMaxThreads;
15325 alitokmen 776
    }
777
 
778
    /**
779
     * {@inheritDoc}
780
     */
781
    public void setHttpMinSpareThreads(final String httpMinSpareThreads) {
21899 alitokmen 782
        Jonas53.logger.finest("[Web configuration] setting min http spare threads : " + httpMinSpareThreads);
22151 cazauxj 783
        this.httpMinSpareThreads = httpMinSpareThreads;
15325 alitokmen 784
    }
785
 
786
    /**
787
     * {@inheritDoc}
788
     */
22151 cazauxj 789
    @Deprecated // not used..
15325 alitokmen 790
    public void setHttpMaxSpareThreads(final String httpMaxSpareThreads) {
21899 alitokmen 791
        Jonas53.logger.finest("[Web configuration] setting max http spare threads : " + httpMaxSpareThreads);
18708 alitokmen 792
        NotApplicableHelper.notApplicable("HTTP.maxSpareThreads");
15325 alitokmen 793
    }
794
 
795
    /**
796
     * {@inheritDoc}
797
     */
22151 cazauxj 798
    public void setHttpEnableLookups(final Boolean enableLookups) {
799
        Jonas53.logger.finest("setting http enable lookups : " + enableLookups);
800
        this.httpEnableLookups = enableLookups;
801
    }
802
 
803
    /**
804
     * {@inheritDoc}
805
     */
806
    public void setHttpConnectionTimeout(final String connectionTimeout) {
807
        Jonas53.logger.finest("setting http connection timeout : " + connectionTimeout);
808
        this.httpConnectionTimeout = connectionTimeout;
809
    }
810
 
811
    /**
812
     * {@inheritDoc}
813
     */
814
    public void setHttpAcceptCount(final String acceptCount) {
815
        Jonas53.logger.finest("setting http accept count : " + acceptCount);
816
        this.httpAcceptCount = acceptCount;
817
    }
818
 
819
    /**
820
     * {@inheritDoc}
821
     */
822
    public void setHttpMaxKeepAliveRequest(final String maxKeepAliveRequest) {
823
        Jonas53.logger.finest("setting max keep alive http request : " + maxKeepAliveRequest);
824
        this.httpMaxKeepAliveRequest = maxKeepAliveRequest;
825
    }
826
 
827
    /**
828
     * {@inheritDoc}
829
     */
830
    public void setHttpCompression(final String compression) {
831
        Jonas53.logger.finest("setting http compression : " + compression);
832
        this.httpCompression = compression;
833
    }
834
 
835
    /**
836
     * {@inheritDoc}
837
     */
838
    public void setHttpRedirectPort(final String redirectPort) {
839
        Jonas53.logger.finest("setting http redirect port : " + redirectPort);
840
        this.httpRedirectPort = redirectPort;
841
    }
842
 
843
    /**
844
     * {@inheritDoc}
845
     */
15325 alitokmen 846
    public void setHttpsPort(final String httpsPort) {
21899 alitokmen 847
        Jonas53.logger.finest("[Web configuration] setting https port : " + httpsPort);
22151 cazauxj 848
        this.httpsPort = httpsPort;
15325 alitokmen 849
    }
850
 
851
    /**
852
     * {@inheritDoc}
853
     */
854
    public void setHttpsMaxThreads(final String httpsMaxThreads) {
21899 alitokmen 855
        Jonas53.logger.finest("[Web configuration] setting max https threads : " + httpsMaxThreads);
22151 cazauxj 856
        this.httpsMaxThreads = httpsMaxThreads;
15325 alitokmen 857
    }
858
 
859
    /**
860
     * {@inheritDoc}
861
     */
862
    public void setHttpsMinSpareThreads(final String httpsMinSpareThreads) {
21899 alitokmen 863
        Jonas53.logger.finest("setting min https spare threads : " + httpsMinSpareThreads);
22151 cazauxj 864
        this.httpsMinSpareThreads = httpsMinSpareThreads;
15325 alitokmen 865
    }
866
 
867
    /**
868
     * {@inheritDoc}
869
     */
22151 cazauxj 870
    @Deprecated //never used...
15325 alitokmen 871
    public void setHttpsMaxSpareThreads(final String httpsMaxSpareThreads) {
21899 alitokmen 872
        Jonas53.logger.finest("setting max https spare threads : " + httpsMaxSpareThreads);
18708 alitokmen 873
        NotApplicableHelper.notApplicable("HTTPS.maxSpareThreads");
15325 alitokmen 874
    }
875
 
876
    /**
877
     * {@inheritDoc}
878
     */
22151 cazauxj 879
    public void setHttpsEnableLookups(final Boolean enableLookups) {
880
        Jonas53.logger.finest("setting https enable lookups property : " + enableLookups);
881
        this.httpsEnableLookups = enableLookups;
882
    }
883
 
884
    /**
885
     * {@inheritDoc}
886
     */
887
    public void setHttpsConnectionTimeout(final String connectionTimeout) {
888
        Jonas53.logger.finest("setting https connection timeout : " + connectionTimeout);
889
        this.httpsConnectionTimeout = connectionTimeout;
890
    }
891
 
892
    /**
893
     * {@inheritDoc}
894
     */
895
    public void setHttpsAcceptCount(final String acceptCount) {
896
        Jonas53.logger.finest("setting https accept count : " + acceptCount);
897
        this.httpsAcceptCount = acceptCount;
898
    }
899
 
900
    /**
901
     * {@inheritDoc}
902
     */
903
    public void setHttpsMaxKeepAliveRequest(final String maxKeepAliveRequest) {
904
        Jonas53.logger.finest("setting max keep alive https request : " + maxKeepAliveRequest);
905
        this.httpsMaxKeepAliveRequest = maxKeepAliveRequest;
906
    }
907
 
908
    /**
909
     * {@inheritDoc}
910
     */
911
    public void setHttpsCompression(final String compression) {
912
        Jonas53.logger.finest("setting https compression : " + compression);
913
        this.httpsCompression = compression;
914
    }
915
 
916
    /**
917
     * {@inheritDoc}
918
     */
919
    public void setHttpsRedirectPort(final String redirectPort) {
920
        Jonas53.logger.finest("setting https redirect port : " + redirectPort);
921
        this.httpsRedirectPort = redirectPort;
922
    }
923
 
924
    /**
925
     * {@inheritDoc}
926
     */
927
    public void setHttpsKeystoreFile(final String keystoreFile) {
928
        Jonas53.logger.finest("setting https keystore file : " + keystoreFile);
929
        this.httpsKeystoreFile = keystoreFile;
930
    }
931
 
932
    /**
933
     * {@inheritDoc}
934
     */
935
    public void setHttpsKeystorePass(final String keystorePass) {
936
        Jonas53.logger.finest("setting https keystore password : " + keystorePass);
937
        this.httpsKeystorePass = keystorePass;
938
    }
939
 
940
    /**
941
     * {@inheritDoc}
942
     */
15325 alitokmen 943
    public void setAjpPort(final String ajpPort) {
21899 alitokmen 944
        Jonas53.logger.finest("[Web configuration] setting ajp port : " + ajpPort);
22151 cazauxj 945
        this.ajpPort = ajpPort;
15325 alitokmen 946
    }
947
 
948
    /**
949
     * {@inheritDoc}
950
     */
951
    public void setAjpMaxThreads(final String ajpMaxThreads) {
21899 alitokmen 952
        Jonas53.logger.finest("[Web configuration] setting max ajp threads : " + ajpMaxThreads);
22151 cazauxj 953
        this.ajpMaxThreads = ajpMaxThreads;
15325 alitokmen 954
    }
955
 
956
    /**
957
     * {@inheritDoc}
958
     */
959
    public void setAjpMinSpareThreads(final String ajpMinSpareThreads) {
21899 alitokmen 960
        Jonas53.logger.finest("[Web configuration] setting min ajp spare threads : " + ajpMinSpareThreads);
22151 cazauxj 961
        this.ajpMinSpareThreads = ajpMinSpareThreads;
15325 alitokmen 962
    }
963
 
964
    /**
965
     * {@inheritDoc}
966
     */
22151 cazauxj 967
    @Deprecated //never used...
15325 alitokmen 968
    public void setAjpMaxSpareThreads(final String ajpMaxSpareThreads) {
21899 alitokmen 969
        Jonas53.logger.finest("[Web configuration] setting max ajp spare threads : " + ajpMaxSpareThreads);
18708 alitokmen 970
        NotApplicableHelper.notApplicable("AJP.maxSpareThreads");
15325 alitokmen 971
    }
972
 
973
    /**
974
     * {@inheritDoc}
975
     */
22151 cazauxj 976
    public void setAjpEnableLookups(final Boolean enableLookups) {
977
        Jonas53.logger.finest("setting ajp enable lookups property : " + enableLookups);
978
        this.ajpEnableLookups = enableLookups;
979
    }
980
 
981
    /**
982
     * {@inheritDoc}
983
     */
984
    public void setAjpConnectionTimeout(final String connectionTimeout) {
985
        Jonas53.logger.finest("setting ajp connection timeout : " + connectionTimeout);
986
        this.ajpConnectionTimeout = connectionTimeout;
987
    }
988
 
989
    /**
990
     * {@inheritDoc}
991
     */
992
    public void setAjpAcceptCount(final String acceptCount) {
993
        Jonas53.logger.finest("setting ajp accept count : " + acceptCount);
994
        this.ajpAcceptCount = acceptCount;
995
    }
996
 
997
    /**
998
     * {@inheritDoc}
999
     */
1000
    public void setAjpRedirectPort(final String redirectPort) {
1001
        Jonas53.logger.finest("setting ajp redirect port : " + redirectPort);
1002
        this.ajpRedirectPort = redirectPort;
1003
    }
1004
 
1005
    /**
1006
     * {@inheritDoc}
1007
     */
1008
    public void setMaxActiveWebSessions(final String maxActiveSession) {
1009
        Jonas53.logger.finest("setting max active session : " + maxActiveSession);
1010
        this.maxActiveSession = maxActiveSession;
1011
    }
1012
 
1013
    /**
1014
     * {@inheritDoc}
1015
     */
22166 alitokmen 1016
    public void setJmxSecured(final boolean enabled) {
22167 alitokmen 1017
        Jonas53.logger.finest("[Security] setting JMX security:" + enabled);
22166 alitokmen 1018
        security.setSecureJmx(enabled);
1019
    }
1020
 
1021
    /**
1022
     * {@inheritDoc}
1023
     */
22151 cazauxj 1024
    public void addUser(final String username, final String password, final String roles, final String groups,
1025
                        final String description) {
1026
        User user = new User();
1027
        user.setName(username);
1028
        user.setPassword(password);
1029
        user.setGroups(groups);
1030
        user.setRoles(roles);
1031
        user.setDescription(description);
1032
        this.users.add(user);
1033
    }
1034
 
1035
    /**
1036
     * {@inheritDoc}
1037
     */
1038
    public void addAdmin(final String username, final String password) {
1039
        User admin = new User();
1040
        admin.setName(username);
1041
        admin.setPassword(password);
1042
        this.admins.add(admin);
1043
    }
1044
 
1045
    /**
1046
     * {@inheritDoc}
1047
     */
15325 alitokmen 1048
    public void setJvmRoute(final String jvmRoute) {
21899 alitokmen 1049
        Jonas53.logger.finest("[Web configuration] setting jvm route : " + jvmRoute);
1050
        this.jvmRoute = jvmRoute;
15325 alitokmen 1051
    }
1052
 
1053
    /**
1054
     * {@inheritDoc}
1055
     */
1056
    public void setHttpReplicationClusterName(final String clusterName) {
21899 alitokmen 1057
        Jonas53.logger.finest("[Web configuration] setting cluster name : " + clusterName);
22151 cazauxj 1058
        this.sessionReplicationClusterName = clusterName;
15325 alitokmen 1059
    }
1060
 
1061
    /**
1062
     * {@inheritDoc}
1063
     */
18562 alitokmen 1064
    public void setHttpReplicationMulticastAddress(final String mCastAddr) {
21899 alitokmen 1065
        Jonas53.logger.finest("[Web configuration] setting multi cast address : " + mCastAddr);
22151 cazauxj 1066
        this.sessionReplicationMulticastAddress = mCastAddr;
15325 alitokmen 1067
    }
1068
 
1069
    /**
1070
     * {@inheritDoc}
1071
     */
18562 alitokmen 1072
    public void setHttpReplicationMulticastPort(final String mCastPort) {
21899 alitokmen 1073
        Jonas53.logger.finest("[Web configuration] setting multi cast port : " + mCastPort);
22151 cazauxj 1074
        this.sessionReplicationMulticastPort = mCastPort;
15325 alitokmen 1075
    }
1076
 
1077
    /**
1078
     * {@inheritDoc}
1079
     */
1080
    public void setHttpReplicationListenPort(final String listenPort) {
21899 alitokmen 1081
        Jonas53.logger.finest("[Web configuration] setting listen port : " + listenPort);
22151 cazauxj 1082
        this.sessionReplicationListenPort = listenPort;
15325 alitokmen 1083
    }
1084
 
22151 cazauxj 1085
    /**
1086
     * {@inheritDoc}
1087
     */
1088
    public void setHttpReplicationAlgorithm(final String algorithm) {
1089
        Jonas53.logger.finest("[Web configuration] setting http replication algorithm : " + algorithm);
1090
        this.sessionReplicationAlgorithm = algorithm;
1091
    }
1092
 
15325 alitokmen 1093
    /* ------------------------------- */
1094
 
1095
    /* ------------------------------- */
22256 cazauxj 1096
    /**
1097
     * Active db service
1098
     */
1099
    private void initDb() {
1100
        if (this.db == null) {
1101
            this.db = new DbH2();
1102
            this.db.setProject(this.project);
1103
        }
1104
    }
1105
 
15325 alitokmen 1106
    /* Service db configuration */
1107
    /**
1108
     * {@inheritDoc}
1109
     */
1110
    public void setDbPort(final String port) {
21899 alitokmen 1111
        Jonas53.logger.finest("[Database configuration] setting db port: " + port);
22256 cazauxj 1112
        initDb();
15325 alitokmen 1113
        this.db.setPort(port);
1114
    }
1115
 
19758 alitokmen 1116
    /**
1117
     * {@inheritDoc}
1118
     */
1119
    public void setDbName(final String name) {
21899 alitokmen 1120
        Jonas53.logger.finest("[Database configuration] setting db name: " + name);
22256 cazauxj 1121
        initDb();
21899 alitokmen 1122
        this.db.setDbName(name);
19758 alitokmen 1123
    }
1124
 
1125
    /**
1126
     * {@inheritDoc}
1127
     */
1128
    public void setDbUsers(final String users) {
21899 alitokmen 1129
        Jonas53.logger.finest("[Database configuration] setting db users: " + users);
22256 cazauxj 1130
        initDb();
21899 alitokmen 1131
        this.db.setUsers(users);
19758 alitokmen 1132
    }
22151 cazauxj 1133
 
1134
    /**
1135
     * {@inheritDoc}
1136
     */
1137
    public void setDbId(final String dbId) {
1138
        this.dbId = dbId;
1139
    }
19758 alitokmen 1140
 
15325 alitokmen 1141
    /* ------------------------------- */
1142
 
1143
    /* ------------------------------- */
1144
    /* Service discovery configuration */
1145
    /**
1146
     * {@inheritDoc}
1147
     */
1148
    public void setDiscoveryMasterActivated(final Boolean masterActivated) {
21899 alitokmen 1149
        Jonas53.logger.finest("[Discovery configuration] setting masterActivated : " + masterActivated);
15325 alitokmen 1150
        this.jonasProperties.setMaster(masterActivated);
1151
    }
1152
 
1153
    /**
1154
     * {@inheritDoc}
1155
     */
1156
    public void setDiscoverySourcePort(final String sourcePort) {
21899 alitokmen 1157
        Jonas53.logger.finest("[Discovery configuration] setting source port : " + sourcePort);
22256 cazauxj 1158
        initDiscovery();
15325 alitokmen 1159
        this.discovery.setSourcePort(sourcePort);
1160
    }
1161
 
1162
    /**
1163
     * {@inheritDoc}
1164
     */
1165
    public void setDiscoveryDomainName(final String domainName) {
21899 alitokmen 1166
        Jonas53.logger.finest("[Discovery configuration] setting domain name : " + domainName);
1167
        this.addReplacement("jonas.properties", "domain.name    jonas", "domain.name    " + domainName);
15325 alitokmen 1168
    }
1169
 
1170
    /**
1171
     * {@inheritDoc}
1172
     */
1173
    public void setDiscoveryGreetingPort(final String greetingPort) {
21899 alitokmen 1174
        Jonas53.logger.finest("[Discovery configuration] setting greeting port : " + greetingPort);
22256 cazauxj 1175
        initDiscovery();
15543 rbresson 1176
        this.discovery.setGreetingPort(greetingPort);
15325 alitokmen 1177
    }
1178
 
1179
    /**
1180
     * {@inheritDoc}
1181
     */
1182
    public void setDiscoveryMulticastAddress(final String multicastAddress) {
21899 alitokmen 1183
        Jonas53.logger.finest("[Discovery configuration] setting multicast address : " + multicastAddress);
22256 cazauxj 1184
        initDiscovery();
15325 alitokmen 1185
        this.discovery.setMcastAddr(multicastAddress);
1186
    }
1187
 
1188
    /**
1189
     * {@inheritDoc}
1190
     */
1191
    public void setDiscoveryMulticastPort(final String multicastPort) {
21899 alitokmen 1192
        Jonas53.logger.finest("[Discovery configuration] setting multicast port : " + multicastPort);
22256 cazauxj 1193
        initDiscovery();
15325 alitokmen 1194
        this.discovery.setMcastPort(multicastPort);
1195
    }
1196
 
1197
    /**
1198
     * {@inheritDoc}
1199
     */
18562 alitokmen 1200
    public void setDiscoveryTTL(final String ttl) {
21899 alitokmen 1201
        Jonas53.logger.finest("[Discovery configuration] setting ttl : " + ttl);
22256 cazauxj 1202
        initDiscovery();
15325 alitokmen 1203
        this.discovery.setTtl(ttl);
1204
    }
1205
 
22256 cazauxj 1206
    /**
1207
     * Init discovery object if not set
1208
     */
1209
    private void initDiscovery() {
1210
        if (this.discovery == null) {
1211
            this.discovery = new DiscoveryMulticast();
1212
            this.discovery.setProject(this.project);
1213
        }
1214
    }
1215
 
15325 alitokmen 1216
    /* ------------------------------- */
1217
 
1218
    /* ------------------------------- */
1219
    /* Service mail configuration */
1220
    /**
1221
     * {@inheritDoc}
1222
     */
1223
    public void setMailFactoryType(final String factoryType) {
21899 alitokmen 1224
        Jonas53.logger.finest("[Mail Service Configuration] setting mail factory type : " + factoryType);
22160 alitokmen 1225
        NotApplicableHelper.notApplicable("Mail.factoryType");
15325 alitokmen 1226
    }
1227
 
1228
    /**
1229
     * {@inheritDoc}
1230
     */
1231
    public void setMailFactoryName(final String factoryName) {
21899 alitokmen 1232
        Jonas53.logger.finest("[Mail Service Configuration] setting mail factory name : " + factoryName);
22160 alitokmen 1233
        NotApplicableHelper.notApplicable("Mail.factoryName");
15325 alitokmen 1234
    }
1235
 
22151 cazauxj 1236
    /**
1237
     * {@inheritDoc}
1238
     */
1239
    public void addMailMimme(final String name, final String host, final String mailto, final String subject) {
1240
        Jonas53.logger.finest("[Mail Service Configuration] addition of a new mail mimme configuration file.");
1241
        Mail mail = new Mail();
1242
        mail.setProject(this.project);
1243
        mail.setName(name);
1244
        mail.setHost(host);
1245
        mail.setMailTo(mailto);
1246
        mail.setSubject(subject);
1247
        mail.setType("MimePartDataSource");
1248
        this.mails.add(mail);
1249
    }
1250
 
1251
    /**
1252
     * {@inheritDoc}
1253
     */
1254
    public void addMailSession(final String name) {
1255
        Jonas53.logger.finest("[Mail Service Configuration] addition of a new mail session configuration file.");
1256
        Mail mail = new Mail();
1257
        mail.setProject(this.project);
1258
        mail.setName(name);
1259
        mail.setType("Session");
1260
        this.mails.add(mail);
1261
    }
1262
 
15325 alitokmen 1263
    /* ------------------------------- */
1264
 
1265
    /* ------------------------------- */
1266
    /* Service WS configuration */
22256 cazauxj 1267
 
15325 alitokmen 1268
    /**
22256 cazauxj 1269
     * Init WsdlPublisherFile if not set
1270
     */
1271
    private void initWsdlPublisherFile() {
1272
        if (this.wsdlPublisherFile == null) {
1273
            this.wsdlPublisherFile = new org.ow2.jonas.antmodular.jonasbase.wsdl.File();
1274
        }
1275
    }
1276
 
1277
    /**
15325 alitokmen 1278
     * {@inheritDoc}
1279
     */
18562 alitokmen 1280
    public void setWsdlPublisherFileName(final String fileName) {
21899 alitokmen 1281
        Jonas53.logger.finest("[WS Service configuration] setting wsdlPublisherFile name : " + fileName);
22256 cazauxj 1282
        initWsdlPublisherFile();
18562 alitokmen 1283
        this.wsdlPublisherFile.setName(fileName);
15325 alitokmen 1284
    }
1285
 
1286
    /**
1287
     * {@inheritDoc}
1288
     */
18562 alitokmen 1289
    public void setWsdlPublisherFileDirectory(final String fileDir) {
21899 alitokmen 1290
        Jonas53.logger.finest("[WS Service configuration] setting wsdlPublisherFile directory : " + fileDir);
22256 cazauxj 1291
        initWsdlPublisherFile();
18562 alitokmen 1292
        this.wsdlPublisherFile.setDir(fileDir);
15325 alitokmen 1293
    }
1294
 
1295
    /* ------------------------------- */
1296
 
1297
    /* ------------------------------- */
1298
    /* Service HA configuration */
1299
    /**
1300
     * {@inheritDoc}
1301
     */
1302
    public void setHaActivated(final Boolean activated) {
21899 alitokmen 1303
        Jonas53.logger.finest("[HA Service configuration] setting ha activated : " + activated);
22256 cazauxj 1304
        //do nothing
15325 alitokmen 1305
    }
1306
 
1307
    /**
1308
     * {@inheritDoc}
1309
     */
18562 alitokmen 1310
    public void setHaMulticastAddress(final String multicastAddr) {
21899 alitokmen 1311
        Jonas53.logger.finest("[HA Service configuration] setting multicast address : " + multicastAddr);
22256 cazauxj 1312
        initHa();
15604 rbresson 1313
        this.ha.setMcastAddr(multicastAddr);
15325 alitokmen 1314
    }
1315
 
1316
    /**
1317
     * {@inheritDoc}
1318
     */
1319
    public void setHaMulticastPort(final String multicastPort) {
21899 alitokmen 1320
        Jonas53.logger.finest("[HA Service configuration] setting multicast port : " + multicastPort);
22256 cazauxj 1321
        initHa();
15604 rbresson 1322
        this.ha.setMcastPort(multicastPort);
15325 alitokmen 1323
    }
1324
 
22256 cazauxj 1325
    /**
1326
     * Activate HA
1327
     */
1328
    private void initHa() {
1329
        if (this.ha == null) {
1330
            this.ha = new Ha();
1331
            this.ha.setProject(this.project);
1332
        }
1333
    }
1334
 
15325 alitokmen 1335
    /* ------------------------------- */
1336
 
1337
    /* ------------------------------- */
1338
    /* Security manager configuration */
1339
    /**
1340
     * {@inheritDoc}
1341
     */
18562 alitokmen 1342
    public void setSecurityManagerActivated(final Boolean activation) {
21899 alitokmen 1343
        Jonas53.logger.finest("[Security Manager configuration] setting isActivates : " + activation);
15325 alitokmen 1344
        this.jonasProperties.setSecurityManager(activation);
1345
    }
1346
 
1347
    /* ------------------------------- */
1348
 
1349
    /* ------------------------------- */
1350
    /* Ejb clustering configuration */
1351
    /**
1352
     * {@inheritDoc}
1353
     */
15575 rbresson 1354
    /**
1355
     * {@inheritDoc}
1356
     */
1357
    public void setEjbClusteringActivated(final Boolean activated) {
21899 alitokmen 1358
        Jonas53.logger.finest("[Ejb Clustering configuration] setting ejb clustering activated activated : " + activated);
22256 cazauxj 1359
        if (activated) {
1360
            this.cmi = new Cmi();
1361
            this.cmi.setProject(this.project);
1362
        }
15575 rbresson 1363
    }
1364
 
18562 alitokmen 1365
    public void setEjbClusteringMulticastAddress(final String multicastAddr) {
21899 alitokmen 1366
        Jonas53.logger.finest("[Ejb Clustering configuration] setting multicast address : " + multicastAddr);
22256 cazauxj 1367
        if (this.cmi != null) {
1368
            this.cmi.setMcastAddr(multicastAddr);
1369
        }
15325 alitokmen 1370
    }
1371
 
1372
    /**
1373
     * {@inheritDoc}
1374
     */
1375
    public void setEjbClusteringMulticastPort(final String multicastPort) {
21899 alitokmen 1376
        Jonas53.logger.finest("[Ejb Clustering configuration] setting multicast port : " + multicastPort);
22256 cazauxj 1377
        if (this.cmi != null) {
1378
            this.cmi.setMcastPort(multicastPort);
1379
        }
15325 alitokmen 1380
    }
1381
 
22151 cazauxj 1382
    /**
1383
     * {@inheritDoc}
1384
     */
1385
    public void setEjbClusteringReplicationEnable(final Boolean enable) {
1386
        Jonas53.logger.finest("[EJB Clustering configuration] : " + enable);
22256 cazauxj 1387
        if (this.cmi != null) {
1388
            this.cmi.setReplicationEnabled(enable);
1389
        }
22151 cazauxj 1390
    }
1391
 
15325 alitokmen 1392
    /* ------------------------------- */
1393
 
1394
    /* ------------------------------- */
1395
    /* Jms configuration */
22256 cazauxj 1396
 
15325 alitokmen 1397
    /**
22256 cazauxj 1398
     * Initialize JMS if not set
1399
     */
1400
    private void initJms() {
1401
        if (this.jms == null) {
1402
            this.jms = new Jms();
1403
            this.jms.setProject(this.project);
1404
        }
1405
    }
1406
 
1407
    /**
15325 alitokmen 1408
     * {@inheritDoc}
1409
     */
1410
    public void setJmsPort(final String port) {
21899 alitokmen 1411
        Jonas53.logger.finest("[Jms configuration] setting port : " + port);
22256 cazauxj 1412
        initJms();
15325 alitokmen 1413
        this.jms.setPort(port);
1414
    }
1415
 
1416
    /**
1417
     * {@inheritDoc}
1418
     */
18562 alitokmen 1419
    public void setJmsQueues(final String queue) {
21899 alitokmen 1420
        Jonas53.logger.finest("[Jms configuration] setting queue : " + queue);
22256 cazauxj 1421
        initJms();
15325 alitokmen 1422
        this.jms.setInitialQueues(queue);
1423
    }
1424
 
1425
    /**
1426
     * {@inheritDoc}
1427
     */
18562 alitokmen 1428
    public void setJmsTopics(final String topic) {
21899 alitokmen 1429
        Jonas53.logger.finest("[Jms configuration] setting topic : " + topic);
22256 cazauxj 1430
        initJms();
15325 alitokmen 1431
        this.jms.setInitialTopics(topic);
1432
    }
1433
 
22151 cazauxj 1434
    /**
1435
     * {@inheritDoc}
1436
     */
1437
    public void setJmsHost(final String host) {
1438
        Jonas53.logger.finest("[Jms configuration] setting host : " + host);
22256 cazauxj 1439
        initJms();
22151 cazauxj 1440
        this.jms.setHost(host);
1441
    }
15325 alitokmen 1442
 
1443
    /**
1444
     * {@inheritDoc}
1445
     */
22151 cazauxj 1446
    public void addJdbcResource(final JdbcXMLConfiguration jdbcXMLConfiguration) {
21899 alitokmen 1447
        JdbcXml jdbcXml = new JdbcXml();
1448
        jdbcXml.setProject(this.project);
22151 cazauxj 1449
        if (jdbcXMLConfiguration.classname != null) {
1450
            Jonas53.logger.finest("[JdbcXML configuration] setting classname: " + jdbcXMLConfiguration.classname);
1451
            jdbcXml.setClassName(jdbcXMLConfiguration.classname);
19752 alitokmen 1452
        }
22151 cazauxj 1453
        if (jdbcXMLConfiguration.mapper != null) {
1454
            Jonas53.logger.finest("[JdbcXML configuration] setting mapper: " + jdbcXMLConfiguration.mapper);
1455
            jdbcXml.setMapper(jdbcXMLConfiguration.mapper);
19752 alitokmen 1456
        }
22151 cazauxj 1457
        if (jdbcXMLConfiguration.name != null) {
1458
            Jonas53.logger.finest("[JdbcXML configuration] setting name: " + jdbcXMLConfiguration.name);
1459
            jdbcXml.setName(jdbcXMLConfiguration.name);
19752 alitokmen 1460
        }
22151 cazauxj 1461
        if (jdbcXMLConfiguration.username != null) {
1462
            Jonas53.logger.finest("[JdbcXML configuration] setting username: " + jdbcXMLConfiguration.username);
1463
            jdbcXml.setUserName(jdbcXMLConfiguration.username);
19752 alitokmen 1464
        }
22151 cazauxj 1465
        if (jdbcXMLConfiguration.password != null) {
1466
            Jonas53.logger.finest("[JdbcXML configuration] setting password: " + jdbcXMLConfiguration.password);
1467
            jdbcXml.setPassword(jdbcXMLConfiguration.password);
1468
        }
1469
        if (jdbcXMLConfiguration.url != null) {
1470
            Jonas53.logger.finest("[JdbcXML configuration] setting url: " + jdbcXMLConfiguration.url);
1471
            jdbcXml.setUrl(jdbcXMLConfiguration.url);
1472
        }
1473
        if (jdbcXMLConfiguration.conCheckLevel != null)  {
1474
            Jonas53.logger.finest("[JdbcXML configuration] setting conCheckLevel: " + jdbcXMLConfiguration.conCheckLevel);
1475
            jdbcXml.setConCheckLevel(jdbcXMLConfiguration.conCheckLevel);
19752 alitokmen 1476
        }
22151 cazauxj 1477
        if (jdbcXMLConfiguration.connMaxAge != null) {
1478
            Jonas53.logger.finest("[JdbcXML configuration] setting connMaxAge: " + jdbcXMLConfiguration.connMaxAge);
1479
            jdbcXml.setConnMaxAge(jdbcXMLConfiguration.connMaxAge);
1480
        }
1481
        if (jdbcXMLConfiguration.conTestStmt != null) {
1482
            Jonas53.logger.finest("[JdbcXML configuration] setting conTestStmt: " + jdbcXMLConfiguration.conTestStmt);
1483
            jdbcXml.setConTestStmt(jdbcXMLConfiguration.conTestStmt);
1484
        }
1485
        if (jdbcXMLConfiguration.initConPool != null) {
1486
            Jonas53.logger.finest("[JdbcXML configuration] setting initConPool: " + jdbcXMLConfiguration.initConPool);
1487
            jdbcXml.setInitConPool(jdbcXMLConfiguration.initConPool);
1488
        }
1489
        if (jdbcXMLConfiguration.maxConPool != null) {
1490
            Jonas53.logger.finest("[JdbcXML configuration] setting maxConPool: " + jdbcXMLConfiguration.maxConPool);
1491
            jdbcXml.setMaxConPool(jdbcXMLConfiguration.maxConPool);
1492
        }
1493
        if (jdbcXMLConfiguration.maxOpenTime != null) {
1494
            Jonas53.logger.finest("[JdbcXML configuration] setting maxOpenTime: " + jdbcXMLConfiguration.maxOpenTime);
1495
            jdbcXml.setMaxOpenTime(jdbcXMLConfiguration.maxOpenTime);
19752 alitokmen 1496
        }
22151 cazauxj 1497
        if (jdbcXMLConfiguration.maxWaiters != null) {
1498
            Jonas53.logger.finest("[JdbcXML configuration] setting maxWaiters: " + jdbcXMLConfiguration.maxWaiters);
1499
            jdbcXml.setMaxWaiters(jdbcXMLConfiguration.maxWaiters);
19752 alitokmen 1500
        }
22151 cazauxj 1501
        if (jdbcXMLConfiguration.minConPool != null) {
1502
            Jonas53.logger.finest("[JdbcXML configuration] setting minConPool: " + jdbcXMLConfiguration.minConPool);
1503
            jdbcXml.setMinConPool(jdbcXMLConfiguration.minConPool);
19752 alitokmen 1504
        }
22151 cazauxj 1505
        if (jdbcXMLConfiguration.maxWaitTime != null) {
1506
            Jonas53.logger.finest("[JdbcXML configuration] setting maxWaiters: " + jdbcXMLConfiguration.maxWaiters);
1507
            jdbcXml.setMaxWaitTime(jdbcXMLConfiguration.maxWaitTime);
19752 alitokmen 1508
        }
22151 cazauxj 1509
        if (jdbcXMLConfiguration.pstmtCachePolicy != null) {
1510
            Jonas53.logger.finest("[JdbcXML configuration] setting pstmtCachePolicy: " + jdbcXMLConfiguration.pstmtCachePolicy);
1511
            jdbcXml.setPstmtCachePolicy(jdbcXMLConfiguration.pstmtCachePolicy);
19752 alitokmen 1512
        }
22151 cazauxj 1513
        if (jdbcXMLConfiguration.pstmtMax != null) {
1514
            Jonas53.logger.finest("[JdbcXML configuration] setting pstmtMax: " + jdbcXMLConfiguration.pstmtMax);
1515
            jdbcXml.setPstmtMax(jdbcXMLConfiguration.pstmtMax);
19752 alitokmen 1516
        }
22151 cazauxj 1517
        if (jdbcXMLConfiguration.samplingPeriod != null) {
1518
            Jonas53.logger.finest("[JdbcXML configuration] setting samplingPeriod: " + jdbcXMLConfiguration.samplingPeriod);
1519
            jdbcXml.setSamplingPeriod(jdbcXMLConfiguration.samplingPeriod);
19752 alitokmen 1520
        }
22151 cazauxj 1521
        if (jdbcXMLConfiguration.description != null) {
1522
            Jonas53.logger.finest("[JdbcXML configuration] setting description: " + jdbcXMLConfiguration.description);
1523
            jdbcXml.setDescription(jdbcXMLConfiguration.description);
19752 alitokmen 1524
        }
22151 cazauxj 1525
        this.jdbcXmlList.add(jdbcXml);
1526
    }
15325 alitokmen 1527
 
22151 cazauxj 1528
    /**
1529
     * {@inheritDoc}
1530
     */
1531
    public void addJdbcResource(final String ref, final JdbcXMLConfiguration jdbcXMLConfiguration) {
1532
        if (ref.equals(dbId)) {
22256 cazauxj 1533
            initDb();
22151 cazauxj 1534
            jdbcXMLConfiguration.classname = this.db.getClassname();
1535
            jdbcXMLConfiguration.mapper = this.db.getMapper();
1536
            jdbcXMLConfiguration.url = this.db.getUrl("localhost");
22256 cazauxj 1537
            Map.Entry<String, String> user = this.db.getFirstUsernameAndPassword();
22151 cazauxj 1538
            jdbcXMLConfiguration.username = user.getKey();
1539
            jdbcXMLConfiguration.password = user.getValue();
1540
            addJdbcResource(jdbcXMLConfiguration);
1541
        } else {
1542
            NotApplicableHelper.notApplicable("Resource.Jdbc. The reference " + ref + " is invalid.");
19752 alitokmen 1543
        }
22151 cazauxj 1544
    }
15325 alitokmen 1545
 
22151 cazauxj 1546
    /**
1547
     * {@inheritDoc}
1548
     */
1549
    public void addJdbcRA(final String raName, final JDBCConfiguration configuration) {
1550
        NotApplicableHelper.notApplicable("resource.addJdbcRa");
1551
    }
15325 alitokmen 1552
 
22151 cazauxj 1553
    /**
22256 cazauxj 1554
     * Initialize Smartclient if not set
1555
     */
1556
    private void initSmartclient() {
1557
        if (this.smartClient == null) {
1558
            this.smartClient = new SmartClient();
1559
            this.smartClient.setProject(this.project);
1560
        }
1561
    }
1562
 
1563
    /**
22151 cazauxj 1564
     * {@inheritDoc}
1565
     */
1566
    public void setSmartClientPort(final String port) {
1567
        Jonas53.logger.finest("[Smartclient configuration] setting port: " + port);
22256 cazauxj 1568
        initSmartclient();
22151 cazauxj 1569
        this.smartClient.setPort(port);
15325 alitokmen 1570
    }
1571
 
1572
    /* ------------------------------- */
1573
 
1574
    /**
1575
     * {@inheritDoc}
1576
     */
1577
    public void execute() {
15604 rbresson 1578
        if (!this.isJonasRootSet) {
15429 alitokmen 1579
            throw new IllegalArgumentException("Jonas root is not set.");
15367 rbresson 1580
        }
15604 rbresson 1581
        if (!this.isJonasBaseSet) {
15429 alitokmen 1582
            throw new IllegalArgumentException("Jonas base is not set.");
15367 rbresson 1583
        }
1584
 
21899 alitokmen 1585
        this.jonasBase.addConfiguredServices(this.services);
1586
        this.jonasBase.execute();
1587
        this.jonasProperties.execute();
1588
        this.doReplacements(new File(this.jonasFileBase, "conf"));
1589
 
22256 cazauxj 1590
        if (this.ha != null) {
1591
            this.ha.execute();
1592
        }
1593
        if (this.cmi != null) {
1594
            this.cmi.execute();
1595
        }
1596
 
21899 alitokmen 1597
        WebContainer webContainer = null;
1598
        try {
1599
            if (this.webContainer == null) {
1600
                // If not set, get the webContainer from jonas.properties
1601
                //
1602
                // jonas.service.web.class is for example org.ow2.jonas.web.tomcat7.Tomcat7Service,
1603
                // we therefore split it at each for and get the length - 2 (in our example, tomcat7).
1604
                Properties jonasProperties = new Properties();
21900 alitokmen 1605
                InputStream fis = new FileInputStream(new File(this.jonasFileBase, "conf/jonas.properties"));
1606
                try {
1607
                    jonasProperties.load(fis);
1608
                } finally {
1609
                    fis.close();
1610
                    fis = null;
1611
                    System.gc();
1612
                }
22256 cazauxj 1613
                final String webToken = jonasProperties.getProperty("jonas.service.web.class");
1614
                if (webToken != null) {
1615
                    String[] defaultWebcontainerClass = webToken.split("\\.");
1616
                    this.webContainer = defaultWebcontainerClass[defaultWebcontainerClass.length - 2];
1617
                }
21899 alitokmen 1618
            }
22151 cazauxj 1619
 
22256 cazauxj 1620
            if (this.webContainer != null) {
1621
                for (String webContainerClassName : getAllClasses((URLClassLoader) this.getClass().getClassLoader(),
1622
                        WebContainer.class.getName())) {
1623
 
1624
                    if (webContainerClassName.contains(this.webContainer)) {
1625
                        webContainer = (WebContainer)
1626
                                this.getClass().getClassLoader().loadClass(webContainerClassName).newInstance();
1627
                        webContainer.setProject(this.project);
1628
                    }
21899 alitokmen 1629
                }
1630
            }
1631
        } catch (Exception e) {
1632
            throw new IllegalStateException("Cannot create Web container", e);
1633
        }
1634
 
22256 cazauxj 1635
        if (webContainer != null) {
1636
            //jvm route
1637
            if (this.jvmRoute != null) {
1638
                invokeMethod(webContainer, "setJvmRoute", this.jvmRoute, "Web.jvmRoute",
1639
                        "[Web configuration] cannot set jvm route : " + jvmRoute);
1640
            }
1641
 
1642
            //web ondemand
1643
            invokeMethod(webContainer, "setOndemandenabled", String.valueOf(this.isWebOnDemandActivated),
1644
                    "webContainer.ondemandenabled", "[Web configuration] cannot set ondemandenable : " + this.isWebOnDemandActivated);
1645
 
1646
            if (this.isWebOnDemandActivated && this.webOnDemandRedirectPort != null) {
1647
                invokeMethod(webContainer, "setOndemandredirectPort", this.webOnDemandRedirectPort, "webContainer.ondemandRedirectPort",
1648
                        "[Web configuration] cannot set ondemand redirect port : " + this.webOnDemandRedirectPort);
1649
            }
1650
 
1651
            //create AJP connector
1652
            Ajp ajp = null;
1653
            if (this.isAjpActivated) {
1654
                ajp = (Ajp) instanciateConnector(Ajp.class.getName(), this.webContainer);
1655
                if (ajp != null) {
1656
                    if (this.ajpEnableLookups != null) {
1657
                        invokeMethod(ajp, "setEnableLookups", String.valueOf(this.ajpEnableLookups), "ajp.enableLookups",
1658
                                "[AJP configuration] cannot set enableLookups property : " + this.ajpEnableLookups);
1659
                    }
1660
                    if (this.ajpAcceptCount != null) {
1661
                        invokeMethod(ajp, "setAcceptCount", this.ajpAcceptCount, "ajp.acceptCount",
1662
                                "[AJP configuration] cannot set accept count : " + this.ajpAcceptCount);
1663
                    }
1664
                    if (this.ajpConnectionTimeout != null) {
1665
                        invokeMethod(ajp, "setConnectionTimeout", this.ajpConnectionTimeout, "ajp.connectionTimeout",
1666
                                "[AJP configuration] cannot set connection timeout to: " + this.ajpConnectionTimeout);
1667
                    }
1668
                    if (this.ajpMaxThreads != null) {
1669
                        invokeMethod(ajp, "setMaxThreads", this.ajpMaxThreads, "ajp.maxThreads",
1670
                                "[AJP configuration] cannot set max threads ; " + this.ajpMaxThreads);
1671
                    }
1672
                    if (this.ajpMinSpareThreads != null) {
1673
                        invokeMethod(ajp, "setMinSpareThreads", this.ajpMinSpareThreads, "ajp.minSpareThreads",
1674
                                "[AJP configuration] cannot set min spare threads : " + this.ajpMinSpareThreads);
1675
                    }
1676
                    if (this.ajpPort != null) {
1677
                        invokeMethod(ajp, "setPort", this.ajpPort, "ajp.port", "[AJP configuration] cannot set port : " +
1678
                                this.ajpPort);
1679
                    }
1680
                    if (this.ajpRedirectPort != null) {
1681
                        invokeMethod(ajp, "setRedirectPort", this.ajpRedirectPort, "ajp.redirectPort",
1682
                                "[AJP configuration] cannot set redirect port : " + this.ajpRedirectPort);
1683
                    }
22151 cazauxj 1684
                }
22256 cazauxj 1685
            }
1686
 
1687
            //create HTTP connector
1688
            Http http = null;
1689
            if (this.isHttpActivated) {
1690
                http = (Http) instanciateConnector(Http.class.getName(), this.webContainer);
1691
                if (http != null) {
1692
                    if (this.httpEnableLookups != null) {
1693
                        invokeMethod(http, "setEnableLookups", String.valueOf(this.httpEnableLookups), "http.enableLookups",
1694
                                "[HTTP configuration] cannot set enableLookups property : " + this.httpEnableLookups);
1695
                    }
1696
                    if (this.httpAcceptCount != null) {
1697
                        invokeMethod(http, "setAcceptCount", this.httpAcceptCount, "http.acceptCount",
1698
                                "[HTTP configuration] cannot set accept count : " + this.httpAcceptCount);
1699
                    }
1700
                    if (this.httpConnectionTimeout != null) {
1701
                        invokeMethod(http, "setConnectionTimeout", this.httpConnectionTimeout, "http.connectionTimeout",
1702
                                "[HTTP configuration] cannot set connection timeout to: " + this.httpConnectionTimeout);
1703
                    }
1704
                    if (this.httpMaxThreads != null) {
1705
                        invokeMethod(http, "setMaxThreads", this.httpMaxThreads, "http.maxThreads",
1706
                                "[HTTP configuration] cannot set max threads ; " + this.httpMaxThreads);
1707
                    }
1708
                    if (this.httpMinSpareThreads != null) {
1709
                        invokeMethod(http, "setMinSpareThreads", this.httpMinSpareThreads, "http.minSpareThreads",
1710
                                "[HTTP configuration] cannot set min spare threads : " + this.httpMinSpareThreads);
1711
                    }
1712
                    if (this.httpPort != null) {
1713
                        invokeMethod(http, "setPort", this.httpPort, "http.port", "[HTTP configuration] cannot set port : " +
1714
                                this.httpPort);
1715
                    }
1716
                    if (this.httpRedirectPort != null) {
1717
                        invokeMethod(http, "setRedirectPort", this.httpRedirectPort, "http.redirectPort",
1718
                                "[HTTP configuration] cannot set redirect port : " + this.httpRedirectPort);
1719
                    }
1720
                    if (this.httpCompression != null) {
1721
                        invokeMethod(http, "setCompression", this.httpCompression, "http.compression",
1722
                                "[HTTP configuration] cannot set compression : " + this.httpCompression);
1723
                    }
1724
                    if (this.httpMaxKeepAliveRequest != null) {
1725
                        invokeMethod(http, "setMaxKeepAliveRequest", this.httpMaxKeepAliveRequest, "http.maxKeepAliveRequest",
1726
                                "[HTTP configuration] cannot set max keep alive request : " + this.httpMaxKeepAliveRequest);
1727
                    }
22151 cazauxj 1728
                }
22256 cazauxj 1729
            }
1730
 
1731
            //create HTTPS connector
1732
            Https https = null;
1733
            if (this.isHttpsActivated) {
1734
                https = (Https) instanciateConnector(Https.class.getName(), this.webContainer);
1735
                if (https != null) {
1736
                    if (this.httpsEnableLookups != null) {
1737
                        invokeMethod(https, "setEnableLookups", String.valueOf(this.httpsEnableLookups), "https.enableLookups",
1738
                                "[HTTPS configuration] cannot set enableLookups property : " + this.httpsEnableLookups);
1739
                    }
1740
                    if (this.httpsAcceptCount != null) {
1741
                        invokeMethod(https, "setAcceptCount", this.httpsAcceptCount, "https.acceptCount",
1742
                                "[HTTPS configuration] cannot set accept count : " + this.httpsAcceptCount);
1743
                    }
1744
                    if (this.httpsConnectionTimeout != null) {
1745
                        invokeMethod(https, "setConnectionTimeout", this.httpsConnectionTimeout, "https.connectionTimeout",
1746
                                "[HTTPS configuration] cannot set connection timeout to: " + this.httpsConnectionTimeout);
1747
                    }
1748
                    if (this.httpsMaxThreads != null) {
1749
                        invokeMethod(https, "setMaxThreads", this.httpsMaxThreads, "https.maxThreads",
1750
                                "[HTTPS configuration] cannot set max threads ; " + this.httpsMaxThreads);
1751
                    }
1752
                    if (this.httpsMinSpareThreads != null) {
1753
                        invokeMethod(https, "setMinSpareThreads", this.httpsMinSpareThreads, "https.minSpareThreads",
1754
                                "[HTTPS configuration] cannot set min spare threads : " + this.httpsMinSpareThreads);
1755
                    }
1756
                    if (this.httpsPort != null) {
1757
                        invokeMethod(https, "setPort", this.httpsPort, "https.port", "[HTTPS configuration] cannot set port : " +
1758
                                this.httpsPort);
1759
                    }
1760
                    if (this.httpsRedirectPort != null) {
1761
                        invokeMethod(https, "setRedirectPort", this.httpsRedirectPort, "https.redirectPort",
1762
                                "[HTTPS configuration] cannot set redirect port : " + this.httpsRedirectPort);
1763
                    }
1764
                    if (this.httpsCompression != null) {
1765
                        invokeMethod(https, "setCompression", this.httpsCompression, "https.compression",
1766
                                "[HTTPS configuration] cannot set compression : " + this.httpsCompression);
1767
                    }
1768
                    if (this.httpsMaxKeepAliveRequest != null) {
1769
                        invokeMethod(https, "setMaxKeepAliveRequest", this.httpsMaxKeepAliveRequest, "https.maxKeepAliveRequest",
1770
                                "[HTTPS configuration] cannot set max keep alive request : " + this.httpsMaxKeepAliveRequest);
1771
                    }
1772
                    if (this.httpsKeystoreFile != null) {
1773
                        invokeMethod(https, "setKeystoreFile", this.httpsKeystoreFile, "https.keyStoreFile",
1774
                                "[HTTPS configuration] cannot set keystore file : " + this.httpsKeystoreFile);
1775
                    }
1776
                    if (this.httpsKeystorePass != null) {
1777
                        invokeMethod(https, "setKeystorePass", this.httpsKeystorePass, "https.keyStorePass",
1778
                                "[HTTPS configuration] cannot set keystore pass : " + this.httpsKeystorePass);
1779
                    }
22151 cazauxj 1780
                }
21899 alitokmen 1781
            }
1782
 
22256 cazauxj 1783
            SessionReplication sessionReplication = null;
1784
            if (this.isHttpReplicationActivated) {
1785
                sessionReplication = new SessionReplication();
1786
                if (this.sessionReplicationAlgorithm != null) {
1787
                    sessionReplication.setAlgorithm(this.sessionReplicationAlgorithm);
21899 alitokmen 1788
                }
22256 cazauxj 1789
                if (this.sessionReplicationClusterName != null) {
1790
                    sessionReplication.setName(this.sessionReplicationClusterName);
22151 cazauxj 1791
                }
22256 cazauxj 1792
                if (this.sessionReplicationMulticastAddress != null) {
1793
                    sessionReplication.setMcastAddr(this.sessionReplicationMulticastAddress);
22151 cazauxj 1794
                }
22256 cazauxj 1795
                if (this.sessionReplicationMulticastPort != null) {
1796
                    sessionReplication.setMcastPort(this.sessionReplicationMulticastPort);
22151 cazauxj 1797
                }
22256 cazauxj 1798
                if (this.sessionReplicationListenPort != null) {
1799
                    sessionReplication.setListenPort(this.sessionReplicationListenPort);
22151 cazauxj 1800
                }
21899 alitokmen 1801
            }
1802
 
22256 cazauxj 1803
            TomcatSessionManager tomcatSessionManager = null;
1804
            if (this.isHttpSessionManagerActivated) {
1805
                tomcatSessionManager = new TomcatSessionManager();
1806
                if (this.maxActiveSession != null) {
1807
                    tomcatSessionManager.setMaxActiveSessions(this.maxActiveSession);
22151 cazauxj 1808
                }
1809
            }
1810
 
22256 cazauxj 1811
            //instanciate webcontainer Connectors object
1812
            Connectors connectors = null;
1813
            Method connectorsMethod = null;
1814
            for (Method method : webContainer.getClass().getMethods()) {
1815
                if (method.getName().equals("addConfiguredConnectors") && method.getParameterTypes().length == 1) {
1816
                    try {
1817
                        connectors = (Connectors) method.getParameterTypes()[0].newInstance();
1818
                        connectors.setProject(this.project);
22426 cazauxj 1819
                        connectors.setSkipOptionalDeployablesCopy(true);
22256 cazauxj 1820
                    } catch (Exception e) {
1821
                        throw new IllegalStateException("Cannot generate Web connector to configure", e);
1822
                    }
1823
                    connectorsMethod = method;
1824
                    break;
1825
                }
22151 cazauxj 1826
            }
22256 cazauxj 1827
            if (connectors == null) {
1828
                throw new IllegalStateException("Cannot find method for adding configured Web connector");
22151 cazauxj 1829
            }
22256 cazauxj 1830
 
1831
            //addition of all connector to the Connectors object
1832
            if (http != null) {
1833
                invokeMethod(connectors, "addConfiguredHttp", http, "web.connectors.http",
1834
                        "[Web container] cannot add configured Web HTTP connector");
22151 cazauxj 1835
            }
22256 cazauxj 1836
            if (https != null) {
1837
                invokeMethod(connectors, "addConfiguredHttps", https, "web.connectors.https",
1838
                        "[Web container] cannot add configured Web HTTPS connector");
22151 cazauxj 1839
            }
22256 cazauxj 1840
            if (ajp != null) {
1841
                invokeMethod(connectors, "addConfiguredAjp", ajp, "web.connectors.ajp",
1842
                        "[Web container] cannot add configured Web AJP connector");
22151 cazauxj 1843
            }
1844
 
22256 cazauxj 1845
            //addition of Connectors object to the WebContainer
1846
            try {
1847
                connectorsMethod.invoke(webContainer, connectors);
1848
            } catch (Exception e) {
1849
                throw new IllegalStateException("Cannot add configured Web connector", e);
22151 cazauxj 1850
            }
1851
 
22256 cazauxj 1852
            //addition of session manager to the webcontainer
1853
            if (tomcatSessionManager != null) {
1854
                invokeMethod(webContainer, "addConfiguredSessionManager", tomcatSessionManager, "web.sessionManager",
1855
                        "[Web container] cannot add configured Web session manager");
21899 alitokmen 1856
            }
22151 cazauxj 1857
 
22256 cazauxj 1858
            //addition of session replication object to the webContainer
1859
            if (sessionReplication != null) {
1860
                invokeMethod(webContainer, "addConfiguredSessionReplication", sessionReplication, "web.sessionReplication",
1861
                        "[Web container] cannot add configured Web session replication");
1862
            }
22151 cazauxj 1863
 
22256 cazauxj 1864
            //execute the webcontainer task
1865
            webContainer.execute();
21899 alitokmen 1866
        }
22151 cazauxj 1867
 
15660 alitokmen 1868
        if (!this.isProtocolsListSet) {
1869
            this.carol.setProtocols("jrmp");
1870
        }
21899 alitokmen 1871
        this.carol.execute();
1872
 
22256 cazauxj 1873
        if (this.db != null) {
21899 alitokmen 1874
            this.db.execute();
15669 alitokmen 1875
        }
21899 alitokmen 1876
 
22151 cazauxj 1877
        //TODO to be able to configure each discovery service
22256 cazauxj 1878
        if (this.discovery != null) {
1879
            this.discovery.execute();
1880
        }
21899 alitokmen 1881
 
22256 cazauxj 1882
        if (this.smartClient != null) {
22151 cazauxj 1883
            this.smartClient.execute();
1884
        }
1885
 
21911 alitokmen 1886
        boolean first = true;
22151 cazauxj 1887
        for (JdbcXml jdbcXml : this.jdbcXmlList) {
1888
 
21911 alitokmen 1889
            // The JdbcXml task will write all DS definitions to a single file
1890
            // called JONAS_BASE/deploy/jdbc-ds.xml
1891
            //
1892
            // Since the file does not exist at the first call, we need to set
1893
            // it as "new file"; after we tell JdbcXml to merge
1894
            jdbcXml.setNewFile(Boolean.toString(first));
1895
            jdbcXml.execute();
1896
            first = false;
1897
        }
21899 alitokmen 1898
 
22256 cazauxj 1899
        if (this.jms != null) {
1900
            this.jms.execute();
1901
        }
21899 alitokmen 1902
 
22151 cazauxj 1903
        for (User admin: admins) {
1904
            this.security.addConfiguredAdmin(admin);
15655 alitokmen 1905
        }
22151 cazauxj 1906
        for (User user: users) {
1907
            this.security.addConfiguredUser(user);
1908
        }
1909
        this.security.execute();
21899 alitokmen 1910
 
22151 cazauxj 1911
        for (Mail mail: this.mails) {
1912
            mail.execute();
1913
        }
1914
 
22256 cazauxj 1915
        if (this.wsdlPublisherFile != null) {
1916
            this.wsdlPublish = new WsdlPublish();
1917
            this.wsdlPublish.setProject(this.project);
18562 alitokmen 1918
            this.wsdlPublish.addConfiguredFile(this.wsdlPublisherFile);
21899 alitokmen 1919
            this.wsdlPublish.execute();
15655 alitokmen 1920
        }
22222 cazauxj 1921
 
1922
        if (this.wrapper != null) {
1923
            this.wrapper.execute();
1924
        }
15325 alitokmen 1925
    }
15649 rbresson 1926
 
1927
    /* --------------------------------- */
1928
    /* Cluster daemon configuration part */
1929
 
1930
    /**
22256 cazauxj 1931
     * Initialize ClusterDaemon if not set
1932
     */
1933
    private void initClusterDaemon() {
1934
        if (this.clusterDaemon == null) {
1935
            this.clusterDaemon = new ClusterDaemon();
1936
            this.clusterDaemon.setProject(this.project);
1937
        }
1938
    }
1939
 
1940
    /**
15649 rbresson 1941
     * {@inheritDoc}
1942
     */
1943
    public void setCDClusterName(final String clusterName) {
21899 alitokmen 1944
        Jonas53.logger.finest("[Cluster daemon configuration] setting cluster name : " + clusterName);
22256 cazauxj 1945
        initClusterDaemon();
21908 alitokmen 1946
        this.clusterDaemon.setName(clusterName);
15649 rbresson 1947
    }
1948
 
1949
    /**
1950
     * {@inheritDoc}
1951
     */
15678 alitokmen 1952
    public void setCDClusterDomain(final String clusterDomain) {
21899 alitokmen 1953
        Jonas53.logger.finest("[Cluster daemon configuration] setting cluster domain name : " + clusterDomain);
22256 cazauxj 1954
        initClusterDaemon();
21908 alitokmen 1955
        this.clusterDaemon.setDomainName(clusterDomain);
15678 alitokmen 1956
    }
1957
 
1958
    /**
1959
     * {@inheritDoc}
1960
     */
15714 alitokmen 1961
    public void setCDProtocol(final String protocol) {
21899 alitokmen 1962
        Jonas53.logger.finest("[Cluster daemon configuration] setting protocol : " + protocol);
22151 cazauxj 1963
        NotApplicableHelper.notApplicable("clusterdaemon.protocol");
15714 alitokmen 1964
    }
1965
 
1966
    /**
1967
     * {@inheritDoc}
1968
     */
1969
    public void setCDPort(final String port) {
21899 alitokmen 1970
        Jonas53.logger.finest("[Cluster daemon configuration] setting port : " + port);
22151 cazauxj 1971
        NotApplicableHelper.notApplicable("clusterdaemon.port");
15714 alitokmen 1972
    }
1973
 
1974
    /**
1975
     * {@inheritDoc}
1976
     */
15649 rbresson 1977
    public void setCDDestDirPrefix(final String destDirPrefix) {
21899 alitokmen 1978
        Jonas53.logger.finest("[Cluster daemon configuration] setting dest dir prefix : " + destDirPrefix);
22256 cazauxj 1979
        initClusterDaemon();
15665 alitokmen 1980
        this.clusterDaemon.setDestDirPrefix(destDirPrefix);
1981
        this.clusterDaemon.setCdDir(destDirPrefix);
21899 alitokmen 1982
        this.project.setProperty("jonas.base", destDirPrefix);
15649 rbresson 1983
    }
1984
 
1985
    /**
1986
     * {@inheritDoc}
1987
     */
1988
    public void setCDInteractionMode(final String interactionMode) {
21899 alitokmen 1989
        Jonas53.logger.finest("[Cluster daemon configuration] setting interaction mode : " + interactionMode);
22256 cazauxj 1990
        initClusterDaemon();
21908 alitokmen 1991
        this.clusterDaemon.setInteractionMode(interactionMode);
15649 rbresson 1992
    }
1993
 
1994
    /**
1995
     * {@inheritDoc}
1996
     */
1997
    public void setCDJavaHome(final String javaHome) {
21899 alitokmen 1998
        Jonas53.logger.finest("[Cluster daemon configuration] setting java home : " + javaHome);
22256 cazauxj 1999
        initClusterDaemon();
15665 alitokmen 2000
        this.clusterDaemon.setJdk(javaHome);
15649 rbresson 2001
    }
2002
 
2003
    /**
2004
     * {@inheritDoc}
2005
     */
2006
    public void setCDJonasRoot(final String jonasRoot) {
21899 alitokmen 2007
        Jonas53.logger.finest("[Cluster daemon configuration] setting jonas root : " + jonasRoot);
22151 cazauxj 2008
        NotApplicableHelper.notApplicable("jonas.root");
15649 rbresson 2009
    }
2010
 
2011
    /**
2012
     * {@inheritDoc}
2013
     */
2014
    public void setCDServerNamePrefix(final String serverNamePrefix) {
21899 alitokmen 2015
        Jonas53.logger.finest("[Cluster daemon configuration] setting server name prefix : " + serverNamePrefix);
22256 cazauxj 2016
        initClusterDaemon();
15679 alitokmen 2017
        this.clusterDaemon.setClusterNodesName(serverNamePrefix);
15649 rbresson 2018
    }
2019
 
2020
    /**
2021
     * {@inheritDoc}
2022
     */
2023
    public void setCDXparam(final String xparam) {
21899 alitokmen 2024
        Jonas53.logger.finest("[Cluster daemon configuration] setting xparam : " + xparam);
22256 cazauxj 2025
        initClusterDaemon();
15665 alitokmen 2026
        this.clusterDaemon.setXprm(xparam);
15649 rbresson 2027
    }
2028
 
2029
    /**
2030
     * {@inheritDoc}
2031
     */
15657 rbresson 2032
    public void setCDAutoBoot(final boolean autoBoot) {
21899 alitokmen 2033
        Jonas53.logger.finest("[Cluster daemon configuration] setting auto boot : " + autoBoot);
22256 cazauxj 2034
        initClusterDaemon();
15665 alitokmen 2035
        this.clusterDaemon.setAutoBoot(new Boolean(autoBoot).toString());
15649 rbresson 2036
    }
2037
 
2038
    /**
2039
     * {@inheritDoc}
2040
     */
15653 rbresson 2041
    public void setCDNbInstances(final int nbInsts) {
21899 alitokmen 2042
        Jonas53.logger.finest("[Cluster daemon configuration] setting nb instance : " + nbInsts);
22256 cazauxj 2043
        initClusterDaemon();
21899 alitokmen 2044
        this.clusterDaemon.setInstNb(nbInsts);
15649 rbresson 2045
    }
2046
 
2047
    /**
2048
     * {@inheritDoc}
2049
     */
22223 cazauxj 2050
    public void setCDJOnASScript(final String jonasScript) {
2051
        Jonas53.logger.finest("[Cluster daemon configuration] setting jonas script : " + jonasScript);
22256 cazauxj 2052
        initClusterDaemon();
22223 cazauxj 2053
        this.clusterDaemon.setJonasScript(jonasScript);
2054
    }
2055
 
2056
    /**
2057
     * {@inheritDoc}
2058
     */
15649 rbresson 2059
    public void executeCDConf() {
22256 cazauxj 2060
        if (this.clusterDaemon != null) {
2061
            this.clusterDaemon.execute();
2062
        }
15649 rbresson 2063
    }
2064
    /* --------------------------------- */
21899 alitokmen 2065
 
21911 alitokmen 2066
    /**
22222 cazauxj 2067
     * {@inheritDoc}
2068
     */
2069
    public void setWrapperConfiguration(final String javaHome, final String wrapperHome, final String serviceName,
2070
                                        final String serviceDescription, final Boolean verbosity, final String logfile,
2071
                                        final String logfileRollmode) {
2072
        File wrapperDir = null;
2073
        if (wrapperHome != null) {
2074
            wrapperDir = new File(wrapperHome);
2075
        }
2076
        if (wrapperDir == null || !wrapperDir.exists()) {
2077
            wrapperDir = new File(this.project.getProperty("jonas.root") + File.separator + "wrapper");
2078
        }
2079
 
2080
        //locate wrapper ANT task
2081
        File wrapperAntTaskFile = new File(wrapperDir + File.separator + "lib" + File.separator + "ant" + File.separator
2082
                + "ow2_jonas_wrapper_ant.jar");
2083
        if (!wrapperAntTaskFile.exists()) {
2084
            Jonas53.logger.finest("Wrapper home is incorrect. Cannot find Wrapper ANT task");
2085
            NotApplicableHelper.notApplicable("wrapper.home");
2086
        } else {
2087
            URL wrapperAntTask = null;
2088
            try {
2089
                wrapperAntTask = wrapperAntTaskFile.toURI().toURL();
2090
            } catch (MalformedURLException e) {
2091
                Jonas53.logger.severe("Cannot get the URL of the file " + wrapperAntTaskFile.getAbsolutePath());
2092
            }
2093
 
2094
            if (wrapperAntTask != null) {
2095
                ClassLoader classLoader = new URLClassLoader(new URL[] {wrapperAntTask}, this.getClass().getClassLoader());
2096
                Class<? extends JOnASWrapper> clazz = null;
2097
                try {
2098
                    clazz = classLoader.loadClass(JOnASWrapper.class.getName()).asSubclass(JOnASWrapper.class);
2099
                } catch (ClassNotFoundException e) {
2100
                    Jonas53.logger.severe("Cannot found class " + JOnASWrapper.class.getName());
2101
                }
2102
                try {
2103
                    this.wrapper = clazz.newInstance();
2104
                } catch (InstantiationException e) {
2105
                    Jonas53.logger.severe("Cannot instanciate " + Jonas53.class.getName());
2106
                } catch (IllegalAccessException e) {
2107
                    Jonas53.logger.severe("Cannot instanciate " + Jonas53.class.getName());
2108
                }
2109
                if (this.wrapper != null) {
2110
                    this.wrapper.setProject(this.project);
2111
                    if (javaHome != null) {
2112
                        this.wrapper.setJavaHome(javaHome);
2113
                    }
2114
                    if (wrapperHome != null) {
2115
                        this.wrapper.setWrapperHome(wrapperHome);
2116
                    }
2117
                    if (serviceName != null) {
2118
                        this.wrapper.setServiceName(serviceName);
2119
                    }
2120
                    if (serviceDescription != null) {
2121
                        this.wrapper.setServiceDescription(serviceDescription);
2122
                    }
2123
                    if (verbosity != null) {
2124
                        this.wrapper.setVerbosity(verbosity);
2125
                    }
2126
                    if (logfile != null) {
2127
                        this.wrapper.setLogfile(logfile);
2128
                    }
2129
                    if (logfileRollmode != null) {
2130
                        this.wrapper.setLogfileRollmode(logfileRollmode);
2131
                    }
2132
                }
2133
            }
2134
        }
2135
    }
2136
 
2137
 
2138
    /**
21911 alitokmen 2139
     * Gets all classes in a given URLClassLoader that are children of a given class or interface.
2140
     * @param urlCL URLClassLoader to scan.
2141
     * @param parent Parent class or interface that returned classes should implement.
2142
     * @return All classes in <code>urlCl</code> that are children of class or interface <code>parent</code>.
2143
     * @throws IOException If the URLClassLoader cannot be read.
2144
     * @throws URISyntaxException If the URLClassLoader cannot be read.
2145
     * @throws ClassNotFoundException If class or interface <code>parent</code> cannot be loaded.
2146
     */
21899 alitokmen 2147
    private SortedSet<String> getAllClasses(URLClassLoader urlCL, String parent)
2148
        throws IOException, URISyntaxException, ClassNotFoundException {
2149
 
2150
        SortedSet<String> classes = new TreeSet<String>();
2151
 
2152
        Class<?> parentClass;
2153
        try {
2154
            parentClass = urlCL.loadClass(parent);
2155
        } catch (ClassNotFoundException e) {
2156
            throw new IllegalArgumentException("Class " + parent + " not found in " + urlCL);
2157
        }
2158
 
2159
        for (URL url : urlCL.getURLs()) {
2160
            classes.addAll(getAllClasses(url, urlCL, parentClass));
2161
        }
2162
 
2163
        return classes;
2164
    }
2165
 
21911 alitokmen 2166
    /**
2167
     * Gets all classes in a given JAR file or a URLClassLoader that are children of a given class or interface.
2168
     * @param jarUrl JAR file's URL.
2169
     * @param urlCL URLClassLoader to scan.
2170
     * @param parentClass Parent class or interface that returned classes should implement.
2171
     * @return All classes in <code>jar</code> that are member of <code>urlCl</code> that are children of class or interface
2172
     * <code>parent</code>.
2173
     * @throws IOException If the JAR file cannot be read.
2174
     * @throws URISyntaxException If the JAR file cannot be read.
2175
     * @throws ClassNotFoundException If class or interface <code>parent</code> cannot be loaded.
2176
     */
2177
    private SortedSet<String> getAllClasses(URL jarUrl, URLClassLoader urlCL, Class<?> parentClass)
21899 alitokmen 2178
        throws IOException, URISyntaxException, ClassNotFoundException {
2179
 
2180
        SortedSet<String> classes = new TreeSet<String>();
2181
 
21911 alitokmen 2182
        File jarFile = new File(jarUrl.toURI());
2183
        if (!jarFile.isFile()) {
21899 alitokmen 2184
            return classes;
2185
        }
2186
 
21911 alitokmen 2187
        JarFile jar = new JarFile(jarFile);
21899 alitokmen 2188
        Enumeration<JarEntry> entries = jar.entries();
2189
        while (entries.hasMoreElements()) {
2190
            JarEntry entry = entries.nextElement();
2191
            String entryName = entry.getName();
2192
            if (entryName.endsWith(".class") && !entryName.contains("$")) {
2193
                entryName = entryName.substring(0, entryName.length() - 6);
2194
                entryName = entryName.replace('/', '.');
2195
                entryName = entryName.replace('\\', '.');
2196
 
2197
                Class<?> entryClass;
2198
                try {
2199
                    entryClass = urlCL.loadClass(entryName);
2200
                } catch (NoClassDefFoundError ignored) {
2201
                    continue;
2202
                }
2203
                if (!entryClass.isInterface() && ! Modifier.isAbstract(entryClass.getModifiers())
2204
                    && parentClass.isAssignableFrom(entryClass)) {
2205
 
2206
                    classes.add(entryName);
2207
                }
2208
            }
2209
        }
2210
 
2211
        return classes;
2212
    }
22151 cazauxj 2213
 
2214
    /**
2215
     * Generic method in order to invoke a method
2216
     * @param object The object which contains the method to invoke
2217
     * @param methodToInvoke Name of the method to invoke
2218
     * @param parameter The parameter of the method to invoke.
2219
     * @param notApplicableLog Log if no such method is defined in the given object class
2220
     * @param invocationExceptionLog Log if the method invocation failed
2221
     */
2222
    private void invokeMethod(final Object object, final String methodToInvoke,
2223
                              final Object parameter, final String notApplicableLog,
2224
                              final String invocationExceptionLog) {
2225
        List<Object> parameters = new ArrayList<Object>();
2226
        parameters.add(parameter);
2227
        invokeMethod(object, methodToInvoke, parameters, notApplicableLog, invocationExceptionLog);
2228
    }
2229
 
2230
    /**
2231
     * Generic method in order to invoke a method
2232
     * @param object The object which contains the method to invoke
2233
     * @param methodToInvoke Name of the method to invoke
2234
     * @param parameters  List of parameters of the method to invoke.
2235
     * @param notApplicableLog Log if no such method is defined in the given object class
2236
     * @param invocationExceptionLog Log if the method invocation failed
2237
     */
2238
    private void invokeMethod(final Object object, final String methodToInvoke,
2239
                              final List<Object> parameters, final String notApplicableLog,
2240
                              final String invocationExceptionLog) {
2241
        if (object == null) {
2242
            throw new IllegalArgumentException("'object' parameter shouldn't be null");
2243
        }
2244
        if (parameters == null) {
2245
            throw new IllegalArgumentException("'parameters' parameter shouldn't be null");
2246
        }
2247
 
2248
        List<Class<?>> parametersClass = new ArrayList<Class<?>>();
2249
        for (Object parameter: parameters) {
2250
            parametersClass.add(parameter.getClass());
2251
        }
2252
        Method method = null;
2253
        try {
2254
            method = object.getClass().getMethod(methodToInvoke, parametersClass.toArray(new Class<?>[parametersClass.size()]));
2255
        } catch (NoSuchMethodException e) {
2256
            NotApplicableHelper.notApplicable(notApplicableLog);
2257
        }
2258
        if (method != null) {
2259
            try {
2260
                method.invoke(object, parameters.toArray(new Object[parameters.size()]));
2261
            } catch (Exception e) {
2262
                throw new IllegalArgumentException(invocationExceptionLog, e);
2263
            }
2264
        }
2265
    }
2266
 
2267
    /**
2268
     * Instanciate a connector (HTTP, HTTPS, AJP) according to the webcontainer implementation
2269
     * @param connectorClassName Name of the generic connector class
2270
     * @param webContainer Name of the webcontainer implementation
2271
     * @return the instance of a connector
2272
     */
2273
    private Object instanciateConnector(final String connectorClassName, final String webContainer) {
2274
        try {
2275
            //try to find a connector classname with a name equals to ${connector.name} + ${webcontainer.name}
2276
            SortedSet<String> classesName = getAllClasses((URLClassLoader) this.getClass().getClassLoader(), connectorClassName);
2277
            for (String className: classesName) {
2278
                if (className.contains(webContainer)) {
2279
                    return this.getClass().getClassLoader().loadClass(className).newInstance();
2280
                }
2281
            }
2282
 
2283
            //try to find a connector classname with a name equals to ${connector.name} + ${webcontainer.nameWithoutVersions}
2284
            String webContainerWitoutVersion =  webContainer.trim();
2285
            while (Character.isDigit(webContainerWitoutVersion.charAt(webContainerWitoutVersion.length() - 1))) {
2286
                webContainerWitoutVersion = webContainerWitoutVersion.substring(0, webContainerWitoutVersion.length() - 1);
2287
            }
2288
            for (String className: classesName) {
2289
                if (className.contains(webContainerWitoutVersion)) {
2290
                    return this.getClass().getClassLoader().loadClass(className).newInstance();
2291
                }
2292
            }
2293
 
2294
            //nothing found...so just return a super instance of the connector
2295
            return this.getClass().getClassLoader().loadClass(connectorClassName).newInstance();
2296
 
2297
        } catch (Exception e) {
2298
            throw new IllegalStateException("Cannot create an AJP connector", e);
2299
        }
2300
    }
15325 alitokmen 2301
}