[EJB 3.0 Development] - EJB 3.1 Embedded EJBContainer in AS
by Andrew Rubinger
Andrew Rubinger [http://community.jboss.org/people/ALRubinger] created the discussion
"EJB 3.1 Embedded EJBContainer in AS"
To view the discussion, visit: http://community.jboss.org/message/542619#542619
--------------------------------------------------------------
I'm tracking integration of the Embedded EJB3 "EJBContainer" APIs into AS here:
https://jira.jboss.org/jira/browse/JBAS-7964 https://jira.jboss.org/jira/browse/JBAS-7964
The task for the "embedded" component is:
https://jira.jboss.org/jira/browse/EJBTHREE-2083 https://jira.jboss.org/jira/browse/EJBTHREE-2083
We now have a passing test in my development branch of AS. It:
* Deploys a Servlet into AS
* Issues an HTTP request to the Servlet
* Servlet then starts a new EJBContainer and deploys a ShrinkWrap archive into it (which is a JBoss-specific extension)
* Looks up the EJB proxy using EJBContainer.getContext() and invokes upon it
* Returns the result to the caller
Pending is still to split the ShrinkWrap-specific stuff out into an extension module, but it proves we're on the way to something working from inside AS. It's essentially spec API wrappers to our existing runtime.
http://anonsvn.jboss.org/repos/jbossas/branches/TEMP_EJB3_EMBEDDABLE_JBAS... http://anonsvn.jboss.org/repos/jbossas/branches/TEMP_EJB3_EMBEDDABLE_JBAS...
/*
* JBoss, Home of Professional Open Source.
* Copyright 2009, 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.jbossas.embedded.testsuite.servlet;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jboss.ejb3.embedded.api.JBossEJBContainer;
import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputBean;
import org.jboss.jbossas.embedded.testsuite.ejb3.slsb.OutputLocalBusiness;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
/**
* Servlet which forwards calls upon an EJB
* via the {@link EJBContainer} API.
*
* @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
* @version $Revision: $
*/
public class EmbeddedEjbCallingServlet extends HttpServlet
{
//-------------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
* Logger
*/
private static final Logger log = Logger.getLogger(EmbeddedEjbCallingServlet.class.getName());
/**
* serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* Content type to use in forwarding
*/
private static final String CONTENT_TYPE_TEXT_PLAIN = "text/plain";
//-------------------------------------------------------------------------------------||
// Overridden Implementations ---------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
* Returns the value {@link OutputLocalBusiness#OUTPUT} by invoking via an EJB
*
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
IOException
{
// Log
log.info("Request: " + request);
// Set the content-type to text
response.setContentType(CONTENT_TYPE_TEXT_PLAIN);
// Create the EJB Container
final Map<String, String> ejbContainerProps = new HashMap<String, String>();
ejbContainerProps.put(EJBContainer.MODULES, ""); // Deploy no modules and do no scanning by default
final JBossEJBContainer ejbContainer = (JBossEJBContainer) EJBContainer.createEJBContainer(ejbContainerProps);
// Define the EJB JAR
final JavaArchive archive = ShrinkWrap.create("outputSlsb.jar", JavaArchive.class).addClasses(OutputBean.class,
OutputLocalBusiness.class);
// Deploy the JAR
ejbContainer.deploy(archive);
// Look up the EJB
final Context context = ejbContainer.getContext();
final OutputLocalBusiness bean;
try
{
bean = (OutputLocalBusiness) context.lookup(OutputLocalBusiness.JNDI_NAME);
}
catch (final NamingException e)
{
throw new RuntimeException("Could not find bean proxy at " + OutputLocalBusiness.JNDI_NAME, e);
}
// Invoke
final String value = bean.getOutput();
// Undeploy
ejbContainer.undeploy(archive);
// Shut down EJBContainer
ejbContainer.close();
// Write out
log.info("Got value from EJB: " + value);
response.getWriter().write(value);
}
}
S,
ALR
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/542619#542619]
Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
Re: [jboss-dev-forums] [JBoss Microcontainer Development] - ClassPool bootstrap refactoring
by Kabir Khan
Kabir Khan [http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the discussion
"ClassPool bootstrap refactoring"
To view the discussion, visit: http://community.jboss.org/message/542584#542584
--------------------------------------------------------------
IRC discussion
>
> kkhan:ping ALR
>
> [14:24]ALR:kkhan: Hey
>
> [14:24]kkhan:ALR: Regarding my bootstrap stuff I think you're right
>
> [14:24] ggear joined the chat room.
>
> [14:24] ggear was granted voice by ChanServ.
>
> [14:25]kkhan:too many dependencies on classpools and other stuuff
>
> [14:25]ALR:kkhan: Yup, saw your post.
>
> [14:25]kkhan:ALR: Are you ok with me adding the correct hooks for events where I need them, or do you prefer doing so yourself
>
> [14:25]ALR:Also we should be making sure all commits/features get testied
>
> [14:26]ALR:kkhan: Sure, you can add them. I'll give some opinions and help guide as you need.
>
> [14:26]kkhan:ALR: Yeah, what I had wasn't really meant to be committed, it was more a basis for further instructions
>
> [14:26]kkhan:*further discussion
>
> [14:26]ALR:kkhan: Ah OK. I put it in to facilitate testing
>
> [14:26]ALR:But hadn't really planned on releasing like that
>
> [14:26]ALR:kkhan: I'll reply to your post, but also
>
> [14:26]ALR::
>
> [14:26]ALR:I got that ClassLoading SPI test passing
>
> [14:27]kkhan:ok cool
>
> [14:27]ALR:Let's see what events you need:
>
> [14:27]kkhan:ALR: It probably makes sense to rever what I had done to get rid of all the deps
>
> [14:27]kkhan:and then do it properly
>
> [14:27]kkhan:so I didn't really look into the ClassLoading SPI test since that was more deps
>
> [14:27]ALR: http://anonsvn.jboss.org/repos/jbossas/projects/bootstrap/trunk/api/src/m... http://anonsvn.jboss.org/repos/jbossas/projects/bootstrap/trunk/api/src/m...
>
> [14:28]kkhan:I want something like PRE_KERNEL_BOOTSTRAP and POST_KERNEL_BOOTSTRAP
>
> [14:29]kkhan:ALR: Sound ok?
>
> [14:29]ALR:kkhan: Not really in its current form
>
> [14:30]ALR:As "Kernel" is an MC construct
>
> [14:30]ALR:And these LifecycleStates are in the main API
>
> [14:30]kkhan:Actually, I probably don't need the PRE one that can be done whenever
>
> [14:30]kkhan:i.e. early
>
> [14:30]ALR:kkhan: "INSTANCIATED"
>
> [14:30]ALR:Or maybe PRE_INIT
>
> [14:31]ALR:And the "post", when exactly does that need to happen?
>
> [14:31]kkhan:The post needs to happen after the kernel has been bootstrapped, but before anything else has been deployed
>
> [14:32]ALR:kkhan: By "deployed", you mean processing the bootstrap XMLs?
>
> [14:32]kkhan:yes
>
> [14:32] pgier joined the chat room.
>
> [14:32] pgier was granted voice by ChanServ.
>
> [14:32]ALR:OK
>
> [14:32]ALR:Lemme look
>
> [14:33]kkhan:ALR: I think a PRE_CONFIG or POST_CONFIG state would do the trick, to be raised by AbstractServer.doInitialize() somewhere
>
> [14:33]kkhan:That should be generic enough
>
> [14:33]ALR:Yep
>
> [14:33]kkhan:ALR: Ok, I'll go with that then
>
> [14:34]ALR:Just need to think of a good name.
>
> [14:34]ALR:I think "PRE_BOOTSTRAP", "POST_BOOTSTRAP"?
>
> [14:34]kkhan:Hmm, not sure
>
> [14:34] vblagoje joined the chat room.
>
> [14:35]ALR:That's essentially what we're doing.
>
> [14:35]kkhan:Since only AbtractMCServerBase calls bootstrap
>
> [14:35]ALR:The generic API knows about bootstraps.
>
> [14:35]kkhan:So where do I raise it?
>
> [14:35]ALR:Yes, but that's only because it's our only impl.
>
> [14:35]ALR:We could also, for instance, have a Fungal (JCA Kernel) implementation.
>
> [14:36]ALR:So you'd fire the callbacks in AbstractMCServerBase, yes.
>
> [14:36]ALR:Or at a higher level, even better, if you could refactor to get the right wiring.
>
> [14:37]kkhan:I think I'd like to trigger it from AbstractServer.doInitialize()
>
> [14:37]ALR: http://anonsvn.jboss.org/repos/jbossas/projects/bootstrap/trunk/impl-base... http://anonsvn.jboss.org/repos/jbossas/projects/bootstrap/trunk/impl-base...
>
> [14:37]ALR:Yes, all you need to do is call "setState"
>
> [14:37]kkhan:Just need the name
>
> [14:38] smarlow is now known as smarlow_afk.
>
> [14:38]ALR:AbstractServer.doInitialize is now abstract
>
> [14:38]ALR:So again, some refactoring may be needed to get your pre/post bootstrap hooks up at that level
>
> [14:38]ALR:kkhan: Why don't I take this?
>
> [14:38]ALR:I'll get you the hooks.
>
> [14:38]ALR:And refactor the events and the tests.
>
> [14:38]kkhan:ALR: Cool
>
> [14:38]ALR:Then you can extract out your ClassPool stuff.
>
> [14:39]ALR:And reintegrate it.
>
> [14:39]kkhan:ALR: Yeah, sounds good
>
> [14:39]kkhan:Thanks
>
> [14:39]ALR:kkhan: Where do you see the ClassPool logic going?
>
> [14:39]kkhan:ALR: I think that will go in the classpool project
>
> [14:40]kkhan:And then I'll modify AS MAin to set the correct event handlers before booting the server
>
> [14:40]ALR:kkhan: Making ClassPool depend upon bootstrap-api?
>
> [14:40]kkhan:ALR: I haven't looked too much into which deps that would bring in yet
>
> [14:40]ALR:kkhan: I think we should put it into bootstrap-impl-as.
>
> [14:41]ALR:kkhan: For 2 reasons:
>
> [14:41]kkhan:ALR: ok by me
>
> [14:41]ALR:1) ClassPool needn't know about Bootstrap.
>
> [14:41]ALR:2) We shouldn't add the event handlers in AS Main; that's used only by standalone AS. We get it for free in Embedded if we set it up in bootstrap-as.
>
> [14:42]kkhan:ALR: ok, as long as you don;t mind the deps there.
>
> [14:42]ALR:kkhan: Nope. It's for AS, so all bets are off.
>
> [14:42]kkhan:ALR: ok cool
>
>
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/542584#542584]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
Re: [jboss-dev-forums] [JBoss Microcontainer Development] - JBoss Reflect Performance Javassist vs Introspection
by Kabir Khan
Kabir Khan [http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the discussion
"JBoss Reflect Performance Javassist vs Introspection"
To view the discussion, visit: http://community.jboss.org/message/542552#542552
--------------------------------------------------------------
> Kabir Khan wrote:
>
> I have done some performance measurements where I compare the times taken creating the following class, using javassist.bytecode.* and asm
>
>
> *public* *class* JavassistMethod1 *implements* JavassistMethod
> {
> *public* Object invoke(Object target, Object[] args) *throws* Throwable
> {
> *return* Integer.valueOf(((SomeClass)target).someMethod(((Integer)args[0]).intValue(), (String)args[1])).intValue();
> }
> }
>
>
>
>
>
>
> Which would be used to call the method:
>
> *int* someMethod(*int* i, String);
>
>
>
>
>
>
> The basic flow for what I do for both approaches is the same, whereby I do the following lots of times to generate lots of similar classes:
>
>
>
>
>
> A) - Create class structure
>
> B) - Add default constructor with body to call super
>
> C) - Add invoke method
>
> C1) - Add invoke method body
>
> D) - Convert class structure from A) into byte[]
>
> E) - Define java.lang.Class by calling ClassLoader.defineClass()
>
> F) - Call Class.newInstance()
Chiba has done some great work on creating a new API for Javassist tailor made to create new classes. Taking the defining of the class and instantiating it out of the equation (since that is JVM stuff out of our control), so we do A-D so we have the bytes ready to create the class the times are now for creating 20000 JavassistMethod implementations
|| *ASM* || *Javassist ClassFile* || JavassistClassFileWriter ||
| 476 | 1030 | 356 |
| 613 | 1056 | 269 |
| 483 | 1076 | 309 |
| 464 | 1001 | 357 |
| 383 | 1186 | 315 |
I have attached the modified benchmark
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/542552#542552]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
[jBPM Development] - JBPM-2835 HistroyDetail not saved in database.
by HuiSheng Xu
HuiSheng Xu [http://community.jboss.org/people/rebody] created the discussion
"JBPM-2835 HistroyDetail not saved in database."
To view the discussion, visit: http://community.jboss.org/message/542473#542473
--------------------------------------------------------------
Hi guys,
I create a patch and testcase as Arul said.
https://jira.jboss.org/jira/browse/JBPM-2835 https://jira.jboss.org/jira/browse/JBPM-2835
But the behaviour of HistoryTaskDetail is totally weird. For example, if we use taskService.assignTask() or takeTask(), it won't add any HistoryTaskDetail into database, because AssignTaskCmd didn't notify TaskUpdated event. So the assignee changed details won't be saved. If we want to save the detail information, we have to getTask() first, and modify task information, then invoke taskService.saveTask() to save the task into database and notify TaskUpdated event. But the setAssignee() of TaskImpl must be used in the Environment, otherwise it will throw a None Session in Context Exception. Unfortunately, there is no existing Command for doing this, so we have to create a customized command by ourselves.
So I afraid this part should be rewritten in the future.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/542473#542473]
Start a new discussion in jBPM Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months