diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d9856ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+target
+.idea
+.settings
+.eclipse
+*.iml
+*~
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..6e539e4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+ 4.0.0
+
+
+ org.jboss
+ jboss-parent
+ 6
+
+
+ org.jboss
+ jboss-iiop-client
+ 1.0.0.Beta1-SNAPSHOT
+
+ JBoss IIOP Client
+ Client library for EJB applications working against JBoss AS
+ using the IIOP protocol
+
+
+ 1.0.0.Final
+
+
+
+
+
+
+
+
+ org.jboss.spec.javax.ejb
+ jboss-ejb-api_3.1_spec
+ ${version.org.jboss.spec.javax.ejb}
+ provided
+
+
+
+
+ junit
+ junit
+ 4.8.2
+ test
+
+
+
+
+ scm:git:git@github.com:jbossas/jboss-iiop-client.git
+ scm:git:git@github.com:jbossas/jboss-iiop-client.git
+ https://github.com/jbossas/jboss-iiop-client
+
+
diff --git a/src/main/java/org/jboss/ejb/iiop/EJBMetaDataIIOP.java b/src/main/java/org/jboss/ejb/iiop/EJBMetaDataIIOP.java
new file mode 100644
index 0000000..3a6a1e0
--- /dev/null
+++ b/src/main/java/org/jboss/ejb/iiop/EJBMetaDataIIOP.java
@@ -0,0 +1,86 @@
+package org.jboss.ejb.iiop;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBMetaData;
+
+/**
+ *The {@link EJBMetaData} implementation used in remote IIOP invocations.
+ *
+ * @author Stuart Douglas
+ */
+public class EJBMetaDataIIOP implements EJBMetaData {
+
+ private final Class remoteClass;
+
+ private final Class homeClass;
+
+ private final Class pkClass;
+
+ private final boolean session;
+
+ private final boolean statelessSession;
+
+ private final EJBHome home;
+
+ public EJBMetaDataIIOP(final Class remoteClass, final Class homeClass, final Class pkClass, final boolean session,
+ final boolean statelessSession, final EJBHome home) {
+ this.remoteClass = remoteClass;
+ this.homeClass = homeClass;
+ this.pkClass = pkClass;
+ this.session = session;
+ this.statelessSession = statelessSession;
+ this.home = home;
+ }
+
+
+ /**
+ * Obtains the home interface of the enterprise Bean.
+ */
+ public EJBHome getEJBHome() {
+ return home;
+ }
+
+ /**
+ * Obtains the Class
object for the enterprise Bean's home
+ * interface.
+ */
+ public Class getHomeInterfaceClass() {
+ return homeClass;
+ }
+
+ /**
+ * Obtains the Class
object for the enterprise Bean's remote
+ * interface.
+ */
+ public Class getRemoteInterfaceClass() {
+ return remoteClass;
+ }
+
+ /**
+ * Obtains the Class
object for the enterprise Bean's primary
+ * key class.
+ */
+ public Class getPrimaryKeyClass() {
+ if (session)
+ throw new RuntimeException("A session bean does not have a primary key class");
+ return pkClass;
+ }
+
+ /**
+ * Tests if the enterprise Bean's type is "session".
+ *
+ * @return true if the type of the enterprise Bean is session bean.
+ */
+ public boolean isSession() {
+ return session;
+ }
+
+ /**
+ * Tests if the enterprise Bean's type is "stateless session".
+ *
+ * @return true if the type of the enterprise Bean is stateless session.
+ */
+ public boolean isStatelessSession() {
+ return statelessSession;
+ }
+}
diff --git a/src/main/java/org/jboss/ejb/iiop/HandleImplIIOP.java b/src/main/java/org/jboss/ejb/iiop/HandleImplIIOP.java
new file mode 100644
index 0000000..ef017c5
--- /dev/null
+++ b/src/main/java/org/jboss/ejb/iiop/HandleImplIIOP.java
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.iiop;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.spi.HandleDelegate;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.PortableRemoteObject;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * A CORBA-based EJBObject handle implementation.
+ */
+public class HandleImplIIOP implements Handle, Serializable {
+
+ private static final long serialVersionUID = -601170775289648475L;
+
+ /**
+ * This handle encapsulates an stringfied CORBA reference for an
+ * EJBObject
.
+ */
+ private String ior;
+
+ /**
+ * The stub class
+ */
+ private transient Class> stubClass = EJBObject.class;
+
+ /**
+ * Constructs an HandleImplIIOP
.
+ *
+ * @param ior An stringfied CORBA reference for an EJBObject
.
+ */
+ public HandleImplIIOP(String ior) {
+ this.ior = ior;
+ }
+
+ /**
+ * Constructs an HandleImplIIOP.
+ *
+ * @param obj An EJBObject
.
+ */
+ public HandleImplIIOP(EJBObject obj) {
+ this((org.omg.CORBA.Object) obj);
+ }
+
+ /**
+ * Constructs an HandleImplIIOP.
+ *
+ * @param obj A CORBA reference for an EJBObject
.
+ */
+ public HandleImplIIOP(org.omg.CORBA.Object obj) {
+ this.ior = getOrb().object_to_string(obj);
+ this.stubClass = obj.getClass();
+ }
+
+ /**
+ * Obtains the EJBObject
represented by this handle.
+ *
+ * @return a reference to an EJBObject
.
+ * @throws java.rmi.RemoteException
+ */
+ public EJBObject getEJBObject() throws RemoteException {
+ try {
+ org.omg.CORBA.Object obj = getOrb().string_to_object(ior);
+ return narrow(obj);
+ } catch (RemoteException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RemoteException("Could not get EJBObject from Handle", e);
+ }
+ }
+
+ private EJBObject narrow(org.omg.CORBA.Object obj) throws ClassCastException, RemoteException {
+ // Null object - this should probably throw some kind of error?
+ if (obj == null)
+ return null;
+
+ if (stubClass.isAssignableFrom(obj.getClass()))
+ return (EJBObject) obj;
+
+ if (stubClass == EJBObject.class)
+ return (EJBObject) PortableRemoteObject.narrow(obj, EJBObject.class);
+
+ // Create the stub from the stub class
+ try {
+ Stub stub = (Stub) stubClass.newInstance();
+ stub._set_delegate(((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate());
+ return (EJBObject) stub;
+ } catch (Exception e) {
+ throw new RemoteException("Error creating stub", e);
+ }
+ }
+
+ private void writeObject(ObjectOutputStream oostream) throws IOException {
+ final HandleDelegate delegate = getHandleDelegate();
+ delegate.writeEJBObject(getEJBObject(), oostream);
+ }
+
+ private void readObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException {
+ EJBObject obj = getHandleDelegate().readEJBObject(oistream);
+ this.ior = getOrb().object_to_string((org.omg.CORBA.Object) obj);
+ this.stubClass = obj.getClass();
+ }
+
+ private HandleDelegate getHandleDelegate() {
+ try {
+ return (HandleDelegate) new InitialContext().lookup("java:comp/HandleDelegate");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ORB getOrb() {
+ try {
+ return (ORB) new InitialContext().lookup("java:comp/ORB");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/org/jboss/ejb/iiop/HomeHandleImplIIOP.java b/src/main/java/org/jboss/ejb/iiop/HomeHandleImplIIOP.java
new file mode 100644
index 0000000..287832d
--- /dev/null
+++ b/src/main/java/org/jboss/ejb/iiop/HomeHandleImplIIOP.java
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.iiop;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBHome;
+import javax.ejb.HomeHandle;
+import javax.ejb.spi.HandleDelegate;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.PortableRemoteObject;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * A CORBA-based EJB home handle implementation.
+ *
+ */
+public class HomeHandleImplIIOP implements HomeHandle {
+
+ private static final long serialVersionUID = 965281969551395661L;
+
+ /**
+ * This handle encapsulates an stringfied CORBA reference for an
+ * EJBHome
.
+ */
+ private String ior;
+
+ /**
+ * The stub class
+ */
+ private transient Class> stubClass = EJBHome.class;
+
+ /**
+ * Constructs a HomeHandleImplIIOP
.
+ *
+ * @param ior An stringfied CORBA reference for an EJBHome
.
+ */
+ public HomeHandleImplIIOP(final String ior) {
+ this.ior = ior;
+ }
+
+ /**
+ * Constructs a HomeHandleImplIIOP.
+ *
+ * @param home An EJBHome
.
+ */
+ public HomeHandleImplIIOP(final EJBHome home) {
+ this((org.omg.CORBA.Object) home);
+ }
+
+ /**
+ * Constructs a HomeHandleImplIIOP.
+ *
+ * @param home A CORBA reference for an EJBHome
.
+ */
+ public HomeHandleImplIIOP(final org.omg.CORBA.Object home) {
+ this.ior = getOrb().object_to_string(home);
+ this.stubClass = home.getClass();
+ }
+
+ /**
+ * Obtains the EJBHome
represented by this home handle.
+ *
+ * @return a reference to an EJBHome
.
+ * @throws java.rmi.RemoteException
+ */
+ public EJBHome getEJBHome() throws RemoteException {
+ try {
+ final org.omg.CORBA.Object obj = getOrb().string_to_object(ior);
+ return narrow(obj);
+ } catch (RemoteException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RemoteException("Could not get EJBHome from HomeHandle", e);
+ }
+ }
+
+ private EJBHome narrow(org.omg.CORBA.Object obj) throws ClassCastException, RemoteException {
+ // Null object - this should probably throw some kind of error?
+ if (obj == null)
+ return null;
+
+ // Already the correct type
+ if (stubClass.isAssignableFrom(obj.getClass()))
+ return (EJBHome) obj;
+
+ // Backwards compatibility - almost certainly wrong!
+ if (stubClass == EJBHome.class)
+ return (EJBHome) PortableRemoteObject.narrow(obj, EJBHome.class);
+
+ // Create the stub from the stub class
+ try {
+ final Stub stub = (Stub) stubClass.newInstance();
+ stub._set_delegate(((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate());
+ return (EJBHome) stub;
+ } catch (Exception e) {
+ throw new RemoteException("Error creating stub", e);
+ }
+ }
+
+ private void writeObject(final ObjectOutputStream oostream) throws IOException {
+ getHandleDelegate().writeEJBHome(getEJBHome(), oostream);
+ }
+
+ private void readObject(final ObjectInputStream oistream) throws IOException, ClassNotFoundException {
+ final EJBHome obj = getHandleDelegate().readEJBHome(oistream);
+ this.ior = getOrb().object_to_string((org.omg.CORBA.Object) obj);
+ this.stubClass = obj.getClass();
+ }
+
+
+ private HandleDelegate getHandleDelegate(){
+ try {
+ return (HandleDelegate) new InitialContext().lookup("java:comp/HandleDelegate");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ORB getOrb() {
+ try {
+ return (ORB) new InitialContext().lookup("java:comp/ORB");
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}