Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for SFSB proxy serialization
- Loading branch information
1 parent
092056b
commit 3b466ee
Showing
15 changed files
with
427 additions
and
17 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
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
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
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
35 changes: 35 additions & 0 deletions
35
ee/src/main/java/org/jboss/as/ee/component/serialization/WriteReplaceInterface.java
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,35 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat 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.as.ee.component.serialization; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Interface used to allow the proxy to supprt serialization. Currently used to work around | ||
* a limitation in the ProxyFactory | ||
* @author Stuart Douglas | ||
*/ | ||
public interface WriteReplaceInterface { | ||
|
||
Object writeReplace() throws IOException; | ||
|
||
} |
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
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
55 changes: 55 additions & 0 deletions
55
ejb3/src/main/java/org/jboss/as/ejb3/component/stateful/StatefulSerializedProxy.java
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,55 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat 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.as.ejb3.component.stateful; | ||
|
||
import org.jboss.as.ee.component.ComponentView; | ||
import org.jboss.as.server.CurrentServiceContainer; | ||
import org.jboss.ejb.client.SessionID; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
|
||
import java.io.ObjectStreamException; | ||
import java.io.Serializable; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Serialized form of a SFSB | ||
* | ||
* @author Stuart Douglas | ||
*/ | ||
public class StatefulSerializedProxy implements Serializable { | ||
|
||
|
||
private static final long serialVersionUID = 627023970448688592L; | ||
private final String viewName; | ||
private final SessionID sessionID; | ||
|
||
public StatefulSerializedProxy(final String viewName, final SessionID sessionID) { | ||
this.viewName = viewName; | ||
this.sessionID = sessionID; | ||
} | ||
|
||
private Object readResolve() throws ObjectStreamException { | ||
ServiceController<ComponentView> view = (ServiceController<ComponentView>) CurrentServiceContainer.getServiceContainer().getRequiredService(ServiceName.parse(viewName)); | ||
return view.getValue().createInstance(Collections.<Object, Object>singletonMap(StatefulSessionComponent.SESSION_ATTACH_KEY, sessionID)).createProxy(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
ejb3/src/main/java/org/jboss/as/ejb3/component/stateful/WriteReplaceInterceptor.java
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,62 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat 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.as.ejb3.component.stateful; | ||
|
||
import org.jboss.ejb.client.SessionID; | ||
import org.jboss.invocation.Interceptor; | ||
import org.jboss.invocation.InterceptorContext; | ||
import org.jboss.invocation.InterceptorFactory; | ||
import org.jboss.invocation.InterceptorFactoryContext; | ||
|
||
/** | ||
* Interceptor that handles the writeReplace method for a SFSB | ||
* | ||
* @author Stuart Douglas | ||
*/ | ||
public class WriteReplaceInterceptor implements Interceptor { | ||
|
||
private final String serviceName; | ||
|
||
public WriteReplaceInterceptor(final String serviceName) { | ||
this.serviceName = serviceName; | ||
} | ||
|
||
@Override | ||
public Object processInvocation(final InterceptorContext context) throws Exception { | ||
SessionID sessionId = (SessionID) context.getPrivateData(StatefulContextIdKey.INSTANCE); | ||
return new StatefulSerializedProxy(serviceName, sessionId); | ||
} | ||
|
||
public static class Factory implements InterceptorFactory { | ||
|
||
private final String serviceName; | ||
|
||
public Factory(final String serviceName) { | ||
this.serviceName = serviceName; | ||
} | ||
|
||
@Override | ||
public Interceptor create(final InterceptorFactoryContext context) { | ||
return new WriteReplaceInterceptor(serviceName); | ||
} | ||
} | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
...est/java/org/jboss/as/testsuite/integration/ejb/stateful/serialization/AnnotatedBean.java
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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, 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. | ||
*/ | ||
|
||
package org.jboss.as.testsuite.integration.ejb.stateful.serialization; | ||
|
||
import javax.ejb.Stateful; | ||
|
||
/** | ||
* stateful session bean | ||
* | ||
*/ | ||
@Stateful | ||
public class AnnotatedBean { | ||
|
||
private int value; | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(final int value) { | ||
this.value = value; | ||
} | ||
} |
Oops, something went wrong.