Author: jim.ma
Date: 2015-03-10 05:02:23 -0400 (Tue, 10 Mar 2015)
New Revision: 19547
Added:
common/branches/management/src/main/java/org/jboss/ws/common/utils/RuntimeConfigUtils.java
Modified:
common/branches/management/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java
common/branches/management/src/main/java/org/jboss/ws/common/deployment/DefaultHttpEndpoint.java
common/branches/management/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
common/branches/management/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java
Log:
[JBWS-3880]Add apis to allow get all configurations and runtime properties from Endpoint
Modified:
common/branches/management/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java
===================================================================
---
common/branches/management/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java 2015-03-10
09:02:06 UTC (rev 19546)
+++
common/branches/management/src/main/java/org/jboss/ws/common/deployment/AbstractDefaultEndpoint.java 2015-03-10
09:02:23 UTC (rev 19547)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2015, 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.
*
@@ -21,8 +21,10 @@
*/
package org.jboss.ws.common.deployment;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.management.MalformedObjectNameException;
@@ -45,12 +47,15 @@
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointMetrics;
import org.jboss.wsf.spi.metadata.config.EndpointConfig;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
import org.jboss.wsf.spi.security.SecurityDomainContext;
/**
* A general abstract JAXWS endpoint.
*
* @author Thomas.Diesler(a)jboss.com
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
* @since 20-Apr-2007
*/
public class AbstractDefaultEndpoint extends AbstractExtensible
@@ -72,6 +77,7 @@
protected volatile SecurityDomainContext securityDomainContext;
protected volatile InstanceProvider instanceProvider;
protected volatile EndpointConfig endpointConfig;
+ protected Map<String, String> configsMap = new HashMap<String,
String>(64);
AbstractDefaultEndpoint(String targetBean)
{
@@ -100,6 +106,7 @@
{
assertEndpointSetterAccess();
this.targetBean = targetBean;
+ configsMap.put(Endpoint.TARGETBEAN, targetBean);
}
public synchronized Class<?> getTargetBeanClass()
@@ -146,6 +153,7 @@
{
assertEndpointSetterAccess();
this.name = name;
+ configsMap.put(Endpoint.NAME, name.toString());
}
public String getShortName()
@@ -157,6 +165,7 @@
{
assertEndpointSetterAccess();
this.shortName = shortName;
+ configsMap.put(Endpoint.SHORTNAME, shortName);
}
@@ -178,6 +187,7 @@
public void setType(EndpointType type)
{
this.type = type;
+ configsMap.put(Endpoint.TYPE, type.name());
}
public RequestHandler getRequestHandler()
@@ -189,6 +199,7 @@
{
assertEndpointSetterAccess();
this.requestHandler = handler;
+ configsMap.put(Endpoint.REQUESTHANDLER, handler.getClass().getName());
}
public LifecycleHandler getLifecycleHandler()
@@ -200,6 +211,7 @@
{
assertEndpointSetterAccess();
this.lifecycleHandler = handler;
+ configsMap.put(Endpoint.LIFECYCLEHANDLER, handler.getClass().getName());
}
public InvocationHandler getInvocationHandler()
@@ -211,6 +223,7 @@
{
assertEndpointSetterAccess();
this.invocationHandler = handler;
+ configsMap.put(Endpoint.INVOCATIONHANDLER, handler.getClass().getName());
}
@Override
@@ -307,6 +320,7 @@
public void setSecurityDomainContext(SecurityDomainContext securityDomainContext)
{
this.securityDomainContext = securityDomainContext;
+ this.configsMap.put(Endpoint.SECURITY_DOMAIN,
securityDomainContext.getSecurityDomain());
}
public InstanceProvider getInstanceProvider()
@@ -324,10 +338,31 @@
{
assertEndpointSetterAccess();
this.endpointConfig = endpointConfig;
+ StringBuffer preHandlerChains = new StringBuffer();
+ for (UnifiedHandlerChainMetaData uhcmd : endpointConfig.getPreHandlerChains()) {
+ for (UnifiedHandlerMetaData uhmd : uhcmd.getHandlers()) {
+ preHandlerChains.append(uhmd.getHandlerClass()).append(" ");
+ }
+ }
+ configsMap.put(Endpoint.PRE_HANDLERCHAIN, preHandlerChains.toString());
+ StringBuffer postHandlerChains = new StringBuffer();
+ for (UnifiedHandlerChainMetaData uhcmd : endpointConfig.getPostHandlerChains()) {
+ for (UnifiedHandlerMetaData uhmd : uhcmd.getHandlers()) {
+ postHandlerChains.append(uhmd.getHandlerClass()).append(" ");
+ }
+ }
+ configsMap.put(Endpoint.POST_HANDLERCHAIN, postHandlerChains.toString());
+ configsMap.putAll(endpointConfig.getProperties());
}
public EndpointConfig getEndpointConfig()
{
return endpointConfig;
}
+
+ public Map<String, String> getAllConfigsMap() {
+ configsMap.put(Endpoint.ADDRESS, this.getAddress());
+ configsMap.putAll(this.getRuntimeProperties());
+ return configsMap;
+ }
}
Modified:
common/branches/management/src/main/java/org/jboss/ws/common/deployment/DefaultHttpEndpoint.java
===================================================================
---
common/branches/management/src/main/java/org/jboss/ws/common/deployment/DefaultHttpEndpoint.java 2015-03-10
09:02:06 UTC (rev 19546)
+++
common/branches/management/src/main/java/org/jboss/ws/common/deployment/DefaultHttpEndpoint.java 2015-03-10
09:02:23 UTC (rev 19547)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2015, 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.
*
@@ -31,7 +31,7 @@
*/
public class DefaultHttpEndpoint extends AbstractDefaultEndpoint implements HttpEndpoint
{
-
+ protected static final String URL_PATTEN = "urlPattern";
DefaultHttpEndpoint(String targetBean)
{
super(targetBean);
@@ -60,6 +60,7 @@
{
assertEndpointSetterAccess();
this.urlPattern = urlPattern;
+ this.configsMap.put(URL_PATTEN, urlPattern);
}
}
Modified:
common/branches/management/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
---
common/branches/management/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2015-03-10
09:02:06 UTC (rev 19546)
+++
common/branches/management/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2015-03-10
09:02:23 UTC (rev 19547)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2015, 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.
*
@@ -36,6 +36,7 @@
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.spi.deployment.AbstractExtensible;
import org.jboss.wsf.spi.management.CommonConfigStore;
import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.spi.management.StackConfig;
@@ -57,9 +58,10 @@
* @author alessio.soldano(a)jboss.com
* @author Thomas.Diesler(a)jboss.org
* @author darran.lofthouse(a)jboss.com
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
* @since 08-May-2006
*/
-public abstract class AbstractServerConfig implements AbstractServerConfigMBean,
ServerConfig
+public abstract class AbstractServerConfig extends AbstractExtensible implements
AbstractServerConfigMBean, ServerConfig
{
private static final RuntimePermission LOOKUP_SERVER_INTEGRATION_SERVER_CONFIG = new
RuntimePermission("org.jboss.ws.LOOKUP_SERVER_INTEGRATION_SERVER_CONFIG");
Added:
common/branches/management/src/main/java/org/jboss/ws/common/utils/RuntimeConfigUtils.java
===================================================================
---
common/branches/management/src/main/java/org/jboss/ws/common/utils/RuntimeConfigUtils.java
(rev 0)
+++
common/branches/management/src/main/java/org/jboss/ws/common/utils/RuntimeConfigUtils.java 2015-03-10
09:02:23 UTC (rev 19547)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, 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.ws.common.utils;
+
+import java.security.AccessController;
+
+import org.jboss.ws.common.management.AbstractServerConfig;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.ServerConfig;
+/**
+ * Utility class to compute the runtime configuration
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+public class RuntimeConfigUtils
+{
+ public static boolean isEnabled(final Endpoint endpoint, final String property)
+ {
+ if (endpoint.getRuntimeProperty(property) != null)
+ {
+ return true;
+ }
+ if (endpoint.getService().getDeployment().getRuntimeProperty(property) != null)
+ {
+ return true;
+ }
+ if (getServerConfig().getRuntimeProperty(property) != null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private static ServerConfig getServerConfig()
+ {
+ if (System.getSecurityManager() == null)
+ {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return
AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
+
+}
Property changes on:
common/branches/management/src/main/java/org/jboss/ws/common/utils/RuntimeConfigUtils.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
common/branches/management/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java
===================================================================
---
common/branches/management/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java 2015-03-10
09:02:06 UTC (rev 19546)
+++
common/branches/management/src/test/java/org/jboss/test/ws/common/management/DefaultEndpointRegistryTestCase.java 2015-03-10
09:02:23 UTC (rev 19547)
@@ -35,6 +35,8 @@
import javax.management.ObjectName;
+import junit.framework.TestCase;
+
import org.jboss.ws.api.monitoring.Record;
import org.jboss.ws.api.monitoring.RecordProcessor;
import org.jboss.ws.common.management.DefaultEndpointRegistry;
@@ -51,8 +53,6 @@
import org.jboss.wsf.spi.metadata.config.EndpointConfig;
import org.jboss.wsf.spi.security.SecurityDomainContext;
-import junit.framework.TestCase;
-
/**
* Test the DefaultEndpointRegistry
*
@@ -417,6 +417,30 @@
// TODO Auto-generated method stub
}
+
+ @Override
+ public String getRuntimeProperty(String key) {
+ return null;
+ }
+
+ @Override
+ public void setRuntimeProperty(String key, String value) {
+ }
+
+ @Override
+ public void removeRuntimeProperty(String key) {
+ }
+
+ @Override
+ public Map<String, String> getRuntimeProperties() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getAllConfigsMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
};
}
}