Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around class table incompatibility problem by using surrogate classes #228

Merged
merged 1 commit into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ final class ProtocolV1ClassTable implements ClassTable {
* set below.
*/
private static final Class<?>[] classes = {
EJBLocator.class,
EJBHomeLocator.class,
StatelessEJBLocator.class,
StatefulEJBLocator.class,
EntityEJBLocator.class,
V1EJBLocator.class,
V1HomeLocator.class,
V1StatelessLocator.class,
V1StatefulLocator.class,
V1EntityLocator.class,
EJBHandle.class,
EJBHomeHandle.class,
SerializedEJBInvocationHandler.class,
Expand Down Expand Up @@ -143,6 +143,11 @@ final class ProtocolV1ClassTable implements ClassTable {
deprecatedClassTableClasses.add(Throwable.class);
deprecatedClassTableClasses.add(Exception.class);
deprecatedClassTableClasses.add(RuntimeException.class);
deprecatedClassTableClasses.add(EJBLocator.class);
deprecatedClassTableClasses.add(EJBHomeLocator.class);
deprecatedClassTableClasses.add(StatefulEJBLocator.class);
deprecatedClassTableClasses.add(StatelessEJBLocator.class);
deprecatedClassTableClasses.add(EntityEJBLocator.class);

final Map<Class<?>, ByteWriter> map = new IdentityHashMap<Class<?>, ByteWriter>();
final Class<?>[] classes = ProtocolV1ClassTable.classes;
Expand Down
112 changes: 112 additions & 0 deletions src/main/java/org/jboss/ejb/protocol/remote/V1EJBLocator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* 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.
*/

package org.jboss.ejb.protocol.remote;

import java.io.Serializable;

import javax.ejb.EJBHome;
import javax.ejb.EJBObject;

import org.jboss.ejb.client.Affinity;
import org.jboss.ejb.client.EJBHomeLocator;
import org.jboss.ejb.client.EntityEJBLocator;
import org.jboss.ejb.client.SessionID;
import org.jboss.ejb.client.StatefulEJBLocator;
import org.jboss.ejb.client.StatelessEJBLocator;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
abstract class V1EJBLocator<T> implements Serializable {
private static final long serialVersionUID = -7306257085240447972L;

final Class<T> viewType;
final String appName;
final String moduleName;
final String beanName;
final String distinctName;
final Affinity affinity;

V1EJBLocator(final Class<T> viewType, final String appName, final String moduleName, final String beanName, final String distinctName, final Affinity affinity) {
this.viewType = viewType;
this.appName = appName;
this.moduleName = moduleName;
this.beanName = beanName;
this.distinctName = distinctName;
this.affinity = affinity;
}

abstract Object readResolve();
}

final class V1StatefulLocator<T> extends V1EJBLocator<T> {
private static final long serialVersionUID = 8229686118358785586L;

final SessionID sessionId;
final String sessionOwnerNode;

V1StatefulLocator(final Class<T> viewType, final String appName, final String moduleName, final String beanName, final String distinctName, final Affinity affinity, final SessionID sessionId, final String sessionOwnerNode) {
super(viewType, appName, moduleName, beanName, distinctName, affinity);
this.sessionId = sessionId;
this.sessionOwnerNode = sessionOwnerNode;
}

Object readResolve() {
return new StatefulEJBLocator<T>(viewType, appName, moduleName, beanName, distinctName, sessionId, affinity);
}
}

final class V1StatelessLocator<T> extends V1EJBLocator<T> {
private static final long serialVersionUID = -3040039191221970094L;

V1StatelessLocator(final Class<T> viewType, final String appName, final String moduleName, final String beanName, final String distinctName, final Affinity affinity) {
super(viewType, appName, moduleName, beanName, distinctName, affinity);
}

Object readResolve() {
return new StatelessEJBLocator<T>(viewType, appName, moduleName, beanName, distinctName, affinity);
}
}

final class V1EntityLocator<T extends EJBObject> extends V1EJBLocator<T> {
private static final long serialVersionUID = 6674116259124568398L;

final Object primaryKey;

V1EntityLocator(final Class<T> viewType, final String appName, final String moduleName, final String beanName, final String distinctName, final Affinity affinity, final Object primaryKey) {
super(viewType, appName, moduleName, beanName, distinctName, affinity);
this.primaryKey = primaryKey;
}

Object readResolve() {
return new EntityEJBLocator<T>(viewType, appName, moduleName, beanName, distinctName, primaryKey, affinity);
}
}

final class V1HomeLocator<T extends EJBHome> extends V1EJBLocator<T> {
private static final long serialVersionUID = -3040039191221970094L;

V1HomeLocator(final Class<T> viewType, final String appName, final String moduleName, final String beanName, final String distinctName, final Affinity affinity) {
super(viewType, appName, moduleName, beanName, distinctName, affinity);
}

Object readResolve() {
return new EJBHomeLocator<T>(viewType, appName, moduleName, beanName, distinctName, affinity);
}
}