001: /* WfProcessIteratorSSBean.java */
002: package org.enhydra.shark.ejb;
003:
004: import java.rmi.RemoteException;
005:
006: import javax.ejb.EJBException;
007: import javax.ejb.EJBObject;
008: import javax.ejb.SessionBean;
009: import javax.ejb.SessionContext;
010: import javax.naming.Context;
011: import javax.naming.InitialContext;
012: import javax.rmi.PortableRemoteObject;
013:
014: import org.enhydra.shark.api.client.wfmodel.WfProcess;
015: import org.enhydra.shark.api.client.wfmodel.WfProcessIterator;
016:
017: /**
018: * @ejb.bean
019: * name="WfProcessIteratorSS"
020: * type="Stateful"
021: * display-name="WfProcessIterator"
022: * jndi-name="org/enhydra/shark/ejb/WfProcessIteratorSS"
023: * local-jndi-name="org/enhydra/shark/ejb/WfProcessIteratorSSLocal"
024: * transaction-type="Container"
025: * view-type="both"
026: * local-business-interface="org.enhydra.shark.api.client.wfmodel.WfProcessIterator"
027: *
028: * @ejb.ejb-ref ejb-name="WfProcessSS"
029: * view-type="both"
030: * ref-name="org/enhydra/shark/ejb/WfProcessSS"
031: *
032: * @ejb:interface
033: * extends="org.enhydra.shark.api.client.wfmodel.WfProcessIterator,javax.ejb.EJBObject"
034: *
035: * @ejb:transaction
036: * type="Required"
037: *
038: * @jonas:bean
039: * ejb-name="WfProcessIteratorSS"
040: * jndi-name="org/enhydra/shark/ejb/WfProcessIteratorSS"
041: *
042: * OMG definition: The WfProcessIterator interface specializes the WfBase::BaseIterator
043: * interface and adds specific process operations. The following attributes can be used in
044: * query expressions: key, name, priority, description, state.
045: * <p>
046: * We extended OMG's interface by duplicating methods, and adding additional parameter
047: * that represents transaction. If you use methods without SharkTransaction parameter, the
048: * transaction will be implicitly created, and if you use it with SharkTransaction
049: * parameter you must obey to some rules explained in HowTo documentation.
050: * <p>
051: * Also, look at our implementation API documentation of this interface to see which
052: * additional attributes can be used in query expressions.
053: *
054: * @author V.Puskas
055: * @author S.Bojanic
056: * @author T.Jovanovic
057: * @version 0.1
058: */
059: public abstract class WfProcessIteratorSSBean extends
060: BaseIteratorSSBean implements WfProcessIterator, SessionBean {
061:
062: private SessionContext context;
063:
064: /**
065: * @ejb:interface-method
066: * view-type="both"
067: */
068: public WfProcess get_next_object() throws Exception {
069: WfProcess wfshark = ((WfProcessIterator) sharkObj)
070: .get_next_object();
071: WfProcessSS wf = null;
072: try {
073: Context initialContext = EJBJNDIContext.getInstance()
074: .getInitialContext();
075: wf = ((org.enhydra.shark.ejb.WfProcessSSHome) PortableRemoteObject
076: .narrow(
077: initialContext
078: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
079: org.enhydra.shark.ejb.WfProcessSSHome.class))
080: .create(wfshark);
081: return (WfProcessSS) wf.getPassedEJBObject();
082: } catch (Exception ex) {
083: throw new EJBException(ex);
084: }
085: }
086:
087: /**
088: * @ejb:interface-method
089: * view-type="both"
090: */
091: public WfProcess get_previous_object() throws Exception {
092: WfProcess wfshark = ((WfProcessIterator) sharkObj)
093: .get_previous_object();
094: WfProcessSS wf = null;
095: try {
096: Context initialContext = EJBJNDIContext.getInstance()
097: .getInitialContext();
098: wf = ((org.enhydra.shark.ejb.WfProcessSSHome) PortableRemoteObject
099: .narrow(
100: initialContext
101: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
102: org.enhydra.shark.ejb.WfProcessSSHome.class))
103: .create(wfshark);
104: return (WfProcessSS) wf.getPassedEJBObject();
105: } catch (Exception ex) {
106: throw new EJBException(ex);
107: }
108: }
109:
110: /**
111: * @ejb:interface-method
112: * view-type="both"
113: */
114: public WfProcess[] get_next_n_sequence(int max_number)
115: throws Exception {
116: WfProcess[] wfsshark = ((WfProcessIterator) sharkObj)
117: .get_next_n_sequence(max_number);
118: WfProcessSSHome home = null;
119: InitialContext initialContext = EJBJNDIContext.getInstance()
120: .getInitialContext();
121: home = (WfProcessSSHome) PortableRemoteObject.narrow(
122: initialContext
123: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
124: org.enhydra.shark.ejb.WfProcessSSHome.class);
125: int len = wfsshark.length;
126: WfProcessSS[] remotes = new WfProcessSS[len];
127: for (int i = 0; i < len; i++) {
128: remotes[i] = (WfProcessSS) (home.create(wfsshark[i]))
129: .getPassedEJBObject();
130: }
131: return remotes;
132: }
133:
134: /**
135: * @ejb:interface-method
136: * view-type="both"
137: */
138: public WfProcess[] get_previous_n_sequence(int max_number)
139: throws Exception {
140: WfProcess[] wfsshark = ((WfProcessIterator) sharkObj)
141: .get_previous_n_sequence(max_number);
142: WfProcessSSHome home = null;
143: InitialContext initialContext = EJBJNDIContext.getInstance()
144: .getInitialContext();
145: home = (WfProcessSSHome) PortableRemoteObject.narrow(
146: initialContext
147: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
148: org.enhydra.shark.ejb.WfProcessSSHome.class);
149: int len = wfsshark.length;
150: WfProcessSS[] remotes = new WfProcessSS[len];
151: for (int i = 0; i < len; i++) {
152: remotes[i] = (WfProcessSS) (home.create(wfsshark[i]))
153: .getPassedEJBObject();
154: }
155: return remotes;
156: }
157:
158: /**
159: * @ejb.interface-method
160: * view-type="both"
161: **/
162: public EJBObject getPassedEJBObject() throws EJBException {
163: try {
164: return context.getEJBObject();
165: } catch (Exception ex) {
166: throw new EJBException(ex);
167: }
168: }
169:
170: public void setSessionContext(SessionContext ctx)
171: throws EJBException, RemoteException {
172: context = ctx;
173: }
174:
175: /**
176: * @ejb:create-method
177: */
178: public void ejbCreate(
179: org.enhydra.shark.api.client.wfmodel.WfProcessIterator iter) {
180: sharkObj = iter;
181: }
182:
183: /* (non-Javadoc)
184: * @see javax.ejb.SessionBean#ejbActivate()
185: */
186: public void ejbActivate() throws EJBException, RemoteException {
187: }
188:
189: /* (non-Javadoc)
190: * @see javax.ejb.SessionBean#ejbPassivate()
191: */
192: public void ejbPassivate() throws EJBException, RemoteException {
193: }
194:
195: /* (non-Javadoc)
196: * @see javax.ejb.SessionBean#ejbRemove()
197: */
198: public void ejbRemove() throws EJBException, RemoteException {
199: }
200: }
|