KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > cfg > ContainerTransaction


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.ejb.cfg;
30
31 import com.caucho.config.ConfigException;
32 import com.caucho.util.L10N;
33
34 import javax.annotation.PostConstruct;
35
36 /**
37  * Configuraton for a method transaction
38  */

39 public class ContainerTransaction {
40   private static final L10N L = new L10N(ContainerTransaction.class);
41
42   private EjbConfig _config;
43   private String JavaDoc _location;
44   private MethodSignature _method;
45   private String JavaDoc _trans;
46
47   /**
48    * Creates a new cmp-relation
49    */

50   public ContainerTransaction(EjbConfig config)
51   {
52     _config = config;
53   }
54
55   public void setConfigLocation(String JavaDoc filename, int line)
56   {
57     _location = filename + ":" + line;
58   }
59
60   public void setDescription(String JavaDoc description)
61   {
62   }
63
64   public void setMethod(MethodSignature method)
65   {
66     _method = method;
67   }
68
69   public void setTransAttribute(String JavaDoc trans)
70     throws ConfigException
71   {
72     if (trans.equals("Required")) {
73     }
74     else if (trans.equals("RequiresNew")) {
75     }
76     else if (trans.equals("Mandatory")) {
77     }
78     else if (trans.equals("NotSupported")) {
79     }
80     else if (trans.equals("Never")) {
81     }
82     else if (trans.equals("Supports")) {
83     }
84     else
85       throw new ConfigException(L.l("`{0}' is an unknown transaction type. The transaction types are:\n Required - creates a new transaction if none is active.\n RequiresNew - always creates a new transaction.\n Mandatory - requires an active transaction.\n NotSupported - suspends any active transaction.\n Never - forbids any active transaction.\n Supports - allows a transaction or no transaction.", trans));
86
87     _trans = trans;
88   }
89
90   @PostConstruct
91   public void init()
92     throws ConfigException
93   {
94     EjbBean bean = _config.getBeanConfig(_method.getEJBName());
95
96     if (bean == null)
97       throw new ConfigException(L.l("`{0}' is an unknown entity bean.",
98                                     _method.getEJBName()));
99
100     EjbMethodPattern method = bean.createMethod(_method);
101
102     method.setTransAttribute(_trans);
103   }
104 }
105
Popular Tags