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.config.*;
033: import com.caucho.ejb.cfg.*;
034: import com.caucho.java.JavaWriter;
035: import com.caucho.util.L10N;
036:
037: import javax.ejb.*;
038: import java.io.IOException;
039: import java.lang.reflect.*;
040: import java.util.*;
041:
042: /**
043: * Represents a public interface to a bean, e.g. a local stateless view
044: */
045: public class StatelessLocalHomeView extends StatelessHomeView {
046: private static final L10N L = new L10N(StatelessLocalHomeView.class);
047:
048: public StatelessLocalHomeView(StatelessGenerator bean, ApiClass api) {
049: super (bean, api);
050: }
051:
052: @Override
053: protected String getViewClassName() {
054: return getApi().getSimpleName() + "__EJBLocalHome";
055: }
056:
057: @Override
058: protected void generateExtends(JavaWriter out) throws IOException {
059: out.println(" extends StatelessHome");
060: }
061:
062: /**
063: * Generates prologue for the context.
064: */
065: public void generateContextPrologue(JavaWriter out)
066: throws IOException {
067: out.println();
068: out.println("private " + getViewClassName() + " _localHome;");
069:
070: out.println();
071: out.println("@Override");
072: out.println("public EJBHome getEJBHome()");
073: out.println("{");
074: out.println(" return _localHome;");
075: out.println("}");
076: }
077:
078: /**
079: * Generates context home's constructor
080: */
081: @Override
082: public void generateContextHomeConstructor(JavaWriter out)
083: throws IOException {
084: out.println("_localHome = new " + getViewClassName()
085: + "(this);");
086: }
087:
088: /**
089: * Generates context home's constructor
090: */
091: @Override
092: public void generateContextObjectConstructor(JavaWriter out)
093: throws IOException {
094: out.println("_localHome = context._localHome;");
095: }
096:
097: /**
098: * Generates code to create the provider
099: */
100: public void generateCreateProvider(JavaWriter out, String var)
101: throws IOException {
102: out.println();
103: out.println("if (" + var + " == " + getApi().getName()
104: + ".class)");
105: out.println(" return _localHome;");
106: }
107: }
|