1 22 package org.jboss.metadata; 23 24 import java.lang.reflect.Method ; 25 import java.util.ArrayList ; 26 import java.util.Collection ; 27 import java.util.HashMap ; 28 import java.util.HashSet ; 29 import java.util.Iterator ; 30 import java.util.LinkedList ; 31 import java.util.Set ; 32 33 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap; 34 35 import org.jboss.deployment.DeploymentException; 36 import org.jboss.invocation.InvocationType; 37 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData; 38 import org.jboss.mx.util.ObjectNameFactory; 39 import org.jboss.security.AnybodyPrincipal; 40 import org.jboss.security.NobodyPrincipal; 41 import org.jboss.security.SimplePrincipal; 42 import org.w3c.dom.Element ; 43 44 45 60 public abstract class BeanMetaData 61 extends MetaData 62 { 63 65 public static final char SESSION_TYPE = 'S'; 66 public static final char ENTITY_TYPE = 'E'; 67 public static final char MDB_TYPE = 'M'; 68 public static final String LOCAL_INVOKER_PROXY_BINDING = "LOCAL"; 69 70 72 private ApplicationMetaData application; 73 74 private String description; 76 private String displayName; 77 82 private String ejbName; 83 85 private String homeClass; 86 88 private String remoteClass; 89 91 private String localHomeClass; 92 94 private String localClass; 95 97 protected String serviceEndpointClass; 98 100 private String ejbClass; 101 102 protected char beanType; 103 104 protected boolean containerManagedTx = true; 105 106 108 private ArrayList environmentEntries = new ArrayList (); 109 111 private HashMap ejbReferences = new HashMap (); 112 113 private HashMap ejbLocalReferences = new HashMap (); 114 115 private HashMap serviceReferences = new HashMap (); 116 117 private ArrayList securityRoleReferences = new ArrayList (); 118 119 private SecurityIdentityMetaData securityIdentity = null; 120 121 private SecurityIdentityMetaData ejbTimeoutIdentity = null; 122 123 private HashMap resourceReferences = new HashMap (); 124 125 private HashMap resourceEnvReferences = new HashMap (); 126 127 private HashMap messageDestinationReferences = new HashMap (); 128 129 private ArrayList methodAttributes = new ArrayList (); 130 private ConcurrentReaderHashMap cachedMethodAttributes = new ConcurrentReaderHashMap(); 131 132 private ArrayList permissionMethods = new ArrayList (); 133 134 private ArrayList transactionMethods = new ArrayList (); 135 136 private ConcurrentReaderHashMap methodTx = new ConcurrentReaderHashMap(); 137 138 private ArrayList excludedMethods = new ArrayList (); 139 140 protected HashMap invokerBindings = null; 141 142 private ClusterConfigMetaData clusterConfig = null; 143 144 145 private String jndiName; 146 147 148 private String localJndiName; 149 150 protected String configurationName; 151 152 private ConfigurationMetaData configuration; 153 154 private String securityProxy; 155 156 157 protected boolean clustered = false; 158 159 protected boolean callByValue = false; 160 161 private Collection depends = new LinkedList (); 162 163 164 private IorSecurityConfigMetaData iorSecurityConfig; 165 166 protected EjbPortComponentMetaData portComponent; 167 168 private boolean exceptionRollback = false; 169 170 private boolean timerPersistence = true; 171 172 174 public BeanMetaData(ApplicationMetaData app, char beanType) 176 { 177 this.application = app; 178 this.beanType = beanType; 179 } 180 181 public void setBeanType(char beanType) 182 { 183 this.beanType = beanType; 184 } 185 186 public String getDescription() 187 { 188 return description; 189 } 190 191 public void setDescription(String description) 192 { 193 this.description = description; 194 } 195 196 public String getDisplayName() 197 { 198 return displayName; 199 } 200 201 public void setDisplayName(String displayName) 202 { 203 this.displayName = displayName; 204 } 205 206 public boolean isSession() 207 { 208 return beanType == SESSION_TYPE; 209 } 210 211 public boolean isMessageDriven() 212 { 213 return beanType == MDB_TYPE; 214 } 215 216 public boolean isEntity() 217 { 218 return beanType == ENTITY_TYPE; 219 } 220 221 public String getHome() 222 { 223 return homeClass; 224 } 225 226 public String getRemote() 227 { 228 return remoteClass; 229 } 230 231 public String getLocalHome() 232 { 233 return localHomeClass; 234 } 235 236 public String getLocal() 237 { 238 return localClass; 239 } 240 241 public String getServiceEndpoint() 242 { 243 return serviceEndpointClass; 244 } 245 246 public EjbPortComponentMetaData getPortComponent() 247 { 248 return portComponent; 249 } 250 251 public void setPortComponent(EjbPortComponentMetaData portComponent) 252 { 253 this.portComponent = portComponent; 254 } 255 256 public String getEjbClass() 257 { 258 return ejbClass; 259 } 260 261 public String getEjbName() 262 { 263 return ejbName; 264 } 265 266 public void setEjbName(String ejbName) 267 { 268 this.ejbName = ejbName; 269 } 270 271 public boolean isContainerManagedTx() 272 { 273 return containerManagedTx; 274 } 275 276 public boolean isBeanManagedTx() 277 { 278 return !containerManagedTx; 279 } 280 281 public Iterator getEjbReferences() 282 { 283 return ejbReferences.values().iterator(); 284 } 285 286 public void addEjbReference(EjbRefMetaData ref) 287 { 288 ejbReferences.put(ref.getName(), ref); 289 } 290 291 public Iterator getEjbLocalReferences() 292 { 293 return ejbLocalReferences.values().iterator(); 294 } 295 296 public void addEjbLocalReference(EjbLocalRefMetaData ref) 297 { 298 ejbLocalReferences.put(ref.getName(), ref); 299 } 300 301 protected abstract void defaultInvokerBindings(); 302 303 public Iterator getInvokerBindings() 304 { 305 if (invokerBindings == null) 306 { 307 String [] defaultNames = configuration.getInvokers(); 309 if (defaultNames.length > 0) 310 { 311 invokerBindings = new HashMap (); 312 for (int count = 0; count < defaultNames.length; count++) 313 { 314 invokerBindings.put(defaultNames[count], getJndiName()); 315 } 316 } 317 else 318 { 319 defaultInvokerBindings(); 321 } 322 } 323 324 return invokerBindings.keySet().iterator(); 325 } 326 327 public String getInvokerBinding(String invokerName) 328 { 329 if (invokerBindings == null) 330 { 331 defaultInvokerBindings(); 332 } 333 334 return (String )invokerBindings.get(invokerName); 335 } 336 337 public void addInvokerBinding(String bindingName, String jndiName) 338 { 339 if(invokerBindings == null) 340 { 341 invokerBindings = new HashMap (); 342 } 343 invokerBindings.put(bindingName, jndiName); 344 } 345 346 public EjbRefMetaData getEjbRefByName(String name) 347 { 348 return (EjbRefMetaData)ejbReferences.get(name); 349 } 350 351 public EjbLocalRefMetaData getEjbLocalRefByName(String name) 352 { 353 return (EjbLocalRefMetaData)ejbLocalReferences.get(name); 354 } 355 356 public Iterator getEnvironmentEntries() 357 { 358 return environmentEntries.iterator(); 359 } 360 361 public void addEnvironmentEntry(EnvEntryMetaData envEntry) 362 { 363 environmentEntries.add(envEntry); 364 } 365 366 public Iterator getSecurityRoleReferences() 367 { 368 return securityRoleReferences.iterator(); 369 } 370 371 public Iterator getResourceReferences() 372 { 373 return resourceReferences.values().iterator(); 374 } 375 376 public void addResourceReference(ResourceRefMetaData resRef) 377 { 378 resourceReferences.put(resRef.getRefName(), resRef); 379 } 380 381 public ResourceRefMetaData getResourceReference(String refName) 382 { 383 return (ResourceRefMetaData)resourceReferences.get(refName); 384 } 385 386 public Iterator getResourceEnvReferences() 387 { 388 return resourceEnvReferences.values().iterator(); 389 } 390 391 public void addResourceEnvReference(ResourceEnvRefMetaData resEnvRef) 392 { 393 resourceEnvReferences.put(resEnvRef.getRefName(), resEnvRef); 394 } 395 396 public ResourceEnvRefMetaData getResourceEnvReference(String refName) 397 { 398 return (ResourceEnvRefMetaData)resourceEnvReferences.get(refName); 399 } 400 401 public Iterator getMessageDestinationReferences() 402 { 403 return messageDestinationReferences.values().iterator(); 404 } 405 406 public void addMessageDestinationReference(MessageDestinationRefMetaData ref) 407 { 408 messageDestinationReferences.put(ref.getRefName(), ref); 409 } 410 411 public MessageDestinationRefMetaData getMessageDestinationReference(String refName) 412 { 413 return (MessageDestinationRefMetaData)messageDestinationReferences.get(refName); 414 } 415 416 419 public HashMap getServiceReferences() 420 { 421 return serviceReferences; 422 } 423 424 public void addServiceReference(ServiceRefMetaData ref) 425 { 426 serviceReferences.put(ref.getServiceRefName(), ref); 427 } 428 429 public String getJndiName() 430 { 431 if (jndiName == null) 433 { 434 jndiName = ejbName; 435 } 436 return jndiName; 437 } 438 439 443 public String getLocalJndiName() 444 { 445 if (localJndiName == null) 446 { 447 localJndiName = "local/" + ejbName + '@' + System.identityHashCode(ejbName); 449 } 450 return localJndiName; 451 } 452 453 456 public String getContainerObjectNameJndiName() 457 { 458 return getHome() != null ? getJndiName() : getLocalJndiName(); 459 } 460 461 public String getConfigurationName() 462 { 463 if (configurationName == null) 464 { 465 configurationName = getDefaultConfigurationName(); 466 } 467 return configurationName; 468 } 469 470 public ConfigurationMetaData getContainerConfiguration() 471 { 472 if (configuration == null) 473 { 474 String configName = getConfigurationName(); 475 configuration = application.getConfigurationMetaDataByName(configName); 476 if (configuration == null) 477 throw new IllegalStateException ("Container config not found " + configName); 478 } 479 return configuration; 480 } 481 482 public String getSecurityProxy() 483 { 484 return securityProxy; 485 } 486 487 public SecurityIdentityMetaData getSecurityIdentityMetaData() 488 { 489 return securityIdentity; 490 } 491 492 public void setSecurityIdentityMetaData(SecurityIdentityMetaData securityIdentity) 493 { 494 this.securityIdentity = securityIdentity; 495 } 496 497 public SecurityIdentityMetaData getEjbTimeoutIdentity() 498 { 499 return ejbTimeoutIdentity; 500 } 501 502 public ApplicationMetaData getApplicationMetaData() 503 { 504 return application; 505 } 506 507 public abstract String getDefaultConfigurationName(); 508 509 public Iterator getTransactionMethods() 510 { 511 return transactionMethods.iterator(); 512 } 513 514 public Iterator getPermissionMethods() 515 { 516 return permissionMethods.iterator(); 517 } 518 519 public Iterator getExcludedMethods() 520 { 521 return excludedMethods.iterator(); 522 } 523 524 public void addTransactionMethod(MethodMetaData method) 525 { 526 transactionMethods.add(method); 527 } 528 529 public void addPermissionMethod(MethodMetaData method) 530 { 531 if (method.isUnchecked()) 534 { 535 permissionMethods.add(0, method); 536 } 537 else 538 { 539 permissionMethods.add(method); 540 } 541 } 542 543 public void addExcludedMethod(MethodMetaData method) 544 { 545 excludedMethods.add(method); 546 } 547 548 public byte getMethodTransactionType(String methodName, Class [] params, InvocationType iface) 549 { 550 byte result = TX_UNKNOWN; 552 553 MethodMetaData bestMatch = null; 554 Iterator iterator = getTransactionMethods(); 555 while (iterator.hasNext()) 556 { 557 MethodMetaData m = (MethodMetaData)iterator.next(); 558 if (m.patternMatches(methodName, params, iface)) 559 { 560 561 if (bestMatch == null) 563 { 564 bestMatch = m; 565 } 566 else 567 { 568 if (bestMatch.getMethodName().equals("*")) 570 { 571 bestMatch = m; 572 } 573 if (m.getMethodParams().length > 0) 575 { 576 bestMatch = m; 577 break; 578 } 579 } 580 } 581 } 582 583 if (bestMatch != null) 584 { 585 result = bestMatch.getTransactionType(); 586 } 587 588 return result; 589 } 590 591 public byte getTransactionMethod(Method m, InvocationType iface) 593 { 594 if (m == null) 595 return MetaData.TX_SUPPORTS; 596 597 Byte b = (Byte )methodTx.get(m); 598 if (b != null) return b.byteValue(); 599 600 byte result = getMethodTransactionType(m.getName(), m.getParameterTypes(), iface); 601 602 if (result == MetaData.TX_UNKNOWN) 604 result = MetaData.TX_REQUIRED; 605 606 methodTx.put(m, new Byte (result)); 607 return result; 608 } 609 610 public Collection getDepends() 611 { 612 Collection allDepends = new LinkedList (depends); 613 allDepends.addAll(getContainerConfiguration().getDepends()); 614 return allDepends; 615 } 616 617 623 private MethodAttributes methodAttributesForMethod(String methodName) 624 { 625 if (methodName == null) 626 methodName = "*null*"; 627 628 MethodAttributes ma = 629 (MethodAttributes)cachedMethodAttributes.get(methodName); 630 631 if (ma == null) 632 { 633 Iterator iterator = methodAttributes.iterator(); 634 while (iterator.hasNext() && ma == null) 635 { 636 ma = (MethodAttributes)iterator.next(); 637 if (!ma.patternMatches(methodName)) 638 { 639 ma = null; 640 } 641 } 642 if (ma == null) 643 { 644 ma = MethodAttributes.kDefaultMethodAttributes; 645 } 646 647 cachedMethodAttributes.put(methodName, ma); 648 } 649 return ma; 650 } 651 652 655 public boolean isMethodReadOnly(String methodName) 656 { 657 return methodAttributesForMethod(methodName).readOnly; 658 } 659 660 public boolean isMethodReadOnly(Method method) 661 { 662 if (method == null) 663 { 664 return false; 665 } 666 return methodAttributesForMethod(method.getName()).readOnly; 667 } 668 669 672 public int getTransactionTimeout(String methodName) 673 { 674 return methodAttributesForMethod(methodName).txTimeout; 675 } 676 677 public int getTransactionTimeout(Method method) 678 { 679 if (method == null) 680 return 0; 681 return getTransactionTimeout(method.getName()); 682 } 683 684 695 public Set getMethodPermissions(String methodName, Class [] params, 696 InvocationType iface) 697 { 698 Set result = new HashSet (); 699 Iterator iterator = getExcludedMethods(); 702 while (iterator.hasNext()) 703 { 704 MethodMetaData m = (MethodMetaData)iterator.next(); 705 if (m.patternMatches(methodName, params, iface)) 706 { 707 712 result.add(NobodyPrincipal.NOBODY_PRINCIPAL); 713 return result; 714 } 715 } 716 717 iterator = getPermissionMethods(); 719 while (iterator.hasNext()) 720 { 721 MethodMetaData m = (MethodMetaData)iterator.next(); 722 if (m.patternMatches(methodName, params, iface)) 723 { 724 728 if (m.isUnchecked()) 729 { 730 result.clear(); 731 result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL); 732 break; 733 } 734 else 736 { 737 Iterator rolesIterator = m.getRoles().iterator(); 738 while (rolesIterator.hasNext()) 739 { 740 String roleName = (String )rolesIterator.next(); 741 result.add(new SimplePrincipal(roleName)); 742 } 743 } 744 } 745 } 746 747 if (this.isExcludeMissingMethods() == false) 748 { 749 if (result.isEmpty()) 751 { 752 result.add(AnybodyPrincipal.ANYBODY_PRINCIPAL); 753 } 754 } 755 756 return result; 757 } 758 759 767 public boolean hasMethodPermission(String methodName, Class [] params, 768 InvocationType iface) 769 { 770 Iterator iterator = getExcludedMethods(); 772 while (iterator.hasNext()) 773 { 774 MethodMetaData m = (MethodMetaData)iterator.next(); 775 if (m.patternMatches(methodName, params, iface)) 776 { 777 return true; 778 } 779 } 780 781 iterator = getPermissionMethods(); 783 while (iterator.hasNext()) 784 { 785 MethodMetaData m = (MethodMetaData)iterator.next(); 786 if (m.patternMatches(methodName, params, iface)) 787 { 788 return true; 789 } 790 } 791 792 return false; 793 } 794 795 public boolean isClustered() 797 { 798 return this.clustered; 799 } 800 801 public boolean isCallByValue() 802 { 803 return callByValue; 804 } 805 806 public boolean isExcludeMissingMethods() 807 { 808 return application.isExcludeMissingMethods(); 809 } 810 811 public ClusterConfigMetaData getClusterConfigMetaData() 812 { 813 if (clusterConfig == null) 814 { 815 clusterConfig = getContainerConfiguration().getClusterConfigMetaData(); 816 if (clusterConfig == null) 817 { 818 clusterConfig = new ClusterConfigMetaData(); 819 } 820 822 clusterConfig.init(this); 823 } 824 return this.clusterConfig; 825 } 826 827 public IorSecurityConfigMetaData getIorSecurityConfigMetaData() 828 { 829 return iorSecurityConfig; 830 } 831 832 public boolean getExceptionRollback() 833 { 834 return exceptionRollback; 835 } 836 837 public boolean getTimerPersistence() 838 { 839 return timerPersistence; 840 } 841 842 public ApplicationMetaData getApplication() 843 { 844 return application; 845 } 846 847 public void setApplication(ApplicationMetaData application) 848 { 849 this.application = application; 850 } 851 852 public ClusterConfigMetaData getClusterConfig() 853 { 854 return clusterConfig; 855 } 856 857 public void setClusterConfig(ClusterConfigMetaData clusterConfig) 858 { 859 this.clusterConfig = clusterConfig; 860 } 861 862 public void setHome(String homeClass) 863 { 864 this.homeClass = homeClass; 865 } 866 867 public IorSecurityConfigMetaData getIorSecurityConfig() 868 { 869 return iorSecurityConfig; 870 } 871 872 public void setIorSecurityConfig(IorSecurityConfigMetaData iorSecurityConfig) 873 { 874 this.iorSecurityConfig = iorSecurityConfig; 875 } 876 877 public void setLocal(String localClass) 878 { 879 this.localClass = localClass; 880 } 881 882 public void setLocalHome(String localHomeClass) 883 { 884 this.localHomeClass = localHomeClass; 885 } 886 887 public ArrayList getMethodAttributes() 888 { 889 return methodAttributes; 890 } 891 892 public void setMethodAttributes(ArrayList methodAttributes) 893 { 894 this.methodAttributes = methodAttributes; 895 } 896 897 public ConcurrentReaderHashMap getMethodTx() 898 { 899 return methodTx; 900 } 901 902 public void setMethodTx(ConcurrentReaderHashMap methodTx) 903 { 904 this.methodTx = methodTx; 905 } 906 907 public void setRemote(String remoteClass) 908 { 909 this.remoteClass = remoteClass; 910 } 911 912 public String getServiceEndpointClass() 913 { 914 return serviceEndpointClass; 915 } 916 917 public void setServiceEndpointClass(String serviceEndpointClass) 918 { 919 this.serviceEndpointClass = serviceEndpointClass; 920 } 921 922 public void setCallByValue(boolean callByValue) 923 { 924 this.callByValue = callByValue; 925 } 926 927 public void setClustered(boolean clustered) 928 { 929 this.clustered = clustered; 930 } 931 932 public void setConfigurationName(String configurationName) 933 { 934 this.configurationName = configurationName; 935 } 936 937 public void setContainerManagedTx(boolean containerManagedTx) 938 { 939 this.containerManagedTx = containerManagedTx; 940 } 941 942 public void setDepends(Collection depends) 943 { 944 this.depends = depends; 945 } 946 947 public void setEjbClass(String ejbClass) 948 { 949 this.ejbClass = ejbClass; 950 } 951 952 public void setEjbLocalReferences(HashMap ejbLocalReferences) 953 { 954 this.ejbLocalReferences = ejbLocalReferences; 955 } 956 957 public void setEjbReferences(HashMap ejbReferences) 958 { 959 this.ejbReferences = ejbReferences; 960 } 961 962 public void setEjbTimeoutIdentity(SecurityIdentityMetaData ejbTimeoutIdentity) 963 { 964 this.ejbTimeoutIdentity = ejbTimeoutIdentity; 965 } 966 967 public void setEnvironmentEntries(ArrayList environmentEntries) 968 { 969 this.environmentEntries = environmentEntries; 970 } 971 972 public void setExceptionRollback(boolean exceptionRollback) 973 { 974 this.exceptionRollback = exceptionRollback; 975 } 976 977 public void setExcludedMethods(ArrayList excludedMethods) 978 { 979 this.excludedMethods = excludedMethods; 980 } 981 982 public void setInvokerBindings(HashMap invokerBindings) 983 { 984 this.invokerBindings = invokerBindings; 985 } 986 987 public void setJndiName(String jndiName) 988 { 989 this.jndiName = jndiName; 990 } 991 992 public void setLocalJndiName(String localJndiName) 993 { 994 this.localJndiName = localJndiName; 995 } 996 997 public void setMessageDestinationReferences(HashMap messageDestinationReferences) 998 { 999 this.messageDestinationReferences = messageDestinationReferences; 1000 } 1001 1002 public void setPermissionMethods(ArrayList permissionMethods) 1003 { 1004 this.permissionMethods = permissionMethods; 1005 } 1006 1007 public void setResourceEnvReferences(HashMap resourceEnvReferences) 1008 { 1009 this.resourceEnvReferences = resourceEnvReferences; 1010 } 1011 1012 public void setResourceReferences(HashMap resourceReferences) 1013 { 1014 this.resourceReferences = resourceReferences; 1015 } 1016 1017 public void setSecurityProxy(String securityProxy) 1018 { 1019 this.securityProxy = securityProxy; 1020 } 1021 1022 public void setSecurityRoleReferences(ArrayList securityRoleReferences) 1023 { 1024 this.securityRoleReferences = securityRoleReferences; 1025 } 1026 1027 public void setServiceReferences(HashMap serviceReferences) 1028 { 1029 this.serviceReferences = serviceReferences; 1030 } 1031 1032 public void setTimerPersistence(boolean timerPersistence) 1033 { 1034 this.timerPersistence = timerPersistence; 1035 } 1036 1037 public void setTransactionMethods(ArrayList transactionMethods) 1038 { 1039 this.transactionMethods = transactionMethods; 1040 } 1041 1042 1046 public void importEjbJarXml(Element element) 1047 throws DeploymentException 1048 { 1049 ejbName = getElementContent(getUniqueChild(element, "ejb-name")); 1051 1052 if (isMessageDriven() == false) 1054 { 1055 homeClass = getElementContent(getOptionalChild(element, "home")); 1056 remoteClass = getElementContent(getOptionalChild(element, "remote")); 1057 localHomeClass = getElementContent(getOptionalChild(element, 1058 "local-home")); 1059 localClass = getElementContent(getOptionalChild(element, "local")); 1060 } 1061 ejbClass = getElementContent(getUniqueChild(element, "ejb-class")); 1062 1063 Iterator iterator = getChildrenByTagName(element, "env-entry"); 1065 1066 while (iterator.hasNext()) 1067 { 1068 Element envEntry = (Element )iterator.next(); 1069 1070 EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData(); 1071 envEntryMetaData.importEjbJarXml(envEntry); 1072 1073 environmentEntries.add(envEntryMetaData); 1074 } 1075 1076 iterator = getChildrenByTagName(element, "ejb-ref"); 1078 1079 while (iterator.hasNext()) 1080 { 1081 Element ejbRef = (Element )iterator.next(); 1082 1083 EjbRefMetaData ejbRefMetaData = new EjbRefMetaData(); 1084 ejbRefMetaData.importEjbJarXml(ejbRef); 1085 1086 ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData); 1087 } 1088 1089 iterator = getChildrenByTagName(element, "ejb-local-ref"); 1091 1092 while (iterator.hasNext()) 1093 { 1094 Element ejbLocalRef = (Element )iterator.next(); 1095 1096 EjbLocalRefMetaData ejbLocalRefMetaData = new EjbLocalRefMetaData(); 1097 ejbLocalRefMetaData.importEjbJarXml(ejbLocalRef); 1098 1099 ejbLocalReferences.put(ejbLocalRefMetaData.getName(), 1100 ejbLocalRefMetaData); 1101 } 1102 1103 iterator = MetaData.getChildrenByTagName(element, "service-ref"); 1105 while (iterator.hasNext()) 1106 { 1107 Element serviceRef = (Element )iterator.next(); 1108 if (ServiceRefMetaData.isValidDoctype(serviceRef)) 1109 { 1110 ServiceRefMetaData refMetaData = new ServiceRefMetaData(application.getResourceCl()); 1111 refMetaData.importStandardXml(serviceRef); 1112 serviceReferences.put(refMetaData.getServiceRefName(), refMetaData); 1113 } 1114 } 1115 1116 iterator = getChildrenByTagName(element, "security-role-ref"); 1118 1119 while (iterator.hasNext()) 1120 { 1121 Element secRoleRef = (Element )iterator.next(); 1122 SecurityRoleRefMetaData securityRoleRefMetaData = new SecurityRoleRefMetaData(); 1123 securityRoleRefMetaData.importEjbJarXml(secRoleRef); 1124 securityRoleReferences.add(securityRoleRefMetaData); 1125 } 1126 1127 Element securityIdentityElement = getOptionalChild(element, 1129 "security-identity"); 1130 if (securityIdentityElement != null) 1131 { 1132 securityIdentity = new SecurityIdentityMetaData(); 1133 securityIdentity.importEjbJarXml(securityIdentityElement); 1134 } 1135 1136 iterator = getChildrenByTagName(element, "resource-ref"); 1138 1139 while (iterator.hasNext()) 1140 { 1141 Element resourceRef = (Element )iterator.next(); 1142 1143 ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData(); 1144 resourceRefMetaData.importEjbJarXml(resourceRef); 1145 1146 resourceReferences.put(resourceRefMetaData.getRefName(), 1147 resourceRefMetaData); 1148 } 1149 1150 iterator = getChildrenByTagName(element, "resource-env-ref"); 1152 while (iterator.hasNext()) 1153 { 1154 Element resourceRef = (Element )iterator.next(); 1155 ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData(); 1156 refMetaData.importEjbJarXml(resourceRef); 1157 resourceEnvReferences.put(refMetaData.getRefName(), refMetaData); 1158 } 1159 1160 iterator = getChildrenByTagName(element, "message-destination-ref"); 1162 while (iterator.hasNext()) 1163 { 1164 Element messageDestinationRef = (Element )iterator.next(); 1165 1166 MessageDestinationRefMetaData messageDestinationRefMetaData = new MessageDestinationRefMetaData(); 1167 messageDestinationRefMetaData.importEjbJarXml(messageDestinationRef); 1168 1169 messageDestinationReferences.put(messageDestinationRefMetaData.getRefName(), messageDestinationRefMetaData); 1170 } 1171 } 1172 1173 1177 public void importJbossXml(Element element) throws DeploymentException 1178 { 1179 1181 jndiName = getElementContent(getOptionalChild(element, "jndi-name")); 1183 1184 localJndiName = getElementContent(getOptionalChild(element, "local-jndi-name")); 1187 1188 String callByValueElt = getElementContent(getOptionalChild(element, "call-by-value"), (callByValue ? "True" : "False")); 1190 callByValue = callByValueElt.equalsIgnoreCase("True"); 1191 1192 configurationName = getElementContent(getOptionalChild(element, "configuration-name")); 1194 if (configurationName != null && getApplicationMetaData().getConfigurationMetaDataByName(configurationName) == null) 1195 { 1196 throw new DeploymentException("configuration '" + configurationName + "' not found in standardjboss.xml or jboss.xml"); 1197 } 1198 1199 securityProxy = getElementContent(getOptionalChild(element, "security-proxy"), securityProxy); 1201 1202 exceptionRollback = MetaData.getOptionalChildBooleanContent(element, "exception-on-rollback", false); 1204 1205 timerPersistence = MetaData.getOptionalChildBooleanContent(element, "timer-persistence", true); 1207 1208 Iterator iterator = getChildrenByTagName(element, "resource-ref"); 1210 while (iterator.hasNext()) 1211 { 1212 Element resourceRef = (Element )iterator.next(); 1213 String resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name")); 1214 ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)resourceReferences.get(resRefName); 1215 1216 if (resourceRefMetaData == null) 1217 { 1218 throw new DeploymentException("resource-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml"); 1219 } 1220 resourceRefMetaData.importJbossXml(resourceRef); 1221 } 1222 1223 iterator = getChildrenByTagName(element, "resource-env-ref"); 1225 while (iterator.hasNext()) 1226 { 1227 Element resourceRef = (Element )iterator.next(); 1228 String resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name")); 1229 ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)resourceEnvReferences.get(resRefName); 1230 if (refMetaData == null) 1231 { 1232 throw new DeploymentException("resource-env-ref " + resRefName + " found in jboss.xml but not in ejb-jar.xml"); 1233 } 1234 refMetaData.importJbossXml(resourceRef); 1235 } 1236 1237 iterator = getChildrenByTagName(element, "message-destination-ref"); 1239 while (iterator.hasNext()) 1240 { 1241 Element messageDestinationRef = (Element )iterator.next(); 1242 String messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name")); 1243 MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData)messageDestinationReferences.get(messageDestinationRefName); 1244 if (messageDestinationRefMetaData == null) 1245 throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss.xml but not in ejb-jar.xml"); 1246 messageDestinationRefMetaData.importJbossXml(messageDestinationRef); 1247 } 1248 1249 iterator = getChildrenByTagName(element, "ejb-ref"); 1251 while (iterator.hasNext()) 1252 { 1253 Element ejbRef = (Element )iterator.next(); 1254 String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name")); 1255 EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName); 1256 if (ejbRefMetaData == null) 1257 { 1258 throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml"); 1259 } 1260 ejbRefMetaData.importJbossXml(ejbRef); 1261 } 1262 1263 1264 iterator = getChildrenByTagName(element, "ejb-local-ref"); 1266 while (iterator.hasNext()) 1267 { 1268 Element ejbLocalRef = (Element )iterator.next(); 1269 String ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name")); 1270 1271 EjbLocalRefMetaData ejbLocalRefMetaData = getEjbLocalRefByName(ejbLocalRefName); 1272 if (ejbLocalRefMetaData == null) 1273 { 1274 throw new DeploymentException("ejb-local-ref " + ejbLocalRefName + " found in jboss.xml but not in ejb-jar.xml"); 1275 } 1276 ejbLocalRefMetaData.importJbossXml(ejbLocalRef); 1277 } 1278 1279 iterator = MetaData.getChildrenByTagName(element, "service-ref"); 1281 while (iterator.hasNext()) 1282 { 1283 Element serviceRef = (Element )iterator.next(); 1284 String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name"); 1285 ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName); 1286 if (refMetaData == null && ServiceRefMetaData.isValidDoctype(serviceRef)) 1287 { 1288 throw new DeploymentException("service-ref " + serviceRefName + " found in jboss.xml but not in ejb-jar.xml"); 1289 } 1290 if (refMetaData != null) 1291 refMetaData.importJBossXml(serviceRef); 1292 } 1293 1294 Element securityIdentityElement = getOptionalChild(element, "security-identity"); 1296 if (securityIdentityElement != null) 1297 { 1298 if (securityIdentity == null) 1299 throw new DeploymentException(ejbName + ", security-identity in jboss.xml has no match in ejb-jar.xml"); 1300 String runAsPrincipal = getElementContent(getUniqueChild(securityIdentityElement, 1301 "run-as-principal"), securityIdentity.getRunAsPrincipalName()); 1302 securityIdentity.setRunAsPrincipalName(runAsPrincipal); 1303 } 1304 1305 Element ejbTimeoutIdentityElement = getOptionalChild(element, "ejb-timeout-identity"); 1307 if (ejbTimeoutIdentityElement != null) 1308 { 1309 ejbTimeoutIdentity = new SecurityIdentityMetaData(); 1310 String runAsPrincipal = getElementContent(getUniqueChild(ejbTimeoutIdentityElement, 1311 "run-as-principal"), null); 1312 ejbTimeoutIdentity.setRunAsRoleName("ejbTimeout"); 1313 if( runAsPrincipal != null && runAsPrincipal.length() > 0 ) 1314 ejbTimeoutIdentity.setRunAsPrincipalName(runAsPrincipal); 1315 else 1316 ejbTimeoutIdentity.setUseCallerIdentity(true); 1317 } 1318 1319 Element mas = getOptionalChild(element, "method-attributes"); 1321 if (mas != null) 1322 { 1323 iterator = getChildrenByTagName(mas, "method"); 1325 while (iterator.hasNext()) 1326 { 1327 MethodAttributes ma = new MethodAttributes(); 1328 Element maNode = (Element )iterator.next(); 1329 ma.pattern = getElementContent(getUniqueChild(maNode, "method-name")); 1330 ma.readOnly = getOptionalChildBooleanContent(maNode, "read-only"); 1331 ma.idempotent = getOptionalChildBooleanContent(maNode, "idempotent"); 1332 String txTimeout = getOptionalChildContent(maNode, "transaction-timeout"); 1333 try 1334 { 1335 if (txTimeout != null && txTimeout.length() > 0) 1336 ma.txTimeout = Integer.parseInt(txTimeout); 1337 } 1338 catch (Exception ignore) 1339 { 1340 log.debug("Ignoring transaction-timeout '" + txTimeout + "'", ignore); 1341 } 1342 methodAttributes.add(ma); 1343 } 1344 } 1345 1346 Element inv = getOptionalChild(element, "invoker-bindings"); 1350 if (inv != null) 1351 { 1352 iterator = getChildrenByTagName(inv, "invoker"); 1354 invokerBindings = new HashMap (); 1355 while (iterator.hasNext()) 1356 { 1357 Element node = (Element )iterator.next(); 1358 String invokerBindingName = getUniqueChildContent(node, "invoker-proxy-binding-name"); 1359 String jndiBinding = getOptionalChildContent(node, "jndi-name"); 1360 1361 if (jndiBinding == null) 1362 { 1363 jndiBinding = getJndiName(); } 1365 invokerBindings.put(invokerBindingName, jndiBinding); 1366 1367 Iterator ejbrefiterator = getChildrenByTagName(node, "ejb-ref"); 1369 while (ejbrefiterator.hasNext()) 1370 { 1371 Element ejbRef = (Element )ejbrefiterator.next(); 1372 String ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name")); 1373 EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName); 1374 if (ejbRefMetaData == null) 1375 { 1376 throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss.xml but not in ejb-jar.xml"); 1377 } 1378 ejbRefMetaData.importJbossXml(invokerBindingName, ejbRef); 1379 } 1380 } 1381 } 1382 1383 String clusteredElt = getElementContent(getOptionalChild(element, "clustered"), (clustered ? "True" : "False")); 1386 clustered = clusteredElt.equalsIgnoreCase("True"); 1387 1388 Element clusterConfigElement = getOptionalChild(element, "cluster-config"); 1389 if (clusterConfigElement != null) 1390 { 1391 this.clusterConfig = new ClusterConfigMetaData(); 1392 clusterConfig.init(this); 1393 clusterConfig.importJbossXml(clusterConfigElement); 1394 } 1395 1396 for (Iterator dependsElements = getChildrenByTagName(element, "depends"); dependsElements.hasNext();) 1398 { 1399 Element dependsElement = (Element )dependsElements.next(); 1400 String dependsName = getElementContent(dependsElement); 1401 depends.add(ObjectNameFactory.create(dependsName)); 1402 } 1404 Element iorSecurityConfigEl = getOptionalChild(element, "ior-security-config"); 1406 if (iorSecurityConfigEl != null) 1407 { 1408 iorSecurityConfig = new IorSecurityConfigMetaData(iorSecurityConfigEl); 1409 } 1410 1411 } 1412} 1413 | Popular Tags |