1 22 package org.jboss.resource.deployment; 23 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.net.URL ; 27 28 import javax.management.ObjectName ; 29 import javax.resource.spi.XATerminator ; 30 import javax.resource.spi.work.WorkManager ; 31 32 import org.jboss.deployment.DeploymentException; 33 import org.jboss.deployment.DeploymentInfo; 34 import org.jboss.deployment.ObjectModelFactorySimpleSubDeployerSupport; 35 import org.jboss.resource.metadata.ConnectorMetaData; 36 import org.jboss.resource.metadata.JBossRAMetaData; 37 import org.jboss.resource.metadata.RARDeploymentMetaData; 38 import org.jboss.xb.binding.ObjectModelFactory; 39 import org.jboss.xb.binding.Unmarshaller; 40 import org.jboss.xb.binding.UnmarshallerFactory; 41 42 49 public class RARDeployer extends ObjectModelFactorySimpleSubDeployerSupport 50 implements RARDeployerMBean 51 { 52 53 54 private static final String JBOSS_RA_XML = "META-INF/jboss-ra.xml"; 55 56 57 protected ObjectName workManagerName; 58 59 60 protected WorkManager workManager; 61 62 63 protected XATerminator xaTerminator; 64 65 66 protected ObjectName xaTerminatorName; 67 68 public RARDeployer() 69 { 70 setEnhancedSuffixes(new String [] { "250:.rar" }); 71 } 72 73 protected void parseMetaData(DeploymentInfo di, URL url) throws DeploymentException 74 { 75 76 super.parseMetaData(di, url); 77 78 InputStream is = di.localCl.getResourceAsStream(JBOSS_RA_XML); 79 RARDeploymentMetaData rdmd = new RARDeploymentMetaData(); 80 rdmd.setConnectorMetaData((ConnectorMetaData)di.metaData); 81 di.metaData = rdmd; 82 83 try 84 { 85 if(is != null) 86 { 87 88 Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); 89 ObjectModelFactory factory = getExtendedObjectModelFactory(); 90 JBossRAMetaData ramd = (JBossRAMetaData)unmarshaller.unmarshal(is, factory, (Object )null); 91 rdmd.setRaXmlMetaData(ramd); 92 93 } 94 95 } 96 97 catch (Throwable t) 98 { 99 100 DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + url, t); 101 102 }finally 103 { 104 try 105 { 106 if(is != null) 107 { 108 is.close(); 109 } 110 } 111 catch (IOException e) 112 { 113 } 114 } 115 116 117 } 118 public String getExtension() 119 { 120 return ".rar"; 121 } 122 123 public String getMetaDataURL() 124 { 125 return "META-INF/ra.xml"; 126 } 127 128 public String getObjectName(DeploymentInfo di) throws DeploymentException 129 { 130 String name = di.shortName; 131 di = di.parent; 132 while (di != null) 133 { 134 name = di.shortName + "#" + name; 135 di = di.parent; 136 } 137 return "jboss.jca:service=RARDeployment,name='" + name + "'"; 138 } 139 140 public String getDeploymentClass() 141 { 142 return RARDeployment.class.getName(); 143 } 144 145 public ObjectModelFactory getObjectModelFactory() 146 { 147 return new ResourceAdapterObjectModelFactory(); 148 } 149 150 public ObjectName getWorkManagerName() 151 { 152 return workManagerName; 153 } 154 155 public void setWorkManagerName(ObjectName workManagerName) 156 { 157 this.workManagerName = workManagerName; 158 } 159 160 public ObjectName getXATerminatorName() 161 { 162 return xaTerminatorName; 163 } 164 165 public void setXATerminatorName(ObjectName xaTerminatorName) 166 { 167 this.xaTerminatorName = xaTerminatorName; 168 } 169 170 protected void startService() throws Exception 171 { 172 workManager = (WorkManager ) server.getAttribute(workManagerName, "Instance"); 173 xaTerminator = (XATerminator ) server.getAttribute(xaTerminatorName, "XATerminator"); 174 super.startService(); 175 } 176 177 private ObjectModelFactory getExtendedObjectModelFactory() 178 { 179 return new JBossRAObjectModelFactory(); 180 } 181 } 182 | Popular Tags |