KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > opc > utils > jsputil


1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any
21 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
22 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
24 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
25 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
27 * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
28 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
29 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
30 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
31 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that Software is not designed, licensed or intended
34 * for use in the design, construction, operation or maintenance of
35 * any nuclear facility.
36 */

37
38 /*
39  * util.java
40  *
41  * Created on June 12, 2005, 1:25 AM
42  *
43  * To change this template, choose Tools | Options and locate the template under
44  * the Source Creation and Management node. Right-click the template and choose
45  * Open. You can then make changes to the template in the Source Editor.
46  */

47
48 package com.sun.j2ee.blueprints.opc.utils;
49
50 import javax.naming.InitialContext JavaDoc;
51 import javax.naming.NamingException JavaDoc;
52 import javax.rmi.PortableRemoteObject JavaDoc;
53 //import samples.comet.ejb.Welcome;
54
//import samples.comet.ejb.WelcomeHome;
55

56
57 /**
58  *
59  * @author pb
60  */

61 public class jsputil {
62     
63     /** Creates a new instance of util */
64     public jsputil() {
65     }
66     
67     private String JavaDoc getFString(int length, String JavaDoc val){
68         int diff=length-val.length();
69         if(diff>0){
70             byte[] tmp=new byte[diff];
71             for(int i=0;i<diff;i++)
72                 tmp[i]=(byte)' ';
73             return (val+new String JavaDoc(tmp));
74         } else{
75             if(diff<0)
76                 return (val.substring(0,length));
77             else
78                 return (val);
79         }
80     }
81     
82     
83 // public String getMessage(String reqName) {
84
// String msg = "";
85
// Welcome _welcome= null;
86
// try{
87
// String name = reqName;
88
// if(name!=null && name.length()>0){
89
// InitialContext ic = new InitialContext();
90
// Object objRef = ic.lookup("java:comp/env/ejb/welcome");
91
//
92
// WelcomeHome home = (WelcomeHome)PortableRemoteObject.narrow(objRef, WelcomeHome.class);
93
// _welcome = home.create();
94
//
95
// _welcome.setName(getFString(10,name));
96
// boolean ok=_welcome.execute();
97
// if(ok){
98
// msg=_welcome.getMessage();
99
// }else{
100
// return "Failed to execute";
101
// }
102
// }
103
// if(_welcome!=null){
104
// _welcome.remove();
105
// _welcome=null;
106
// }
107
// }catch(javax.resource.ResourceException e){
108
// e.printStackTrace();
109
// } catch (NamingException ex){
110
// ex.printStackTrace();
111
// } catch (javax.ejb.CreateException crex) {
112
// crex.printStackTrace();
113
// } catch (java.rmi.RemoteException crex) {
114
// crex.printStackTrace();
115
// } catch (javax.ejb.RemoveException crex) {
116
// crex.printStackTrace();
117
// }
118
// return msg;
119
// }
120
}
121
Popular Tags