This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 93815
Collapse All | Expand All

(-)src/org/netbeans/modules/j2ee/deployment/common/api/MessageDestination.java (+59 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.j2ee.deployment.common.api;
21
22
/**
23
 * Represents a message destination
24
 *
25
 * @author Libor Kotouc
26
 *
27
 * @since 1.25
28
 */
29
public interface MessageDestination {
30
    
31
    /**
32
     * Message destination type
33
     */
34
    public enum Type {
35
        /**
36
         * Queue
37
         */ 
38
        QUEUE, 
39
        
40
        /**
41
         * Topic
42
         */
43
        TOPIC
44
    };
45
    
46
    /**
47
     * Returns the JNDI name
48
     *
49
     * @return the JNDI name
50
     */
51
    public String getJndiName();
52
    
53
    /**
54
     * Returns the type
55
     * 
56
     * @return the type
57
     */
58
    public Type getType();
59
}
(-)src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java (-7 / +171 lines)
Lines 13-26 Link Here
13
 * "Portions Copyrighted [year] [name of copyright owner]"
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
18
 */
19
19
20
package org.netbeans.modules.j2ee.deployment.config;
20
package org.netbeans.modules.j2ee.deployment.config;
21
21
22
import java.beans.PropertyChangeEvent;
23
import java.beans.PropertyChangeListener;
24
import java.io.File;
22
import java.io.File;
25
import java.io.IOException;
23
import java.io.IOException;
26
import java.io.OutputStream;
24
import java.io.OutputStream;
Lines 31-43 Link Here
31
import java.util.Iterator;
29
import java.util.Iterator;
32
import java.util.Map;
30
import java.util.Map;
33
import java.util.Set;
31
import java.util.Set;
34
import javax.enterprise.deploy.model.DDBean;
35
import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
36
import org.netbeans.modules.j2ee.dd.api.common.ComponentInterface;
32
import org.netbeans.modules.j2ee.dd.api.common.ComponentInterface;
37
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
33
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
38
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
34
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
39
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
35
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
40
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
41
import org.netbeans.modules.j2ee.deployment.impl.Server;
36
import org.netbeans.modules.j2ee.deployment.impl.Server;
42
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
37
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
43
import javax.enterprise.deploy.shared.ModuleType;
38
import javax.enterprise.deploy.shared.ModuleType;
Lines 60-66 Link Here
60
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
61
import org.netbeans.api.project.FileOwnerQuery;
56
import org.netbeans.api.project.FileOwnerQuery;
62
import org.netbeans.api.project.Project;
57
import org.netbeans.api.project.Project;
58
import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans;
59
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
63
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
60
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
61
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
64
62
65
/**
63
/**
66
 * Each J2eeModuleProvider hold a reference to an instance of this config support.
64
 * Each J2eeModuleProvider hold a reference to an instance of this config support.
Lines 376-382 Link Here
376
    }
374
    }
377
    
375
    
378
    public Datasource createDatasource(String jndiName, String  url, String username, String password, String driver) 
376
    public Datasource createDatasource(String jndiName, String  url, String username, String password, String driver) 
379
    throws OperationUnsupportedException, DatasourceAlreadyExistsException {
377
    throws UnsupportedOperationException, DatasourceAlreadyExistsException {
380
        Datasource ds = null;
378
        Datasource ds = null;
381
        if (server != null) {
379
        if (server != null) {
382
            ModuleConfiguration config = getModuleConfiguration();
380
            ModuleConfiguration config = getModuleConfiguration();
Lines 393-398 Link Here
393
        }
391
        }
394
        return ds;
392
        return ds;
395
    }    
393
    }    
394
    
395
    public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException {
396
        if (server != null) {
397
            ModuleConfiguration config = getModuleConfiguration();
398
            if (config != null) {
399
                DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class);
400
                if (datasourceConfiguration != null) {
401
                    datasourceConfiguration.bindDatasourceReference(dsReferenceName, dsJNDIName);
402
                }
403
            }
404
        }
405
   }
406
407
    public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName,
408
                                           String ejbName, String ejbType) throws ConfigurationException {
409
        if (!EnterpriseBeans.SESSION.equals(ejbType) &&
410
            !EnterpriseBeans.ENTITY.equals(ejbType) &&
411
            !EnterpriseBeans.MESSAGE_DRIVEN.equals(ejbType)) {
412
            throw new IllegalArgumentException("ejbType parameter doesn't have an allowed value.");
413
        }
414
        
415
        if (server != null) {
416
            ModuleConfiguration config = getModuleConfiguration();
417
            if (config != null) {
418
                DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class);
419
                if (datasourceConfiguration != null) {
420
                    datasourceConfiguration.bindDatasourceReferenceEjb(dsReferenceName, dsJNDIName, ejbName, ejbType);
421
                }
422
            }
423
        }
424
    }
425
426
    public Datasource findDatasourceForReference(String referenceName) throws ConfigurationException {
427
        String jndiName = findDatasourceBinding(referenceName);
428
        if (jndiName == null) {
429
            return null;
430
        }
431
        Set<Datasource> datasources = getDatasources();
432
        for (Datasource ds : datasources) {
433
            if (jndiName.equals(ds.getJndiName())) {
434
                return ds;
435
            }
436
        }
437
        datasources = provider.getServerDatasources();
438
        for (Datasource ds : datasources) {
439
            if (jndiName.equals(ds.getJndiName())) {
440
                return ds;
441
            }
442
        }
443
        
444
        return null;
445
    }
446
447
    private String findDatasourceBinding(String dsReferenceName) throws ConfigurationException {
448
        String jndiName = null;
449
        if (server != null) {
450
            ModuleConfiguration config = getModuleConfiguration();
451
            if (config != null) {
452
                DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class);
453
                if (datasourceConfiguration != null) {
454
                    jndiName = datasourceConfiguration.findDatasourceBinding(dsReferenceName);
455
                }
456
            }
457
        }
458
        
459
        return jndiName;
460
    }
461
462
    public Datasource findDatasourceForReferenceEjb(String referenceName, String ejbName) throws ConfigurationException {
463
        String jndiName = findDatasourceBindingEjb(referenceName, ejbName);
464
        if (jndiName == null) {
465
            return null;
466
        }
467
        Set<Datasource> datasources = getDatasources();
468
        for (Datasource ds : datasources) {
469
            if (jndiName.equals(ds.getJndiName())) {
470
                return ds;
471
            }
472
        }
473
        datasources = provider.getServerDatasources();
474
        for (Datasource ds : datasources) {
475
            if (jndiName.equals(ds.getJndiName())) {
476
                return ds;
477
            }
478
        }
479
        
480
        return null;
481
    }
482
    
483
    private String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException {
484
        String jndiName = null;
485
        if (server != null) {
486
            ModuleConfiguration config = getModuleConfiguration();
487
            if (config != null) {
488
                DatasourceConfiguration datasourceConfiguration = config.getLookup().lookup(DatasourceConfiguration.class);
489
                if (datasourceConfiguration != null) {
490
                    jndiName = datasourceConfiguration.findDatasourceBindingEjb(dsReferenceName, ejbName);
491
                }
492
            }
493
        }
494
        
495
        return jndiName;
496
    }
497
498
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException {
499
        
500
        Set<MessageDestination> destinations = Collections.<MessageDestination>emptySet();
501
        
502
        if (server != null) {
503
            ModuleConfiguration config = getModuleConfiguration();
504
            if (config != null) {
505
                MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class);
506
                if (msgConfig != null) {
507
                    destinations = msgConfig.getMessageDestinations();
508
                }
509
            }
510
        }
511
512
        return destinations;
513
    }
514
515
    public Set<MessageDestination> getServerMessageDestinations() throws ConfigurationException {
516
        ServerInstance si = ServerRegistry.getInstance().getServerInstance(provider.getServerInstanceID());
517
        if (si == null) {
518
            ErrorManager.getDefault().log(ErrorManager.WARNING, 
519
                    "The server data sources cannot be retrieved because the server instance cannot be found.");
520
            return Collections.<MessageDestination>emptySet();
521
        }
522
        
523
        return si.getMessageDestinations();
524
   }
525
    
526
    public boolean supportsCreateMessageDestination() {
527
        if (server == null) {
528
            // the module has no target server
529
            return false;
530
        }
531
        ModuleConfiguration config = getModuleConfiguration();
532
        if (config != null) {
533
            MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class);
534
            if (msgConfig != null) {
535
                return msgConfig.supportsCreateMessageDestination();
536
            }
537
        }
538
        return false;
539
    }
540
541
    public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) 
542
    throws UnsupportedOperationException, ConfigurationException {
543
        
544
        if (server == null) {
545
            return null;
546
        }
547
         
548
        ModuleConfiguration config = getModuleConfiguration();
549
        if (config == null) {
550
            return null;
551
        }
552
        
553
        MessageDestinationConfiguration msgConfig = config.getLookup().lookup(MessageDestinationConfiguration.class);
554
        if (msgConfig != null) {
555
            return msgConfig.createMessageDestination(jndiName, type);
556
        }
557
558
        return null;
559
    }
396
    
560
    
397
    // DeploymentConfigurationProvider implementation -------------------------
561
    // DeploymentConfigurationProvider implementation -------------------------
398
    
562
    
(-)src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java (-5 / +17 lines)
Lines 13-33 Link Here
13
 * "Portions Copyrighted [year] [name of copyright owner]"
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
18
 */
19
19
20
package org.netbeans.modules.j2ee.deployment.devmodules.api;
20
package org.netbeans.modules.j2ee.deployment.devmodules.api;
21
21
22
import java.awt.event.WindowAdapter;
23
import java.awt.event.WindowEvent;
24
import java.util.ArrayList;
22
import java.util.ArrayList;
25
import java.util.Collection;
23
import java.util.Collection;
26
import java.util.Iterator;
24
import java.util.Iterator;
27
import java.util.List;
25
import java.util.List;
28
import java.util.Map;
29
import java.util.Set;
26
import java.util.Set;
30
import java.util.WeakHashMap;
27
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
31
import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener;
28
import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener;
32
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
29
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
33
import org.netbeans.modules.j2ee.deployment.impl.*;
30
import org.netbeans.modules.j2ee.deployment.impl.*;
Lines 106-111 Link Here
106
            }
103
            }
107
104
108
            jmp.deployDatasources();
105
            jmp.deployDatasources();
106
            
107
if (System.getProperties().getProperty("resource-api-redesign") != null) {
108
            deployMessageDestinations(jmp);
109
}
109
110
110
            modules = targetserver.deploy(progress, forceRedeploy);
111
            modules = targetserver.deploy(progress, forceRedeploy);
111
            // inform the plugin about the deploy action, even if there was
112
            // inform the plugin about the deploy action, even if there was
Lines 127-132 Link Here
127
            if (progress != null) {
128
            if (progress != null) {
128
                progress.finish();
129
                progress.finish();
129
            }
130
            }
131
        }
132
    }
133
    
134
    public void deployMessageDestinations(J2eeModuleProvider jmp) throws ConfigurationException {
135
        ServerInstance si = ServerRegistry.getInstance ().getServerInstance (jmp.getServerInstanceID ());
136
        if (si != null) {
137
            si.deployMessageDestinations(jmp.getConfigSupport().getMessageDestinations());
138
        }
139
        else {
140
            ErrorManager.getDefault().log(ErrorManager.WARNING, 
141
                    "The message destinations cannot be deployed because the server instance cannot be found.");
130
        }
142
        }
131
    }
143
    }
132
    
144
    
(-)src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java (-13 / +110 lines)
Lines 13-35 Link Here
13
 * "Portions Copyrighted [year] [name of copyright owner]"
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
18
 */
19
19
20
package org.netbeans.modules.j2ee.deployment.devmodules.spi;
20
package org.netbeans.modules.j2ee.deployment.devmodules.spi;
21
21
22
import java.beans.PropertyChangeListener;
23
import java.beans.PropertyChangeSupport;
24
import java.io.IOException;
25
import java.io.OutputStream;
22
import java.io.OutputStream;
26
import java.util.Collections;
23
import java.util.Collections;
27
import java.util.Iterator;
24
import java.util.Iterator;
28
import java.util.Map;
29
import java.util.Set;
25
import java.util.Set;
30
import javax.enterprise.deploy.spi.Target;
26
import javax.enterprise.deploy.spi.Target;
31
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
27
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
32
import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
33
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
28
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
34
import org.netbeans.modules.j2ee.deployment.common.api.ValidationException;
29
import org.netbeans.modules.j2ee.deployment.common.api.ValidationException;
35
import org.netbeans.modules.j2ee.deployment.config.*;
30
import org.netbeans.modules.j2ee.deployment.config.*;
Lines 38-44 Link Here
38
import org.netbeans.modules.j2ee.deployment.impl.Server;
33
import org.netbeans.modules.j2ee.deployment.impl.Server;
39
import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
34
import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
40
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
35
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
41
import org.netbeans.modules.j2ee.deployment.impl.ServerString;
42
import org.netbeans.modules.j2ee.deployment.impl.ServerTarget;
36
import org.netbeans.modules.j2ee.deployment.impl.ServerTarget;
43
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
37
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
44
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
38
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
Lines 49-59 Link Here
49
import org.netbeans.modules.j2ee.deployment.plugins.spi.VerifierSupport;
43
import org.netbeans.modules.j2ee.deployment.plugins.spi.VerifierSupport;
50
import org.openide.ErrorManager;
44
import org.openide.ErrorManager;
51
import org.openide.filesystems.FileObject;
45
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileUtil;
53
import org.openide.util.WeakListeners;
54
import java.io.File;
55
import java.util.ArrayList;
46
import java.util.ArrayList;
56
import java.util.List;
47
import java.util.List;
48
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
57
49
58
/** This object must be implemented by J2EE module support and an instance 
50
/** This object must be implemented by J2EE module support and an instance 
59
 * added into project lookup.
51
 * added into project lookup.
Lines 207-213 Link Here
207
        try {
199
        try {
208
            //btw, ds existence in a project is verified directly in the deployment configuration
200
            //btw, ds existence in a project is verified directly in the deployment configuration
209
            ds = getConfigSupport().createDatasource(jndiName, url, username, password, driver);
201
            ds = getConfigSupport().createDatasource(jndiName, url, username, password, driver);
210
        } catch (OperationUnsupportedException oue) {
202
        } catch (UnsupportedOperationException oue) {
211
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, oue);
203
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, oue);
212
        }
204
        }
213
        
205
        
Lines 325-337 Link Here
325
         * @param password user's password
317
         * @param password user's password
326
         * @param driver fully qualified name of database driver class
318
         * @param driver fully qualified name of database driver class
327
         * @return created data source
319
         * @return created data source
328
         * @exception OperationUnsupportedException if operation is not supported
320
         * @exception UnsupportedOperationException if operation is not supported
329
         * @exception DatasourceAlreadyExistsException if conflicting data source is found
321
         * @exception DatasourceAlreadyExistsException if conflicting data source is found
330
         *
322
         *
331
         * @since 1.15 
323
         * @since 1.15 
332
         */
324
         */
333
        public Datasource createDatasource(String jndiName, String  url, String username, String password, String driver)
325
        public Datasource createDatasource(String jndiName, String  url, String username, String password, String driver)
334
        throws OperationUnsupportedException, DatasourceAlreadyExistsException, ConfigurationException;
326
        throws UnsupportedOperationException, DatasourceAlreadyExistsException, ConfigurationException;
327
        
328
        /**
329
         * Binds the data source name used in the sources with the corresponding data source which is
330
         * identified the given JNDI name.
331
         * 
332
         * @param referenceName name used to identify the data source
333
         * @param jndiName JNDI name of the data source
334
         * @throws ConfigurationException if there is some problem with data source configuration
335
         * 
336
         * @since 1.25
337
         */
338
        public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException;
339
340
        /**
341
         * Binds the data source name used in the sources with the corresponding data source which is
342
         * identified the given JNDI name. The reference is used within the scope of the EJB.
343
         * 
344
         * @param referenceName name used to identify the data source
345
         * @param jndiName JNDI name of the data source
346
         * @param ejbName EJB name
347
         * @param ejbType EJB type - the possible values are 
348
         * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.SESSION,
349
         * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.ENTITY and
350
         * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.MESSAGE_DRIVEN
351
352
         * @throws ConfigurationException if there is some problem with data source configuration
353
         * @throws IllegalArgumentException if ejbType doesn't have one of allowed values
354
         * 
355
         * @since 1.25
356
         */
357
        public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName,
358
                                               String ejbName, String ejbType) throws ConfigurationException;
359
        
360
        /**
361
         * Finds data source which is mapped to the given reference name.
362
         * 
363
         * @referenceName reference name
364
         * @return data source if it exists, null otherwise
365
         *
366
         * @throws ConfigurationException if there is some problem with data source configuration
367
         * 
368
         * @since 1.25
369
         */
370
        public Datasource findDatasourceForReference(String referenceName) throws ConfigurationException;
371
372
        /**
373
         * Finds data source which is mapped to the given reference name in the scope the EJB.
374
         * 
375
         * @param referenceName reference name
376
         * @param ejbName EJB name
377
         * @return data source if it exists, null otherwise
378
         *
379
         * @throws ConfigurationException if there is some problem with data source configuration
380
         * 
381
         * @since 1.25
382
         */
383
        public Datasource findDatasourceForReferenceEjb(String referenceName, String ejbName) throws ConfigurationException;
384
        
385
        /**
386
         * Retrieves message destinations stored in the module.
387
         * 
388
         * @return set of message destinations
389
         * 
390
         * @throws ConfigurationException if there is some problem with message destination configuration
391
         * 
392
         * @since 1.25
393
         */
394
        public Set<MessageDestination> getMessageDestinations() throws ConfigurationException;
395
396
        /**
397
         * Retrieves message destinations configured on the target server instance.
398
         *
399
         * @return set of message destinations
400
         * 
401
         * @throws ConfigurationException if there is some problem with message destination configuration
402
         * 
403
         * @since 1.25 
404
         */
405
        public Set<MessageDestination> getServerMessageDestinations() throws ConfigurationException;
406
        
407
        /**
408
         * Tests whether a message destination creation is supported.
409
         *
410
         * @return true if message destination creation is supported, false otherwise.
411
         *
412
         * @since 1.25
413
         */
414
        public boolean supportsCreateMessageDestination();
415
416
        /**
417
         * Creates and saves a message destination in the module if it does not exist in the module yet.
418
         * Message destinations are considered to be equal if their JNDI names are equal.
419
         *
420
         * @param jndiName JNDI name of the message destination
421
         * @param type message destination type; the value is of 
422
         * org.netbeans.modules.j2ee.deployment.common.api.MessageDestination.Type type
423
         * @return created message destination
424
         * 
425
         * @throws UnsupportedOperationException if this opearation is not supported
426
         * @throws ConfigurationException if there is some problem with message destination configuration
427
         *
428
         * @since 1.25 
429
         */
430
        public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) 
431
        throws UnsupportedOperationException, ConfigurationException;
335
    }
432
    }
336
433
337
    /**
434
    /**
(-)src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java (-1 / +61 lines)
Lines 13-19 Link Here
13
 * "Portions Copyrighted [year] [name of copyright owner]"
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
18
 */
19
19
Lines 38-43 Link Here
38
import org.openide.filesystems.*;
38
import org.openide.filesystems.*;
39
import java.util.*;
39
import java.util.*;
40
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
40
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
41
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
41
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
42
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
42
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
43
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
43
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
44
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
Lines 52-57 Link Here
52
import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
55
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
56
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
55
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
57
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
56
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
58
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
57
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
59
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
Lines 103-108 Link Here
103
    private FindJSPServlet findJSPServlet;
105
    private FindJSPServlet findJSPServlet;
104
    private DatasourceManager dsMgr;
106
    private DatasourceManager dsMgr;
105
    private DatasourceManager ddsMgr;
107
    private DatasourceManager ddsMgr;
108
    private MessageDestinationDeployment msgDestDeploymentConnected;
109
    private MessageDestinationDeployment msgDestDeploymentDisconnected;
106
    private final Set targetsStartedByIde = new HashSet(); // valued by target name
110
    private final Set targetsStartedByIde = new HashSet(); // valued by target name
107
    private Map targets; // keyed by target name, valued by ServerTarget
111
    private Map targets; // keyed by target name, valued by ServerTarget
108
    private boolean managerStartedByIde = false;
112
    private boolean managerStartedByIde = false;
Lines 555-560 Link Here
555
559
556
        if (dsMgr != null) 
560
        if (dsMgr != null) 
557
            dsMgr.deployDatasources(datasources);
561
            dsMgr.deployDatasources(datasources);
562
    }
563
    
564
    private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() {
565
        if (msgDestDeploymentConnected == null) {
566
            msgDestDeploymentConnected = server.getOptionalFactory().
567
                    getMessageDestinationDeployment(getDeploymentManager());
568
        }
569
570
        return msgDestDeploymentConnected;
571
    }
572
    
573
    private MessageDestinationDeployment getMessageDestinationDeploymentDisconnected() {
574
        DeploymentManager dm = null;
575
        try {
576
            dm = getDisconnectedDeploymentManager();
577
        }  catch (DeploymentManagerCreationException dmce) {
578
            throw new RuntimeException(dmce);
579
        }
580
        synchronized (this) {
581
            if (msgDestDeploymentDisconnected == null) {
582
                msgDestDeploymentDisconnected = server.getOptionalFactory().getMessageDestinationDeployment(dm);
583
            }
584
            return msgDestDeploymentDisconnected;
585
        }
586
    }
587
    
588
    /**
589
     * Retrieves message destinations configured on the target server instance.
590
     *
591
     * @return set of message destinations
592
     * 
593
     * @throws ConfigurationException if there is some problem with message destination configuration
594
     */
595
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException {
596
        
597
        MessageDestinationDeployment destDepl = getMessageDestinationDeploymentDisconnected();
598
        if (destDepl != null) {
599
            return destDepl.getMessageDestinations();
600
        }
601
        
602
        return Collections.<MessageDestination>emptySet();
603
    }
604
    
605
    /**
606
     * Deploys message destinations saved in the module.
607
     *
608
     * @param destinations set of message destinations
609
     * 
610
     * @throws ConfigurationException if there is some problem with message destination configuration
611
     */
612
    public void deployMessageDestinations(Set<MessageDestination> destinations) throws ConfigurationException {
613
        
614
        MessageDestinationDeployment destDepl = getMessageDestinationDeploymentConnected();
615
        if (destDepl != null) {
616
            destDepl.deployMessageDestinations(destinations);
617
        }
558
    }
618
    }
559
    
619
    
560
    //---------- State API's:  running, debuggable, startedByIDE -----------
620
    //---------- State API's:  running, debuggable, startedByIDE -----------
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/MessageDestinationDeployment.java (+53 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.j2ee.deployment.plugins.spi;
21
22
import java.util.Set;
23
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
24
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
25
26
/**
27
 * MessageDestinationDeployment is responsible for retrieving message destinations
28
 * configured on the server and for message destination deployment.
29
 *
30
 * @author Libor Kotouc
31
 *
32
 * @since 1.25
33
 */
34
public interface MessageDestinationDeployment {
35
    
36
    /**
37
     * Retrieves message destinations configured on the target server instance.
38
     *
39
     * @return set of message destinations
40
     * 
41
     * @throws ConfigurationException if there is some problem with message destination configuration
42
     */
43
    Set<MessageDestination> getMessageDestinations() throws ConfigurationException;
44
45
    /**
46
     * Deploys message destinations saved in the module.
47
     *
48
     * @param destinations set of message destinations
49
     * 
50
     * @exception ConfigurationException if there is some problem with message destination configuration
51
     */
52
    void deployMessageDestinations(Set<MessageDestination> destinations) throws ConfigurationException;
53
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java (-3 / +17 lines)
Lines 13-19 Link Here
13
 * "Portions Copyrighted [year] [name of copyright owner]"
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
18
 */
19
19
Lines 21-28 Link Here
21
package org.netbeans.modules.j2ee.deployment.plugins.spi;
21
package org.netbeans.modules.j2ee.deployment.plugins.spi;
22
22
23
import javax.enterprise.deploy.spi.DeploymentManager;
23
import javax.enterprise.deploy.spi.DeploymentManager;
24
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
25
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
26
import org.openide.WizardDescriptor;
24
import org.openide.WizardDescriptor;
27
25
28
/**
26
/**
Lines 93-96 Link Here
93
    public DatasourceManager getDatasourceManager(DeploymentManager dm) {
91
    public DatasourceManager getDatasourceManager(DeploymentManager dm) {
94
        return null;
92
        return null;
95
    }
93
    }
94
95
    /**
96
     * Creates a <code>MessageDestinationDeployment</code> for the given deployment manager
97
     * or <code>null</code> if message destination deployment is not supported
98
     *
99
     * @param dm the deployment manager
100
     *
101
     * @return a message destination deployment or <code>null</code> 
102
     *          if message destination deployment is not supported
103
     *
104
     * @since 1.25
105
     */
106
    public MessageDestinationDeployment getMessageDestinationDeployment(DeploymentManager dm) {
107
        return null;
108
    }
109
    
96
}
110
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/DatasourceConfiguration.java (+56 lines)
Lines 71-74 Link Here
71
     */
71
     */
72
    Datasource createDatasource(String jndiName, String  url, String username, String password, String driver) 
72
    Datasource createDatasource(String jndiName, String  url, String username, String password, String driver) 
73
    throws UnsupportedOperationException, ConfigurationException, DatasourceAlreadyExistsException;
73
    throws UnsupportedOperationException, ConfigurationException, DatasourceAlreadyExistsException;
74
75
    /**
76
     * Binds the data source name used in the sources with the corresponding data source which is
77
     * identified the given JNDI name.
78
     * 
79
     * @param referenceName name used to identify the data source
80
     * @param jndiName JNDI name of the data source
81
     * @throws ConfigurationException if there is some problem with data source configuration
82
     * 
83
     * @since 1.25
84
     */
85
    public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException;
86
87
    /**
88
     * Binds the data source name used in the sources with the corresponding data source which is
89
     * identified the given JNDI name. The reference is used within the scope of the EJB.
90
     * 
91
     * @param referenceName name used to identify the data source
92
     * @param jndiName JNDI name of the data source
93
     * @param ejbName EJB name
94
     * @param ejbType EJB type - the possible values are 
95
     * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.SESSION,
96
     * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.ENTITY and
97
     * org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.MESSAGE_DRIVEN
98
99
     * @throws ConfigurationException if there is some problem with data source configuration
100
     * 
101
     * @since 1.25
102
     */
103
    public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName,
104
                                           String ejbName, String ejbType) throws ConfigurationException;
105
106
    /**
107
     * Finds JNDI name of the data source which is mapped to the given reference name.
108
     * 
109
     * @referenceName reference name
110
     * @return JNDI name of the data source if the mapping exists, null otherwise
111
     *
112
     * @throws ConfigurationException if there is some problem with data source configuration
113
     * 
114
     * @since 1.25
115
     */
116
    public String findDatasourceBinding(String dsReferenceName) throws ConfigurationException;
117
    
118
    /**
119
     * Finds JNDI name of the data source which is mapped to the given reference name in the scope the EJB.
120
     * 
121
     * @param referenceName reference name
122
     * @param ejbName EJB name
123
     * @return JNDI name of the data source if the mapping exists, null otherwise
124
     *
125
     * @throws ConfigurationException if there is some problem with data source configuration
126
     * 
127
     * @since 1.25
128
     */
129
    public String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException;
74
}
130
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/MessageDestinationConfiguration.java (+73 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.j2ee.deployment.plugins.spi.config;
21
22
import java.util.Set;
23
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
24
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
25
26
/**
27
 * Configuration useful for managing module message destinations.
28
 * <p>
29
 * Implementation of this interface should be registered in the {@link ModuleConfiguration}
30
 * lookup.
31
 *
32
 * @author Libor Kotouc
33
 */
34
public interface MessageDestinationConfiguration {
35
    
36
    /**
37
     * Retrieves message destinations stored in the module.
38
     * 
39
     * @return set of message destinations
40
     * 
41
     * @throws ConfigurationException if there is some problem with message destination configuration
42
     * 
43
     * @since 1.25
44
     */
45
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException;
46
    
47
    /**
48
     * Tests whether a message destination creation is supported.
49
     *
50
     * @return true if message destination creation is supported, false otherwise.
51
     *
52
     * @since 1.25
53
     */
54
    public boolean supportsCreateMessageDestination();
55
            
56
    /**
57
     * Creates and saves a message destination in the module if it does not exist in the module yet.
58
     * Message destinations are considered to be equal if their JNDI names are equal.
59
     *
60
     * @param jndiName JNDI name of the message destination
61
     * @param type message destination type; the value is of 
62
     * org.netbeans.modules.j2ee.deployment.common.api.MessageDestination.Type type
63
     * @return created message destination
64
     * 
65
     * @throws UnsupportedOperationException if this opearation is not supported
66
     * @throws ConfigurationException if there is some problem with message destination configuration
67
     *
68
     * @since 1.25 
69
     */
70
    public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) 
71
    throws UnsupportedOperationException, ConfigurationException;
72
    
73
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/config/ModuleConfiguration.java (-1 / +2 lines)
Lines 39-45 Link Here
39
     * implementations of all the supported configurations.
39
     * implementations of all the supported configurations.
40
     * <p>
40
     * <p>
41
     * The configuration are:  {@link ContextRootConfiguration},  {@link DatasourceConfiguration}, 
41
     * The configuration are:  {@link ContextRootConfiguration},  {@link DatasourceConfiguration}, 
42
     * {@link MappingConfiguration}, {@link EjbResourceConfiguration}, {@link DeploymentPlanConfiguration}
42
     * {@link MappingConfiguration}, {@link EjbResourceConfiguration}, {@link DeploymentPlanConfiguration},
43
     * {@link MessageDestinationConfiguration}
43
     * <p>
44
     * <p>
44
     * Implementators are advised to use {@link org.openide.util.lookup.Lookups#fixed}
45
     * Implementators are advised to use {@link org.openide.util.lookup.Lookups#fixed}
45
     * to implement this method.
46
     * to implement this method.

Return to bug 93815