[jboss-svn-commits] JBL Code SVN: r15415 - in labs/jbosstm/workspace/baframework/trunk: demo/resources/web and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 27 19:40:22 EDT 2007
Author: maciej.machulak
Date: 2007-09-27 19:40:22 -0400 (Thu, 27 Sep 2007)
New Revision: 15415
Added:
labs/jbosstm/workspace/baframework/trunk/demo/resources/web/checkout.jsp
labs/jbosstm/workspace/baframework/trunk/readme.txt
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BATaskVisitor.java
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/CommonServiceInfo.java
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/EJBMethodDescriptionImpl.java
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/IncorrectDataException.java
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/ServiceType.java
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/WebMethodDescriptionImpl.java
Removed:
labs/jbosstm/workspace/baframework/trunk/README.txt
labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BAServiceVisitor.java
Log:
Corrected Service Visitor component -> Task Visitor
Deleted: labs/jbosstm/workspace/baframework/trunk/README.txt
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/README.txt 2007-09-27 23:30:01 UTC (rev 15414)
+++ labs/jbosstm/workspace/baframework/trunk/README.txt 2007-09-27 23:40:22 UTC (rev 15415)
@@ -1,144 +0,0 @@
-JBoss, Home of Professional Open Source
-Copyright 2007, Red Hat Middleware LLC, and individual contributors
-as indicated by the @author tags.
-See the copyright.txt in the distribution for a full listing
-of individual contributors.
-This copyrighted material is made available to anyone wishing to use,
-modify, copy, or redistribute it subject to the terms and conditions
-of the GNU General Public License, v. 2.0.
-This program is distributed in the hope that it will be useful, but WITHOUT A
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-You should have received a copy of the GNU General Public License,
-v. 2.0 along with this distribution; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-MA 02110-1301, USA.
-
-(C) 2007,
- at author JBoss Inc.
-
-### Business Activity Framework & Demo Application
-### Version: 0.1
-### Date: July 31, 2007
-### Author: Maciej Machulak (mmachulak at redhat.com)
-### WWW: http://labs.jboss.com/jbosstm/baframework
-
-Contents:
-1. Introduction
-2. Building Business Activity Framework
-3. Building Business Activity Demo Application
-4. Other documentation
-
-
-### 1. Introduction
-
-The Business Activity Framework is a fully novel comprehensive solution for building
-transactional Web Services with accordance to the model defined in the WS-BusinessActivity
-specification. It provides a lightweight API that consists of a set of easy to learn and
-intuitive annotations and operations. It significantly facilitates development of transaction
-aware Web Services and releases programmers from mixing transaction related code with business
-logic of their applications.
-Web Services must be simply annotated with a set of defined annotations and the framework
-transparently applies all necessary transactional mechanisms to enable participation in
-long-running Business Activities.
-
-IMPORTANT NOTICE:
-This is the first release of the framework and is aimed mainly for testing.
-
-It it assumed that demo application is tested locally - Coordinator has been set to
-following address: http://localhost:8080. This is set in the following file:
-ws-c.war (WEB-INF/web.xml)
-
- <init-param>
- <param-name>BaseHttpURI</param-name>
- <param-value>http://localhost:8080/xts/soap/</param-value>
- </init-param>
-
-The client application uses the http://localhost:8080 address to lookup Web Services
-by default as well. This can be changed in the following source file:
-com/jboss/ba/demo/client/HotelService.java
-
-JBoss Application Server on which the Business Activity Framework is to be used must be
-able to understand aspects (using JBoss AOP framework). By default JBoss AOP is bundled
-with the application server. For information how to enable this
-feature please refer to the JBoss AOP documentation.
-
-
-### 2. Building Business Activity framework
-
-Building the BA Framework requires following components:
-- JDK (version 1.5)
- (available at http://java.sun.com/javase/downloads/index_jdk5.jsp)
-- Ant build tool (version 1.7.0)
- (available at http://ant.apache.org/)
-- JBoss Application Server (version 4.2.0 GA)
- (available at http://labs.jboss.com/jbossas/)
-- JBoss Transaction Service (version 4.2.3 SP5)
- (available at http://labs.jboss.com/jbosstm/)
-
-1) Edit 'build.xml' file and set following properties:
- - jboss.home (i.e. "/home/mmachulak/dev/jboss-4.2.0.GA")
- - xts.home" (i.e. "/home/mmachulak/dev/JBossTS/XTS/xts-install")
-
-2) Run 'ant'
- This produces following files:
- - build/baframework-client.jar
- - build/baframework.aop
-
- 'baframework-client.jar' file needs to be in the classpath of the application that wants
- to use the framework.
- 'baframework.aop' file must be deployed with the application as shown in the following
- example of application.xml file:
-
- <application>
- <module>
- <ejb>MyEJB.jar</ejb>
- </module>
-
- <module>
- <java>baframework.aop</java>
- </module>
- </application>
-
- For the use of the demo application it is not necessary to copy those files anywhere.
-
-
-### 3. Building Business Activity Demo Application
-
-Building the BA Framework Demo Application requires following components:
-- JDK (version 1.5)
- (available at http://java.sun.com/javase/downloads/index_jdk5.jsp)
-- Ant build tool (version 1.7.0)
- (available at http://ant.apache.org/)
-- JBoss Application Server (version 4.2.0 GA)
- (available at http://labs.jboss.com/jbossas/)
-- JBoss Transaction Service (version 4.2.3 SP5)
- (available at http://labs.jboss.com/jbosstm/)
-
-1) Go to the demo/ directory (i.e. 'cd demo/')
-
-2) Edit 'build.xml' file and set following properties:
- - jboss.home (i.e. "/home/mmachulak/dev/jboss-4.2.0.GA")
- - xts.home" (i.e. "/home/mmachulak/dev/JBossTS/XTS/xts-install")
-
-3) Run 'ant'
- This produces the following file:
- - build/bademo.ear
-
- This archive contains the demo application (hotel.jar), the framework's client library
- (baframework-client.jar), the framework (baframework.aop) and the required infrastructure
- for WS-BusinessActivity.
-
-4) Run 'ant deploy'
- This copies the bademo.ear file to the deployment directory of the JBoss Application Server.
-
-Demo application is accessible through the following address: http://localhost:8080/bademo
-
-All necessary information related to using the demo application has been provided on web pages
-that are the part of the demo application.
-
-
-### 4. Other documentation
-
-All documentation directly related to the Business Activity framework can be found on the
-website of this framework.
Added: labs/jbosstm/workspace/baframework/trunk/demo/resources/web/checkout.jsp
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/demo/resources/web/checkout.jsp (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/demo/resources/web/checkout.jsp 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,182 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2007, Red Hat Middleware LLC, and individual contributors
+as indicated by the @author tags.
+See the copyright.txt in the distribution for a full listing
+of individual contributors.
+This copyrighted material is made available to anyone wishing to use,
+modify, copy, or redistribute it subject to the terms and conditions
+of the GNU General Public License, v. 2.0.
+This program is distributed in the hope that it will be useful, but WITHOUT A
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+You should have received a copy of the GNU General Public License,
+v. 2.0 along with this distribution; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+MA 02110-1301, USA.
+
+(C) 2007,
+ at author JBoss Inc.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Business Activity Framework Demo Application</title>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
+ <meta http-equiv="content-language" content="en">
+ <meta name="author" content="Maciej Machulak">
+ <link rel="stylesheet" type="text/css" href="green.css"/>
+</head>
+<body>
+
+<div id="main">
+
+<div id="headerLeft">
+ <h1>Business Activity Framework Demo Application</h1>
+</div>
+
+<div id="headerRight">
+ <img src="jboss.jpg">
+</div>
+
+<div id="headerBottom">
+ Debug window (service return value):
+</div>
+
+<div id="headerDebug">
+ ${requestScope.DEBUG}
+</div>
+
+${requestScope.ACTIVE}
+
+<div id="menu">
+ <p>
+ <a href="HotelService?page=index.jsp">Home</a><br>
+ <a href="HotelService?page=about.jsp">About Demo Application</a><br>
+ <a href="HotelService?page=author.jsp">About Author</a><br>
+ </p>
+ <hr>
+ <p>
+ <a href="HotelService?page=initialise.jsp" ${requestScope.INITIALISE}>Initialise data</a><br>
+ <a href="HotelService?method=dropHotelData&baRequest=false" ${requestScope.DROP}>Delete data</a><br>
+ <a href="HotelService?method=getHotelData&baRequest=false" ${requestScope.SHOW}>Show data</a><br>
+ <a href="HotelService?method=getHotelOrders&baRequest=true" ${requestScope.ORDER}>Show orders</a><br>
+ </p>
+ <hr>
+ <p>
+ <a href="HotelService?method=startBA&baRequest=true" ${requestScope.BEGIN}>Begin Business Activity</a><br>
+ </p>
+ <hr>
+ <p>
+ <b>BA services:</b><br>
+ <a href="HotelService?page=hotelinfo.jsp" ${requestScope.BASERVICE}>Hotel Info</a><br>
+ <a href="HotelService?page=bookroom.jsp" ${requestScope.BASERVICE}>Book Room</a><br>
+ <a href="HotelService?page=getpackage.jsp" ${requestScope.BASERVICE}>Get Package</a><br>
+ <a href="HotelService?page=bookfitness.jsp" ${requestScope.BASERVICE}>Book Fitness</a><br>
+ <a href="HotelService?page=bookcasino.jsp" ${requestScope.BASERVICE}>Book Casino</a><br>
+ <a href="HotelService?page=ordermeal.jsp" ${requestScope.BASERVICE}>Order Meal</a><br>
+ <a href="HotelService?page=increaserating.jsp" ${requestScope.BASERVICE}>Increase Rating</a><br>
+ <a href="HotelService?page=decreaserating.jsp" ${requestScope.BASERVICE}>Decrease Rating</a><br>
+ </p>
+ <hr>
+ <p>
+ <a href="HotelService?method=completeBA&baRequest=true" ${requestScope.COMPLETE}>Complete Business Activity</a><br>
+ <a href="HotelService?method=closeBA&baRequest=true" ${requestScope.CLOSE}>Close Business Activity</a><br>
+ <a href="HotelService?method=cancelBA&baRequest=true" ${requestScope.CANCEL}>Cancel Business Activity</a><br>
+ </p>
+ <hr>
+ <p>
+ <b>Normal services:</b><br>
+ <a href="HotelService?page=cancelroom.jsp" ${requestScope.SERVICE}>Cancel Room</a><br>
+ <a href="HotelService?page=cancelpackage.jsp" ${requestScope.SERVICE}>Cancel Package</a><br>
+ <a href="HotelService?page=cancelfitness.jsp" ${requestScope.SERVICE}>Cancel Fitness</a><br>
+ <a href="HotelService?page=cancelcasino.jsp" ${requestScope.SERVICE}>Cancel Casino</a><br>
+ <a href="HotelService?page=cancelmeal.jsp" ${requestScope.SERVICE}>Cancel Meal</a><br>
+ </p>
+ <hr>
+</div>
+
+
+
+<div id="body" align=center>
+
+ <p align="center">
+ <fieldset class="medium">
+ <legend>checkoutFitnessPass()</legend>
+ </fieldset>
+ </p>
+
+ <p align="left">
+ <b>Method's class</b><br>
+ com.jboss.ba.demo.service.HotelImpl
+ </p>
+
+ <p align="left">
+ <b>Method's signature</b><br>
+
+ <div id="code">
+
+<pre>
+ at WebMethod<br>
+public boolean checkoutFitnessPass(<span class="annotation">@BAParam</span>("<span class="id">user</span>")String username,<br>
+				<span class="annotation">@BAParam</span>("<span class="id">password</span>")String password,<br>
+				<span class="annotation">@BAParam</span>("<span class="id">reservation</span>")Integer orderNumber,<br>
+				<span class="annotation">@BAParam</span>("<span class="id">id</span>")String uniqueID)<br>
+<br>
+throws HotelCustomException;
+</pre>
+ </div>
+ </p>
+
+ <p>
+ </p>
+
+ <p align="left">
+ <b>Service description</b>
+ <br>
+ This service validates previously acquired fitness passes for the given reservation number. It differentiates single purchases of those passes by the unique identifier.<br>
+ This service takes following parameters:
+ <ul align="left">
+ <li>Username
+ <li>Password
+ <li>Reservation Number
+ <li>Fitness Unique ID
+ </ul>
+ </p>
+ <p align="left">
+ This service returns:
+ <ul align="left">
+ <li>Boolean value that specifies whether checkout was successful or not.
+ </ul>
+ </p>
+ <p align="left">
+ It throws following exceptions:
+ <ul align="left">
+ <li>HotelCustomException
+ </ul>
+ </p>
+ <p align="left">
+ HotelCustomException is thrown if either the user cannot log in (username, password or both are incorrect)
+ or the reservation number is incorrect (reservation does not exist).
+ </p>
+
+
+</div>
+
+
+
+
+
+
+<div id="footer">
+ <p align=right>
+ © JBoss, a division of Red Hat
+ </p>
+</div>
+
+</div>
+
+</body>
+</html>
Added: labs/jbosstm/workspace/baframework/trunk/readme.txt
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/readme.txt (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/readme.txt 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,144 @@
+JBoss, Home of Professional Open Source
+Copyright 2007, Red Hat Middleware LLC, and individual contributors
+as indicated by the @author tags.
+See the copyright.txt in the distribution for a full listing
+of individual contributors.
+This copyrighted material is made available to anyone wishing to use,
+modify, copy, or redistribute it subject to the terms and conditions
+of the GNU General Public License, v. 2.0.
+This program is distributed in the hope that it will be useful, but WITHOUT A
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+You should have received a copy of the GNU General Public License,
+v. 2.0 along with this distribution; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+MA 02110-1301, USA.
+
+(C) 2007,
+ at author JBoss Inc.
+
+### Business Activity Framework & Demo Application
+### Version: 0.1
+### Date: July 31, 2007
+### Author: Maciej Machulak (mmachulak at redhat.com)
+### WWW: http://labs.jboss.com/jbosstm/baframework
+
+Contents:
+1. Introduction
+2. Building Business Activity Framework
+3. Building Business Activity Demo Application
+4. Other documentation
+
+
+### 1. Introduction
+
+The Business Activity Framework is a fully novel comprehensive solution for building
+transactional Web Services with accordance to the model defined in the WS-BusinessActivity
+specification. It provides a lightweight API that consists of a set of easy to learn and
+intuitive annotations and operations. It significantly facilitates development of transaction
+aware Web Services and releases programmers from mixing transaction related code with business
+logic of their applications.
+Web Services must be simply annotated with a set of defined annotations and the framework
+transparently applies all necessary transactional mechanisms to enable participation in
+long-running Business Activities.
+
+IMPORTANT NOTICE:
+This is the first release of the framework and is aimed mainly for testing.
+
+It it assumed that demo application is tested locally - Coordinator has been set to
+following address: http://localhost:8080. This is set in the following file:
+ws-c.war (WEB-INF/web.xml)
+
+ <init-param>
+ <param-name>BaseHttpURI</param-name>
+ <param-value>http://localhost:8080/xts/soap/</param-value>
+ </init-param>
+
+The client application uses the http://localhost:8080 address to lookup Web Services
+by default as well. This can be changed in the following source file:
+com/jboss/ba/demo/client/HotelService.java
+
+It is possible to use either deployment time of compile time AOP instrumentation. By
+default JBoss Application Server comes bundled with a JBoss AOP Deployer (this deployer,
+however, must be enabled explicitly - please refer to the JBoss AOP documentation for
+further instructions.
+
+
+### 2. Building Business Activity framework
+
+Building the BA Framework requires following components:
+- JDK (version 1.5)
+ (available at http://java.sun.com/javase/downloads/index_jdk5.jsp)
+- Ant build tool (version 1.7.0)
+ (available at http://ant.apache.org/)
+- JBoss Application Server (version 4.2.1 GA)
+ (available at http://labs.jboss.com/jbossas/)
+- JBoss Transaction Service (version 4.2.3 SP5)
+ (available at http://labs.jboss.com/jbosstm/)
+
+1) Edit 'build.xml' file and set following properties:
+ - jboss.home (e.g. "/home/mmachulak/dev/jboss-4.2.1.GA")
+ - xts.home" (e.g. "/home/mmachulak/dev/JBossTS/XTS/xts-install")
+
+2) Run 'ant'
+ This produces following files:
+ - build/baframework-client.jar
+ - build/baframework.aop
+
+ 'baframework-client.jar' file needs to be in the classpath of the application that wants
+ to use the framework.
+ 'baframework.aop' file must be deployed with the application as shown in the following
+ example of application.xml file:
+
+ <application>
+ <module>
+ <ejb>MyEJB.jar</ejb>
+ </module>
+
+ <module>
+ <java>baframework.aop</java>
+ </module>
+ </application>
+
+ For the use of the demo application it is not necessary to copy those files anywhere.
+
+
+### 3. Building Business Activity Demo Application
+
+Building the BA Framework Demo Application requires following components:
+- JDK (version 1.5)
+ (available at http://java.sun.com/javase/downloads/index_jdk5.jsp)
+- Ant build tool (version 1.7.0)
+ (available at http://ant.apache.org/)
+- JBoss Application Server (version 4.2.0 GA)
+ (available at http://labs.jboss.com/jbossas/)
+- JBoss Transaction Service (version 4.2.3 SP5)
+ (available at http://labs.jboss.com/jbosstm/)
+
+1) Go to the demo/ directory (i.e. 'cd demo/')
+
+2) Edit 'build.xml' file and set following properties:
+ - jboss.home (e.g. "/home/mmachulak/dev/jboss-4.2.0.GA")
+ - xts.home" (e.g. "/home/mmachulak/dev/JBossTS/XTS/xts-install")
+
+3) Run 'ant'
+ This produces the following file:
+ - build/bademo.ear
+
+ This archive contains the demo application (hotel.jar), the framework's client library
+ (baframework-client.jar), the framework (baframework.aop) and the required infrastructure
+ for WS-BusinessActivity.
+
+4) Run 'ant deploy'
+ This copies the bademo.ear file to the deployment directory of the JBoss Application Server.
+
+Demo application is accessible through the following address: http://localhost:8080/bademo
+
+All necessary information related to using the demo application has been provided on web pages
+that are the part of the demo application.
+
+
+### 4. Other documentation
+
+All documentation directly related to the Business Activity framework can be found on the
+website of this framework (http://labs.jboss.com/jbosstm/baframework).
Property changes on: labs/jbosstm/workspace/baframework/trunk/readme.txt
___________________________________________________________________
Name: svn:executable
+ *
Deleted: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BAServiceVisitor.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BAServiceVisitor.java 2007-09-27 23:30:01 UTC (rev 15414)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BAServiceVisitor.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -1,1022 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2007,
- * @author JBoss Inc.
- */
-package org.jboss.txbridge.ba.helper;
-
-import org.apache.log4j.Logger;
-import org.jboss.txbridge.ba.annotation.*;
-import org.jboss.txbridge.ba.exception.MethodIncorrectlyAnnotatedException;
-import org.jboss.txbridge.ba.exception.MethodNotAccessibleException;
-import org.jboss.txbridge.ba.service.ServiceDescription;
-import org.jboss.txbridge.ba.service.ServiceDescriptionImpl;
-import org.jboss.txbridge.ba.service.MethodDescription;
-import org.jboss.txbridge.ba.service.MethodDescriptionImpl;
-
-import javax.jws.WebMethod;
-import java.lang.reflect.Method;
-import java.lang.annotation.Annotation;
-
-/**
- * This component visits the service and describes it in terms of its requirements related to
- * participating in Business Activities.
- *
- * TODO: Redesign this class - it would be better to have multiple small and exchangeable classes
- * than a big one.
- *
- * @author Maciej P. Machulak (mmachulak at redhat.com)
- * @version 0.1
- */
-public class BAServiceVisitor
-{
- // Logger
- private static Logger log = Logger.getLogger(BAServiceVisitor.class);
-
- /**
- * This method processes a single method that
- *
- * @param method is the method to be processed.
- * @return the service description.
- * @throws org.jboss.txbridge.ba.exception.MethodIncorrectlyAnnotatedException if the method is not annotated correctly.
- * @throws org.jboss.txbridge.ba.exception.MethodNotAccessibleException if the specified compensatiom method is not accessible.
- */
- public static synchronized ServiceDescription processMethod(Method method)
- throws MethodIncorrectlyAnnotatedException, MethodNotAccessibleException
- {
- log.info("processMethod()");
-
- // Create new ServiceDescription
- ServiceDescription serviceDescription = new ServiceDescriptionImpl();
-
- // Create new MethodDescription for the original class
- MethodDescription originalMethod = new MethodDescriptionImpl();
-
- // Check what is the name of the method...
- log.info("Method name: " + method.getName());
- String methodName = method.getName();
- // ...by default the web method name is the same as the method's name.
- String webMethodName = methodName;
-
- // Set the class of the method
- Class methodClass = method.getDeclaringClass();
- originalMethod.setClazz(methodClass);
-
- // Check if there is a business activity annotation
- Class[] baClass = null;
- Class[] baInterface = null;
- String baJndiName = null;
- String baProviderURL = null;
- String endpointAddress = null;
- String targetNamespace = null;
- String serviceName = null;
- BAService BAServiceAnnotation = (BAService) methodClass.getAnnotation(BAService.class);
- if (BAServiceAnnotation != null)
- {
- log.info("BAService annotation found.");
- baClass = BAServiceAnnotation.serviceClass();
- log.info("Compensation class: " + baClass);
- baInterface = BAServiceAnnotation.ejbInterface();
- log.info("EJB Interface: " + baInterface);
- baJndiName = BAServiceAnnotation.jndiName();
- log.info("JNDI name: " + baJndiName);
- baProviderURL = BAServiceAnnotation.providerURL();
- log.info("Provider URL: " + baProviderURL);
- endpointAddress = BAServiceAnnotation.wsdl();
- targetNamespace = BAServiceAnnotation.namespace();
- serviceName = BAServiceAnnotation.serviceName();
- }
-
- // Check if there is a WebMethod annotation
- WebMethod webMethodAnnotation = method.getAnnotation(WebMethod.class);
- if (webMethodAnnotation != null)
- {
- log.info("WebMethod annotation present!");
-
- // Check if the operation name has been specified
- String name = webMethodAnnotation.operationName();
- if (name != null && !name.equals(""))
- {
- log.info("WebMethod operationName: " + name);
- // If yes... change the name of the web method
- webMethodName = name;
- }
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("Method does not have @WebMethod annotation.");
- }
-
- // Remember names of the method
- originalMethod.setMethodName(methodName);
- originalMethod.setWebMethodName(webMethodName);
-
- // Set the parameter types of the original method
- originalMethod.setParameterTypes(method.getParameterTypes());
-
- // Check if this method is a BA service
- BAMethod baMethod = method.getAnnotation(BAMethod.class);
- MethodType methodType;
- AgreementType agreementType;
- if (baMethod != null)
- {
- log.info("Method " + methodName + " is a BA service.");
-
- // Get the type of the service
- methodType = baMethod.type();
- log.info("MethodType: " + methodType);
- serviceDescription.setMethodType(methodType);
-
- // Get the agreement type
- agreementType = baMethod.agreement();
- log.info("AgreementType: " + agreementType);
- serviceDescription.setAgreementType(agreementType);
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("Method does not have @BAMethod annotation.");
- }
-
- // Check the compensation method
- MethodDescription md = new MethodDescriptionImpl();
- BACompensatedBy baComp = method.getAnnotation(BACompensatedBy.class);
- if (baComp != null)
- {
- log.info("BACompensatedBy annotation present!");
-
- String compensationMethodName = baComp.value();
- log.info("Compensation method: " + compensationMethodName);
- md.setMethodName(compensationMethodName);
-
- // Check the datamgmt type
- log.info("Compensation type: " + baComp.type());
- md.setDataMatch(baComp.type());
-
- // Set parameter match
- log.info("Parameters match: " + baComp.match());
- md.setParameterMatch(baComp.match());
-
- // Check if this is a single datamgmt
- log.info("Compensation single: " + baComp.single());
- md.setSingle(baComp.single());
-
- // Get datamgmt mode
- ExecutionMode compensationMode = baComp.mode();
- md.setExecutionMode(compensationMode);
- log.info("Compensation mode: " + compensationMode);
-
- // Get information according to the required datamgmt
- if (compensationMode == ExecutionMode.POJO)
- {
- // We need following information
- // 1) Method name (already obtained)
- // 2) Method's class
-
- // Getting method's class
- Class compensationMethodClass = baComp.serviceClass()[0];
- if (compensationMethodClass == null)
- {
- // It can be either local class or a class specified in BAService annotation
- if (baClass != null)
- {
- log.info("Compensation method class specified in BA");
- compensationMethodClass = baClass[0];
- }
- else
- {
- log.info("Compensation method is in the same class: ");
- compensationMethodClass = method.getDeclaringClass();
- }
- }
- else
- {
- log.info("Compensation class: " + compensationMethodClass);
- }
- md.setClazz(compensationMethodClass);
-
- // Checking if the method exists
- log.info("Checking if method exists");
- Method[] methodList = compensationMethodClass.getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + compensationMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(compensationMethodName))
- {
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Compensation method has parameters");
-
- log.info("Setting parameter match type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the datamgmt method
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- else
- {
- log.info("Compensation method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Compensation method not found.");
- }
-
- }
- else if (compensationMode == ExecutionMode.DII)
- {
- md.setEndpointAddress(baComp.wsdl());
- md.setTargetNamespace(baComp.namespace());
- md.setServiceName(baComp.serviceName());
- }
- else if (compensationMode == ExecutionMode.EJB)
- {
-
- // We need following information
- // 1) Method name (already obtained)
- // 2) Method's class (optional)
- // 3) Interface of the EJB
- // 4) JNDI name of the EJB
- // 5) Provider URL (optional)
-
- // Method's class
- log.info("Getting method's class");
- Class[] compensationMethodClass = baComp.serviceClass();
- boolean baParamAnnotationFound = true;
- if (compensationMethodClass.length == 0)
- {
- log.info("Method's class not specified");
-
- // Class can be either specified in the Business Activity annotation or datamgmt is remote
- log.info("Checking if method's class has been specified in BAService");
- if (baClass != null && baClass.length > 0 && baClass[0] != null)
- {
- log.info("Compensation class specified in the BAService annotation");
- compensationMethodClass = new Class[1];
- compensationMethodClass[0] = baClass[0];
- }
- else
- {
- log.info("Compensation class not specified - remote datamgmt.");
- }
- }
- else
- {
- log.info("Method's class specified");
- }
-
- if (compensationMethodClass.length > 0)
- {
- // Compensation class specified
- log.info("Compensation class: " + compensationMethodClass[0]);
-
- // Checking if the datamgmt method exists
- log.info("Checking if datamgmt method exists");
- Method[] methodList = compensationMethodClass[0].getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + compensationMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(compensationMethodName))
- {
- log.info("Method found!");
-
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Compensation method has parameters");
-
- log.info("Setting datamgmt type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the datamgmt method
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- baParamAnnotationFound = true;
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- else
- {
- log.info("Compensation method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Compensation method not found.");
- }
-
- }
- md.setClazz(compensationMethodClass[0]);
-
- // Get the interface
- Class[] ejbInterface = baComp.ejbInterface();
- if (ejbInterface.length == 0)
- {
- log.info("EJB interface not specified");
- if (baInterface != null && baInterface.length > 0 && !baInterface[0].equals(""))
- {
- log.info("EJB interface specified in BAService - storing value");
- ejbInterface = new Class[1];
- ejbInterface[0] = baInterface[0];
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("Interface to EJB not specified.");
- }
- }
- else
- {
- log.info("EJB Interface specified.");
- }
- if (ejbInterface.length > 0 )
- {
- // Interface specified
- log.info("EJB Interface: " + ejbInterface[0]);
-
- // Checking if the datamgmt method exists
- log.info("Checking if datamgmt method exists");
- Method[] methodList = ejbInterface[0].getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + compensationMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(compensationMethodName))
- {
- log.info("Method found!");
-
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Compensation method has parameters");
-
- log.info("Setting datamgmt type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the datamgmt method
- if (!baParamAnnotationFound)
- {
-
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- }
- else
- {
- log.info("Compensation method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Compensation method not found.");
- }
-
- }
- md.setEjbInterface(ejbInterface[0]);
-
- // Get the JNDI name of the EJB
- log.info("Getting JNDI name of the EJB");
- String jndiName = baComp.jndiName();
- if (!jndiName.equals(""))
- {
- log.info("JNDI name: " + jndiName);
- }
- else
- {
- // Check if the JNDI name has been specified
- if (baJndiName != null && !baJndiName.equals(""))
- {
- jndiName = baJndiName;
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("JNDI name not specified");
- }
- }
- md.setJndiName(jndiName);
-
- // Check if the URL provider has been specified
- String providerURL = baComp.providerURL();
- if (!providerURL.equals(""))
- {
- log.info("Provider URL: " + providerURL);
- }
- else
- {
- // Check if the provider URL has been specified
- if (baProviderURL != null && !baProviderURL.equals(""))
- {
- providerURL = baProviderURL;
- }
- else
- {
- providerURL = null;
- }
- }
- md.setProviderURL(providerURL);
- }
-
- }
- else
- {
- log.info("BACompensatedBy annotation missing.");
- log.info("Checking the type of the service.");
- if (methodType == MethodType.READONLY)
- {
- log.info("Service is read only. BACompensatedBy is not necessary.");
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("BACompensatedBy annotation missing.");
- }
- }
- serviceDescription.putMethod("compensate",md);
-
- // Check the Completion method
- md = new MethodDescriptionImpl();
- BACompletedBy baCompleted = method.getAnnotation(BACompletedBy.class);
- if (baCompleted != null)
- {
- log.info("BACompletedBy annotation present!");
-
- String CompletionMethodName = baCompleted.value();
- log.info("Completion method: " + CompletionMethodName);
- md.setMethodName(CompletionMethodName);
-
- // Check the Completion type
- log.info("Data match type: " + baCompleted.type());
- md.setDataMatch(baCompleted.type());
-
- // Set parameter match
- log.info("Parameters match: " + baCompleted.match());
- md.setParameterMatch(baCompleted.match());
-
- // Check if this is a single Completion
- log.info("Completion single: " + baCompleted.single());
- md.setSingle(baCompleted.single());
-
- // Get Completion mode
- ExecutionMode completionMode = baCompleted.mode();
- md.setExecutionMode(baCompleted.mode());
- log.info("Completion mode: " + completionMode);
-
- // Get information according to the required Completion
- if (completionMode == ExecutionMode.POJO)
- {
- // We need following information
- // 1) Method name (already obtained)
- // 2) Method's class
-
- // Getting method's class
- Class CompletionMethodClass = baCompleted.serviceClass()[0];
- if (CompletionMethodClass == null)
- {
- // It can be either local class or a class specified in BAService annotation
- if (baClass != null)
- {
- log.info("Completion method class specified in BA");
- CompletionMethodClass = baClass[0];
- }
- else
- {
- log.info("Completion method is in the same class: ");
- CompletionMethodClass = method.getDeclaringClass();
- }
- }
- else
- {
- log.info("Completion class: " + CompletionMethodClass);
- }
- md.setClazz(CompletionMethodClass);
-
- // Checking if the Completion method exists
- log.info("Checking if Completion method exists");
- Method[] methodList = CompletionMethodClass.getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + CompletionMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(CompletionMethodName))
- {
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Completion method has parameters");
-
- log.info("Setting Completion type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the Completion method
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- else
- {
- log.info("Completion method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Completion method not found.");
- }
-
- }
- else if (completionMode == ExecutionMode.DII)
- {
- md.setEndpointAddress(baComp.wsdl());
- md.setTargetNamespace(baComp.namespace());
- md.setServiceName(baComp.serviceName());
- }
- else if (completionMode == ExecutionMode.EJB)
- {
-
- // We need following information
- // 1) Method name (already obtained)
- // 2) Method's class (optional)
- // 3) Interface of the EJB
- // 4) JNDI name of the EJB
- // 5) Provider URL (optional)
-
- // Method's class
- log.info("Getting method's class");
- Class[] CompletionMethodClass = baCompleted.serviceClass();
- boolean baParamAnnotationFound = true;
- if (CompletionMethodClass.length == 0)
- {
- log.info("Method's class not specified");
-
- // Class can be either specified in the Business Activity annotation or Completion is remote
- log.info("Checking if method's class has been specified in BAService");
- if (baClass != null && baClass.length > 0 && baClass[0] != null)
- {
- log.info("Completion class specified in the BAService annotation");
- CompletionMethodClass = new Class[1];
- CompletionMethodClass[0] = baClass[0];
- }
- else
- {
- log.info("Completion class not specified - remote Completion.");
- }
- }
- else
- {
- log.info("Method's class specified");
- }
-
- if (CompletionMethodClass.length > 0)
- {
- // Completion class specified
- log.info("Completion class: " + CompletionMethodClass[0]);
-
- // Checking if the Completion method exists
- log.info("Checking if Completion method exists");
- Method[] methodList = CompletionMethodClass[0].getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + CompletionMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(CompletionMethodName))
- {
- log.info("Method found!");
-
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Completion method has parameters");
-
- log.info("Setting Completion type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the Completion method
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- baParamAnnotationFound = true;
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- else
- {
- log.info("Completion method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Completion method not found.");
- }
-
- }
- md.setClazz(CompletionMethodClass[0]);
-
- // Get the interface
- Class[] ejbInterface = baCompleted.ejbInterface();
- if (ejbInterface.length == 0)
- {
- log.info("EJB interface not specified");
- if (baInterface != null && baInterface.length > 0 && !baInterface[0].equals(""))
- {
- log.info("EJB interface specified in BAService - storing value");
- ejbInterface = new Class[1];
- ejbInterface[0] = baInterface[0];
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("Interface to EJB not specified.");
- }
- }
- else
- {
- log.info("EJB Interface specified.");
- }
- if (ejbInterface.length > 0 )
- {
- // Interface specified
- log.info("EJB Interface: " + ejbInterface[0]);
-
- // Checking if the Completion method exists
- log.info("Checking if Completion method exists");
- Method[] methodList = ejbInterface[0].getMethods();
- boolean methodFound = false;
- for (Method singleMethod : methodList)
- {
- log.info("Comparing " + CompletionMethodName + " against " + singleMethod.getName() + ".");
- if (singleMethod.getName().equals(CompletionMethodName))
- {
- log.info("Method found!");
-
- // Remember types of parameters
- log.info("Getting parameter types");
- Class[] parameterTypes = singleMethod.getParameterTypes();
-
- if (parameterTypes != null)
- {
- log.info("Completion method has parameters");
-
- log.info("Setting Completion type");
- md.setParameterTypes(singleMethod.getParameterTypes());
-
- // Remember annotations of the parameters of the Completion method
- if (!baParamAnnotationFound)
- {
-
- log.info("Checking annotations");
- Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
- Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- else
- {
- log.info("No BAParam annotation for parameter: " + i);
- }
- }
- i++;
- }
- md.setParameterAnnotations(parameterAnnotation);
- }
- }
- else
- {
- log.info("Completion method does not take any parameters");
- }
- methodFound = true;
- break;
- }
- }
- if (!methodFound)
- {
- throw new MethodNotAccessibleException("Completion method not found.");
- }
-
- }
- md.setEjbInterface(ejbInterface[0]);
-
- // Get the JNDI name of the EJB
- log.info("Getting JNDI name of the EJB");
- String jndiName = baCompleted.jndiName();
- if (!jndiName.equals(""))
- {
- log.info("JNDI name: " + jndiName);
- }
- else
- {
- // Check if the JNDI name has been specified
- if (baJndiName != null && !baJndiName.equals(""))
- {
- jndiName = baJndiName;
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("JNDI name not specified");
- }
- }
- md.setJndiName(jndiName);
-
- // Check if the URL provider has been specified
- String providerURL = baCompleted.providerURL();
- if (!providerURL.equals(""))
- {
- log.info("Provider URL: " + providerURL);
- }
- else
- {
- // Check if the provider URL has been specified
- if (baProviderURL != null && !baProviderURL.equals(""))
- {
- providerURL = baProviderURL;
- }
- else
- {
- providerURL = null;
- }
- }
- md.setProviderURL(providerURL);
- }
-
- }
- else
- {
- log.info("BACompletedBy annotation missing.");
- log.info("Checking the agreement protocol type.");
- if (agreementType == AgreementType.PARTICIPANT_COMPLETION)
- {
- log.info("Agreement protocol is participant completion. BACompletedBy is not necessary.");
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("BACompletedBy annotation missing.");
- }
- }
- serviceDescription.putMethod("complete",md);
-
-
- // Remember @BAParam annotation values
- Object[] parameterAnnotation = new Object[method.getParameterTypes().length];
- Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- int i = 0;
- for (Annotation[] annotationArray : parameterAnnotations)
- {
- for (Annotation annotation : annotationArray)
- {
- if (annotation instanceof BAParam)
- {
- log.info("BAParam annotation present for parameter: " + i);
- String valueS = ((BAParam)annotation).value();
- try
- {
- Integer valueI = new Integer(valueS);
- parameterAnnotation[i] = valueI;
- }
- catch (NumberFormatException nfe)
- {
- parameterAnnotation[i] = valueS;
- }
- }
- }
- i++;
- }
- originalMethod.setParameterAnnotations(parameterAnnotation);
-
- // Remember @BAResult annotation value
- BAResult baResult = method.getAnnotation(BAResult.class);
- Integer returnId;
- if (baResult != null)
- {
- log.info("BAResult annotation present!");
-
- // Check if the service really returns a value
- Class returnType = method.getReturnType();
- if (returnType == null)
- {
- throw new MethodIncorrectlyAnnotatedException("BAResult used on method with no return value!");
- }
- String returnName = baResult.value();
- if (!returnName.equals(""))
- {
- // Check if this is a numerical identifier or not
- try
- {
- returnId = new Integer(returnName);
- log.info("Return identifier: " + returnId);
- originalMethod.setReturnId(returnId);
- }
- catch (NumberFormatException nfe)
- {
- log.info("Return identifier: " + returnName);
- originalMethod.setReturnId(returnName);
- }
- }
- else
- {
- throw new MethodIncorrectlyAnnotatedException("BAResult annotation has a wrong identifier.");
- }
-
- }
-
- // Remember the original method description
- serviceDescription.putMethod("original",originalMethod);
-
- // Return the service description
- return serviceDescription;
- }
-
-}
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BATaskVisitor.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BATaskVisitor.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BATaskVisitor.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,1097 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.helper;
+
+import org.apache.log4j.Logger;
+import org.jboss.txbridge.ba.annotation.*;
+import org.jboss.txbridge.ba.exception.MethodIncorrectlyAnnotatedException;
+import org.jboss.txbridge.ba.exception.MethodNotAccessibleException;
+import org.jboss.txbridge.ba.service.*;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * This component visits the service and describes it in terms of its requirements related to
+ * participating in Business Activities.
+ *
+ * TODO: Redesign this class - it would be better to have multiple small and exchangeable classes
+ * than a big one.
+ *
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public class BATaskVisitor
+{
+ // Logger
+ private static Logger log = Logger.getLogger(BATaskVisitor.class);
+
+ /**
+ * This method processes a single method that is exposed as a transactional Web Service (Business Activity
+ * task). All obtained information is stored in a ServiceDescription object, which is later returned.
+ * Following information is processed by this method:
+ * 1) Service type (read only / modify)
+ * 2) Required agreement protocol (participant / coordinator completion)
+ * 3) Common execution-related information (specified in the @BAService annotation)
+ * 4) Description of the original service
+ * 5) Description of the completion service (optional)
+ * 6) Description of the compensation service (optional)
+ * 7) Description of the cancel service (to be implemented)
+ * 8) Description of the close service (to be implemented)
+ *
+ * @param method is the method to be processed.
+ * @return the service description.
+ * @throws org.jboss.txbridge.ba.exception.MethodIncorrectlyAnnotatedException if the method is not annotated correctly.
+ * @throws org.jboss.txbridge.ba.exception.MethodNotAccessibleException if the specified compensatiom method is not accessible.
+ */
+ public static ServiceDescription processMethod(Method method)
+ throws MethodIncorrectlyAnnotatedException, MethodNotAccessibleException
+ {
+ log.info("processMethod()");
+
+ // Check what is the name of the method...
+ log.info("Processing method: " + method.getName());
+
+ // Create new ServiceDescription
+ ServiceDescription serviceDescription = new ServiceDescriptionImpl();
+
+ // Get information about the Web Service method type
+ MethodType methodType = processMethodType(method);
+ log.info("Method type: " + methodType);
+ serviceDescription.setMethodType(methodType);
+
+ // Get information about the required agreement protocol
+ AgreementType agreementType = processAgreementType(method);
+ log.info("Agreement protocol: " + agreementType);
+ serviceDescription.setAgreementType(agreementType);
+
+ // Get common execution related information
+ CommonServiceInfo commonInfo = processServiceCommon(method);
+
+ // Get description of the original method
+ MethodDescription originalMethod = processOriginalService(method);
+ // Store descriptions
+ serviceDescription.putMethod("original",originalMethod);
+
+ // Get description of the compensation action
+ BACompensatedBy baCompensated = method.getAnnotation(BACompensatedBy.class);
+ if (baCompensated == null)
+ {
+ log.info("BACompensatedBy annotation missing.");
+ log.info("Checking the type of the service.");
+ if (methodType == MethodType.READONLY)
+ {
+ log.info("Service is read only. BACompensatedBy is not necessary.");
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("BACompensatedBy annotation missing.");
+ }
+ }
+ else
+ {
+ MethodDescription compensationMethod = processCompensationService(method,baCompensated,commonInfo);
+ serviceDescription.putMethod("compensate",compensationMethod);
+ }
+
+ // Get description of the completion action
+ BACompletedBy baCompleted = method.getAnnotation(BACompletedBy.class);
+ if (baCompleted == null)
+ {
+ log.info("BACompletedBy annotation missing.");
+ log.info("Checking the agreement protocol type.");
+ if (agreementType == AgreementType.PARTICIPANT_COMPLETION)
+ {
+ log.info("Agreement protocol is participant completion. BACompletedBy is not necessary.");
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("BACompletedBy annotation missing.");
+ }
+ }
+ else
+ {
+ MethodDescription completionMethod = processCompletionService(method,baCompleted,commonInfo);
+ serviceDescription.putMethod("complete",completionMethod);
+ }
+
+ // Return the service description
+ return serviceDescription;
+ }
+
+ /**
+ * Process information concerning the original service - what kind of parameters have been used,
+ * which arguments need to be stored, if the return value needs to be stored, etc.
+ *
+ * @param method is the method that needs to be processed.
+ * @return description of the original method.
+ * @throws MethodIncorrectlyAnnotatedException if incorrect data has been specified.
+ */
+ public static MethodDescription processOriginalService(Method method)
+ throws MethodIncorrectlyAnnotatedException
+ {
+ // - create the method description object
+ MethodDescription md = new MethodDescriptionImpl();
+ // - get name of the Method
+ String methodName = method.getName();
+ md.setMethodName(methodName);
+ // - set the class of the method
+ Class methodClass = method.getDeclaringClass();
+ md.setClazz(methodClass);
+ // - set the parameter types of the original service
+ md.setParameterTypes(method.getParameterTypes());
+ // - set parameter identifiers
+ Object[] parameterAnnotation = new Object[method.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ // - set return value identifier
+ BAResult baResult = method.getAnnotation(BAResult.class);
+ Integer returnId;
+ if (baResult != null)
+ {
+ log.info("BAResult annotation present!");
+
+ // Check if the service really returns a value
+ Class returnType = method.getReturnType();
+ if (returnType == null)
+ {
+ throw new MethodIncorrectlyAnnotatedException("BAResult used on method with no return value!");
+ }
+ String returnName = baResult.value();
+ if (!returnName.equals(""))
+ {
+ // Check if this is a numerical identifier or not
+ try
+ {
+ returnId = new Integer(returnName);
+ log.info("Return identifier: " + returnId);
+ md.setReturnId(returnId);
+ }
+ catch (NumberFormatException nfe)
+ {
+ log.info("Return identifier: " + returnName);
+ md.setReturnId(returnName);
+ }
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("BAResult annotation has a wrong identifier.");
+ }
+
+ }
+ return md;
+ }
+
+ /**
+ * This method processes information related to the MethodType of a single method. This
+ * information is retrieved from the BAMethod annotation.
+ *
+ * @param method is the method that needs to be processed
+ * @return the method type of this method.
+ * @throws MethodIncorrectlyAnnotatedException if description of the method is incorrect
+ */
+ public static MethodType processMethodType(Method method)
+ throws MethodIncorrectlyAnnotatedException
+ {
+ // Check if this method is a BA service
+ BAMethod baMethod = method.getAnnotation(BAMethod.class);
+ if (baMethod != null)
+ {
+ // Return the method type
+ return baMethod.type();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("Method does not have @BAMethod annotation.");
+ }
+
+ }
+
+ /**
+ * This method processes information related to the AgreementType of a single method. This
+ * information is retrieved from the BAMethod annotation.
+ *
+ * @param method is the method that needs to be processed
+ * @return the method type of this method.
+ * @throws MethodIncorrectlyAnnotatedException if description of the method is incorrect
+ */
+ public static AgreementType processAgreementType(Method method)
+ throws MethodIncorrectlyAnnotatedException
+ {
+ // Check if this method is a BA service
+ BAMethod baMethod = method.getAnnotation(BAMethod.class);
+ if (baMethod != null)
+ {
+ return baMethod.agreement();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("Method does not have @BAMethod annotation.");
+ }
+
+ }
+
+ /**
+ * This method processes information specified in the @BAService annotation. It creates
+ * a CommonServiceInfo object, which holds all that information and returns this object.
+ *
+ * @param method is the method of a class that is annotated with @BAService annotation
+ * @return the CommonServiceInfo object that contains all information specified in the @BAService annotation.
+ * @throws MethodIncorrectlyAnnotatedException if provided information is incorrect.
+ * @throws MethodNotAccessibleException if specified execution-related information is incorrect (e.g. WSDL is not accessible).
+ */
+ public static CommonServiceInfo processServiceCommon(Method method)
+ throws MethodIncorrectlyAnnotatedException, MethodNotAccessibleException
+ {
+ CommonServiceInfo serviceInfo = new CommonServiceInfo();
+ Class<?> methodClass = method.getClass();
+ BAService BAServiceAnnotation = methodClass.getAnnotation(BAService.class);
+ if (BAServiceAnnotation != null)
+ {
+ try
+ {
+ log.info("BAService annotation found.");
+ serviceInfo.setBaClass(BAServiceAnnotation.serviceClass());
+ serviceInfo.setBaInterface(BAServiceAnnotation.ejbInterface());
+ serviceInfo.setBaJndiName(BAServiceAnnotation.jndiName());
+ serviceInfo.setBaProviderURL(BAServiceAnnotation.providerURL());
+ serviceInfo.setEndpointAddress(BAServiceAnnotation.wsdl());
+ serviceInfo.setTargetNamespace(BAServiceAnnotation.namespace());
+ serviceInfo.setServiceName(BAServiceAnnotation.serviceName());
+ }
+ catch (IncorrectDataException ide)
+ {
+ throw new MethodIncorrectlyAnnotatedException(ide);
+ }
+ }
+ return serviceInfo;
+ }
+
+ /**
+ * This method processes information related to a single service compensation service.
+ * Data is retrieved from the annotations and stored in the MethodDescription object.
+ * This object is later returned.
+ *
+ * @param method is the method, which is annotated with information related to a single service
+ * @param baComp is the annotation with all required information
+ * @param commonInfo is the object that contains common execution-related information.
+ * @return MethodDescription object that describes a single service
+ * @throws MethodIncorrectlyAnnotatedException if description of a service is incorrect
+ * @throws MethodNotAccessibleException if the service, which is described, is not accessible
+
+ */
+ private static MethodDescription processCompensationService(Method method, BACompensatedBy baComp, CommonServiceInfo commonInfo)
+ throws MethodIncorrectlyAnnotatedException, MethodNotAccessibleException
+ {
+ MethodDescription md = new MethodDescriptionImpl();
+ String methodName = baComp.value();
+ log.info("Method: " + methodName);
+ md.setMethodName(methodName);
+
+ // Check the data match type
+ log.info("Data match type: " + baComp.type());
+ md.setDataMatch(baComp.type());
+
+ // Set parameter match
+ log.info("Parameters match: " + baComp.match());
+ md.setParameterMatch(baComp.match());
+
+ // Check if this is a single execution
+ log.info("Single execution: " + baComp.single());
+ md.setSingle(baComp.single());
+
+ // Get the execution mode mode
+ ExecutionMode executionMode = baComp.mode();
+ md.setExecutionMode(executionMode);
+ log.info("Execution mode: " + executionMode);
+
+ // Get information according to the required execution mode
+ if (executionMode == ExecutionMode.POJO)
+ {
+ // We need following information
+ // 1) Method name (already obtained)
+ // 2) Method's class
+
+ // Getting method's class
+ Class methodClass = baComp.serviceClass()[0];
+ if (methodClass == null)
+ {
+ // It can be either local class or a class specified in BAService annotation
+ if (commonInfo.getBaClass() != null)
+ {
+ log.info("Method class specified in BA");
+ methodClass = commonInfo.getBaClass();
+ }
+ else
+ {
+ log.info("Method is in the same class: ");
+ methodClass = method.getDeclaringClass();
+ }
+ }
+ else
+ {
+ log.info("Method class: " + methodClass);
+ }
+ md.setClazz(methodClass);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = methodClass.getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter match type");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Remember identifiers of the parameters
+ log.info("Checking identifiers of parameters");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ else if (executionMode == ExecutionMode.DII)
+ {
+ md.setEndpointAddress(baComp.wsdl());
+ md.setTargetNamespace(baComp.namespace());
+ md.setServiceName(baComp.serviceName());
+ }
+ else if (executionMode == ExecutionMode.EJB)
+ {
+
+ // We need following information
+ // 1) Method name (already obtained)
+ // 2) Method's class (optional)
+ // 3) Interface of the EJB
+ // 4) JNDI name of the EJB
+ // 5) Provider URL (optional)
+
+ // Method's class
+ log.info("Getting method's class");
+ Class[] methodClass = baComp.serviceClass();
+ boolean baParamAnnotationFound = true;
+ if (methodClass.length == 0)
+ {
+ log.info("Method's class not specified");
+
+ // Class can be either specified in the BAService annotation or is remote
+ log.info("Checking if method's class has been specified in BAService");
+ if (commonInfo.getBaClass() != null)
+ {
+ log.info("Class specified in the BAService annotation");
+ methodClass = new Class[1];
+ methodClass[0] = commonInfo.getBaClass();
+ }
+ else
+ {
+ log.info("Class not specified - remote execution.");
+ }
+ }
+ else
+ {
+ log.info("Method's class specified");
+ }
+
+ if (methodClass.length > 0)
+ {
+ // Class specified
+ log.info("Class: " + methodClass[0]);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = methodClass[0].getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ log.info("Method found!");
+
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter types");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Process identifiers of method's parameters
+ log.info("Checking identifiers");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ baParamAnnotationFound = true;
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ md.setClazz(methodClass[0]);
+
+ // Get the interface
+ Class[] ejbInterface = baComp.ejbInterface();
+ if (ejbInterface.length == 0)
+ {
+ log.info("EJB interface not specified");
+ if (commonInfo.getBaInterface() != null)
+ {
+ log.info("EJB interface specified in BAService - storing value");
+ ejbInterface = new Class[1];
+ ejbInterface[0] = commonInfo.getBaInterface();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("Interface to EJB not specified.");
+ }
+ }
+ else
+ {
+ log.info("EJB Interface specified.");
+ }
+ if (ejbInterface.length > 0 )
+ {
+ // Interface specified
+ log.info("EJB Interface: " + ejbInterface[0]);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = ejbInterface[0].getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ log.info("Method found!");
+
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter types");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Process identifiers of method's parameters
+ if (!baParamAnnotationFound)
+ {
+
+ log.info("Checking identifiers");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ md.setEjbInterface(ejbInterface[0]);
+
+ // Get the JNDI name of the EJB
+ log.info("Getting JNDI name of the EJB");
+ String jndiName = baComp.jndiName();
+ if (!jndiName.equals(""))
+ {
+ log.info("JNDI name: " + jndiName);
+ }
+ else
+ {
+ // Check if the JNDI name has been specified
+ if (commonInfo.getBaJndiName() != null)
+ {
+ jndiName = commonInfo.getBaJndiName();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("JNDI name not specified");
+ }
+ }
+ md.setJndiName(jndiName);
+
+ // Check if the URL provider has been specified
+ String providerURL = baComp.providerURL();
+ if (!providerURL.equals(""))
+ {
+ log.info("Provider URL: " + providerURL);
+ }
+ else
+ {
+ // Check if the provider URL has been specified
+ if (commonInfo.getBaProviderURL() != null)
+ {
+ providerURL = commonInfo.getBaProviderURL();
+ }
+ else
+ {
+ providerURL = null;
+ }
+ }
+ md.setProviderURL(providerURL);
+ }
+ return md;
+ }
+
+ /**
+ * This method processes information related to a single completion service.
+ * Data is retrieved from the annotations and stored in the MethodDescription object.
+ * This object is later returned.
+ *
+ * @param method is the method, which is annotated with information related to a single service
+ * @param baComp is the annotation with all required information
+ * @param commonInfo is the object that contains common execution-related information.
+ * @return MethodDescription object that describes a single service
+ * @throws MethodIncorrectlyAnnotatedException if description of a service is incorrect
+ * @throws MethodNotAccessibleException if the service, which is described, is not accessible
+ */
+ private static MethodDescription processCompletionService(Method method, BACompletedBy baComp, CommonServiceInfo commonInfo)
+ throws MethodIncorrectlyAnnotatedException, MethodNotAccessibleException
+ {
+ MethodDescription md = new MethodDescriptionImpl();
+ String methodName = baComp.value();
+ log.info("Method: " + methodName);
+ md.setMethodName(methodName);
+
+ // Check the data match type
+ log.info("Data match type: " + baComp.type());
+ md.setDataMatch(baComp.type());
+
+ // Set parameter match
+ log.info("Parameters match: " + baComp.match());
+ md.setParameterMatch(baComp.match());
+
+ // Check if this is a single execution
+ log.info("Single execution: " + baComp.single());
+ md.setSingle(baComp.single());
+
+ // Get the execution mode mode
+ ExecutionMode executionMode = baComp.mode();
+ md.setExecutionMode(executionMode);
+ log.info("Execution mode: " + executionMode);
+
+ // Get information according to the required execution mode
+ if (executionMode == ExecutionMode.POJO)
+ {
+ // We need following information
+ // 1) Method name (already obtained)
+ // 2) Method's class
+
+ // Getting method's class
+ Class methodClass = baComp.serviceClass()[0];
+ if (methodClass == null)
+ {
+ // It can be either local class or a class specified in BAService annotation
+ if (commonInfo.getBaClass() != null)
+ {
+ log.info("Method class specified in BA");
+ methodClass = commonInfo.getBaClass();
+ }
+ else
+ {
+ log.info("Method is in the same class: ");
+ methodClass = method.getDeclaringClass();
+ }
+ }
+ else
+ {
+ log.info("Method class: " + methodClass);
+ }
+ md.setClazz(methodClass);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = methodClass.getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter match type");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Remember identifiers of the parameters
+ log.info("Checking identifiers of parameters");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ else if (executionMode == ExecutionMode.DII)
+ {
+ md.setEndpointAddress(baComp.wsdl());
+ md.setTargetNamespace(baComp.namespace());
+ md.setServiceName(baComp.serviceName());
+ }
+ else if (executionMode == ExecutionMode.EJB)
+ {
+
+ // We need following information
+ // 1) Method name (already obtained)
+ // 2) Method's class (optional)
+ // 3) Interface of the EJB
+ // 4) JNDI name of the EJB
+ // 5) Provider URL (optional)
+
+ // Method's class
+ log.info("Getting method's class");
+ Class[] methodClass = baComp.serviceClass();
+ boolean baParamAnnotationFound = true;
+ if (methodClass.length == 0)
+ {
+ log.info("Method's class not specified");
+
+ // Class can be either specified in the BAService annotation or is remote
+ log.info("Checking if method's class has been specified in BAService");
+ if (commonInfo.getBaClass() != null)
+ {
+ log.info("Class specified in the BAService annotation");
+ methodClass = new Class[1];
+ methodClass[0] = commonInfo.getBaClass();
+ }
+ else
+ {
+ log.info("Class not specified - remote execution.");
+ }
+ }
+ else
+ {
+ log.info("Method's class specified");
+ }
+
+ if (methodClass.length > 0)
+ {
+ // Class specified
+ log.info("Class: " + methodClass[0]);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = methodClass[0].getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ log.info("Method found!");
+
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter types");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Process identifiers of method's parameters
+ log.info("Checking identifiers");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ baParamAnnotationFound = true;
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ md.setClazz(methodClass[0]);
+
+ // Get the interface
+ Class[] ejbInterface = baComp.ejbInterface();
+ if (ejbInterface.length == 0)
+ {
+ log.info("EJB interface not specified");
+ if (commonInfo.getBaInterface() != null)
+ {
+ log.info("EJB interface specified in BAService - storing value");
+ ejbInterface = new Class[1];
+ ejbInterface[0] = commonInfo.getBaInterface();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("Interface to EJB not specified.");
+ }
+ }
+ else
+ {
+ log.info("EJB Interface specified.");
+ }
+ if (ejbInterface.length > 0 )
+ {
+ // Interface specified
+ log.info("EJB Interface: " + ejbInterface[0]);
+
+ // Checking if the method exists
+ log.info("Checking if method exists");
+ Method[] methodList = ejbInterface[0].getMethods();
+ boolean methodFound = false;
+ for (Method singleMethod : methodList)
+ {
+ log.info("Comparing " + methodName + " against " + singleMethod.getName() + ".");
+ if (singleMethod.getName().equals(methodName))
+ {
+ log.info("Method found!");
+
+ // Remember types of parameters
+ log.info("Getting parameter types");
+ Class[] parameterTypes = singleMethod.getParameterTypes();
+
+ if (parameterTypes != null)
+ {
+ log.info("Method has parameters");
+
+ log.info("Setting parameter types");
+ md.setParameterTypes(singleMethod.getParameterTypes());
+
+ // Process identifiers of method's parameters
+ if (!baParamAnnotationFound)
+ {
+
+ log.info("Checking identifiers");
+ Object[] parameterAnnotation = new Object[singleMethod.getParameterTypes().length];
+ Annotation[][] parameterAnnotations = singleMethod.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] annotationArray : parameterAnnotations)
+ {
+ for (Annotation annotation : annotationArray)
+ {
+ if (annotation instanceof BAParam)
+ {
+ log.info("BAParam annotation present for parameter: " + i);
+ String valueS = ((BAParam)annotation).value();
+ try
+ {
+ Integer valueI = new Integer(valueS);
+ parameterAnnotation[i] = valueI;
+ }
+ catch (NumberFormatException nfe)
+ {
+ parameterAnnotation[i] = valueS;
+ }
+ }
+ else
+ {
+ log.info("No BAParam annotation for parameter: " + i);
+ }
+ }
+ i++;
+ }
+ md.setParameterIdentifiers(parameterAnnotation);
+ }
+ }
+ else
+ {
+ log.info("Method does not take any parameters");
+ }
+ methodFound = true;
+ break;
+ }
+ }
+ if (!methodFound)
+ {
+ throw new MethodNotAccessibleException("Method not found.");
+ }
+
+ }
+ md.setEjbInterface(ejbInterface[0]);
+
+ // Get the JNDI name of the EJB
+ log.info("Getting JNDI name of the EJB");
+ String jndiName = baComp.jndiName();
+ if (!jndiName.equals(""))
+ {
+ log.info("JNDI name: " + jndiName);
+ }
+ else
+ {
+ // Check if the JNDI name has been specified
+ if (commonInfo.getBaJndiName() != null)
+ {
+ jndiName = commonInfo.getBaJndiName();
+ }
+ else
+ {
+ throw new MethodIncorrectlyAnnotatedException("JNDI name not specified");
+ }
+ }
+ md.setJndiName(jndiName);
+
+ // Check if the URL provider has been specified
+ String providerURL = baComp.providerURL();
+ if (!providerURL.equals(""))
+ {
+ log.info("Provider URL: " + providerURL);
+ }
+ else
+ {
+ // Check if the provider URL has been specified
+ if (commonInfo.getBaProviderURL() != null)
+ {
+ providerURL = commonInfo.getBaProviderURL();
+ }
+ else
+ {
+ providerURL = null;
+ }
+ }
+ md.setProviderURL(providerURL);
+ }
+ return md;
+ }
+
+}
Property changes on: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/helper/BATaskVisitor.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/CommonServiceInfo.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/CommonServiceInfo.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/CommonServiceInfo.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.service;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public class CommonServiceInfo
+{
+ private Class baClass;
+ private Class baInterface;
+ private String baJndiName;
+ private String baProviderURL;
+ private String endpointAddress;
+ private String targetNamespace;
+ private String serviceName;
+
+
+ public Class getBaClass()
+ {
+ return baClass;
+ }
+
+ public void setBaClass(Class[] baClass)
+ throws IncorrectDataException
+ {
+ if (baClass.length > 0)
+ {
+ this.baClass = baClass[0];
+ }
+ else
+ {
+ throw new IncorrectDataException();
+ }
+ }
+
+ public Class getBaInterface()
+ {
+ return baInterface;
+ }
+
+ public void setBaInterface(Class[] baInterface)
+ throws IncorrectDataException
+ {
+ if (baInterface.length > 0)
+ {
+ this.baInterface = baInterface[0];
+ }
+ else
+ {
+ throw new IncorrectDataException();
+ }
+ }
+
+ public String getBaJndiName()
+ {
+ return baJndiName;
+ }
+
+ public void setBaJndiName(String baJndiName)
+ {
+ this.baJndiName = baJndiName;
+ }
+
+ public String getBaProviderURL()
+ {
+ return baProviderURL;
+ }
+
+ public void setBaProviderURL(String baProviderURL)
+ throws IncorrectDataException
+ {
+ try
+ {
+ new URL(baProviderURL);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IncorrectDataException(e);
+ }
+ this.baProviderURL = baProviderURL;
+ }
+
+ public String getEndpointAddress()
+ {
+ return endpointAddress;
+ }
+
+ public void setEndpointAddress(String endpointAddress)
+ throws IncorrectDataException
+ {
+ try
+ {
+ new URL(endpointAddress);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IncorrectDataException(e);
+ }
+ this.endpointAddress = endpointAddress;
+ }
+
+ public String getTargetNamespace()
+ {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace)
+ {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+}
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/EJBMethodDescriptionImpl.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/EJBMethodDescriptionImpl.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/EJBMethodDescriptionImpl.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.service;
+
+/**
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public class EJBMethodDescriptionImpl extends MethodDescriptionImpl
+{
+ private Class clazz;
+ private Class ejbInterface;
+ private String jndiName;
+ private String providerURL;
+
+ public Class getClazz()
+ {
+ return clazz;
+ }
+
+ public void setClazz(Class clazz)
+ {
+ this.clazz = clazz;
+ }
+
+ public Class getEjbInterface()
+ {
+ return ejbInterface;
+ }
+
+ public void setEjbInterface(Class ejbInterface)
+ {
+ this.ejbInterface = ejbInterface;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public String getProviderURL()
+ {
+ return providerURL;
+ }
+
+ public void setProviderURL(String providerURL)
+ {
+ this.providerURL = providerURL;
+ }
+}
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/IncorrectDataException.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/IncorrectDataException.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/IncorrectDataException.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.service;
+
+/**
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public class IncorrectDataException extends Exception
+{
+
+ public IncorrectDataException()
+ {
+ super();
+ }
+
+ public IncorrectDataException(String message)
+ {
+ super(message);
+ }
+
+ public IncorrectDataException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/ServiceType.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/ServiceType.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/ServiceType.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.service;
+
+/**
+ *
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public enum ServiceType
+{
+ ORIGINAL,
+ COMPLETE,
+ COMPENSATE,
+ CANCEL,
+ CLOSE
+}
Added: labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/WebMethodDescriptionImpl.java
===================================================================
--- labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/WebMethodDescriptionImpl.java (rev 0)
+++ labs/jbosstm/workspace/baframework/trunk/src/org/jboss/txbridge/ba/service/WebMethodDescriptionImpl.java 2007-09-27 23:40:22 UTC (rev 15415)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss Inc.
+ */
+package org.jboss.txbridge.ba.service;
+
+/**
+ * @author Maciej P. Machulak (mmachulak at redhat.com)
+ * @version 0.1
+ */
+public class WebMethodDescriptionImpl
+{
+ private String endpointAddress;
+ private String targetNamespace;
+ private String serviceName;
+
+ public String getEndpointAddress()
+ {
+ return endpointAddress;
+ }
+
+ public void setEndpointAddress(String endpointAddress)
+ {
+ this.endpointAddress = endpointAddress;
+ }
+
+ public String getTargetNamespace()
+ {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace)
+ {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+}
More information about the jboss-svn-commits
mailing list