Skip to main content
summaryrefslogtreecommitdiffstats
blob: d8ba4c971812f51b13067251a2af414ac5dd5797 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/***************************************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others. 
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   IBM Corporation - initial API and implementation
 **************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.util;

import org.eclipse.emf.common.util.URI;
import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry;
import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory;
import org.eclipse.wst.common.internal.emf.resource.Renderer;
import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
import org.eclipse.wst.common.internal.emf.resource.TranslatorResource;
import org.eclipse.wst.common.internal.emf.resource.TranslatorResourceFactory;

/**
 * May be referenced but should NOT be extended by clients
 * 
 * @author xjiang
 *
 */
public final class FacesConfigResourceFactory extends TranslatorResourceFactory 
{
    /**
     * @return a faces config resource factory for use with faces-config
     * files contained in JARs
     */
    public static FacesConfigResourceFactory createResourceFactoryForJar()
    {
        return new FacesConfigResourceFactory(EMF2DOMRendererFactory.INSTANCE);
    }
    
	/**
	 * Construct a faces resource factory.
	 * 
	 * @param rendererFactory 
	 */
	protected FacesConfigResourceFactory(RendererFactory rendererFactory) {
		super(rendererFactory);
	}


	/* (non-Javadoc)
	 * @see org.eclipse.wst.common.internal.emf.resource.TranslatorResourceFactory#createResource(org.eclipse.emf.common.util.URI)
	 */
	protected TranslatorResource createResource(URI uri, Renderer aRenderer) {
		return new FacesConfigResourceImpl(uri, aRenderer);
	}
	
	/**
	 * Method registerDtds.
	 */
	public static void registerDtds() {
	    // TODO: should we be registering dtd/xsd here?
	    // how does MyEntityResolver in the resource affect this (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=154439)
	}

	/**
	 * register using the default renderer factory.
	 * @see #registerWith(String, FacesRendererFactory)
	 */
	public static void register() {
		register((String)null);
	}

	/**
	 * Register the sFileName with the default renderer factory
	 * @param sFileName
	 */
	public static void register(String sFileName) {
		registerWith(sFileName, FacesRendererFactory.INSTANCE);
	}

	/**
	 * Register myself with the Resource.Factory.Registry
	 * @param sFileName 
	 * @param aRendererFactory 
	 */
	private static void registerWith(String sFileName, FacesRendererFactory aRendererFactory) {
		if (sFileName != null) {
			WTPResourceFactoryRegistry.INSTANCE.registerLastFileSegment(sFileName, new FacesConfigResourceFactory(FacesRendererFactory.INSTANCE));
		} else {
			WTPResourceFactoryRegistry.INSTANCE.registerLastFileSegment("faces-config.xml", new FacesConfigResourceFactory(FacesRendererFactory.INSTANCE)); //$NON-NLS-1$
		}
	}
}

Back to the top