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 stateful view
044: */
045: public class StatefulRemoteView extends StatefulObjectView {
046: private static final L10N L = new L10N(StatefulRemoteView.class);
047:
048: public StatefulRemoteView(StatefulGenerator bean, ApiClass api) {
049: super (bean, api);
050: }
051:
052: protected String getViewClassName() {
053: return getApi().getSimpleName() + "__EJBRemote";
054: }
055:
056: @Override
057: protected void generateExtends(JavaWriter out) throws IOException {
058: /*
059: if (EJBLocalObject.class.isAssignableFrom(getApi().getJavaClass()))
060: out.println(" extends StatefulObject21");
061: else if (EJBObject.class.isAssignableFrom(getApi().getJavaClass()))
062: out.println(" extends StatefulObject21");
063: else
064: out.println(" extends StatefulObject");
065: */
066: out.println(" extends StatefulObject");
067: }
068:
069: /**
070: * Generates prologue for the context.
071: */
072: public void generateContextPrologue(JavaWriter out)
073: throws IOException {
074: out.println();
075: out
076: .println("private " + getViewClassName()
077: + " _remoteObject;");
078:
079: if (EJBObject.class.isAssignableFrom(getApi().getJavaClass())) {
080: out.println();
081: out.println("@Override");
082: out.println("public EJBObject getEJBObject()");
083: out.println("{");
084: out.println(" if (_remoteObject != null)");
085: out.println(" return _remoteObject;");
086: out.println(" else");
087: out.println(" return super.getEJBObject();");
088: out.println("}");
089: }
090:
091: out.println();
092: out.println("public " + getSessionBean().getClassName() + "("
093: + getContextClassName() + " context, "
094: + getViewClassName() + " remoteObject)");
095: out.println("{");
096: out.println(" this(context);");
097: out.println();
098: out.println(" _remoteObject = remoteObject;");
099: out.println("}");
100: }
101:
102: @Override
103: public void generateClassContent(JavaWriter out) throws IOException {
104: super.generateClassContent(out);
105: }
106: }
|