001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.ejb.gen;
031:
032: import com.caucho.ejb.cfg.*;
033: import com.caucho.java.JavaWriter;
034: import com.caucho.util.L10N;
035:
036: import java.io.*;
037: import java.lang.reflect.*;
038: import java.util.*;
039: import javax.annotation.security.*;
040: import javax.ejb.*;
041: import javax.interceptor.*;
042:
043: /**
044: * Represents a stateless local business method
045: */
046: public class StatelessLocalMethod extends BusinessMethodGenerator {
047: private ApiClass _ejbClass;
048:
049: public StatelessLocalMethod(ApiClass ejbClass, StatelessView view,
050: ApiMethod apiMethod, Method implMethod, int index) {
051: super (view, apiMethod, implMethod, index);
052:
053: _ejbClass = ejbClass;
054: }
055:
056: /**
057: * Session bean default is REQUIRED
058: */
059: @Override
060: public void introspect(Method apiMethod, Method implMethod) {
061: getXa().setTransactionType(TransactionAttributeType.REQUIRED);
062:
063: super .introspect(apiMethod, implMethod);
064: }
065:
066: /**
067: * Returns true if any interceptors enhance the business method
068: */
069: @Override
070: public boolean isEnhanced() {
071: return true;
072: }
073:
074: /**
075: * Generates the underlying bean instance
076: */
077: protected void generatePreCall(JavaWriter out) throws IOException {
078: /*
079: out.println("Thread thread = Thread.currentThread();");
080: out.println("ClassLoader oldLoader = thread.getContextClassLoader();");
081: out.println("try {");
082: out.pushDepth();
083: out.println("thread.setContextClassLoader(_context.getStatelessServer().getClassLoader());");
084: */
085: }
086:
087: /**
088: * Generates the underlying bean instance
089: */
090: protected void generateThis(JavaWriter out) throws IOException {
091: out.print("this");
092: }
093:
094: /**
095: * Generates the underlying bean instance
096: */
097: protected void generateSuper(JavaWriter out) throws IOException {
098: out.print("super");
099: }
100:
101: /**
102: * Generates the underlying bean instance
103: */
104: protected void generatePostCall(JavaWriter out) throws IOException {
105: /*
106: out.popDepth();
107: out.println("} finally {");
108: out.println(" thread.setContextClassLoader(oldLoader);");
109: out.println("}");
110: */
111: }
112: }
|