KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > MockGBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.deployment;
19
20 import org.apache.geronimo.gbean.GBeanInfo;
21 import org.apache.geronimo.gbean.GBeanInfoBuilder;
22
23 /**
24  *
25  *
26  * @version $Rev: 486195 $ $Date: 2006-12-12 10:42:02 -0500 (Tue, 12 Dec 2006) $
27  */

28 public class MockGBean implements MockEndpoint {
29     private final String JavaDoc name;
30     private String JavaDoc value;
31     private int intValue;
32
33     private FooBarBean fooBarBean;
34
35     private MockEndpoint endpoint;
36
37     public MockGBean(String JavaDoc name) {
38         this.name = name;
39     }
40
41     public String JavaDoc getName() {
42         return name;
43     }
44
45     public String JavaDoc getValue() {
46         return value;
47     }
48
49     public void setValue(String JavaDoc value) {
50         this.value = value;
51     }
52
53     public int getIntValue() {
54         return intValue;
55     }
56
57     public void setIntValue(int intValue) {
58         this.intValue = intValue;
59     }
60
61     public FooBarBean getFooBarBean() {
62         return fooBarBean;
63     }
64
65     public void setFooBarBean(FooBarBean fooBarBean) {
66         this.fooBarBean = fooBarBean;
67     }
68
69     public MockEndpoint getMockEndpoint() {
70         return endpoint;
71     }
72
73     public void setMockEndpoint(MockEndpoint endpoint) {
74         this.endpoint = endpoint;
75     }
76
77     public String JavaDoc doSomething(String JavaDoc name) {
78         return name;
79     }
80
81     public String JavaDoc checkEndpoint() {
82         if (endpoint == null) {
83             return "no endpoint";
84         }
85         return endpoint.doSomething("endpointCheck");
86     }
87
88     public static final GBeanInfo GBEAN_INFO;
89
90     static {
91         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(MockGBean.class);
92
93         infoFactory.addAttribute("name", String JavaDoc.class, true);
94         infoFactory.addAttribute("value", String JavaDoc.class, true);
95         infoFactory.addAttribute("intValue", int.class, true);
96         infoFactory.addAttribute("fooBarBean", FooBarBean.class, true);
97
98         infoFactory.addOperation("checkEndpoint");
99         infoFactory.addOperation("doSomething", new Class JavaDoc[]{String JavaDoc.class});
100
101         infoFactory.addReference("MockEndpoint", MockEndpoint.class, null);
102
103         infoFactory.setConstructor(new String JavaDoc[] {"name"});
104
105         GBEAN_INFO = infoFactory.getBeanInfo();
106     }
107
108     public static GBeanInfo getGBeanInfo() {
109         return GBEAN_INFO;
110     }
111 }
112
Popular Tags