diff --git a/j2ee.api.ejbmodule/nbproject/project.xml b/j2ee.api.ejbmodule/nbproject/project.xml --- a/j2ee.api.ejbmodule/nbproject/project.xml +++ b/j2ee.api.ejbmodule/nbproject/project.xml @@ -207,6 +207,7 @@ org.netbeans.modules.maven.jaxws org.netbeans.modules.profiler.j2ee org.netbeans.modules.web.project + org.netbeans.modules.web.beans org.netbeans.modules.websvc.core org.netbeans.modules.websvc.dev org.netbeans.modules.websvc.jaxrpc diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectCreateData.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectCreateData.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectCreateData.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectCreateData.java @@ -70,6 +70,8 @@ private File libFolder; + private boolean cdiEnabled; + public AppClientProjectCreateData() { } @@ -161,4 +163,12 @@ this.testFolders = testFolders; } + public boolean isCDIEnabled() { + return cdiEnabled; + } + + public void setCDIEnabled(boolean cdiEnabled) { + this.cdiEnabled = cdiEnabled; + } + } diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java @@ -70,6 +70,7 @@ import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; import org.netbeans.api.j2ee.core.Profile; import org.netbeans.modules.j2ee.common.Util; +import org.netbeans.modules.j2ee.common.dd.DDHelper; import org.netbeans.modules.java.api.common.ant.UpdateHelper; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.ui.PlatformUiSupport; @@ -191,6 +192,9 @@ AppClient appClient = DDProvider.getDefault().getDDRoot(ddFile); appClient.setDisplayName(name); appClient.write(ddFile); + if (createData.isCDIEnabled()) { + DDHelper.createBeansXml(j2eeProfile, confRoot); + } final String realServerLibraryName = configureServerLibrary(createData.getLibrariesDefinition(), serverInstanceID, projectDir, createData.getServerLibraryName() != null); diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/wizards/NewAppClientProjectWizardIterator.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/wizards/NewAppClientProjectWizardIterator.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/wizards/NewAppClientProjectWizardIterator.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/wizards/NewAppClientProjectWizardIterator.java @@ -129,6 +129,7 @@ createData.setLibrariesDefinition( SharabilityUtility.getLibraryLocation((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SHARED_LIBRARIES))); createData.setServerLibraryName((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SERVER_LIBRARY)); + createData.setCDIEnabled((Boolean)wiz.getProperty(ProjectServerWizardPanel.CDI)); AntProjectHelper h = AppClientProjectGenerator.createProject(createData); diff --git a/j2ee.common/apichanges.xml b/j2ee.common/apichanges.xml --- a/j2ee.common/apichanges.xml +++ b/j2ee.common/apichanges.xml @@ -103,6 +103,21 @@ + + + Helper method DDHelper.createBeansXml was added. + + + + + +

+ Helper method DDHelper.createBeansXml was added. +

+
+ +
+ Migrate all Java related code to java.api.common module. diff --git a/j2ee.common/nbproject/project.xml b/j2ee.common/nbproject/project.xml --- a/j2ee.common/nbproject/project.xml +++ b/j2ee.common/nbproject/project.xml @@ -423,6 +423,7 @@ org.netbeans.modules.web.jsf org.netbeans.modules.web.project org.netbeans.modules.web.struts + org.netbeans.modules.web.beans org.netbeans.modules.websvc.core org.netbeans.modules.websvc.jaxrpc org.netbeans.modules.websvc.restapi diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/dd/resources/beans-1.0.xml b/j2ee.common/src/org/netbeans/modules/j2ee/common/dd/resources/beans-1.0.xml new file mode 100644 --- /dev/null +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/dd/resources/beans-1.0.xml @@ -0,0 +1,5 @@ + + + diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/Bundle.properties b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/Bundle.properties --- a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/Bundle.properties +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/Bundle.properties @@ -61,6 +61,7 @@ PanelSharabilityVisual.librariesLabel.text=&Sharable Libraries Location: PanelSharabilityVisual.sharableCheckBox.text=Check Whether This Project Should be Sharable. PanelSharabilityVisual.serverLibraryCheckbox.text=&Use dedicated library folder for server JAR files +PanelSharabilityVisual.cdiCheckbox.text=&Enable Context and Dependency Injection # ProjectLocationPanel LBL_NWP1_ProjectTitleName=Name and Location diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.form b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.form --- a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.form +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.form @@ -24,40 +24,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -70,19 +39,51 @@ - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -106,14 +107,16 @@ - + + + - + @@ -138,7 +141,7 @@ - + @@ -454,5 +457,18 @@ + + + + + + + + + + + + + diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.java b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.java --- a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.java +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerPanel.java @@ -169,6 +169,7 @@ mainClassLabel1 = new javax.swing.JLabel(); mainClassTextFieldWithinEar = new javax.swing.JTextField(); serverLibraryCheckbox = new javax.swing.JCheckBox(); + cdiCheckbox = new javax.swing.JCheckBox(); jLabelEnterprise.setLabelFor(jComboBoxEnterprise); org.openide.awt.Mnemonics.setLocalizedText(jLabelEnterprise, NbBundle.getMessage(ProjectServerPanel.class, "LBL_NWP1_AddToEnterprise_Label")); // NOI18N @@ -256,36 +257,16 @@ } }); + cdiCheckbox.setSelected(true); + org.openide.awt.Mnemonics.setLocalizedText(cdiCheckbox, org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "PanelSharabilityVisual.cdiCheckbox.text")); // NOI18N + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jLabelContextPath) - .add(serverInstanceLabel) - .add(j2eeSpecLabel)) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(mainClassTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE) - .add(74, 74, 74)) - .add(layout.createSequentialGroup() - .add(jTextFieldContextPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE) - .add(74, 74, 74)) - .add(layout.createSequentialGroup() - .add(serverInstanceComboBox, 0, 350, Short.MAX_VALUE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(addServerButton)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(serverLibraryCheckbox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE) - .add(74, 74, 74)) - .add(layout.createSequentialGroup() - .add(j2eeSpecComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap()))) - .add(layout.createSequentialGroup() .add(mainClassLabel) - .addContainerGap(463, Short.MAX_VALUE)) + .addContainerGap(495, Short.MAX_VALUE)) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) @@ -295,16 +276,40 @@ .add(mainClassLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jTextFieldEjbModuleName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE) - .add(jTextFieldWebAppName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE) - .add(jTextFieldCarName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE) - .add(mainClassTextFieldWithinEar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)) + .add(jTextFieldEjbModuleName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE) + .add(jTextFieldWebAppName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE) + .add(jTextFieldCarName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE) + .add(mainClassTextFieldWithinEar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)) .add(74, 74, 74)) - .add(warningPlaceHolderPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE) + .add(warningPlaceHolderPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(jLabelEnterprise) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(jComboBoxEnterprise, 0, 342, Short.MAX_VALUE)) + .add(jComboBoxEnterprise, 0, 366, Short.MAX_VALUE)) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLabelContextPath) + .add(serverInstanceLabel) + .add(j2eeSpecLabel)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(cdiCheckbox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE) + .addContainerGap()) + .add(layout.createSequentialGroup() + .add(mainClassTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE) + .add(74, 74, 74)) + .add(layout.createSequentialGroup() + .add(jTextFieldContextPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE) + .add(74, 74, 74)) + .add(layout.createSequentialGroup() + .add(serverInstanceComboBox, 0, 398, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(addServerButton)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(serverLibraryCheckbox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE) + .add(74, 74, 74)) + .add(j2eeSpecComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) @@ -325,6 +330,8 @@ .add(j2eeSpecLabel) .add(j2eeSpecComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(cdiCheckbox) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(warningPlaceHolderPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) @@ -350,7 +357,7 @@ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(mainClassLabel1) .add(mainClassTextFieldWithinEar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(67, 67, 67)) + .add(174, 174, 174)) ); jLabelEnterprise.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N @@ -379,6 +386,7 @@ mainClassLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N mainClassTextFieldWithinEar.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N serverLibraryCheckbox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N + cdiCheckbox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectServerPanel.class, "ACSD_ProjectServerPanel_NA")); // NOI18N @@ -572,6 +580,7 @@ d.putProperty(ProjectServerWizardPanel.CREATE_WAR, Boolean.valueOf(createWARCheckBox.isVisible() ? createWARCheckBox.isSelected() : false)); d.putProperty(ProjectServerWizardPanel.CREATE_JAR, Boolean.valueOf(createEjbCheckBox.isVisible() ? createEjbCheckBox.isSelected() : false)); d.putProperty(ProjectServerWizardPanel.CREATE_CAR, Boolean.valueOf(createCarCheckBox.isVisible() ? createCarCheckBox.isSelected() : false)); + d.putProperty(ProjectServerWizardPanel.CDI, Boolean.valueOf(cdiCheckbox.isVisible() ? cdiCheckbox.isSelected() : false)); // #119052 String sourceLevel = "1.5"; // NOI18N @@ -642,6 +651,7 @@ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addServerButton; + private javax.swing.JCheckBox cdiCheckbox; private javax.swing.JCheckBox createCarCheckBox; private javax.swing.JCheckBox createEjbCheckBox; private javax.swing.JCheckBox createWARCheckBox; @@ -769,8 +779,10 @@ Profile j2ee = getSelectedJ2eeProfile(); if (j2ee == null) { warningPlaceHolderPanel.setVisible(false); + cdiCheckbox.setVisible(false); return; } + cdiCheckbox.setVisible(j2ee.equals(Profile.JAVA_EE_6_FULL) || j2ee.equals(Profile.JAVA_EE_6_WEB)); String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); if (warningType == null && warningPanel == null) { warningPlaceHolderPanel.setVisible(false); diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerWizardPanel.java b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerWizardPanel.java --- a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerWizardPanel.java +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/ProjectServerWizardPanel.java @@ -70,6 +70,7 @@ public static final String CREATE_WAR = "createWAR"; // NOI18N public static final String CREATE_JAR = "createJAR"; // NOI18N public static final String CREATE_CAR = "createCAR"; // NOI18N + public static final String CDI = "cdi"; // NOI18N private WizardDescriptor wizardDescriptor; private ProjectServerPanel component; diff --git a/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/Bundle.properties b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/Bundle.properties --- a/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/Bundle.properties +++ b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/Bundle.properties @@ -39,4 +39,4 @@ LBL_EnterpriseCatalog=Enterprise Deployment Descriptors Catalog -DESC_EnterpriseCatalog=XML Catalog for web, ejb-jar, application and application-client XML schema files. +DESC_EnterpriseCatalog=XML Catalog for web, ejb-jar, cdi, application and application-client XML schema files. diff --git a/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/EnterpriseCatalog.java b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/EnterpriseCatalog.java --- a/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/EnterpriseCatalog.java +++ b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/EnterpriseCatalog.java @@ -108,6 +108,8 @@ // web 2.2 and 2.3 dtds schemas.add(new SchemaInfo("web-app_2_2.dtd", "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", true)); //NO18N schemas.add(new SchemaInfo("web-app_2_3.dtd", "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", true)); //NO18N + // cdi + schemas.add(new SchemaInfo("beans_1_0.xsd", JAVAEE_NS)); } diff --git a/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/resources/beans_1_0.xsd b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/resources/beans_1_0.xsd new file mode 100644 --- /dev/null +++ b/j2ee.ddloaders/src/org/netbeans/modules/j2ee/ddloaders/catalog/resources/beans_1_0.xsd @@ -0,0 +1,180 @@ + + + + + + + + + Contexts and Dependency Injection (CDI) defines + a set of complementary services that help improve the structure + of application code. beans.xml is used to enable CDI services + for the current bean archive as well as to enable named + interceptors, decorators and alternatives for the current bean + archive. + + + + + + + Bean classes of enabled beans must be + deployed in bean archives. A library jar, EJB jar, + application client jar or rar archive is a bean archive if + it has a file named beans.xml in the META-INF directory. The + WEB-INF/classes directory of a war is a bean archive if + there is a file named beans.xml in the WEB-INF directory of + the war. A directory in the JVM classpath is a bean archive + if it has a file named beans.xml in the META-INF directory. + + + + + + + + + + + + + + + By default, a bean archive has no enabled + interceptors bound via interceptor bindings. An interceptor + must be explicitly enabled by listing its class under the + <interceptors> element of the beans.xml file of the + bean archive. The order of the interceptor declarations + determines the interceptor ordering. Interceptors which + occur earlier in the list are called first. If the same + class is listed twice under the <interceptors> + element, the container automatically detects the problem and + treats it as a deployment problem. + + + + + + + + Each child <class> element + must specify the name of an interceptor class. If + there is no class with the specified name, or if + the class with the specified name is not an + interceptor class, the container automatically + detects the problem and treats it as a deployment + problem. + + + + + + + + + + + By default, a bean archive has no enabled + decorators. A decorator must be explicitly enabled by + listing its bean class under the <decorators> element + of the beans.xml file of the bean archive. The order of the + decorator declarations determines the decorator ordering. + Decorators which occur earlier in the list are called first. + If the same class is listed twice under the + <decorators> element, the container automatically + detects the problem and treats it as a deployment problem. + + + + + + + + Each child <class> element + must specify the name of a decorator class. If + there is no class with the specified name, or if + the class with the specified name is not a + decorator class, the container automatically + detects the problem and treats it as a deployment + problem. + + + + + + + + + + + An alternative is a bean that must be + explicitly declared in the beans.xml file if it should be + available for lookup, injection or EL resolution. By + default, a bean archive has no selected alternatives. An + alternative must be explicitly declared using the + <alternatives> element of the beans.xml file of the + bean archive. The <alternatives> element contains a + list of bean classes and stereotypes. An alternative is + selected for the bean archive if either: the alternative is + a managed bean or session bean and the bean class of the + bean is listed, or the alternative is a producer method, + field or resource, and the bean class that declares the + method or field is listed, or any @Alternative stereotype of + the alternative is listed. + + + + + + + + Each child <class> element + must specify the name of an alternative bean class. + If there is no class with the specified name, or if + the class with the specified name is not an + alternative bean class, the container automatically + detects the problem and treats it as a deployment + problem. If the same class is listed twice under + the <alternatives> element, the container + automatically detects the problem and treats it as + a deployment problem. + + + + + + + + Each child <stereotype> + element must specify the name of an @Alternative + stereotype annotation. If there is no annotation + with the specified name, or the annotation is not + an @Alternative stereotype, the container + automatically detects the problem and treats it as + a deployment problem. If the same stereotype is + listed twice under the <alternatives> + element, the container automatically detects the + problem and treats it as a deployment problem. + + + + + + + + diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/ui/wizards/NewEarProjectWizardIterator.java b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/ui/wizards/NewEarProjectWizardIterator.java --- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/ui/wizards/NewEarProjectWizardIterator.java +++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/ui/wizards/NewEarProjectWizardIterator.java @@ -151,6 +151,7 @@ } String platformName = (String)wiz.getProperty(ProjectServerWizardPanel.JAVA_PLATFORM); String sourceLevel = (String)wiz.getProperty(ProjectServerWizardPanel.SOURCE_LEVEL); + Boolean cdi = (Boolean)wiz.getProperty(ProjectServerWizardPanel.CDI); // remember last used server UserProjectSettings.getDefault().setLastUsedServer(serverInstanceID); @@ -160,14 +161,14 @@ String serverLibraryName = (String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SERVER_LIBRARY); return testableInstantiate(dirF,name,j2eeLevel, serverInstanceID, warName, ejbJarName, carName, mainClass, platformName, sourceLevel, handle, - librariesDefinition, serverLibraryName); + librariesDefinition, serverLibraryName, cdi); } /** Package private for unit test only. */ static Set testableInstantiate(File dirF, String name, Profile j2eeProfile, String serverInstanceID, String warName, String ejbJarName, String carName, String mainClass, String platformName, String sourceLevel, ProgressHandle handle, - String librariesDefinition, String serverLibraryName) throws IOException { + String librariesDefinition, String serverLibraryName, Boolean cdi) throws IOException { Set resultSet = new LinkedHashSet(); AntProjectHelper h = EarProjectGenerator.createProject(dirF, name, j2eeProfile, serverInstanceID, sourceLevel, librariesDefinition, serverLibraryName); @@ -215,6 +216,7 @@ createData.setSourceLevel(sourceLevel); createData.setLibrariesDefinition(librariesDefinition); createData.setServerLibraryName(serverLibraryName); + createData.setCDIEnabled(cdi); if (handle != null) handle.progress(NbBundle.getMessage(NewEarProjectWizardIterator.class, "LBL_NewEarProjectWizardIterator_WizardProgress_WAR"), 3); @@ -242,6 +244,7 @@ createData.setServerInstanceID(serverInstanceID); createData.setLibrariesDefinition(librariesDefinition); createData.setServerLibraryName(serverLibraryName); + createData.setCDIEnabled(cdi); if (handle != null) handle.progress(NbBundle.getMessage(NewEarProjectWizardIterator.class, "LBL_NewEarProjectWizardIterator_WizardProgress_AppClient"), 5); @@ -268,6 +271,7 @@ createData.setServerInstanceID(serverInstanceID); createData.setLibrariesDefinition(librariesDefinition); createData.setServerLibraryName(serverLibraryName); + createData.setCDIEnabled(cdi); if (handle != null) handle.progress(NbBundle.getMessage(NewEarProjectWizardIterator.class, "LBL_NewEarProjectWizardIterator_WizardProgress_EJB"), 7); diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectCreateData.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectCreateData.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectCreateData.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectCreateData.java @@ -68,6 +68,8 @@ private File libFolder; + private boolean cdiEnabled; + public EjbJarProjectCreateData() { } @@ -151,4 +153,12 @@ this.testFolders = testFolders; } + public boolean isCDIEnabled() { + return cdiEnabled; + } + + public void setCDIEnabled(boolean cdiEnabled) { + this.cdiEnabled = cdiEnabled; + } + } diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java @@ -71,6 +71,7 @@ import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; import org.netbeans.api.j2ee.core.Profile; import org.netbeans.modules.j2ee.common.Util; +import org.netbeans.modules.j2ee.common.dd.DDHelper; import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject; import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType; import org.netbeans.modules.j2ee.ejbjarproject.Utils; @@ -210,6 +211,9 @@ ejbJar.setDisplayName(name); ejbJar.write(ddFile); } + if (createData.isCDIEnabled()) { + DDHelper.createBeansXml(profile, confRoot); + } return h; } diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/NewEjbJarProjectWizardIterator.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/NewEjbJarProjectWizardIterator.java --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/NewEjbJarProjectWizardIterator.java +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/NewEjbJarProjectWizardIterator.java @@ -124,6 +124,7 @@ createData.setLibrariesDefinition( SharabilityUtility.getLibraryLocation((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SHARED_LIBRARIES))); createData.setServerLibraryName((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SERVER_LIBRARY)); + createData.setCDIEnabled((Boolean)wiz.getProperty(ProjectServerWizardPanel.CDI)); AntProjectHelper h = EjbJarProjectGenerator.createProject(createData); diff --git a/web.beans/src/org/netbeans/modules/web/beans/resources/Bundle.properties b/web.beans/src/org/netbeans/modules/web/beans/resources/Bundle.properties --- a/web.beans/src/org/netbeans/modules/web/beans/resources/Bundle.properties +++ b/web.beans/src/org/netbeans/modules/web/beans/resources/Bundle.properties @@ -2,6 +2,9 @@ Templates/CDI=Context and Dependency Injection Templates/CDI/beans.xml=beans.xml (CDI Configuration File) + +Templates/CDI=Context and Dependency Injection +Templates/CDI/beans.xml=beans.xml (CDI Configuration File) Templates/CDI/Interceptor.java=Interceptor Binding Type Templates/CDI/Qualifier.java=Qualifier Type Templates/CDI/Scope.java=Scope Type diff --git a/web.project/src/org/netbeans/modules/web/project/api/WebProjectCreateData.java b/web.project/src/org/netbeans/modules/web/project/api/WebProjectCreateData.java --- a/web.project/src/org/netbeans/modules/web/project/api/WebProjectCreateData.java +++ b/web.project/src/org/netbeans/modules/web/project/api/WebProjectCreateData.java @@ -81,6 +81,8 @@ private String librariesDefinition; private boolean webXmlRequired; + + private boolean cdiEnabled; /** * Creates a new instance of WebProjectCreateData @@ -413,4 +415,12 @@ this.webXmlRequired = webXmlRequired; } + public boolean isCDIEnabled() { + return cdiEnabled; + } + + public void setCDIEnabled(boolean cdiEnabled) { + this.cdiEnabled = cdiEnabled; + } + } diff --git a/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java b/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java --- a/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java +++ b/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java @@ -249,6 +249,9 @@ final FileObject webInfFO = webFO.createFolder(WEB_INF); DDHelper.createWebXml(j2eeProfile, createData.isWebXmlRequired(), webInfFO); + if (createData.isCDIEnabled()) { + DDHelper.createBeansXml(j2eeProfile, webInfFO); + } EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); Element data = h.getPrimaryConfigurationData(true); diff --git a/web.project/src/org/netbeans/modules/web/project/ui/wizards/NewWebProjectWizardIterator.java b/web.project/src/org/netbeans/modules/web/project/ui/wizards/NewWebProjectWizardIterator.java --- a/web.project/src/org/netbeans/modules/web/project/ui/wizards/NewWebProjectWizardIterator.java +++ b/web.project/src/org/netbeans/modules/web/project/ui/wizards/NewWebProjectWizardIterator.java @@ -148,6 +148,7 @@ SharabilityUtility.getLibraryLocation((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SHARED_LIBRARIES))); createData.setServerLibraryName((String) wiz.getProperty(ProjectServerWizardPanel.WIZARD_SERVER_LIBRARY)); createData.setWebXmlRequired(checkFrameworksForWebXml()); + createData.setCDIEnabled((Boolean)wiz.getProperty(ProjectServerWizardPanel.CDI)); AntProjectHelper h = WebProjectUtilities.createProject(createData); handle.progress(2);