01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.metadata;
23:
24: /**
25: *
26: * Provides meta-data for method-attributes
27: * <method-attributes>
28: * <method>
29: * <method-name>get*</method-name>
30: * <read-only>true</read-only>
31: * <idempotent>true</idempotent>
32: * <transaction-timeout>100</tranaction-timeout>
33: * </method>
34: * </method-attributes>
35: *
36: * @author <a href="pete@subx.com">Peter Murray</a>
37: *
38: * @version $Revision: 57209 $
39: *
40: * <p><b>Revisions:</b><br>
41: * <p><b>2001/04/10: peter</b>
42: * <ol>
43: * <li>Initial revision
44: * </ol>
45: */
46: public class MethodAttributes {
47: String pattern;
48: boolean readOnly;
49: boolean idempotent;
50: int txTimeout;
51:
52: public static MethodAttributes kDefaultMethodAttributes;
53:
54: static {
55: kDefaultMethodAttributes = new MethodAttributes();
56: kDefaultMethodAttributes.pattern = "*";
57: kDefaultMethodAttributes.readOnly = false;
58: kDefaultMethodAttributes.idempotent = false;
59: kDefaultMethodAttributes.txTimeout = 0;
60: }
61:
62: public boolean patternMatches(String methodName) {
63: int ct, end;
64:
65: end = pattern.length();
66:
67: if (end > methodName.length())
68: return false;
69:
70: for (ct = 0; ct < end; ct++) {
71: char c = pattern.charAt(ct);
72: if (c == '*')
73: return true;
74: if (c != methodName.charAt(ct))
75: return false;
76: }
77: return ct == methodName.length();
78: }
79:
80: public boolean isReadOnly() {
81: return readOnly;
82: }
83:
84: public boolean isIdempotent() {
85: return idempotent;
86: }
87:
88: public int getTransactionTimeout() {
89: return txTimeout;
90: }
91: }
|