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 remote stateless view
044: */
045: public class StatelessRemoteHomeView extends StatelessHomeView {
046: private static final L10N L = new L10N(
047: StatelessRemoteHomeView.class);
048:
049: public StatelessRemoteHomeView(StatelessGenerator bean, ApiClass api) {
050: super (bean, api);
051: }
052:
053: @Override
054: protected String getViewClassName() {
055: return getApi().getSimpleName() + "__EJBRemoteHome";
056: }
057:
058: @Override
059: protected void generateExtends(JavaWriter out) throws IOException {
060: out.println(" extends StatelessHome");
061: }
062:
063: /**
064: * Generates prologue for the context.
065: */
066: public void generateContextPrologue(JavaWriter out)
067: throws IOException {
068: out.println();
069: out.println("private " + getViewClassName() + " _remoteHome;");
070:
071: out.println();
072: out.println("@Override");
073: out.println("public EJBHome getEJBHome()");
074: out.println("{");
075: out.println(" return _remoteHome;");
076: out.println("}");
077: }
078:
079: /**
080: * Generates context home's constructor
081: */
082: @Override
083: public void generateContextHomeConstructor(JavaWriter out)
084: throws IOException {
085: out.println("_remoteHome = new " + getViewClassName()
086: + "(this);");
087: }
088:
089: /**
090: * Generates context home's constructor
091: */
092: @Override
093: public void generateContextObjectConstructor(JavaWriter out)
094: throws IOException {
095: out.println("_remoteHome = context._remoteHome;");
096: }
097:
098: /**
099: * Generates code to create the provider
100: */
101: public void generateCreateProvider(JavaWriter out, String var)
102: throws IOException {
103: out.println();
104: out.println("if (" + var + " == " + getApi().getName()
105: + ".class)");
106: out.println(" return _remoteHome;");
107: }
108: }
|