blob: 5b06f4d6682414c89de34f52594967497d43acfd [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Deployment ID</title>
<meta name="description" content="Apache TomEE">
<meta name="author" content="Apache TomEE">
<meta name="google-translate-customization" content="f36a520c08f4c9-0a04e86a9c075ce9-g265f3196f697cf8f-10">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="./resources/css/bootstrap.css" rel="stylesheet">
<link href="./resources/css/prettify.css" rel="stylesheet">
<!--link href="./resources/css/bootstrap-mods.css" rel="stylesheet"-->
<link href="./resources/css/main.css" rel="stylesheet">
<link href="./resources/font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
var t = encodeURIComponent(document.title.replace(/^\s+|\s+$/g,""));
var u = encodeURIComponent(""+document.URL);
function fbshare () {
window.open(
"http://www.facebook.com/sharer/sharer.php?u="+u,
'Share on Facebook',
'width=640,height=426');
};
function gpshare () {
window.open(
"https://plus.google.com/share?url="+u,
'Share on Google+',
'width=584,height=385');
};
function twshare () {
window.open(
"https://twitter.com/intent/tweet?url="+u+"&text="+t,
'Share on Twitter',
'width=800,height=526');
};
function pinshare () {
window.open("//www.pinterest.com/pin/create/button/?url="+u+"&media=http%3A%2F%2Ftomee.apache.org%2Fresources%2Fimages%2Ffeather-logo.png&description="+t,
'Share on Pinterest',
'width=800,height=526');
};
</script>
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="./favicon.ico">
<link rel="apple-touch-icon" href="./resources/images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="./resources/images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="./resources/images/apple-touch-icon-114x114.png">
<script src="./resources/js/prettify.js" type="text/javascript"></script>
<script src="./resources/js/jquery-latest.js"></script>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<script src="./resources/js/common.js"></script>
<script src="./resources/js/prettyprint.js"></script>
<!--script src="//assets.pinterest.com/js/pinit.js" type="text/javascript" async></script//-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2717626-1']);
_gaq.push(['_setDomainName', 'apache.org']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="topbar" data-dropdown="dropdown">
<div class="fill">
<div class="container">
<a class="brand" href="./index.html">Apache TomEE</a>
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Apache
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<!-- <li><a href="./misc/whoweare.html">Who we are?</a></li> -->
<!-- <li><a href="./misc/heritage.html">Heritage</a></li> -->
<li><a href="http://www.apache.org">Apache Home</a></li>
<!-- <li><a href="./misc/resources.html">Resources</a></li> -->
<li><a href="./misc/contact.html">Contact</a></li>
<li><a href="./misc/legal.html">Legal</a></li>
<li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="divider"/>
<li><a href="http://www.apache.org/security">Security</a></li>
</ul>
</li>
<li><a href="./index.html">Home</a></li>
<li><a href="./downloads.html">Downloads</a></li>
<li><a href="./documentation.html">Documentation</a></li>
<li><a href="./examples-trunk/index.html">Examples</a></li>
<li><a href="./support.html">Support</a></li>
<li><a href="./contribute.html">Contribute</a></li>
<li><a href="./security/index.html">Security</a></li>
</ul>
<!-- Google CSE Search Box Begins -->
<FORM class="pull-right" id="searchbox_010475492895890475512:_t4iqjrgx90" action="http://www.google.com/cse">
<INPUT type="hidden" name="cx" value="010475492895890475512:_t4iqjrgx90">
<INPUT type="hidden" name="cof" value="FORID:0">
<INPUT size="18" width="130" style="width:130px" name="q" type="text" placeholder="Search">
</FORM>
<!--<SCRIPT type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_010475492895890475512:_t4iqjrgx90"></SCRIPT>-->
<!-- Google CSE Search Box Ends -->
</div>
</div>
</div>
<div class="container">
<div class="page-header">
<small><a href="./index.html">Home</a></small><br>
<h1>Deployment ID
<div style="float: right; position: relative; bottom: -10px; ">
<a onclick="javascript:gpshare()" class="gp-share sprite" title="Share on Google+">share [gp]</a>
<a onclick="javascript:fbshare()" class="fb-share sprite" title="Share on Facebook">share [fb]</a>
<a onclick="javascript:twshare()" class="tw-share sprite" title="Share on Twitter">share [tw]</a>
<a onclick="javascript:pinshare()" class="pin-share sprite" title="Share on Pinterest">share [pin]</a>
<a data-toggle="modal" href="#edit" class="edit-page" title="Contribute to this Page">contribute</a>
</div>
</h1>
</div>
<p><a name="DeploymentID-WhatisaDeploymentID?"></a></p>
<h1>What is a Deployment ID?</h1>
<p>Every bean deployed in OpenEJB has a unique deployment-id that identifies
it within the scope of the entire container system. The server and
container system refer beans at run-time using the bean's deployment id.</p>
<p><a name="DeploymentID-Likeejb-name"></a></p>
<h2>Like ejb-name</h2>
<p>This deployment id is much like the <ejb-name> element of the ejb-jar.xml ,
with one very important difference. The <ejb-name> is only required to be
unique within the scope of the ejb-jar.xml in the bean's jar. The
deployment id is required to be unique across all beans and jars in
OpenEJB. This is a subtle, but important, distinction.</p>
<p>Remember that the EJB specification was designed so that enterprise beans
could be create, packaged, and sold by vendors (EJB Providers).
Furthermore, users should be able to buy a packaged set of beans (a jar
with an ejb-jar.xml in it) and deploy it into an EJB Container without
modification.</p>
<p><a name="DeploymentID-Theejb-nameisnotunique"></a></p>
<h2>The ejb-name is not unique</h2>
<p>Let's consider this, what happens if two vendors each sell a package (jar)
that contains a bean with the <ejb-name> PurchaseOrder? Both are completely
different in terms functionality and are different beans in every other
respect. The EJB spec says, this is fine, ejb-names only have to unique
within the jar and that jar's ejb-jar.xml file. It's ridiculous to expect
EJB Providers to call each other up and ask, "Are you already using the
name 'PurchaseOrder' in your jar?" Remember that the EJB specification was
designed so that enterprise beans could be create, packaged, and sold by
vendors (EJB Providers). Furthermore, users should be able to buy a
packaged set of beans (a jar with an ejb-jar.xml in it) and deploy it into
an EJB Container without modification. This is all fine and dandy, but it
still leaves it up to the EJB Container/Server providers to settle the
difference.</p>
<p><a name="DeploymentID-Thedeployment-idisunique"></a></p>
<h2>The deployment-id is unique</h2>
<p>OpenEJB solves this with the OpenEJB-specific deployment id. By requiring
that each bean deployed into OpenEJB has a unique name, we can guarantee
that we are always referring to the right bean at all times. Furthermore, it
allows you to deploy different versions of the same package several times
in the same container system, each time giving the beans new deployment
ids.</p>
<p><a name="DeploymentID-Usingejb-nameasdeployment-idanyway"></a></p>
<h2>Using ejb-name as deployment-id anyway</h2>
<p>If you're lazy -- as any truly great programmer should be -- and don't want
to type a deployment id for each bean every time you deploy a jar, you can
use the -D option of the Deploy Tool. This will throw caution to the wind,
and automatically assign the bean's ejb-name as the value of the bean's
OpenEJB deployment id. This leaves up to you to guarantee that bean's
ejb-name will be unique across all beans and jars in the container system.
In other words, be very careful with the -D option!</p>
<p><a name="DeploymentID-Howisitused?"></a></p>
<h1>How is it used?</h1>
<p><a name="DeploymentID-Inthecontainersystem"></a></p>
<h2>In the container system</h2>
<p>In the container system, the deployment id is used to index the bean in a
system-wide registry. This registry is refereed to on every call made in the
container system. Being able to safely hash and cache bean information by
id is a must. This stresses the importance of unique ids for every bean
deployed in OpenEJB.</p>
<p><a name="DeploymentID-IntheLocalServer"></a></p>
<h2>In the Local Server</h2>
<p>The Local (IntraVM) Server is an integral part of the container system and
the two are, in many ways, inseparable. The Local Server takes care of all
bean to bean and client to bean invocations made inside the virtual
machine. For this reason, it often refered to as the IntraVM Server.</p>
<p>For bean to bean communications, the Local Server must create a JNDI
namespace (JNDI ENC) for each bean as defined by the bean's <env-entry>,
<ejb-ref>, and <resource-ref> elements of the bean's ejb-jar.xml file.
Every bean literally gets its very own JNDI namespace. When a bean makes a
JNDI call, the Local Server intercepts this call and uses the deployment id
of the calling bean to retrieve that bean's private JNDI namespace from the
container system's index. The Local Server then carries out the lookup on
that bean's namespace.</p>
<p>All non-bean clients share one big global namespace. Since non-bean clients
are not deployed and do not have a deployment descriptor like an
ejb-jar.xml, the Local Server is unable to taylor a namespace for each
non-bean client as it can for bean clients. The Local server cannot
identify non-bean clients as they have no deployment id. All JNDI calls
made by clients that the Local Server cannot identify go to the public,
global namespace. The public, global JNDI namespace contains all beans and
resources in the container system. name.</p>
<p>Each bean is added to the public, global namespace using it's deployment id
as its JNDI lookup. For example, if a bean had a deployment-id of
"/my/bean/foo", a non-bean client could lookup that bean as follows.</p>
<pre><code>...
Object bean = initialContext.lookup("/my/bean/Foo");
...
</code></pre>
<p>If a bean in the container system made the above JNDI call, the Local
Server would see the bean's identity (deployment id) hidden in the Thread,
go get the bean's private JNDI namespace and finish the lookup on that.
Since all names in bean's JNDI namespace are required start with
"java:comp/env", the lookup would fail and the bean would receive a
javax.naming.NameNotFoundException.</p>
<p>In short...</p>
<p>For beans:
- Each bean has it's own private, personalized JNDI namespace
- The names in it are the same names it uses in its ejb-jar.xml
- Beans can only access their private namespace, period</p>
<p>For non-beans (everyone else):
- Non-bean clients share the public, global JNDI namespace
- The names in it are the deployment ids of all the beans
- Non-bean clients can only access the one global namespace</p>
<p><a name="DeploymentID-IntheRemoteServer"></a></p>
<h2>In the Remote Server</h2>
<p>The Remote Server has a public, global namespace just as the Local Server
does. The difference being that the Remote Server only serves clients
outside the container system and outside the virtual machine. So, all
clients from the perspective of the Remote Server are non-bean clients. As
a result, the Remote Server only has the one public, global JNDI namespace.
Just as in the Local Server, the names in this namespace consist of the
deployment ids of the beans in the container system.</p>
<p>Just as before, clients can lookup beans from the Remote Server using the
bean's deployment id. For example, if a bean had a deployment-id of
"/my/bean/foo", a client could lookup that bean as follows.</p>
<pre><code>...
Object bean = initialContext.lookup("/my/bean/Foo");
...
</code></pre>
<p><a name="DeploymentID-IntheCORBAAdapter"></a></p>
<h2>In the CORBA Adapter</h2>
<p>The CORBA Adapter is separate than the Remote Server. It adapts the OpenEJB
Container System and the Local Server into OpenORB as an embedded library.
It provides users of OpenORB the ability to lookup and execute beans (EJBs)
via the RMI-IIOP protocol. All the EJBHome and EJBObject interfaces of
beans in OpenEJB are implemented by OpenORB as CORBA stubs and ties.</p>
<p>The beans are exported into OpenORB's naming service by deployment id. So,
just as with the Local Server and Remote Server, clients can lookup beans
using the bean's deployment id. OpenORB has a JNDI implementation of their
naming service, so lookups can be done just as before.</p>
<pre><code>...
String[] args = ...
// The ORB and Object
org.omg.CORBA.ORB orb = null;
org.omg.CORBA.Object bean = null.
// The Naming Service and Object Name
org.omg.CosNaming.NamingContext context = null;
org.omg.CosNaming.NameComponent[] name = null;
// Get the ORB
orb = org.omg.CORBA.ORB.init( args, null );
// Get the Naming Service
org.omg.CORBA.Object ref = null;
ref = orb.resolve_initial_references("NameService");
context = org.omg.CosNaming.NamingContextHelper.narrow( ref );
// Get the Name as a component
// Note: the string is the bean's deployment id
name = new org.omg.CosNaming.NameComponent[ 1 ];
name[0] = new org.omg.CosNaming.NameComponent("/my/bean/foo","");
// Finally, get the bean as a CORBA object
// Equvalent to an InitialContext.lookup("/my/bean/foo");
bean = context.resolve( name );
...
</code></pre>
<p><a name="DeploymentID-WhathappensifthereisaduplicatedeploymentID?"></a></p>
<h1>What happens if there is a duplicate deployment ID?</h1>
<p>The deployment ID uniquely identifies the bean in the OpenEJB container
system. Therefore, no two beans can share the same deployment ID.</p>
<p>If a bean attempts to use a deployment ID that is already in use by another
bean, the second bean and all beans in it's jar will not be loaded. In
addition, the system will log a warning like the following one asking you
to redeploy the jar and choose an different deployment ID for the bean.</p>
<pre><code>WARN : Jar C:\openejb\beans\fooEjbs.jar cannot be loaded. The Deployment ID "/my/bean/foo" is already in use. Please redeploy this jar and assign a different deployment ID to the bean with the ejb-name "FooBean".
</code></pre>
<p>For example, the acmeEjbs.jar contains a bean with the ejb-name
"DaffyDuckBean". The disneyEjbs.jar contains contains a bean with the
ejb-name "DonaldDuckBean".</p>
<p>We deploy the acmeEjbs.jar and give the "DaffyDuckBean" the deployment ID
of "/my/favorite/duck". Sometime afterwards, we deploy the disneyEjbs.jar
and assign the "DonaldDuckBean" the deployment ID "/my/favorite/duck",
having forgotten that we already gave that unique ID to the "DaffyDuckBean"
in the acmeEjbs.jar.</p>
<p>When the container system is started, the system will begin loading all the
beans one jar at a time. It will first load the acmeEjbs.jar and index each
bean by deployment ID. But, when the system reaches the disneyEjbs.jar, it
will discover that it cannot index the "DonaldDuckBean" using the
deployment ID "/my/favorite/duck" because that index is already taken.</p>
<p>The system cannot load the "DonaldDuckBean" and must also ignore the rest
of the beans in the disneyEjbs.jar as they may need the "DonaldDuckBean"
bean to function properly. The disneyEjbs.jar is skipped and the following
warning is logged.</p>
<pre><code>WARN : Jar C:\openejb\beans\disneyEjbs.jar cannot be loaded. The Deployment ID "/my/favorite/duck" is already in use. Please redeploy this jar and assign a different deployment ID to the bean with the ejb-name "DonaldDuckBean".
</code></pre>
<div id="edit" class="modal hide fade in" style="display: none; ">
<div class="modal-header">
<a class="close" data-dismiss="modal">x</a>
<h3>Thank you for contributing to the documentation!</h3>
</div>
<div class="modal-body">
<h4>Any help with the documentation is greatly appreciated.</h4>
<p>All edits are reviewed before going live, so feel free to do much more than fix typos or links. If you see a page that could benefit from an entire rewrite, we'd be thrilled to review it. Don't be surprised if we like it so much we ask you for help with other pages :)</p>
<small>NOTICE: unless indicated otherwise on the pages in question, all editable content available from apache.org is presumed to be licensed under the Apache License (AL) version 2.0 and hence all submissions to apache.org treated as formal Contributions under the license terms.</small>
<!--[if gt IE 6]>
<h4>Internet Explorer Users</h4>
<p>If you are not an Apache committer, click the Yes link and enter a <i>anonymous</i> for the username and leave the password empty</p>
<![endif]-->
</div>
<div class="modal-footer">
Do you have an Apache ID?
<a href="javascript:void(location.href='https://cms.apache.org/redirect?uri='+escape(location.href))" class="btn">Yes</a>
<a href="javascript:void(location.href='https://anonymous:@cms.apache.org/redirect?uri='+escape(location.href))" class="btn">No</a>
</div>
</div>
<script src="./resources/js/bootstrap-modal.js"></script>
<footer>
<p>Copyright &copy; 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation.
All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
</footer>
</div> <!-- /container -->
<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./resources/js/bootstrap-dropdown.js"></script>
</body>
</html>