You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/05/10 22:32:32 UTC
svn commit: r169518 [3/8] - in /incubator/beehive/trunk:
docs/forrest/src/documentation/content/xdocs/
docs/forrest/src/documentation/content/xdocs/system-controls/
docs/forrest/src/documentation/content/xdocs/system-controls/ejb/
docs/forrest/src/documentation/content/xdocs/system-controls/jdbc/
docs/forrest/src/documentation/content/xdocs/system-controls/jms/
docs/forrest/src/documentation/content/xdocs/system-controls/webservices/
docs/forrest/src/documentation/content/xdocs/tutorial/
system-controls/samples/ system-controls/samples/ejb/
system-controls/samples/ejb/client/ system-controls/samples/ejb/client/org/
system-controls/samples/ejb/client/org/apache/
system-controls/samples/ejb/client/org/apache/beehive/
system-controls/samples/ejb/client/org/apache/beehive/controls/
system-controls/samples/ejb/client/org/apache/beehive/controls/system/
system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/
system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/
system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/
system-controls/samples/ejb/control/ system-controls/samples/ejb/control/org/
system-controls/samples/ejb/control/org/apache/
system-controls/samples/ejb/control/org/apache/beehive/
system-controls/samples/ejb/control/org/apache/beehive/controls/
system-controls/samples/ejb/control/org/apache/beehive/controls/system/
system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/
system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/
system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/control/
system-controls/samples/ejb/ejb/ system-controls/samples/ejb/ejb/META-INF/
system-controls/samples/ejb/ejb/org/
system-controls/samples/ejb/ejb/org/apache/
system-controls/samples/ejb/ejb/org/apache/beehive/
system-controls/samples/ejb/ejb/org/apache/beehive/controls/
system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/
system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/
system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/
system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/
system-controls/samples/jdbc/ system-controls/samples/jdbc/jdbcControlSample/
system-controls/samples/jdbc/jdbcControlSample/META-INF/
system-controls/samples/jdbc/jdbcControlSample/WEB-INF/
system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/
system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/controls/
system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/servlet/
system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/shared/
system-controls/samples/jms/ system-controls/samples/jms/src/
system-controls/samples/jms/src/org/
system-controls/samples/jms/src/org/apache/
system-controls/samples/jms/src/org/apache/beehive/
system-controls/samples/jms/src/org/apache/beehive/controls/
system-controls/samples/jms/src/org/apache/beehive/controls/system/
system-controls/samples/jms/src/org/apache/beehive/controls/system/jms/
system-controls/samples/jms/src/org/apache/beehive/controls/system/jms/samples/
system-controls/samples/webservice/
system-controls/samples/webservice/amazon/
system-controls/samples/webservice/amazon/junit/
system-controls/samples/webservice/amazon/schemas/
system-controls/samples/webservice/common/
system-controls/samples/webservice/common/src/
system-controls/samples/webservice/common/src/test/
system-controls/samples/webservice/google/
system-controls/samples/webservice/google/junit/
system-controls/samples/webservice/google/junit/model/
system-controls/samples/webservice/google/rpc_schemas/
system-controls/samples/webservice/google/servlet/
system-controls/samples/webservice/lib/
system-controls/samples/webservice/wsm_samples_client/
system-controls/samples/webservice/wsm_samples_client/doc_schemas/
system-controls/samples/webservice/wsm_samples_client/junit/
system-controls/samples/webservice/wsm_samples_client/junit/org/
system-controls/samples/webservice/wsm_samples_client/junit/org/wsm/
system-controls/samples/webservice/wsm_samples_client/junit/org/wsm/samples/
system-controls/samples/webservice/wsm_samples_client/junit/org/wsm/samples/client/
system-controls/samples/webservice/wsm_samples_client/junit/org/wsm/samples/client/header/
system-controls/samples/webservice/wsm_samples_client/junit/org/wsm/samples/client/webparam/
system-controls/samples/webservice/wsm_samples_client/rpc_schemas/
system-controls/samples/webservice/xmlbeans/
system-controls/samples/webservice/xmlbeans/junit/
system-controls/samples/webservice/xmlbeans/schemas/ system-controls/src/ejb/
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jdbc/jdbcControlTutorial.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jdbc/jdbcControlTutorial.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jdbc/jdbcControlTutorial.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jdbc/jdbcControlTutorial.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>Jdbc Control Overview</title>
+ </header>
+ <body>
+ <section>
+ <title>Overview</title>
+ <section>
+ <title>The Problem with Jdbc: Complexity</title>
+ <p>
+ The Jdbc Control makes it easy to access a relational database from your Java code using SQL commands.
+ The Jdbc Control handles the work of connecting to the database, so you don't have to understand JDBC to
+ work with a database.</p>
+ <p>
+ The methods that you add to a Jdbc Control execute SQL commands against the database. You can send any
+ SQL command to the database via the Jdbc Control, so that you can retrieve data, perform operations like
+ inserts and updates, and even make structural changes to the database.</p>
+ <p>
+ All Jdbc controls are subclassed from the JdbcControl interface. The interface defines methods that Jdbc
+ control instances can call from an application. See the Tutorial for more detailed information
+ about using the JdbcControl.</p>
+ </section>
+ </section>
+ <section>
+ <title>Tutorial</title>
+ <section>
+ <title>Jdbc Control Tutorial</title>
+ <p>
+ The code fragements used in the mini-tutorial are from the jdbcControlSample - the full source
+ can be found in the samples directory of the JdbcControl's source tree.</p>
+ </section>
+
+ <section>
+ <title>Extending the Jdbc-Control Interface</title>
+ <p>
+ The JdbcControl is an extensible control. Before a JdbcControl can be used in an application,
+ a subinterface of the org.apache.beehive.controls.system.jdbc.JdbcControl interface must be created.</p>
+ <source>
+/**
+ * JdbcControl implementation for the JdbcControl sample app.
+ */
+@org.apache.beehive.controls.api.bean.ControlExtension
+@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/JdbcControlSampleDB")
+public interface SimpleDBControl extends JdbcControl {
+ .
+ .
+ .
+}
+ </source>
+
+ <p>
+ In the sample above several Java 1.5 annotations are used. The @ControlExtension annotation is required and
+ tells the Beehive control framework that this control extends an extensible control (in this case the JdbcControl).
+ </p>
+ </section>
+
+ <section>
+ <title>Connecting to a Database Instance</title>
+ <p> After a .jcx file has been created, the next step is to tell the JdbcControl how to connect to a database instance.
+ This is done using class level Java annotations, there are two annotations which can be used:</p>
+ <ul>
+ <li>JdbcControl.ConnectionDriver</li>
+ <li>JdbcControl.ConnectionDataSource</li>
+ </ul>
+
+ <p>(i) See the Jdbc Control Annotation Reference for additional information about these annotations.</p>
+ </section>
+
+ <section>
+ <title>Making Jdbc Calls to a Database Instance</title>
+
+ <p>Now that the jcx knows how to connect to the database instance, the next step is to create
+ methods in the jcx which access the database. Let's assume we want to access a table
+ in the database which looks like:</p>
+
+ <source>
+CREATE TABLE products (name VARCHAR(64), description VARCHAR(128), quantity INT)
+ </source>
+
+ <p>Here's what the control might look like:</p>
+
+ <source>
+/**
+ * JdbcControl implementation for the JdbcControl sample app.
+ */
+@org.apache.beehive.controls.api.bean.ControlExtension
+@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/JdbcControlSampleDB")
+public interface SimpleDBControl extends JdbcControl
+{
+
+ static public class Product
+ {
+ private String _name;
+ private String _description;
+ private int _quantity;
+
+ public int getQuantity() { return _quantity; }
+ public void setQuantity(int i) { _quantity = i; }
+
+ public String getName() { return _name; }
+ public void setName(String n) { _name = n; }
+
+ public String getDescription() { return _description; }
+ public void setDescription(String n) { _description = n; }
+ }
+
+ /**
+ * Get the name column from the products table.
+ * @return An array of strings.
+ */
+ @JdbcControl.SQL(statement="SELECT name FROM products")
+ public String[] getProductNames() throws SQLException;
+
+ /**
+ * Get the rest of the columns associated with a product name.
+ * @param productName Name of product to lookup.
+ * @return An instance of Product.
+ */
+ @JdbcControl.SQL(statement="SELECT * FROM products WHERE name={productName}")
+ public Product getProductDetails(String productName) throws SQLException;
+
+ static final long serialVersionUID = 1L;
+}
+ </source>
+
+ <p>The SimpleJdbcControl can be accessed from an application as follows:</p>
+
+ <source>
+public class Foo {
+
+ // the @Control annotation causes the control to be intialized when this class is loaded.
+ @Control
+ public SimpleDBControl jdbcCtrl;
+
+ public void doFoo() {
+ String[] productNames = jdbcCtrl.getProductNames();
+ Product productInfo = jdbcCtrl.getProductDetails(productNames[3]);
+ }
+}
+ </source>
+
+ <p>Note the use of the @SQL method annotation in SimpleDBControl.jcx, see the Jdbc Control Annotation Reference for
+ additional information about the SQL annotation.</p>
+ </section>
+ <section>
+ <title>SQL Parameter Substitution</title>
+
+ <p>It is also possible to substitute method parameter values into the statement member of the @SQL annotation:</p>
+
+ <source>
+//
+// simple query with param substitution
+//
+@SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+public ResultSet getSomeUser(int someUserId) throws SQLException;
+
+//
+// query with sql substitution
+//
+@SQL(statement="SELECT * FROM USERS WHERE {sql: where}")
+public ResultSet getJustOneUser(String where) throws SQLException;
+ </source>
+
+
+ <p>For the first method, the value of the parameter 'someUserId' gets substituted into the SQL statement at
+ runtime when the getSomeUser() method is invoked. For the second method, the substitution gets added to the
+ SQL statement as the literal value of the 'where' parameter.</p>
+
+ </section>
+ </section>
+ </body>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jms-annotations.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jms-annotations.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jms-annotations.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jms-annotations.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>JMS Control Annotations</title>
+ </header>
+ <body>
+ <section>
+ <title>JMS Control Annotations</title>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.CorrelationId.html">@JMSControl.CorrelationId</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Delivery.html">@JMSControl.Delivery</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Destination.html">@JMSControl.Destination</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Expiration.html">@JMSControl.Expiration</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Message.html">@JMSControl.Message</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Priority.html">@JMSControl.Priority</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Properties.html">@JMSControl.Properties</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Property.html">@JMSControl.Property</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.PropertyValue.html">@JMSControl.PropertyValue</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/jms/JMSControl.Type.html">@JMSControl.Type</a></p>
+ </section>
+ </body>
+ <footer>
+ <legal>Java, J2EE, and JCP are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.<br/>
+ © 2005, Apache Software Foundation
+ </legal>
+ </footer>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsControlTutorial.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsControlTutorial.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsControlTutorial.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsControlTutorial.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>Jms Control Tutorial</title>
+ </header>
+ <body>
+ <section>
+ <title>Jms Control Tutorial</title>
+
+ <p>The JmsControl is an extensible control. Before a JmsControl can be used in an application,
+ a sub-interface of the org.apache.beehive.controls.system.jms.JmsControl interface must be created and
+ annotated with @ControlExtension.</p>
+
+ <source>
+@ControlExtension
+public interface SampleQueue extends JMSControl
+{
+...
+}
+ </source>
+
+ <p>In order for the control to work, it needs to know the destination of the messages. This is
+ accomplished using a JNDI context. Unless otherwise specified the default initial
+ context is used. This may be overridden by settng the jndiContextFactory and
+ jndiProviderUrl properties, either programically (setJndiContextFactory() and
+ setJndiProviderUrl()) or via the corresponding @Destination attributes.</p>
+
+ <p>The queue/topic destination is then obtained using the value of the sendJndiName property
+ and a queue/topic connection is obtained using by the jndiConnectionFactory property.
+ In most cases the same connection factory is used for both queues and topics. The
+ @Destination sendType attribute may be used to constrain the use of the control to
+ either a topic or a queue. By default it's value is Auto which allowes for run-time
+ determination of whether the sendJndiName names a queue or a topic. By setting it to
+ Queue or Topic a run-time check is made to see if the connection factory and destination
+ is of the correct type.</p>
+
+ <p>If the JNDI context to be used (i.e. the control is running in an ejb-container (or
+ servlet-container with a JNDI context) is known (or is the default context) and the
+ connection-factory (e.g. weblogic.jms.ConnectionFactory) and queue JNDI name
+ (e.g. jms.SampleQueue) is also known at development time then the extension class can
+ be annotated with the @Destination annotation as shown in the example:</p>
+
+ <source>
+@ControlExtension
+@JMSControl.Destination(sendType=JMSControl.DestinationType.Queue,sendJndiName="jms.SampleQueue",jndiConnectionFactory="weblogic.jms.ConnectionFactory")
+public interface SampleQueue extends JMSControl
+{
+...
+}
+ </source>
+
+ <p>Likewise, for a topic (e.g. jms.SampleTopic) the following .jcx might be appropriate:</p>
+
+ <source>
+@ControlExtension
+@JMSControl.Destination(sendType=JMSControl.DestinationType.Topic,sendJndiName="jms.SampleTopic",jndiConnectionFactory="weblogic.jms.ConnectionFactory")
+public interface SampleTopic extends JMSControl
+{
+...
+}
+ </source>
+
+
+ <p>The sendType attribute could be left out of these examples and the control extensions would still work.</p>
+
+ <p>See Extension Class Annotation for other annotations defined at the class or type level.</p>
+
+ <p>The extension interface can include one or more methods that send messages. These methods must have
+ at least one unannotated parameter that corresponds to the body of the message. Other annotated
+ parameters can defined to provide property values and other information at run-time to the
+ message (see Extension Class Annotation for allowed annotation). The method itself can be
+ annotated (see Extension Class Annotation for allowed annotation).</p>
+
+ <p>Some examples appropriate to topics and queues include:</p>
+
+ <source>
+/**
+ * Submit an xml object (org.apache.xmlbeans) as a text message.
+ * @param document the document.
+ * @param type the message JMS type.
+*/
+public void submitXml(XmlObject document,@Type String type);
+
+/**
+ * Submit an xml object (org.apache.xmlbeans) with JMS type "xmlObject".
+ * @param document the document.
+ */
+@Message(MessageType.Text)
+@Type("xmlObject")
+public void submitXml(XmlObject document);
+
+/**
+ * Submit an already constructed message
+ * @param message the jms-message.
+*/
+public void submitMessage(Message message);
+
+/**
+ * Submit a BytesMessage with the given byte array body and property hello.
+ * @param body the byte array.
+ * @param hello the value of the hello property.
+*/
+public void submitMessage(byte[] body, @Property(name=hello) hello);
+
+
+/**
+ * Submit a MapMessage with the given map and property hello set to world.
+ * @param body the byte array.
+*/
+@Properties({PropertyValue(name="hello", value="world")})
+public void submitMessage(Map body);
+ </source>
+ </section>
+ </body>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsDoc.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsDoc.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsDoc.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/jms/jmsDoc.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>Jms Control Overview</title>
+ </header>
+ <body>
+ <section>
+ <title>Overview</title>
+
+ <p>The JMS control provides for sending messages to a queue or topic destination. It is an extensible
+ control where sub-classes are bound to specific queues/topics and methods may be defined to
+ send messages of specific types with specific properties and headers. The queue connections
+ are transparently managed by the controls relieving the developer of that responsibility.</p>
+
+ <p>In the example below, the OrderQueue control class has one submitOrder() method that takes an
+ Order object as the body and a string that sets the'DeliverBy' property in the
+ javax.jms.ObjectMessage to be sent to the queue.orders JMS queue.</p>
+
+ <source>
+@ControlExtension
+@JMSControl.Destination(sendJndiName="queue.orders",jndiConnectionFactory="weblogic.jws.jms.QueueConnectionFactory")
+public interface OrderQueue extends JMSControl
+ {
+ public class Order implements java.io.Serializable
+ {
+ public Order()
+ {
+
+ }
+ public Order(int buyer,String[] list)
+ {
+ buyerId = buyer;
+ itemList = list;
+
+ }
+ private int buyerId;
+ private String[] itemList;
+ }
+
+ public void submitOrder(Order order,@Property(name="DeliverBy") String deliverBy);
+}
+ </source>
+ </section>
+ <section>
+ <title>Control Methods</title>
+
+ <p>The methods for the jms-control are:</p>
+ <table>
+ <tr><th>Method</th><th>Description</th></tr>
+ <tr><td>getSession()</td><td>Get the queue/topic session.</td></tr>
+ <tr><td>getDestination()</td><td>Get the queue/topic destination.</td></tr>
+ <tr><td>getConnection()</td><td>Get the queue/topic connection.</td></tr>
+ <tr><td>setHeaders(Map)</td><td>Set the headers from the given map. The keys should be of type HeaderType or equivalent strings. Used only for the next message send. See table below for valid values.</td></tr>
+ <tr><td>setHeader(HeaderType,Object)</td><td>Set a header. Used only for the next message send.</td></tr>
+ <tr><td>setProperties(Map)</td><td>Set the properties on the message using the map of string/object pairs. Used only for the next message send.</td></tr>
+ <tr><td>setProperty(String,Object)</td><td>Set a property. Used only for the next message send.</td></tr>
+ </table>
+
+ <p>The methods of the extension control-classes correspond to sending a message to a topic/queue, e.g.</p>
+ <source>send<message-type>(...)</source>
+ </section>
+ <section>
+ <title>Header Types</title>
+
+ <p>The table below defines the valid values for header types passed into setHeader() or setHeaders():</p>
+ <table>
+ <tr><th>JMS Message Method</th><th>HeaderType/String</th><th>Allowed Value Types</th></tr>
+ <tr><td>setJMSType()</td><td>JMSType</td><td>String</td></tr>
+ <tr><td>setJMSCorrelationID()</td><td>JMSCorrelationID</td><td>String or byte[]</td></tr>
+ <tr><td>setJMSExpiration()</td><td>JMSExpiration</td><td>String valued long or Long</td></tr>
+ <tr><td>setJMSPriority()</td><td>Priority</td><td>String valued int or Integer</td></tr>
+ </table>
+
+ <p>All other values are silently ignored (for backward compatability).</p>
+ </section>
+
+ <section>
+ <title>Extension Class Annotation</title>
+
+ <p>The is one TYPE/FIELD level annotation is:</p>
+
+ <ul>
+ <li>@Destination - defines the destination of the message, the message type and
+ connection related attributes.</li>
+ </ul>
+ <p></p>
+ <p>The defined annotation attributes for the @Destination element are:</p>
+ <table>
+ <tr><th>Attribute</th><th>Value</th><th>Description</th></tr>
+ <tr><td>sendJndiName</td><td>string</td><td>JNDI name of the queue or topic. Required.</td></tr>
+ <tr><td>sendCorrelationProperty</td><td>string</td><td>The correlation property to be used for message sent. Default is empty which signifies that the JMS correlation header is to be used. Optional.</td></tr>
+ <tr><td>connectionFactoryJndiName</td><td>string</td><td>JNDI name of the connection factory. Required</td></tr>
+ <tr><td>transacted</td><td>boolean</td><td>True if en-queuing is under transactional semantics of the enclosing container. Default is true. See JMS documentation on transactional semantics of en-queueing and de-queueing.</td></tr>
+ <tr><td>acknowledgeMode</td><td>enum AcknowledgeMode</td><td>The acknowledgement strategy, one of Auto, Client, DupsOk. Default is Auto. See JMS API documentation on javax.jms.Session.AUTO_ACKNOWLEDGE/CLIENT_ACKNOWLEDGE/DUPS_OK_ACKNOWLEDGE for more information</td></tr>
+ <tr><td>sendType</td><td>enum DestinationType</td><td>Values are Auto, Queue and Topic. If Auto, then the type is determined by the destination named by the sendJndiName attribute. Default is Auto.</td></tr>
+ <tr><td>jndiContextFactory</td><td>string</td><td>The class name of the jndi-context-factory. Default is none.</td></tr>
+ <tr><td>jndiProviderURL</td><td>string</td><td>The provider URL for JNDI. Default is none.</td></tr>
+ </table>
+
+ <p>The method and parameters can be annotated with the annotation types in the next section.</p>
+ </section>
+ <section>
+ <title>Extension Method Annotation</title>
+
+ <p>The jms-control is intended to be extended. One or more methods may be defined that send messages
+ to the given destination may be annotated with:</p>
+
+ <ul>
+ <li>@Message( message-type) or @Message or nothing.</li>
+
+ <li>@Priority - the int valued attribute contains a JMS priority (0-9). If not given then
+ the default for the provider is used.</li>
+
+ <li>@Expiration - the long valued attribute contains a JMS expiration in milliseconds.
+ If not given then the default for the provider is used.</li>
+
+ <li>@Delivery - the DeliveryMode valued attribute determines the delivery mode of the
+ message. If not given then the default for the provider is used.</li>
+
+ <li>@Type - the string valued attribute determines the JMS type.</li>
+
+ <li>@CorrelationId - the string valued attribute determines the correlation id.</li>
+
+ <li>@Properties( PropertyValue[] ) - One or more string/int/long valued properties to be added
+ to the message. PropertyValue has the string valued attributes 'name','value' and class
+ valued 'type'. The allowed values for 'type' are String.class, Integer.class and Long.class.
+ If not given then 'String.class' is assumed.</li>
+ </ul>
+
+
+ <p>The message-type value is a MessageType enumerated value. Values are: Auto, Object, Bytes, Text,
+ Map and JMSMessage. If not given or no message-type string then the default is Auto. If Auto
+ then the type of JMS message is determined by the type of the body passed in. If the body is a
+ String or XmlObject then a TextMessage is sent, if the body is a byte[] then a StreamMessage
+ is sent, if the body is a Map then a MapMessage is sent, if the body is a JMSMessage then it is sent,
+ otherwise if the body is Serializable then an ObjectMessage is sent. Any other type
+ results in a control exception.</p>
+
+ <p>The values of the DeliveryMode enumerated value are: NonPersistent, Persistent and Auto where
+ Auto is the default.</p>
+ </section>
+ <section>
+ <title>Extension Method Parameter Annotation</title>
+
+ <p>Parameters to a send message method may be annotated:</p>
+ <ul>
+ <li>@Property (name= blah ) - the parameter contains the value of the property blah.</li>
+
+ <li>@Priority - the int or integer valued String parameter contains a JMS priority (0-9). If
+ not given then the method-level annotation is used if given else the default for
+ the provider is used.</li>
+
+ <li>@Expiration - the long or integer valued String parameter contains a JMS expiration in
+ milliseconds. If not given then the method-level annotation is used if given else
+ the default for the provider is used.</li>
+
+ <li>@Delivery - the DeliveryMode valued parameter determines the delivery mode of the message.
+ If not given then the method-level annotation is used if given else the default for
+ the provider is used.</li>
+
+ <li>@Type - the string valued parameter determines the JMS type.</li>
+
+ <li>@CorrelationId - the string valued parameter determines the correlation id.</li>
+ </ul>
+
+
+ <p>These annotations denote which parameter is to be the body of the message and zero or more
+ properties to be set in the message respectively.</p>
+
+ </section>
+ </body>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservices-annotations.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservices-annotations.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservices-annotations.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservices-annotations.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>Webservice Control Annotations</title>
+ </header>
+ <body>
+ <section>
+ <title>Webservice Control Annotations</title>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/webservice/ServiceControl.Location.html">@ServiceControl.Location</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/webservice/ServiceControl.OperationName.html">@ServiceControl.OperationName</a></p>
+ <p><a href="../../apidocs/classref_systemcontrols/org/apache/beehive/controls/system/webservice/ServiceControl.WSDL.html">@ServiceControl.WSDL</a></p>
+ </section>
+ </body>
+ <footer>
+ <legal>Java, J2EE, and JCP are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.<br/>
+ © 2005, Apache Software Foundation
+ </legal>
+ </footer>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesControlTutorial.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesControlTutorial.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesControlTutorial.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesControlTutorial.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>WebServices Control Tutorial</title>
+ </header>
+ <body>
+ <section>
+ <title>WebServices Control Tutorial</title>
+ <p>TBD</p>
+ </section>
+ </body>
+</document>
Added: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesDoc.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesDoc.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesDoc.xml (added)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/system-controls/webservices/webservicesDoc.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>WebServices Control Overview</title>
+ </header>
+ <body>
+ <section>
+ <title>What is the Web Service Control?</title>
+
+ <p>The Web Service Control provides an easy way to create a web service client
+ based on a valid WSDL document. A rudimentary client generator is provided
+ that will create a control extension that with a few simple modifications can
+ call the target web service using either XmlBeans (for Literal) or Axis Generated
+ Beans (for Encoded) as parameters and return types.</p>
+ <p>Type generation is handled ahead of the sample compilation so that all types used
+ in the control extension are already available on the classpath.</p>
+ </section>
+ </body>
+</document>
Modified: incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/tutorial/tut_dbdrivenwebapp.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/tutorial/tut_dbdrivenwebapp.xml?rev=169518&r1=169517&r2=169518&view=diff
==============================================================================
--- incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/tutorial/tut_dbdrivenwebapp.xml (original)
+++ incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/tutorial/tut_dbdrivenwebapp.xml Tue May 10 13:32:29 2005
@@ -19,9 +19,9 @@
import java.util.HashMap;
import org.apache.beehive.controls.api.bean.ControlExtension;
-import org.controlhaus.jdbc.JdbcControl;
-import org.controlhaus.jdbc.JdbcControl.ConnectionDataSource;
-import org.controlhaus.jdbc.JdbcControl.SQL;
+import org.apache.beehive.controls.system.jdbc.JdbcControl;
+import org.apache.beehive.controls.system.jdbc.JdbcControl.ConnectionDataSource;
+import org.apache.beehive.controls.system.jdbc.JdbcControl.SQL;
@ControlExtension
@ConnectionDataSource(jndiName="jdbc:derby:build/databaseControlTestDB;create=true")
Added: incubator/beehive/trunk/system-controls/samples/ejb/build.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/build.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/build.xml (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/build.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,88 @@
+<?xml version="1.0" ?>
+
+<project name="ejb-control sample" basedir="." default="build">
+
+ <import file="../../systemcontrols-imports.xml"/>
+
+ <property environment="env"/>
+
+ <property name="sample.build.dir" value="${basedir}/build"/>
+
+ <property name="build.samples.classes" value="${sample.build.dir}/classes"/>
+ <property name="build.samples.beansrc" value="${sample.build.dir}/beansrc"/>
+ <property name="samples.control.dir" value="${basedir}/control"/>
+ <property name="samples.ejb.dir" value="${basedir}/ejb"/>
+ <property name="samples.client.dir" value="${basedir}/client"/>
+ <property name="build.samples.jar" value="ejb-control-samples.jar"/>
+
+ <path id="build.classpath">
+ <pathelement path="${build.samples.classes}"/>
+ <fileset file="${build.lib.dir}/beehive-ejb-control.jar"/>
+ <path refid="ejb.dependency.path"/>
+ <path refid="controls.dependency.path"/>
+ <path refid="xbean.dependency.path"/>
+ </path>
+
+ <taskdef name="assemble"
+ classname="org.apache.beehive.controls.runtime.assembly.AssembleTask"
+ classpathref="build.classpath"
+ onerror="report"/>
+
+ <taskdef name="control-jar"
+ classname="org.apache.beehive.controls.runtime.packaging.ControlJarTask"
+ onerror="report"
+ classpathref="build.classpath"/>
+
+
+ <target name="clean" description="Deletes all generated files">
+ <delete dir="${sample.build.dir}"/>
+ <delete file="velocity.log"/>
+ </target>
+
+ <target name="dirs">
+ <mkdir dir="${sample.build.dir}"/>
+ <mkdir dir="${build.samples.classes}"/>
+ <mkdir dir="${build.samples.beansrc}"/>
+ </target>
+
+
+ <target name="build-samples-ejb" depends="dirs" description="Builds sample control ejb">
+ <javac srcdir="${samples.ejb.dir}" destdir="${build.samples.classes}"
+ classpathref="build.classpath"
+ debug="on"
+ target="1.5">
+ </javac>
+
+ <jar jarfile="${sample.build.dir}/HelloEJB.jar">
+ <fileset dir="${build.samples.classes}" includes="org/controlhaus/ejb/sample/bean/**"/>
+ <fileset dir="${samples.ejb.dir}" includes="META-INF/**"/>
+ </jar>
+ </target>
+
+
+ <target name="build-samples-control" depends="build-samples-ejb" description="Builds sample control control">
+ <build-controls srcdir="${samples.control.dir}" destdir="${build.samples.classes}"
+ tempdir="${build.samples.beansrc}" classpathref="build.classpath"/>
+ </target>
+
+
+ <target name="build" depends="build-samples-control" description="Builds sample control client">
+
+ <build-controls srcdir="${samples.client.dir}" destdir="${build.samples.classes}"
+ tempdir="${build.samples.beansrc}" classpathref="build.classpath"/>
+
+ <assemble moduleDir="${build.samples.classes}"
+ srcOutputDir="${build.samples.beansrc}"
+ contextFactoryClassname="org.apache.beehive.controls.runtime.assembly.EJBAssemblyContext$Factory">
+ <classpath>
+ <path refid="build.classpath"/>
+ </classpath>
+ <fileset dir="${build.samples.classes}">
+ <include name="**/*.controls.properties"/>
+ </fileset>
+ </assemble>
+
+ <control-jar destfile="${build.dir}/${build.samples.jar}" basedir="${build.samples.classes}"/>
+ </target>
+
+</project>
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/ControlTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/ControlTestCase.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/ControlTestCase.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/ControlTestCase.java Tue May 10 13:32:29 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+
+import java.beans.Beans;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+
+
+/**
+ * An test case that handles establishing a bean context
+ * if there isn't one and providing methods instantiating controls by name
+ * via proper channels (@see Beans.instantiate) and adding/removing
+ * them.
+ */
+public abstract class ControlTestCase extends TestCase
+{
+ /* Public Constructor(s) */
+ /**
+ * Contstruct a test-case with the given name.
+ * @param name the name of the test case.
+ */
+ public ControlTestCase(String name) throws Exception
+ {
+ super(name);
+ }
+ /* Public Method(s) */
+ /**
+ * @see TestCase#setUp
+ */
+ public void setUp() throws Exception
+ {
+ _embeddedContext = ControlThreadContext.getContext();
+ if(_embeddedContext == null)
+ {
+ _embeddedContext = _cntxt = new DefaultContainerContext();
+ _cntxt.beginContext();
+ }
+ initializeAsClient(this);
+ }
+ /**
+ * @see TestCase#tearDown
+ */
+ public void tearDown() throws Exception
+ {
+ if(_cntxt != null)
+ {
+ _cntxt.endContext();
+ }
+ }
+ /* Protected Method(s) */
+ /**
+ * Instantiate the control with the given name and add
+ * it to the current bean-context.
+ * @param name the fully-qualified name of the control.
+ */
+ protected ControlBean instantiateControl(String name) throws Exception
+ {
+ ControlBean bean = (ControlBean)Beans.instantiate(Thread.currentThread().getContextClassLoader(),
+ name,_embeddedContext);
+ initializeAsClient(bean);
+ return bean;
+ }
+ /**
+ * Remove the given control from the current bean-context.
+ * @param bean
+ */
+ protected void freeControl(ControlBean bean)
+ {
+ if(bean != null)
+ {
+ _embeddedContext.remove(bean);
+ }
+ }
+ /**
+ * Initialize this junit as a control client.
+ */
+ protected void initializeAsClient(Object obj)
+ {
+ if(_cntxt == null)
+ {
+ return;
+ }
+ Class cls = obj.getClass();
+ while(cls != null && cls != ControlTestCase.class && cls != Object.class)
+ {
+ String init = cls.getName()+CLASS_ClientInitializer;
+ try
+ {
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(init);
+ Object initializer = cls.newInstance();
+ Method m = clazz.getMethod(METHOD_Initialize,new Class[] {ControlBeanContext.class,cls });
+ m.invoke(initializer,new Object[] { _cntxt ,this } );
+
+ }
+ catch(Exception e)
+ {
+
+ }
+ cls = cls.getSuperclass();
+ }
+ }
+ /* Private Constant(s) */
+ final private static String CLASS_ClientInitializer = "ClientInitializer";
+ final private static String METHOD_Initialize = "initialize";
+
+ /* Private Field(s) */
+ /* The current context. */
+ private ControlContainerContext _embeddedContext;
+ /* The default context if one didn't exist */
+ private ControlContainerContext _cntxt;
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultContainerContext.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultContainerContext.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultContainerContext.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultContainerContext.java Tue May 10 13:32:29 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+import java.io.IOException;
+
+import org.apache.beehive.controls.api.ControlException;
+import org.apache.beehive.controls.api.context.ControlHandle;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.runtime.bean.ControlContainerContext;
+import org.apache.beehive.controls.runtime.bean.ControlBeanContext;
+
+/**
+ * The DefaultContainerContext provides a ControlContainerContext implementation to be used
+ * for simple testing of controls.
+ */
+public class DefaultContainerContext extends ControlContainerContext
+{
+
+ /* Public Constructor(s) */
+ /**
+ * Construct a container-context for a standalone
+ * application use.
+ */
+ public DefaultContainerContext()
+ {
+ super();
+ }
+ /* Public Method(s) */
+
+ /**
+ * @see ControlContainerContext#getControlHandle(org.apache.beehive.controls.runtime.bean.ControlBean)
+ */
+ public ControlHandle getControlHandle(ControlBean bean)
+ {
+ return new DefaultControlHandle(this,bean);
+ }
+
+ /* Private Constant(s) */
+ private static final long serialVersionUID = -7967007783133727017L;
+
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultControlHandle.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultControlHandle.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultControlHandle.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/DefaultControlHandle.java Tue May 10 13:32:29 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.beehive.controls.api.context.ControlHandle;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.events.EventRef;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+
+/**
+ * A control-handle used for simple invokation/event support.
+ */
+public class DefaultControlHandle implements ControlHandle, Serializable
+{
+ /** Public Constructor(s) */
+ /**
+ * Default constructor (used by serialization).
+ */
+ public DefaultControlHandle()
+ {
+
+ }
+
+ /**
+ * Construct a simple-control handle.
+ *
+ * @param context
+ * The control-container-context.
+ * @param bean
+ * the control bean.
+ */
+ public DefaultControlHandle(ControlContainerContext context,
+ ControlBean bean)
+ {
+ _context = context;
+ _controlId = bean.getControlID();
+ _controlInterface = bean.getControlInterface().getName();
+ _controlBean = bean.getClass().getName();
+ }
+
+ /** Public Method(s) */
+ /**
+ * @see org.apache.beehive.controls.api.context.ControlHandle#getControlID()
+ */
+ public String getControlID()
+ {
+ return _controlId;
+ }
+
+ /**
+ * @see org.apache.beehive.controls.api.context.ControlHandle#sendEvent(org.apache.beehive.controls.api.events.EventRef,
+ * java.lang.Object[])
+ */
+ public Object sendEvent(EventRef event, Object[] args)
+ throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException
+ {
+ if(_context == null)
+ {
+ _context = ControlThreadContext.getContext();
+ }
+ if(_context == null)
+ {
+ throw new IllegalArgumentException("No container context to send event to");
+ }
+ try
+ {
+ //
+ // Push the test context, to simulate re-entering the container
+ //
+ _context.beginContext();
+
+ return _context.dispatchEvent(this, event, args);
+ } finally
+ {
+ _context.endContext();
+ }
+ }
+
+ private static final long serialVersionUID = 1928410200080675302L;
+
+ /* Private Field(s) */
+ /** The control-id of the control. */
+ private String _controlId;
+
+ /** The interface class of the control. */
+ private String _controlInterface;
+
+ /** The bean class of the control. */
+ private String _controlBean;
+
+ /** The control container context */
+ private transient ControlContainerContext _context;
+
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlClient.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlClient.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlClient.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlClient.java Tue May 10 13:32:29 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.system.ejb.sample.control.HelloEJBControl;
+
+public class EJBControlClient
+{
+ @Control
+ private HelloEJBControl hello;
+
+ public EJBControlClient()
+ {
+ super();
+ }
+
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlTestCase.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlTestCase.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/EJBControlTestCase.java Tue May 10 13:32:29 2005
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+import org.apache.beehive.controls.system.ejb.sample.control.HelloEJBControlBean;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class EJBControlTestCase extends SingleControlTestCase
+{
+
+ public EJBControlTestCase(String name) throws Exception {
+ super(name, HelloEJBControlBean.class.getName());
+ }
+
+ public static void main (String[] args) {
+ junit.textui.TestRunner.run (suite());
+ }
+
+ public static Test suite() {
+ return new TestSuite(EJBControlTestCase.class);
+ }
+
+ public void testHello()
+ {
+ try
+ {
+ HelloEJBControlBean helloEJBBean = (HelloEJBControlBean)this.getControl();
+ String str = helloEJBBean.hello();
+ System.out.println(str);
+ }
+ catch (Exception e)
+ {
+ assertTrue("Exception occurred: " + e, false);
+ }
+
+ }
+
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/HelloBeanClient.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/HelloBeanClient.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/HelloBeanClient.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/HelloBeanClient.java Tue May 10 13:32:29 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.beehive.controls.system.ejb.sample.bean.HelloHome;
+import org.apache.beehive.controls.system.ejb.sample.bean.HelloRemote;
+
+public class HelloBeanClient
+{
+
+ /**
+ *
+ */
+ public HelloBeanClient()
+ {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ Context ctx = null;
+ Hashtable ht = new Hashtable();
+ ht.put(Context.INITIAL_CONTEXT_FACTORY,
+ "weblogic.jndi.WLInitialContextFactory");
+ ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
+ ht.put(Context.SECURITY_PRINCIPAL, "weblogic");
+ ht.put(Context.SECURITY_CREDENTIALS, "weblogic");
+ ctx = new InitialContext(ht);
+
+ //Object objref = ctx.lookup("java:comp/env/ejb/messageBuffer.TestHome");
+ Object objref = ctx.lookup("org.apache.beehive.controls.system.ejb.sample.HelloHome");
+ HelloHome home = (HelloHome) PortableRemoteObject.narrow(objref,
+ HelloHome.class);
+
+ HelloRemote hello = (HelloRemote) PortableRemoteObject.narrow(home.create(), HelloRemote.class);
+ String txt = hello.hello();
+ System.out.println("Message returned from Hello Bean: " + txt);
+ }
+ catch (Exception ex)
+ {
+ System.err.println("Caught an unexpected exception!");
+ ex.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/SingleControlTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/SingleControlTestCase.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/SingleControlTestCase.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/client/org/apache/beehive/controls/system/ejb/sample/client/SingleControlTestCase.java Tue May 10 13:32:29 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.client;
+
+
+import java.beans.Beans;
+
+import junit.framework.TestCase;
+
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+
+
+/**
+ * A test case that handles establishing a bean context
+ * if there isn't one and instantiating a single control.
+ */
+public abstract class SingleControlTestCase extends ControlTestCase
+{
+ /* Public Constructor(s) */
+ /**
+ * Contstruct a test-case with the given name for a single control.
+ * @param name the name of the test case.
+ */
+ public SingleControlTestCase(String testName,String controlName) throws Exception
+ {
+ super(testName);
+ _controlName = controlName;
+ }
+ /* Public Method(s) */
+ /**
+ * @see TestCase#setUp
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ _bean = instantiateControl(_controlName);
+ }
+
+ /**
+ * @see TestCase#tearDown
+ */
+ public void tearDown() throws Exception
+ {
+ //freeControl(_bean);
+ super.tearDown();
+ }
+ /* Protected Method(s) */
+ /**
+ * Get the single control bean.
+ * @return a control-bean.
+ */
+ protected ControlBean getControl() throws Exception
+ {
+ return _bean;
+ }
+ /* Private Field(s) */
+ /** The name of the control */
+ private String _controlName;
+ /** A cache of the bean. */
+ private ControlBean _bean;
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/control/HelloEJBControl.jcx
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/control/HelloEJBControl.jcx?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/control/HelloEJBControl.jcx (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/control/org/apache/beehive/controls/system/ejb/sample/control/HelloEJBControl.jcx Tue May 10 13:32:29 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.control;
+
+import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.system.ejb.EJBControl;
+import org.apache.beehive.controls.system.ejb.SessionEJBControl;
+import org.apache.beehive.controls.system.ejb.sample.bean.HelloHome;
+import org.apache.beehive.controls.system.ejb.sample.bean.HelloRemote;
+
+@ControlExtension
+@EJBControl.EJBHome(jndiName="org.apache.beehive.controls.system.ejb.sample.HelloHome")
+@EJBControl.JNDIContextEnv(contextFactory="weblogic.jndi.WLInitialContextFactory",
+ providerURL="t3://localhost:7001", principal="weblogic", credentials="weblogic")
+public interface HelloEJBControl
+ extends SessionEJBControl, HelloHome, HelloRemote
+{
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/META-INF/ejb-jar.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/META-INF/ejb-jar.xml (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/META-INF/ejb-jar.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
+
+
+<!-- Generated XML! -->
+
+<ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>HelloBean</ejb-name>
+ <home>org.apache.beehive.controls.system.ejb.sample.bean.bean.HelloHome</home>
+ <remote>org.apache.beehive.controls.system.ejb.sample.bean.bean.HelloRemote</remote>
+ <local-home>org.apache.beehive.controls.system.ejb.sample.bean.bean.HelloLocalHome</local-home>
+ <local>org.apache.beehive.controls.system.ejb.sample.bean.bean.HelloLocal</local>
+ <ejb-class>org.apache.beehive.controls.system.ejb.sample.bean.bean.HelloBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>HelloBean</ejb-name>
+ <method-intf>Remote</method-intf>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Supports</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+
+</ejb-jar>
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloBean.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloBean.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloBean.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloBean.java Tue May 10 13:32:29 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.bean;
+
+import java.rmi.RemoteException;
+import javax.ejb.*;
+
+public class HelloBean implements SessionBean
+{
+ public HelloBean()
+ {
+ }
+
+ public void ejbCreate()
+ {
+ }
+
+ public void ejbRemove()
+ throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbActivate()
+ throws EJBException, RemoteException
+ {
+
+ }
+
+ public void ejbPassivate()
+ throws EJBException, RemoteException
+ {
+ }
+
+ public void setSessionContext(SessionContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public String hello()
+ {
+ return "Hello";
+ }
+
+ private static final long serialVersionUID = 0xa0aa87e44ca8f7c2L;
+ private SessionContext ctx;
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloHome.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloHome.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloHome.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloHome.java Tue May 10 13:32:29 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.bean;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+// Referenced classes of package org.apache.beehive.controls.junit.ejb.impl:
+// JUnitRunnerRemote
+
+public interface HelloHome
+ extends EJBHome
+{
+
+ public abstract HelloRemote create()
+ throws CreateException, RemoteException;
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocal.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocal.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocal.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocal.java Tue May 10 13:32:29 2005
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.bean;
+
+import javax.ejb.EJBLocalObject;
+
+public interface HelloLocal
+ extends EJBLocalObject
+{
+ public abstract String hello();
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocalHome.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocalHome.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocalHome.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloLocalHome.java Tue May 10 13:32:29 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.bean;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+// Referenced classes of package org.apache.beehive.controls.junit.ejb.impl:
+// JUnitRunnerRemote
+
+public interface HelloLocalHome
+ extends EJBLocalHome
+{
+
+ public abstract HelloLocal create()
+ throws CreateException;
+}
Added: incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloRemote.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloRemote.java?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloRemote.java (added)
+++ incubator/beehive/trunk/system-controls/samples/ejb/ejb/org/apache/beehive/controls/system/ejb/sample/bean/HelloRemote.java Tue May 10 13:32:29 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004 BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.beehive.controls.system.ejb.sample.bean;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBObject;
+
+public interface HelloRemote
+ extends EJBObject
+{
+ public abstract String hello()
+ throws RemoteException;
+}
Added: incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/Controller.jpf?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/Controller.jpf (added)
+++ incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/Controller.jpf Tue May 10 13:32:29 2005
@@ -0,0 +1,126 @@
+import javax.servlet.http.HttpSession;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import org.apache.beehive.controls.api.bean.Control;
+import controls.SimpleDBControl;
+import controls.PopulateDBCtrl;
+import shared.SharedFlow;
+
+@Jpf.Controller(
+ simpleActions={},
+ sharedFlowRefs={
+ @Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class)
+ }
+)
+public class Controller
+ extends PageFlowController
+{
+ @Jpf.SharedFlowField(name="shared")
+ private shared.SharedFlow sharedFlow;
+
+ // initialize the SimpleDBCtrl
+ @Control()
+ private SimpleDBControl _simpleDbCtrl;
+
+ // initialize the PopulateDBCtrl
+ @Control()
+ private PopulateDBCtrl _popCtrl;
+
+ public transient String[] productNames;
+ public transient SimpleDBControl.Product productDetails;
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="success", path="index.jsp")
+ }
+ )
+ protected Forward begin() {
+ return new Forward("success");
+ }
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="success", path="demo.jsp"),
+ @Jpf.Forward(name="error", path="error.jsp")
+ }
+ )
+ protected Forward startDemo() {
+
+ try {
+ productNames = _simpleDbCtrl.getProductNames();
+ } catch (SQLException sqe) {
+ System.out.println("JdbcSampleApp: Error Calling Simpledb: " + sqe);
+ return new Forward("error");
+ }
+ return new Forward("success");
+ }
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="details", path="details.jsp"),
+ @Jpf.Forward(name="error", path="error.jsp")
+ }
+ )
+ protected Forward productDetails() {
+
+ try {
+ productDetails = _simpleDbCtrl.getProductDetails(getRequest().getParameter("key"));
+ } catch (SQLException sqe) {
+ System.out.println("JdbcSampleApp: Error Calling Simpledb: " + sqe);
+ return new Forward("error");
+ }
+ return new Forward("details");
+ }
+
+ /**
+ * Callback that is invoked when this controller instance is created.
+ */
+ protected void onCreate()
+ {
+ String check = null;
+
+ try {
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+ } catch (ClassNotFoundException e) {
+ System.out.println("JdbcSampleApp: Class Not Found: " + e);
+ return;
+ }
+
+ System.out.println("jdbcControlSample: checking to see if products table exists...");
+ try {
+ check = _popCtrl.isProductsTableEmpty();
+ } catch (SQLException sqe) {
+ }
+
+ // table has been loaded -- just return
+ if (check != null) {
+ System.out.println("jdbcControlSample: products table exists.");
+ return;
+ }
+
+ System.out.println("jdbcControlSample: products table does not exist, creating...");
+ try {
+ _popCtrl.createProductsTable();
+ _popCtrl.addProductRow("apple", "red apples", 200);
+ _popCtrl.addProductRow("orange", "orange oranges", 400);
+ _popCtrl.addProductRow("kiwi", "lots of kiwi", 800);
+ _popCtrl.addProductRow("banana", "yellow", 123);
+ _popCtrl.addProductRow("coconut", "coconutty", 21);
+ _popCtrl.addProductRow("plum", "lots of plums", 999);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Callback that is invoked when this controller instance is destroyed.
+ */
+ protected void onDestroy(HttpSession session)
+ {
+ }
+}
Added: incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/META-INF/context.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/META-INF/context.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/META-INF/context.xml (added)
+++ incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/META-INF/context.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<Context path="/JdbcControlSample" docBase="/d:/beeline/samples/jdbcControlSample" debug="5" reloadable="true" crossContext="true">
+
+ <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_dataWeb_log." suffix=".txt" timestamp="true"/>
+
+ <Resource name="jdbc/JdbcControlSampleDB" auth="Container" type="javax.sql.DataSource"/>
+
+ <ResourceParams name="jdbc/JdbcControlSampleDB">
+
+ <parameter>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </parameter>
+
+ <parameter>
+ <name>driverClassName</name>
+ <value>org.apache.derby.jdbc.EmbeddedDriver</value>
+ </parameter>
+
+ <parameter>
+ <name>url</name>
+ <value>jdbc:derby:JdbcControlSampleDB;create=true</value>
+ </parameter>
+
+ <!-- Maximum number of dB connections in pool. Make sure you
+ configure your mysqld max_connections large enough to handle
+ all of your db connections. Set to 0 for no limit.
+ -->
+ <parameter>
+ <name>maxActive</name>
+ <value>100</value>
+ </parameter>
+
+ <!-- Maximum number of idle dB connections to retain in pool.
+ Set to 0 for no limit.
+ -->
+ <parameter>
+ <name>maxIdle</name>
+ <value>30</value>
+ </parameter>
+
+ <!-- Maximum time to wait for a dB connection to become available
+ in ms, in this example 10 seconds. An Exception is thrown if
+ this timeout is exceeded. Set to -1 to wait indefinitely.
+ -->
+ <parameter>
+ <name>maxWait</name>
+ <value>10000</value>
+ </parameter>
+
+ </ResourceParams>
+</Context>
Added: incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.properties?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.properties (added)
+++ incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.properties Tue May 10 13:32:29 2005
@@ -0,0 +1,9 @@
+#
+#
+#
+beehive.home=../../../..
+
+servlet-api.jar=${os.CATALINA_HOME}/common/lib/servlet-api.jar
+jsp-api.jar=${os.CATALINA_HOME}/common/lib/jsp-api.jar
+
+context.path=netui-blank
Added: incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.xml?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.xml (added)
+++ incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/build.xml Tue May 10 13:32:29 2005
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ -->
+
+<!--
+ An Ant build file for compiling a Beehive page flow web application.
+-->
+<project name="Beehive/Samples/netui-blank" default="usage" basedir="../..">
+
+ <property environment="os"/>
+ <property file="${basedir}/WEB-INF/src/build.properties"/>
+
+ <import file="${beehive.home}/beehive-imports.xml"/>
+ <import file="${beehive.home}/ant/beehive-tools.xml"/>
+
+ <property name="webapp.dir" location="${basedir}"/>
+
+ <property name="tmp.sourcegen.dir" value=".tmpbeansrc"/>
+ <property name="tmp.jpfgen.dir" value=".pageflow-struts-generated"/>
+
+ <!-- Define the classpath used to build the webapp -->
+ <path id="webapp.build.classpath">
+ <pathelement location="${servlet-api.jar}"/>
+ <pathelement location="${jsp-api.jar}"/>
+ <pathelement location="${webapp.dir}/WEB-INF/classes"/>
+ <fileset dir="${webapp.dir}/WEB-INF/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="deploy-beehive" description="Copy the Beehive page flow and web service rutime into the target webapp">
+ <deploy-netui webappDir="${webapp.dir}"/>
+ <deploy-wsm webappDir="${webapp.dir}"/>
+ </target>
+
+ <target name="build" depends="deploy-beehive" description="Build the webapp">
+ <available property="webapp.dir.available" file="${webapp.dir}" type="dir"/>
+ <fail unless="webapp.dir.available" message="Can't find the webapp directory ${webapp.dir}"/>
+
+ <!--
+ this directory needs to get whacked before every build so
+ that control interface repackagings don't cause stale
+ files to be compiled
+ -->
+ <delete dir="${webapp.dir}/WEB-INF/${tmp.sourcegen.dir}" includeEmptyDirs="true"/>
+
+ <mkdir dir="${webapp.dir}/WEB-INF/classes"/>
+
+ <!-- compile XSDs -->
+ <build-schemas srcdir="${webapp.dir}/WEB-INF/schemas" destdir="${webapp.dir}/WEB-INF/classes"/>
+
+ <!-- compile controls -->
+ <build-controls srcdir="${webapp.dir}/WEB-INF/src"
+ destdir="${webapp.dir}/WEB-INF/classes"
+ tempdir="${webapp.dir}/WEB-INF/${tmp.sourcegen.dir}"
+ classpathref="webapp.build.classpath"/>
+
+ <!-- compile JPFs -->
+ <build-pageflows srcdir="${webapp.dir}"
+ weboutputdir="${webapp.dir}"
+ classoutputdir="${webapp.dir}/WEB-INF/classes"
+ tempdir="${webapp.dir}/WEB-INF/${tmp.sourcegen.dir}"
+ classpathref="webapp.build.classpath"/>
+
+ <!-- copy resources -->
+ <echo>Copy all .properties and .xml files</echo>
+ <copy todir="${webapp.dir}/WEB-INF/classes">
+ <fileset dir="${webapp.dir}/WEB-INF/src" includes="**/*.properties"/>
+ <fileset dir="${webapp.dir}/WEB-INF/src" includes="**/*.xml"/>
+ </copy>
+ </target>
+
+ <target name="clean" description="Clean the webapp">
+ <delete dir="${webapp.dir}/WEB-INF/classes" includeEmptyDirs="true"/>
+ <delete dir="${webapp.dir}/WEB-INF/${tmp.sourcegen.dir}" includeEmptyDirs="true"/>
+ <delete dir="${webapp.dir}/WEB-INF/${tmp.jpfgen.dir}" includeEmptyDirs="true"/>
+ </target>
+
+ <target name="war" description="Build a compressed WAR file that can be deployed to an application container">
+ <property name="archive.dir" value="${webapp.dir}/.."/>
+
+ <!-- this does *not* exclude source from the archive -->
+ <war destfile="${archive.dir}/${context.path}.war" webxml="${webapp.dir}/WEB-INF/web.xml">
+ <fileset dir="${webapp.dir}">
+ <exclude name="WEB-INF/web.xml"/>
+ <exclude name="WEB-INF/src/**"/>
+ </fileset>
+ </war>
+ </target>
+
+ <target name="usage" description="Print usage information for this build file">
+ <echo>
+To run the webapp, two steps need to occur:
+- copy the Beehive runtime to the webapp
+- build the webapp
+
+Once the webapp is built, it's ready to deploy onto your application container.
+ </echo>
+
+ <java fork="no" classname="org.apache.tools.ant.Main">
+ <arg line="-f ${ant.file} -projecthelp"/>
+ </java>
+ </target>
+
+</project>
Added: incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/controls/PopulateDBCtrl.jcx
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/controls/PopulateDBCtrl.jcx?rev=169518&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/controls/PopulateDBCtrl.jcx (added)
+++ incubator/beehive/trunk/system-controls/samples/jdbc/jdbcControlSample/WEB-INF/src/controls/PopulateDBCtrl.jcx Tue May 10 13:32:29 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package controls;
+
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import org.apache.beehive.controls.system.jdbc.JdbcControl;
+
+/**
+ * This Jdbc Control is used to populate the sample database.
+ */
+@org.apache.beehive.controls.api.bean.ControlExtension
+@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/JdbcControlSampleDB")
+public interface PopulateDBCtrl extends JdbcControl
+{
+ /**
+ * Create the products table in the database.
+ */
+ @JdbcControl.SQL(statement="CREATE TABLE products (name VARCHAR(64), description VARCHAR(128), quantity INT)")
+ public void createProductsTable() throws SQLException;
+
+ /**
+ * Add a row to the products table.
+ * @param name String
+ * @param description String
+ * @param quantity int
+ */
+ @JdbcControl.SQL(statement="INSERT INTO products VALUES ({name}, {description}, {quantity})")
+ public void addProductRow(String name, String description, int quantity) throws SQLException;
+
+ /**
+ * Returns the number of rows in the products table.
+ * @return
+ */
+ @JdbcControl.SQL(statement="SELECT name FROM products WHERE name='apple'")
+ public String isProductsTableEmpty() throws SQLException;
+
+ static final long serialVersionUID = 1L;
+}