Author: julien(a)jboss.com
Date: 2007-03-17 20:50:12 -0400 (Sat, 17 Mar 2007)
New Revision: 6728
Added:
trunk/jems/src/main/org/jboss/portal/jems/as/JMX.java
trunk/jems/src/main/org/jboss/portal/jems/as/JNDI.java
Removed:
trunk/common/src/main/org/jboss/portal/common/util/JMX.java
trunk/common/src/main/org/jboss/portal/common/util/JNDI.java
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/cache/CMSTreeCacheServiceImpl.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationManagerImpl.java
trunk/common/build.xml
trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java
trunk/jems/src/main/org/jboss/portal/jems/as/system/LifeCycleAdapter.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
Log:
moved classes from common package depending on jboss as libs to the JEMS package
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/cache/CMSTreeCacheServiceImpl.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/cache/CMSTreeCacheServiceImpl.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/cache/CMSTreeCacheServiceImpl.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -28,7 +28,7 @@
import org.jboss.portal.cms.impl.CMSCacheException;
import org.jboss.portal.cms.impl.CMSTreeCacheService;
import org.jboss.portal.cms.model.File;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import java.util.Locale;
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-03-18 00:31:41 UTC
(rev 6727)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2007-03-18 00:50:12 UTC
(rev 6728)
@@ -46,7 +46,7 @@
import org.jboss.portal.common.net.URLVisitor;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.XML;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.IdentityServiceController;
Modified: trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationManagerImpl.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationManagerImpl.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationManagerImpl.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -25,13 +25,13 @@
import javax.security.auth.Subject;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.cms.impl.jcr.command.ACLEnforcer;
-import org.jboss.portal.common.util.JNDI;
/**
* Created on : Jan 23, 2007
Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml 2007-03-18 00:31:41 UTC (rev 6727)
+++ trunk/common/build.xml 2007-03-18 00:50:12 UTC (rev 6728)
@@ -64,11 +64,17 @@
<!-- Configure thirdparty libraries -->
&libraries;
+
+ <path id="jbossas_restriction">
+ <pathelement
location="${jbossas/core.libs.lib}/jboss-jmx.jar"/>
+ <pathelement
location="${jbossas/core.libs.lib}/jboss-j2ee.jar"/>
+ </path>
+
<path id="library.classpath">
<path refid="sun.jaf.classpath"/>
<path refid="sun.servlet.classpath"/>
<path refid="oswego.concurrent.classpath"/>
- <path refid="jbossas/core.libs.classpath"/>
+ <path refid="jbossas_restriction"/>
<path refid="apache.ant.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="jboss.test.classpath"/>
Modified:
trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/common/src/main/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.net.URLNavigationProvider;
import org.jboss.portal.common.net.URLVisitor;
-import org.jboss.logging.Logger;
+import org.apache.log4j.Logger;
import java.util.Arrays;
import java.net.URL;
@@ -42,7 +42,7 @@
private Logger log = Logger.getLogger(FileURLNavigationProvider.class);
/** Trace. */
- private boolean trace = log.isTraceEnabled();
+ private boolean trace = log.isDebugEnabled();
public void visit(URL url, URLVisitor visitor) throws IllegalArgumentException,
IOException
{
@@ -57,7 +57,7 @@
{
if (trace)
{
- log.trace("entering directory" + file.getAbsolutePath());
+ log.debug("entering directory" + file.getAbsolutePath());
}
visitor.startDir(file.toURL(), name);
File[] childrenFiles = file.listFiles();
@@ -70,14 +70,14 @@
visitor.endDir(file.toURL(), name);
if (trace)
{
- log.trace("leaving directory" + file.getAbsolutePath());
+ log.debug("leaving directory" + file.getAbsolutePath());
}
}
else
{
if (trace)
{
- log.trace("visiting file " + file.getAbsolutePath());
+ log.debug("visiting file " + file.getAbsolutePath());
}
URL url = file.toURL();
File file2 = new File(url.getFile());
@@ -87,7 +87,7 @@
}
else if (trace)
{
- log.trace("The file does not respect url format");
+ log.debug("The file does not respect url format");
}
}
}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/JMX.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/JMX.java 2007-03-18 00:31:41 UTC
(rev 6727)
+++ trunk/common/src/main/org/jboss/portal/common/util/JMX.java 2007-03-18 00:50:12 UTC
(rev 6728)
@@ -1,199 +0,0 @@
-/******************************************************************************
- * 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.common.util;
-
-import org.apache.log4j.Logger;
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanProxyCreationException;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.mx.util.ObjectNameConverter;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import java.util.Comparator;
-import java.util.Hashtable;
-import java.util.Properties;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public final class JMX
-{
-
- private static final Logger log = Logger.getLogger(JMX.class);
-
- public static ObjectName extend(ObjectName name, Properties keyProperties)
- {
- try
- {
- Hashtable table = name.getKeyPropertyList();
- table.putAll(keyProperties);
- return ObjectNameConverter.convert(name.getDomain(), table);
- }
- catch (MalformedObjectNameException e)
- {
- log.error("", e);
- throw new RuntimeException();
- }
- }
-
- /**
- * ObjectName comparator based on canonical name lexicography.
- */
- public static Comparator OBJECT_NAME_COMPARATOR = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- ObjectName n1 = (ObjectName)o1;
- ObjectName n2 = (ObjectName)o2;
- return n1.getCanonicalName().compareTo(n2.getCanonicalName());
- }
- };
-
- public static void safeUnregister(MBeanServer server, ObjectName name)
- {
- if (server != null)
- {
- if (name != null)
- {
- try
- {
- server.unregisterMBean(name);
- }
- catch (InstanceNotFoundException e)
- {
- log.error("MBean " + name + " nto here");
- }
- catch (MBeanRegistrationException e)
- {
- log.error("MBean threw an exception during unregistration",
e.getTargetException());
- }
- }
- else
- {
- log.error("Cannot unregister a null MBean");
- }
- }
- else
- {
- log.error("Cannot unregister with a null MBeanServer");
- }
- }
-
- /**
- * Retrieves the MBeanProxy associated with the given class and name from the
specified MBeanServer.
- *
- * @param clazz the interface implemented by the MBean which is to be retrieved
- * @param name the MBean's ObjectName
- * @param server the MBeanServer from which to retrieve the MBeanProxy
- * @return a MBeanProxy for the specified MBean if it exists
- * @throws RuntimeException if the MBean couldn't be retrieved
- */
- public static Object getMBeanProxy(Class clazz, ObjectName name, MBeanServer server)
- {
- try
- {
- return MBeanProxy.get(clazz, name, server);
- }
- catch (MBeanProxyCreationException e)
- {
- String message = "Couldn't retrieve '" +
name.getCanonicalName() + "' MBean with class " + clazz.getName();
- log.error(message, e);
- throw new RuntimeException(message, e);
- }
- }
-
- /**
- * Retrieves the MBeanProxy associated with the given class and name from the JBoss
microkernel as returned by
- * <code>MBeanServerLocator.locateJBoss()</code>.
- *
- * @param clazz the interface implemented by the MBean which is to be retrieved
- * @param name a String representation of the MBean's ObjectName
- * @return a MBeanProxy for the specified MBean if it exists
- * @throws IllegalArgumentException if the given name is not a valid ObjectName
- * @throws RuntimeException if the MBean couldn't be retrieved
- * @see #getMBeanProxy(Class, javax.management.ObjectName,
javax.management.MBeanServer)
- * @since 2.4
- */
- public static Object getMBeanProxy(Class clazz, String name)
- {
- ObjectName objecName;
- try
- {
- objecName = new ObjectName(name);
- }
- catch (MalformedObjectNameException e)
- {
- throw new IllegalArgumentException("'" + name + "' is not
a valid ObjectName");
- }
- MBeanServer server = MBeanServerLocator.locateJBoss();
- return getMBeanProxy(clazz, objecName, server);
- }
-
- public static boolean addNotificationListener(
- MBeanServer server,
- ObjectName name,
- NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- {
- try
- {
- server.addNotificationListener(name, listener, filter, handback);
- return true;
- }
- catch (InstanceNotFoundException e)
- {
- return false;
- }
- }
-
- public static boolean removeNotificationListener(
- MBeanServer server,
- ObjectName name,
- NotificationListener listener)
- {
- try
- {
- server.removeNotificationListener(name, listener);
- return true;
- }
- catch (InstanceNotFoundException e)
- {
- log.error("Cannot remove notification listener", e);
- return false;
- }
- catch (ListenerNotFoundException e)
- {
- log.error("Cannot remove notification listener", e);
- return false;
- }
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/JNDI.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/JNDI.java 2007-03-18 00:31:41 UTC
(rev 6727)
+++ trunk/common/src/main/org/jboss/portal/common/util/JNDI.java 2007-03-18 00:50:12 UTC
(rev 6728)
@@ -1,126 +0,0 @@
-/******************************************************************************
- * 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.common.util;
-
-import org.jboss.util.naming.NonSerializableFactory;
-
-import javax.naming.CompositeName;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-/**
- * Various JNDI stuff.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class JNDI
-{
-
- /**
- * Encapsulate JNDI binding operation into one single class, hidding non usefull JNDI
complexity.
- * It has been designed to fit with service life cycle.
- *
- * <code>
- *
- * private String jndiName;
- * private JNDI.Binding jndiBinding;
- *
- * public void startService() throws Exception
- * {
- * ...
- * if (this.jndiName != null)
- * {
- * jndiBinding = new JNDI.Binding(jndiName, this);
- * jndiBinding.bind();
- * }
- * ...
- * }
- *
- * public void stopService() throws Exception
- * {
- * ...
- * if (jndiBinding != null)
- * {
- * jndiBinding.unbind();
- * jndiBinding = null;
- * }
- * ...
- * }
- * </code>
- */
- public static class Binding
- {
-
- /** . */
- private final String jndiName;
-
- /** . */
- private String unbindJNDIName;
-
- /** . */
- private Object o;
-
- public Binding(String jndiName, Object o)
- {
- if (jndiName == null)
- {
- throw new IllegalArgumentException("No JNDI name provided");
- }
- if (o == null)
- {
- throw new IllegalArgumentException("No object to bind for JNDI name
" + jndiName);
- }
- this.jndiName = jndiName;
- this.o = o;
- }
-
- /**
- * Attempt to perform binding.
- *
- * @throws NamingException on failure
- */
- public void bind() throws NamingException
- {
- NonSerializableFactory.rebind(new CompositeName(jndiName), o, true);
- unbindJNDIName = jndiName;
- }
-
- /**
- * Unbinds in a safe manner.
- */
- public void unbind()
- {
- if (unbindJNDIName != null)
- {
- try
- {
- NonSerializableFactory.unbind(unbindJNDIName);
- }
- catch (NameNotFoundException ignore)
- {
- }
- }
- }
- }
-}
Modified: trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java 2007-03-18
00:31:41 UTC (rev 6727)
+++ trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -22,17 +22,15 @@
******************************************************************************/
package org.jboss.portal.common.util;
-import org.jboss.logging.Logger;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import org.apache.log4j.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.Properties;
/**
Modified: trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2007-03-18
00:31:41 UTC (rev 6727)
+++ trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.common.util;
-import org.jboss.logging.Logger;
+import org.apache.log4j.Logger;
import java.util.Collections;
import java.util.HashMap;
@@ -297,9 +297,9 @@
}
catch (IllegalArgumentException e)
{
- if (log.isTraceEnabled())
+ if (log.isDebugEnabled())
{
- log.warn("Invalid desired locale " + desiredLocale);
+ log.debug("Invalid desired locale " + desiredLocale);
}
}
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -23,7 +23,7 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.jems.as.system.JBossServiceModelMBean;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.identity.IdentityContextImpl;
Modified:
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -21,7 +21,7 @@
*/
package org.jboss.portal.identity.config;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.identity.IdentityConfiguration;
import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.jems.as.system.AbstractJBossService;
Modified:
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -25,14 +25,13 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.identity.service.IdentityModuleService;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.InitialContext;
import javax.naming.ldap.InitialLdapContext;
import java.util.Hashtable;
-import java.util.Map;
/**
* Keeps configuration of connection to LDAP server
Modified:
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -23,7 +23,7 @@
import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.identity.IdentityConfiguration;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.event.IdentityEventBroadcaster;
import org.jboss.portal.jems.as.system.AbstractJBossService;
Copied: trunk/jems/src/main/org/jboss/portal/jems/as/JMX.java (from rev 6720,
trunk/common/src/main/org/jboss/portal/common/util/JMX.java)
===================================================================
--- trunk/jems/src/main/org/jboss/portal/jems/as/JMX.java (rev 0)
+++ trunk/jems/src/main/org/jboss/portal/jems/as/JMX.java 2007-03-18 00:50:12 UTC (rev
6728)
@@ -0,0 +1,199 @@
+/******************************************************************************
+ * 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.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanProxyCreationException;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.mx.util.ObjectNameConverter;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import java.util.Comparator;
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public final class JMX
+{
+
+ private static final Logger log = Logger.getLogger(JMX.class);
+
+ public static ObjectName extend(ObjectName name, Properties keyProperties)
+ {
+ try
+ {
+ Hashtable table = name.getKeyPropertyList();
+ table.putAll(keyProperties);
+ return ObjectNameConverter.convert(name.getDomain(), table);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ log.error("", e);
+ throw new RuntimeException();
+ }
+ }
+
+ /**
+ * ObjectName comparator based on canonical name lexicography.
+ */
+ public static Comparator OBJECT_NAME_COMPARATOR = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ ObjectName n1 = (ObjectName)o1;
+ ObjectName n2 = (ObjectName)o2;
+ return n1.getCanonicalName().compareTo(n2.getCanonicalName());
+ }
+ };
+
+ public static void safeUnregister(MBeanServer server, ObjectName name)
+ {
+ if (server != null)
+ {
+ if (name != null)
+ {
+ try
+ {
+ server.unregisterMBean(name);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.error("MBean " + name + " nto here");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ log.error("MBean threw an exception during unregistration",
e.getTargetException());
+ }
+ }
+ else
+ {
+ log.error("Cannot unregister a null MBean");
+ }
+ }
+ else
+ {
+ log.error("Cannot unregister with a null MBeanServer");
+ }
+ }
+
+ /**
+ * Retrieves the MBeanProxy associated with the given class and name from the
specified MBeanServer.
+ *
+ * @param clazz the interface implemented by the MBean which is to be retrieved
+ * @param name the MBean's ObjectName
+ * @param server the MBeanServer from which to retrieve the MBeanProxy
+ * @return a MBeanProxy for the specified MBean if it exists
+ * @throws RuntimeException if the MBean couldn't be retrieved
+ */
+ public static Object getMBeanProxy(Class clazz, ObjectName name, MBeanServer server)
+ {
+ try
+ {
+ return MBeanProxy.get(clazz, name, server);
+ }
+ catch (MBeanProxyCreationException e)
+ {
+ String message = "Couldn't retrieve '" +
name.getCanonicalName() + "' MBean with class " + clazz.getName();
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ /**
+ * Retrieves the MBeanProxy associated with the given class and name from the JBoss
microkernel as returned by
+ * <code>MBeanServerLocator.locateJBoss()</code>.
+ *
+ * @param clazz the interface implemented by the MBean which is to be retrieved
+ * @param name a String representation of the MBean's ObjectName
+ * @return a MBeanProxy for the specified MBean if it exists
+ * @throws IllegalArgumentException if the given name is not a valid ObjectName
+ * @throws RuntimeException if the MBean couldn't be retrieved
+ * @see #getMBeanProxy(Class, javax.management.ObjectName,
javax.management.MBeanServer)
+ * @since 2.4
+ */
+ public static Object getMBeanProxy(Class clazz, String name)
+ {
+ ObjectName objecName;
+ try
+ {
+ objecName = new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new IllegalArgumentException("'" + name + "' is not
a valid ObjectName");
+ }
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ return getMBeanProxy(clazz, objecName, server);
+ }
+
+ public static boolean addNotificationListener(
+ MBeanServer server,
+ ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object handback)
+ {
+ try
+ {
+ server.addNotificationListener(name, listener, filter, handback);
+ return true;
+ }
+ catch (InstanceNotFoundException e)
+ {
+ return false;
+ }
+ }
+
+ public static boolean removeNotificationListener(
+ MBeanServer server,
+ ObjectName name,
+ NotificationListener listener)
+ {
+ try
+ {
+ server.removeNotificationListener(name, listener);
+ return true;
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.error("Cannot remove notification listener", e);
+ return false;
+ }
+ catch (ListenerNotFoundException e)
+ {
+ log.error("Cannot remove notification listener", e);
+ return false;
+ }
+ }
+}
Property changes on: trunk/jems/src/main/org/jboss/portal/jems/as/JMX.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/jems/src/main/org/jboss/portal/jems/as/JNDI.java (from rev 6720,
trunk/common/src/main/org/jboss/portal/common/util/JNDI.java)
===================================================================
--- trunk/jems/src/main/org/jboss/portal/jems/as/JNDI.java (rev
0)
+++ trunk/jems/src/main/org/jboss/portal/jems/as/JNDI.java 2007-03-18 00:50:12 UTC (rev
6728)
@@ -0,0 +1,126 @@
+/******************************************************************************
+ * 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.util.naming.NonSerializableFactory;
+
+import javax.naming.CompositeName;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * Various JNDI stuff.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class JNDI
+{
+
+ /**
+ * Encapsulate JNDI binding operation into one single class, hidding non usefull JNDI
complexity.
+ * It has been designed to fit with service life cycle.
+ *
+ * <code>
+ *
+ * private String jndiName;
+ * private JNDI.Binding jndiBinding;
+ *
+ * public void startService() throws Exception
+ * {
+ * ...
+ * if (this.jndiName != null)
+ * {
+ * jndiBinding = new JNDI.Binding(jndiName, this);
+ * jndiBinding.bind();
+ * }
+ * ...
+ * }
+ *
+ * public void stopService() throws Exception
+ * {
+ * ...
+ * if (jndiBinding != null)
+ * {
+ * jndiBinding.unbind();
+ * jndiBinding = null;
+ * }
+ * ...
+ * }
+ * </code>
+ */
+ public static class Binding
+ {
+
+ /** . */
+ private final String jndiName;
+
+ /** . */
+ private String unbindJNDIName;
+
+ /** . */
+ private Object o;
+
+ public Binding(String jndiName, Object o)
+ {
+ if (jndiName == null)
+ {
+ throw new IllegalArgumentException("No JNDI name provided");
+ }
+ if (o == null)
+ {
+ throw new IllegalArgumentException("No object to bind for JNDI name
" + jndiName);
+ }
+ this.jndiName = jndiName;
+ this.o = o;
+ }
+
+ /**
+ * Attempt to perform binding.
+ *
+ * @throws NamingException on failure
+ */
+ public void bind() throws NamingException
+ {
+ NonSerializableFactory.rebind(new CompositeName(jndiName), o, true);
+ unbindJNDIName = jndiName;
+ }
+
+ /**
+ * Unbinds in a safe manner.
+ */
+ public void unbind()
+ {
+ if (unbindJNDIName != null)
+ {
+ try
+ {
+ NonSerializableFactory.unbind(unbindJNDIName);
+ }
+ catch (NameNotFoundException ignore)
+ {
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/jems/src/main/org/jboss/portal/jems/as/JNDI.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/jems/src/main/org/jboss/portal/jems/as/system/LifeCycleAdapter.java
===================================================================
--- trunk/jems/src/main/org/jboss/portal/jems/as/system/LifeCycleAdapter.java 2007-03-18
00:31:41 UTC (rev 6727)
+++ trunk/jems/src/main/org/jboss/portal/jems/as/system/LifeCycleAdapter.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -26,7 +26,7 @@
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanProxyCreationException;
import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.portal.common.util.JMX;
+import org.jboss.portal.jems.as.JMX;
import org.jboss.system.ServiceController;
import org.jboss.system.ServiceControllerMBean;
import org.jboss.system.ServiceMBean;
Modified: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2007-03-18
00:31:41 UTC (rev 6727)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -35,7 +35,7 @@
import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.common.util.Tools;
import org.jbpm.JbpmContext;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java 2007-03-18
00:31:41 UTC (rev 6727)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/endpoints/WSRPBaseEndpoint.java 2007-03-18
00:50:12 UTC (rev 6728)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp.endpoints;
-import org.jboss.portal.common.util.JMX;
+import org.jboss.portal.jems.as.JMX;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPProducer;