PageRenderTime 37ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/jacorb/src/main/java/org/jboss/as/jacorb/rmi/ExceptionAnalysis.java

#
Java | 87 lines | 38 code | 15 blank | 34 comment | 5 complexity | 649be74c3bbf2c47653432592815266a MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2008, Red Hat Middleware LLC, and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.jacorb.rmi;
  23. import org.jboss.as.jacorb.JacORBMessages;
  24. /**
  25. * Exception analysis.
  26. * <p/>
  27. * Routines here are conforming to the "Java(TM) Language to IDL Mapping
  28. * Specification", version 1.1 (01-06-07).
  29. *
  30. * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
  31. */
  32. public class ExceptionAnalysis extends ValueAnalysis {
  33. private static WorkCacheManager cache
  34. = new WorkCacheManager(ExceptionAnalysis.class);
  35. private String exceptionRepositoryId;
  36. public static ExceptionAnalysis getExceptionAnalysis(Class cls)
  37. throws RMIIIOPViolationException {
  38. return (ExceptionAnalysis) cache.getAnalysis(cls);
  39. }
  40. protected ExceptionAnalysis(Class cls) {
  41. super(cls);
  42. }
  43. protected void doAnalyze() throws RMIIIOPViolationException {
  44. super.doAnalyze();
  45. if (!Exception.class.isAssignableFrom(cls) ||
  46. RuntimeException.class.isAssignableFrom(cls))
  47. throw JacORBMessages.MESSAGES.badRMIIIOPExceptionType(cls.getName(), "1.2.6");
  48. // calculate exceptionRepositoryId
  49. StringBuffer b = new StringBuffer("IDL:");
  50. String pkgName = cls.getPackage().getName();
  51. while (!"".equals(pkgName)) {
  52. int idx = pkgName.indexOf('.');
  53. String n = (idx == -1) ? pkgName : pkgName.substring(0, idx);
  54. b.append(Util.javaToIDLName(n)).append('/');
  55. pkgName = (idx == -1) ? "" : pkgName.substring(idx + 1);
  56. }
  57. String base = cls.getName();
  58. base = base.substring(base.lastIndexOf('.') + 1);
  59. if (base.endsWith("Exception"))
  60. base = base.substring(0, base.length() - 9);
  61. base = Util.javaToIDLName(base + "Ex");
  62. b.append(base).append(":1.0");
  63. exceptionRepositoryId = b.toString();
  64. }
  65. /**
  66. * Return the repository ID for the mapping of this analysis
  67. * to an exception.
  68. */
  69. public String getExceptionRepositoryId() {
  70. return exceptionRepositoryId;
  71. }
  72. }