Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 /
 
 
 /*
  * Created on : 09.07.2003
  * Created by : s3595
  */
 package at.spardat.xma.boot.comp;
 
 
AppLoaderTools

Author(s):
s3595 Chr. Schaefer (CGS)
Version:
$Id: AppLoaderBase.java 2084 2007-11-27 14:53:31Z s3460 $
 
 public class AppLoaderBase {

    
logger for parser
 
     protected Logger log_;

    
logger for parser
 
     protected Logger parseLog_;

    
configuration properties
 
     protected Properties props;

    
constructs a AppLoaderBase

Parameters:
pnew the boot runtime properties
 
     protected AppLoaderBaseProperties pnew ) {
 
         ifpnew !=null){
                   = pnew;
         } else
              = new Properties();
 
                = Logger.getLogger"boot.appLoader"); //$NON-NLS-1$
           = Logger.getLogger"boot.parser"); //$NON-NLS-1$
     }

    
merge plugin information into the main descriptor.

Parameters:
main application descriptor
plugins import this
 
     protected void mergeIntoXMAApp mainXMAApp plugins ) {
 
         ifplugins.components_.size() > 0 ) {
             .warning("Plug-In Descriptor contains components. They will be ignored");  //$NON-NLS-1$
         }
         ifplugins.pluginspec_.size() > 0 ) {
             .warning("Plug-In Descriptor contains plugin-specs. It should only contain plugin implementations. They will be ignored");  //$NON-NLS-1$
         }
 
         // this.pluginimpl_.put( pi.getStrImplements_(), pi);
 
         for (Iterator iter = plugins.pluginimpl_.values().iterator(); iter.hasNext();) {
             XMAPluginImpl el = (XMAPluginImpl)iter.next();
 
             XMAPluginImpl old = (XMAPluginImpl)main.pluginimpl_.getel.getStrImplements_() );
             ifold != null ) {
                 .warning("Application Descriptor already contains a plug-in implementation for: " + el.getStrImplements_() + " it will be replaced the implementation of this plugins.xml" );  //$NON-NLS-1$ //$NON-NLS-2$
             }
             main.pluginimpl_.putel.getStrImplements_(), el );
         }
 
         for (Iterator iter = plugins.res_.values().iterator() ; iter.hasNext();) {
             XMAResource el = (XMAResource)iter.next();
 
             XMAResource old = (XMAResource)main.res_.getel.getHref_() );
             ifold != null ) {
                 .warning("Application Descriptor already contains a resource for: " + el.getHref_() + " it will be replaced the resource of this plugins.xml" );  //$NON-NLS-1$ //$NON-NLS-2$
             }
             main.addResource(el);
        }
    } // mergeInto

    
creates the has value for the application. This is done by concatenating the content of the two given input streams and calculating the MD5-hash over this combined content.

Parameters:
isApp first description file (xma-app.xml)
isPi second description file (plugin.xml)
Returns:
the calculated hash value
Throws:
java.io.IOException in case of errors reading the streams
    protected byte[] createApplicationHash(InputStream isAppInputStream isPi ) throws IOException  {
        MessageDigest         md;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            .log(.,"error preventing hash calculations: ",e);
            throw new RuntimeException(e);
        }
        int                   b      = -1;
        ByteArrayOutputStream os     = new ByteArrayOutputStream();
        while( (b = isApp.read())!= -1 ) {
            os.write(b);
        }
        while( (b = isPi.read())!= -1 ) {
            os.write(b);
        }
        md.updateos.toByteArray() );
        byte[] digest = md.digest();
        return digest;
    }
New to GrepCode? Check out our FAQ X