Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013 SAP 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: SAP AG - initial contribution /
 
 
 package org.eclipse.virgo.web.enterprise.persistence.openejb.classloading.hook;
 
 import java.io.File;
 
 
 
 	private static final String FILE_SCHEME = "file:";
 	private static final String WEB_CONTEXTPATH_HEADER = "Web-ContextPath";
 	private static final Logger logger = Logger
 			.getLogger("com.sap.core.service.accessor.persistence.classloading.hook.AppLoaderClasspathExtenderClassLoadingHook");
 	private static final String PERSISTENCE_INTEGRATION_JAR_PROP_NAME = "persistence.integration.jar.name";
 	private static final String CONFIG_AREA = "osgi.configuration.area";
 	private static final String LIB_DIR = "lib";
 	private static final String PERSISTENCE_DIR = "persistence";
 	
 	public void addHooks(HookRegistry registry) {
 		registry.addClassLoadingHook(this);
 	}
 
 	public boolean addClassPathEntry(ArrayList<ClasspathEntrycpEntriesString cpClasspathManager hostmanagerBaseData sourcedataProtectionDomain sourcedomain) {
 		if (isAppBundle(sourcedata) && (shouldAdd(cpEntries))) {
 			ClasspathEntry persistenceIntegrationClasspathEntry = null;
 			try {
 				persistenceIntegrationClasspathEntry = determinePersistenceIntegrationPath(hostmanagersourcedatasourcedomain);
 			}
 			
 			if (persistenceIntegrationClasspathEntry != null) {
 				cpEntries.add(persistenceIntegrationClasspathEntry);
 				return true;
 			}
 		}
 		return false;
 	}
 
 	boolean shouldAdd(ArrayList<ClasspathEntrycpEntries) {
 		for (ClasspathEntry cpEntry : cpEntries) {
 				return false;
 			}
 		}
 		return true;
 	}
 
 		if ( == null) {
 		}
 		
 		ClasspathEntry cp = hostmanager.getExternalClassPath(.getAbsolutePath(), sourcedatasourcedomain);
 		if (cp == null) {
 			throw new ClasspathExtenderClassLoadingHookException("Failed to create classpath entry for file [" +  + "]");
 		}
 		
 		return cp;
 	}
 
 		String configurationPath = System.getProperty();
 		if (configurationPath == null) {
 			throw new ClasspathExtenderClassLoadingHookException("Property [" +  + "] is missing");
 		}
 		File configurationFile = new File(normalize(configurationPath));
 		File lib = new File(configurationFile.getParentFile(), );
 		if (!lib.exists()) {
			throw new ClasspathExtenderClassLoadingHookException("lib folder is missing");
		}
		File persistenceLibDir = new File(lib);
		if (!persistenceLibDir.exists()) {
			throw new ClasspathExtenderClassLoadingHookException("lib/persistence folder is missing");
		}
		String[] libs = persistenceLibDir.list(new FilenameFilter() {	
			public boolean accept(File dirString name) {
					return true;
				}
				return false;
			}
		});
		if (libs.length == 0) {
			throw new ClasspathExtenderClassLoadingHookException("No file with name starting with [" +  + "] was found in lib/persistence folder");
		}
		if (libs.length > 1) {
			.log(."Found " + libs.length + " files with name starting with [" +  + "] was found in lib/persistence folder (one expected); choosing [" + libs[0] + "]");
		}
		 = new File(persistenceLibDirlibs[0]);
	}
	String normalize(String filePath) {
		if (filePath.startsWith()) {
			return filePath.substring(.length());
		}
		return filePath;
	}
	boolean isAppBundle(BaseData sourcedata) {
		try {
			if (sourcedata.getManifest().get() != null) {
				return true;
			}
catch (BundleException e) {
			.log(."Error checking if bundle [" + sourcedata
"] is application."e);
			return false;
		}
		return false;
	}
			ClassLoaderDelegate delegateBundleProtectionDomain protectionDomain,
			BaseData sourcedataString[] classpath) {
		return null;
	}
	public String findLibrary(BaseData arg0String arg1) {
		// TODO Auto-generated method stub
		return null;
	}
		// TODO Auto-generated method stub
		return null;
	}
	public void initializedClassLoader(BaseClassLoader arg0BaseData arg1) {
		// TODO Auto-generated method stub
	}
	public byte[] processClass(String namebyte[] classbytesClasspathEntry classpathEntry,
			BundleEntry entryClasspathManager classpathManager) {
		return null;
	}
New to GrepCode? Check out our FAQ X