You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/07/14 22:22:28 UTC
svn commit: r422018 [3/6] - in /beehive/trunk/netui/test: conf/
webapps/controls/ webapps/controls/src/ webapps/controls/src/controls/
webapps/controls/src/controls/binding/
webapps/controls/src/controls/composition/
webapps/controls/src/controls/conte...
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.composition;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * A control interface to test control composition.
+ */
+@ControlInterface
+public interface OuterControl {
+
+ @EventSet(unicast = true)
+ public interface OuterEvents {
+ int report(String message);
+ }
+
+ public void fireOuterEvents(String message);
+
+ public InnerControlBean getDeclaredNestedControl();
+
+ public InnerControlBean getDeclaredNestedControl2();
+
+ public InnerControlBean instantiateNestedControlProgrammatically();
+
+ public InnerControlBean instantiateNestedControlWithProperty();
+
+ /*
+ * Test outer control receiving event from nested control using
+ * EventHandler.
+ */
+ public String testActivityWakeup();
+
+ public String testActivityReadMessage();
+
+ public String testActivityReport();
+
+ public String testActionShopping();
+
+ public String testActionDostuff();
+
+ /*
+ * Tests outer control receiving event from nested control using
+ * event listener. The nested control is instantiated programmatically
+ */
+ public String testEventListener();
+
+ /*
+ * Tests outer control receiving event from nested control using
+ * event listener. The nested control is instantiated decalratively
+ */
+ public String testEventListenerByDeclare();
+
+ /*
+ * Tests outer control receiving event from nested control using
+ * inner class listener. The nested control is instantiated programmatically
+ */
+ public String testInnerClassListener();
+
+ /*
+ * Tests outer control receiving event from nested control using
+ * inner class listener. The nested control is instantiated decalratively
+ */
+ public String testInnerClassListenerByDeclare();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,501 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.composition;
+
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.events.Client;
+import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.beehive.controls.api.properties.BeanPropertyMap;
+
+/**
+ * A control implementation to test control composition. Makes two instances of nested control be declaration.
+ */
+@ControlImplementation
+public class OuterControlImpl implements OuterControl, java.io.Serializable {
+
+ static final long serialVersionUID = 1L;
+ static final String EVENT_RECEIVED = "Event Received";
+
+ private String innerControlEventHandlerWakeUp = "";
+ private String innerControlEventHandlerReadMessage = "";
+ private String innerControlEventHandlerReport = "";
+ private String innerControlEventHandlerShopping = "";
+ private String innerControlEventHandlerDoStuff = "";
+
+ private boolean innerClassWakeUp = false;
+ private boolean innerClassReadMessage = false;
+ private boolean innerClassReport = false;
+ private boolean innerClassShopping = false;
+ private boolean innerClassDoStuff = false;
+
+ private boolean innerControlInnerClassWakeUp = false;
+ private boolean innerControlInnerClassReadMessage = false;
+ private boolean innerControlInnerClassReport = false;
+ private boolean innerControlInnerClassShopping = false;
+ private boolean innerControlInnerClassDoStuff = false;
+
+ @Client
+ transient OuterEvents outerEvents;
+
+ /*Instantiates a nested control without reconfiguring the property*/
+ @Control
+ InnerControlBean innerControl;
+
+ @Control
+ @InnerControl.Identity(job = "farmer")
+ InnerControlBean innerControl2;
+
+ //
+ // Define various event handlers for the nested controls
+ //
+ @EventHandler(field = "innerControl", eventSet = InnerControl.Activity.class, eventName = "wakeup")
+ public void innerControlwakeup() {
+ innerControlEventHandlerWakeUp = EVENT_RECEIVED;
+ }
+
+ @EventHandler(field = "innerControl", eventSet = InnerControl.Activity.class, eventName = "readMessage")
+ public int innerControlreadMessage(String message) {
+ innerControlEventHandlerReadMessage = EVENT_RECEIVED;
+ return 0;
+ }
+
+ @EventHandler(field = "innerControl", eventSet = InnerControl.Activity.class, eventName = "report")
+ public String innerControlreport() {
+ innerControlEventHandlerReport = EVENT_RECEIVED;
+ return "a report";
+ }
+
+ @EventHandler(field = "innerControl", eventSet = InnerControl.Action.class, eventName = "shopping")
+ public Object [] innerControlshopping(double credit) {
+ innerControlEventHandlerShopping = EVENT_RECEIVED;
+ return null;
+ }
+
+ @EventHandler(field = "innerControl", eventSet = InnerControl.Action.class, eventName = "doStuff")
+ public void innerControldoStuff(String vakue) {
+ innerControlEventHandlerDoStuff = EVENT_RECEIVED;
+ }
+
+ @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "wakeup")
+ public void innerControl2wakeup() {
+ }
+
+ @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "readMessage")
+ public int innerControl2readMessage(String message) {
+ return 0;
+ }
+
+ @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "report")
+ public String innerControl2report() {
+ return "a report";
+ }
+
+ @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "shopping")
+ public Object [] innerControl2shopping(double credit) {
+ return null;
+ }
+
+ @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "doStuff")
+ public void innerControl2doStuff(String vakue) {
+ }
+
+ public void fireOuterEvents(String message) {
+ outerEvents.report(message);
+ }
+
+ public InnerControlBean getDeclaredNestedControl() {
+ return innerControl;
+ }
+
+ public InnerControlBean getDeclaredNestedControl2() {
+ return innerControl2;
+ }
+
+ public InnerControlBean instantiateNestedControlProgrammatically() {
+ try {
+ InnerControlBean inner =
+ (InnerControlBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(),
+ "org.apache.beehive.netui.test.controls.composition.InnerControlBean");
+ return inner;
+ }
+ catch (Exception e) {
+ return null;
+ }
+ }
+
+ public InnerControlBean instantiateNestedControlWithProperty() {
+ try {
+ BeanPropertyMap props = new BeanPropertyMap(InnerControl.Identity.class);
+ props.setProperty(InnerControlBean.NameKey, "ken");
+ props.setProperty(InnerControlBean.JobKey, "engineer");
+ props.setProperty(InnerControlBean.RankKey, new Integer(2));
+ InnerControlBean inner = (InnerControlBean) org.apache.beehive.controls.api.bean.Controls.instantiate(
+ Thread.currentThread().getContextClassLoader(),
+ "org.apache.beehive.netui.test.controls.composition.InnerControlBean", props);
+ return inner;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Failed to instantiate nested control", e);
+ }
+ }
+
+ public String testActivityWakeup() {
+
+ String result = "";
+ if (innerControl == null)
+ result = "inner control is NULL";
+ else {
+ innerControl.fireEvent("Activity", "wakeup");
+ /*Wait for the events*/
+ try {
+ Thread.sleep(1000);
+ if (innerControlEventHandlerWakeUp.equals(EVENT_RECEIVED))
+ result = "0";
+ else
+ result = "Acivity.wakeup not received by EventHandler";
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+ }
+ return result;
+ }
+
+ public String testActivityReadMessage() {
+
+ String result = "";
+ if (innerControl == null)
+ result = "inner control is NULL";
+ else {
+ innerControl.fireEvent("Activity", "readMessage");
+ /*Wait for the events*/
+ try {
+ Thread.sleep(1000);
+
+ if (innerControlEventHandlerReadMessage.equals(EVENT_RECEIVED))
+ result = "0";
+ else
+ result = "Acivity.readMessage not received by EventHandler";
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+ }
+ return result;
+
+ }
+
+ public String testActivityReport() {
+
+ String result = "";
+ if (innerControl == null)
+ result = "inner control is NULL";
+ else {
+ innerControl.fireEvent("Activity", "report");
+ /*Wait for the events*/
+ try {
+ Thread.sleep(1000);
+
+ if (innerControlEventHandlerReport.equals(EVENT_RECEIVED))
+ result = "0";
+ else
+ result = "Acivity.report not received by EventHandler";
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+ }
+ return result;
+
+ }
+
+ public String testActionShopping() {
+
+ String result = "";
+ if (innerControl == null)
+ result = "inner control is NULL";
+ else {
+ innerControl.fireEvent("Action", "shopping");
+ /*Wait for the events*/
+ try {
+ Thread.sleep(1000);
+
+ if (innerControlEventHandlerShopping.equals(EVENT_RECEIVED))
+ result = "0";
+ else
+ result = "Action.shopping not received by EventHandler";
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+ }
+ return result;
+
+ }
+
+ public String testActionDostuff() {
+
+ String result = "";
+ if (innerControl == null)
+ result = "inner control is NULL";
+ else {
+ innerControl.fireEvent("Action", "doStuff");
+ /*Wait for the events*/
+ try {
+ Thread.sleep(1000);
+
+ if (innerControlEventHandlerDoStuff.equals(EVENT_RECEIVED))
+ result = "0";
+ else
+ result = "Action.doStuff not received by EventHandler";
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+ }
+ return result;
+
+ }
+
+ /*Tests outer control receiving event from nested control using
+ * event listener. The nested control is instantiated programmatically
+ */
+ public String testEventListener() {
+
+ String result = "init";
+ try {
+
+ InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader(),
+ "org.apache.beehive.netui.test.controls.composition.InnerControlBean");
+ if (nested == null)
+ result = "Nested control instantiated programmatically is NULL.";
+ else {
+ //Create an Event Listener
+ InnerControlEventListener listener = new InnerControlEventListener();
+ nested.addActivityListener(listener);
+ nested.addActionListener(listener);
+ nested.fireAllEvents();
+ try {
+ Thread.sleep(1000);
+ result = listener.getFinalResult();
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+
+
+ }
+ }
+ catch (Exception e) {
+ result = "Exception caught:" + e.toString();
+ }
+ return result;
+ }
+
+ /*Tests outer control receiving event from nested control using
+ * event listener. The nested control is instantiated decalratively
+ */
+ public String testEventListenerByDeclare() {
+
+ String result = "init";
+
+ if (innerControl == null)
+ result = "Nested control instantiated declaratively is NULL.";
+ else {
+ try {
+ //Create an Event Listener
+ InnerControlEventListener listener = new InnerControlEventListener();
+ innerControl.addActivityListener(listener);
+ innerControl.addActionListener(listener);
+ innerControl.fireAllEvents();
+
+ Thread.sleep(1000);
+ result = listener.getFinalResult();
+ }
+ catch (Exception e) {
+ result = "Thread sleep interrupted." + e.toString();
+ }
+
+
+ }
+ return result;
+
+ }
+
+ /*Tests outer control receiving event from nested control using
+ * inner class listener. The nested control is instantiated programmatically
+ */
+ public String testInnerClassListener() {
+
+ String result = "init";
+ try {
+ InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader(),
+ "org.apache.beehive.netui.test.controls.composition.InnerControlBean");
+ if (nested == null)
+ result = "Nested control instantiated programmatically is NULL.";
+ else {
+ nested.addActivityListener(
+ new InnerControl.Activity() {
+
+ public void wakeup() {
+ innerClassWakeUp = true;
+ }
+
+ public int readMessage(String message) {
+ innerClassReadMessage = true;
+ return 0;
+ }
+
+ public String report() {
+ innerClassReport = true;
+ return "event received.";
+ }
+ }
+ );
+ nested.addActionListener(
+ new InnerControl.Action() {
+
+ public Object[] shopping(double credit) {
+ innerClassShopping = true;
+ //return {"food","drinks","candies"};
+ return null;
+ }
+
+ public void doStuff(String value) {
+ innerClassDoStuff = true;
+ }
+ }
+ );
+ nested.fireAllEvents();
+ try {
+ Thread.sleep(1000);
+ }
+ catch (Exception e) {
+ /* ignore */
+ }
+
+ result = getInnerClassListenerResult();
+ }
+ }
+ catch (Exception e) {
+ result = "Exception caught:" + e.toString();
+ }
+ return result;
+ }
+
+ /*Tests outer control receiving event from nested control using
+ * inner class listener. The nested control is instantiated decalratively
+ */
+ public String testInnerClassListenerByDeclare() {
+
+ String result = "init";
+
+ if (innerControl == null)
+ result = "Nested control instantiated declaratively is NULL.";
+ else {
+ try {
+ innerControl.addActivityListener(
+ new InnerControl.Activity() {
+ public void wakeup() {
+ innerControlInnerClassWakeUp = true;
+ }
+
+ public int readMessage(String message) {
+ innerControlInnerClassReadMessage = true;
+ return 0;
+ }
+
+ public String report() {
+ innerControlInnerClassReport = true;
+ return "event received.";
+ }
+ }
+ );
+ innerControl.addActionListener(
+ new InnerControl.Action() {
+
+ public Object[] shopping(double credit) {
+ innerControlInnerClassShopping = true;
+ //return {"food","drinks","candies"};
+ return null;
+ }
+
+ public void doStuff(String value) {
+ innerControlInnerClassDoStuff = true;
+ }
+ }
+ );
+ innerControl.fireAllEvents();
+
+ Thread.currentThread().sleep(1000);
+ }
+ catch (Exception e) {
+ }
+
+ result = getInnerControlInnerClassListenerResult();
+ }
+ return result;
+
+ }
+
+ private String getInnerClassListenerResult() {
+
+ String result = "";
+
+ if (!innerClassWakeUp)
+ result = "WakeUp not received.";
+ if (!innerClassReadMessage)
+ result = result + "readMessage not received.";
+ if (!innerClassReport)
+ result = result + "report not received.";
+ if (!innerClassShopping)
+ result = result + "shopping not received.";
+ if (!innerClassDoStuff)
+ result = result + "dostuff not received.";
+
+ if (result.length() == 0)
+ result = "0";
+
+ return result;
+ }
+
+ private String getInnerControlInnerClassListenerResult() {
+
+ String result = "";
+
+ if (!innerControlInnerClassWakeUp)
+ result = "WakeUp not received.";
+ if (!innerControlInnerClassReadMessage)
+ result = result + "readMessage not received.";
+ if (!innerControlInnerClassReport)
+ result = result + "report not received.";
+ if (!innerControlInnerClassShopping)
+ result = result + "shopping not received.";
+ if (!innerControlInnerClassDoStuff)
+ result = result + "dostuff not received.";
+
+ if (result.length() == 0)
+ result = "0";
+
+ return result;
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/composition/OuterControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.container;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * This control just echos information, plus provides a way to get information
+ * about the state of the control.
+ */
+@ControlInterface
+public interface ContainerControl {
+ public String echo(String value);
+ public String getInfo();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.container;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ResourceContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.beehive.controls.runtime.servlet.ServletBeanContext;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.ServletResponseWrapper;
+
+/**
+ * This is a test control that intends to grow up beyond what
+ * it currently does. For the moment, it is simply a copy of the pflifecycle version.
+ */
+@ControlImplementation(isTransient=true)
+public class ContainerControlImpl
+ implements ContainerControl {
+
+ private boolean _onReleaseCalled = true;
+
+ @Context
+ private ControlBeanContext _context;
+
+ @Context
+ private ResourceContext _resourceContext;
+
+ @Context
+ private ServletContext _sc;
+
+ @Context
+ private ServletRequest _sreq;
+
+ @Context
+ private ServletResponse _sresp;
+
+ public String echo(String value) {
+ return "Echo: '" + value + "'";
+ }
+
+ public String getInfo() {
+ return "Context: " + (_sc != null) +
+ ", Response: " + (_sresp != null) +
+ ", Request: " + (_sreq != null);
+ }
+
+ @EventHandler(field = "_context", eventSet = ControlBeanContext.LifeCycle.class, eventName = "onCreate")
+ public void onCreate() {
+ checkContainerContext();
+ }
+
+ @EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onAcquire")
+ public void onAquire() {
+ checkContainerContext();
+
+ if (!_onReleaseCalled)
+ throw new IllegalStateException("onAcquire called without having called on Release on the previous request!");
+
+ _onReleaseCalled = false;
+ }
+
+ @EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onRelease")
+ public void onRelease() {
+ checkContainerContext();
+ _onReleaseCalled = true;
+ }
+
+ private void checkContainerContext() {
+ ControlContainerContext ccc = ControlThreadContext.getContext();
+ if (ccc == null)
+ throw new IllegalStateException("Control could not find a valid ControlContainerContext!");
+ if (!(ccc instanceof ServletBeanContext))
+ throw new IllegalStateException("Control container context is not a ServletBeanContext");
+
+ ServletBeanContext servletBeanContext = (ServletBeanContext)ccc;
+ if (servletBeanContext.getServletRequest() == null)
+ throw new IllegalStateException("ServletBeanContext could not provide a valid ServletRequest!");
+
+ boolean diff = (_sreq != servletBeanContext.getServletRequest());
+ if (diff && _sreq instanceof ServletRequestWrapper)
+ diff = (_sreq == ((ServletRequestWrapper) _sreq).getRequest());
+ if (diff)
+ throw new IllegalStateException("Wired Up ServletRequest doesn't match ServletBeanContext request");
+
+ if (servletBeanContext.getServletResponse() == null)
+ throw new IllegalStateException("ServletBeanContext could not provide a valid ServletResponse!");
+
+ diff = (_sresp != servletBeanContext.getServletResponse());
+ if (diff && _sresp instanceof ServletResponseWrapper)
+ diff = (_sresp == ((ServletResponseWrapper) _sresp).getResponse());
+ if (diff)
+ throw new IllegalStateException("Wired Up ServletResponse doesn't match ServletBeanContext response");
+
+ if(servletBeanContext.getServletContext() == null)
+ throw new IllegalStateException("ServletBeanContext could not provide a valid ServletContext!");
+ if (_sc == null)
+ throw new IllegalStateException("The ServletContext doesn't exist");
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/container/ContainerControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetter.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetter.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetter.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetter.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.context;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * A control interface to test control context service
+ */
+@ControlInterface
+public interface ServiceGetter {
+ public Object getService(Class theService, Object selector);
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetterImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetterImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetterImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetterImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.context;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+/**
+ * A control implementation that retrieves specific service via controlContext
+ */
+@ControlImplementation(isTransient = true)
+public class ServiceGetterImpl implements ServiceGetter {
+
+ @Context
+ ControlBeanContext context;
+
+ public Object getService(Class theService, Object selector) {
+
+ return context.getService(theService, selector);
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/context/ServiceGetterImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorder.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorder.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorder.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorder.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.contextevent;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * A control interface to test control context events.
+ * There are two sources of control context events: ControlBeanContext and
+ * ResouceContext.
+ * The implementation of this interface only listens to context events from ControlBeanContext.
+ */
+@ControlInterface
+public interface BeanContextRecorder {
+ public String getRecord();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorderImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorderImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorderImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorderImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.contextevent;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.events.EventHandler;
+
+/**
+ * A control impl that listens to and records its lifecycle events
+ * This impl listens to context event by declaring EventHandler
+ * <p/>
+ * There are two sources of control context events: ControlBeanContext and
+ * ResouceContext.
+ * This class only listens to context events from ControlBeanContext.
+ */
+
+@ControlImplementation
+public class BeanContextRecorderImpl implements BeanContextRecorder, java.io.Serializable {
+
+ private String event_log = "init";
+
+ @Context
+ ControlBeanContext context;
+
+ /**
+ * A EventHandler that listens to onCreate event
+ */
+ @EventHandler(field = "context", eventSet = ControlBeanContext.LifeCycle.class, eventName = "onCreate")
+ public void onCreate() {
+ // System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
+ // System.out.println("onCreate invoked on BeanContextRecorderImpl");
+ // System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
+
+ event_log = event_log + "onCreate";
+ }
+
+
+ /**
+ * Returns the event log
+ */
+ public String getRecord() {
+ // System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++");
+ // System.out.println("getRecord on BeanContextRecorderImpl invoked");
+ // System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++");
+
+ return event_log;
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/BeanContextRecorderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/Recorder.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/Recorder.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/Recorder.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/Recorder.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.contextevent;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * A control interface to test control context events.
+ * There are two sources of control context events: ControlBeanContext and
+ * ResouceContext.
+ * The implementation of this interface listens to context events from both sources.
+ */
+@ControlInterface
+public interface Recorder {
+ public String getRecord();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/Recorder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/RecorderImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/RecorderImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/RecorderImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/RecorderImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.contextevent;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ResourceContext;
+import org.apache.beehive.controls.api.events.EventHandler;
+
+/**
+ * A control impl that listens to and records context events
+ * This impl listens to context events by declaring EventHandler.
+ * <p/>
+ * There are two sources of control context events: ControlBeanContext and
+ * ResouceContext.
+ * This class listens to context events from both sources.
+ */
+
+@ControlImplementation
+public class RecorderImpl implements Recorder, java.io.Serializable {
+
+ private String event_log = "init";
+
+ @Context
+ ControlBeanContext context;
+ @Context
+ ResourceContext resourceContext;
+
+ /**
+ * A EventHandler that listens to onCreate event
+ */
+ @EventHandler(field = "context", eventSet = ControlBeanContext.LifeCycle.class, eventName = "onCreate")
+ public void onCreate() {
+ //System.out.println("+++++++++++++++++++++++++++++++++++++++++");
+ //System.out.println("onCreate invoked on RecorderImpl");
+ //System.out.println("++++++++++++++++++++++++++++++++++++++++++");
+
+ event_log = event_log + "onCreate";
+ }
+
+ /**
+ * A EventHandler that listens to onAcquire event
+ */
+ @EventHandler(field = "resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onAcquire")
+ public void onAcquire() {
+ //System.out.println("+++++++++++++++++++++++++++++++++++++++++");
+ //System.out.println("onAcquire invoked on RecorderImpl");
+ //System.out.println("++++++++++++++++++++++++++++++++++++++++++");
+ event_log = event_log + "onAcquire";
+ }
+
+ /**
+ * A EventHandler that listens to onRelease event
+ */
+ @EventHandler(field = "resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onRelease")
+ public void onRelease() {
+ //System.out.println("+++++++++++++++++++++++++++++++++++++++++");
+ //System.out.println("onRelease invoked on RecorderImpl");
+ //System.out.println("++++++++++++++++++++++++++++++++++++++++++");
+
+ event_log = event_log + "onRelease";
+ }
+
+ /**
+ * Returns the event log
+ */
+ public String getRecord() {
+ //System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
+ //System.out.println("getRecord method invoked on RecorderImpl");
+ //System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
+
+ return event_log;
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/contextevent/RecorderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Event2Listener.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Event2Listener.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Event2Listener.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Event2Listener.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.event;
+
+/**
+ * A listener class for Hello.EventSet2 event
+ */
+public class Event2Listener implements Hello.EventSet2 {
+ private String method1Result = "method1NotReceived";
+ private String method2Result = "set2method2NotReceived";
+ private String overloadMethod1 = "overloadMethod1NotReceived";
+ private String overloadMethod2 = "overloadMethod2NotReceived";
+
+
+ public void method1() {
+ //Event received, flip the counter
+ method1Result = "0";
+ }
+
+ public int set2Method2() {
+ //Event received, flip the counter
+ method2Result = "0";
+ return 0;
+ }
+
+ public boolean set2OverloadedMethod() {
+ //Event received, flip the counter
+ overloadMethod1 = "0";
+ return true;
+ }
+
+ public boolean set2OverloadedMethod(int anArg) {
+ //Event received, flip the counter
+ overloadMethod2 = "0";
+ return true;
+ }
+
+ public String getMethod2Result() {
+
+ return method2Result;
+ }
+
+ public String getAllResult() {
+
+ return method1Result + method2Result + overloadMethod1 + overloadMethod2;
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Event2Listener.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Hello.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Hello.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Hello.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Hello.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.event;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * A ControlInterface that declares three events
+ */
+@ControlInterface
+public interface Hello {
+
+ @EventSet
+ public interface EventSet0 {
+ }
+
+
+ @EventSet
+ public interface EventSet1 {
+ public void method1();
+ }
+
+ @EventSet(unicast = true)
+ public interface EventSet2 {
+ public void method1();
+
+ public int set2Method2();
+
+ public boolean set2OverloadedMethod();
+
+ public boolean set2OverloadedMethod(int anArg);
+ }
+
+ public void triggerEvents();
+
+ public void triggerEventsUsingHandle();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/Hello.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/HelloImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/HelloImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/HelloImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/HelloImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.event;
+
+import org.apache.beehive.controls.api.ControlException;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ControlHandle;
+import org.apache.beehive.controls.api.events.Client;
+import org.apache.beehive.controls.api.events.EventRef;
+
+/**
+ * A control implementation that raises events when the method is invoked
+ */
+@ControlImplementation
+public class HelloImpl implements Hello, java.io.Serializable {
+ @Client
+ EventSet0 eventSet0;
+ @Client
+ EventSet1 eventSet1;
+ @Client
+ EventSet2 eventSet2;
+
+ @Context
+ ControlBeanContext beanContext;
+
+ public void triggerEvents() {
+ eventSet1.method1();
+ eventSet2.method1();
+ eventSet2.set2Method2();
+ eventSet2.set2OverloadedMethod();
+ eventSet2.set2OverloadedMethod(68);
+
+ }
+
+ public void triggerEventsUsingHandle() {
+ ControlHandle handle = beanContext.getControlHandle();
+ if (handle == null)
+ throw new ControlException("No control handle for context:" + beanContext);
+
+ Object [] emptyArgs = new Object []{};
+
+ try {
+ // Create an event ref using the method descriptor string format
+ EventRef eventRef = new EventRef(EventSet1.class.getName() + ".method1()V");
+ handle.sendEvent(eventRef, emptyArgs);
+
+ // Create an event ref using Method reflection
+ eventRef = new EventRef(EventSet2.class.getMethod("method1", new Class []{}));
+ handle.sendEvent(eventRef, emptyArgs);
+
+ // Create an event ref using string descriptor, the serialize/deserialize before use
+ eventRef = new EventRef(EventSet2.class.getName() + ".set2Method2()I");
+ eventRef = SerializeUtils.testSerialize(eventRef);
+ handle.sendEvent(eventRef, emptyArgs);
+
+ // Create an event ref using Method reflection, then serialize/deserialize before use
+ eventRef = new EventRef(EventSet2.class.getMethod("set2OverloadedMethod",
+ new Class []{}));
+ eventRef = SerializeUtils.testSerialize(eventRef);
+ handle.sendEvent(eventRef, emptyArgs);
+
+ // Create an event ref using string descriptor, where arg matching is required
+ eventRef = new EventRef(EventSet2.class.getName() + ".set2OverloadedMethod(I)Z");
+ handle.sendEvent(eventRef, new Object []{68});
+ }
+ catch (Exception e) {
+ throw new ControlException("Event dispatch error", e);
+ }
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/HelloImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/SerializeUtils.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/SerializeUtils.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/SerializeUtils.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/SerializeUtils.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.event;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Utility code for testing serialization behavior
+ */
+public final class SerializeUtils {
+ /**
+ * Serializes an object into a byte array, then deserializes it from the array and returns
+ * the deserialized object.
+ */
+ public static <T extends Object> T testSerialize(T obj) {
+ byte [] serializedObject;
+ T returnObject;
+
+ ByteArrayOutputStream baos = null;
+ ObjectOutputStream oos = null;
+ try {
+ baos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.flush();
+ serializedObject = baos.toByteArray();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Error serializing object", e);
+ }
+ finally {
+ if (oos != null)
+ try {
+ oos.close();
+ }
+ catch (IOException ignore) {
+ }
+ if (baos != null)
+ try {
+ baos.close();
+ }
+ catch (IOException ignore) {
+ }
+ }
+
+ ByteArrayInputStream bais = null;
+ ObjectInputStream ois = null;
+ try {
+ bais = new ByteArrayInputStream(serializedObject);
+ ois = new ObjectInputStream(bais);
+ returnObject = (T) ois.readObject();
+ ois.close();
+ bais.close();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Error deserializing object", e);
+ }
+ finally {
+ if (bais != null)
+ try {
+ bais.close();
+ }
+ catch (IOException ignore) {
+ }
+ if (ois != null)
+ try {
+ ois.close();
+ }
+ catch (IOException ignore) {
+ }
+ }
+
+ if (!obj.equals(returnObject))
+ throw new RuntimeException("Deserialized object is not equivalent to original!");
+
+ return returnObject;
+ }
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/event/SerializeUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.extension;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A control interface with one method and one propertySet
+ */
+@ControlInterface
+public interface ExtensibleControl {
+ static final String CURRENT_POSITION = "In_ExtensibleControl_Interface";
+ static final String CURRENT_LAYER = "On_ExtensibleControl_Layer";
+
+ /* A property to be inherited by all the sub controls*/
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ public @interface Origin {
+ String Birthplace() default "ExtensibleControl";
+ }
+
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface WhereAbout {
+ String Position() default CURRENT_POSITION;
+
+ String Layer() default CURRENT_LAYER;
+ }
+
+ @EventSet
+ public interface SuperClassEvent {
+ public void method1();
+ }
+
+ public String hello();
+
+ public String getLayerByContext();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.extension;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ResourceContext;
+import org.apache.beehive.controls.api.events.EventHandler;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+/**
+ * A control impl.
+ * By implementing Extensible, this impl makes itself extensible
+ */
+
+@ControlImplementation
+public class ExtensibleControlImpl implements ExtensibleControl, Extensible, Serializable {
+ @Context
+ ControlBeanContext context;
+
+ @Context
+ ResourceContext resourceContext;
+
+ @EventHandler(field = "resourceContext",
+ eventSet = ResourceContext.ResourceEvents.class,
+ eventName = "onAcquire")
+ public void onAcquire() {
+ System.out.println("ExtensibleControlImpl.onAcquire()");
+ }
+
+ @EventHandler(field = "resourceContext",
+ eventSet = ResourceContext.ResourceEvents.class,
+ eventName = "onRelease")
+ public void onRelease() {
+ System.out.println("ExtensibleControlImpl.onRelease()");
+ }
+
+ public String hello() {
+ return "Hello from super control";
+ }
+
+ public String getLayerByContext() {
+ /**BUG: could not refer to Greeting directly*/
+ WhereAbout whereabout = context.getControlPropertySet(WhereAbout.class);
+
+ return whereabout.Layer();
+ }
+
+ public Object invoke(Method m, Object[] args) throws Throwable {
+ return null;
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/ExtensibleControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.extension;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A sub control extending ExtensibleControl.
+ * This control declares one new method and one new propertySet.
+ * It also resets the value of the propertySet inherited from ExtensibleControl.
+ */
+//@ControlExtension ::JIRA-118 and JIRA-197
+@ControlInterface
+@ExtensibleControl.WhereAbout(Layer = "On_SubControl_Interface_Layer")
+public interface SubControl extends ExtensibleControl {
+
+ static final String A_MESSAGE = "New Property Declared by Sub Control";
+
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface NewProperty {
+ String Message() default A_MESSAGE;
+ }
+
+ @EventSet
+ public interface SubClassEvent {
+ public void method1();
+ }
+
+ public String hello2();
+
+ public String accessInheritedProperty();
+
+ public String getAnnotatedInheritedPropertyByContext();
+
+ public String getExtendedPropertyByContext();
+
+ public int invokeInheritedEventFromSubControl();
+
+ public int invokeExtendedEventFromSubControl();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.extension;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.events.Client;
+
+/**
+ * A control impl of a SubControl and extending ExtensibleControlImpl.
+ * It accesses the propertySets inherited from ExtensibleControl, and extended by
+ * its own interface.
+ */
+@ControlImplementation
+public class SubControlImpl extends ExtensibleControlImpl
+ implements SubControl, java.io.Serializable {
+ @Context
+ ControlBeanContext context;
+
+ @Client
+ SuperClassEvent superevent;
+ @Client
+ SubClassEvent subevent;
+
+ public String hello2() {
+ return "Hello from _subcontrol";
+ }
+
+ /*Accessing the propertySet inherited from ExtensibleControl*/
+ public String accessInheritedProperty() {
+ /**Bug: could not refer to WhereAbout directly*/
+ WhereAbout where = context.getControlPropertySet(WhereAbout.class);
+
+ return where.Position();
+ }
+
+ public String getAnnotatedInheritedPropertyByContext() {
+ Origin origin = context.getControlPropertySet(Origin.class);
+ return origin.Birthplace();
+ }
+
+ public String getExtendedPropertyByContext() {
+
+ NewProperty newproperty = context.getControlPropertySet(NewProperty.class);
+
+ return newproperty.Message();
+ }
+
+ public int invokeInheritedEventFromSubControl() {
+
+ superevent.method1();
+ return 0;
+ }
+
+ public int invokeExtendedEventFromSubControl() {
+
+ subevent.method1();
+ return 0;
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/extension/SubControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SingleProperty.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SingleProperty.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SingleProperty.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SingleProperty.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.instantiate;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A control interface with three single-member propertySets and one method
+ */
+@ControlInterface
+public interface SingleProperty {
+ static final String GREET_DEFAULT = "Hello";
+
+ /**
+ * A single member property with default value
+ */
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Greeting {
+ public String GreetWord() default GREET_DEFAULT;
+ }
+
+ /**
+ * A single member property without default value
+ */
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Identity {
+ public String name();
+ }
+
+ /**
+ * A single member property of primitive types
+ */
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Identifier {
+ public int age() default 20;
+ }
+
+
+ public String sayHello();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SingleProperty.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SinglePropertyImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SinglePropertyImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SinglePropertyImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SinglePropertyImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.instantiate;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+/**
+ * A control impl that accesses the property declared by its control interface via control context
+ */
+
+@ControlImplementation(isTransient = true)
+public class SinglePropertyImpl implements SingleProperty {
+ @Context
+ ControlBeanContext context;
+
+ /*Accesses the propertySet value and returns the value*/
+ public String sayHello() {
+ /**BUG: could not refer to Greeting directly*/
+ Greeting greeting = context.getControlPropertySet(Greeting.class);
+ return greeting.GreetWord();
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/instantiate/SinglePropertyImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundExtPropertySet.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundExtPropertySet.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundExtPropertySet.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundExtPropertySet.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.property;
+
+import org.apache.beehive.controls.api.packaging.PropertyInfo;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An externally defined property set.
+ */
+@PropertySet
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
+public @interface BoundExtPropertySet {
+ public static final int AGE_DEFAULT = 5;
+
+ @PropertyInfo(bound = true)
+ public int age() default AGE_DEFAULT;
+
+ @PropertyInfo(constrained = true)
+ public float height() default 0.0f;
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundExtPropertySet.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.property;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.bean.ExternalPropertySets;
+import org.apache.beehive.controls.api.packaging.PropertyInfo;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A control interface with bound and/or constrain propertySet
+ */
+@ControlInterface
+@ExternalPropertySets({BoundExtPropertySet.class})
+public interface BoundPropertyControl {
+ static final String BRAND_DEFAULT = "DEFAULT_BRAND";
+ static final String MATERIAL_DEFAULT = "DEFAULT_MATERIAL";
+ static final String QUALITY_DEFAULT = "DEFAULT_QUALITY";
+
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Wheel {
+ @PropertyInfo(bound = true)
+ public String Brand() default BRAND_DEFAULT;
+ }
+
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Door {
+ @PropertyInfo(constrained = true)
+ public String Material() default MATERIAL_DEFAULT;
+ }
+
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Window {
+ @PropertyInfo(bound = true, constrained = true)
+ public String Quality() default QUALITY_DEFAULT;
+ }
+
+ public String sayHello();
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.property;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+/**
+ * A control impl that accesses the property declared by its control interface via control context
+ */
+
+@ControlImplementation(isTransient = true)
+public class BoundPropertyControlImpl implements BoundPropertyControl {
+
+ @Context
+ ControlBeanContext context;
+
+ /**
+ * Accesses the propertySet value and returns the value
+ */
+ public String sayHello() {
+ /**BUG: could not refer to Greeting directly*/
+ //Greeting greeting=(SingleProperty.Greeting)context.getControlPropertySet(SingleProperty.Greeting.class);
+
+ //return greeting.GreetWord();
+ return "Hello";
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/BoundPropertyControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.property;
+
+import org.apache.beehive.controls.api.bean.AnnotationMemberTypes;
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@ControlInterface
+public interface PropertyConstraintControl {
+
+ @PropertySet
+ @Target({ElementType.FIELD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Person {
+ @AnnotationMemberTypes.Text(maxLength = 8)
+ public String name() default "";
+
+ @AnnotationMemberTypes.Date(minValue = "1900/1/1")
+ public String dob() default "";
+
+ @AnnotationMemberTypes.Int(minValue = 0, maxValue = 130)
+ public int age() default AnnotationMemberTypes.OPTIONAL_INT;
+ }
+
+ public String hello();
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControlImpl.java?rev=422018&view=auto
==============================================================================
--- beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControlImpl.java (added)
+++ beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControlImpl.java Fri Jul 14 13:22:22 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.netui.test.controls.property;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+@ControlImplementation(isTransient = true)
+public class PropertyConstraintControlImpl implements PropertyConstraintControl {
+ @Context
+ ControlBeanContext ctx;
+
+ public String hello() {
+ Person person = ctx.getControlPropertySet(Person.class);
+ return "Hello " + person.name();
+ }
+
+}
Propchange: beehive/trunk/netui/test/webapps/controls/src/org/apache/beehive/netui/test/controls/property/PropertyConstraintControlImpl.java
------------------------------------------------------------------------------
svn:eol-style = native