001/*
002 * Copyright (c) 2006-2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *     Bogdan Stefanescu
012 *     Benjamin JALON
013 */
014
015package org.nuxeo.runtime.model.impl;
016
017import java.net.URL;
018
019import org.nuxeo.common.xmap.Context;
020import org.nuxeo.runtime.model.RuntimeContext;
021
022/**
023 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
024 */
025public class XMapContext extends Context {
026
027    private static final long serialVersionUID = -7194560385886298218L;
028
029    final RuntimeContext ctx;
030
031    public XMapContext(RuntimeContext ctx) {
032        this.ctx = ctx;
033    }
034
035    @Override
036    public Class<?> loadClass(String className) throws ClassNotFoundException {
037        if (className.startsWith("[")) {
038            return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
039        }
040        return ctx.loadClass(className);
041    }
042
043    @Override
044    public URL getResource(String name) {
045        return ctx.getResource(name);
046    }
047
048}