KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > util > ejb > local > LocalEJBValidator


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.util.ejb.local;
6
7 import com.opensymphony.module.propertyset.PropertySet;
8
9 import com.opensymphony.workflow.*;
10
11 import org.apache.commons.logging.Log;
12 import org.apache.commons.logging.LogFactory;
13
14 import java.lang.reflect.Method JavaDoc;
15
16 import java.util.Map JavaDoc;
17
18 import javax.ejb.EJBHome JavaDoc;
19
20 import javax.naming.InitialContext JavaDoc;
21
22 import javax.rmi.PortableRemoteObject JavaDoc;
23
24
25 /**
26  *
27  *
28  * @author $Author: hani $
29  * @version $Revision: 1.2 $
30  */

31 public class LocalEJBValidator implements Validator {
32     //~ Static fields/initializers /////////////////////////////////////////////
33

34     private static final Log log = LogFactory.getLog(LocalEJBValidator.class);
35
36     //~ Methods ////////////////////////////////////////////////////////////////
37

38     public void validate(Map JavaDoc transientVars, Map JavaDoc args, PropertySet ps) throws WorkflowException {
39         String JavaDoc ejbLocation = (String JavaDoc) args.get(AbstractWorkflow.EJB_LOCATION);
40
41         Validator sessionBean = null;
42
43         try {
44             EJBHome JavaDoc home = (EJBHome JavaDoc) PortableRemoteObject.narrow(new InitialContext JavaDoc().lookup(ejbLocation), EJBHome JavaDoc.class);
45             Method JavaDoc create = home.getClass().getMethod("create", new Class JavaDoc[0]);
46             sessionBean = (Validator) create.invoke(home, new Object JavaDoc[0]);
47         } catch (Exception JavaDoc e) {
48             String JavaDoc message = "Could not get handle to local EJB validator: " + ejbLocation;
49             log.error(message, e);
50             throw new WorkflowException(message, e);
51         }
52
53         sessionBean.validate(transientVars, args, ps);
54     }
55 }
56
Popular Tags