1 /*
2 * Copyright 2007 Joachim Grueneis
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.castor.xml;
17
18 import org.castor.mapping.BindingType;
19 import org.exolab.castor.xml.ClassDescriptorResolverFactory;
20 import org.exolab.castor.xml.Introspector;
21 import org.exolab.castor.xml.XMLClassDescriptorResolver;
22 import org.exolab.castor.xml.XMLContext;
23 import org.exolab.castor.xml.util.ResolverStrategy;
24 import org.exolab.castor.xml.util.resolvers.CastorXMLStrategy;
25
26 /**
27 * As the name already expresses: this class is there for backward compatibility
28 * and should be removed from Castor with a future release.
29 *
30 * Normally the internal context is created by XMLContext exclusivly and then
31 * handed down the call chain. This very class is used in all cases, which fail
32 * to be on a call chain started with {@link XMLContext}.
33 *
34 * Ideally, all usage of this class should disappear and be replaced with proper
35 * usage of {@link XMLContext}.
36 *
37 * @see XMLContext
38 * @author Joachim Grueneis, jgrueneis_at_gmail_dot_com
39 * @version $Id$
40 */
41 public class BackwardCompatibilityContext extends AbstractInternalContext implements InternalContext {
42 /**
43 * Initializes InternalContext with default values.
44 */
45 public BackwardCompatibilityContext() {
46 super();
47 setClassLoader(getClass().getClassLoader());
48
49 XMLClassDescriptorResolver cdr = (XMLClassDescriptorResolver) ClassDescriptorResolverFactory
50 .createClassDescriptorResolver(BindingType.XML);
51 cdr.setInternalContext(this);
52 setXMLClassDescriptorResolver(cdr);
53
54 Introspector introspector = new Introspector();
55 introspector.setInternalContext(this);
56 setIntrospector(introspector);
57 cdr.setIntrospector(introspector);
58
59 ResolverStrategy resolverStrategy = new CastorXMLStrategy();
60 setResolverStrategy(resolverStrategy);
61 cdr.setResolverStrategy(resolverStrategy);
62 }
63 }