All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.plugins.PluginManagerClient Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * 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:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: PluginManagerClient.java 2246 2008-01-03 09:22:50Z s2877 $
package at.spardat.xma.plugins;

import at.spardat.xma.boot.comp.data.XMAApp;
import at.spardat.xma.boot.comp.data.XMAPluginImpl;
import at.spardat.xma.session.XMASessionClient;


/**
 * Realizes the plugin concept at the client side of XMA.
 *
 * @author YSD, CGS(s3595)
 */
public class PluginManagerClient extends PluginManager {

    /* used to get info about the application and its plugins. */
    private XMASessionClient xmasession;

    /* application description used for plugin lookups */
    private XMAApp           appDes;

    /* constructor */
    public PluginManagerClient( XMASessionClient session ) {
        this.xmasession   = session;
        this.appDes       = null;
    }


    /**
     * @see at.spardat.xma.plugins.PluginManager#resolvePlugin(java.lang.String, java.lang.ClassLoader)
     */
    protected Object resolvePlugin (String interfaceName, ClassLoader cl) {

        if( appDes == null ) {
            appDes = xmasession.getAppContainer().getApp();
        }

        XMAPluginImpl impl = appDes.getPluginImpl( interfaceName );
        if( impl == null ) {
            throw new RuntimeException ("no implementation for plug-in-interface " + interfaceName);
        }

        String strImpl = impl.getImplClient_();
        if( strImpl == null )
            throw new RuntimeException ("no implementation for plug-in-interface " + interfaceName);

        try {
            Object ret =  cl.loadClass(strImpl).newInstance();
            // TODO LOG
            return ret;
        } catch( Exception exc ) {
            throw new RuntimeException("could not load implementation for "+interfaceName+": "+exc.toString());
        }

        } // resolvePlugin


    /**
     * Checks if a plugin is configured for the given interface and a client side implementation is defined.
     * @param interfaceName the fully qualified name of a java interface, specifying
     *         the interface the plugin has to implement.
     * @return true if a plugin is declared for the given interface in xma-app.xml, false otherwise.
     * @author s2877
     */
    public boolean isPluginDeclared(String interfaceName) {
        if( appDes == null ) {
            appDes = xmasession.getAppContainer().getApp();
        }

        XMAPluginImpl impl = appDes.getPluginImpl( interfaceName );
        if(impl != null ) {
            return impl.getImplClient_()!=null;
        } else {
            return false;
        }
    }
}








© 2015 - 2024 Weber Informatics LLC | Privacy Policy