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 77344
Collapse All | Expand All

(-)serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/ConfigurationSupportImpl.java (+11 lines)
Lines 86-91 Link Here
86
        ((SunONEDeploymentConfiguration)config).ensureResourceDefined(ddBean);
86
        ((SunONEDeploymentConfiguration)config).ensureResourceDefined(ddBean);
87
    }
87
    }
88
88
89
    /** Called through j2eeserver when a new EJB resource may need to be added to the
90
     *  user's project.
91
     */
92
    public void ensureResourceDefinedForEjb(DeploymentConfiguration config, DDBean ddBean, String jndiName) {
93
        checkConfiguration(config);
94
        if(ddBean == null) {
95
            throw new IllegalArgumentException("DDBean parameter cannot be null.");
96
        }
97
        ((SunONEDeploymentConfiguration)config).ensureResourceDefinedForEjb(ddBean, jndiName);
98
    }
99
89
    
100
    
90
    /** Conduit to pass the cmp mapping information directly to the configuration
101
    /** Conduit to pass the cmp mapping information directly to the configuration
91
     *  backend.
102
     *  backend.
(-)serverplugins/sun/sunddui/src/org/netbeans/modules/j2ee/sun/share/configbean/SunONEDeploymentConfiguration.java (-40 / +46 lines)
Lines 474-526 Link Here
474
                ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "DDBean from wrong tree in ensureResourceDefined: " + ddBean); // NOI18N
474
                ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "DDBean from wrong tree in ensureResourceDefined: " + ddBean); // NOI18N
475
            }
475
            }
476
        } else if("entity".equals(type)) { //NOI18N
476
        } else if("entity".equals(type)) { //NOI18N
477
            // Find the DConfigBean for this ddBean.  This is actually quite complicated since
477
            ensureResourceDefinedForEjb(ddBean, null);
478
            // the DDBean passed in is from j2eeserver, not from the DDBean tree used and managed
478
        }
479
            // by the plugin.
479
    }
480
            BaseEjb theEjbDCB = getEjbDConfigBean(ddBean);
480
481
            
481
    public void ensureResourceDefinedForEjb(DDBean ddBean, String jndiName) {
482
            if(theEjbDCB == null) {
482
        // Find the DConfigBean for this ddBean.  This is actually quite complicated since
483
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("EJB DConfigBean cannot be found for DDBean: " + ddBean)); // NOI18N
483
        // the DDBean passed in is from j2eeserver, not from the DDBean tree used and managed
484
        // by the plugin.
485
        BaseEjb theEjbDCB = getEjbDConfigBean(ddBean);
486
487
        if(theEjbDCB == null) {
488
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("EJB DConfigBean cannot be found for DDBean: " + ddBean)); // NOI18N
489
            return;
490
        }
491
492
        if(theEjbDCB instanceof CmpEntityEjb) {
493
            ResourceConfiguratorInterface rci = getResourceConfigurator();
494
            CmpEntityEjb cmpEjbDCB = (CmpEntityEjb) theEjbDCB;
495
496
            if(resourceDir == null) {
497
                // Unable to create JDBC data source for CMP.
498
                // JNDI name of CMP resource field not set.
499
                postResourceError(NbBundle.getMessage(SunONEDeploymentConfiguration.class, 
500
                        "ERR_NoCmpOrJdbcDataSource", cmpEjbDCB.getEjbName())); // NOI18N
484
                return;
501
                return;
485
            }
502
            }
486
503
487
            if(theEjbDCB instanceof CmpEntityEjb) {
504
            if (jndiName == null) {
488
                ResourceConfiguratorInterface rci = getResourceConfigurator();
489
                CmpEntityEjb cmpEjbDCB = (CmpEntityEjb) theEjbDCB;
490
                
491
                if(resourceDir == null) {
492
                    // Unable to create JDBC data source for CMP.
493
                    // JNDI name of CMP resource field not set.
494
                    postResourceError(NbBundle.getMessage(SunONEDeploymentConfiguration.class, 
495
                            "ERR_NoCmpOrJdbcDataSource", cmpEjbDCB.getEjbName())); // NOI18N
496
                    return;
497
                }
498
                
499
                String description = getField(ddBean, "description"); //NOI18N
505
                String description = getField(ddBean, "description"); //NOI18N
500
                String jndiName = rci.createJDBCDataSourceForCmp(cmpEjbDCB.getEjbName(), description, resourceDir);
506
                jndiName = rci.createJDBCDataSourceForCmp(cmpEjbDCB.getEjbName(), description, resourceDir);
501
                
507
            }
502
                // Set the CmpResource jndi-name if not already defined.
508
503
                if(jndiName != null) {
509
            // Set the CmpResource jndi-name if not already defined.
504
                    Base parentDCB = cmpEjbDCB.getParent();
510
            if(jndiName != null) {
505
                    if(parentDCB instanceof EjbJarRoot) {
511
                Base parentDCB = cmpEjbDCB.getParent();
506
                        EjbJarRoot ejbJarRoot = (EjbJarRoot) parentDCB;
512
                if(parentDCB instanceof EjbJarRoot) {
507
                        CmpResource cmpResource = null;
513
                    EjbJarRoot ejbJarRoot = (EjbJarRoot) parentDCB;
508
                        if(ejbJarRoot.getCmpResource() == null) {
514
                    CmpResource cmpResource = null;
509
                            cmpResource = getStorageFactory().createCmpResource();
515
                    if(ejbJarRoot.getCmpResource() == null) {
510
                        } else {
516
                        cmpResource = getStorageFactory().createCmpResource();
511
                            cmpResource = (CmpResource)ejbJarRoot.getCmpResource().clone();
512
                        }
513
                        cmpResource.setJndiName(jndiName);
514
                        try {
515
                            ejbJarRoot.setCmpResource(cmpResource);
516
                        } catch(PropertyVetoException ex) {
517
                            // Should never happen
518
                            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
519
                        }
520
                    } else {
517
                    } else {
518
                        cmpResource = (CmpResource)ejbJarRoot.getCmpResource().clone();
519
                    }
520
                    cmpResource.setJndiName(jndiName);
521
                    try {
522
                        ejbJarRoot.setCmpResource(cmpResource);
523
                    } catch(PropertyVetoException ex) {
521
                        // Should never happen
524
                        // Should never happen
522
                        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("CmpEntityBean DConfigBean parent is of wrong type: " + parentDCB)); // NOI18N
525
                        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
523
                    }
526
                    }
527
                } else {
528
                    // Should never happen
529
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("CmpEntityBean DConfigBean parent is of wrong type: " + parentDCB)); // NOI18N
524
                }
530
                }
525
            }
531
            }
526
        }
532
        }
(-)j2ee/persistence/src/org/netbeans/modules/j2ee/persistence/wizard/fromdb/RelatedCMPHelper.java (-1 / +1 lines)
Lines 155-161 Link Here
155
        return configFilesFolder;
155
        return configFilesFolder;
156
    }
156
    }
157
    
157
    
158
    String getDatasourceName() {
158
    public String getDatasourceName() {
159
        return datasourceName;
159
        return datasourceName;
160
    }
160
    }
161
    
161
    
(-)j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java (-1 / +5 lines)
Lines 273-278 Link Here
273
    }
273
    }
274
    
274
    
275
    public void ensureResourceDefinedForEjb(final String ejbname, final String ejbtype) {
275
    public void ensureResourceDefinedForEjb(final String ejbname, final String ejbtype) {
276
        ensureResourceDefinedForEjb(ejbname, ejbtype, null);
277
    }
278
    
279
    public void ensureResourceDefinedForEjb(String ejbname, String ejbtype, String jndiName) {
276
        if (! J2eeModule.EJB.equals(provider.getJ2eeModule().getModuleType())) {
280
        if (! J2eeModule.EJB.equals(provider.getJ2eeModule().getModuleType())) {
277
            throw new IllegalArgumentException("Trying to get config bean for ejb on non ejb module!"); //NONI18N
281
            throw new IllegalArgumentException("Trying to get config bean for ejb on non ejb module!"); //NONI18N
278
        }
282
        }
Lines 300-306 Link Here
300
        }
304
        }
301
        DeploymentConfiguration config = getDeploymentConfiguration();
305
        DeploymentConfiguration config = getDeploymentConfiguration();
302
        ConfigurationSupport serverConfig = server.getConfigurationSupport();
306
        ConfigurationSupport serverConfig = server.getConfigurationSupport();
303
        serverConfig.ensureResourceDefined(config, ejbBean);
307
        serverConfig.ensureResourceDefinedForEjb(config, ejbBean, jndiName);
304
    }
308
    }
305
    
309
    
306
    public Set<Datasource> getDatasources() {
310
    public Set<Datasource> getDatasources() {
(-)j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java (+9 lines)
Lines 330-335 Link Here
330
        public void ensureResourceDefinedForEjb(String ejbname, String ejbtype);
330
        public void ensureResourceDefinedForEjb(String ejbname, String ejbtype);
331
        
331
        
332
        /**
332
        /**
333
         * Ensure needed resources are automatically defined for the entity
334
         * represented by given DDBean.
335
         * @param ejbName the EJB name
336
         * @param ejbType the DTD name for type of EJB: 'message-drive', 'entity', 'session'.
337
         * @param jndiName the JNDI name of the resource where the EJB is stored
338
         */
339
        public void ensureResourceDefinedForEjb(String ejbName, String ejbType, String jndiName);
340
        
341
        /**
333
         * Tests whether data source creation is supported.
342
         * Tests whether data source creation is supported.
334
         *
343
         *
335
         * @return true if data source creation is supported, false otherwise.
344
         * @return true if data source creation is supported, false otherwise.
(-)j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/api/ConfigurationSupport.java (+12 lines)
Lines 131-136 Link Here
131
                                               DDBean bean);
131
                                               DDBean bean);
132
    
132
    
133
    /**
133
    /**
134
     * Ensure resource is defined for the specified DD bean (for example entity bean).
135
     *
136
     * @param config  deployment configuration
137
     * @param bean DD bean in question
138
     * @param jndiName the JNDI name of the resource where the EJB is stored
139
     */
140
    public void ensureResourceDefinedForEjb(DeploymentConfiguration config, 
141
                                               DDBean bean, String jndiName)
142
    {
143
    }
144
    
145
    /**
134
     * Return the context root (context path) defined for the module specified 
146
     * Return the context root (context path) defined for the module specified 
135
     * by the deployable object.
147
     * by the deployable object.
136
     *
148
     *
(-)j2ee/ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/cmp/CmpGenerator.java (-1 / +1 lines)
Lines 562-568 Link Here
562
        dd.write(ejbModule.getDeploymentDescriptor());
562
        dd.write(ejbModule.getDeploymentDescriptor());
563
        if (pwm != null) {
563
        if (pwm != null) {
564
            for (int i = 0; i < genBeans.length; i++){
564
            for (int i = 0; i < genBeans.length; i++){
565
                pwm.getConfigSupport().ensureResourceDefinedForEjb(genBeans[i].getClassName(), "entity"); //NOI18N
565
                pwm.getConfigSupport().ensureResourceDefinedForEjb(genBeans[i].getClassName(), "entity", helper.getDatasourceName()); //NOI18N
566
            }
566
            }
567
        }
567
        }
568
        
568
        

Return to bug 77344