01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.kernel;
17:
18: import org.apache.geronimo.gbean.DynamicGBean;
19: import org.apache.geronimo.gbean.GBeanInfo;
20: import org.apache.geronimo.gbean.GBeanInfoBuilder;
21: import org.apache.geronimo.gbean.DynamicGAttributeInfo;
22:
23: /**
24: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
25: */
26: public class MockDynamicGBean implements DynamicGBean {
27:
28: private static final GBeanInfo GBEAN_INFO;
29:
30: public static final String MUTABLE_INT_ATTRIBUTE_NAME = "MutableInt";
31:
32: private int mutableInt;
33:
34: public Object getAttribute(String name) throws Exception {
35: if (MUTABLE_INT_ATTRIBUTE_NAME.equals(name)) {
36: return new Integer(mutableInt);
37: }
38: return null;
39: }
40:
41: public void setAttribute(String name, Object value)
42: throws Exception {
43: if (MUTABLE_INT_ATTRIBUTE_NAME.equals(name)) {
44: mutableInt = ((Integer) value).intValue();
45: return;
46: }
47: throw new IllegalArgumentException(name
48: + " attribute not supported");
49: }
50:
51: public Object invoke(String name, Object[] arguments, String[] types)
52: throws Exception {
53: return null;
54: }
55:
56: /**
57: * @return GBeanInfo of this GBean
58: */
59: public static GBeanInfo getGBeanInfo() {
60: return GBEAN_INFO;
61: }
62:
63: static {
64: GBeanInfoBuilder infoFactory = GBeanInfoBuilder
65: .createStatic(MockDynamicGBean.class);
66: infoFactory.addAttribute(new DynamicGAttributeInfo(
67: "mutableInt", Integer.class.getName(), false, false,
68: true, true));
69: GBEAN_INFO = infoFactory.getBeanInfo();
70: }
71: }
|