Author: ALRubinger
Date: 2009-05-19 14:30:58 -0400 (Tue, 19 May 2009)
New Revision: 10067
Modified:
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java
Log:
[JBWS-2652] Upgrade jbossws-common AbstractServerConfig to new jboss-bootstrap SPIs
Modified:
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java
===================================================================
---
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java 2009-05-19
12:39:00 UTC (rev 10066)
+++
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java 2009-05-19
18:30:58 UTC (rev 10067)
@@ -23,6 +23,8 @@
import java.io.File;
import java.net.InetAddress;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.net.UnknownHostException;
import java.util.Set;
@@ -45,6 +47,12 @@
public abstract class AbstractServerConfig implements AbstractServerConfigMBean,
ServerConfig
{
private static final Logger log = Logger.getLogger(AbstractServerConfig.class);
+
+ protected static final ObjectName OBJECT_NAME_SERVER_CONFIG;
+ static
+ {
+ OBJECT_NAME_SERVER_CONFIG =
ObjectNameFactory.create("jboss.system:type=ServerConfig");
+ }
// The MBeanServer
private MBeanServer mbeanServer;
@@ -110,44 +118,56 @@
public File getServerTempDir()
{
- try
- {
- ObjectName oname =
ObjectNameFactory.create("jboss.system:type=ServerConfig");
- File dir = (File)getMbeanServer().getAttribute(oname,
"ServerTempDir");
- return dir;
- }
- catch (JMException e)
- {
- return null;
- }
+ return this.getDirFromServerConfig("ServerTempLocation");
}
public File getHomeDir()
{
+ return this.getDirFromServerConfig("JBossHome");
+ }
+
+ public File getServerDataDir()
+ {
+ return this.getDirFromServerConfig("ServerDataLocation");
+ }
+
+ /**
+ * Obtains the specified attribute from the server configuration,
+ * represented as a {@link File}.
+ *
+ * @param attributeName
+ * @return
+ * @author ALR
+ */
+ protected File getDirFromServerConfig(final String attributeName)
+ {
+ // Define the ON to invoke upon
+ final ObjectName on = OBJECT_NAME_SERVER_CONFIG;
+
+ // Get the URL location
+ URL location = null;
try
{
- ObjectName oname =
ObjectNameFactory.create("jboss.system:type=ServerConfig");
- File dir = (File)getMbeanServer().getAttribute(oname, "HomeDir");
- return dir;
+ location = (URL) getMbeanServer().getAttribute(on, attributeName);
}
- catch (JMException e)
+ catch (final JMException e)
{
- return null;
+ throw new RuntimeException("Could not obtain attribute " +
attributeName + " from " + on, e);
}
- }
- public File getServerDataDir()
- {
+ // Represent as a File
+ File dir = null;
try
{
- ObjectName oname =
ObjectNameFactory.create("jboss.system:type=ServerConfig");
- File dir = (File)getMbeanServer().getAttribute(oname,
"ServerDataDir");
- return dir;
+ dir = new File(location.toURI());
}
- catch (JMException e)
+ catch (final URISyntaxException urise)
{
- return null;
+ throw new RuntimeException("Could not desired directory from URL: " +
location, urise);
}
+
+ // Return
+ return dir;
}
public int getWebServicePort()
Show replies by date