/** * Tries to create a new instance of the given class. This is a short cut for the common bean instantiation code. * * @param className the class name as String, never null. * @param source the source class, from where to get the classloader. * @return the instantiated object or null, if an error occured. * @deprecated This class is not typesafe and instantiates the specified object without any additional checks. */ public static Object loadAndInstantiate( final String className, final Class source ) { return loadAndInstantiate( className, source, null ); }
public WrapperWMFDrawableFactoryModule() { parent = ObjectUtilities.loadAndInstantiate ( "org.pentaho.reporting.libraries.resourceloader.modules.factory.wmf.WMFImageFactoryModule", WrapperWMFImageFactoryModule.class, FactoryModule.class ); }
public WrapperWMFImageFactoryModule() { parent = ObjectUtilities.loadAndInstantiate ( "org.pentaho.reporting.libraries.resourceloader.modules.factory.wmf.WMFImageFactoryModule", WrapperWMFImageFactoryModule.class, FactoryModule.class ); }
public WrapperSVGDrawableFactoryModule() { parent = ObjectUtilities.loadAndInstantiate ( "org.pentaho.reporting.libraries.resourceloader.modules.factory.svg.SVGDrawableFactoryModule", WrapperSVGDrawableFactoryModule.class, FactoryModule.class ); }
public WrapperSVGImageFactoryModule() { parent = ObjectUtilities.loadAndInstantiate ( "org.pentaho.reporting.libraries.resourceloader.modules.factory.svg.SVGImageFactoryModule", WrapperSVGImageFactoryModule.class, FactoryModule.class ); }
/** * Tries to create a new instance of the given class. This is a short cut for the common bean instantiation code. * * @param className the class name as String, never null. * @param source the source class, from where to get the classloader. * @return the instantiated object or null, if an error occured. * @deprecated This class is not typesafe and instantiates the specified object without any additional checks. */ public static Object loadAndInstantiate(final String className, final Class source) { return loadAndInstantiate(className, source, null); }
public PropertyEditor getEditor( final int position ) { try { final ResourceBundle bundle = getBundle( Locale.getDefault() ); final String key = "parameter." + position + ".editor"; if ( bundle.containsKey( key ) == false ) { return null; } final String string = bundle.getString( key ); return ObjectUtilities.loadAndInstantiate( string, AbstractSequenceDescription.class, PropertyEditor.class ); } catch ( Exception e ) { return null; } }
/** * Checks, whether the given handler classname can be instantiated and is in fact an object of the required * target-type. * * @param className the classname that should be checked. * @return true, if the handler is valid, false otherwise. */ private boolean isValidHandler( final String className ) { if ( className == null ) { return false; } final XmlReadHandler o = ObjectUtilities.loadAndInstantiate( className, getClass(), getTargetClass() ); return o != null; }
public ImageEncoder createEncoder( final String mimeType ) throws UnsupportedEncoderException { final Object o = encoders.get( mimeType ); if ( o == null ) { throw new UnsupportedEncoderException( "No encoder for mime-type " + mimeType ); } final ImageEncoder imageEncoder = ObjectUtilities.loadAndInstantiate( (String) o, ImageEncoderRegistry.class, ImageEncoder.class ); if ( imageEncoder == null ) { throw new UnsupportedEncoderException( "No encoder for mime-type " + mimeType ); } return imageEncoder; } }
/** * Creates an object based on this object description. * * @return The object. */ public Object createObject() { try { final String o = (String) getParameter( "class" ); return ObjectUtilities.loadAndInstantiate( CompatibilityMapperUtil.mapClassName( o ), getClass(), null ); } catch ( Exception e ) { return null; } }
private void initializeFunctions() { final Configuration config = LibCssBoot.getInstance().getGlobalConfig(); Iterator it = config.findPropertyKeys( CSS_VALUE_FUNCTIONS_PREFIX ); while ( it.hasNext() ) { final String key = (String) it.next(); final String value = config.getConfigProperty( key ); final String name = key.substring( CSS_VALUE_FUNCTIONS_PREFIX.length() ).toLowerCase(); final Object o = ObjectUtilities.loadAndInstantiate( value, AbstractStyleResolver.class, StyleValueFunction.class ); if ( o != null ) { functions.put( name, o ); } } }
public static DataFactoryWriteHandler lookupWriteHandler( final DataFactory dataFactory ) { final String configKey = PREFIX + dataFactory.getClass().getName(); final Configuration globalConfig = ClassicEngineBoot.getInstance().getGlobalConfig(); final String value = globalConfig.getConfigProperty( configKey ); if ( value != null ) { return (DataFactoryWriteHandler) ObjectUtilities.loadAndInstantiate( value, DataFactoryWriter.class, DataFactoryWriteHandler.class ); } return null; }
public static ActionFactory createActionFactory( final Configuration config ) { final String factoryClass = config.getConfigProperty( ACTION_FACTORY_CONFIG_KEY ); final Object maybeFactory = ObjectUtilities.loadAndInstantiate( factoryClass, PreviewPane.class, ActionFactory.class ); final ActionFactory actionFactory; if ( maybeFactory != null ) { actionFactory = (ActionFactory) maybeFactory; } else { actionFactory = new DefaultActionFactory(); } return actionFactory; }
public static synchronized DataCache getCache() { if ( dataCache == null && noCacheDefined == false ) { final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig(); final String cacheImpl = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.cache.DataCache" ); dataCache = ObjectUtilities.loadAndInstantiate( cacheImpl, DataCacheFactory.class, DataCache.class ); if ( dataCache == null ) { logger.info( "Unable to create valid cache, returning <null>" ); noCacheDefined = true; dataCache = null; } } return dataCache; } }
private void writeConnectionInfo( final WriteableDocumentBundle bundle, final BundleWriterState state, final XmlWriter xmlWriter, final ConnectionProvider connectionProvider ) throws IOException, BundleWriterException { final String configKey = SQLDataFactoryModule.CONNECTION_WRITER_PREFIX + connectionProvider.getClass().getName(); final Configuration globalConfig = ClassicEngineBoot.getInstance().getGlobalConfig(); final String value = globalConfig.getConfigProperty( configKey ); if ( value != null ) { final ConnectionProviderWriteHandler handler = ObjectUtilities.loadAndInstantiate( value, SQLReportDataFactory.class, ConnectionProviderWriteHandler.class ); if ( handler != null ) { handler.writeReport( bundle, state, xmlWriter, connectionProvider ); } } }
/** * Constructs a ConfigDescriptionEditor that is initially invisible. */ public ConfigDescriptionEditor( final String booterClass ) { final AbstractBoot boot = ObjectUtilities.loadAndInstantiate( booterClass, ConfigDescriptionEditor.class, AbstractBoot.class ); if ( boot != null ) { boot.start(); this.configurationToEdit = boot.getGlobalConfig(); } init(); }
public static IconTheme createIconTheme( final Configuration config ) { final String themeClass = config.getConfigProperty( ICON_THEME_CONFIG_KEY ); final Object maybeTheme = ObjectUtilities.loadAndInstantiate( themeClass, PreviewPane.class, IconTheme.class ); final IconTheme iconTheme; if ( maybeTheme != null ) { iconTheme = (IconTheme) maybeTheme; } else { iconTheme = new DefaultIconTheme(); } iconTheme.initialize( config ); return iconTheme; }
private AttributeCore parseAttributeCore( final Attributes attrs ) throws ParseException { final AttributeCore attributeCore; final String metaDataCoreClass = attrs.getValue( getUri(), "impl" ); // NON-NLS if ( metaDataCoreClass != null ) { attributeCore = ObjectUtilities.loadAndInstantiate( metaDataCoreClass, AttributeReadHandler.class, AttributeCore.class ); if ( attributeCore == null ) { throw new ParseException( "Attribute 'impl' references a invalid AttributeCore implementation.", getLocator() ); } } else { attributeCore = new DefaultAttributeCore(); } return attributeCore; }
private DataFactoryCore parseDataFactoryCore( final Attributes attrs ) throws ParseException { final String metaDataCoreClass = attrs.getValue( getUri(), "impl" ); // NON-NLS if ( metaDataCoreClass != null ) { DataFactoryCore dataFactoryCore = ObjectUtilities.loadAndInstantiate( metaDataCoreClass, DataFactoryReadHandler.class, DataFactoryCore.class ); if ( dataFactoryCore == null ) { throw new ParseException( "Attribute 'impl' references a invalid DataFactoryPropertyCore implementation.", getLocator() ); } return dataFactoryCore; } else { return new DefaultDataFactoryCore(); } }
protected void startParsing( final Attributes attrs ) throws SAXException { final String validatorClass = attrs.getValue( getUri(), "validator" ); if ( validatorClass == null ) { parameterDefinition.setValidator( new DefaultReportParameterValidator() ); } else { final Object o = ObjectUtilities.loadAndInstantiate( CompatibilityMapperUtil.mapClassName( validatorClass ), getClass(), ReportParameterValidator.class ); if ( o == null ) { throw new ParseException( "Valud given for 'validator' is invalid", getLocator() ); } parameterDefinition.setValidator( (ReportParameterValidator) o ); } }