KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > virtualdatabase > protocol > GetMetadata


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2006 Continuent, Inc.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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  */

21
22 package org.continuent.sequoia.controller.virtualdatabase.protocol;
23
24 import java.io.Serializable JavaDoc;
25 import java.lang.reflect.InvocationTargetException JavaDoc;
26
27 import org.continuent.hedera.common.Member;
28 import org.continuent.sequoia.common.exceptions.ControllerException;
29 import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
30 import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabaseDynamicMetaData;
31
32 /**
33  * This class defines a GetMetadata command.
34  *
35  * @author <a HREF="mailto:damian.arregui@continuent.com">Damián Arregui</a>
36  * @version 1.0
37  */

38 public class GetMetadata extends DistributedVirtualDatabaseMessage
39 {
40   private static final long serialVersionUID = -3691893740718177069L;
41
42   private String JavaDoc methodName;
43   private Class JavaDoc[] argTypes;
44   private Object JavaDoc[] args;
45
46   /**
47    * Creates a new <code>GetMetadata</code> object
48    *
49    * @param methodName name of the metdata-related method to be invoked.
50    * @param argTypes array describing the types of method arguments.
51    * @param args array of method arguments.
52    */

53   public GetMetadata(String JavaDoc methodName, Class JavaDoc[] argTypes, Object JavaDoc[] args)
54   {
55     this.methodName = methodName;
56     this.argTypes = argTypes;
57     this.args = args;
58   }
59
60   /**
61    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
62    * org.continuent.hedera.common.Member)
63    */

64   public Object JavaDoc handleMessageSingleThreaded(DistributedVirtualDatabase dvdb,
65       Member sender)
66   {
67
68     try
69     {
70       return VirtualDatabaseDynamicMetaData.class.getMethod(methodName,
71           argTypes).invoke(dvdb.getDynamicMetaData(), args);
72     }
73     catch (IllegalArgumentException JavaDoc e)
74     {
75       return new ControllerException(e);
76     }
77     catch (SecurityException JavaDoc e)
78     {
79       return new ControllerException(e);
80     }
81     catch (IllegalAccessException JavaDoc e)
82     {
83       return new ControllerException(e);
84     }
85     catch (InvocationTargetException JavaDoc e)
86     {
87       return new ControllerException(e);
88     }
89     catch (NoSuchMethodException JavaDoc e)
90     {
91       return new ControllerException(e);
92     }
93   }
94
95   /**
96    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
97    * org.continuent.hedera.common.Member, java.lang.Object)
98    */

99   public Serializable JavaDoc handleMessageMultiThreaded(
100       DistributedVirtualDatabase dvdb, Member sender,
101       Object JavaDoc handleMessageSingleThreadedResult)
102   {
103     return (Serializable JavaDoc) handleMessageSingleThreadedResult;
104   }
105
106 }
107
Popular Tags