[jboss-remoting-commits] JBoss Remoting SVN: r4799 - in remoting-mc-int/trunk/metadata/src/main: resources/META-INF and 1 other directory.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Jan 9 19:26:03 EST 2009


Author: david.lloyd at jboss.com
Date: 2009-01-09 19:26:03 -0500 (Fri, 09 Jan 2009)
New Revision: 4799

Added:
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientMetaData.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientSourceMetaData.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocalServiceMetaData.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocateServiceMetaData.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemoteServiceMetaData.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingHelper.java
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ServiceListenerMetaData.java
   remoting-mc-int/trunk/metadata/src/main/resources/META-INF/jboss-remoting_3_0.xsd
Removed:
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java
Modified:
   remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java
Log:
Get metadata together

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+ at XmlType(name = "client")
+public final class ClientMetaData {
+    private String name;
+    private String serviceBean;
+    private String requestClassName;
+    private String replyClassName;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getServiceBean() {
+        return serviceBean;
+    }
+
+    @XmlAttribute(name = "service-bean", required = true)
+    public void setServiceBean(final String serviceBean) {
+        this.serviceBean = serviceBean;
+    }
+
+    public String getRequestClassName() {
+        return requestClassName;
+    }
+
+    @XmlAttribute(name = "request-class-name")
+    public void setRequestClassName(final String requestClassName) {
+        this.requestClassName = requestClassName;
+    }
+
+    public String getReplyClassName() {
+        return replyClassName;
+    }
+
+    @XmlAttribute(name = "reply-class-name")
+    public void setReplyClassName(final String replyClassName) {
+        this.replyClassName = replyClassName;
+    }
+}

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientSourceMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientSourceMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ClientSourceMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ */
+ at XmlType(name = "client-source")
+public final class ClientSourceMetaData {
+    private String name;
+    private String serviceBean;
+    private String requestClassName;
+    private String replyClassName;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getServiceBean() {
+        return serviceBean;
+    }
+
+    @XmlAttribute(name = "service-bean", required = true)
+    public void setServiceBean(final String serviceBean) {
+        this.serviceBean = serviceBean;
+    }
+
+    public String getRequestClassName() {
+        return requestClassName;
+    }
+
+    @XmlAttribute(name = "request-class-name")
+    public void setRequestClassName(final String requestClassName) {
+        this.requestClassName = requestClassName;
+    }
+
+    public String getReplyClassName() {
+        return replyClassName;
+    }
+
+    @XmlAttribute(name = "reply-class-name")
+    public void setReplyClassName(final String replyClassName) {
+        this.replyClassName = replyClassName;
+    }
+
+}

Deleted: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java	2009-01-09 20:50:24 UTC (rev 4798)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -1,135 +0,0 @@
-package org.jboss.remoting.metadata;
-
-import java.io.Serializable;
-import java.util.List;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.remoting.core.util.CollectionUtil;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * Metadata that describes the creation of a Remoting endpoint.
- *
- * @see org.jboss.remoting.Endpoint
- */
- at XmlType(name = "endpoint")
-public class EndpointMetaData implements BeanMetaDataFactory, Serializable {
-    private static final long serialVersionUID = 1L;
-
-    private String name;
-    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.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.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
-     */
-    @XmlTransient
-    public List<BeanMetaData> getBeans() {
-        final String userEndpointName = "Endpoint:" + name;
-        final String coreEndpointName = "CoreEndpoint:" + name;
-        final String jrppProtocolSupportName = "JrppProtocolSupport:" + name;
-
-        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.remoting.RequestListener", builder.createInject(rootRequestListenerName));
-        builder.addPropertyMetaData("executor", builder.createInject(executorName));
-        return builder.getBeanMetaData();
-    }
-
-    private BeanMetaData buildEndpointMetaData(final String userEndpointName, final String coreEndpointName) {
-        final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(userEndpointName);
-        builder.setFactory(coreEndpointName, "userEndpoint");
-        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));
-        return builder.getBeanMetaData();
-    }
-}

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocalServiceMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocalServiceMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocalServiceMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+ at XmlType(name = "service")
+public final class LocalServiceMetaData implements Cloneable {
+
+    private String name;
+    private String requestListenerClass;
+    private String requestClassName;
+    private String replyClassName;
+    private String serviceType;
+    private String groupName;
+    private int metric;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getRequestListenerClass() {
+        return requestListenerClass;
+    }
+
+    @XmlAttribute(name = "request-listener-class")
+    public void setRequestListenerClass(final String requestListenerClass) {
+        this.requestListenerClass = requestListenerClass;
+    }
+
+    public String getRequestClassName() {
+        return requestClassName;
+    }
+
+    @XmlAttribute(name = "request-class")
+    public void setRequestClassName(final String requestClassName) {
+        this.requestClassName = requestClassName;
+    }
+
+    public String getReplyClassName() {
+        return replyClassName;
+    }
+
+    @XmlAttribute(name = "reply-class")
+    public void setReplyClassName(final String replyClassName) {
+        this.replyClassName = replyClassName;
+    }
+
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    @XmlAttribute(name = "service-type", required = true)
+    public void setServiceType(final String serviceType) {
+        this.serviceType = serviceType;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    @XmlAttribute(name = "group-name")
+    public void setGroupName(final String groupName) {
+        this.groupName = groupName;
+    }
+
+    public int getMetric() {
+        return metric;
+    }
+
+    @XmlAttribute(name = "metric")
+    public void setMetric(final int metric) {
+        this.metric = metric;
+    }
+
+    protected LocalServiceMetaData clone() throws CloneNotSupportedException {
+        return (LocalServiceMetaData) super.clone();
+    }
+}

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocateServiceMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocateServiceMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/LocateServiceMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+ at XmlType(name = "locate-service")
+public final class LocateServiceMetaData {
+    private String name;
+    private String uri;
+    private String requestClassName;
+    private String replyClassName;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    @XmlAttribute(required = true)
+    public void setUri(final String uri) {
+        this.uri = uri;
+    }
+
+    public String getRequestClassName() {
+        return requestClassName;
+    }
+
+    @XmlAttribute(name = "request-class-name")
+    public void setRequestClassName(final String requestClassName) {
+        this.requestClassName = requestClassName;
+    }
+
+    public String getReplyClassName() {
+        return replyClassName;
+    }
+
+    @XmlAttribute(name = "reply-class-name")
+    public void setReplyClassName(final String replyClassName) {
+        this.replyClassName = replyClassName;
+    }
+}

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemoteServiceMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemoteServiceMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemoteServiceMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+ at XmlType(name = "remote-service")
+public final class RemoteServiceMetaData {
+    private String name;
+    private String serviceType;
+    private String groupName;
+    private String endpointName;
+    private String requestHandlerSourceBean;
+    private int metric;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    @XmlAttribute(name = "service-type", required = true)
+    public void setServiceType(final String serviceType) {
+        this.serviceType = serviceType;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    @XmlAttribute(name = "group-name", required = true)
+    public void setGroupName(final String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String getEndpointName() {
+        return endpointName;
+    }
+
+    @XmlAttribute(name = "endpoint-name", required = true)
+    public void setEndpointName(final String endpointName) {
+        this.endpointName = endpointName;
+    }
+
+    public String getRequestHandlerSourceBean() {
+        return requestHandlerSourceBean;
+    }
+
+    @XmlAttribute(name = "request-handler-source-bean", required = true)
+    public void setRequestHandlerSourceBean(final String requestHandlerSourceBean) {
+        this.requestHandlerSourceBean = requestHandlerSourceBean;
+    }
+
+    public int getMetric() {
+        return metric;
+    }
+
+    @XmlAttribute
+    public void setMetric(final int metric) {
+        this.metric = metric;
+    }
+}

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingHelper.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingHelper.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingHelper.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.Endpoint;
+import org.jboss.remoting.RequestListener;
+import org.jboss.remoting.LocalServiceConfiguration;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.SimpleCloseable;
+import org.jboss.remoting.RemoteServiceConfiguration;
+import org.jboss.xnio.IoUtils;
+import java.io.IOException;
+
+/**
+ *
+ */
+public final class RemotingHelper {
+    private RemotingHelper() {}
+
+    @SuppressWarnings({ "unchecked" })
+    public static <I, O> Handle<RequestHandlerSource> registerService(final Endpoint endpoint, final Class<I> requestClass, final Class<O> replyClass, final Class<? extends RequestListener> listenerClass, final String serviceType, final String groupName, final int metric) throws IOException, IllegalAccessException, InstantiationException {
+        final RequestListener<I, O> listener = (RequestListener<I, O>) listenerClass.newInstance();
+        final LocalServiceConfiguration<I, O> config = new LocalServiceConfiguration<I, O>(listener, requestClass, replyClass);
+        config.setGroupName(groupName);
+        config.setServiceType(serviceType);
+        config.setMetric(metric);
+        return endpoint.registerService(config);
+    }
+
+    public static <I, O> Client<I, O> createClient(final Endpoint endpoint, final RequestHandlerSource handlerSource, final Class<I> requestClass, final Class<O> replyClass) throws IOException {
+        final Handle<RequestHandler> handle = handlerSource.createRequestHandler();
+        try {
+            return endpoint.createClient(handle.getResource(), requestClass, replyClass);
+        } finally {
+            IoUtils.safeClose(handle);
+        }
+    }
+
+    public static SimpleCloseable registerRemoteService(final Endpoint endpoint, final String serviceType, final String groupName, final String endpointName, final RequestHandlerSource requestHandlerSource, final int metric) throws IOException {
+        final RemoteServiceConfiguration config = new RemoteServiceConfiguration();
+        config.setServiceType(serviceType);
+        config.setGroupName(groupName);
+        config.setEndpointName(endpointName);
+        config.setRequestHandlerSource(requestHandlerSource);
+        config.setMetric(metric);
+        return endpoint.registerRemoteService(config);
+    }
+}

Modified: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java	2009-01-09 20:50:24 UTC (rev 4798)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -6,7 +6,12 @@
 import java.util.List;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.api.annotations.Inject;
 import org.jboss.remoting.core.util.CollectionUtil;
+import org.jboss.remoting.Endpoint;
+import org.jboss.remoting.ServiceListener;
+import org.jboss.remoting.spi.RequestHandlerSource;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 import javax.xml.bind.annotation.XmlElement;
@@ -14,6 +19,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
 
 /**
  * Metadata which describes a Remoting deployment.  This class is intended for the parsing of
@@ -25,27 +31,77 @@
 public class RemotingMetaData implements BeanMetaDataFactory, Serializable {
     private static final long serialVersionUID = 1L;
 
-    private List<EndpointMetaData> endpoints;
+    private String endpoint;
+    private List<LocalServiceMetaData> localServices;
+    private List<RemoteServiceMetaData> remoteServices;
+    private List<ClientMetaData> clients;
+    private List<ClientSourceMetaData> clientSources;
+    private List<ServiceListenerMetaData> serviceListeners;
+    private ClassLoader classLoader;
 
-    /**
-     * Get the list of nested endpoints as metadata.
-     *
-     * @return the endpoint metadata list
-     */
-    public List<EndpointMetaData> getEndpoints() {
-        return endpoints;
+    public String getEndpoint() {
+        return endpoint;
     }
 
-    /**
-     * Set the list of nested endpoint metadata.
-     *
-     * @param endpoints the endpoint metadata list
-     */
-    @XmlElement(name = "endpoint")
-    public void setEndpoints(final List<EndpointMetaData> endpoints) {
-        this.endpoints = endpoints;
+    @XmlAttribute(name = "endpoint")
+    public void setEndpoint(final String endpoint) {
+        this.endpoint = endpoint;
     }
 
+    public List<LocalServiceMetaData> getLocalServices() {
+        return localServices;
+    }
+
+    @XmlElement(name = "local-service")
+    public void setLocalServices(final List<LocalServiceMetaData> localServices) {
+        this.localServices = localServices;
+    }
+
+    public List<RemoteServiceMetaData> getRemoteServices() {
+        return remoteServices;
+    }
+
+    @XmlElement(name = "remote-service")
+    public void setRemoteServices(final List<RemoteServiceMetaData> remoteServices) {
+        this.remoteServices = remoteServices;
+    }
+
+    public List<ClientMetaData> getClients() {
+        return clients;
+    }
+
+    @XmlElement(name = "client")
+    public void setClients(final List<ClientMetaData> clients) {
+        this.clients = clients;
+    }
+
+    public List<ClientSourceMetaData> getClientSources() {
+        return clientSources;
+    }
+
+    @XmlElement(name = "client-source")
+    public void setClientSources(final List<ClientSourceMetaData> clientSources) {
+        this.clientSources = clientSources;
+    }
+
+    public List<ServiceListenerMetaData> getServiceListeners() {
+        return serviceListeners;
+    }
+
+    @XmlElement(name = "service-listener")
+    public void setServiceListeners(final List<ServiceListenerMetaData> serviceListeners) {
+        this.serviceListeners = serviceListeners;
+    }
+
+    public ClassLoader getClassLoader() {
+        return classLoader;
+    }
+
+    @Inject
+    public void setClassLoader(final ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
     /**
      * Create a duplicate of this object.
      *
@@ -53,9 +109,9 @@
      */
     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());
+        metaData.localServices = new ArrayList<LocalServiceMetaData>(localServices.size());
+        for (LocalServiceMetaData localService : localServices) {
+            metaData.localServices.add(localService.clone());
         }
         return metaData;
     }
@@ -67,10 +123,74 @@
      */
     @XmlTransient
     public List<BeanMetaData> getBeans() {
-        final List<BeanMetaData> metaDataList = CollectionUtil.arrayList();
-        for (EndpointMetaData endpointMetaData : endpoints) {
-            metaDataList.addAll(endpointMetaData.getBeans());
+        try {
+            final ClassLoader classLoader = getClassLoader();
+            final String endpoint = this.endpoint == null ? "default-remoting-endpoint" : this.endpoint;
+            final List<BeanMetaData> metaDataList = CollectionUtil.arrayList();
+            for (LocalServiceMetaData localService : localServices) {
+                BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(localService.getName());
+                builder.setFactoryClass(RemotingHelper.class.getName());
+                builder.setFactoryMethod("registerService");
+                builder.addConstructorParameter(Endpoint.class.getName(), builder.createInject(endpoint));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(localService.getRequestClassName(), classLoader));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(localService.getReplyClassName(), classLoader));
+                builder.addConstructorParameter(Class.class.getName(), Class.forName(localService.getRequestListenerClass(), false, classLoader));
+                builder.addConstructorParameter(String.class.getName(), localService.getServiceType());
+                builder.addConstructorParameter(String.class.getName(), localService.getGroupName());
+                builder.addConstructorParameter(int.class.getName(), Integer.valueOf(localService.getMetric()));
+                builder.setStop("close");
+                metaDataList.add(builder.getBeanMetaData());
+            }
+            for (ClientMetaData client : clients) {
+                BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(client.getName());
+                builder.setFactoryClass(RemotingHelper.class.getName());
+                builder.setFactoryMethod("createClient");
+                builder.addConstructorParameter(Endpoint.class.getName(), builder.createInject(endpoint));
+                builder.addConstructorParameter(RequestHandlerSource.class.getName(), builder.createInject(client.getServiceBean()));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(client.getRequestClassName(), classLoader));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(client.getReplyClassName(), classLoader));
+                builder.setStop("close");
+                metaDataList.add(builder.getBeanMetaData());
+            }
+            for (ClientSourceMetaData clientSource : clientSources) {
+                BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(clientSource.getName());
+                builder.setFactory(builder.createInject(endpoint));
+                builder.setFactoryMethod("createClientSource");
+                builder.addConstructorParameter(RequestHandlerSource.class.getName(), builder.createInject(clientSource.getServiceBean()));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(clientSource.getRequestClassName(), classLoader));
+                builder.addConstructorParameter(Class.class.getName(), getOptionalClass(clientSource.getReplyClassName(), classLoader));
+                builder.setStop("close");
+                metaDataList.add(builder.getBeanMetaData());
+            }
+            for (RemoteServiceMetaData remoteService : remoteServices) {
+                BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(remoteService.getName());
+                builder.setFactoryClass(RemotingHelper.class.getName());
+                builder.setFactoryMethod("registerRemoteService");
+                builder.addConstructorParameter(Endpoint.class.getName(), builder.createInject(endpoint));
+                builder.addConstructorParameter(String.class.getName(), remoteService.getServiceType());
+                builder.addConstructorParameter(String.class.getName(), remoteService.getGroupName());
+                builder.addConstructorParameter(String.class.getName(), remoteService.getEndpointName());
+                builder.addConstructorParameter(RequestHandlerSource.class.getName(), builder.createInject(remoteService.getRequestHandlerSourceBean()));
+                builder.addConstructorParameter(int.class.getName(), Integer.valueOf(remoteService.getMetric()));
+                builder.setStop("close");
+                metaDataList.add(builder.getBeanMetaData());
+            }
+            for (ServiceListenerMetaData serviceListener : serviceListeners) {
+                BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(serviceListener.getName());
+                builder.setFactory(builder.createInject(endpoint));
+                builder.setFactoryMethod("addServiceListener");
+                builder.addConstructorParameter(ServiceListener.class.getName(), builder.createInject(serviceListener.getListenerBean()));
+                builder.addConstructorParameter(boolean.class.getName(), Boolean.valueOf(serviceListener.isOnlyNew()));
+                builder.setStop("close");
+                metaDataList.add(builder.getBeanMetaData());
+            }
+            return Collections.unmodifiableList(metaDataList);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException("Cannot find a required class name", e);
         }
-        return Collections.unmodifiableList(metaDataList);
     }
+
+    private Class<?> getOptionalClass(final String className, final ClassLoader classLoader) throws ClassNotFoundException {
+        return className == null ? Object.class : Class.forName(className, false, classLoader);
+    }
 }

Added: remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ServiceListenerMetaData.java
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ServiceListenerMetaData.java	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/java/org/jboss/remoting/metadata/ServiceListenerMetaData.java	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ *
+ */
+ at XmlType(name = "service-listener")
+public final class ServiceListenerMetaData {
+    private String name;
+    private String listenerBean;
+    private boolean onlyNew;
+
+    public String getName() {
+        return name;
+    }
+
+    @XmlAttribute(required = true)
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getListenerBean() {
+        return listenerBean;
+    }
+
+    @XmlAttribute(name = "listener-bean", required = true)
+    public void setListenerBean(final String listenerBean) {
+        this.listenerBean = listenerBean;
+    }
+
+    public boolean isOnlyNew() {
+        return onlyNew;
+    }
+
+    @XmlAttribute(name = "only-new")
+    public void setOnlyNew(final boolean onlyNew) {
+        this.onlyNew = onlyNew;
+    }
+}

Added: remoting-mc-int/trunk/metadata/src/main/resources/META-INF/jboss-remoting_3_0.xsd
===================================================================
--- remoting-mc-int/trunk/metadata/src/main/resources/META-INF/jboss-remoting_3_0.xsd	                        (rev 0)
+++ remoting-mc-int/trunk/metadata/src/main/resources/META-INF/jboss-remoting_3_0.xsd	2009-01-10 00:26:03 UTC (rev 4799)
@@ -0,0 +1,63 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+        xmlns="urn:jboss:remoting:3.0"
+        targetNamespace="urn:jboss:remoting:3.0"
+        elementFormDefault="qualified"
+        attributeFormDefault="unqualified"
+        version="1.0"
+        >
+
+    <xs:complexType name="remoting">
+        <xs:sequence minOccurs="0" maxOccurs="unbounded">
+            <xs:choice>
+                <xs:element name="local-service" type="local-service"/>
+                <xs:element name="remote-service" type="remote-service"/>
+                <xs:element name="client" type="client"/>
+                <xs:element name="client-source" type="client-source"/>
+                <xs:element name="service-listener" type="service-listener"/>
+            </xs:choice>
+        </xs:sequence>
+        <xs:attribute name="endpoint" type="xs:string" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="local-service">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="request-listener-class" type="xs:string" use="optional"/>
+        <xs:attribute name="request-listener-bean" type="xs:string" use="optional"/>
+        <xs:attribute name="request-class-name" type="xs:string" use="optional"/>
+        <xs:attribute name="reply-class-name" type="xs:string" use="optional"/>
+        <xs:attribute name="service-type" type="xs:string" use="required"/>
+        <xs:attribute name="group-name" type="xs:string" use="optional"/>
+        <xs:attribute name="metric" type="xs:integer" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="remote-service">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="service-type" type="xs:string" use="required"/>
+        <xs:attribute name="group-name" type="xs:string" use="required"/>
+        <xs:attribute name="endpoint-name" type="xs:string" use="required"/>
+        <xs:attribute name="request-handler-source-bean" type="xs:string" use="required"/>
+        <xs:attribute name="metric" type="xs:integer" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="client">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="service-bean" type="xs:string" use="required"/>
+        <xs:attribute name="request-class-name" type="xs:string" use="optional"/>
+        <xs:attribute name="reply-class-name" type="xs:string" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="client-source">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="service-bean" type="xs:string" use="required"/> 
+        <xs:attribute name="request-class-name" type="xs:string" use="optional"/>
+        <xs:attribute name="reply-class-name" type="xs:string" use="optional"/>
+    </xs:complexType>
+
+    <xs:complexType name="service-listener">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="listener-bean" type="xs:string" use="required"/>
+        <xs:attribute name="only-new" type="xs:boolean" use="optional"/>
+    </xs:complexType>
+
+    <xs:element name="remoting" type="remoting"/>
+</xs:schema>




More information about the jboss-remoting-commits mailing list