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.gen21;
031:
032: import com.caucho.ejb.cfg21.EjbEntityBean;
033: import com.caucho.ejb.gen.*;
034: import com.caucho.ejb.cfg.*;
035: import com.caucho.java.gen.BaseMethod;
036: import com.caucho.java.gen.ClassComponent;
037: import com.caucho.util.L10N;
038:
039: import java.util.ArrayList;
040:
041: /**
042: * Assembles the generator structure.
043: */
044: public class EntityAssembler extends BeanAssembler {
045: private static final L10N L = new L10N(EntityAssembler.class);
046:
047: private EjbEntityBean _bean;
048:
049: protected EntityBean _entityBean;
050:
051: public EntityAssembler(EjbEntityBean bean, String fullClassName) {
052: super (bean, fullClassName);
053:
054: _bean = bean;
055:
056: setSuperClass();
057: }
058:
059: /**
060: * Sets the superclas.
061: */
062: protected void setSuperClass() {
063: _genClass.setSuperClassName("QEntityContext");
064: }
065:
066: /**
067: * Adds the header component.
068: */
069: public void addHeaderComponent(ApiClass beanClass,
070: String contextClassName, String implClassName) {
071: _entityBean = new EntityBean(beanClass, contextClassName,
072: implClassName);
073: _entityBean.setBean(_bean);
074:
075: _genClass.addComponent(_entityBean);
076: }
077:
078: /**
079: * Returns the entity bean.
080: */
081: public EjbEntityBean getBean() {
082: return _bean;
083: }
084:
085: /**
086: * Adds the bean method
087: */
088: public void addMethod(BaseMethod method) {
089: _entityBean.addMethod(method);
090: }
091:
092: /**
093: * Adds the bean component
094: */
095: public void addComponent(ClassComponent component) {
096: _entityBean.addComponent(component);
097: }
098:
099: /**
100: * Creates the home view.
101: */
102: public ViewClass createHomeView(ApiClass homeClass,
103: String fullClassName, String viewPrefix) {
104: EntityHomeView homeView = new EntityHomeView(homeClass,
105: fullClassName, viewPrefix, false);
106:
107: _genClass.addComponent(homeView);
108:
109: return homeView;
110: }
111:
112: /**
113: * Creates the home view.
114: */
115: public ViewClass createView(ArrayList<ApiClass> homeClass,
116: String fullClassName, String viewPrefix, String viewSuffix) {
117: EntityView view = new EntityView(homeClass.get(0),
118: fullClassName, viewPrefix);
119:
120: _genClass.addComponent(view);
121:
122: return view;
123: }
124:
125: /**
126: * Creates the home view.
127: */
128: public ViewClass createRemoteView(ArrayList<ApiClass> homeClass,
129: String fullClassName, String viewPrefix, String viewSuffix) {
130: EntityView view = new EntityView(homeClass.get(0),
131: fullClassName, viewPrefix);
132:
133: _genClass.addComponent(view);
134:
135: return view;
136: }
137: }
|