KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > embedded > resource > Ejb3DeploymentInfo


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb3.embedded.resource;
23
24 import java.net.URL JavaDoc;
25 import java.util.jar.JarFile JavaDoc;
26 import java.util.zip.ZipEntry JavaDoc;
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 /**
40  * @version <tt>$Revision: 46471 $</tt>
41  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
42  */

43 public class Ejb3DeploymentInfo extends DeploymentInfo
44 {
45    private static final Logger log = Logger.getLogger(Ejb3DeploymentInfo.class);
46    
47    protected String JavaDoc rarName;
48    protected String JavaDoc listenerType;
49    protected String JavaDoc activationSpecType;
50   
51    public Ejb3DeploymentInfo(String JavaDoc rarName, String JavaDoc listenerType, String JavaDoc activationSpecType) throws Exception JavaDoc
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 JavaDoc
67    {
68       ObjectModelFactory factory = new ResourceAdapterObjectModelFactory();
69       UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
70       Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
71       
72       URL JavaDoc rar = Thread.currentThread().getContextClassLoader().getResource(rarName);
73       JarFile JavaDoc rarFile = new JarFile JavaDoc(rar.getFile());
74       ZipEntry JavaDoc 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