1 22 package org.jboss.ejb3.embedded.resource; 23 24 import java.net.URL ; 25 import java.util.jar.JarFile ; 26 import java.util.zip.ZipEntry ; 27 28 import org.jboss.deployment.DeploymentInfo; 29 30 import org.jboss.logging.Logger; 31 import org.jboss.resource.metadata.ConnectorMetaData; 32 import org.jboss.resource.metadata.MessageListenerMetaData; 33 import org.jboss.xb.binding.ObjectModelFactory; 34 import org.jboss.xb.binding.Unmarshaller; 35 import org.jboss.xb.binding.UnmarshallerFactory; 36 37 import org.jboss.resource.deployment.ResourceAdapterObjectModelFactory; 38 39 43 public class Ejb3DeploymentInfo extends DeploymentInfo 44 { 45 private static final Logger log = Logger.getLogger(Ejb3DeploymentInfo.class); 46 47 protected String rarName; 48 protected String listenerType; 49 protected String activationSpecType; 50 51 public Ejb3DeploymentInfo(String rarName, String listenerType, String activationSpecType) throws Exception 52 { 53 super(Thread.currentThread().getContextClassLoader().getResource(rarName), null, null); 54 55 this.rarName = rarName; 56 this.listenerType = listenerType; 57 this.activationSpecType = activationSpecType; 58 59 MessageListenerMetaData listener = new MessageListenerMetaData(); 60 listener.setType(listenerType); 61 listener.setActivationSpecType(activationSpecType); 62 ConnectorMetaData metaData = getConnectorMetaData(); 63 this.metaData = metaData; 64 } 65 66 protected ConnectorMetaData getConnectorMetaData() throws Exception 67 { 68 ObjectModelFactory factory = new ResourceAdapterObjectModelFactory(); 69 UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance(); 70 Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); 71 72 URL rar = Thread.currentThread().getContextClassLoader().getResource(rarName); 73 JarFile rarFile = new JarFile (rar.getFile()); 74 ZipEntry entry = rarFile.getEntry("META-INF/ra.xml"); 75 76 ConnectorMetaData metaData = (ConnectorMetaData) unmarshaller.unmarshal(rarFile.getInputStream(entry), 77 factory, null); 78 79 return metaData; 80 } 81 } 82 | Popular Tags |