Author: david.lloyd(a)jboss.com
Date: 2008-03-31 18:01:24 -0400 (Mon, 31 Mar 2008)
New Revision: 3815
Added:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/beans/
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/beans/SessionBean.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaData.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaDataAttribute.java
Modified:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/EndpointMetaData.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/RemotingMetaData.java
Log:
Session bean - not the session beans you are thinking of though
Added:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/beans/SessionBean.java
===================================================================
---
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/beans/SessionBean.java
(rev 0)
+++
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/beans/SessionBean.java 2008-03-31
22:01:24 UTC (rev 3815)
@@ -0,0 +1,60 @@
+package org.jboss.cx.remoting.beans;
+
+import java.net.URI;
+import org.jboss.cx.remoting.util.AttributeMap;
+import org.jboss.cx.remoting.Endpoint;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.Session;
+
+/**
+ *
+ */
+public final class SessionBean {
+ private URI destination;
+ private AttributeMap attributeMap;
+ private Endpoint endpoint;
+
+ public URI getDestination() {
+ return destination;
+ }
+
+ public void setDestination(final URI destination) {
+ this.destination = destination;
+ }
+
+ public AttributeMap getAttributeMap() {
+ return attributeMap;
+ }
+
+ public void setAttributeMap(final AttributeMap attributeMap) {
+ this.attributeMap = attributeMap;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(final Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ // lifecycle
+
+ private Session session;
+
+ public void create() {
+
+ }
+
+ public void start() throws RemotingException {
+ session = endpoint.openSession(destination, attributeMap);
+ }
+
+ public void stop() throws RemotingException {
+ session.close();
+ }
+
+ public void destroy() {
+
+ }
+}
Modified:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/EndpointMetaData.java
===================================================================
---
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/EndpointMetaData.java 2008-03-31
22:00:46 UTC (rev 3814)
+++
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/EndpointMetaData.java 2008-03-31
22:01:24 UTC (rev 3815)
@@ -2,7 +2,6 @@
import java.io.Serializable;
import java.util.List;
-import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
@@ -12,7 +11,9 @@
import javax.xml.bind.annotation.XmlType;
/**
+ * Metadata that describes the creation of a Remoting endpoint.
*
+ * @see org.jboss.cx.remoting.Endpoint
*/
@XmlType(name = "endpoint")
public class EndpointMetaData implements BeanMetaDataFactory, Serializable {
@@ -22,56 +23,111 @@
private String executorName;
private String rootRequestListenerName;
+ /**
+ * Get the name of the endpoint to be created.
+ *
+ * @return the name
+ */
public String getName() {
return name;
}
+ /**
+ * Set the name of the endpoint to be created.
+ *
+ * @param name
+ */
@XmlAttribute
public void setName(final String name) {
this.name = name;
}
+ /**
+ * Get the name of the executor to use. The name should be associated with a bean
that implements
+ * {@link java.util.concurrent.Executor}.
+ *
+ * @return the name
+ */
public String getExecutorName() {
return executorName;
}
+ /**
+ * Set the name of the executor to use. The name should be associated with a bean
that implements
+ * {@link java.util.concurrent.Executor}.
+ *
+ * @param executorName the name
+ */
@XmlAttribute(name = "executor")
public void setExecutorName(final String executorName) {
this.executorName = executorName;
}
+ /**
+ * Get the name of the root request listener bean for this endpoint. The name should
be associated with a bean
+ * that implements {@link org.jboss.cx.remoting.RequestListener}.
+ *
+ * @return the name of root request listener bean
+ */
public String getRootRequestListenerName() {
return rootRequestListenerName;
}
+ /**
+ * Set the name of the root request listener bean for this endpoint. The name should
be associated with a bean
+ * that implements {@link org.jboss.cx.remoting.RequestListener}.
+ *
+ * @param rootRequestListenerName the name of the root request listener bean
+ */
@XmlAttribute(name = "rootRequestListener")
public void setRootRequestListenerName(final String rootRequestListenerName) {
this.rootRequestListenerName = rootRequestListenerName;
}
+ /**
+ * Create a duplicate of this metadata object.
+ *
+ * @return a duplicate
+ */
public EndpointMetaData clone() throws CloneNotSupportedException {
return (EndpointMetaData) super.clone();
}
+ /**
+ * Get all the metadata objects required to deploy an endpoint.
+ *
+ * @return the metadata objects
+ */
public List<BeanMetaData> getBeans() {
final String userEndpointName = "Endpoint:" + name;
final String coreEndpointName = "CoreEndpoint:" + name;
final String jrppProtocolSupportName = "JrppProtocolSupport:" + name;
- BeanMetaDataBuilder builder;
- builder = BeanMetaDataBuilder.createBuilder(coreEndpointName);
+ final BeanMetaData coreEndpointMetaData =
buildCoreEndpointMetaData(coreEndpointName);
+ final BeanMetaData endpointMetaData = buildEndpointMetaData(userEndpointName,
coreEndpointName);
+ final BeanMetaData jrppSupportMetaData =
buildJrppProtocolSupportMetaData(userEndpointName, jrppProtocolSupportName);
+
+ return CollectionUtil.unmodifiableList(coreEndpointMetaData, endpointMetaData,
jrppSupportMetaData);
+ }
+
+ private BeanMetaData buildCoreEndpointMetaData(final String coreEndpointName) {
+ final BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(coreEndpointName);
builder.addConstructorParameter("java.lang.String", name);
builder.addConstructorParameter("org.jboss.cx.remoting.RequestListener",
builder.createInject(rootRequestListenerName));
builder.addPropertyMetaData("executor",
builder.createInject(executorName));
- final BeanMetaData coreEndpointMetaData = builder.getBeanMetaData();
- builder = BeanMetaDataBuilder.createBuilder(userEndpointName);
+ return builder.getBeanMetaData();
+ }
+
+ private BeanMetaData buildEndpointMetaData(final String userEndpointName, final
String coreEndpointName) {
+ final BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(userEndpointName);
builder.setFactory(coreEndpointName, "userEndpoint");
- final BeanMetaData endpointMetaData = builder.getBeanMetaData();
- builder = BeanMetaDataBuilder.createBuilder(jrppProtocolSupportName);
+ return builder.getBeanMetaData();
+ }
+
+ private BeanMetaData buildJrppProtocolSupportMetaData(final String userEndpointName,
final String jrppProtocolSupportName) {
+ final BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(jrppProtocolSupportName);
builder.addPropertyMetaData("executor",
builder.createInject(executorName));
builder.addPropertyMetaData("endpoint",
builder.createInject(userEndpointName));
- final BeanMetaData jrppSupportMetaData = builder.getBeanMetaData();
-
- return CollectionUtil.unmodifiableList(coreEndpointMetaData, endpointMetaData,
jrppSupportMetaData);
+ return builder.getBeanMetaData();
}
}
Modified:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/RemotingMetaData.java
===================================================================
---
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/RemotingMetaData.java 2008-03-31
22:00:46 UTC (rev 3814)
+++
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/RemotingMetaData.java 2008-03-31
22:01:24 UTC (rev 3815)
@@ -15,7 +15,8 @@
import javax.xml.bind.annotation.XmlType;
/**
- *
+ * Metadata which describes a Remoting deployment. This class is intended for the
parsing of
+ * {@code jboss-remoting.xml} descriptors.
*/
@JBossXmlSchema (namespace = "urn:jboss:remoting:3.0", elementFormDefault =
XmlNsForm.QUALIFIED)
@XmlRootElement (name = "remoting")
@@ -24,6 +25,7 @@
private static final long serialVersionUID = 1L;
private List<EndpointMetaData> endpoints;
+ private List<SessionMetaData> sessions;
/**
* Get the list of nested endpoints as metadata.
@@ -44,20 +46,55 @@
this.endpoints = endpoints;
}
+ /**
+ * Get the list of nested sessions as metadata.
+ *
+ * @return the session metadata list
+ */
+ public List<SessionMetaData> getSessions() {
+ return sessions;
+ }
+
+ /**
+ * Set the list of nested sessions as metadata.
+ *
+ * @param sessions the session metadata list
+ */
+ @XmlElement(name = "session")
+ public void setSessions(final List<SessionMetaData> sessions) {
+ this.sessions = sessions;
+ }
+
+ /**
+ * Create a duplicate of this object.
+ *
+ * @return a duplicate of this object
+ */
public RemotingMetaData clone() throws CloneNotSupportedException {
final RemotingMetaData metaData = (RemotingMetaData) super.clone();
metaData.endpoints = new ArrayList<EndpointMetaData>();
for (EndpointMetaData endpointMetaData : endpoints) {
metaData.endpoints.add(endpointMetaData.clone());
}
+ for (SessionMetaData sessionMetaData : sessions) {
+ metaData.sessions.add(sessionMetaData.clone());
+ }
return metaData;
}
+ /**
+ * Get the metadata items that this deployment produces.
+ *
+ * @return the list of metadata items
+ */
public List<BeanMetaData> getBeans() {
final List<BeanMetaData> metaDataList = CollectionUtil.arrayList();
for (EndpointMetaData endpointMetaData : endpoints) {
metaDataList.addAll(endpointMetaData.getBeans());
}
+ for (SessionMetaData sessionMetaData : sessions) {
+ metaDataList.addAll(sessionMetaData.getBeans());
+ }
return Collections.unmodifiableList(metaDataList);
}
}
Added:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaData.java
===================================================================
---
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaData.java
(rev 0)
+++
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaData.java 2008-03-31
22:01:24 UTC (rev 3815)
@@ -0,0 +1,103 @@
+package org.jboss.cx.remoting.metadata;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.cx.remoting.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeHashMap;
+import org.jboss.cx.remoting.util.AttributeKey;
+import org.jboss.cx.remoting.util.CollectionUtil;
+import org.jboss.cx.remoting.CommonKeys;
+import java.io.Serializable;
+import java.util.List;
+import java.net.URI;
+import java.lang.reflect.Field;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * Metadata which describes a session to be established and maintained with another
endpoint.
+ */
+@XmlType(namespace = "urn:jboss:remoting:3.0", name = "session")
+public final class SessionMetaData implements BeanMetaDataFactory, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String endpoint;
+ private URI destination;
+ private List<SessionMetaDataAttribute> attributeList;
+
+ public String getName() {
+ return name;
+ }
+
+ @XmlAttribute(required = true)
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ @XmlAttribute(required = true)
+ public void setEndpoint(final String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public URI getDestination() {
+ return destination;
+ }
+
+ @XmlAttribute(required = true)
+ public void setDestination(final URI destination) {
+ this.destination = destination;
+ }
+
+ public List<SessionMetaDataAttribute> getAttributeList() {
+ return attributeList;
+ }
+
+ @XmlElement(name = "attribute")
+ public void setAttributeList(final List<SessionMetaDataAttribute>
attributeList) {
+ this.attributeList = attributeList;
+ }
+
+ public SessionMetaData clone() throws CloneNotSupportedException {
+ return (SessionMetaData) super.clone();
+ }
+
+ public List<BeanMetaData> getBeans() {
+ return CollectionUtil.unmodifiableList(createSessionMetaData());
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private static <T> void putAttribute(AttributeMap attributeMap,
AttributeKey<T> key, Object value) {
+ attributeMap.put(key, (T) value);
+ }
+
+ private BeanMetaData createSessionMetaData() {
+ final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name);
+ builder.addPropertyMetaData("endpoint",
builder.createInject(endpoint));
+ builder.addPropertyMetaData("destination", destination);
+ final AttributeMap attributeMap = new AttributeHashMap();
+ try {
+ for (SessionMetaDataAttribute attribute : attributeList) {
+ Class<?> claxx = attribute.getClaxx();
+ if (claxx == null) {
+ claxx = CommonKeys.class;
+ }
+ final String fieldName = attribute.getName();
+ final Field field = claxx.getDeclaredField(fieldName);
+ final AttributeKey<?> keyInstance = (AttributeKey<?>)
field.get(null);
+ putAttribute(attributeMap, keyInstance, attribute.getValue());
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Error reading field", e);
+ }
+ builder.addPropertyMetaData("attributeMap", attributeMap);
+ return builder.getBeanMetaData();
+ }
+}
Added:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaDataAttribute.java
===================================================================
---
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaDataAttribute.java
(rev 0)
+++
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/metadata/SessionMetaDataAttribute.java 2008-03-31
22:01:24 UTC (rev 3815)
@@ -0,0 +1,44 @@
+package org.jboss.cx.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ *
+ */
+@XmlType(namespace = "urn:jboss:remoting:3.0", name = "attribute")
+public final class SessionMetaDataAttribute {
+ private Class<?> claxx;
+ private String name;
+ private Object value;
+
+ public Class<?> getClaxx() {
+ return claxx;
+ }
+
+ @XmlAttribute(name = "class")
+ public void setClaxx(final Class<?> claxx) {
+ this.claxx = claxx;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @XmlAttribute(name = "name", required = true)
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ @XmlAnyElement
+ public void setValue(final Object value) {
+ this.value = value;
+ }
+}