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

(-)build.xml (+8 lines)
Lines 67-72 Link Here
67
	  removeUnreferencedNodes="true"
67
	  removeUnreferencedNodes="true"
68
          docroot="datasources"
68
          docroot="datasources"
69
	  rootDir="src"/>
69
	  rootDir="src"/>
70
	<schema2beans schema="${jb_dir}/resources/jboss-service_4_0.dtd"
71
	  package="org.netbeans.modules.j2ee.jboss4.config.gen"
72
	  schemaType="dtd"
73
	  validate="true"
74
	  attrProp="true"
75
	  removeUnreferencedNodes="true"
76
          docroot="server"
77
	  rootDir="src"/>
70
	<schema2beans schema="${jb_dir}/resources/jboss-client_4_0.dtd"
78
	<schema2beans schema="${jb_dir}/resources/jboss-client_4_0.dtd"
71
	  package="org.netbeans.modules.j2ee.jboss4.config.gen"
79
	  package="org.netbeans.modules.j2ee.jboss4.config.gen"
72
	  schemaType="dtd"
80
	  schemaType="dtd"
(-)src/org/netbeans/modules/j2ee/jboss4/config/CarDeploymentConfiguration.java (-2 / +6 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 111-117 Link Here
111
                } else {
111
                } else {
112
                    // create jboss-web.xml if it does not exist yet
112
                    // create jboss-web.xml if it does not exist yet
113
                    jbossClient = generateJbossClient();
113
                    jbossClient = generateJbossClient();
114
                    writefile(jbossClientFile, jbossClient);
114
                    writeFile(jbossClientFile, jbossClient);
115
                }
115
                }
116
            } catch (ConfigurationException ce) {
116
            } catch (ConfigurationException ce) {
117
                ErrorManager.getDefault().notify(ce);
117
                ErrorManager.getDefault().notify(ce);
Lines 419-424 Link Here
419
419
420
    public boolean supportsCreateDatasource() {
420
    public boolean supportsCreateDatasource() {
421
        return true;
421
        return true;
422
    }
423
424
    public boolean supportsCreateMessageDestination() {
425
        return false;
422
    }
426
    }
423
    
427
    
424
    // private helper interface -----------------------------------------------
428
    // private helper interface -----------------------------------------------
(-)src/org/netbeans/modules/j2ee/jboss4/config/EarDeploymentConfiguration.java (-2 / +7 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 91-97 Link Here
91
                } else {
91
                } else {
92
                    // create jboss-app.xml if it does not exist yet
92
                    // create jboss-app.xml if it does not exist yet
93
                    jbossApp = genereatejbossApp();
93
                    jbossApp = genereatejbossApp();
94
                    writefile(jbossAppFile, jbossApp);
94
                    writeFile(jbossAppFile, jbossApp);
95
                }
95
                }
96
            } catch (ConfigurationException ce) {
96
            } catch (ConfigurationException ce) {
97
                ErrorManager.getDefault().notify(ce);
97
                ErrorManager.getDefault().notify(ce);
Lines 126-129 Link Here
126
    public boolean supportsCreateDatasource() {
126
    public boolean supportsCreateDatasource() {
127
        return false;
127
        return false;
128
    }
128
    }
129
    
130
    public boolean supportsCreateMessageDestination() {
131
        return false;
132
    }
133
    
129
}
134
}
(-)src/org/netbeans/modules/j2ee/jboss4/config/EjbDeploymentConfiguration.java (-7 / +83 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 40-47 Link Here
40
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
40
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
41
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
41
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
42
import org.netbeans.modules.j2ee.jboss4.config.gen.EnterpriseBeans;
42
import org.netbeans.modules.j2ee.jboss4.config.gen.EnterpriseBeans;
43
import org.netbeans.modules.j2ee.jboss4.config.gen.Entity;
43
import org.netbeans.modules.j2ee.jboss4.config.gen.Jboss;
44
import org.netbeans.modules.j2ee.jboss4.config.gen.Jboss;
44
import org.netbeans.modules.j2ee.jboss4.config.gen.MessageDriven;
45
import org.netbeans.modules.j2ee.jboss4.config.gen.MessageDriven;
46
import org.netbeans.modules.j2ee.jboss4.config.gen.ResourceRef;
47
import org.netbeans.modules.j2ee.jboss4.config.gen.Session;
45
import org.openide.DialogDisplayer;
48
import org.openide.DialogDisplayer;
46
import org.openide.ErrorManager;
49
import org.openide.ErrorManager;
47
import org.openide.NotifyDescriptor;
50
import org.openide.NotifyDescriptor;
Lines 130-136 Link Here
130
    public boolean supportsCreateDatasource() {
133
    public boolean supportsCreateDatasource() {
131
        return true;
134
        return true;
132
    }
135
    }
133
        
136
    
137
    public boolean supportsCreateMessageDestination() {
138
        return true;
139
    }
140
    
134
//        //listen on the resource-ref element
141
//        //listen on the resource-ref element
135
//        deplObj.getDDBeanRoot().addXpathListener(SESSION_RESOURCE_REF, this);
142
//        deplObj.getDDBeanRoot().addXpathListener(SESSION_RESOURCE_REF, this);
136
//        deplObj.getDDBeanRoot().addXpathListener(ENTITY_RESOURCE_REF, this);
143
//        deplObj.getDDBeanRoot().addXpathListener(ENTITY_RESOURCE_REF, this);
Lines 165-171 Link Here
165
                } else {
172
                } else {
166
                    // create jboss.xml if it does not exist yet
173
                    // create jboss.xml if it does not exist yet
167
                    jboss = generateJboss();
174
                    jboss = generateJboss();
168
                    writefile(jbossFile, jboss);
175
                    writeFile(jbossFile, jboss);
169
                }
176
                }
170
            } catch (ConfigurationException ce) {
177
            } catch (ConfigurationException ce) {
171
                ErrorManager.getDefault().notify(ce);
178
                ErrorManager.getDefault().notify(ce);
Lines 237-243 Link Here
237
//                        Set beanNames = null;
244
//                        Set beanNames = null;
238
//                        if (desc.length > 0  && "javax.sql.DataSource".equals(type[0])) { // NOI18N
245
//                        if (desc.length > 0  && "javax.sql.DataSource".equals(type[0])) { // NOI18N
239
//                            beanNames = getRelevantBeansDataRef(desc[0], name[0], eventDDBean.getRoot(), beanType);
246
//                            beanNames = getRelevantBeansDataRef(desc[0], name[0], eventDDBean.getRoot(), beanType);
240
//                            addResReference(desc[0], name[0], beanNames, beanType);
247
//                            String jndiName = JBDeploymentConfiguration.JBOSS4_DATASOURCE_JNDI_PREFIX + resRefName;
248
//                            addResReference(jndiName, name[0], beanNames, beanType);
241
//                        }
249
//                        }
242
//                        else
250
//                        else
243
//                        if ("javax.mail.Session".equals(type[0])) { // NOI18N
251
//                        if ("javax.mail.Session".equals(type[0])) { // NOI18N
Lines 724-744 Link Here
724
        
732
        
725
        return beanMap;
733
        return beanMap;
726
    }
734
    }
735
736
    public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName,
737
                                           String ejbName, String ejbType) throws ConfigurationException {
738
        Set beanNames = new HashSet();
739
        beanNames.add(ejbName);
740
        BEAN_TYPE beanType = BEAN_TYPE.SESSION;
741
        if (org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.ENTITY.equals(ejbType)) {
742
            beanType = BEAN_TYPE.ENTITY;
743
        }
744
        else
745
        if (org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans.MESSAGE_DRIVEN.equals(ejbType)) {
746
            beanType = BEAN_TYPE.MSGDRV;
747
        }
748
749
        addResReference(dsJNDIName, dsReferenceName, beanNames, beanType);
750
    }
751
    
752
    public String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException {
753
754
        EnterpriseBeans beans = getJboss().getEnterpriseBeans();
755
        if (beans == null) {
756
            return null;
757
        }
758
        
759
        Session[] sessions = beans.getSession();
760
        for (Session session : sessions) {
761
            if (ejbName.equals(session.getEjbName())) {
762
                ResourceRef[] resourceRefs = session.getResourceRef();
763
                for (ResourceRef resourceRef : resourceRefs) {
764
                    String rrn = resourceRef.getResRefName();
765
                    if (dsReferenceName.equals(rrn)) {
766
                        return resourceRef.getJndiName();
767
                    }
768
                }
769
                return null;
770
            }
771
        }
772
773
        Entity[] entities = beans.getEntity();
774
        for (Entity entity : entities) {
775
            if (ejbName.equals(entity.getEjbName())) {
776
                ResourceRef[] resourceRefs = entity.getResourceRef();
777
                for (ResourceRef resourceRef : resourceRefs) {
778
                    String rrn = resourceRef.getResRefName();
779
                    if (dsReferenceName.equals(rrn)) {
780
                        return resourceRef.getJndiName();
781
                    }
782
                }
783
                return null;
784
            }
785
        }
786
787
        MessageDriven[] mdbs = beans.getMessageDriven();
788
        for (MessageDriven mdb : mdbs) {
789
            if (ejbName.equals(mdb.getEjbName())) {
790
                ResourceRef[] resourceRefs = mdb.getResourceRef();
791
                for (ResourceRef resourceRef : resourceRefs) {
792
                    String rrn = resourceRef.getResRefName();
793
                    if (dsReferenceName.equals(rrn)) {
794
                        return resourceRef.getJndiName();
795
                    }
796
                }
797
                return null;
798
            }
799
        }
800
        
801
        return null;
802
    }    
803
    
727
    
804
    
728
    /**
805
    /**
729
     * Add a new data source reference to the beans of the given type without it.
806
     * Add a new data source reference to the beans of the given type without it.
730
     * 
807
     * 
731
     * @param desc data source description
808
     * @param jndiName JNDI name of the resource
732
     * @param resRefName data source reference name
809
     * @param resRefName data source reference name
733
     * @param beanNames the beans (ejb-name value) which might need to add data source reference specified by resRefName
810
     * @param beanNames the beans (ejb-name value) which might need to add data source reference specified by resRefName
734
     * @param beanType type of bean to add data source reference to
811
     * @param beanType type of bean to add data source reference to
735
     */
812
     */
736
    private void addResReference(String desc, final String resRefName, final Set beanNames, final BEAN_TYPE beanType) 
813
    private void addResReference(final String jndiName, final String resRefName, final Set beanNames, final BEAN_TYPE beanType) 
737
    throws ConfigurationException 
814
    throws ConfigurationException 
738
    {
815
    {
739
        modifyJboss(new JbossModifier() {
816
        modifyJboss(new JbossModifier() {
740
           public void modify(Jboss modifiedJboss) {
817
           public void modify(Jboss modifiedJboss) {
741
               String jndiName = JBDeploymentConfiguration.JBOSS4_DATASOURCE_JNDI_PREFIX + resRefName;
742
               JbossDataSourceRefModifier.modify(modifiedJboss, resRefName, beanNames, beanType, jndiName);
818
               JbossDataSourceRefModifier.modify(modifiedJboss, resRefName, beanNames, beanType, jndiName);
743
           }
819
           }
744
        });
820
        });
(-)src/org/netbeans/modules/j2ee/jboss4/config/JBDeploymentConfiguration.java (-10 / +40 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 25-47 Link Here
25
import java.io.ByteArrayOutputStream;
25
import java.io.ByteArrayOutputStream;
26
import java.io.File;
26
import java.io.File;
27
import java.io.IOException;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.OutputStream;
28
import java.io.OutputStream;
30
import java.util.HashSet;
29
import java.util.HashSet;
31
import java.util.Set;
30
import java.util.Set;
32
import javax.enterprise.deploy.model.DDBeanRoot;
33
import javax.enterprise.deploy.spi.DConfigBeanRoot;
34
import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
35
import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
36
import javax.swing.text.BadLocationException;
31
import javax.swing.text.BadLocationException;
37
import javax.swing.text.StyledDocument;
32
import javax.swing.text.StyledDocument;
38
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
33
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
39
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
34
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
40
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
35
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
36
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
41
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
37
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
42
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
38
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
39
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
43
import org.netbeans.modules.j2ee.jboss4.config.gen.Datasources;
40
import org.netbeans.modules.j2ee.jboss4.config.gen.Datasources;
44
import org.netbeans.modules.j2ee.jboss4.config.gen.LocalTxDatasource;
41
import org.netbeans.modules.j2ee.jboss4.config.gen.LocalTxDatasource;
42
import org.netbeans.modules.j2ee.jboss4.config.mdb.MessageDestinationSupport;
45
import org.netbeans.modules.schema2beans.BaseBean;
43
import org.netbeans.modules.schema2beans.BaseBean;
46
import org.openide.DialogDisplayer;
44
import org.openide.DialogDisplayer;
47
import org.openide.ErrorManager;
45
import org.openide.ErrorManager;
Lines 62-70 Link Here
62
/** 
60
/** 
63
 * Base for JBoss DeploymentConfiguration implementations.
61
 * Base for JBoss DeploymentConfiguration implementations.
64
 *
62
 *
65
 * @author  Pavel Buzek, lkotouc
63
 * @author  Pavel Buzek, Libor Kotouc
66
 */
64
 */
67
public abstract class JBDeploymentConfiguration implements DatasourceConfiguration {
65
public abstract class JBDeploymentConfiguration 
66
        implements DatasourceConfiguration, MessageDestinationConfiguration {
67
68
    
68
    
69
    protected static final String JBOSS4_DATASOURCE_JNDI_PREFIX = "java:"; // NOI18N
69
    protected static final String JBOSS4_DATASOURCE_JNDI_PREFIX = "java:"; // NOI18N
70
    protected static final String JBOSS4_MAIL_SERVICE_JNDI_NAME = "java:Mail"; // NOI18N
70
    protected static final String JBOSS4_MAIL_SERVICE_JNDI_NAME = "java:Mail"; // NOI18N
Lines 92-97 Link Here
92
    //cached data object for the data source file
92
    //cached data object for the data source file
93
    private DataObject datasourcesDO;
93
    private DataObject datasourcesDO;
94
    
94
    
95
     //support for message destination resources
96
    private MessageDestinationSupport destSupport;
97
    
95
    /** Creates a new instance of JBDeploymentConfiguration */
98
    /** Creates a new instance of JBDeploymentConfiguration */
96
    public JBDeploymentConfiguration (J2eeModule j2eeModule) {
99
    public JBDeploymentConfiguration (J2eeModule j2eeModule) {
97
        this.j2eeModule = j2eeModule;
100
        this.j2eeModule = j2eeModule;
Lines 114-120 Link Here
114
    
117
    
115
    // helper methods -------------------------------------------------
118
    // helper methods -------------------------------------------------
116
    
119
    
117
    protected void writefile(final File file, final BaseBean bean) throws ConfigurationException {
120
    public static void writeFile(final File file, final BaseBean bean) throws ConfigurationException {
118
        try {
121
        try {
119
            FileObject cfolder = FileUtil.toFileObject(file.getParentFile());
122
            FileObject cfolder = FileUtil.toFileObject(file.getParentFile());
120
            if (cfolder == null) {
123
            if (cfolder == null) {
Lines 261-267 Link Here
261
            } else {
264
            } else {
262
                // create jboss-ds.xml if it does not exist yet
265
                // create jboss-ds.xml if it does not exist yet
263
                datasources = new Datasources();
266
                datasources = new Datasources();
264
                writefile(datasourcesFile, datasources);
267
                writeFile(datasourcesFile, datasources);
265
            }
268
            }
266
        } catch (ConfigurationException ce) {
269
        } catch (ConfigurationException ce) {
267
            ErrorManager.getDefault().notify(ce);
270
            ErrorManager.getDefault().notify(ce);
Lines 408-412 Link Here
408
        });
411
        });
409
    }
412
    }
410
    
413
    
414
    public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException {}
415
    
416
    public void bindDatasourceReferenceEjb(String dsReferenceName, String dsJNDIName,
417
                                           String ejbName, String ejbType) throws ConfigurationException {}
418
419
    public String findDatasourceBinding(String dsReferenceName) throws ConfigurationException {
420
        return null;
421
    }
422
    
423
    public String findDatasourceBindingEjb(String dsReferenceName, String ejbName) throws ConfigurationException {
424
        return null;
425
    }
426
   
427
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException {
428
        if (destSupport == null) {
429
            destSupport = new MessageDestinationSupport(resourceDir);
430
        }
431
        return destSupport.getMessageDestinations();
432
    }
433
434
    public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) 
435
    throws UnsupportedOperationException, ConfigurationException {
436
        if (destSupport == null) {
437
            destSupport = new MessageDestinationSupport(resourceDir);
438
        }
439
        return destSupport.createMessageDestination(jndiName, type);
440
    }
411
    
441
    
412
}
442
}
(-)src/org/netbeans/modules/j2ee/jboss4/config/JBossDatasourceManager.java (-2 / +10 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 90-96 Link Here
90
            FileObject dsFO = (FileObject)it.next();
90
            FileObject dsFO = (FileObject)it.next();
91
            File dsFile = FileUtil.toFile(dsFO);
91
            File dsFile = FileUtil.toFile(dsFO);
92
            try {
92
            try {
93
                Datasources ds = Datasources.createGraph(dsFile);
93
                Datasources ds = null;
94
                try {
95
                    ds = Datasources.createGraph(dsFile);
96
                } catch (RuntimeException re) {
97
                    // most likely not a data source (e.g. jms-ds.xml in JBoss 5.x)
98
                    String msg = NbBundle.getMessage(JBossDatasourceManager.class, "MSG_NotParseableDatasources", dsFile.getAbsolutePath());
99
                    ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, msg);
100
                    continue;
101
                }
94
                LocalTxDatasource ltxds[] = ds.getLocalTxDatasource();
102
                LocalTxDatasource ltxds[] = ds.getLocalTxDatasource();
95
                for (int i = 0; i < ltxds.length; i++) {
103
                for (int i = 0; i < ltxds.length; i++) {
96
                    if (ltxds[i].getJndiName().length() > 0) {
104
                    if (ltxds[i].getJndiName().length() > 0) {
(-)src/org/netbeans/modules/j2ee/jboss4/config/WarDeploymentConfiguration.java (-6 / +27 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 54-60 Link Here
54
 * Web module deployment configuration handles creation and updating of the 
54
 * Web module deployment configuration handles creation and updating of the 
55
 * jboss-web.xml configuration file.
55
 * jboss-web.xml configuration file.
56
 *
56
 *
57
 * @author sherold, lkotouc
57
 * @author Stepan Herold, Libor Kotouc
58
 */
58
 */
59
public class WarDeploymentConfiguration extends JBDeploymentConfiguration 
59
public class WarDeploymentConfiguration extends JBDeploymentConfiguration 
60
implements ModuleConfiguration, ContextRootConfiguration, DatasourceConfiguration, 
60
implements ModuleConfiguration, ContextRootConfiguration, DatasourceConfiguration, 
Lines 100-105 Link Here
100
        return true;
100
        return true;
101
    }
101
    }
102
    
102
    
103
    public boolean supportsCreateMessageDestination() {
104
        return true;
105
    }
106
103
    /**
107
    /**
104
     * Return context path.
108
     * Return context path.
105
     * 
109
     * 
Lines 162-168 Link Here
162
                try {
166
                try {
163
                    String resType = resourceRef.getResType();
167
                    String resType = resourceRef.getResType();
164
                    if ("javax.sql.DataSource".equals(resType)) { // NOI18N
168
                    if ("javax.sql.DataSource".equals(resType)) { // NOI18N
165
                        addResReference(resourceRef.getResRefName());
169
                        addResReference(resourceRef.getResRefName(), JBOSS4_DATASOURCE_JNDI_PREFIX + resourceRef.getResRefName());
166
                    } else if ("javax.mail.Session".equals(resType)) { // NOI18N
170
                    } else if ("javax.mail.Session".equals(resType)) { // NOI18N
167
                        addMailReference(resourceRef.getResRefName());
171
                        addMailReference(resourceRef.getResRefName());
168
                    } else if ("javax.jms.ConnectionFactory".equals(resType)) { // NOI18N
172
                    } else if ("javax.jms.ConnectionFactory".equals(resType)) { // NOI18N
Lines 197-208 Link Here
197
        }
201
        }
198
    }
202
    }
199
    
203
    
204
    public void bindDatasourceReference(String dsReferenceName, String dsJNDIName) throws ConfigurationException {
205
        addResReference(dsReferenceName, dsJNDIName);
206
    }
207
    
208
    public String findDatasourceBinding(String dsReferenceName) throws ConfigurationException {
209
        
210
        ResourceRef resourceRefs[] = getJbossWeb().getResourceRef();
211
        for (ResourceRef resourceRef : resourceRefs) {
212
            String rrn = resourceRef.getResRefName();
213
            if (dsReferenceName.equals(rrn)) {
214
                return resourceRef.getJndiName();
215
            }
216
        }
217
        
218
        return null;
219
    }
220
200
    /**
221
    /**
201
     * Add a new resource reference.
222
     * Add a new resource reference.
202
     * 
223
     * 
203
     * @param name resource reference name
224
     * @param name resource reference name
204
     */
225
     */
205
    private void addResReference(final String name) throws ConfigurationException {
226
    private void addResReference(final String name, final String jndiName) throws ConfigurationException {
206
        modifyJbossWeb(new JbossWebModifier() {
227
        modifyJbossWeb(new JbossWebModifier() {
207
            public void modify(JbossWeb modifiedJbossWeb) {
228
            public void modify(JbossWeb modifiedJbossWeb) {
208
229
Lines 219-225 Link Here
219
                //if it doesn't exist yet, create a new one
240
                //if it doesn't exist yet, create a new one
220
                ResourceRef newRR = new ResourceRef();
241
                ResourceRef newRR = new ResourceRef();
221
                newRR.setResRefName(name);
242
                newRR.setResRefName(name);
222
                newRR.setJndiName(JBOSS4_DATASOURCE_JNDI_PREFIX + name);
243
                newRR.setJndiName(jndiName);
223
                modifiedJbossWeb.addResourceRef(newRR);
244
                modifiedJbossWeb.addResourceRef(newRR);
224
            }
245
            }
225
        });
246
        });
Lines 366-372 Link Here
366
                } else {
387
                } else {
367
                    // create jboss-web.xml if it does not exist yet
388
                    // create jboss-web.xml if it does not exist yet
368
                    jbossWeb = generateJbossWeb();
389
                    jbossWeb = generateJbossWeb();
369
                    writefile(jbossWebFile, jbossWeb);
390
                    writeFile(jbossWebFile, jbossWeb);
370
                }
391
                }
371
            } catch (ConfigurationException ce) {
392
            } catch (ConfigurationException ce) {
372
                ErrorManager.getDefault().notify(ce);
393
                ErrorManager.getDefault().notify(ce);
(-)src/org/netbeans/modules/j2ee/jboss4/config/mdb/JBossMessageDestination.java (+46 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.jboss4.config.mdb;
21
22
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
23
24
/**
25
 *
26
 * @author Libor Kotouc
27
 */
28
public class JBossMessageDestination implements MessageDestination {
29
    
30
    private String jndiName;
31
    private Type type;
32
    
33
    public JBossMessageDestination(String jndiName, Type type) {
34
        this.jndiName = jndiName;
35
        this.type = type;
36
    }
37
38
    public String getJndiName() {
39
        return jndiName;
40
    }
41
42
    public Type getType() {
43
        return type;
44
    }
45
    
46
}
(-)src/org/netbeans/modules/j2ee/jboss4/config/mdb/JBossMessageDestinationDeployment.java (+259 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.jboss4.config.mdb;
21
22
import java.io.BufferedOutputStream;
23
import java.io.File;
24
import java.io.IOException;
25
import java.io.OutputStream;
26
import java.util.HashSet;
27
import java.util.Set;
28
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
29
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
30
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
31
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
32
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
33
import org.netbeans.modules.schema2beans.BaseBean;
34
import org.openide.filesystems.FileLock;
35
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileSystem;
37
import org.openide.filesystems.FileUtil;
38
39
/**
40
 *
41
 * @author Libor Kotouc
42
 */
43
public final class JBossMessageDestinationDeployment implements MessageDestinationDeployment {
44
    
45
//    private static final String DSdotXML = "-ds.xml"; // NOI18N
46
//    private static final String JBossDSdotXML = "jboss-ds.xml"; // NOI18N
47
    
48
    // server's deploy dir
49
    private FileObject deployDir;
50
    
51
    public JBossMessageDestinationDeployment(String serverUrl) {
52
        String serverDirPath = InstanceProperties.getInstanceProperties(serverUrl).
53
                                        getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
54
        deployDir = FileUtil.toFileObject(new File(serverDirPath));
55
    }
56
    
57
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException {
58
        HashSet<MessageDestination> destinations = new HashSet<MessageDestination>();
59
        destinations.add(new JBossMessageDestination("SampleServerQueue", MessageDestination.Type.QUEUE));
60
        destinations.add(new JBossMessageDestination("SampleServerTopic", MessageDestination.Type.TOPIC));
61
        return destinations;
62
    }
63
64
    public void deployMessageDestinations(Set<MessageDestination> destinations) throws ConfigurationException {
65
    }
66
    
67
    
68
/*  
69
    public Set<Datasource> getDatasources() throws ConfigurationException {
70
        
71
        Set<Datasource> datasources = new HashSet<Datasource>();
72
        
73
        if (deployDir == null || !deployDir.isValid() || !deployDir.isFolder() || !deployDir.canRead()) {
74
            ErrorManager.getDefault().log(ErrorManager.USER, 
75
                    NbBundle.getMessage(JBossMessageDestinationDeployment.class, "ERR_WRONG_DEPLOY_DIR"));
76
            return datasources;
77
        }
78
        
79
        Enumeration files = deployDir.getChildren(true);
80
        List<FileObject> confs = new LinkedList<FileObject>();
81
        while (files.hasMoreElements()) { // searching for config files with DS
82
            FileObject file = (FileObject) files.nextElement();
83
            if (!file.isFolder() && file.getNameExt().endsWith(DSdotXML) && file.canRead())
84
                confs.add(file);
85
        }
86
        
87
        if (confs.size() == 0) // nowhere to search
88
            return datasources;
89
90
        for (Iterator it = confs.iterator(); it.hasNext();) {
91
            FileObject dsFO = (FileObject)it.next();
92
            File dsFile = FileUtil.toFile(dsFO);
93
            try {
94
                Datasources ds = null;
95
                try {
96
                    ds = Datasources.createGraph(dsFile);
97
                } catch (RuntimeException re) {
98
                    // most likely not a data source (e.g. jms-ds.xml in JBoss 5.x)
99
                    String msg = NbBundle.getMessage(JBossMessageDestinationDeployment.class, "MSG_NotParseableDatasources", dsFile.getAbsolutePath());
100
                    ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, msg);
101
                    continue;
102
                }
103
                LocalTxDatasource ltxds[] = ds.getLocalTxDatasource();
104
                for (int i = 0; i < ltxds.length; i++) {
105
                    if (ltxds[i].getJndiName().length() > 0) {
106
                        datasources.add(new JBossDatasource(
107
                                    ltxds[i].getJndiName(),
108
                                    ltxds[i].getConnectionUrl(),
109
                                    ltxds[i].getUserName(),
110
                                    ltxds[i].getPassword(),
111
                                    ltxds[i].getDriverClass()));
112
                    }
113
                }
114
            } catch (IOException ioe) {
115
                String msg = NbBundle.getMessage(JBossMessageDestinationDeployment.class, "MSG_CannotReadDatasources", dsFile.getAbsolutePath());
116
                throw new ConfigurationException(msg, ioe);
117
            } catch (RuntimeException re) {
118
                String msg = NbBundle.getMessage(JBossMessageDestinationDeployment.class, "MSG_NotParseableDatasources", dsFile.getAbsolutePath());
119
                throw new ConfigurationException(msg ,re);
120
            }
121
        }
122
        
123
        return datasources;
124
    }
125
126
    public void deployDatasources(Set<Datasource> datasources) 
127
    throws ConfigurationException, DatasourceAlreadyExistsException 
128
    {
129
        Set<Datasource> deployedDS = getDatasources();
130
        Map<String, Datasource> ddsMap = transform(deployedDS); // for faster searching
131
        
132
        HashMap<String, Datasource> newDS = new HashMap<String, Datasource>(); // will contain all ds which do not conflict with existing ones
133
        
134
        //resolve all conflicts
135
        LinkedList<Datasource> conflictDS = new LinkedList<Datasource>();
136
        for (Iterator<Datasource> it = datasources.iterator(); it.hasNext();) {
137
            Object o = it.next();
138
            if (!(o instanceof JBossDatasource))
139
                continue;
140
            JBossDatasource ds = (JBossDatasource)o;
141
            String jndiName = ds.getJndiName();
142
            if (ddsMap.keySet().contains(jndiName)) { // conflicting ds found
143
                if (!ddsMap.get(jndiName).equals(ds)) { // found ds is not equal
144
                    conflictDS.add(ddsMap.get(jndiName)); // NOI18N
145
                }
146
            }
147
            else if (jndiName != null) {
148
                newDS.put(jndiName, ds);
149
            }
150
        }
151
        
152
        if (conflictDS.size() > 0) { // conflict found -> exception
153
            throw new DatasourceAlreadyExistsException(conflictDS);
154
        }
155
        
156
        //write jboss-ds.xml
157
        FileObject dsXmlFo = serverDir.getFileObject(JBossDSdotXML);
158
        File dsXMLFile = (dsXmlFo != null ? FileUtil.toFile(dsXmlFo) : null);
159
160
        Datasources deployedDSGraph = null;
161
        try {
162
            deployedDSGraph = (dsXMLFile != null ? Datasources.createGraph(dsXMLFile) : new Datasources());
163
        }
164
        catch (IOException ioe) {
165
            ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(getClass(), "ERR_CannotReadDSdotXml"));
166
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);
167
            return;
168
        }
169
170
        //merge ds graph with newDS - remove conflicting ds from graph
171
        LocalTxDatasource ltxds[] = deployedDSGraph.getLocalTxDatasource();
172
        for (int i = 0; i < ltxds.length; i++) {
173
            String jndiName = ltxds[i].getJndiName();
174
            if (newDS.keySet().contains(jndiName)) //conflict, we must remove it from graph
175
                deployedDSGraph.removeLocalTxDatasource(ltxds[i]);
176
        }
177
        
178
        //add all ds from newDS
179
        for (Iterator it = newDS.values().iterator(); it.hasNext();) {
180
            JBossDatasource ds = (JBossDatasource) it.next();
181
            
182
            LocalTxDatasource lds = new LocalTxDatasource();
183
            lds.setJndiName(ds.getJndiName());
184
            lds.setConnectionUrl(ds.getUrl());
185
            lds.setDriverClass(ds.getDriverClassName());
186
            lds.setUserName(ds.getUsername());
187
            lds.setPassword(ds.getPassword());
188
            lds.setMinPoolSize(ds.getMinPoolSize());
189
            lds.setMaxPoolSize(ds.getMaxPoolSize());
190
            lds.setIdleTimeoutMinutes(ds.getIdleTimeoutMinutes());
191
192
            deployedDSGraph.addLocalTxDatasource(lds);
193
        }
194
        
195
        //write modified graph into jboss-ds.xml
196
        if (newDS.size() > 0) {
197
            if (dsXMLFile == null) {
198
                try {
199
                    dsXmlFo = serverDir.createData(JBossDSdotXML);
200
                }
201
                catch (IOException ioe) {
202
                    ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(getClass(), "ERR_CannotCreateDSdotXml"));
203
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);
204
                    return;
205
                }
206
                
207
                dsXMLFile = FileUtil.toFile(dsXmlFo);
208
            }
209
            
210
            writeFile(dsXMLFile, deployedDSGraph);            
211
        }        
212
        
213
    }
214
    
215
    private Map<String, Datasource> transform(Set<Datasource> datasources) {
216
        HashMap<String, Datasource> map = new HashMap<String, Datasource>();
217
        for (Iterator it = datasources.iterator(); it.hasNext();) {
218
            JBossDatasource ds = (JBossDatasource) it.next();
219
            if (ds.getJndiName() != null)
220
                map.put(ds.getJndiName(), ds);
221
        }
222
        return map;
223
    }
224
*/
225
    private void writeFile(final File file, final BaseBean bean) throws ConfigurationException {
226
        try {
227
228
            FileSystem fs = deployDir.getFileSystem();
229
            fs.runAtomicAction(new FileSystem.AtomicAction() {
230
                public void run() throws IOException {
231
                    OutputStream os = null;
232
                    FileLock lock = null;
233
                    try {
234
                        String name = file.getName();
235
                        FileObject configFO = deployDir.getFileObject(name);
236
                        if (configFO == null) {
237
                            configFO = deployDir.createData(name);
238
                        }
239
                        lock = configFO.lock();
240
                        os = new BufferedOutputStream (configFO.getOutputStream(lock), 4096);
241
                        // TODO notification needed
242
                        if (bean != null) {
243
                            bean.write(os);
244
                        }
245
                    } finally {
246
                        if (os != null) {
247
                            try { os.close(); } catch(IOException ioe) {}
248
                        }
249
                        if (lock != null) 
250
                            lock.releaseLock();
251
                    }
252
                }
253
            });
254
        } catch (IOException e) {
255
            throw new ConfigurationException (e.getLocalizedMessage ());
256
        }
257
    }
258
259
}
(-)src/org/netbeans/modules/j2ee/jboss4/config/mdb/MessageDestinationSupport.java (+168 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
package org.netbeans.modules.j2ee.jboss4.config.mdb;
20
21
import java.io.File;
22
import java.io.IOException;
23
import java.util.Collections;
24
import java.util.HashSet;
25
import java.util.Set;
26
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
27
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
28
import org.netbeans.modules.j2ee.jboss4.config.JBDeploymentConfiguration;
29
import org.netbeans.modules.j2ee.jboss4.config.gen.Mbean;
30
import org.netbeans.modules.j2ee.jboss4.config.gen.Server;
31
import org.openide.ErrorManager;
32
import org.openide.filesystems.FileChangeAdapter;
33
import org.openide.filesystems.FileEvent;
34
import org.openide.filesystems.FileObject;
35
import org.openide.filesystems.FileUtil;
36
37
/**
38
 *
39
 * @author Libor Kotouc
40
 */
41
public class MessageDestinationSupport {
42
    
43
    public static String MSG_DEST_RESOURCE_NAME_JB4 = "netbeans-destinations-service.xml"; // NOI18N
44
    
45
    //model of the destination service file
46
    private Server destinationServiceModel;
47
    
48
    //destination service file (placed in the resourceDir)
49
    private File destinationsFile;
50
    
51
    //destination service file object
52
    private FileObject destinationsFO;
53
    
54
    public MessageDestinationSupport(File resourceDir) {
55
        this.destinationsFile = destinationsFile;
56
57
        destinationsFile = new File(resourceDir, MSG_DEST_RESOURCE_NAME_JB4);
58
        ensureDestinationsFOExists();
59
    }
60
    
61
    /**
62
     * Listener of netbeans-destinations-service.xml document changes.
63
     */
64
    private class MessageDestinationFileListener extends FileChangeAdapter {
65
        
66
        public void fileChanged(FileEvent fe) {
67
            assert(fe.getSource() == destinationsFO);
68
            destinationServiceModel = null;
69
        }
70
71
        public void fileDeleted(FileEvent fe) {
72
            assert(fe.getSource() == destinationsFO);
73
            destinationServiceModel = null;
74
        }
75
    } 
76
    
77
    private void ensureDestinationsFOExists() {
78
        if (!destinationsFile.exists()) {
79
            return;
80
        }
81
        if (destinationsFO == null || !destinationsFO.isValid()) {
82
            destinationsFO = FileUtil.toFileObject(destinationsFile);
83
            assert(destinationsFO != null);
84
            destinationsFO.addFileChangeListener(new MessageDestinationFileListener());
85
        }
86
    }
87
    
88
    public Set<MessageDestination> getMessageDestinations() throws ConfigurationException {
89
        
90
        Server server = getMessageDestinationGraph();
91
        if (server == null) {
92
            return Collections.<MessageDestination>emptySet();
93
        }
94
        
95
        HashSet<MessageDestination> destinations = new HashSet<MessageDestination>();
96
        
97
        for (Mbean mbean : destinationServiceModel.getMbean()) {
98
            String mbeanNameAttribute = mbean.getName();
99
            if (mbeanNameAttribute == null) {
100
                continue;
101
            }
102
            
103
            MessageDestination.Type type = null;
104
            if (mbeanNameAttribute.indexOf("service=Queue") > -1) { // NOI18N
105
                type = MessageDestination.Type.QUEUE;
106
            }
107
            else
108
            if (mbeanNameAttribute.indexOf("service=Topic") > -1) { // NOI18N
109
                type = MessageDestination.Type.TOPIC;
110
            }
111
            if (type == null) {
112
                continue;
113
            }
114
            
115
            int nameIndex = mbeanNameAttribute.indexOf("name="); // NOI18N
116
            if (nameIndex == -1) {
117
                continue;
118
            }
119
            
120
            String name = mbeanNameAttribute.substring(nameIndex + 5); // "name=".length() == 5
121
            if (name.indexOf(",") > -1) {
122
                name = name.substring(0, name.indexOf(",")); // NOI18N
123
            }
124
                
125
            destinations.add(new JBossMessageDestination(name, type));
126
        }
127
        
128
        return destinations;
129
    }
130
131
    public MessageDestination createMessageDestination(String jndiName, MessageDestination.Type type) 
132
    throws UnsupportedOperationException, ConfigurationException {
133
        return new JBossMessageDestination(jndiName, type);
134
    }
135
    
136
    /**
137
     * Return destination service graph. If it was not created yet, load it from the file
138
     * and cache it. If the file does not exist, generate it.
139
     *
140
     * @return Destination service graph or null if the netbeans-destinations-service.xml file is not parseable.
141
     */
142
    private synchronized Server getMessageDestinationGraph() {
143
        
144
        try {
145
            if (destinationsFile.exists()) {
146
                // load configuration if already exists
147
                try {
148
                    if (destinationServiceModel == null)
149
                        destinationServiceModel = Server.createGraph(destinationsFile);
150
                } catch (IOException ioe) {
151
                    ErrorManager.getDefault().notify(ioe);
152
                } catch (RuntimeException re) {
153
                    // netbeans-destinations-service.xml is not parseable, do nothing
154
                }
155
            } else {
156
                // create netbeans-destinations-service.xml if it does not exist yet
157
                destinationServiceModel = new Server();
158
                JBDeploymentConfiguration.writeFile(destinationsFile, destinationServiceModel);
159
                ensureDestinationsFOExists();
160
            }
161
        } catch (ConfigurationException ce) {
162
            ErrorManager.getDefault().notify(ce);
163
        }
164
165
        return destinationServiceModel;
166
    }
167
    
168
}
(-)src/org/netbeans/modules/j2ee/jboss4/ide/JBOptionalDeploymentManagerFactory.java (-1 / +12 lines)
Lines 13-23 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
package org.netbeans.modules.j2ee.jboss4.ide;
19
package org.netbeans.modules.j2ee.jboss4.ide;
20
20
21
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
21
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
22
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
22
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager;
23
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager;
23
import org.netbeans.modules.j2ee.jboss4.config.JBossDatasourceManager;
24
import org.netbeans.modules.j2ee.jboss4.config.JBossDatasourceManager;
Lines 27-32 Link Here
27
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
28
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
28
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
29
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
29
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
30
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
31
import org.netbeans.modules.j2ee.jboss4.config.mdb.JBossMessageDestinationDeployment;
30
import org.openide.WizardDescriptor.InstantiatingIterator;
32
import org.openide.WizardDescriptor.InstantiatingIterator;
31
33
32
/**
34
/**
Lines 61-65 Link Here
61
        
63
        
62
        return dsMgr;
64
        return dsMgr;
63
    }
65
    }
66
67
    public MessageDestinationDeployment getMessageDestinationDeployment(DeploymentManager dm) {
68
        if (!(dm instanceof JBDeploymentManager)) {
69
            throw new IllegalArgumentException("");
70
        }
71
72
        return new JBossMessageDestinationDeployment(((JBDeploymentManager)dm).getUrl());
73
    }
74
    
64
    
75
    
65
}
76
}
(-)src/org/netbeans/modules/j2ee/jboss4/resources/jboss-service_4_0.dtd (+287 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8' ?>
2
3
<!-- A skeleton JBoss MBean service descriptor DTD. This cannot be used in
4
general to validate a jboss-service.xml descriptor due to the fact that the
5
'attribute' element allows ANY content.
6
7
$Id: jboss-service_4_0.dtd,v 1.1.2.1 2007/03/26 09:55:00 lkotouc Exp $
8
9
DOCTYPE server
10
    PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
11
    "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd"
12
-->
13
<!-- The server element is the root element.
14
-->
15
<!ELEMENT server (loader-repository? , local-directory* , classpath* , mbean*)>
16
17
<!-- The loader-repository specifies the name of the UnifiedLoaderRepository
18
   MBean to use for the ear to provide ear level scoping of classes deployed
19
   in the ear. It is a unique JMX ObjectName string. It may also specify
20
   an arbitrary configuration by including a loader-repository-config element.
21
22
Examples:
23
   <loader-repository>jboss.test:loader=cts-cmp2v1-sar.ear</loader-repository>
24
25
   <loader-repository loaderRepositoryClass='dot.com.LoaderRepository'>
26
      dot.com:loader=unique-archive-name
27
      <loader-repository-config configParserClass='dot.com.LoaderParser'>
28
         java2ParentDelegaton=true
29
      </loader-repository-config>
30
   </loader-repository>
31
-->
32
<!ELEMENT loader-repository (#PCDATA | loader-repository-config)*>
33
34
<!-- The loaderRepositoryClass attribute gives the classname of the
35
org.jboss.mx.loading.LoaderRepository implementation.
36
-->
37
<!ATTLIST loader-repository loaderRepositoryClass CDATA  #IMPLIED>
38
39
<!-- The loader-repository-config element specifies any arbitrary configuration
40
fragment for use in configuring the loader-repository instance. The actual
41
content of this element is specific to the loaderRepositoryClass and the
42
code parsing the element.
43
-->
44
<!ELEMENT loader-repository-config (#PCDATA)>
45
46
<!-- The configParserClass attribute gives the classname of the
47
org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfigParser
48
implementation to use to parse the loader-repository-config content.
49
-->
50
<!ATTLIST loader-repository-config configParserClass CDATA  #IMPLIED>
51
52
<!-- A local-directory element specifies that portions of the sar are to be unjard into the data
53
directory of the server configuration.
54
-->
55
<!ELEMENT local-directory EMPTY>
56
57
<!-- The optional path attribute gives the prefix of the sar entries that should be copied
58
into the data directory. If it is not specified the entire sar contents will be placed into
59
the data directory.
60
-->
61
<!ATTLIST local-directory path CDATA  #IMPLIED>
62
63
<!-- A classpath element specifies a location which will be included in the services
64
deployment classpath.
65
-->
66
<!ELEMENT classpath EMPTY>
67
68
<!-- The codebase attribute specifies the base URL from which the jars or classes
69
are loaded from. If the codebase is '.' then it is equal to the mbean deployment URL.
70
Otherwise, it is resolved as a path spec relative to the serverHomeURL (e.g., file:/jboss-3.2.0)
71
using the URL ctor URL(serverHomeURL, codebase)
72
73
Examples:
74
75
   <classpath codebase='.' archives='util.jar' />
76
   <classpath codebase='http://classloader.dot.com' archives='*' />
77
   <classpath codebase="lib" archives="*"/>
78
-->
79
<!ATTLIST classpath codebase CDATA  #REQUIRED>
80
81
<!-- The archives attribute specifies either the '*' wildcard to indicate all contents of the
82
codebase should be included, or a comma seperated list of the jars to include.
83
-->
84
<!ATTLIST classpath archives CDATA  #IMPLIED>
85
86
<!-- The mbean element defines a JBoss MBean service. This includes the
87
mbean class, attributes and dependencies.
88
-->
89
<!ELEMENT mbean (constructor? , xmbean? , attribute* , depends* , depends-list*)>
90
91
<!-- The code attributes gives the fully qualified name of the MBean
92
implementation class.
93
-->
94
<!ATTLIST mbean code      CDATA  #REQUIRED>
95
96
<!-- The name attribute gives the JMX ObjectName string to use when registering
97
the MBean. This must be a unique and valid JMX name.
98
-->
99
<!ATTLIST mbean name      CDATA  #REQUIRED>
100
101
<!-- The optional interface attribute gives the full qualified name of the class
102
uses to construct the management interface of the mbean. In absence of it an interface
103
with the name ending by MBean will be looked in the implementation class. When used
104
this interface is defined explicitely.
105
-->
106
<!ATTLIST mbean interface CDATA  #IMPLIED>
107
108
<!-- The xmbean-dd attribute defines the path to the JBoss XMBean descriptor. This
109
is an xml document conforming to:
110
111
<!DOCTYPE mbean PUBLIC
112
      "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
113
      "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
114
115
If the descriptor is embedded via a nested xmbean element, the xmbean-dd attribute
116
must be given as an empty string.
117
118
Example:
119
	<mbean code="org.jboss.test.jmx.xmbean.User"
120
		name="jboss.test:service=xmbean-user"
121
		xmbean-dd="META-INF/org/jboss/test/jmx/xmbean/User.xml" />
122
-->
123
<!ATTLIST mbean xmbean-dd CDATA  #IMPLIED>
124
125
<!-- The optional xmbean-code attribute specifies the ModelMBean implementation class
126
to use. This defaults to org.jboss.mx.modelmbean.XMBean.
127
-->
128
<!ATTLIST mbean xmbean-code CDATA  #IMPLIED>
129
130
<!-- The xmbean element specifies a nested JBoss XMBean descriptor fragment. Its
131
supported content model is the same as the mbean element of the jboss_xmbean_1_0.dtd
132
133
Example:
134
	<mbean code="org.jboss.test.jmx.xmbean.User"
135
		name="jboss.test:service=xmbean-user"
136
		xmbean-dd="">
137
		<xmbean>
138
			...
139
		</xmbean>
140
	</mbean>
141
-->
142
<!ELEMENT xmbean ANY>
143
144
<!-- The constructor element defines a non-default constructor to use when
145
instantiating the mbean.
146
-->
147
<!ELEMENT constructor (arg*)>
148
149
<!-- The arg element specify the constructor arguments in the order of the
150
ctor signature. Each arg has a type and value attribute.
151
-->
152
<!ELEMENT arg EMPTY>
153
154
<!-- The type attribute gives the type of the argument as defined in the
155
ctor signature. If not defined java.lang.String is assumed.
156
-->
157
<!ATTLIST arg type  CDATA  #IMPLIED>
158
159
<!-- The value attribute provides the string representation of the ctor
160
argument. It is converted from a string to type using Java PropertyEditor or a
161
ctor taking a single string as its argument.
162
-->
163
<!ATTLIST arg value CDATA  #REQUIRED>
164
165
<!-- The attribute element specifies the initial value for a management attribute of
166
the enclosing mbean. Typically the value of the attribute element is the string
167
representation of the attribute, but it can be an arbitrary xml fragment that is
168
parsed by the mbean.
169
-->
170
<!ELEMENT attribute ANY>
171
172
<!-- The required name attribute gives the name of the attribute. This is the
173
name exposed by the mbean to the MBeanServer for the attribute.
174
-->
175
<!ATTLIST attribute name CDATA  #REQUIRED>
176
177
<!-- The optional replace attribute indicates whether references of the form ${x}
178
in the attribute element content should be replaced with the corresponding
179
System.getProperty(x) value.
180
-->
181
<!ATTLIST attribute replace (true | false) 'true'>
182
<!-- The optional trim attribute specifies whether the attribute element content should
183
be trimmed of whitespace.
184
-->
185
<!ATTLIST attribute trim (true | false) 'true'>
186
187
<!-- The attributeClass attribute specifies that type of object that
188
should be created. This is needed for non-concreate attribute types
189
like interfaces and abstract classes.
190
-->
191
<!ATTLIST attribute attributeClass CDATA  #IMPLIED>
192
193
<!-- The serialDataType defines the how the content of the attribute
194
element is interpretted by the ServiceConfigurator. The possible values
195
are:
196
   + text: the content is treated as the string representation of the
197
   attribute value. It will be mapped to the attribute using the PropertyEditor
198
   registered for the attribute type.
199
   + javaBean: the content is a collection of property elements.
200
   + jbxb: the content is an xml element from a namespace with an associated
201
      xml schema that can be unmarshalled using the JBossXB framework.
202
-->
203
<!ATTLIST attribute serialDataType (text | javaBean | jbxb) 'text'>
204
205
<!-- The property element is used to describe the JavaBean properties of
206
an attribute when the attribute element serialDataType is javaBean.
207
-->
208
<!ELEMENT property (#PCDATA)>
209
<!-- The required name attribute gives the name of the property. This is the
210
name of a JavaBean property for the attribute type.
211
-->
212
<!ATTLIST property name CDATA #REQUIRED>
213
214
<!-- The depends element specifies a JMX ObjectName string for an mbean
215
on which the enclosing mbean depends.
216
217
Example:
218
   <mbean code="myBean" name="domain:name=x">
219
      <depends optional-attribute-name="yName">domain:name=y</depends>
220
   </mbean>
221
222
   <mbean code="myBean" name="domain:name=x">
223
      <depends optional-attribute-name="anonName">
224
         <mbean code="nestedBean" name="domain:name=x.y">
225
         ...
226
         </mbean>
227
      </depends>
228
   </mbean>
229
-->
230
<!ELEMENT depends (#PCDATA | mbean)*>
231
232
<!-- The optional-attribute-name attribute specifies the attribute name
233
which should be populated with the JMX ObjectName of the depends element.
234
This allows an mbean to have access to the name of the mbean on which
235
it depends.
236
-->
237
<!ATTLIST depends optional-attribute-name CDATA  #IMPLIED>
238
239
<!-- The proxy-type attribute specifies the interface name
240
that should be exposed on an MBeanProxy pointing at the dependent
241
MBean, specified by the JMX ObjectName.
242
243
The special value proxy-type="attribute" will use the
244
class declared in the MBeanAttributeInfo as the interface
245
for the MBeanProxy.
246
247
Example:
248
   <mbean code="org.jboss.example.Helper" name="domain:name=helper"/>
249
250
   <mbean code="myBean" name="domain:name=x">
251
      <depends optional-attribute-name="Helper"
252
               proxy-type="org.jboss.example.HelperMBean"
253
      >domain:name=helper</depends>
254
   </mbean>
255
256
   <mbean code="myBean" name="domain:name=x">
257
      <depends optional-attribute-name="Helper"
258
               proxy-type="attribute"
259
      >domain:name=helper</depends>
260
   </mbean>
261
-->
262
<!ATTLIST depends proxy-type CDATA  #IMPLIED>
263
264
<!-- The depends-list element specifies a series of JMX ObjectName
265
strings of mbeans on which the enclosing mbean depends.
266
267
Example:
268
   <mbean code="myBean" name="domain:name=x">
269
      <depends-list optional-attribute-name="myObjectNameList">
270
         <depends-list-element>domain:name=y</depends-list-element>
271
         <depends-list-element>domain:name=z</depends-list-element>
272
      </depends-list>
273
   </mbean>
274
-->
275
<!ELEMENT depends-list (depends-list-element)+>
276
277
<!-- The optional-attribute-name attribute specifies the attribute name
278
which should be populated with a java.util.List that contains the JMX
279
ObjectName(s) of the depends-list elements. This allows an mbean to have
280
access to the names of the mbeans on which it depends.
281
-->
282
<!ATTLIST depends-list optional-attribute-name CDATA  #IMPLIED>
283
284
<!-- The depends-list-element element specifies a JMX ObjectName string
285
for an mbean on which the enclosing mbean depends.
286
-->
287
<!ELEMENT depends-list-element (#PCDATA | mbean)*>

Return to bug 93815