001: /* WfProcessMgrIteratorSSBean.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.WfProcessMgr;
015: import org.enhydra.shark.api.client.wfservice.WfProcessMgrIterator;
016:
017: /**
018: * @ejb.bean
019: * name="WfProcessMgrIteratorSS"
020: * type="Stateful"
021: * display-name="WfProcessMgrIterator"
022: * jndi-name="org/enhydra/shark/ejb/WfProcessMgrIteratorSS"
023: * local-jndi-name="org/enhydra/shark/ejb/WfProcessMgrIteratorSSLocal"
024: * transaction-type="Container"
025: * view-type="both"
026: * local-business-interface="org.enhydra.shark.api.client.wfservice.WfProcessMgrIterator"
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.wfservice.WfProcessMgrIterator,javax.ejb.EJBObject"
034: *
035: * @ejb:transaction
036: * type="Required"
037: *
038: * @jonas:bean
039: * ejb-name="WfProcessMgrIteratorSS"
040: * jndi-name="org/enhydra/shark/ejb/WfProcessMgrIteratorSS"
041: *
042: * OMG definition: The WfProcessMgrIterator 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 WfProcessMgrIteratorSSBean extends
060: BaseIteratorSSBean implements WfProcessMgrIterator, SessionBean {
061:
062: private SessionContext context;
063:
064: /**
065: * @ejb:interface-method
066: * view-type="both"
067: */
068: public WfProcessMgr get_next_object() throws Exception {
069: WfProcessMgr wfshark = ((WfProcessMgrIterator) sharkObj)
070: .get_next_object();
071: WfProcessMgrSS wf = null;
072: try {
073: Context initialContext = EJBJNDIContext.getInstance()
074: .getInitialContext();
075: wf = ((org.enhydra.shark.ejb.WfProcessMgrSSHome) PortableRemoteObject
076: .narrow(
077: initialContext
078: .lookup("org/enhydra/shark/ejb/WfProcessMgrSS"),
079: org.enhydra.shark.ejb.WfProcessMgrSSHome.class))
080: .create(wfshark);
081: return (WfProcessMgrSS) 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 WfProcessMgr get_previous_object() throws Exception {
092: WfProcessMgr wfshark = ((WfProcessMgrIterator) sharkObj)
093: .get_previous_object();
094: WfProcessMgrSS wf = null;
095: try {
096: Context initialContext = EJBJNDIContext.getInstance()
097: .getInitialContext();
098: wf = ((org.enhydra.shark.ejb.WfProcessMgrSSHome) PortableRemoteObject
099: .narrow(
100: initialContext
101: .lookup("org/enhydra/shark/ejb/WfProcessMgrSS"),
102: org.enhydra.shark.ejb.WfProcessMgrSSHome.class))
103: .create(wfshark);
104: return (WfProcessMgrSS) 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 WfProcessMgr[] get_next_n_sequence(int max_number)
115: throws Exception {
116: WfProcessMgr[] wfsshark = ((WfProcessMgrIterator) sharkObj)
117: .get_next_n_sequence(max_number);
118: WfProcessMgrSSHome home = null;
119: InitialContext initialContext = EJBJNDIContext.getInstance()
120: .getInitialContext();
121: home = (WfProcessMgrSSHome) PortableRemoteObject
122: .narrow(
123: initialContext
124: .lookup("org/enhydra/shark/ejb/WfProcessMgrSS"),
125: org.enhydra.shark.ejb.WfProcessMgrSSHome.class);
126: int len = wfsshark.length;
127: WfProcessMgrSS[] remotes = new WfProcessMgrSS[len];
128: for (int i = 0; i < len; i++) {
129: remotes[i] = (WfProcessMgrSS) (home.create(wfsshark[i]))
130: .getPassedEJBObject();
131: }
132: return remotes;
133: }
134:
135: /**
136: * @ejb:interface-method
137: * view-type="both"
138: */
139: public WfProcessMgr[] get_previous_n_sequence(int max_number)
140: throws Exception {
141: WfProcessMgr[] wfsshark = ((WfProcessMgrIterator) sharkObj)
142: .get_previous_n_sequence(max_number);
143: WfProcessMgrSSHome home = null;
144: InitialContext initialContext = EJBJNDIContext.getInstance()
145: .getInitialContext();
146: home = (WfProcessMgrSSHome) PortableRemoteObject
147: .narrow(
148: initialContext
149: .lookup("org/enhydra/shark/ejb/WfProcessMgrSS"),
150: org.enhydra.shark.ejb.WfProcessMgrSSHome.class);
151: int len = wfsshark.length;
152: WfProcessMgrSS[] remotes = new WfProcessMgrSS[len];
153: for (int i = 0; i < len; i++) {
154: remotes[i] = (WfProcessMgrSS) (home.create(wfsshark[i]))
155: .getPassedEJBObject();
156: }
157: return remotes;
158: }
159:
160: /**
161: * @ejb.interface-method
162: * view-type="both"
163: **/
164: public EJBObject getPassedEJBObject() throws EJBException {
165: try {
166: return context.getEJBObject();
167: } catch (Exception ex) {
168: throw new EJBException(ex);
169: }
170: }
171:
172: public void setSessionContext(SessionContext ctx)
173: throws EJBException, RemoteException {
174: context = ctx;
175: }
176:
177: /**
178: * @ejb:create-method
179: */
180: public void ejbCreate(
181: org.enhydra.shark.api.client.wfservice.WfProcessMgrIterator iter) {
182: sharkObj = iter;
183: }
184:
185: /* (non-Javadoc)
186: * @see javax.ejb.SessionBean#ejbActivate()
187: */
188: public void ejbActivate() throws EJBException, RemoteException {
189: }
190:
191: /* (non-Javadoc)
192: * @see javax.ejb.SessionBean#ejbPassivate()
193: */
194: public void ejbPassivate() throws EJBException, RemoteException {
195: }
196:
197: /* (non-Javadoc)
198: * @see javax.ejb.SessionBean#ejbRemove()
199: */
200: public void ejbRemove() throws EJBException, RemoteException {
201: }
202: }
|