KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > InteropGBean


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop;
19
20 import java.util.Properties JavaDoc;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.geronimo.gbean.GBeanInfo;
25 import org.apache.geronimo.gbean.GBeanInfoBuilder;
26 import org.apache.geronimo.gbean.GBeanLifecycle;
27 import org.omg.IOP.IOR JavaDoc;
28
29
30 /**
31  * A GBean that provides an example interop
32  *
33  * @version $Rev: $ $Date: $
34  */

35 public class InteropGBean implements GBeanLifecycle {
36
37     private final Log log = LogFactory.getLog(InteropGBean.class);
38
39     private IOR JavaDoc ior;
40
41     private Properties JavaDoc properties;
42     private String JavaDoc strprop;
43     private String JavaDoc name;
44
45     /**
46      * Construct an instance of InteropGBean
47      *
48      * @param strprop some strprop
49      */

50     public InteropGBean(String JavaDoc name, String JavaDoc strprop, Properties JavaDoc properties) {
51         this.name = name;
52         this.strprop = strprop;
53         this.properties = (properties == null ? new Properties JavaDoc() : properties);
54     }
55
56     /**
57      * Returns the strprop.
58      */

59     public String JavaDoc getAStrProp() {
60         return strprop;
61     }
62
63     /**
64      * Sets the strprop
65      *
66      * @param strprop the strprop
67      */

68     public void setAStrProp(String JavaDoc strprop) {
69         this.strprop = strprop;
70     }
71
72     /**
73      * Returns the Properties
74      */

75     public Properties JavaDoc getProperties() {
76         return properties;
77     }
78
79     /**
80      * Sets the properties
81      *
82      * @param properties the props.
83      */

84     public void setProperties(Properties JavaDoc properties) {
85         this.properties = properties;
86     }
87
88     /**
89      * Returns the object name of this protocol GBean
90      */

91     public String JavaDoc getName() {
92         return name;
93     }
94
95     /**
96      * Add the overrides from the member variables to the properties file.
97      */

98     public void echo(String JavaDoc msg) {
99         log.info(getName() + ": Echo " + msg);
100     }
101
102     /*
103      * Interface :: GBeanLifecycle
104      */

105
106     public void doStart() throws Exception JavaDoc {
107         log.info("Started " + getName());
108     }
109
110     public void doStop() throws Exception JavaDoc {
111         log.info("Stopped " + getName());
112     }
113
114     public void doFail() {
115         log.info("Failed " + getName());
116     }
117
118     /*
119      * GBeanInfo
120      */

121
122     public static final GBeanInfo GBEAN_INFO;
123
124     static {
125         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(InteropGBean.class);
126
127         infoFactory.addAttribute("name", String JavaDoc.class, true);
128         infoFactory.addAttribute("strprop", String JavaDoc.class, true);
129         infoFactory.addAttribute("properties", Properties JavaDoc.class, true);
130
131         infoFactory.addOperation("echo", new Class JavaDoc[]{String JavaDoc.class});
132
133         infoFactory.setConstructor(new String JavaDoc[]{"name", "strprop", "properties"});
134
135         GBEAN_INFO = infoFactory.getBeanInfo();
136     }
137
138     public static GBeanInfo getGBeanInfo() {
139         return GBEAN_INFO;
140     }
141 }
142
Popular Tags