Source Code Cross Referenced for RARDeployment.java in  » EJB-Server-JBoss-4.2.1 » connector » org » jboss » resource » deployment » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » connector » org.jboss.resource.deployment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.resource.deployment;
023:
024:        import java.util.Collection;
025:        import java.util.Iterator;
026:        import java.util.Timer;
027:
028:        import javax.management.AttributeNotFoundException;
029:        import javax.management.MBeanAttributeInfo;
030:        import javax.management.MBeanException;
031:        import javax.management.MBeanOperationInfo;
032:        import javax.management.MBeanParameterInfo;
033:        import javax.management.ReflectionException;
034:        import javax.resource.spi.ActivationSpec;
035:        import javax.resource.spi.BootstrapContext;
036:        import javax.resource.spi.ResourceAdapter;
037:        import javax.resource.spi.UnavailableException;
038:        import javax.resource.spi.XATerminator;
039:        import javax.resource.spi.endpoint.MessageEndpointFactory;
040:        import javax.resource.spi.work.WorkManager;
041:
042:        import org.jboss.deployment.DeploymentException;
043:        import org.jboss.deployment.DeploymentInfo;
044:        import org.jboss.resource.metadata.ConfigPropertyMetaData;
045:        import org.jboss.resource.metadata.ConnectorMetaData;
046:        import org.jboss.resource.metadata.DescriptionGroupMetaData;
047:        import org.jboss.resource.metadata.MessageListenerMetaData;
048:        import org.jboss.system.ServiceDynamicMBeanSupport;
049:        import org.jboss.system.server.ServerConfigUtil;
050:
051:        /**
052:         * A resource adapter deployment
053:         *
054:         * @author  <a href="adrian@jboss.com">Adrian Brock</a>
055:         * @version $Revision: 57189 $
056:         */
057:        public class RARDeployment extends ServiceDynamicMBeanSupport implements 
058:                BootstrapContext {
059:            /** The deployment info */
060:            protected DeploymentInfo di;
061:
062:            /** Our deployer */
063:            protected RARDeployer deployer;
064:
065:            /** The meta data */
066:            protected ConnectorMetaData cmd;
067:
068:            /** The resource adapter */
069:            protected ResourceAdapter resourceAdapter;
070:
071:            /**
072:             * Create a new RAR deployment
073:             * 
074:             * @param di the deployment info
075:             */
076:            public RARDeployment(DeploymentInfo di) {
077:                this .di = di;
078:                this .deployer = (RARDeployer) di.deployer;
079:                this .cmd = (ConnectorMetaData) di.metaData;
080:            }
081:
082:            // Public --------------------------------------------------------
083:
084:            public Timer createTimer() throws UnavailableException {
085:                return new Timer(true);
086:            }
087:
088:            public WorkManager getWorkManager() {
089:                return deployer.workManager;
090:            }
091:
092:            public XATerminator getXATerminator() {
093:                return deployer.xaTerminator;
094:            }
095:
096:            protected void startService() throws Exception {
097:                if (cmd.getLicense().getRequired()) {
098:                    log
099:                            .info("Required license terms exist, view META-INF/ra.xml in "
100:                                    + ServerConfigUtil
101:                                            .shortUrlFromServerHome(di.url
102:                                                    .toString()));
103:                    log.debug("License terms full URL: " + di.url);
104:                }
105:                resourceAdapter = ResourceAdapterFactory
106:                        .createResourceAdapter(cmd);
107:                resourceAdapter.start(this );
108:            }
109:
110:            protected void stopService() throws Exception {
111:                resourceAdapter.stop();
112:            }
113:
114:            protected String getInternalDescription() {
115:                String description = null;
116:                DescriptionGroupMetaData dgmd = cmd.getDescription();
117:                if (dgmd != null)
118:                    description = dgmd.getDescription();
119:                if (description == null)
120:                    description = "RAR Deployment " + di.url;
121:                return description;
122:            }
123:
124:            protected MBeanAttributeInfo[] getInternalAttributeInfo() {
125:                Collection properties = cmd.getProperties();
126:                MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[11 + properties
127:                        .size()];
128:                attrs[0] = new MBeanAttributeInfo("MetaData",
129:                        ConnectorMetaData.class.getName(), "The meta data",
130:                        true, false, false);
131:                attrs[1] = new MBeanAttributeInfo("AuthenticationMechanism",
132:                        String.class.getName(), "The authentication mechanism",
133:                        true, false, false);
134:                attrs[2] = new MBeanAttributeInfo("EISType", String.class
135:                        .getName(), "The EIS type", true, false, false);
136:                attrs[3] = new MBeanAttributeInfo("License", String.class
137:                        .getName(), "The license", true, false, false);
138:                attrs[4] = new MBeanAttributeInfo("RAClass", String.class
139:                        .getName(), "The resource adapter class", true, false,
140:                        false);
141:                attrs[5] = new MBeanAttributeInfo("RAVersion", String.class
142:                        .getName(), "The resource adapter version", true,
143:                        false, false);
144:                attrs[6] = new MBeanAttributeInfo("TransactionSupport",
145:                        String.class.getName(), "The transaction support",
146:                        true, false, false);
147:                attrs[7] = new MBeanAttributeInfo("VendorName", String.class
148:                        .getName(), "The vendor name", true, false, false);
149:                attrs[8] = new MBeanAttributeInfo("Version", String.class
150:                        .getName(), "The spec version", true, false, false);
151:                attrs[9] = new MBeanAttributeInfo("ReauthenticationSupport",
152:                        Boolean.TYPE.getName(),
153:                        "Whether reauthentication support is supported", true,
154:                        false, false);
155:                attrs[10] = new MBeanAttributeInfo("ResourceAdapter",
156:                        ResourceAdapter.class.getName(),
157:                        "The resource adapter instance", true, false, false);
158:                int n = 11;
159:                for (Iterator i = properties.iterator(); i.hasNext();) {
160:                    ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData) i
161:                            .next();
162:                    attrs[n++] = new MBeanAttributeInfo(cpmd.getName(), cpmd
163:                            .getType(), cpmd.getDescription().getDescription(),
164:                            true, false, false);
165:                }
166:                return attrs;
167:            }
168:
169:            protected Object getInternalAttribute(String attribute)
170:                    throws AttributeNotFoundException, MBeanException,
171:                    ReflectionException {
172:                if ("MetaData".equals(attribute))
173:                    return cmd;
174:                else if ("AuthenticationMechanism".equals(attribute))
175:                    return cmd.getAuthenticationMechanism()
176:                            .getAuthenticationMechansimType();
177:                else if ("EISType".equals(attribute))
178:                    return cmd.getEISType();
179:                else if ("License".equals(attribute))
180:                    return cmd.getLicense().getDescription().getDescription();
181:                else if ("RAClass".equals(attribute))
182:                    return cmd.getRAClass();
183:                else if ("RAVersion".equals(attribute))
184:                    return cmd.getRAVersion();
185:                else if ("TransactionSupport".equals(attribute))
186:                    return cmd.getTransactionSupport();
187:                else if ("VendorName".equals(attribute))
188:                    return cmd.getVendorName();
189:                else if ("Version".equals(attribute))
190:                    return cmd.getVersion();
191:                else if ("ReauthenticationSupport".equals(attribute))
192:                    return new Boolean(cmd.getReauthenticationSupport());
193:                else if ("ResourceAdapter".equals(attribute))
194:                    return resourceAdapter;
195:                Object property = cmd.getProperty(attribute);
196:                if (property != null)
197:                    return property;
198:
199:                return super .getInternalAttribute(attribute);
200:            }
201:
202:            protected MBeanOperationInfo[] getInternalOperationInfo() {
203:                MBeanOperationInfo[] ops = new MBeanOperationInfo[3];
204:
205:                MBeanParameterInfo[] createActivationSpecParams = new MBeanParameterInfo[] {
206:                        new MBeanParameterInfo("MessagingType", Class.class
207:                                .getName(), "The type of the message listener"),
208:                        new MBeanParameterInfo("ActivationConfig",
209:                                Collection.class.getName(),
210:                                "A collection of activation config properties") };
211:                ops[0] = new MBeanOperationInfo("createActivationSpec",
212:                        "Create an activation spec",
213:                        createActivationSpecParams, ActivationSpec.class
214:                                .getName(), MBeanOperationInfo.ACTION);
215:
216:                MBeanParameterInfo[] activationParams = new MBeanParameterInfo[] {
217:                        new MBeanParameterInfo("MessageEndpointFactory",
218:                                MessageEndpointFactory.class.getName(),
219:                                "The message endpoint factory"),
220:                        new MBeanParameterInfo("ActivationSpec",
221:                                ActivationSpec.class.getName(),
222:                                "The activation spec") };
223:                ops[1] = new MBeanOperationInfo("endpointActivation",
224:                        "Active the endpoint", activationParams, Void.class
225:                                .getName(), MBeanOperationInfo.ACTION);
226:                ops[2] = new MBeanOperationInfo("endpointDeactivation",
227:                        "Deactive the endpoint", activationParams, Void.class
228:                                .getName(), MBeanOperationInfo.ACTION);
229:
230:                return ops;
231:            }
232:
233:            protected Object internalInvoke(String actionName, Object[] params,
234:                    String[] signature) throws MBeanException,
235:                    ReflectionException {
236:                if ("createActivationSpec".equals(actionName)) {
237:                    if (params.length != 2)
238:                        throw new IllegalArgumentException(
239:                                "Wrong number of parameters for " + actionName);
240:                    Class messagingType = (Class) params[0];
241:                    Collection activationConfig = (Collection) params[1];
242:                    return createActivationSpec(messagingType, activationConfig);
243:                } else if ("endpointActivation".equals(actionName)) {
244:                    if (params.length != 2)
245:                        throw new IllegalArgumentException(
246:                                "Wrong number of parameters for " + actionName);
247:                    MessageEndpointFactory messageEndpointFactory = (MessageEndpointFactory) params[0];
248:                    ActivationSpec activationSpec = (ActivationSpec) params[1];
249:                    endpointActivation(messageEndpointFactory, activationSpec);
250:                    return null;
251:                } else if ("endpointDeactivation".equals(actionName)) {
252:                    if (params.length != 2)
253:                        throw new IllegalArgumentException(
254:                                "Wrong number of parameters for " + actionName);
255:                    MessageEndpointFactory messageEndpointFactory = (MessageEndpointFactory) params[0];
256:                    ActivationSpec activationSpec = (ActivationSpec) params[1];
257:                    endpointDeactivation(messageEndpointFactory, activationSpec);
258:                    return null;
259:                }
260:                return super .internalInvoke(actionName, params, signature);
261:            }
262:
263:            protected ActivationSpec createActivationSpec(Class messagingType,
264:                    Collection activationConfig) throws MBeanException {
265:                boolean trace = log.isTraceEnabled();
266:                if (trace)
267:                    log.trace("CreateActivateSpec rar=" + getServiceName()
268:                            + " messagingType=" + messagingType.getName()
269:                            + " activationConfig=" + activationConfig);
270:
271:                try {
272:                    // Find the meta data
273:                    MessageListenerMetaData mlmd = cmd
274:                            .getMessageListener(messagingType.getName());
275:                    if (mlmd == null)
276:                        throw new DeploymentException("MessagingType '"
277:                                + messagingType.getName()
278:                                + "' not found in resource deployment "
279:                                + getServiceName());
280:
281:                    return ActivationSpecFactory.createActivationSpec(
282:                            getServiceName(), messagingType.getName(),
283:                            activationConfig, mlmd);
284:                } catch (Exception e) {
285:                    throw new MBeanException(e,
286:                            "Error in create activation spec "
287:                                    + getServiceName());
288:                }
289:            }
290:
291:            protected void endpointActivation(
292:                    MessageEndpointFactory messageEndpointFactory,
293:                    ActivationSpec activationSpec) throws MBeanException {
294:                boolean trace = log.isTraceEnabled();
295:                if (trace)
296:                    log.trace("EndpointActivation rar=" + getServiceName()
297:                            + " messagingEndpointFactory="
298:                            + messageEndpointFactory + " activationSpec="
299:                            + activationSpec);
300:
301:                try {
302:                    activationSpec.setResourceAdapter(resourceAdapter);
303:                    resourceAdapter.endpointActivation(messageEndpointFactory,
304:                            activationSpec);
305:                } catch (Exception e) {
306:                    throw new MBeanException(e, "Error in endpoint activation "
307:                            + getServiceName());
308:                }
309:            }
310:
311:            protected void endpointDeactivation(
312:                    MessageEndpointFactory messageEndpointFactory,
313:                    ActivationSpec activationSpec) throws MBeanException {
314:                boolean trace = log.isTraceEnabled();
315:                if (trace)
316:                    log.trace("EndpointDeactivation rar=" + getServiceName()
317:                            + " messagingEndpointFactory="
318:                            + messageEndpointFactory + " activationSpec="
319:                            + activationSpec);
320:
321:                try {
322:                    resourceAdapter.endpointDeactivation(
323:                            messageEndpointFactory, activationSpec);
324:                } catch (Exception e) {
325:                    throw new MBeanException(e,
326:                            "Error in endpoint deactivation "
327:                                    + getServiceName());
328:                }
329:            }
330:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.