mp3infoproviderfactory.java

来自「eclise rcp 项目,是非常好的学习源码」· Java 代码 · 共 53 行

JAVA
53
字号
/*******************************************************************************
 * Copyright (c) 2007 Siemens AG
 * 
 * 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:
 *    Kai T鰀ter - initial API and implementation
 *******************************************************************************/

package com.siemens.ct.mp3m.model;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;

import com.siemens.ct.mp3m.utilities.LogUtil;


public class MP3InfoProviderFactory {
    private static MP3InfoProviderFactory factory;

    private IMP3InfoProvider currentProvider;

    /**
     * Creates the only instance of the factory.
     */
    private MP3InfoProviderFactory() {
        IConfigurationElement[] providers = Platform.getExtensionRegistry()
                .getConfigurationElementsFor("com.siemens.ct.mp3m.model", "mp3info");
        for (IConfigurationElement provider : providers) {
            try {
                currentProvider = (IMP3InfoProvider) provider.createExecutableExtension("class");
            } catch (CoreException e) {
            	LogUtil.logError("com.siemens.ct.mp3m.model",e);
            }
        }
    }

    public static MP3InfoProviderFactory getInstance() {
        if (factory == null) {
            factory = new MP3InfoProviderFactory();
        }
        return factory;
    }

    public IMP3Info getMP3Info() {
        return currentProvider.getMP3Info();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?