public void init(URL deployableUnitURL, String deployableUnitName) throws DeploymentException {
		URL url = deployableUnitURL;
		DeployableUnitWrapper du = new DeployableUnitWrapper(deployableUnitURL, deployableUnitName);

		if (logger.isTraceEnabled()) {
			logger.trace("Method init called for " + deployableUnitURL + " [DU: " + deployableUnitName + "]");
		}

		// Get the full path and filename for this du
		String fullPath = du.getFullPath();
		String fileName = du.getFileName();

		try {
			DeployableUnitWrapper duWrapper = null;

			// If we're able to remove it from toAccept was because it was
			// there!
			if ((duWrapper = toAccept.remove(fileName)) != null) {
				// Create a new Deployable Component from this DI.
				DeployableComponent dc = new DeployableComponent(du, url,
						fileName, sleeContainerDeployer);

				// Also get the deployable unit for this (it exists, we've
				// checked!)
				DeployableUnit deployerDU = deployableUnits.get(duWrapper
						.getFileName());

				for (DeployableComponent subDC : dc.getSubComponents()) {
					// Add the sub-component to the DU object.
					deployerDU.addComponent(subDC);
				}
			}
			// If the DU for this component doesn't exists.. it's a new DU!
			else if (fileName.endsWith(".jar")) {
				JarFile duJarFile = null;

				try {
					// Get a reference to the DU jar file
					duJarFile = new JarFile(fullPath);

					// Try to get the Deployable Unit descriptor
					JarEntry duXmlEntry = duJarFile
							.getJarEntry("META-INF/deployable-unit.xml");

					// Got descriptor?
					if (duXmlEntry != null) {
						// Create a new Deployable Unit object.
						DeployableUnit deployerDU = new DeployableUnit(du,sleeContainerDeployer);

						// Let's parse the descriptor to see what we've got...
						DeployableUnitDescriptorFactory dudf = sleeContainerDeployer
								.getSleeContainer().getComponentManagement()
								.getDeployableUnitManagement()
								.getDeployableUnitDescriptorFactory();
						DeployableUnitDescriptor duDesc = dudf.parse(duJarFile
								.getInputStream(duXmlEntry));

						// If the filename is present, an undeploy in on the way... let's wait
						while(deployableUnits.containsKey(fileName)) {
							Thread.sleep(getWaitTimeBetweenOperations());
						}
						
						// Add it to the deployable units map.
						deployableUnits.put(fileName, deployerDU);

						// Go through each jar entry in the DU descriptor
						for (String componentJarName : duDesc.getJarEntries()) {
							// Might have path... strip it!
							int beginIndex;

							if ((beginIndex = componentJarName.lastIndexOf('/')) == -1)
								beginIndex = componentJarName.lastIndexOf('\\');

							beginIndex++;

							// Got a clean jar name, no paths.
							componentJarName = componentJarName.substring(
									beginIndex, componentJarName.length());

							// Put it in the accept list.
							toAccept.put(componentJarName, du);
						}

						// Do the same as above... but for services
						for (String serviceXMLName : duDesc.getServiceEntries()) {
							// Might have path... strip it!
							int beginIndex;

							if ((beginIndex = serviceXMLName.lastIndexOf('/')) == -1)
								beginIndex = serviceXMLName.lastIndexOf('\\');

							beginIndex++;

							// Got a clean XML filename
							serviceXMLName = serviceXMLName.substring(
									beginIndex, serviceXMLName.length());

							// Add it to the accept list.
							toAccept.put(serviceXMLName, du);
						}
					}
				} finally {
					// Clean up!
					if (duJarFile != null) {
						try {
							duJarFile.close();
						} catch (IOException ignore) {
						} finally {
							duJarFile = null;
						}
					}
				}
			}
		} catch (Exception e) {
			// Something went wrong...
			logger.error("Deployment of " + fileName + " failed. ", e);

			return;
		}
	}
public void init(URL deployableUnitURL, String deployableUnitName) throws DeploymentException {
		URL url = deployableUnitURL;
		DeployableUnitWrapper du = new DeployableUnitWrapper(deployableUnitURL, deployableUnitName);

		if (logger.isTraceEnabled()) {
			logger.trace("Method init called for " + deployableUnitURL + " [DU: " + deployableUnitName + "]");
		}

		
		String fullPath = du.getFullPath();
		String fileName = du.getFileName();

		try {
			DeployableUnitWrapper duWrapper = null;

			
			
			if ((duWrapper = toAccept.remove(fileName)) != null) {
				
				DeployableComponent dc = new DeployableComponent(du, url,
						fileName, sleeContainerDeployer);

				
				
				DeployableUnit deployerDU = deployableUnits.get(duWrapper
						.getFileName());

				for (DeployableComponent subDC : dc.getSubComponents()) {
					
					deployerDU.addComponent(subDC);
				}
			}
			
			else if (fileName.endsWith(".jar")) {
				JarFile duJarFile = null;

				try {
					
					duJarFile = new JarFile(fullPath);

					
					JarEntry duXmlEntry = duJarFile
							.getJarEntry("META-INF/deployable-unit.xml");

					
					if (duXmlEntry != null) {
						
						DeployableUnit deployerDU = new DeployableUnit(du,sleeContainerDeployer);

						
						DeployableUnitDescriptorFactory dudf = sleeContainerDeployer
								.getSleeContainer().getComponentManagement()
								.getDeployableUnitManagement()
								.getDeployableUnitDescriptorFactory();
						DeployableUnitDescriptor duDesc = dudf.parse(duJarFile
								.getInputStream(duXmlEntry));

						
						while(deployableUnits.containsKey(fileName)) {
							Thread.sleep(getWaitTimeBetweenOperations());
						}
						
						
						deployableUnits.put(fileName, deployerDU);

						
						for (String componentJarName : duDesc.getJarEntries()) {
							
							int beginIndex;

							if ((beginIndex = componentJarName.lastIndexOf('/')) == -1)
								beginIndex = componentJarName.lastIndexOf('\\');

							beginIndex++;

							
							componentJarName = componentJarName.substring(
									beginIndex, componentJarName.length());

							
							toAccept.put(componentJarName, du);
						}

						
						for (String serviceXMLName : duDesc.getServiceEntries()) {
							
							int beginIndex;

							if ((beginIndex = serviceXMLName.lastIndexOf('/')) == -1)
								beginIndex = serviceXMLName.lastIndexOf('\\');

							beginIndex++;

							
							serviceXMLName = serviceXMLName.substring(
									beginIndex, serviceXMLName.length());

							
							toAccept.put(serviceXMLName, du);
						}
					}
				} finally {
					
					if (duJarFile != null) {
						try {
							duJarFile.close();
						} catch (IOException ignore) {
						} finally {
							duJarFile = null;
						}
					}
				}
			}
		} catch (Exception e) {
			
			logger.error("Deployment of " + fileName + " failed. ", e);

			return;
		}
	}
public void init ( URL deployableUnitURL , String deployableUnitName ) throws DeploymentException { URL url = deployableUnitURL ; DeployableUnitWrapper du = new DeployableUnitWrapper ( deployableUnitURL , deployableUnitName ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Method init called for " + deployableUnitURL + " [DU: " + deployableUnitName + "]" ) ; } // Get the full path and filename for this du String fullPath = du . getFullPath ( ) ; String fileName = du . getFileName ( ) ; try { DeployableUnitWrapper duWrapper = null ; // If we're able to remove it from toAccept was because it was // there! if ( ( duWrapper = toAccept . remove ( fileName ) ) != null ) { // Create a new Deployable Component from this DI. DeployableComponent dc = new DeployableComponent ( du , url , fileName , sleeContainerDeployer ) ; // Also get the deployable unit for this (it exists, we've // checked!) DeployableUnit deployerDU = deployableUnits . get ( duWrapper . getFileName ( ) ) ; for ( DeployableComponent subDC : dc . getSubComponents ( ) ) { // Add the sub-component to the DU object. deployerDU . addComponent ( subDC ) ; } } // If the DU for this component doesn't exists.. it's a new DU! else if ( fileName . endsWith ( ".jar" ) ) { JarFile duJarFile = null ; try { // Get a reference to the DU jar file duJarFile = new JarFile ( fullPath ) ; // Try to get the Deployable Unit descriptor JarEntry duXmlEntry = duJarFile . getJarEntry ( "META-INF/deployable-unit.xml" ) ; // Got descriptor? if ( duXmlEntry != null ) { // Create a new Deployable Unit object. DeployableUnit deployerDU = new DeployableUnit ( du , sleeContainerDeployer ) ; // Let's parse the descriptor to see what we've got... DeployableUnitDescriptorFactory dudf = sleeContainerDeployer . getSleeContainer ( ) . getComponentManagement ( ) . getDeployableUnitManagement ( ) . getDeployableUnitDescriptorFactory ( ) ; DeployableUnitDescriptor duDesc = dudf . parse ( duJarFile . getInputStream ( duXmlEntry ) ) ; // If the filename is present, an undeploy in on the way... let's wait while ( deployableUnits . containsKey ( fileName ) ) { Thread . sleep ( getWaitTimeBetweenOperations ( ) ) ; } // Add it to the deployable units map. deployableUnits . put ( fileName , deployerDU ) ; // Go through each jar entry in the DU descriptor for ( String componentJarName : duDesc . getJarEntries ( ) ) { // Might have path... strip it! int beginIndex ; if ( ( beginIndex = componentJarName . lastIndexOf ( ' ' ) ) == - 1 ) beginIndex = componentJarName . lastIndexOf ( ' ' ) ; beginIndex ++ ; // Got a clean jar name, no paths. componentJarName = componentJarName . substring ( beginIndex , componentJarName . length ( ) ) ; // Put it in the accept list. toAccept . put ( componentJarName , du ) ; } // Do the same as above... but for services for ( String serviceXMLName : duDesc . getServiceEntries ( ) ) { // Might have path... strip it! int beginIndex ; if ( ( beginIndex = serviceXMLName . lastIndexOf ( ' ' ) ) == - 1 ) beginIndex = serviceXMLName . lastIndexOf ( ' ' ) ; beginIndex ++ ; // Got a clean XML filename serviceXMLName = serviceXMLName . substring ( beginIndex , serviceXMLName . length ( ) ) ; // Add it to the accept list. toAccept . put ( serviceXMLName , du ) ; } } } finally { // Clean up! if ( duJarFile != null ) { try { duJarFile . close ( ) ; } catch ( IOException ignore ) { } finally { duJarFile = null ; } } } } } catch ( Exception e ) { // Something went wrong... logger . error ( "Deployment of " + fileName + " failed. " , e ) ; return ; } }
Initializer method for accepted files. Will parse descriptors at this
point.
Initializer method for accepted files . Will parse descriptors at this point .