KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > controls > runtime > bean > AdaptorPersistenceDelegate


1 package org.apache.beehive.controls.runtime.bean;
2 /*
3  * Copyright 2004 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  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * $Header:$
18  */

19
20 import java.beans.BeanInfo JavaDoc;
21 import java.beans.DefaultPersistenceDelegate JavaDoc;
22 import java.beans.Encoder JavaDoc;
23 import java.beans.Expression JavaDoc;
24 import java.beans.IntrospectionException JavaDoc;
25 import java.beans.Introspector JavaDoc;
26 import java.beans.PersistenceDelegate JavaDoc;
27 import java.beans.PropertyDescriptor JavaDoc;
28 import java.beans.Statement JavaDoc;
29 import java.beans.XMLEncoder JavaDoc;
30 import java.util.Set JavaDoc;
31
32 import org.apache.beehive.controls.api.ControlException;
33
34 /**
35  * The AdaptorPersistenceDelegate class supports the XML persistance of Control Client Event
36  * Adaptor instances by implementing the <code>java.beans.PersistenceDelegate</b> API, and
37  * overriding the default persistance algorithm based upon the runtime structure for Controls.
38  */

39 public class AdaptorPersistenceDelegate extends DefaultPersistenceDelegate JavaDoc
40 {
41     /**
42      * PersistenceDelegate.instantiate()
43      */

44     protected Expression JavaDoc instantiate(Object JavaDoc oldInstance, Encoder JavaDoc out)
45     {
46         if (! (oldInstance instanceof EventAdaptor))
47             return super.instantiate(oldInstance, out);
48
49         //
50
// An implementation instance is actually constructed at decode time by calling
51
// ControlBean.ensureControl on the parent bean. This will create a new impl
52
// instance and run the impl initializer on it.
53
//
54
return new Expression JavaDoc(oldInstance, oldInstance.getClass(), "new",
55                               new Object JavaDoc[] { ((EventAdaptor)oldInstance).getClient() });
56     }
57
58     /**
59      * PersistenceDelegate.initialize()
60      */

61     protected void initialize(Class JavaDoc<?> type, Object JavaDoc oldInstance, Object JavaDoc newInstance, Encoder JavaDoc out)
62     {
63         super.initialize(type, oldInstance, newInstance, out);
64     }
65
66     /**
67      * PersistenceDelegate.writeObject()
68      */

69     public void writeObject(Object JavaDoc oldInstance, Encoder JavaDoc out)
70     {
71         super.writeObject(oldInstance, out);
72     }
73 }
74
Popular Tags