KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > core > HelloWorldComponent


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jun 23, 2005
14  * @author James Dixon
15  */

16
17 package org.pentaho.plugin.core;
18
19 import java.io.OutputStream JavaDoc;
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.pentaho.messages.Messages;
23 import org.pentaho.messages.util.LocaleHelper;
24 import org.pentaho.plugin.ComponentBase;
25
26 /**
27  * @author James Dixon
28  *
29  * TODO To change the template for this generated type comment go to Window -
30  * Preferences - Java - Code Style - Code Templates
31  */

32 public class HelloWorldComponent extends ComponentBase {
33
34     /**
35      *
36      */

37     private static final long serialVersionUID = 9050456842938084174L;
38
39     public Log getLogger() {
40         return LogFactory.getLog(HelloWorldComponent.class);
41     }
42
43     protected boolean validateSystemSettings() {
44         // This component does not have any system settings to validate
45
return true;
46     }
47
48     protected boolean validateAction() {
49
50         return true;
51     }
52
53     public void done() {
54     }
55
56     protected boolean executeAction() {
57
58         String JavaDoc quote = (isDefinedInput("quote")) ? getInputStringValue("quote") : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
59
// return the quote as the result of this component
60
String JavaDoc result = Messages.getString("HelloWorld.USER_HELLO_WORLD_TEXT", quote); //$NON-NLS-1$
61

62         OutputStream JavaDoc outputStream = getDefaultOutputStream();
63         setOutputMimeType("text/html"); //$NON-NLS-1$
64
if (outputStream != null) {
65             try {
66                 outputStream.write(result.getBytes(LocaleHelper.getSystemEncoding()));
67             } catch (Exception JavaDoc e) {
68                     error( Messages.getErrorString("HelloWorld.ERROR_0001_COULDNOTWRITE"), e ); //$NON-NLS-1$
69
}
70         }
71
72         info(result);
73         return true;
74     }
75
76     public boolean init() {
77
78         // nothing to do here really
79
return true;
80     }
81
82 }
83
Popular Tags