01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent, Inc.
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * Initial developer(s): Damian Arregui.
19: * Contributor(s): ______________________.
20: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
21:
22: import java.io.Serializable;
23: import java.lang.reflect.InvocationTargetException;
24:
25: import org.continuent.hedera.common.Member;
26: import org.continuent.sequoia.common.exceptions.ControllerException;
27: import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
28: import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabaseDynamicMetaData;
29:
30: /**
31: * This class defines a GetMetadata command.
32: *
33: * @author <a href="mailto:damian.arregui@continuent.com">Damián Arregui</a>
34: * @version 1.0
35: */
36: public class GetMetadata extends DistributedVirtualDatabaseMessage {
37: private static final long serialVersionUID = -3691893740718177069L;
38:
39: private String methodName;
40: private Class[] argTypes;
41: private Object[] args;
42:
43: /**
44: * Creates a new <code>GetMetadata</code> object
45: *
46: * @param methodName name of the metdata-related method to be invoked.
47: * @param argTypes array describing the types of method arguments.
48: * @param args array of method arguments.
49: */
50: public GetMetadata(String methodName, Class[] argTypes,
51: Object[] args) {
52: this .methodName = methodName;
53: this .argTypes = argTypes;
54: this .args = args;
55: }
56:
57: /**
58: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
59: * org.continuent.hedera.common.Member)
60: */
61: public Object handleMessageSingleThreaded(
62: DistributedVirtualDatabase dvdb, Member sender) {
63:
64: try {
65: return VirtualDatabaseDynamicMetaData.class.getMethod(
66: methodName, argTypes).invoke(
67: dvdb.getDynamicMetaData(), args);
68: } catch (IllegalArgumentException e) {
69: return new ControllerException(e);
70: } catch (SecurityException e) {
71: return new ControllerException(e);
72: } catch (IllegalAccessException e) {
73: return new ControllerException(e);
74: } catch (InvocationTargetException e) {
75: return new ControllerException(e);
76: } catch (NoSuchMethodException e) {
77: return new ControllerException(e);
78: }
79: }
80:
81: /**
82: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
83: * org.continuent.hedera.common.Member, java.lang.Object)
84: */
85: public Serializable handleMessageMultiThreaded(
86: DistributedVirtualDatabase dvdb, Member sender,
87: Object handleMessageSingleThreadedResult) {
88: return (Serializable) handleMessageSingleThreadedResult;
89: }
90:
91: }
|