1.1 --- a/visualweb.ejb/nbproject/project.xml Thu Jun 07 20:30:32 2007 +0000
1.2 +++ b/visualweb.ejb/nbproject/project.xml Thu Jun 07 22:14:17 2007 +0000
1.3 @@ -176,6 +176,14 @@
1.4 <specification-version>6.5</specification-version>
1.5 </run-dependency>
1.6 </dependency>
1.7 + <dependency>
1.8 + <code-name-base>org.netbeans.modules.j2ee.sun.dd</code-name-base>
1.9 + <build-prerequisite/>
1.10 + <compile-dependency/>
1.11 + <run-dependency>
1.12 + <release-version>1</release-version>
1.13 + </run-dependency>
1.14 + </dependency>
1.15 </module-dependencies>
1.16 <public-packages/>
1.17 <!--
2.1 --- a/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/Bundle.properties Thu Jun 07 20:30:32 2007 +0000
2.2 +++ b/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/Bundle.properties Thu Jun 07 22:14:17 2007 +0000
2.3 @@ -21,3 +21,6 @@
2.4 SUN_APP_SERVER_7=Sun Application Server 7
2.5
2.6 SUN_APP_SERVER_8_1=Sun Java System Application Server 8.1
2.7 +
2.8 +SUN_APP_SERVER_9=Sun Java System Application Server 9
2.9 +SUN_APP_SERVER_9_1=Sun Java System Application Server 9.1
3.1 --- a/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/EjbContainerVendor.java Thu Jun 07 20:30:32 2007 +0000
3.2 +++ b/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/EjbContainerVendor.java Thu Jun 07 22:14:17 2007 +0000
3.3 @@ -16,6 +16,11 @@
3.4 public class EjbContainerVendor
3.5 {
3.6 // Supported application servers
3.7 + public static final String SUN_APP_SERVER_9_1 = NbBundle.getMessage(EjbContainerVendor.class,
3.8 + "SUN_APP_SERVER_9_1");
3.9 +
3.10 + public static final String SUN_APP_SERVER_9 = NbBundle.getMessage(EjbContainerVendor.class,
3.11 + "SUN_APP_SERVER_9");
3.12 public static final String SUN_APP_SERVER_8_1 = NbBundle.getMessage( EjbContainerVendor.class, "SUN_APP_SERVER_8_1" );
3.13 public static final String SUN_APP_SERVER_8 = NbBundle.getMessage( EjbContainerVendor.class, "SUN_APP_SERVER_8" );
3.14 public static final String SUN_APP_SERVER_7 = NbBundle.getMessage( EjbContainerVendor.class, "SUN_APP_SERVER_7" );
3.15 @@ -36,13 +41,14 @@
3.16
3.17 public static String[] getContainerTypeNames()
3.18 {
3.19 - String[] containerTypes = { SUN_APP_SERVER_8_1, SUN_APP_SERVER_8, SUN_APP_SERVER_7, WEBLOGIC_8_1, WEBSPHERE_5_1 };
3.20 + String[] containerTypes = { SUN_APP_SERVER_9_1, SUN_APP_SERVER_9, SUN_APP_SERVER_8_1,
3.21 + SUN_APP_SERVER_8, SUN_APP_SERVER_7, WEBLOGIC_8_1, WEBSPHERE_5_1 };
3.22 return containerTypes;
3.23 }
3.24
3.25 public static int getDefaultPort( String server )
3.26 {
3.27 - if( server.equals( SUN_APP_SERVER_8_1 ) || server.equals( SUN_APP_SERVER_8 ) || server.equals( SUN_APP_SERVER_7 ) )
3.28 + if (isSunAppServer(server))
3.29 return SUN_APP_SERVER_PORT;
3.30 else if( server.equals( WEBLOGIC_8_1 ) )
3.31 return WEBLOGIC_PORT;
3.32 @@ -51,10 +57,10 @@
3.33 else
3.34 return UNKNOWN_PORT;
3.35 }
3.36 -
3.37 +
3.38 public static String getVendorDDFileName( String server )
3.39 {
3.40 - if( server.equals( SUN_APP_SERVER_8_1 ) || server.equals( SUN_APP_SERVER_8 ) || server.equals( SUN_APP_SERVER_7 ) )
3.41 + if (isSunAppServer(server))
3.42 return SUN_DEPLOYMENT_DESCRIPTOR;
3.43 else if( server.equals( WEBLOGIC_8_1 ) )
3.44 return WEBLOGIC_DEPLOYMENT_DESCRIPTOR;
3.45 @@ -63,4 +69,10 @@
3.46 else
3.47 throw new java.lang.IllegalArgumentException( server );
3.48 }
3.49 +
3.50 + static boolean isSunAppServer(String server) {
3.51 + return server.equals(SUN_APP_SERVER_9_1) || server.equals(SUN_APP_SERVER_9)
3.52 + || server.equals(SUN_APP_SERVER_8_1) || server.equals(SUN_APP_SERVER_8)
3.53 + || server.equals(SUN_APP_SERVER_7);
3.54 + }
3.55 }
4.1 --- a/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/EjbGroup.java Thu Jun 07 20:30:32 2007 +0000
4.2 +++ b/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/datamodel/EjbGroup.java Thu Jun 07 22:14:17 2007 +0000
4.3 @@ -291,10 +291,10 @@
4.4 return justNames;
4.5 }
4.6
4.7 - public Collection getSessionBeans() {
4.8 + public List<EjbInfo> getSessionBeans() {
4.9 if( this.sessionBeans != null )
4.10 {
4.11 - ArrayList beans = new ArrayList( this.sessionBeans.values() );
4.12 + ArrayList<EjbInfo> beans = new ArrayList<EjbInfo>( this.sessionBeans.values() );
4.13 Collections.sort( beans );
4.14 return beans;
4.15 }
4.16 @@ -325,12 +325,7 @@
4.17
4.18 public boolean isSunAppServer()
4.19 {
4.20 - if( this.getAppServerVendor().equals( EjbContainerVendor.SUN_APP_SERVER_8_1 ) ||
4.21 - this.getAppServerVendor().equals( EjbContainerVendor.SUN_APP_SERVER_8 ) ||
4.22 - this.getAppServerVendor().equals( EjbContainerVendor.SUN_APP_SERVER_7 ) )
4.23 - return true;
4.24 - else
4.25 - return false;
4.26 + return EjbContainerVendor.isSunAppServer(getAppServerVendor());
4.27 }
4.28
4.29 public boolean isWebLogicAppServer()
5.1 --- a/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/nodes/EjbLibReferenceHelper.java Thu Jun 07 20:30:32 2007 +0000
5.2 +++ b/visualweb.ejb/src/org/netbeans/modules/visualweb/ejb/nodes/EjbLibReferenceHelper.java Thu Jun 07 22:14:17 2007 +0000
5.3 @@ -17,6 +17,7 @@
5.4 import java.util.Collection;
5.5 import java.util.HashMap;
5.6 import java.util.Iterator;
5.7 +import java.util.List;
5.8 import java.util.Map;
5.9 import java.util.logging.Level;
5.10
5.11 @@ -25,6 +26,11 @@
5.12 import org.netbeans.api.project.Project;
5.13 import org.netbeans.api.project.libraries.Library;
5.14 import org.netbeans.api.project.libraries.LibraryManager;
5.15 +import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
5.16 +import org.netbeans.modules.j2ee.sun.dd.api.DDProvider;
5.17 +import org.netbeans.modules.j2ee.sun.dd.api.RootInterface;
5.18 +import org.netbeans.modules.j2ee.sun.dd.api.common.EjbRef;
5.19 +import org.netbeans.modules.j2ee.sun.dd.api.web.SunWebApp;
5.20 import org.netbeans.modules.visualweb.api.designerapi.DesignerServiceHack;
5.21 import org.netbeans.modules.visualweb.api.j2ee.common.RequestedEjbResource;
5.22 import org.netbeans.modules.visualweb.ejb.EjbDataSourceManager;
5.23 @@ -38,6 +44,7 @@
5.24 import org.openide.filesystems.FileLock;
5.25 import org.openide.filesystems.FileObject;
5.26 import org.openide.filesystems.FileUtil;
5.27 +import org.openide.util.Lookup;
5.28
5.29 /**
5.30 *
5.31 @@ -621,6 +628,53 @@
5.32 // Add an ejb-ref to the standard webapp DD, web.xml
5.33 addToWebXml(project, ejbGroup);
5.34
5.35 - // TODO add it to the container-specific DD
5.36 + // Add it to the container-specific DD
5.37 + addToVendorDD(project, ejbGroup);
5.38 + }
5.39 +
5.40 + private static void addToVendorDD(Project project, EjbGroup ejbGroup) throws IOException {
5.41 + Lookup lookup = project.getLookup();
5.42 + J2eeModuleProvider provider = (J2eeModuleProvider) lookup.lookup(J2eeModuleProvider.class);
5.43 + FileObject[] configFiles = provider.getConfigurationFiles();
5.44 + for (FileObject fo : configFiles) {
5.45 + if (fo.getNameExt().equals("sun-web.xml")) {
5.46 + addToSunWebXml(ejbGroup, fo);
5.47 + // TODO Add support to other servers here
5.48 + }
5.49 + }
5.50 + }
5.51 +
5.52 + private static void addToSunWebXml(EjbGroup ejbGroup, FileObject fo) throws IOException {
5.53 + RootInterface sunDDRoot = DDProvider.getDefault().getDDRoot(fo);
5.54 + if (sunDDRoot instanceof SunWebApp) {
5.55 + SunWebApp sunWebXml = (SunWebApp) sunDDRoot;
5.56 +
5.57 + List<EjbInfo> sessionBeans = ejbGroup.getSessionBeans();
5.58 + for (EjbInfo ejbInfo : sessionBeans) {
5.59 + String refName = ejbInfo.getWebEjbRef();
5.60 + String jndiName = ejbInfo.getJNDIName();
5.61 +
5.62 + EjbRef ref = findEjbRefByName(sunWebXml, refName);
5.63 + if (ref != null) {
5.64 + ref.setJndiName(jndiName);
5.65 + } else {
5.66 + ref = sunWebXml.newEjbRef();
5.67 + ref.setEjbRefName(refName);
5.68 + ref.setJndiName(jndiName);
5.69 + sunWebXml.addEjbRef(ref);
5.70 + }
5.71 + }
5.72 + sunWebXml.write(fo);
5.73 + }
5.74 + }
5.75 +
5.76 + private static EjbRef findEjbRefByName(SunWebApp sunWebXml, String ejbRefName) {
5.77 + EjbRef[] ejbRefs = sunWebXml.getEjbRef();
5.78 + for (EjbRef ref : ejbRefs) {
5.79 + if (ref.getEjbRefName().equals(ejbRefName)) {
5.80 + return ref;
5.81 + }
5.82 + }
5.83 + return null;
5.84 }
5.85 }