Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67d3d4c
Showing
5 changed files
with
466 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
target | ||
.idea | ||
.settings | ||
.eclipse | ||
*.iml | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2010, Red Hat, Inc., 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. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-parent</artifactId> | ||
<version>6</version> | ||
</parent> | ||
|
||
<groupId>org.jboss</groupId> | ||
<artifactId>jboss-iiop-client</artifactId> | ||
<version>1.0.0.Beta1-SNAPSHOT</version> | ||
|
||
<name>JBoss IIOP Client</name> | ||
<description>Client library for EJB applications working against JBoss AS | ||
using the IIOP protocol</description> | ||
|
||
<properties> | ||
<version.org.jboss.spec.javax.ejb>1.0.0.Final</version.org.jboss.spec.javax.ejb> | ||
</properties> | ||
|
||
<build> | ||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.jboss.spec.javax.ejb</groupId> | ||
<artifactId>jboss-ejb-api_3.1_spec</artifactId> | ||
<version>${version.org.jboss.spec.javax.ejb}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- JUnit --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<scm> | ||
<connection>scm:git:git@github.com:jbossas/jboss-iiop-client.git</connection> | ||
<developerConnection>scm:git:git@github.com:jbossas/jboss-iiop-client.git</developerConnection> | ||
<url>https://github.com/jbossas/jboss-iiop-client</url> | ||
</scm> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <code>Class</code> object for the enterprise Bean's home | ||
* interface. | ||
*/ | ||
public Class getHomeInterfaceClass() { | ||
return homeClass; | ||
} | ||
|
||
/** | ||
* Obtains the <code>Class</code> object for the enterprise Bean's remote | ||
* interface. | ||
*/ | ||
public Class getRemoteInterfaceClass() { | ||
return remoteClass; | ||
} | ||
|
||
/** | ||
* Obtains the <code>Class</code> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* <code>EJBObject</code>. | ||
*/ | ||
private String ior; | ||
|
||
/** | ||
* The stub class | ||
*/ | ||
private transient Class<?> stubClass = EJBObject.class; | ||
|
||
/** | ||
* Constructs an <code>HandleImplIIOP</code>. | ||
* | ||
* @param ior An stringfied CORBA reference for an <code>EJBObject</code>. | ||
*/ | ||
public HandleImplIIOP(String ior) { | ||
this.ior = ior; | ||
} | ||
|
||
/** | ||
* Constructs an <tt>HandleImplIIOP</tt>. | ||
* | ||
* @param obj An <code>EJBObject</code>. | ||
*/ | ||
public HandleImplIIOP(EJBObject obj) { | ||
this((org.omg.CORBA.Object) obj); | ||
} | ||
|
||
/** | ||
* Constructs an <tt>HandleImplIIOP</tt>. | ||
* | ||
* @param obj A CORBA reference for an <code>EJBObject</code>. | ||
*/ | ||
public HandleImplIIOP(org.omg.CORBA.Object obj) { | ||
this.ior = getOrb().object_to_string(obj); | ||
this.stubClass = obj.getClass(); | ||
} | ||
|
||
/** | ||
* Obtains the <code>EJBObject</code> represented by this handle. | ||
* | ||
* @return a reference to an <code>EJBObject</code>. | ||
* @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); | ||
} | ||
} | ||
} |
Oops, something went wrong.