1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp; 26 27 import java.util.ArrayList ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 import java.util.ResourceBundle ; 31 32 import java.beans.PropertyChangeListener ; 33 import java.beans.PropertyChangeEvent ; 34 35 import java.awt.Component ; 36 import java.awt.Container ; 37 38 import javax.swing.JPanel ; 39 import javax.swing.DefaultComboBoxModel ; 40 41 import org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException; 42 import org.netbeans.modules.j2ee.sun.dd.api.web.CacheMapping; 43 import org.netbeans.modules.j2ee.sun.dd.api.web.CacheHelper; 44 import org.netbeans.modules.j2ee.sun.dd.api.web.ConstraintField; 45 46 import org.netbeans.modules.j2ee.sun.share.configbean.Utils; 47 import org.netbeans.modules.j2ee.sun.share.configbean.ServletRef; 48 import org.netbeans.modules.j2ee.sun.share.configbean.WebAppCache; 49 import org.netbeans.modules.j2ee.sun.share.configbean.WebAppRoot; 50 51 55 public class SelectedCacheMappingPanel extends javax.swing.JPanel { 56 57 private static final ResourceBundle webappBundle = ResourceBundle.getBundle( 58 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.webapp.Bundle"); 60 private static final ResourceBundle commonBundle = ResourceBundle.getBundle( 61 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); 63 private WebAppRootCustomizer masterPanel; 64 private CacheMapping selectedCacheMapping; 65 66 private DefaultComboBoxModel servletNamesModel; 67 private DefaultComboBoxModel helperRefsModel; 68 69 private boolean isServletTarget; 70 private String servletName; 71 private String urlPattern; 72 73 private boolean isHelperReference; 74 private String helperRef; 75 private PolicyStorage policy; 76 77 79 boolean duringInit; 80 81 82 public SelectedCacheMappingPanel(WebAppRootCustomizer src) { 83 masterPanel = src; 84 85 duringInit = false; 86 87 initComponents(); 88 initUserComponents(); 89 } 90 91 96 private void initComponents() { 98 java.awt.GridBagConstraints gridBagConstraints; 99 100 jRBGCacheTarget = new javax.swing.ButtonGroup (); 101 jRBGCacheReference = new javax.swing.ButtonGroup (); 102 jLblSelectedMapping = new javax.swing.JLabel (); 103 jLblTarget = new javax.swing.JLabel (); 104 jRBnServletName = new javax.swing.JRadioButton (); 105 jCbxServletName = new javax.swing.JComboBox (); 106 jRBnURLPattern = new javax.swing.JRadioButton (); 107 jTxtURLPattern = new javax.swing.JTextField (); 108 jLblReference = new javax.swing.JLabel (); 109 jRBnCacheHelper = new javax.swing.JRadioButton (); 110 jCbxCacheHelper = new javax.swing.JComboBox (); 111 jRBnCachePolicy = new javax.swing.JRadioButton (); 112 jBtnEditPolicy = new javax.swing.JButton (); 113 114 setLayout(new java.awt.GridBagLayout ()); 115 116 getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_SelectedCacheMapping")); 117 getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_SelectedCacheMapping")); 118 jLblSelectedMapping.setText(webappBundle.getString("LBL_SelectedCacheMapping")); 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 121 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 122 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 123 add(jLblSelectedMapping, gridBagConstraints); 124 125 jLblTarget.setText(webappBundle.getString("LBL_CacheTarget_1")); 126 gridBagConstraints = new java.awt.GridBagConstraints (); 127 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 128 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 129 gridBagConstraints.weightx = 1.0; 130 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 131 add(jLblTarget, gridBagConstraints); 132 133 jRBGCacheTarget.add(jRBnServletName); 134 jRBnServletName.setSelected(true); 135 jRBnServletName.setText(webappBundle.getString("LBL_ServletName")); 136 jRBnServletName.addActionListener(new java.awt.event.ActionListener () { 137 public void actionPerformed(java.awt.event.ActionEvent evt) { 138 jRBnServletNameActionPerformed(evt); 139 } 140 }); 141 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 144 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 145 add(jRBnServletName, gridBagConstraints); 146 jRBnServletName.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_ServletName")); 147 jRBnServletName.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_ServletName")); 148 149 jCbxServletName.setPrototypeDisplayValue(""); 150 jCbxServletName.addActionListener(new java.awt.event.ActionListener () { 151 public void actionPerformed(java.awt.event.ActionEvent evt) { 152 jCbxServletNameActionPerformed(evt); 153 } 154 }); 155 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 158 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 159 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 160 gridBagConstraints.weightx = 1.0; 161 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 5); 162 add(jCbxServletName, gridBagConstraints); 163 jCbxServletName.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_ServletSelector")); 164 jCbxServletName.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_ServletSelector")); 165 166 jRBGCacheTarget.add(jRBnURLPattern); 167 jRBnURLPattern.setText(webappBundle.getString("LBL_URLPattern")); 168 jRBnURLPattern.addActionListener(new java.awt.event.ActionListener () { 169 public void actionPerformed(java.awt.event.ActionEvent evt) { 170 jRBnURLPatternActionPerformed(evt); 171 } 172 }); 173 174 gridBagConstraints = new java.awt.GridBagConstraints (); 175 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 176 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 177 add(jRBnURLPattern, gridBagConstraints); 178 jRBnURLPattern.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_URLPattern")); 179 jRBnURLPattern.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_URLPattern")); 180 181 jTxtURLPattern.addKeyListener(new java.awt.event.KeyAdapter () { 182 public void keyReleased(java.awt.event.KeyEvent evt) { 183 jTxtURLPatternKeyReleased(evt); 184 } 185 }); 186 187 gridBagConstraints = new java.awt.GridBagConstraints (); 188 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 189 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 190 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 5); 191 add(jTxtURLPattern, gridBagConstraints); 192 jTxtURLPattern.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_URLPatternText")); 193 jTxtURLPattern.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_URLPatternText")); 194 195 jLblReference.setText(webappBundle.getString("LBL_CacheReference_1")); 196 gridBagConstraints = new java.awt.GridBagConstraints (); 197 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 198 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 199 gridBagConstraints.weightx = 1.0; 200 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 201 add(jLblReference, gridBagConstraints); 202 203 jRBGCacheReference.add(jRBnCacheHelper); 204 jRBnCacheHelper.setSelected(true); 205 jRBnCacheHelper.setText(webappBundle.getString("LBL_CacheHelper")); 206 jRBnCacheHelper.addActionListener(new java.awt.event.ActionListener () { 207 public void actionPerformed(java.awt.event.ActionEvent evt) { 208 jRBnCacheHelperActionPerformed(evt); 209 } 210 }); 211 212 gridBagConstraints = new java.awt.GridBagConstraints (); 213 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 214 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 0); 215 add(jRBnCacheHelper, gridBagConstraints); 216 jRBnCacheHelper.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_CacheHelper")); 217 jRBnCacheHelper.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_CacheHelper")); 218 219 jCbxCacheHelper.setPrototypeDisplayValue(""); 220 jCbxCacheHelper.addActionListener(new java.awt.event.ActionListener () { 221 public void actionPerformed(java.awt.event.ActionEvent evt) { 222 jCbxCacheHelperActionPerformed(evt); 223 } 224 }); 225 226 gridBagConstraints = new java.awt.GridBagConstraints (); 227 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 228 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 229 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 230 gridBagConstraints.weightx = 1.0; 231 gridBagConstraints.insets = new java.awt.Insets (6, 6, 0, 5); 232 add(jCbxCacheHelper, gridBagConstraints); 233 jCbxCacheHelper.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_CacheHelperSelector")); 234 jCbxCacheHelper.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_CacheHelperSelector")); 235 236 jRBGCacheReference.add(jRBnCachePolicy); 237 jRBnCachePolicy.setText(webappBundle.getString("LBL_Policy")); 238 jRBnCachePolicy.addActionListener(new java.awt.event.ActionListener () { 239 public void actionPerformed(java.awt.event.ActionEvent evt) { 240 jRBnCachePolicyActionPerformed(evt); 241 } 242 }); 243 244 gridBagConstraints = new java.awt.GridBagConstraints (); 245 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 246 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 0); 247 add(jRBnCachePolicy, gridBagConstraints); 248 jRBnCachePolicy.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_Policy")); 249 jRBnCachePolicy.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_Policy")); 250 251 jBtnEditPolicy.setText(webappBundle.getString("LBL_EditPolicy")); 252 jBtnEditPolicy.addActionListener(new java.awt.event.ActionListener () { 253 public void actionPerformed(java.awt.event.ActionEvent evt) { 254 jBtnEditPolicyActionPerformed(evt); 255 } 256 }); 257 258 gridBagConstraints = new java.awt.GridBagConstraints (); 259 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 260 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 261 gridBagConstraints.weightx = 1.0; 262 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 5); 263 add(jBtnEditPolicy, gridBagConstraints); 264 jBtnEditPolicy.getAccessibleContext().setAccessibleName(webappBundle.getString("ACSN_EditPolicy")); 265 jBtnEditPolicy.getAccessibleContext().setAccessibleDescription(webappBundle.getString("ACSD_EditPolicy")); 266 267 } 269 private void jRBnCachePolicyActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 272 isHelperReference = false; 273 selectedCacheMapping.setCacheHelperRef(null); 274 275 if(policy != null) { 277 policy.savePolicyToMapping(selectedCacheMapping); 278 policy = null; 279 } 280 281 enableHelperPolicyFields(); 282 283 masterPanel.getBean().setDirty(); 284 } 285 } 287 private void jRBnCacheHelperActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 290 isHelperReference = true; 291 292 policy = new PolicyStorage(selectedCacheMapping); 294 295 selectedCacheMapping.setCacheHelperRef(helperRef); 301 selectedCacheMapping.setTimeout(null); 302 selectedCacheMapping.setRefreshField(false); 303 selectedCacheMapping.setHttpMethod(null); 304 try { 305 selectedCacheMapping.setDispatcher(null); 306 } catch(VersionNotSupportedException ex) { 307 } 309 selectedCacheMapping.setKeyField(null); 310 selectedCacheMapping.setConstraintField(null); 311 enableHelperPolicyFields(); 312 313 masterPanel.getBean().setDirty(); 314 } 315 } 317 private void jRBnURLPatternActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 320 isServletTarget = false; 321 selectedCacheMapping.setUrlPattern(urlPattern); 322 selectedCacheMapping.setServletName(null); 323 enableServletURLFields(); 324 325 masterPanel.getBean().setDirty(); 326 } 327 } 329 private void jRBnServletNameActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 332 isServletTarget = true; 333 selectedCacheMapping.setUrlPattern(null); 334 selectedCacheMapping.setServletName(servletName); 335 enableServletURLFields(); 336 337 masterPanel.getBean().setDirty(); 338 } 339 } 341 private void jBtnEditPolicyActionPerformed(java.awt.event.ActionEvent evt) { if(CachePolicyPanel.invokeAsPopup((JPanel ) getParent(), masterPanel.getBean().getAppServerVersion(), selectedCacheMapping)) { 344 masterPanel.getBean().setDirty(); 345 } 346 } 348 private void jCbxCacheHelperActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 351 helperRef = (String ) helperRefsModel.getSelectedItem(); 352 if(selectedCacheMapping != null) { 353 selectedCacheMapping.setCacheHelperRef(helperRef); 354 } 355 356 masterPanel.getBean().setDirty(); 357 } 358 } 360 private void jTxtURLPatternKeyReleased(java.awt.event.KeyEvent evt) { urlPattern = jTxtURLPattern.getText(); 363 367 if(selectedCacheMapping != null) { 368 selectedCacheMapping.setUrlPattern(urlPattern); 369 } 370 371 masterPanel.getBean().setDirty(); 372 } 374 private void jCbxServletNameActionPerformed(java.awt.event.ActionEvent evt) { if(!duringInit) { 377 servletName = (String ) servletNamesModel.getSelectedItem(); 378 if(selectedCacheMapping != null) { 379 selectedCacheMapping.setServletName(servletName); 380 } 381 382 masterPanel.getBean().setDirty(); 383 } 384 } 386 387 private javax.swing.JButton jBtnEditPolicy; 389 private javax.swing.JComboBox jCbxCacheHelper; 390 private javax.swing.JComboBox jCbxServletName; 391 private javax.swing.JLabel jLblReference; 392 private javax.swing.JLabel jLblSelectedMapping; 393 private javax.swing.JLabel jLblTarget; 394 private javax.swing.ButtonGroup jRBGCacheReference; 395 private javax.swing.ButtonGroup jRBGCacheTarget; 396 private javax.swing.JRadioButton jRBnCacheHelper; 397 private javax.swing.JRadioButton jRBnCachePolicy; 398 private javax.swing.JRadioButton jRBnServletName; 399 private javax.swing.JRadioButton jRBnURLPattern; 400 private javax.swing.JTextField jTxtURLPattern; 401 403 private void initUserComponents() { 404 masterPanel.addPropertyChangeListener(WebAppRootCustomizer.CACHE_HELPER_LIST_CHANGED, 405 new PropertyChangeListener () { 406 public void propertyChange(PropertyChangeEvent pce) { 407 cacheHelperListChanged(); 408 } 409 }); 410 411 masterPanel.addPropertyChangeListener(WebAppRootCustomizer.SERVLET_LIST_CHANGED, 412 new PropertyChangeListener () { 413 public void propertyChange(PropertyChangeEvent pce) { 414 servletListChanged(); 415 } 416 }); 417 } 418 419 public void setSelectedCacheMapping(CacheMapping mapping) { 420 try { 421 duringInit = true; 422 selectedCacheMapping = mapping; 423 policy = null; 424 425 if(selectedCacheMapping != null) { 426 servletNamesModel = getServletComboBoxModel(); 427 helperRefsModel = getHelperRefComboBoxModel(); 428 429 servletName = mapping.getServletName(); 430 urlPattern = mapping.getUrlPattern(); 431 isServletTarget = (servletName != null) ? true : false; 432 helperRef = mapping.getCacheHelperRef(); 433 isHelperReference = (helperRef != null) ? true : false; 434 } else { 435 servletNamesModel = new DefaultComboBoxModel (); 437 helperRefsModel = new DefaultComboBoxModel (); 438 servletName = null; 439 urlPattern = null; 440 isServletTarget = false; 441 helperRef = null; 442 isHelperReference = false; 443 } 444 445 if(isServletTarget) { 446 urlPattern = null; 448 jRBnServletName.setSelected(true); 449 } else { 450 servletName = null; 452 if(urlPattern == null) { 453 urlPattern = ""; } 455 456 jRBnURLPattern.setSelected(true); 457 } 458 459 jCbxServletName.setModel(servletNamesModel); 460 jCbxServletName.setSelectedItem(servletName); 461 jTxtURLPattern.setText(urlPattern); 462 463 if(isHelperReference) { 464 jRBnCacheHelper.setSelected(true); 465 } else { 466 jRBnCachePolicy.setSelected(true); 467 } 468 469 jCbxCacheHelper.setModel(helperRefsModel); 470 jCbxCacheHelper.setSelectedItem(helperRef); 471 472 if(selectedCacheMapping != null) { 473 enableServletURLFields(); 474 enableHelperPolicyFields(); 475 } 476 } finally { 477 duringInit = false; 478 } 479 } 480 481 private DefaultComboBoxModel getServletComboBoxModel() { 482 DefaultComboBoxModel model = new DefaultComboBoxModel (); 484 WebAppRoot bean = masterPanel.getBean(); 485 if(bean != null) { 486 List servlets = bean.getServlets(); 487 for(Iterator iter = servlets.iterator(); iter.hasNext(); ) { 488 ServletRef servletRef = (ServletRef) iter.next(); 489 model.addElement(servletRef.getServletName()); 490 } 491 } 492 493 return model; 494 } 495 496 private DefaultComboBoxModel getHelperRefComboBoxModel() { 497 DefaultComboBoxModel model = new DefaultComboBoxModel (); 499 model.addElement("default-helper"); 501 WebAppRoot bean = masterPanel.getBean(); 502 if(bean != null) { 503 WebAppCache cacheBean = bean.getCacheBean(); 504 List helpers = cacheBean.getCacheHelpers(); 505 if(helpers != null) { 506 for(Iterator iter = helpers.iterator(); iter.hasNext(); ) { 507 CacheHelper helperRef = (CacheHelper) iter.next(); 508 model.addElement(helperRef.getName()); 509 } 510 } 511 } 512 513 return model; 514 } 515 516 private void enableServletURLFields() { 517 jCbxServletName.setEnabled(isServletTarget); 518 jTxtURLPattern.setEnabled(!isServletTarget); 519 jTxtURLPattern.setEditable(!isServletTarget); 520 } 521 522 private void enableHelperPolicyFields() { 523 jCbxCacheHelper.setEnabled(isHelperReference); 524 jBtnEditPolicy.setEnabled(!isHelperReference); 525 } 526 527 public void setContainerEnabled(Container container, boolean enabled) { 528 Component [] components = container.getComponents(); 529 for(int i = 0; i < components.length; i++) { 530 components[i].setEnabled(enabled); 531 if(components[i] instanceof Container ) { 532 setContainerEnabled((Container ) components[i], enabled); 533 } 534 } 535 } 536 537 private void cacheHelperListChanged() { 538 if(selectedCacheMapping != null) { 541 helperRefsModel = getHelperRefComboBoxModel(); 542 jCbxCacheHelper.setModel(helperRefsModel); 543 544 if(isHelperReference) { 545 int helperIndex = helperRefsModel.getIndexOf(helperRef); 546 if(helperIndex >= 0) { 547 jCbxCacheHelper.setSelectedIndex(helperIndex); 548 } else { 549 jCbxCacheHelper.setSelectedItem(null); 550 } 551 } 552 } 553 } 554 555 private void servletListChanged() { 556 if(selectedCacheMapping != null) { 559 servletNamesModel = getServletComboBoxModel(); 560 jCbxServletName.setModel(servletNamesModel); 561 562 if(isServletTarget) { 563 int servletIndex = servletNamesModel.getIndexOf(servletName); 564 if(servletIndex >= 0) { 565 jCbxServletName.setSelectedIndex(servletIndex); 566 } else { 567 jCbxServletName.setSelectedItem(null); 568 } 569 } 570 } 571 } 572 573 579 private class PolicyStorage { 580 private String timeoutName; 581 private String timeoutValue; 582 private String timeoutScope; 583 private String refreshFieldName; 584 private String refreshFieldScope; 585 private List httpMethods; private List dispatchers; private List keyFieldNames; private List keyFieldScopes; private List constraints; 591 596 public PolicyStorage(CacheMapping mapping) { 597 if(Utils.notEmpty(mapping.getTimeoutName())) { 599 timeoutValue = mapping.getTimeout(); 600 timeoutName = mapping.getTimeoutName(); 601 timeoutScope = mapping.getTimeoutScope(); 602 } 603 604 if(Utils.notEmpty(mapping.getRefreshFieldName())) { 606 refreshFieldName = mapping.getRefreshFieldName(); 607 refreshFieldScope = mapping.getRefreshFieldScope(); 608 } 609 610 String [] methods = mapping.getHttpMethod(); 612 if(methods != null) { 613 httpMethods = new ArrayList (methods.length); 614 for(int i = 0; i < methods.length; i++) { 615 httpMethods.add(methods[i]); 616 } 617 } 618 619 try { 621 String [] dsps; 622 dsps = mapping.getDispatcher(); 623 if(dsps != null) { 624 dispatchers = new ArrayList (dsps.length); 625 for(int i = 0; i < dsps.length; i++) { 626 dispatchers.add(dsps[i]); 627 } 628 } 629 } catch(VersionNotSupportedException ex) { 630 dispatchers = null; 632 } 633 634 int numFields = mapping.sizeKeyField(); 636 if(numFields > 0) { 637 keyFieldNames = new ArrayList (numFields); 638 keyFieldScopes = new ArrayList (numFields); 639 640 for(int i = 0; i < numFields; i++) { 641 keyFieldNames.add(mapping.getKeyFieldName(i)); 642 keyFieldScopes.add(mapping.getKeyFieldScope(i)); 643 } 644 } 645 646 if(mapping.sizeConstraintField() > 0) { 652 ConstraintField [] fields = mapping.getConstraintField(); 653 constraints = new ArrayList (fields.length); 654 for(int i = 0; i < fields.length; i++) { 655 constraints.add(fields[i].clone()); 656 } 657 } 658 } 659 660 664 public void savePolicyToMapping(CacheMapping mapping) { 665 if(Utils.notEmpty(timeoutName)) { 667 mapping.setTimeout(timeoutValue); 668 mapping.setTimeoutName(timeoutName); 669 mapping.setTimeoutScope(timeoutScope); 670 } 671 672 if(Utils.notEmpty(refreshFieldName)) { 674 mapping.setRefreshField(true); 675 mapping.setRefreshFieldName(refreshFieldName); 676 mapping.setRefreshFieldScope(refreshFieldScope); 677 } else { 678 mapping.setRefreshField(false); 679 } 680 681 if(httpMethods != null) { 683 mapping.setHttpMethod((String []) httpMethods.toArray(new String [0])); 684 } 685 686 if(dispatchers != null) { 688 try { 689 mapping.setDispatcher((String []) dispatchers.toArray(new String [0])); 690 } catch (VersionNotSupportedException ex) { 691 } 693 } 694 695 if(keyFieldNames != null) { 697 int numFields = keyFieldNames.size(); 698 mapping.setKeyField(new boolean [numFields]); 699 for(int i = 0; i < numFields; i++) { 700 mapping.setKeyField(i, true); 701 mapping.setKeyFieldName(i, (String ) keyFieldNames.get(i)); 702 mapping.setKeyFieldScope(i, (String ) keyFieldScopes.get(i)); 703 } 704 } 705 706 if(constraints != null) { 708 int size = constraints.size(); 709 ConstraintField [] fields = new ConstraintField [size]; 710 711 for(int i = 0; i < size; i++) { 712 fields[i] = (ConstraintField) constraints.get(i); 713 } 714 715 mapping.setConstraintField(fields); 716 } 717 } 718 } 719 } 720 | Popular Tags |