Author: julien(a)jboss.com
Date: 2007-08-17 06:17:39 -0400 (Fri, 17 Aug 2007)
New Revision: 7970
Added:
branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/as/JNDIBinder.java
Modified:
branches/JBoss_Portal_Branch_2_6/build/ide/intellij/idea60/modules/identity/identity.iml
Log:
added a JNDIBinder service that will be used to decouple the identity module from the jems
module
Modified:
branches/JBoss_Portal_Branch_2_6/build/ide/intellij/idea60/modules/identity/identity.iml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/build/ide/intellij/idea60/modules/identity/identity.iml 2007-08-17
09:29:00 UTC (rev 7969)
+++
branches/JBoss_Portal_Branch_2_6/build/ide/intellij/idea60/modules/identity/identity.iml 2007-08-17
10:17:39 UTC (rev 7970)
@@ -137,6 +137,15 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss-portal/modules/common/lib/portal-common-lib.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Added:
branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/as/JNDIBinder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/as/JNDIBinder.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/as/JNDIBinder.java 2007-08-17
10:17:39 UTC (rev 7970)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.portal.jems.as;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * A service that binds an injected service to the JNDI registry.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JNDIBinder extends AbstractJBossService
+{
+
+ /** The jndi name. */
+ private String jndiName;
+
+ /** The injected service that will be bound. */
+ private Object targetObject;
+
+ /** The jndi binding object. */
+ private JNDI.Binding jndiBinding;
+
+ public String getJNDIName()
+ {
+ return jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Object getTargetObject()
+ {
+ return targetObject;
+ }
+
+ public void setTargetObject(Object targetObject)
+ {
+ this.targetObject = targetObject;
+ }
+
+ protected void createService() throws Exception
+ {
+ if (jndiName == null)
+ {
+ throw new IllegalStateException("No jndi name provided");
+ }
+ }
+
+ protected void startService() throws Exception
+ {
+ if (targetObject == null)
+ {
+ throw new IllegalStateException("No target object to bind");
+ }
+
+ //
+ log.debug("About to bind service" + targetObject + " to JNDI with
name " + jndiName);
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ log.debug("Service" + targetObject + " bound to JNDI with name
" + jndiName);
+ }
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+}