View Javadoc

1   /*$Id: SampleJavaClassApplications.java,v 1.6 2006/06/13 20:33:13 clq2 Exp $
2    * Created on 08-Jun-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.applications.javaclass;
12  
13  import org.apache.commons.logging.Log;
14  import org.apache.commons.logging.LogFactory;
15  import org.astrogrid.applications.service.v1.cea.CeaSecurityGuard;
16  
17  
18  /*** Sample class of static methods, to use as java 'applications'
19   * @author Noel Winstanley nw@jb.man.ac.uk 08-Jun-2004
20   *
21   */
22  public class SampleJavaClassApplications {
23      /***
24       * Commons Logger for this class
25       */
26      private static final Log logger = LogFactory
27          .getLog(SampleJavaClassApplications.class);
28  
29      /*** Static methods - so no public constructor
30       * 
31       */
32      private SampleJavaClassApplications() {
33          super();
34      }
35      /*** the classic */
36      public static String helloWorld() {
37          return "Hello World!";
38      }
39      
40      /*** say hello to someone */
41      public static String helloYou(String who) {
42          return "Hello " + who;
43      }
44      /*** add two numbers */
45      public static int sum(int a, int b) {
46          logger.info("Summing " + a + " and " + b);
47          return a + b;
48      }
49      
50      /*** Two different argument types */
51      public static String echoDifferentArgs(String string, int integer) {
52          return string + integer;
53      }
54      
55      /***
56       * Uses security facade to find the caller's identity.
57       */
58      public static String whoAmI() {
59        CeaSecurityGuard g = CeaSecurityGuard.getInstanceFromContext();
60        if (g.isAuthenticated()) {
61          return g.getX500Principal().getName();
62        }
63        else {
64          return "not authenticated";
65        } 
66      }
67          
68  }
69  
70  
71  /* 
72  $Log: SampleJavaClassApplications.java,v $
73  Revision 1.6  2006/06/13 20:33:13  clq2
74  pal_gtr_1671
75  
76  Revision 1.5.50.1  2006/06/09 17:49:07  gtr
77  I added security features.
78  
79  Revision 1.5  2005/07/14 13:36:11  jdt
80  merge from  Branch aginab_jdt_1182
81  
82  Revision 1.4.164.1  2005/07/08 17:43:38  jdt
83  added a method to illustrate the parameter ordering bug
84  
85  Revision 1.4  2004/07/26 10:21:47  nw
86  javadoc
87  
88  Revision 1.3  2004/07/22 16:32:54  nw
89  cleaned up application / parameter adapter interface.
90  
91  Revision 1.2  2004/07/01 11:16:22  nw
92  merged in branch
93  nww-itn06-componentization
94  
95  Revision 1.1.2.2  2004/07/01 01:42:46  nw
96  final version, before merge
97  
98  Revision 1.1.2.1  2004/06/14 08:56:58  nw
99  factored applications into sub-projects,
100 got packaging of wars to work again
101  
102 */