Author: richard.opalka(a)jboss.com
Date: 2011-01-11 11:08:33 -0500 (Tue, 11 Jan 2011)
New Revision: 13555
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/
common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractDefaultEndpoint.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentModelFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/BackwardCompatibleContextRootDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextPropertiesDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextRootDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeployment.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentAspectManagerFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentModelFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultHttpEndpoint.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultJMSEndpoint.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandler.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandlerFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectInstaller.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAPIDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointHandlerDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointLifecycleDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointMetricsDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointNameDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/JAXBIntroDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/URLPatternDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/WebservicesDescriptorParserImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/jms/
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/jms/WebservicesDescriptorProcessorImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/DefaultResourceInjectorFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/
common/trunk/src/main/java/org/jboss/wsf/framework/management/ContextServlet.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointMetricsFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistry.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistryFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultJMSEndpointResolver.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/EndpointMetricsImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/MBeanServerLocator.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistry.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistryMBean.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AbstractRecordProcessor.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AndFilter.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/HostFilter.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessor.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessorMBean.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/NotFilter.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OperationFilter.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OrFilter.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordImpl.java
common/trunk/src/main/java/org/jboss/wsf/framework/security/
common/trunk/src/main/java/org/jboss/wsf/framework/security/DefaultSecurityAdapterFactory.java
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java
Log:
refactoring framework sources to common
Added: common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
(rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework;
+
+import org.jboss.wsf.framework.deployment.DefaultDeploymentAspectManagerFactory;
+import org.jboss.wsf.framework.deployment.DefaultDeploymentModelFactory;
+import org.jboss.wsf.framework.deployment.DefaultLifecycleHandlerFactory;
+import org.jboss.wsf.framework.invocation.DefaultResourceInjectorFactory;
+import org.jboss.wsf.framework.management.DefaultEndpointMetricsFactory;
+import org.jboss.wsf.framework.management.DefaultEndpointRegistryFactory;
+import org.jboss.wsf.framework.management.DefaultJMSEndpointResolver;
+import org.jboss.wsf.framework.security.DefaultSecurityAdapterFactory;
+import org.jboss.wsf.framework.serviceref.DefaultServiceRefHandlerFactory;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManagerFactory;
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+import org.jboss.wsf.spi.management.EndpointMetricsFactory;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.management.JMSEndpointResolver;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+/**
+ * @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+class DefaultSPIProvider extends SPIProvider
+{
+
+ /**
+ * Gets the specified SPI.
+ */
+ public <T> T getSPI(Class<T> spiType)
+ {
+ T returnType = null;
+
+ // SPIs provided by framework, defaults can be overridden
+ if (DeploymentAspectManagerFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultDeploymentAspectManagerFactory.class);
+ }
+ if (DeploymentModelFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultDeploymentModelFactory.class);
+ }
+ else if (EndpointMetricsFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultEndpointMetricsFactory.class);
+ }
+ else if (LifecycleHandlerFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultLifecycleHandlerFactory.class);
+ }
+ else if (ResourceInjectorFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultResourceInjectorFactory.class);
+ }
+ else if (ServiceRefHandlerFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultServiceRefHandlerFactory.class);
+ }
+ else if (SecurityAdaptorFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultSecurityAdapterFactory.class);
+ }
+ else if (EndpointRegistryFactory.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultEndpointRegistryFactory.class);
+ }
+ else if (JMSEndpointResolver.class.equals(spiType))
+ {
+ returnType = loadService(spiType, DefaultJMSEndpointResolver.class);
+ }
+ else
+ {
+ // SPI provided by either container or stack integration that has no default
implementation
+ returnType = (T)loadService(spiType, null);
+ }
+
+ if (returnType == null)
+ throw new WSFException("Failed to provide SPI '" + spiType +
"'");
+
+ return returnType;
+ }
+
+ // Load SPI implementation through ServiceLoader
+ @SuppressWarnings("unchecked")
+ private <T> T loadService(Class<T> spiType, Class<?> defaultImpl)
+ {
+ final String defaultImplName = defaultImpl != null ? defaultImpl.getName() : null;
+ return (T)ServiceLoader.loadService(spiType.getName(), defaultImplName);
+ }
+
+}
Added: common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+
+/**
+ * TODO: javadoc
+ *
+ * @author <a href="mailto:hbraun@redhat.com">Heiko Braun</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class DefaultSPIProviderResolver extends SPIProviderResolver
+{
+
+ private static final SPIProvider SPI_PROVIDER = new DefaultSPIProvider();
+
+ public DefaultSPIProviderResolver()
+ {
+ super();
+ }
+
+ public SPIProvider getProvider()
+ {
+ return DefaultSPIProviderResolver.SPI_PROVIDER;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractDefaultEndpoint.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractDefaultEndpoint.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/AbstractDefaultEndpoint.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.wsf.common.injection.PreDestroyHolder;
+import org.jboss.wsf.spi.deployment.AbstractExtensible;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
+import org.jboss.wsf.spi.deployment.Service;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.deployment.Endpoint.EndpointState;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * A general abstract JAXWS endpoint.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class AbstractDefaultEndpoint extends AbstractExtensible
+{
+ protected Service service;
+ protected ObjectName name;
+ protected String shortName;
+ protected String urlPattern;
+ protected String targetBean;
+ protected Class<?> targetBeanClass;
+ protected EndpointState state;
+ protected RequestHandler requestHandler;
+ protected InvocationHandler invocationHandler;
+ protected LifecycleHandler lifecycleHandler;
+ protected EndpointMetrics metrics;
+ protected String address;
+ protected List<RecordProcessor> recordProcessors = new
Vector<RecordProcessor>();
+
+ AbstractDefaultEndpoint(String targetBean)
+ {
+ this.targetBean = targetBean;
+ this.state = EndpointState.UNDEFINED;
+ }
+
+ public Service getService()
+ {
+ return service;
+ }
+
+ public void setService(Service service)
+ {
+ assertEndpointSetterAccess();
+ this.service = service;
+ }
+
+ public String getTargetBeanName()
+ {
+ return targetBean;
+ }
+
+ public void setTargetBeanName(String targetBean)
+ {
+ assertEndpointSetterAccess();
+ this.targetBean = targetBean;
+ }
+
+ public synchronized Class<?> getTargetBeanClass()
+ {
+ if (targetBean == null)
+ throw new IllegalStateException("Target bean not set");
+ if (targetBeanClass != null)
+ return targetBeanClass;
+
+ ClassLoader classLoader = service.getDeployment().getRuntimeClassLoader();
+
+ try
+ {
+ targetBeanClass = classLoader.loadClass(targetBean);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new WSFDeploymentException(ex);
+ }
+
+ return targetBeanClass;
+ }
+
+ public ObjectName getName()
+ {
+ if(null==name)
+ {
+ // build implicit name
+ try
+ {
+ name = new ObjectName(
+ Endpoint.SEPID_DOMAIN,
+ Endpoint.SEPID_PROPERTY_ENDPOINT, targetBean
+ );
+
+ } catch (MalformedObjectNameException e)
+ {
+ //
+ }
+ }
+
+ return name;
+ }
+
+ public void setName(ObjectName name)
+ {
+ assertEndpointSetterAccess();
+ this.name = name;
+ }
+
+ public String getShortName()
+ {
+ return shortName;
+ }
+
+ public void setShortName(String shortName)
+ {
+ assertEndpointSetterAccess();
+ this.shortName = shortName;
+ }
+
+
+ public EndpointState getState()
+ {
+ return state;
+ }
+
+ public void setState(EndpointState state)
+ {
+ this.state = state;
+ }
+
+ public RequestHandler getRequestHandler()
+ {
+ return requestHandler;
+ }
+
+ public void setRequestHandler(RequestHandler handler)
+ {
+ assertEndpointSetterAccess();
+ this.requestHandler = handler;
+ }
+
+ public LifecycleHandler getLifecycleHandler()
+ {
+ return lifecycleHandler;
+ }
+
+ public void setLifecycleHandler(LifecycleHandler handler)
+ {
+ assertEndpointSetterAccess();
+ this.lifecycleHandler = handler;
+ }
+
+ public InvocationHandler getInvocationHandler()
+ {
+ return invocationHandler;
+ }
+
+ public void setInvocationHandler(InvocationHandler handler)
+ {
+ assertEndpointSetterAccess();
+ this.invocationHandler = handler;
+ }
+
+ @Override
+ public <T> T addAttachment(Class<T> clazz, Object obj)
+ {
+ boolean isPreDestroyHolderClass = clazz.equals(PreDestroyHolder.class); //
JBWS-2268 hack
+ boolean isObjectClass = clazz.equals(Object.class); // JBWS-2486 hack
+
+ if (!isPreDestroyHolderClass && !isObjectClass)
+ {
+ assertEndpointSetterAccess();
+ }
+ return super.addAttachment(clazz, obj);
+ }
+
+ @Override
+ public <T> T removeAttachment(Class<T> key)
+ {
+ boolean isPreDestroyHolderClass = key.equals(PreDestroyHolder.class); // JBWS-2268
hack
+ boolean isObjectClass = key.equals(Object.class); // JBWS-2486 hack
+
+ if (!isPreDestroyHolderClass && !isObjectClass)
+ {
+ assertEndpointSetterAccess();
+ }
+ return super.removeAttachment(key);
+ }
+
+ public void removeProperty(String key)
+ {
+ assertEndpointSetterAccess();
+ super.removeProperty(key);
+ }
+
+ public void setProperty(String key, Object value)
+ {
+ assertEndpointSetterAccess();
+ super.setProperty(key, value);
+ }
+
+ protected void assertEndpointSetterAccess()
+ {
+ if (state == EndpointState.STARTED)
+ throw new IllegalStateException("Cannot modify endpoint properties in
state: " + state);
+ }
+
+ public List<RecordProcessor> getRecordProcessors()
+ {
+ return recordProcessors;
+ }
+
+ public void setRecordProcessors(List<RecordProcessor> recordProcessors)
+ {
+ this.recordProcessors = new Vector<RecordProcessor>(recordProcessors);
+ }
+
+ public void processRecord(Record record)
+ {
+ for (RecordProcessor processor : recordProcessors)
+ {
+ if (processor.isRecording())
+ {
+ boolean match = true;
+ if (processor.getFilters() != null)
+ {
+ for (Iterator<RecordFilter> it = processor.getFilters().iterator();
it.hasNext() && match;)
+ {
+ match = it.next().match(record);
+ }
+ }
+ if (match)
+ {
+ processor.processRecord(record);
+ }
+ }
+ }
+ }
+
+ public String getAddress()
+ {
+ return this.address;
+ }
+
+ public void setAddress(String address)
+ {
+ this.address = address;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * A general web service deployment that is based on an archive.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class ArchiveDeploymentImpl extends DefaultDeployment implements
ArchiveDeployment
+{
+ // The optional parent
+ private ArchiveDeployment parent;
+ // The root file for this deployment
+ private UnifiedVirtualFile rootFile;
+
+ private static Logger log = Logger.getLogger(ArchiveDeploymentImpl.class);
+
+ private List<UnifiedVirtualFile> metadataFiles;
+
+ ArchiveDeploymentImpl(String simpleName, ClassLoader classLoader)
+ {
+ super(simpleName, classLoader);
+ }
+
+ public ArchiveDeployment getParent()
+ {
+ return parent;
+ }
+
+ public void setParent(ArchiveDeployment parent)
+ {
+ this.parent = parent;
+ }
+
+ public UnifiedVirtualFile getRootFile()
+ {
+ return rootFile;
+ }
+
+ public void setRootFile(UnifiedVirtualFile rootFile)
+ {
+ this.rootFile = rootFile;
+ }
+
+ public String getCanonicalName()
+ {
+ String name = getSimpleName();
+ if (getParent() != null)
+ name = getParent().getCanonicalName() + "/" + name;
+ return name;
+ }
+
+ @Deprecated
+ public URL getMetaDataFileURL(String resourcePath) throws IOException
+ {
+ return getResourceResolver().resolve(resourcePath);
+ }
+
+ public List<UnifiedVirtualFile> getMetadataFiles()
+ {
+ return metadataFiles;
+ }
+
+ public void setMetadataFiles(List<UnifiedVirtualFile> metadataFiles)
+ {
+ this.metadataFiles = metadataFiles;
+ }
+
+ public ResourceResolver getResourceResolver()
+ {
+ return new ResourceResolverImpl(rootFile, metadataFiles);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentModelFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentModelFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentModelFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Service;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 26-Jul-2007
+ */
+public class ArchiveDeploymentModelFactory extends DeploymentModelFactory
+{
+ public Deployment newDeployment(String simpleName, ClassLoader initialLoader)
+ {
+ return new ArchiveDeploymentImpl(simpleName, initialLoader);
+ }
+
+ public Service newService()
+ {
+ return new DefaultService();
+ }
+
+ @Deprecated
+ /**
+ * Use #newHttpEndpoint(String) instead
+ */
+ public Endpoint newEndpoint(String targetBean)
+ {
+ return this.newHttpEndpoint(targetBean);
+ }
+
+ public Endpoint newHttpEndpoint(String targetBean)
+ {
+ return new DefaultHttpEndpoint(targetBean);
+ }
+
+ public Endpoint newJMSEndpoint(String targetBean)
+ {
+ return new DefaultJMSEndpoint(targetBean);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/BackwardCompatibleContextRootDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/BackwardCompatibleContextRootDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/BackwardCompatibleContextRootDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.StringTokenizer;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+/**
+ * A deployer that assigns the context root to the service.
+ *
+ * If there is no explicit <context-root>, this deployer uses
+ * the first token from the <port-component-uri> element.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class BackwardCompatibleContextRootDeploymentAspect extends
ContextRootDeploymentAspect
+{
+ @Override
+ protected String getExplicitContextRoot(Deployment dep)
+ {
+ String contextRoot = super.getExplicitContextRoot(dep);
+ if (contextRoot == null)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ String urlPattern = getUrlPattern(dep, ep);
+ if (urlPattern != null)
+ {
+ StringTokenizer st = new StringTokenizer(urlPattern, "/");
+ if (st.countTokens() > 1)
+ {
+ String firstToken = st.nextToken();
+ if (contextRoot != null && contextRoot.equals(firstToken) ==
false)
+ throw new IllegalStateException("All endpoints must share the
same <context-root>: " + contextRoot + "!=" + firstToken);
+
+ contextRoot = firstToken;
+ }
+ }
+ }
+ }
+ return contextRoot;
+ }
+
+ private String getUrlPattern(Deployment dep, Endpoint ep)
+ {
+ String urlPattern = null;
+
+ EJBArchiveMetaData appMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (appMetaData != null && appMetaData.getBeanByEjbName(ep.getShortName())
!= null)
+ {
+ EJBMetaData bmd = appMetaData.getBeanByEjbName(ep.getShortName());
+ urlPattern = bmd.getPortComponentURI();
+ }
+
+ return urlPattern;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextPropertiesDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextPropertiesDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextPropertiesDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Populate deployment context properties
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 19-May-2006
+ */
+public class ContextPropertiesDeploymentAspect extends AbstractDeploymentAspect
+{
+ // The configured service endpoint servlet
+ private Map<String,String> contextProperties;
+
+ public Map<String, String> getContextProperties()
+ {
+ return contextProperties;
+ }
+
+ public void setContextProperties(Map<String, String> contextProperties)
+ {
+ this.contextProperties = contextProperties;
+ }
+
+ @Override
+ public void start(Deployment dep)
+ {
+ if (contextProperties != null)
+ {
+ Iterator<String> it = contextProperties.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = it.next();
+ String value = contextProperties.get(key);
+ dep.setProperty(key, value);
+ }
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextRootDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextRootDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ContextRootDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.ws.Constants;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.annotation.AuthMethod;
+import org.jboss.wsf.spi.annotation.TransportGuarantee;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+
+/**
+ * A deployer that assigns the context root to the service
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class ContextRootDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ String contextRoot = dep.getService().getContextRoot();
+ if (contextRoot == null)
+ {
+ contextRoot = getExplicitContextRoot(dep);
+ if (contextRoot == null)
+ contextRoot = getImplicitContextRoot((ArchiveDeployment)dep);
+
+ // Always prefix with '/'
+ if (contextRoot.startsWith("/") == false)
+ contextRoot = "/" + contextRoot;
+
+ dep.getService().setContextRoot(contextRoot);
+ }
+ }
+
+ protected String getExplicitContextRoot(Deployment dep)
+ {
+ String contextRoot = null;
+
+ // #1 Use the explicit context root from the web meta data
+ JSEArchiveMetaData webMetaData = dep.getAttachment(JSEArchiveMetaData.class);
+ if (webMetaData != null)
+ contextRoot = webMetaData.getContextRoot();
+
+ // #2 Use the explicit context root from @WebContext.contextRoot
+ if (contextRoot == null)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ Class implClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)implClass.getAnnotation(WebContext.class);
+ this.validateSecuritySettings(anWebContext);
+ if (anWebContext != null && anWebContext.contextRoot().length() >
0)
+ {
+ if (contextRoot != null &&
contextRoot.equals(anWebContext.contextRoot()) == false)
+ throw new IllegalStateException("Context root must be the same for
all deployed endpoints");
+
+ contextRoot = anWebContext.contextRoot();
+ }
+ }
+ }
+
+ // #3 Use the explicit context root from webservices/context-root
+ EJBArchiveMetaData appMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (contextRoot == null && appMetaData != null)
+ {
+ contextRoot = appMetaData.getWebServiceContextRoot();
+ }
+
+ return contextRoot;
+ }
+
+ /** Use the implicit context root derived from the deployment name
+ */
+ protected String getImplicitContextRoot(ArchiveDeployment dep)
+ {
+ String simpleName = dep.getSimpleName();
+ String contextRoot = simpleName.substring(0, simpleName.length() - 4);
+ if (dep.getParent() != null && Constants.BC_CONTEXT_MODE)
+ {
+ simpleName = dep.getParent().getSimpleName();
+ contextRoot = simpleName.substring(0, simpleName.length() - 4) + "-" +
contextRoot;
+ }
+ return contextRoot;
+ }
+
+ private void validateSecuritySettings(WebContext webCtx)
+ {
+ if (webCtx != null)
+ {
+ TransportGuarantee.valueOf(webCtx.transportGuarantee());
+ AuthMethod.valueOf(webCtx.authMethod());
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeployment.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeployment.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeployment.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.AbstractExtensible;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Service;
+
+/**
+ * A general web service deployment dep.
+ *
+ * It has no notion of J2EE deployment packages.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class DefaultDeployment extends AbstractExtensible implements Deployment
+{
+ // The name for this deployment
+ private String simpleName;
+ // A deployment has one service
+ private Service service;
+ // The type of this deployment
+ private DeploymentType type;
+ // The state for this deployment
+ private DeploymentState state;
+ // The deployment class loader
+ private ClassLoader initialLoader;
+ // The runtime class loader
+ private ClassLoader runtimeLoader;
+
+ DefaultDeployment(String name, ClassLoader classLoader)
+ {
+ simpleName = name;
+ state = DeploymentState.UNDEFINED;
+ initialLoader = classLoader;
+ setService(new DefaultService());
+ }
+
+ public String getSimpleName()
+ {
+ return simpleName;
+ }
+
+ public void setSimpleName(String name)
+ {
+ this.simpleName = name;
+ }
+
+ public void setInitialClassLoader(ClassLoader classLoader)
+ {
+ this.initialLoader = classLoader;
+ }
+
+ public ClassLoader getInitialClassLoader()
+ {
+ return initialLoader;
+ }
+
+ public void setRuntimeClassLoader(ClassLoader classLoader)
+ {
+ this.runtimeLoader = classLoader;
+ }
+
+ public ClassLoader getRuntimeClassLoader()
+ {
+ return runtimeLoader;
+ }
+
+ public Service getService()
+ {
+ return service;
+ }
+
+ public void setService(Service service)
+ {
+ service.setDeployment(this);
+ this.service = service;
+ }
+
+ public DeploymentState getState()
+ {
+ return state;
+ }
+
+ public void setState(DeploymentState deploymentState)
+ {
+ this.state = deploymentState;
+ }
+
+ public DeploymentType getType()
+ {
+ return type;
+ }
+
+ public void setType(DeploymentType deploymentType)
+ {
+ this.type = deploymentType;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentAspectManagerFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentAspectManagerFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentAspectManagerFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManagerFactory;
+
+/**
+ * A DeploymentAspectManagerFactory that retrieves a configured
+ * {@link DeploymentAspectManager} from MC kernel.
+ *
+ * @see org.jboss.wsf.framework.deployment.DeploymentAspectInstaller
+ *
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class DefaultDeploymentAspectManagerFactory extends
DeploymentAspectManagerFactory
+{
+
+ // TODO: review this class methods, maybe only one method getDeploymentAspectManager()
will be sufficient
+ public DeploymentAspectManager getDeploymentAspectManager(Deployment.DeploymentType
deploymentType)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public DeploymentAspectManager getDeploymentAspectManager(String beanName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentModelFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentModelFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultDeploymentModelFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Service;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jul 18, 2007
+ */
+public class DefaultDeploymentModelFactory extends DeploymentModelFactory
+{
+ public Deployment newDeployment(String simpleName, ClassLoader initialLoader)
+ {
+ return new DefaultDeployment(simpleName, initialLoader);
+ }
+
+ public Service newService()
+ {
+ return new DefaultService();
+ }
+
+ @Deprecated
+ /**
+ * Use #newHttpEndpoint(String) instead
+ */
+ public Endpoint newEndpoint(String targetBean)
+ {
+ return this.newHttpEndpoint(targetBean);
+ }
+
+ public Endpoint newHttpEndpoint(String targetBean)
+ {
+ return new DefaultHttpEndpoint(targetBean);
+ }
+
+ public Endpoint newJMSEndpoint(String targetBean)
+ {
+ return new DefaultJMSEndpoint(targetBean);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultHttpEndpoint.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultHttpEndpoint.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultHttpEndpoint.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.framework.deployment;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+
+/**
+ * DefaultHttpEndpoint implementation
+ *
+ * @author <a href="ema(a)redhat.com">Jim Ma</a>
+ */
+public class DefaultHttpEndpoint extends AbstractDefaultEndpoint implements HttpEndpoint
+{
+
+ private static final Logger log = Logger.getLogger(DefaultHttpEndpoint.class);
+
+ DefaultHttpEndpoint(String targetBean)
+ {
+ super(targetBean);
+ }
+
+ public EndpointMetrics getEndpointMetrics()
+ {
+ return metrics;
+ }
+
+ public void setEndpointMetrics(EndpointMetrics metrics)
+ {
+ assertEndpointSetterAccess();
+ metrics.setEndpoint(this);
+ this.metrics = metrics;
+
+ }
+
+ public String getURLPattern()
+ {
+ return urlPattern;
+ }
+
+ public void setURLPattern(String urlPattern)
+ {
+ assertEndpointSetterAccess();
+ this.urlPattern = urlPattern;
+ }
+
+ public Context getJNDIContext()
+ {
+ Context retVal = null;
+
+ try
+ {
+ retVal = getInvocationHandler().getJNDIContext(this);
+ }
+ catch (NamingException e)
+ {
+ // JNDI not available neither in JSE environment nor in SAR archives
+ }
+
+ return retVal;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultJMSEndpoint.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultJMSEndpoint.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultJMSEndpoint.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.framework.deployment;
+
+import java.net.URI;
+
+import javax.naming.Context;
+
+import org.jboss.wsf.spi.deployment.JMSEndpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+
+/**
+ * Default JMSEndpoint implementation
+ *
+ * @author <a href="ema(a)redhat.com">Jim Ma</a>
+ */
+public class DefaultJMSEndpoint extends AbstractDefaultEndpoint implements JMSEndpoint
+{
+
+ private String targetDestination;
+ private String replyDestination;
+ private URI requestURI;
+
+ DefaultJMSEndpoint(String targetBean)
+ {
+ super(targetBean);
+ }
+
+ @Deprecated
+ public String getURLPattern()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public void setURLPattern(String urlPattern)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getTargetDestination()
+ {
+ return targetDestination;
+ }
+
+ public void setTargetDestination(String targetDestination)
+ {
+ this.targetDestination = targetDestination;
+ }
+
+ public String getReplyDestination()
+ {
+ return replyDestination;
+ }
+
+ public void setReplyDestination(String replyDestination)
+ {
+ this.replyDestination = replyDestination;
+ }
+
+ public URI getRequestURI()
+ {
+ return this.requestURI;
+ }
+
+ public void setRequestURI(URI requestURI)
+ {
+ this.requestURI = requestURI;
+ }
+
+ public String getAddress()
+ {
+ if (getTargetDestination() != null)
+ {
+ StringBuffer address = new StringBuffer();
+ address.append("jms:jndi:" + getTargetDestination());
+ if (this.getReplyDestination() != null)
+ {
+ address.append("?replyToName =" + this.getReplyDestination());
+ }
+ return address.toString();
+ }
+ return "Not available";
+ }
+
+ //TODO:enable jms endpoint management
+ @Override
+ public EndpointMetrics getEndpointMetrics()
+ {
+ return null;
+ }
+ @Override
+ public Context getJNDIContext()
+ {
+ return null;
+ }
+
+ @Override
+ public void setEndpointMetrics(EndpointMetrics metrics)
+ {
+
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandler.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandler.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandler.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint.EndpointState;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * A basic lifecycle handler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 31-Oct-2006
+ */
+public class DefaultLifecycleHandler implements LifecycleHandler
+{
+ // provide logging
+ protected final Logger log = Logger.getLogger(getClass());
+
+ public void start(Endpoint ep)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Start: " + ep.getName());
+
+ EndpointState state = ep.getState();
+ if (state != EndpointState.UNDEFINED)
+ {
+ log.error("Cannot start endpoint in state: " + state);
+ }
+ else
+ {
+ if (ep.getEndpointMetrics() != null)
+ ep.getEndpointMetrics().start();
+
+ InvocationHandler invHandler = ep.getInvocationHandler();
+ if (invHandler == null)
+ throw new IllegalStateException("Invocation handler not
available");
+ invHandler.init(ep);
+
+ ep.setState(EndpointState.STARTED);
+ }
+ }
+
+ public void stop(Endpoint ep)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Stop: " + ep.getName());
+
+ EndpointState state = ep.getState();
+ if (state != EndpointState.STARTED)
+ {
+ log.error("Cannot stop endpoint in state: " + state);
+ }
+ else
+ {
+ if (ep.getEndpointMetrics() != null)
+ ep.getEndpointMetrics().stop();
+
+ ep.setState(EndpointState.STOPPED);
+ }
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandlerFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandlerFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultLifecycleHandlerFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jul 23, 2007
+ */
+public class DefaultLifecycleHandlerFactory extends LifecycleHandlerFactory
+{
+ public LifecycleHandler newLifecycleHandler()
+ {
+ return new DefaultLifecycleHandler();
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DefaultService.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.spi.deployment.AbstractExtensible;
+import org.jboss.wsf.spi.deployment.Service;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+import java.util.LinkedList;
+import java.util.List;
+
+
+/**
+ * A general service.
+ *
+ * Maintains a named set of Endpoints
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class DefaultService extends AbstractExtensible implements Service
+{
+ private Deployment dep;
+ private List<Endpoint> endpoints = new LinkedList<Endpoint>();
+ private String contextRoot;
+ private List<String> virtualHosts;
+
+ DefaultService()
+ {
+ }
+
+ public Deployment getDeployment()
+ {
+ return dep;
+ }
+
+ public void setDeployment(Deployment dep)
+ {
+ this.dep = dep;
+ }
+
+ public void addEndpoint(Endpoint endpoint)
+ {
+ endpoint.setService(this);
+ endpoints.add(endpoint);
+ }
+
+ public List<Endpoint> getEndpoints()
+ {
+ return endpoints;
+ }
+
+ public Endpoint getEndpointByName(String shortName)
+ {
+ Endpoint retEndpoint = null;
+ for (Endpoint ep : endpoints)
+ {
+ if (ep.getShortName().equals(shortName))
+ {
+ retEndpoint = ep;
+ break;
+ }
+ }
+ return retEndpoint;
+ }
+
+ public String getContextRoot()
+ {
+ return contextRoot;
+ }
+
+ public void setContextRoot(String contextRoot)
+ {
+ this.contextRoot = contextRoot;
+ }
+
+ public List<String> getVirtualHosts()
+ {
+ if ( virtualHosts != null )
+ {
+ final List<String> retVal = new LinkedList<String>();
+ for ( String virtualHost : virtualHosts )
+ {
+ retVal.add( virtualHost );
+ }
+ return retVal;
+ }
+
+ return null;
+ }
+
+ public void setVirtualHosts(List<String> virtualHosts)
+ {
+ this.virtualHosts = virtualHosts;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectInstaller.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectInstaller.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectInstaller.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
+
+/**
+ * A deployment aspect installer.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class DeploymentAspectInstaller
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(DeploymentAspectInstaller.class);
+
+ private DeploymentAspectManager manager;
+ private Set<DeploymentAspect> aspects;
+ private boolean sortAspectsOnCreate;
+ private Set<String> parentProvidedConditions = new HashSet<String>();
+
+ public void setManager(DeploymentAspectManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public void setAspects(Set<DeploymentAspect> aspects)
+ {
+ this.aspects = aspects;
+ }
+
+ public void setSortAspectsOnCreate(boolean sortAspectsOnCreate)
+ {
+ this.sortAspectsOnCreate = sortAspectsOnCreate;
+ }
+
+ public void create()
+ {
+ List<DeploymentAspect> unsortedAspects = new
ArrayList<DeploymentAspect>();
+
+ unsortedAspects.addAll(manager.getDeploymentAspects());
+ unsortedAspects.addAll(aspects);
+
+ List<DeploymentAspect> sortedAspects = unsortedAspects;
+ if (sortAspectsOnCreate)
+ {
+ // get the conditions provided by the parent
+ if (manager.getParent() != null)
+ {
+ Iterator<DeploymentAspect> it =
manager.getParent().getDeploymentAspects().iterator();
+ while (it.hasNext())
+ {
+ DeploymentAspect aspect = it.next();
+ parentProvidedConditions.addAll(aspect.getProvidesAsSet());
+ }
+ }
+
+ sortedAspects = new ArrayList<DeploymentAspect>();
+ List<DeploymentAspect> allAspects = new
ArrayList<DeploymentAspect>(unsortedAspects);
+
+ // Add aspects with no requirements first
+ Iterator<DeploymentAspect> itAll = allAspects.iterator();
+ while (itAll.hasNext())
+ {
+ DeploymentAspect aspect = itAll.next();
+ if (aspect.getRequires() == null ||
parentProvidedConditions.containsAll(aspect.getRequiresAsSet()))
+ {
+ sortedAspects.add(aspect);
+ itAll.remove();
+ }
+ }
+
+ // Add aspects that have requirements that already added aspects provide
+ itAll = allAspects.iterator();
+ while (itAll.hasNext())
+ {
+ DeploymentAspect aspect = itAll.next();
+ int index = getAspectIndex(sortedAspects, aspect);
+ if (index != -1)
+ {
+ sortedAspects.add(index, aspect);
+ itAll.remove();
+
+ itAll = allAspects.iterator(); // Hm,...
+ }
+ }
+
+ // Add LAST_DEPLOYMENT_ASPECT
+ itAll = allAspects.iterator();
+ while (itAll.hasNext())
+ {
+ DeploymentAspect aspect = itAll.next();
+ if (DeploymentAspect.LAST_DEPLOYMENT_ASPECT.equals(aspect.getRequires()))
+ {
+ sortedAspects.add(aspect);
+ itAll.remove();
+ }
+ }
+
+ if (allAspects.size() != 0)
+ throwSortException(sortedAspects, allAspects);
+ }
+ manager.setDeploymentAspects(sortedAspects);
+ }
+
+ public void destroy()
+ {
+ List<DeploymentAspect> managerAspects = new
ArrayList<DeploymentAspect>();
+ managerAspects.addAll(manager.getDeploymentAspects());
+ Iterator<DeploymentAspect> it = aspects.iterator();
+ while (it.hasNext())
+ {
+ DeploymentAspect aspect = it.next();
+ managerAspects.remove(aspect);
+ }
+ manager.setDeploymentAspects(managerAspects);
+ }
+
+ private void throwSortException(List<DeploymentAspect> sortedAspects,
List<DeploymentAspect> allAspects)
+ {
+ Set<String> providedConditions = new HashSet<String>();
+ for (int i = 0; i < sortedAspects.size(); i++)
+ {
+ DeploymentAspect sortedAspect = sortedAspects.get(i);
+ providedConditions.addAll(sortedAspect.getProvidesAsSet());
+ }
+
+ String exmsg = "Cannot add deployment aspect(s)";
+ StringBuilder str = new StringBuilder(exmsg);
+
+ if (manager.getParent() != null)
+ str.append("\n" + manager.getParent().getName() + " provides:
" + parentProvidedConditions);
+
+ str.append("\n" + manager.getName() + " provides: " +
providedConditions);
+
+ for (DeploymentAspect da : allAspects)
+ {
+ str.append("\n " + da.getClass().getName() + ", requires:
" + da.getRequires());
+ }
+
+ log.error(str);
+ throw new IllegalStateException(str.toString());
+ }
+
+ private int getAspectIndex(List<DeploymentAspect> sortedAspects,
DeploymentAspect aspect)
+ {
+ int index = -1;
+ Set<String> providedConditions = new
HashSet<String>(parentProvidedConditions);
+ for (int i = 0; i < sortedAspects.size(); i++)
+ {
+ DeploymentAspect sortedAspect = sortedAspects.get(i);
+ providedConditions.addAll(sortedAspect.getProvidesAsSet());
+ if (providedConditions.containsAll(aspect.getRequiresAsSet()))
+ {
+ index = i + 1;
+ break;
+ }
+ }
+ return index;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/DeploymentAspectManagerImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentState;
+
+/**
+ * A general service deployment manger.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ */
+public class DeploymentAspectManagerImpl implements DeploymentAspectManager
+{
+ // provide logging
+ private static final Logger log =
Logger.getLogger(DeploymentAspectManagerImpl.class);
+
+ private String name;
+ private DeploymentAspectManager parent;
+ private List<DeploymentAspect> depAspects = new
ArrayList<DeploymentAspect>();
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public DeploymentAspectManager getParent()
+ {
+ return parent;
+ }
+
+ public void setParent(DeploymentAspectManager parent)
+ {
+ this.parent = parent;
+ }
+
+ public List<DeploymentAspect> getDeploymentAspects()
+ {
+ return Collections.unmodifiableList(depAspects);
+ }
+
+ public void setDeploymentAspects(List<DeploymentAspect> aspects)
+ {
+ depAspects.clear();
+ depAspects.addAll(aspects);
+
+ if (log.isTraceEnabled())
+ {
+ // Debug the aspect list
+ StringBuilder builder = new StringBuilder("setDeploymentAspects on " +
name);
+ for (DeploymentAspect aspect : aspects)
+ builder.append("\n " + aspect.getClass().getName() + "
provides: " + aspect.getProvidesAsSet() + " requires: " +
aspect.getRequiresAsSet());
+
+ log.trace(builder);
+ }
+ }
+
+ /**
+ * Iterate over the registered deployers calls create on each.
+ * Iterate over the registered deployers again and calls start on each.
+ * If start fails it automaticall calls destroy in the reverse order
+ * starting with the deployer that failed
+ */
+ public void deploy(Deployment dep)
+ {
+ // create the deployment
+ Set<String> providedConditions = new HashSet<String>();
+ for (int i = 0; i < getDeploymentAspects().size(); i++)
+ {
+ DeploymentAspect aspect = getDeploymentAspects().get(i);
+
+ // Check that all required aspects are met
+ /*
+ TODO: This should done by adding all provided conditions to the Deployment
+ when being executed. Otherwise we will miss the parent provided conditions
here
+
+ Set<String> requiredSet = aspect.getRequiresAsSet();
+ requiredSet.remove(DeploymentAspect.LAST_DEPLOYMENT_ASPECT);
+ if (providedConditions.containsAll(requiredSet) == false)
+ throw new IllegalStateException("Required conditions '" +
aspect.getRequires() + "' not satisfied by '" + providedConditions +
"' for: " + aspect);
+ */
+
+ providedConditions.addAll(aspect.getProvidesAsSet());
+ }
+
+ // start the deployment
+ for (int i = 0; i < getDeploymentAspects().size(); i++)
+ {
+ DeploymentAspect aspect = getDeploymentAspects().get(i);
+ try
+ {
+ logInvocation(aspect, "Start");
+ aspect.start(dep);
+ }
+ catch (RuntimeException rte)
+ {
+ while (i-- >= 0)
+ {
+ // destroy the deployment
+ failsafeStop(aspect, dep);
+ }
+ throw rte;
+ }
+ }
+
+ dep.setState(DeploymentState.STARTED);
+ }
+
+ public void undeploy(Deployment dep)
+ {
+ for (int i = getDeploymentAspects().size(); 0 < i; i--)
+ {
+ DeploymentAspect aspect = getDeploymentAspects().get(i - 1);
+ failsafeStop(aspect, dep);
+ }
+
+ dep.setState(DeploymentState.STOPPED);
+ }
+
+ private void failsafeStop(DeploymentAspect aspect, Deployment dep)
+ {
+ try
+ {
+ logInvocation(aspect, "Stop");
+ aspect.stop(dep);
+ }
+ catch (RuntimeException rte)
+ {
+ WSFDeploymentException.rethrow(rte);
+ }
+ }
+
+ private void logInvocation(DeploymentAspect aspect, String method)
+ {
+ if (log.isTraceEnabled())
+ {
+ String name = aspect.getClass().getName();
+ name = name.substring(name.lastIndexOf(".") + 1);
+ log.trace("[" + this.name + "]" + name + ":" +
method);
+ }
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAPIDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAPIDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAPIDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.ResourceLoaderAdapter;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+
+/**
+ * A deployment aspect for JAXWS Endpoint API endpoints.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 31-Jul-2007
+ */
+// TODO: [JBWS-2674] review this deployment aspect once AS IL is rewritten
+public class EndpointAPIDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ dep.setType(DeploymentType.JAXWS_JSE);
+
+ if (dep instanceof ArchiveDeployment)
+ {
+ ArchiveDeployment arc = (ArchiveDeployment)dep;
+ UnifiedVirtualFile rootFile = arc.getRootFile();
+ if (rootFile == null)
+ {
+ rootFile = new ResourceLoaderAdapter(dep.getInitialClassLoader());
+ arc.setRootFile(rootFile);
+ }
+ }
+
+ ClassLoader rtcl = dep.getRuntimeClassLoader();
+ if (rtcl == null)
+ {
+ // TODO: What's this? Look's quiet hacky...
+ log.warn("Using inital class laoder as runtime laoder. Hack?", new
IllegalArgumentException());
+ dep.setRuntimeClassLoader(dep.getInitialClassLoader());
+ }
+
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ if (ep.getShortName() == null)
+ {
+ String name = ep.getTargetBeanName();
+ String shortName = name.substring(name.lastIndexOf('.') + 1);
+ ep.setShortName(shortName);
+ }
+
+ if (((HttpEndpoint)ep).getURLPattern() == null)
+ {
+ ((HttpEndpoint)ep).setURLPattern("/*");
+ }
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointAddressDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData.JSEResourceCollection;
+
+/**
+ * A deployer that assigns the endpoint address.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 19-May-2007
+ */
+public class EndpointAddressDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ String contextRoot = dep.getService().getContextRoot();
+ if (contextRoot == null)
+ throw new IllegalStateException("Cannot obtain context root");
+
+ // TODO: remove this hack - review API
+ String protocol = (String)dep.getService().getProperty("protocol");
+ String host = (String)dep.getService().getProperty("host");
+ Integer port = (Integer)dep.getService().getProperty("port");
+ Integer securePort = null;
+
+ if (protocol == null)
+ {
+ SPIProvider provider = SPIProviderResolver.getInstance().getProvider();
+ ServerConfigFactory spi = provider.getSPI(ServerConfigFactory.class);
+ ServerConfig serverConfig = spi.getServerConfig();
+
+ host = serverConfig.getWebServiceHost();
+ port = serverConfig.getWebServicePort();
+ securePort = serverConfig.getWebServiceSecurePort();
+ }
+ Map<String, Endpoint> endpointsMap = new HashMap<String, Endpoint>();
+ List<Endpoint> deleteList = new LinkedList<Endpoint>();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ boolean confidential = isConfidentialTransportGuarantee(dep, ep);
+ int currentPort = confidential ? securePort : port;
+ String hostAndPort = host + (currentPort > 0 ? ":" + currentPort :
"");
+
+ HttpEndpoint httpEp = (HttpEndpoint)ep;
+ String urlPattern = httpEp.getURLPattern();
+ if (urlPattern == null)
+ throw new IllegalStateException("Cannot obtain url pattern");
+
+ if (urlPattern.endsWith("/*"))
+ urlPattern = urlPattern.substring(0, urlPattern.length() - 2);
+
+ protocol = confidential ? "https://" : "http://";
+ String address = protocol + hostAndPort + contextRoot + urlPattern;
+ httpEp.setAddress(address);
+ //JBWS-2957: EJB3 binds the same endpoint class to multiple beans at multiple
JNDI locations;
+ //generally speaking we can't have multiple endpoints published at the same
address and we
+ //can't ensure that completely in AS integration, since the publish address
is final just here
+ if (!endpointsMap.containsKey(address))
+ {
+ endpointsMap.put(address, httpEp);
+ }
+ else
+ {
+ deleteList.add(httpEp);
+ }
+ }
+ //Remove endpoints with duplicated address
+ for (Endpoint ep : deleteList)
+ {
+ dep.getService().getEndpoints().remove(ep);
+ }
+ }
+
+ protected boolean isConfidentialTransportGuarantee(Deployment dep, Endpoint ep)
+ {
+ String transportGuarantee = null;
+ if (DeploymentType.JAXWS_JSE == dep.getType())
+ {
+ JSEArchiveMetaData webMetaData = dep.getAttachment(JSEArchiveMetaData.class);
+ if (webMetaData != null)
+ {
+ String servletLink = ep.getShortName();
+ Map<String, String> servletMappings =
webMetaData.getServletMappings();
+ String urlPattern = servletMappings.get(servletLink);
+
+ if (urlPattern == null)
+ throw new RuntimeException("Cannot find <url-pattern> for
servlet-name: " + servletLink);
+
+ List<JSESecurityMetaData> securityList =
webMetaData.getSecurityMetaData();
+ for (JSESecurityMetaData currentSecurity : securityList)
+ {
+ if (currentSecurity.getTransportGuarantee() != null &&
currentSecurity.getTransportGuarantee().length() > 0)
+ {
+ for (JSEResourceCollection currentCollection :
currentSecurity.getWebResources())
+ {
+ for (String currentUrlPattern : currentCollection.getUrlPatterns())
+ {
+ if (urlPattern.equals(currentUrlPattern) ||
"/*".equals(currentUrlPattern))
+ {
+ transportGuarantee = currentSecurity.getTransportGuarantee();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (DeploymentType.JAXWS_EJB3 == dep.getType())
+ {
+ //TODO Unify annotation scans
+ Class implClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)implClass.getAnnotation(WebContext.class);
+ if (anWebContext != null)
+ {
+ transportGuarantee = anWebContext.transportGuarantee();
+ }
+ if (anWebContext == null || transportGuarantee == null ||
transportGuarantee.length() == 0)
+ {
+ String ejbName = ep.getShortName();
+ EJBArchiveMetaData ejbArchiveMD =
dep.getAttachment(EJBArchiveMetaData.class);
+ EJBMetaData ejbMD = ejbArchiveMD != null ?
ejbArchiveMD.getBeanByEjbName(ejbName) : null;
+ EJBSecurityMetaData ejbSecurityMD = ejbMD != null ?
ejbMD.getSecurityMetaData() : null;
+
+ if (ejbSecurityMD != null)
+ {
+ transportGuarantee = ejbSecurityMD.getTransportGuarantee();
+ }
+ }
+ }
+ return "CONFIDENTIAL".equals(transportGuarantee);
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointHandlerDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointHandlerDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointHandlerDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
+import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.invocation.RequestHandlerFactory;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.MDBMetaData;
+
+/**
+ * A deployer that assigns the handlers to the Endpoint
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class EndpointHandlerDeploymentAspect extends AbstractDeploymentAspect
+{
+ private SPIProvider spiProvider;
+
+ public EndpointHandlerDeploymentAspect()
+ {
+ super();
+ spiProvider = SPIProviderResolver.getInstance().getProvider();
+ }
+
+ @Override
+ public void start(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ // Associate a request handler
+ ep.setRequestHandler(getRequestHandler(dep));
+
+ // Associate a lifecycle handler
+ ep.setLifecycleHandler(getLifecycleHandler(dep));
+
+ // Associate an invocation handler
+ // Invocation handlers are assigned per container or per stack
+ InvocationHandler invocationHandler = getInvocationHandler(ep);
+ if (invocationHandler != null)
+ ep.setInvocationHandler(invocationHandler);
+
+ }
+ }
+
+ private RequestHandler getRequestHandler(Deployment dep)
+ {
+ return spiProvider.getSPI(RequestHandlerFactory.class).newRequestHandler();
+ }
+
+ private LifecycleHandler getLifecycleHandler(Deployment dep)
+ {
+ return spiProvider.getSPI(LifecycleHandlerFactory.class).newLifecycleHandler();
+ }
+
+ private InvocationHandler getInvocationHandler(Endpoint ep)
+ {
+ Deployment dep = ep.getService().getDeployment();
+ DeploymentType depType = dep.getType();
+
+ String key = depType.toString();
+
+ // Use a special key for MDB endpoints
+ EJBArchiveMetaData uapp = dep.getAttachment(EJBArchiveMetaData.class);
+ if (uapp != null)
+ {
+ EJBMetaData bmd = uapp.getBeanByEjbName(ep.getShortName());
+ if (depType == DeploymentType.JAXRPC_EJB21 && bmd instanceof
MDBMetaData)
+ {
+ key = InvocationType.JAXRPC_MDB21.toString();
+ }
+ else if (depType == DeploymentType.JAXWS_EJB3 && bmd instanceof
MDBMetaData)
+ {
+ key = InvocationType.JAXWS_MDB3.toString();
+ }
+ }
+
+ InvocationType type = InvocationType.valueOf(key);
+ InvocationHandler invocationHandler =
spiProvider.getSPI(InvocationHandlerFactory.class).newInvocationHandler(type);
+ return invocationHandler;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointLifecycleDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointLifecycleDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointLifecycleDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.LifecycleHandler;
+import org.jboss.wsf.spi.deployment.Service;
+
+/**
+ * A deployer that that calls the endpoint lifecycle handler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class EndpointLifecycleDeploymentAspect extends AbstractDeploymentAspect
+{
+
+ @Override
+ public void start(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ getLifecycleHandler(ep, true).start(ep);
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ Service service = dep.getService();
+ if (service != null)
+ {
+ for (Endpoint ep : service.getEndpoints())
+ {
+ LifecycleHandler lifecycleHandler = getLifecycleHandler(ep, false);
+ if (lifecycleHandler != null)
+ lifecycleHandler.stop(ep);
+ }
+ }
+ }
+
+ private LifecycleHandler getLifecycleHandler(Endpoint ep, boolean assertHandler)
+ {
+ LifecycleHandler lifecycleHandler = ep.getLifecycleHandler();
+ if (lifecycleHandler == null && assertHandler)
+ throw new IllegalStateException("LifecycleHandler not initialised");
+
+ return lifecycleHandler;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointMetricsDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointMetricsDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointMetricsDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.EndpointMetricsFactory;
+
+/**
+ * A deployer that assigns the metrics to the Endpoint
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 20-Jun-2007
+ */
+public class EndpointMetricsDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ SPIProvider provider = SPIProviderResolver.getInstance().getProvider();
+ EndpointMetricsFactory factory = provider.getSPI(EndpointMetricsFactory.class);
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ EndpointMetrics metrics = factory.newEndpointMetrics();
+ ep.setEndpointMetrics(metrics);
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointNameDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointNameDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointNameDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.MDBMetaData;
+
+/**
+ * A deployer that assigns the complete name to the Endpoint
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class EndpointNameDeploymentAspect extends AbstractDeploymentAspect
+{
+ @Override
+ public void start(Deployment dep)
+ {
+ String contextRoot = dep.getService().getContextRoot();
+ if (contextRoot == null || contextRoot.startsWith("/") == false)
+ throw new IllegalStateException("Context root expected to start with
leading slash: " + contextRoot);
+
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ StringBuilder name = new StringBuilder(Endpoint.SEPID_DOMAIN + ":");
+ name.append(Endpoint.SEPID_PROPERTY_CONTEXT + "=" +
contextRoot.substring(1) + ",");
+ name.append(Endpoint.SEPID_PROPERTY_ENDPOINT + "=" +
ep.getShortName());
+
+ // Append the JMS destination, for an MDB endpoint
+ EJBArchiveMetaData uapp = dep.getAttachment(EJBArchiveMetaData.class);
+ if (uapp != null)
+ {
+ EJBMetaData bmd = uapp.getBeanByEjbName(ep.getShortName());
+ if (bmd instanceof MDBMetaData)
+ {
+ String destName = ((MDBMetaData)bmd).getDestinationJndiName();
+ name.append(",jms=" + destName);
+ }
+ }
+
+ ep.setName(ObjectNameFactory.create(name.toString()));
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+
+import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.framework.management.recording.ManagedRecordProcessor;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * A deployer that sets the record processors for each endpoint
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 12-Dec-2007
+ */
+public class EndpointRecordProcessorDeploymentAspect extends AbstractDeploymentAspect
+{
+ private MBeanServer mbeanServer;
+ private List<RecordProcessor> processors;
+
+ public void setProcessors(List<RecordProcessor> processors)
+ {
+ this.processors = processors;
+ }
+
+ @Override
+ public void start(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ List<RecordProcessor> processorList = new
LinkedList<RecordProcessor>();
+ if (processors != null)
+ {
+ for (RecordProcessor pr : processors)
+ {
+ try
+ {
+ RecordProcessor clone = (RecordProcessor)pr.clone();
+ registerRecordProcessor(clone, ep);
+ processorList.add(clone);
+ }
+ catch (CloneNotSupportedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ ep.setRecordProcessors(processorList);
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ List<RecordProcessor> processors = ep.getRecordProcessors();
+ for (RecordProcessor processor : processors)
+ {
+ this.unregisterRecordProcessor(processor, ep);
+ }
+ }
+ }
+
+ private void registerRecordProcessor(RecordProcessor processor, Endpoint ep)
+ {
+ try
+ {
+ mbeanServer.registerMBean(processor, ObjectNameFactory.create(ep.getName() +
",recordProcessor=" + processor.getName()));
+ }
+ catch (JMException ex)
+ {
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
+ }
+ }
+
+ private void unregisterRecordProcessor(RecordProcessor processor, Endpoint ep)
+ {
+ try
+ {
+ mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() +
",recordProcessor=" + processor.getName()));
+ }
+ catch (JMException ex)
+ {
+ log.error("Cannot unregister record processor with JMX server", ex);
+ }
+ }
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRegistryDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+
+/**
+ * A deployer that registers the endpoints
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ */
+public class EndpointRegistryDeploymentAspect extends AbstractDeploymentAspect
+{
+ private EndpointRegistry registry;
+
+ public void start(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ if (registry == null)
+ registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ registry.register(ep);
+ }
+ }
+
+ public void stop(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ if (registry == null)
+ registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ registry.unregister(ep);
+ }
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/JAXBIntroDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/JAXBIntroDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/JAXBIntroDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.wsf.framework.deployment;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.jaxb.intros.BindingCustomizationFactory;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.binding.JAXBBindingCustomization;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * Installs jaxbintro binding customization into the deployment
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
+ */
+public class JAXBIntroDeploymentAspect extends AbstractDeploymentAspect
+{
+ private static Logger logger = Logger.getLogger(JAXBIntroDeploymentAspect.class);
+ private static final String META_INF_JAXB_INTROS_XML =
"META-INF/jaxb-intros.xml";
+ private static final String WEB_INF_JAXB_INTROS_XML =
"WEB-INF/jaxb-intros.xml";
+
+ public void start(Deployment deployment)
+ {
+ // assert ArchiveDeployment
+ if(! (deployment instanceof ArchiveDeployment) )
+ {
+ if (log.isTraceEnabled())
+ log.trace("JAXBIntroDeploymentAspect doesn't work on " +
deployment.getClass());
+ return;
+ }
+
+ ArchiveDeployment archive = (ArchiveDeployment)deployment;
+ InputStream introsConfigStream = null;
+
+ try
+ {
+ // META-INF first
+ UnifiedVirtualFile vfs =
archive.getRootFile().findChild(META_INF_JAXB_INTROS_XML);
+ introsConfigStream = vfs.toURL().openStream();
+ } catch (Exception e) {}
+
+ if(null == introsConfigStream)
+ {
+ try
+ {
+ // WEB-INF second
+ UnifiedVirtualFile vfs =
archive.getRootFile().findChild(WEB_INF_JAXB_INTROS_XML);
+ introsConfigStream = vfs.toURL().openStream();
+ } catch (Exception e) {
+ return;
+ }
+ }
+
+ try
+ {
+
+ if(introsConfigStream != null)
+ {
+ BindingCustomization jaxbCustomizations = new JAXBBindingCustomization();
+ BindingCustomizationFactory.populateBindingCustomization(introsConfigStream,
jaxbCustomizations);
+
+ // Add the customizations to the deployment too; later consumed by
BusDeploymentAspect in CXF stack
+ deployment.addAttachment(BindingCustomization.class, jaxbCustomizations);
+ // JBossWSBeanConfigurer#configureService becomes the consumer later on
+ for(Endpoint endpoint : deployment.getService().getEndpoints())
+ {
+ endpoint.addAttachment(BindingCustomization.class, jaxbCustomizations);
+ }
+
+ }
+
+ }
+ finally
+ {
+ if(introsConfigStream != null)
+ {
+ try {
+ introsConfigStream.close();
+ } catch (IOException e) {
+ logger.error("[" + deployment.getService().getContextRoot() +
"] Error closing JAXB Introductions Configurations stream ", e);
+ }
+ }
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.wsf.framework.deployment;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * A resource resolver implementation using unified virtual files
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Nov-2009
+ *
+ */
+public class ResourceResolverImpl implements ResourceResolver
+{
+ private static Logger log = Logger.getLogger(ResourceResolverImpl.class);
+
+ private UnifiedVirtualFile rootFile;
+ private Collection<UnifiedVirtualFile> metadataFiles;
+
+ public ResourceResolverImpl(UnifiedVirtualFile rootFile,
Collection<UnifiedVirtualFile> metadataFiles)
+ {
+ this.rootFile = rootFile;
+ this.metadataFiles = metadataFiles;
+ }
+
+ public URL resolve(String resourcePath) throws IOException
+ {
+ URL resourceURL = null;
+ if (resourcePath != null && resourcePath.length() > 0)
+ {
+ if (resourcePath.startsWith("/"))
+ resourcePath = resourcePath.substring(1);
+
+ try
+ {
+ // assign an absolute URL
+ resourceURL = new URL(resourcePath);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ if (resourceURL == null && rootFile != null)
+ {
+ try
+ {
+ UnifiedVirtualFile vfResource = rootFile.findChild(resourcePath);
+ resourceURL = vfResource.toURL();
+ }
+ catch (IOException e)
+ {
+ if (metadataFiles == null || metadataFiles.isEmpty())
+ {
+ throw e;
+ }
+ else
+ {
+ if (log.isTraceEnabled())
+ log.trace("Cannot get " + resourcePath + " from root
file, trying with additional metadata files", e);
+ }
+ }
+ }
+ //scan additional metadata files (for instance originally attached to a
VFSDeploymentUnit)
+ if (resourceURL == null && metadataFiles != null &&
!metadataFiles.isEmpty())
+ {
+ UnifiedVirtualFile vfResource = null;
+ for (Iterator<UnifiedVirtualFile> it = metadataFiles.iterator();
it.hasNext() && vfResource == null;)
+ {
+ UnifiedVirtualFile uvf = it.next();
+ URL wsdlUrl = uvf.toURL();
+ String wsdlPath = wsdlUrl.getPath();
+ if (wsdlPath.startsWith("/"))
+ wsdlPath = wsdlPath.substring(1);
+ if (resourcePath.equals(wsdlPath))
+ {
+ vfResource = uvf;
+ }
+ else
+ {
+ try
+ {
+ vfResource = uvf.findChild(resourcePath);
+ }
+ catch (IOException e)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Cannot get " + resourcePath + " from
" + uvf, e);
+ }
+ }
+ }
+ if (vfResource == null)
+ throw new IOException("Could not find " + resourcePath + "
in the additional metadatafiles!");
+
+ resourceURL = vfResource.toURL();
+ }
+ }
+ return resourceURL;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/URLPatternDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/URLPatternDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/URLPatternDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.StringTokenizer;
+
+import javax.jws.WebService;
+
+import org.jboss.ws.Constants;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+
+/**
+ * A deployer that assigns the URLPattern to endpoints.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 19-May-2007
+ */
+public class URLPatternDeploymentAspect extends AbstractDeploymentAspect
+{
+
+ @Override
+ public void start(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ HttpEndpoint httpEp = (HttpEndpoint)ep;
+ String urlPattern = httpEp.getURLPattern();
+ if (urlPattern == null)
+ {
+ urlPattern = getExplicitPattern(dep, ep);
+ if (urlPattern == null)
+ urlPattern = getImplicitPattern(dep, ep);
+
+ // Always prefix with '/'
+ if (urlPattern.startsWith("/") == false)
+ urlPattern = "/" + urlPattern;
+
+ httpEp.setURLPattern(urlPattern);
+ }
+ }
+ }
+
+ protected String getExplicitPattern(Deployment dep, Endpoint ep)
+ {
+ String urlPattern = null;
+
+ // #1 For JSE lookup the url-pattern from the servlet mappings
+ JSEArchiveMetaData webMetaData = dep.getAttachment(JSEArchiveMetaData.class);
+ if (webMetaData != null)
+ {
+ String epName = ep.getShortName();
+ urlPattern = webMetaData.getServletMappings().get(epName);
+ if (urlPattern == null)
+ throw new IllegalStateException("Cannot obtain servlet mapping for:
" + epName);
+ }
+
+ // #2 Use the explicit urlPattern from port-component/port-component-uri
+ EJBArchiveMetaData appMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (appMetaData != null && appMetaData.getBeanByEjbName(ep.getShortName())
!= null)
+ {
+ EJBMetaData bmd = appMetaData.getBeanByEjbName(ep.getShortName());
+ urlPattern = bmd.getPortComponentURI();
+ if (urlPattern != null)
+ {
+ String contextRoot = dep.getService().getContextRoot();
+
+ if (urlPattern.startsWith("/") == false)
+ urlPattern = "/" + urlPattern;
+
+ StringTokenizer st = new StringTokenizer(urlPattern, "/");
+ if (st.countTokens() > 1 && urlPattern.startsWith(contextRoot +
"/"))
+ {
+ urlPattern = urlPattern.substring(contextRoot.length());
+ }
+ }
+ }
+
+ // #3 For EJB use @WebContext.urlPattern
+ if (urlPattern == null)
+ {
+ Class beanClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)beanClass.getAnnotation(WebContext.class);
+ if (anWebContext != null && anWebContext.urlPattern().length() > 0)
+ {
+ urlPattern = anWebContext.urlPattern();
+ }
+ else if (!Constants.BC_CONTEXT_MODE)
+ {
+ WebService webServiceAnnotation =
(WebService)beanClass.getAnnotation(WebService.class);
+ String name = webServiceAnnotation != null ? webServiceAnnotation.name() :
null;
+ if (name != null && name.length() > 0)
+ {
+ urlPattern = name;
+ }
+ else
+ {
+ String fullClassName = beanClass.getName();
+ urlPattern =
fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
+ }
+ if (webServiceAnnotation != null &&
!"".equals(webServiceAnnotation.serviceName()))
+ {
+ urlPattern = webServiceAnnotation.serviceName() + "/" +
urlPattern;
+ }
+
+ }
+
+ }
+
+ return urlPattern;
+ }
+
+ protected String getImplicitPattern(Deployment dep, Endpoint ep)
+ {
+ // #4 Fallback to the ejb-name
+ String urlPattern = ep.getShortName();
+ return urlPattern;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/VirtualHostDeploymentAspect.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.deployment;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+
+/**
+ * A deployer that assigns the virtual hosts to the service
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 10-Jul-2008
+ */
+public class VirtualHostDeploymentAspect extends AbstractDeploymentAspect
+{
+
+ @Override
+ public void start(Deployment dep)
+ {
+ if ( DeploymentType.JAXWS_EJB3.equals(dep.getType()))
+ {
+ dep.getService().setVirtualHosts(getExplicitVirtualHosts(dep));
+ }
+ }
+
+ protected List<String> getExplicitVirtualHosts(Deployment dep)
+ {
+ String[] virtualHosts = null;
+
+ // Use the virtual hosts from @WebContext.virtualHosts
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ Class implClass = ep.getTargetBeanClass();
+ WebContext anWebContext =
(WebContext)implClass.getAnnotation(WebContext.class);
+ if (anWebContext != null && anWebContext.virtualHosts() != null
&& anWebContext.virtualHosts().length > 0)
+ {
+ String[] anVirtualHosts = anWebContext.virtualHosts();
+ // Avoid modifying the annotation values.
+ String[] temp = new String[anVirtualHosts.length];
+ System.arraycopy(anVirtualHosts, 0, temp, 0, anVirtualHosts.length);
+ Arrays.sort(temp);
+
+ if (virtualHosts == null)
+ {
+ virtualHosts = temp;
+ }
+ else
+ {
+ if (Arrays.equals(virtualHosts, temp) == false)
+ {
+ throw new IllegalStateException("virtualHosts must be the same for
all deployed endpoints");
+ }
+ }
+ }
+ }
+
+ if ( virtualHosts != null )
+ {
+ return Arrays.asList(virtualHosts);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/WebservicesDescriptorParserImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/WebservicesDescriptorParserImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/WebservicesDescriptorParserImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.framework.deployment;
+
+import java.net.URL;
+
+import org.jboss.wsf.spi.metadata.webservices.WebservicesDescriptorParser;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * Webservices descriptor parser implementation.
+ *
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ * @author alessio.soldano(a)jboss.com
+ */
+public final class WebservicesDescriptorParserImpl implements
WebservicesDescriptorParser
+{
+ private String descriptorName;
+
+ @Override
+ public String getDescriptorName()
+ {
+ return this.descriptorName;
+ }
+
+ /**
+ * Invoked via MC.
+ * @param descriptorName
+ */
+ public void setDescriptorName(final String descriptorName)
+ {
+ this.descriptorName = descriptorName;
+ }
+
+ @Override
+ public WebservicesMetaData parse(URL url)
+ {
+ return WebservicesFactory.load(url);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/jms/WebservicesDescriptorProcessorImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/jms/WebservicesDescriptorProcessorImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/deployment/jms/WebservicesDescriptorProcessorImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.framework.deployment.jms;
+
+import org.jboss.wsf.spi.metadata.webservices.WebservicesDescriptorProcessor;
+
+/**
+ * Webservices descriptor processor implementation.
+ *
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+@Deprecated
+public final class WebservicesDescriptorProcessorImpl implements
WebservicesDescriptorProcessor
+{
+ private String descriptorName;
+ private boolean isValidating;
+
+ /* (non-Javadoc)
+ * @see org.jboss.wsf.spi.metadata.DescriptorProcessor#getDescriptorName()
+ */
+ @Override
+ public String getDescriptorName()
+ {
+ return this.descriptorName;
+ }
+
+ /**
+ * Invoked via MC.
+ * @param descriptorName
+ */
+ public void setDescriptorName(final String descriptorName)
+ {
+ this.descriptorName = descriptorName;
+ }
+
+// /* (non-Javadoc)
+// * @see org.jboss.wsf.spi.metadata.DescriptorProcessor#getFactory(java.net.URL)
+// */
+// public ObjectModelFactory getFactory(final URL url)
+// {
+// if (url == null)
+// throw new IllegalArgumentException("URL cannot be null");
+//
+// return new WebservicesFactory(url);
+// }
+
+ /* (non-Javadoc)
+ * @see org.jboss.wsf.spi.metadata.DescriptorProcessor#isValidating()
+ */
+ @Override
+ public boolean isValidating()
+ {
+ return this.isValidating;
+ }
+
+ /**
+ * Invoked via MC.
+ * @param isValidating
+ */
+ public void setValidating(final boolean isValidating)
+ {
+ this.isValidating = isValidating;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/DefaultResourceInjectorFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/DefaultResourceInjectorFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/DefaultResourceInjectorFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.invocation;
+
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+import org.jboss.wsf.spi.invocation.ResourceInjector;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jul 19, 2007
+ */
+public class DefaultResourceInjectorFactory extends ResourceInjectorFactory
+{
+ public ResourceInjector newResourceInjector()
+ {
+ return new WebServiceContextInjector();
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.invocation;
+
+
+import java.net.URL;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.framework.management.recording.RecordFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordGroupAssociation;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+import org.jboss.wsf.spi.management.recording.Record.MessageType;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+/**
+ * This handler is responsible for collecting the information about the
+ * messages being exchanged and recording them on the server side. This
+ * is performed delegating to the RecordProcessors installed into the
+ * current endpoint.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class RecordingServerHandler extends GenericSOAPHandler
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(RecordingServerHandler.class);
+
+ @SuppressWarnings("unchecked")
+ protected boolean handleInbound(MessageContext ctx)
+ {
+ Endpoint endpoint = EndpointAssociation.getEndpoint();
+ if (endpoint != null && isRecording(endpoint))
+ {
+ Record record = RecordFactory.newRecord();
+ RecordGroupAssociation.pushGroupID(record.getGroupID());
+ record.setDate(new Date());
+ HttpServletRequest httpServletRequest =
(HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST);
+ if (httpServletRequest != null)
+ {
+ try
+ {
+ record.setDestinationHost(new
URL(httpServletRequest.getRequestURL().toString()).getHost());
+ record.setSourceHost(httpServletRequest.getRemoteHost());
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to read from the http servlet request! " +
e.getMessage());
+ }
+ }
+
record.setHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_REQUEST_HEADERS)));
+ record.setMessageType(MessageType.INBOUND);
+ record.setOperation((QName)ctx.get(MessageContext.WSDL_OPERATION));
+ boolean processEnvelope = false;
+ for (Iterator<RecordProcessor> it =
endpoint.getRecordProcessors().iterator(); it.hasNext() && !processEnvelope; )
+ {
+ processEnvelope = it.next().isProcessEnvelope();
+ }
+ if (processEnvelope) //skip message processing if not required since it's
very time-consuming
+ {
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+ try
+ {
+ SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
+ if (soapEnv != null)
+ {
+ record.setEnvelope(DOMWriter.printNode(soapEnv, true));
+ }
+ }
+ catch (SOAPException ex)
+ {
+ log.error("Cannot trace SOAPMessage", ex);
+ }
+ }
+ endpoint.processRecord(record);
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected boolean handleOutbound(MessageContext ctx)
+ {
+ Endpoint endpoint = EndpointAssociation.getEndpoint();
+ if (endpoint != null && isRecording(endpoint))
+ {
+ String groupID = RecordGroupAssociation.popGroupID();
+ Record record = RecordFactory.newRecord(groupID);
+ record.setDate(new Date());
+
record.setHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_RESPONSE_HEADERS)));
+ record.setMessageType(MessageType.OUTBOUND);
+ record.setOperation((QName)ctx.get(MessageContext.WSDL_OPERATION));
+ boolean processEnvelope = false;
+ for (Iterator<RecordProcessor> it =
endpoint.getRecordProcessors().iterator(); it.hasNext() && !processEnvelope; )
+ {
+ processEnvelope = it.next().isProcessEnvelope();
+ }
+ if (processEnvelope) //skip message processing if not required since it's
very time-consuming
+ {
+ SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+ try
+ {
+ SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
+ if (soapEnv != null)
+ {
+ record.setEnvelope(DOMWriter.printNode(soapEnv, true));
+ }
+ }
+ catch (SOAPException ex)
+ {
+ log.error("Cannot trace SOAPMessage", ex);
+ }
+ }
+ endpoint.processRecord(record);
+ }
+ return true;
+ }
+
+ public boolean handleFault(MessageContext ctx)
+ {
+ return handleOutbound(ctx);
+ }
+
+ /**
+ * Returns true if there's at least a record processor in recording mode
+ *
+ * @param endpoint
+ * @return
+ */
+ private boolean isRecording(Endpoint endpoint)
+ {
+ List<RecordProcessor> processors = endpoint.getRecordProcessors();
+ if (processors == null || processors.isEmpty())
+ {
+ return false;
+ }
+ for (RecordProcessor processor : processors)
+ {
+ if (processor.isRecording())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.invocation;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.common.injection.InjectionHelper;
+import org.jboss.wsf.spi.invocation.ResourceInjector;
+
+/**
+ * Inject the JAXWS WebServiceContext
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author ropalka(a)redhat.com
+ */
+public class WebServiceContextInjector extends ResourceInjector
+{
+ public void inject(Object instance, WebServiceContext context)
+ {
+ InjectionHelper.injectWebServiceContext(instance, context);
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/framework/management/ContextServlet.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/management/ContextServlet.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/ContextServlet.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Set;
+
+import javax.management.ObjectName;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+
+/**
+ * The servlet that that is associated with context /jbossws
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 21-Mar-2005
+ */
+public class ContextServlet extends HttpServlet
+{
+ // provide logging
+ protected final Logger log = Logger.getLogger(ContextServlet.class);
+
+ protected EndpointRegistry epRegistry;
+
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ epRegistry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ }
+
+ /** Process GET requests.
+ */
+ public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
+ {
+ PrintWriter writer = res.getWriter();
+ res.setContentType("text/html");
+
+ writer.print("<html>");
+ setupHTMLResponseHeader(writer);
+
+ URL requestURL = new URL(req.getRequestURL().toString());
+
+ writer.print("<body>");
+
+ writer.print("<div
class='pageHeader'>JBossWS/Services</div>");
+ writer.print("<div class='pageSection'>");
+ writer.print("<fieldset>");
+ writer.print("<legend><b>Registered Service
Endpoints</b></legend>");
+ writer.print("<table>");
+
+ // begin iteration
+ Set<ObjectName> epNames = epRegistry.getEndpoints();
+
+ if (epNames.isEmpty())
+ {
+ writer.print("<tr>");
+ writer.print(" <td><h3>There are currently no endpoints
deployed</h3></td>");
+ writer.print("</tr>");
+ }
+
+ for (ObjectName oname : epNames)
+ {
+ Endpoint ep = epRegistry.getEndpoint(oname);
+
+ writer.print("<tr>");
+ writer.print(" <td>Endpoint Name</td>");
+ writer.print(" <td>" + ep.getName() + "</td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td>Endpoint Address</td>");
+ writer.print(" <td>" + getAddressHtmlTag(requestURL, ep) +
"</td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td colspan=2>");
+ writer.print(" ");
+ writer.print("");
+
+ EndpointMetrics metrics = ep.getEndpointMetrics();
+ if (metrics != null)
+ {
+ writer.print("<table class='metrics'>");
+ writer.print("<tr>");
+ writer.print(" <td>StartTime</td>");
+ writer.print(" <td>StopTime</td>");
+ writer.print(" <td></td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td>" + metrics.getStartTime() +
"</td>");
+
+ String stopTime = metrics.getStopTime() != null ?
metrics.getStopTime().toString() : "";
+ writer.print(" <td>" + stopTime + "</td>");
+ writer.print(" <td></td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+
+ writer.print(" <td>RequestCount</td>");
+ writer.print(" <td>ResponseCount</td>");
+ writer.print(" <td>FaultCount</td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td>" + metrics.getRequestCount() +
"</td>");
+ writer.print(" <td>" + metrics.getResponseCount() +
"</td>");
+ writer.print(" <td>" + metrics.getFaultCount() +
"</td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td>MinProcessingTime</td>");
+ writer.print(" <td>MaxProcessingTime</td>");
+ writer.print(" <td>AvgProcessingTime</td>");
+ writer.print("</tr>");
+ writer.print("<tr>");
+ writer.print(" <td>" + metrics.getMinProcessingTime() +
"</td>");
+ writer.print(" <td>" + metrics.getMaxProcessingTime() +
"</td>");
+ writer.print(" <td>" + metrics.getAverageProcessingTime() +
"</td>");
+ writer.print("</tr>");
+ writer.print("");
+ writer.print("");
+ writer.print("</table>");
+ writer.print("");
+ }
+
+ writer.print(" </td>");
+ writer.print("</tr>");
+
+ writer.print("<tr><td
colspan='3'> </td></tr>");
+ }
+ // end iteration
+ writer.print("</table>");
+ writer.print("");
+ writer.print("</fieldset>");
+ writer.print("</div>");
+
+ writer.print("</body>");
+ writer.print("</html>");
+ writer.close();
+ }
+
+ private void setupHTMLResponseHeader(PrintWriter writer)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ ServerConfig serverConfig =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+ writer.println("<head>");
+ writer.println("<meta http-equiv='Content-Type content='text/html;
charset=iso-8859-1'>");
+ writer.println("<title>JBossWS / " +
serverConfig.getImplementationVersion() + "</title>");
+ writer.println("<link rel='stylesheet'
href='./styles.css'>");
+ writer.println("</head>");
+ }
+
+ private String getAddressHtmlTag(final URL requestURL, final Endpoint ep) throws
IOException
+ {
+ String address = createAddress(requestURL, ep.getAddress());
+
+ if (address.startsWith("jms"))
+ {
+ return ep.getAddress();
+ }
+
+ StringBuilder sb = new StringBuilder("<a href='");
+ sb.append(address);
+ sb.append("?wsdl'>");
+ sb.append(address);
+ sb.append("</a>");
+ return sb.toString();
+ }
+
+ private String createAddress(final URL requestURL, final String endpointAddress)
throws IOException
+ {
+ String address = endpointAddress;
+ if (address.contains(ServerConfig.UNDEFINED_HOSTNAME))
+ {
+ URL internalAddress = new URL(address);
+
+ String protocol = requestURL.getProtocol();
+ String host = requestURL.getHost();
+ int port = requestURL.getPort();
+ String path = internalAddress.getPath();
+
+ if (port > -1)
+ {
+ address = new URL(protocol, host, port, path).toString();
+ }
+ else
+ {
+ address = new URL(protocol, host, path).toString();
+ }
+ }
+
+ return address;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointMetricsFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointMetricsFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointMetricsFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.EndpointMetricsFactory;
+
+/**
+ * Endpoint Metrics factory
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 08-Aug-2007
+ */
+public class DefaultEndpointMetricsFactory extends EndpointMetricsFactory
+{
+ @Override
+ public EndpointMetrics newEndpointMetrics()
+ {
+ return new EndpointMetricsImpl();
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistry.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistry.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistry.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointResolver;
+
+import javax.management.ObjectName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A general endpoint registry.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class DefaultEndpointRegistry implements EndpointRegistry
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(DefaultEndpointRegistry.class);
+
+ private Map<ObjectName, Endpoint> endpoints = new HashMap<ObjectName,
Endpoint>();
+
+ public Endpoint getEndpoint(ObjectName epName)
+ {
+ if (epName == null)
+ throw new IllegalArgumentException("Endpoint name cannot be null");
+
+ if (isRegistered(epName) == false)
+ throw new IllegalStateException("Endpoint not registered: " +
epName);
+
+ Endpoint endpoint = endpoints.get(epName);
+ return endpoint;
+ }
+
+ public Endpoint resolve(EndpointResolver resolver)
+ {
+ return resolver.query(endpoints.values().iterator());
+ }
+
+ public boolean isRegistered(ObjectName epName)
+ {
+ if (epName == null)
+ throw new IllegalArgumentException("Endpoint name cannot be null");
+
+ return endpoints.get(epName) != null;
+ }
+
+ public Set<ObjectName> getEndpoints()
+ {
+ return endpoints.keySet();
+ }
+
+ public void register(Endpoint endpoint)
+ {
+ if (endpoint == null)
+ throw new IllegalArgumentException("Endpoint cannot be null");
+
+ ObjectName epName = endpoint.getName();
+ if (epName == null)
+ throw new IllegalStateException("Endpoint name cannot be null for: " +
endpoint);
+
+ if (isRegistered(epName))
+ throw new IllegalStateException("Endpoint already registered: " +
epName);
+
+ log.info("register: " + epName);
+ endpoints.put(epName, endpoint);
+ }
+
+ public void unregister(Endpoint endpoint)
+ {
+ if (endpoint == null)
+ throw new IllegalArgumentException("Endpoint cannot be null");
+
+ ObjectName epName = endpoint.getName();
+ if (isRegistered(epName) == false)
+ throw new IllegalStateException("Endpoint not registered: " +
epName);
+
+ log.info("remove: " + epName);
+ endpoints.remove(epName);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistryFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistryFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultEndpointRegistryFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.wsf.framework.management;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.ioc.IoCContainerProxy;
+import org.jboss.wsf.spi.ioc.IoCContainerProxyFactory;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+
+/**
+ * Retrieves registry from MC kernel.
+ *
+ * @author <a href="mailto:hbraun@redhat.com">Heiko Braun</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class DefaultEndpointRegistryFactory extends EndpointRegistryFactory
+{
+
+ private Logger log = Logger.getLogger(DefaultEndpointRegistryFactory.class);
+ /** The bean name in the kernel registry. */
+ private static final String BEAN_NAME = "WSEndpointRegistry";
+ private static final EndpointRegistry fallbackRegistry = new
DefaultEndpointRegistry();;
+
+ /**
+ * Constructor.
+ */
+ public DefaultEndpointRegistryFactory()
+ {
+ super();
+ }
+
+ /**
+ * Returns endpoint registry registered in MC kernel.
+ *
+ * @return endpoint registry
+ */
+ public EndpointRegistry getEndpointRegistry()
+ {
+ try
+ {
+ final SPIProvider spiProvider =
SPIProviderResolver.getInstance().getProvider();
+ final IoCContainerProxyFactory iocContainerFactory =
spiProvider.getSPI(IoCContainerProxyFactory.class);
+ final IoCContainerProxy iocContainer = iocContainerFactory.getContainer();
+
+ return iocContainer.getBean(DefaultEndpointRegistryFactory.BEAN_NAME,
EndpointRegistry.class);
+ }
+ catch (WSFException e)
+ {
+ log.warn("Unable to get WSEndpointRegistry from IoC, using default
one");
+ return fallbackRegistry; // JSE environment
+ }
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultJMSEndpointResolver.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultJMSEndpointResolver.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/DefaultJMSEndpointResolver.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.framework.management;
+
+/**
+ * Default resolver for JMS endpoints
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Mar-2010
+ * @Deprecated Use org.jboss.wsf.common.management.DefaultJMSEndpointResolver instead
+ */
+@Deprecated
+public class DefaultJMSEndpointResolver extends
org.jboss.wsf.common.management.DefaultJMSEndpointResolver {}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/EndpointMetricsImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/EndpointMetricsImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/EndpointMetricsImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import java.util.Date;
+
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+
+/**
+ * Service Endpoint Metrics
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 14-Dec-2005
+ */
+public class EndpointMetricsImpl implements EndpointMetrics
+{
+ private Endpoint endpoint;
+
+ private Date startTime;
+ private Date stopTime;
+ private long requestCount;
+ private long responseCount;
+ private long faultCount;
+ private long maxProcessingTime;
+ private long minProcessingTime;
+ private long avgProcessingTime;
+ private long totalProcessingTime;
+
+ public Endpoint getEndpoint()
+ {
+ return endpoint;
+ }
+
+ public void setEndpoint(Endpoint endpoint)
+ {
+ this.endpoint = endpoint;
+ }
+
+ public void start()
+ {
+ startTime = new Date();
+ stopTime = null;
+ requestCount = 0;
+ responseCount = 0;
+ faultCount = 0;
+ maxProcessingTime = 0;
+ minProcessingTime = 0;
+ avgProcessingTime = 0;
+ totalProcessingTime = 0;
+ }
+
+ public void stop()
+ {
+ stopTime = new Date();
+ }
+
+ public long processRequestMessage()
+ {
+ requestCount++;
+ return System.currentTimeMillis();
+ }
+
+ public void processResponseMessage(long beginTime)
+ {
+ responseCount++;
+ processAnyMessage(beginTime);
+ }
+
+ public void processFaultMessage(long beginTime)
+ {
+ faultCount++;
+ processAnyMessage(beginTime);
+ }
+
+ private void processAnyMessage(long beginTime)
+ {
+ if (beginTime > 0)
+ {
+ long procTime = System.currentTimeMillis() - beginTime;
+
+ if (minProcessingTime == 0)
+ minProcessingTime = procTime;
+
+ maxProcessingTime = Math.max(maxProcessingTime, procTime);
+ minProcessingTime = Math.min(minProcessingTime, procTime);
+ totalProcessingTime = totalProcessingTime + procTime;
+ avgProcessingTime = totalProcessingTime / (responseCount + faultCount);
+ }
+ }
+
+ public Date getStartTime()
+ {
+ return startTime;
+ }
+
+ public Date getStopTime()
+ {
+ return stopTime;
+ }
+
+ public long getMinProcessingTime()
+ {
+ return minProcessingTime;
+ }
+
+ public long getMaxProcessingTime()
+ {
+ return maxProcessingTime;
+ }
+
+ public long getAverageProcessingTime()
+ {
+ return avgProcessingTime;
+ }
+
+ public long getTotalProcessingTime()
+ {
+ return totalProcessingTime;
+ }
+
+ public long getRequestCount()
+ {
+ return requestCount;
+ }
+
+ public long getFaultCount()
+ {
+ return faultCount;
+ }
+
+ public long getResponseCount()
+ {
+ return responseCount;
+ }
+
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder("\nEndpoint Metrics: " +
endpoint.getName());
+ buffer.append("\n startTime=" + startTime);
+ buffer.append("\n stopTime=" + stopTime);
+ buffer.append("\n requestCount=" + requestCount);
+ buffer.append("\n responseCount=" + responseCount);
+ buffer.append("\n faultCount=" + faultCount);
+ buffer.append("\n maxProcessingTime=" + maxProcessingTime);
+ buffer.append("\n minProcessingTime=" + minProcessingTime);
+ buffer.append("\n avgProcessingTime=" + avgProcessingTime);
+ buffer.append("\n totalProcessingTime=" + totalProcessingTime);
+ return buffer.toString();
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/MBeanServerLocator.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/management/MBeanServerLocator.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/MBeanServerLocator.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import javax.management.MBeanServer;
+
+/**
+ * Locate the single instance of the MBeanServer
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ */
+public final class MBeanServerLocator
+{
+
+ private final MBeanServer mbeanServer;
+
+ public MBeanServerLocator(final MBeanServer mbeanServer)
+ {
+ super();
+
+ this.mbeanServer = mbeanServer;
+ }
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+
+}
Added: common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.framework.management.recording.ManagedRecordProcessor;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * The endpoint MBean representation
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 20-Jun-2007
+ */
+public class ManagedEndpoint implements ManagedEndpointMBean
+{
+ private Endpoint endpoint;
+ private MBeanServer mbeanServer;
+ private Logger log = Logger.getLogger(this.getClass());
+
+ public ManagedEndpoint(Endpoint endpoint, MBeanServer mbeanServer)
+ {
+ this.endpoint = endpoint;
+ this.mbeanServer = mbeanServer;
+ }
+
+ public String getAddress()
+ {
+ return endpoint.getAddress();
+ }
+
+ public long getAverageProcessingTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getAverageProcessingTime() : 0;
+ }
+
+ public long getFaultCount()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getFaultCount() : 0;
+ }
+
+ public long getMaxProcessingTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getMaxProcessingTime() : 0;
+ }
+
+ public long getMinProcessingTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getMinProcessingTime() : 0;
+ }
+
+ public long getRequestCount()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getRequestCount() : 0;
+ }
+
+ public long getResponseCount()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getResponseCount() : 0;
+ }
+
+ public Date getStartTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getStartTime() : null;
+ }
+
+ public Date getStopTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getStopTime() : null;
+ }
+
+ public long getTotalProcessingTime()
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ return metrics != null ? metrics.getTotalProcessingTime() : 0;
+ }
+
+ public void start()
+ {
+ endpoint.getLifecycleHandler().start(endpoint);
+ }
+
+ public void stop()
+ {
+ endpoint.getLifecycleHandler().stop(endpoint);
+ }
+
+ public void processRecord(Record record)
+ {
+ endpoint.processRecord(record);
+ }
+
+ public void addRecordProcessor(RecordProcessor processor)
+ {
+ this.getRecordProcessors().add(processor);
+ try
+ {
+ mbeanServer.registerMBean(processor, ObjectNameFactory.create(endpoint.getName()
+ ",recordProcessor=" + processor.getName()));
+ }
+ catch (JMException ex)
+ {
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
+ }
+ }
+
+ public List<RecordProcessor> getRecordProcessors()
+ {
+ return endpoint.getRecordProcessors();
+ }
+
+ public void setRecordProcessors(List<RecordProcessor> processors)
+ {
+ //unregister current processors
+ for (RecordProcessor processor : processors)
+ {
+ try
+ {
+ mbeanServer.unregisterMBean(ObjectNameFactory.create(endpoint.getName() +
",recordProcessor=" + processor.getName()));
+ }
+ catch (JMException ex)
+ {
+ log.error("Cannot unregister record processor with JMX server",
ex);
+ }
+ }
+ //set and register the new processors
+ endpoint.setRecordProcessors(processors);
+ for (RecordProcessor processor : processors)
+ {
+ try
+ {
+ mbeanServer.registerMBean(processor,
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException ex)
+ {
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
+ }
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointMBean.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * MBean interface.
+ * @since 15-April-2004
+ */
+public interface ManagedEndpointMBean
+{
+ void start();
+
+ void stop();
+
+ String getAddress();
+
+ Date getStartTime();
+
+ Date getStopTime();
+
+ long getMinProcessingTime();
+
+ long getMaxProcessingTime();
+
+ long getAverageProcessingTime();
+
+ long getTotalProcessingTime();
+
+ long getRequestCount();
+
+ long getFaultCount();
+
+ long getResponseCount();
+
+ void processRecord(Record record);
+
+ void addRecordProcessor(RecordProcessor processor);
+
+ List<RecordProcessor> getRecordProcessors();
+
+ void setRecordProcessors(List<RecordProcessor> processors);
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistry.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistry.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistry.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * A Service Endpoint Registry
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 04-May-2007
+ */
+public class ManagedEndpointRegistry extends DefaultEndpointRegistry implements
ManagedEndpointRegistryMBean
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(ManagedEndpointRegistry.class);
+
+ // The MBeanServer
+ private MBeanServer mbeanServer;
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ @Override
+ public void register(Endpoint endpoint)
+ {
+ super.register(endpoint);
+
+ try
+ {
+ ManagedEndpoint jmxEndpoint = new ManagedEndpoint(endpoint, mbeanServer);
+ getMbeanServer().registerMBean(jmxEndpoint, endpoint.getName());
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot register endpoint with JMX server", ex);
+ }
+ }
+
+ @Override
+ public void unregister(Endpoint endpoint)
+ {
+ super.unregister(endpoint);
+ try
+ {
+ if (getMbeanServer() != null)
+ getMbeanServer().unregisterMBean(endpoint.getName());
+ else
+ log.warn("MBeanServer not available, cannot unregister endpoint with JMX
server");
+ }
+ catch (JMException ex)
+ {
+ log.error("Cannot unregister endpoint with JMX server", ex);
+ }
+ }
+
+ public void create() throws Exception
+ {
+ if (mbeanServer != null)
+ {
+ getMbeanServer().registerMBean(this, OBJECT_NAME);
+ }
+ }
+
+ public void destroy() throws Exception
+ {
+ log.debug("Destroy service endpoint manager");
+ if (mbeanServer != null)
+ {
+ getMbeanServer().unregisterMBean(OBJECT_NAME);
+ }
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistryMBean.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistryMBean.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpointRegistryMBean.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management;
+
+import javax.management.ObjectName;
+
+import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+
+/**
+ * MBean interface.
+ * @since 15-April-2004
+ */
+public interface ManagedEndpointRegistryMBean extends EndpointRegistry
+{
+ /** The object name in the MBean server */
+ ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=EndpointRegistry");
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AbstractRecordProcessor.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AbstractRecordProcessor.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AbstractRecordProcessor.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * An abstract record processor providing basic implementation
+ * of the processor configuration and filter's management
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public abstract class AbstractRecordProcessor implements RecordProcessor
+{
+ protected List<RecordFilter> filters = new Vector<RecordFilter>();
+ protected boolean processDestinationHost = true;
+ protected boolean processSourceHost = true;
+ protected boolean processHeaders = true;
+ protected boolean processEnvelope = true;
+ protected boolean processMessageType = true;
+ protected boolean processOperation = true;
+ protected boolean processDate = true;
+ protected String name;
+ protected boolean recording = false;
+
+ public abstract void processRecord(Record record);
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void addFilter(RecordFilter filter)
+ {
+ filters.add(filter);
+ }
+
+ public List<RecordFilter> getFilters()
+ {
+ return filters;
+ }
+
+ public void setFilters(List<RecordFilter> filters)
+ {
+ this.filters = new Vector<RecordFilter>(filters);
+ }
+
+ public boolean isProcessDestinationHost()
+ {
+ return processDestinationHost;
+ }
+
+ public void setProcessDestinationHost(boolean processDestinationHost)
+ {
+ this.processDestinationHost = processDestinationHost;
+ }
+
+ public boolean isProcessSourceHost()
+ {
+ return processSourceHost;
+ }
+
+ public void setProcessSourceHost(boolean processSourceHost)
+ {
+ this.processSourceHost = processSourceHost;
+ }
+
+ public boolean isProcessHeaders()
+ {
+ return processHeaders;
+ }
+
+ public void setProcessHeaders(boolean processHeaders)
+ {
+ this.processHeaders = processHeaders;
+ }
+
+ public boolean isProcessEnvelope()
+ {
+ return processEnvelope;
+ }
+
+ public void setProcessEnvelope(boolean processEnvelope)
+ {
+ this.processEnvelope = processEnvelope;
+ }
+
+ public boolean isProcessMessageType()
+ {
+ return processMessageType;
+ }
+
+ public void setProcessMessageType(boolean processMessageType)
+ {
+ this.processMessageType = processMessageType;
+ }
+
+ public boolean isProcessOperation()
+ {
+ return processOperation;
+ }
+
+ public void setProcessOperation(boolean processOperation)
+ {
+ this.processOperation = processOperation;
+ }
+
+ public boolean isProcessDate()
+ {
+ return processDate;
+ }
+
+ public void setProcessDate(boolean processDate)
+ {
+ this.processDate = processDate;
+ }
+
+ public boolean isRecording()
+ {
+ return recording;
+ }
+
+ public void setRecording(boolean recording)
+ {
+ this.recording = recording;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ AbstractRecordProcessor retObj = (AbstractRecordProcessor)super.clone();
+ retObj.filters = new Vector<RecordFilter>();
+ for (RecordFilter fil : this.filters)
+ {
+ RecordFilter clFil = (RecordFilter)fil.clone();
+ retObj.filters.add(clFil);
+ }
+ retObj.processDestinationHost = this.processDestinationHost;
+ retObj.processSourceHost = this.processSourceHost;
+ retObj.processHeaders = this.processHeaders;
+ retObj.processEnvelope = this.processEnvelope;
+ retObj.processMessageType = this.processMessageType;
+ retObj.processOperation = this.processOperation;
+ retObj.processDate = this.processDate;
+ retObj.recording = this.recording;
+ retObj.name = this.name;
+ return retObj;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ sb.append(" (recording = " + recording);
+ sb.append(", processDestinationHost = " + processDestinationHost);
+ sb.append(", processSourceHost = " + processSourceHost);
+ sb.append(", processHeaders = " + processHeaders);
+ sb.append(", processEnvelope = " + processEnvelope);
+ sb.append(", processMessageType = " + processMessageType);
+ sb.append(", processOperation = " + processOperation);
+ sb.append(", processDate = " + processDate);
+ sb.append(")");
+ return sb.toString();
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AndFilter.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AndFilter.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/AndFilter.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * A simple record filter acting like the AND operator
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 18-Dec-2007
+ *
+ */
+public class AndFilter implements RecordFilter
+{
+ private static final long serialVersionUID = -7535769052173597426L;
+
+ private RecordFilter filter1;
+ private RecordFilter filter2;
+
+ public AndFilter(RecordFilter filter1, RecordFilter filter2)
+ {
+ this.filter1 = filter1;
+ this.filter2 = filter2;
+ }
+
+ public boolean match(Record record)
+ {
+ return filter1.match(record) && filter2.match(record);
+ }
+
+ public RecordFilter getFilter1()
+ {
+ return filter1;
+ }
+
+ public RecordFilter getFilter2()
+ {
+ return filter2;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ AndFilter retObj = (AndFilter)super.clone();
+ retObj.filter1 = (RecordFilter)this.filter1.clone();
+ retObj.filter2 = (RecordFilter)this.filter2.clone();
+ return retObj;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/HostFilter.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/HostFilter.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/HostFilter.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * This filter matches records having the source/destination host equal to
+ * any of the provided hosts.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 11-Dec-2007
+ */
+public class HostFilter implements RecordFilter
+{
+ private static final long serialVersionUID = -5935962601380315102L;
+
+ private List<String> hosts = new LinkedList<String>();
+ private boolean source;
+
+ public HostFilter(String host, boolean source)
+ {
+ this.hosts.add(host);
+ this.source = source;
+ }
+
+ public HostFilter(Collection<String> hosts, boolean source)
+ {
+ this.hosts.addAll(hosts);
+ this.source = source;
+ }
+
+ public boolean match(Record record)
+ {
+ for (String host : hosts)
+ {
+ if ((source && host.equalsIgnoreCase(record.getSourceHost())) ||
(!source && host.equalsIgnoreCase(record.getDestinationHost())))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<String> getHosts()
+ {
+ return hosts;
+ }
+
+ public boolean isSource()
+ {
+ return source;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ HostFilter retObj = (HostFilter)super.clone();
+ retObj.hosts = new LinkedList<String>(this.hosts);
+ retObj.source = this.source;
+ return retObj;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.Record.MessageType;
+
+/**
+ * A simple record processor that writes records to the configured log.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class LogRecorder extends AbstractRecordProcessor implements Serializable
+{
+ private static final long serialVersionUID = -7126227194320867819L;
+
+ private Logger log = Logger.getLogger(this.getClass());
+
+ public LogRecorder()
+ {
+ this.name = "LogRecorder";
+ }
+
+ @Override
+ public void processRecord(Record record)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (this.isProcessMessageType())
+ {
+ if (record.getMessageType() == MessageType.INBOUND)
+ {
+ sb.append("INBOUND MESSAGE ");
+ if (this.isProcessSourceHost() && record.getSourceHost() != null)
+ {
+ sb.append("from ");
+ sb.append(record.getSourceHost());
+ }
+ }
+ else if (record.getMessageType() == MessageType.OUTBOUND)
+ {
+ sb.append("OUTBOUND MESSAGE ");
+ if (this.isProcessDestinationHost() && record.getDestinationHost() !=
null)
+ {
+ sb.append("to ");
+ sb.append(record.getDestinationHost());
+ }
+ }
+ else
+ {
+ log.warn("Unknown message type: " + record.getMessageType());
+ if (this.isProcessSourceHost() && record.getSourceHost() != null)
+ {
+ sb.append("from ");
+ sb.append(record.getSourceHost());
+ }
+ if (this.isProcessDestinationHost() && record.getDestinationHost() !=
null)
+ {
+ sb.append("to ");
+ sb.append(record.getDestinationHost());
+ }
+ }
+ }
+ else
+ {
+ sb.append("MESSAGE");
+ }
+ sb.append(":");
+ if (this.isProcessDate())
+ {
+ sb.append("\nDate: ");
+ sb.append(record.getDate());
+ }
+ sb.append("\nGroupID: ");
+ sb.append(record.getGroupID());
+ if (this.isProcessOperation())
+ {
+ sb.append("\nOperation: ");
+ sb.append(record.getOperation());
+ }
+ sb.append("\n");
+ Map<String, List<String>> headers = record.getHeaders();
+ if (this.isProcessHeaders() && headers != null)
+ {
+ for (String key : headers.keySet())
+ {
+ sb.append(key);
+ sb.append(": ");
+ for (String h : headers.get(key))
+ {
+ sb.append(h);
+ sb.append("; ");
+ }
+ sb.append("\n");
+ }
+ sb.append("\n");
+ }
+ sb.append("\n");
+ if (this.isProcessEnvelope())
+ {
+ sb.append(record.getEnvelope());
+ }
+ log.debug(sb.toString());
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessor.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessor.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessor.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.List;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+import org.jboss.wsf.spi.management.recording.RecordProcessor;
+
+/**
+ * The record processor MBean representation
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 12-Dec-2007
+ */
+public class ManagedRecordProcessor implements ManagedRecordProcessorMBean
+{
+ private RecordProcessor processor;
+
+ public ManagedRecordProcessor(RecordProcessor processor)
+ {
+ this.processor = processor;
+ }
+
+ public void addFilter(RecordFilter filter)
+ {
+ processor.addFilter(filter);
+ }
+
+ public List<RecordFilter> getFilters()
+ {
+ return processor.getFilters();
+ }
+
+ public boolean isProcessDate()
+ {
+ return processor.isProcessDate();
+ }
+
+ public boolean isProcessDestinationHost()
+ {
+ return processor.isProcessDestinationHost();
+ }
+
+ public boolean isProcessHeaders()
+ {
+ return processor.isProcessHeaders();
+ }
+
+ public boolean isProcessEnvelope()
+ {
+ return processor.isProcessEnvelope();
+ }
+
+ public boolean isProcessMessageType()
+ {
+ return processor.isProcessMessageType();
+ }
+
+ public boolean isProcessOperation()
+ {
+ return processor.isProcessOperation();
+ }
+
+ public boolean isProcessSourceHost()
+ {
+ return processor.isProcessSourceHost();
+ }
+
+ public void processRecord(Record record)
+ {
+ processor.processRecord(record);
+ }
+
+ public void setFilters(List<RecordFilter> filters)
+ {
+ processor.setFilters(filters);
+ }
+
+ public void setProcessDate(boolean value)
+ {
+ processor.setProcessDate(value);
+ }
+
+ public void setProcessDestinationHost(boolean value)
+ {
+ processor.setProcessDestinationHost(value);
+ }
+
+ public void setProcessHeaders(boolean value)
+ {
+ processor.setProcessHeaders(value);
+ }
+
+ public void setProcessEnvelope(boolean value)
+ {
+ processor.setProcessEnvelope(value);
+ }
+
+ public void setProcessMessageType(boolean value)
+ {
+ processor.setProcessMessageType(value);
+ }
+
+ public void setProcessOperation(boolean value)
+ {
+ processor.setProcessOperation(value);
+ }
+
+ public void setProcessSourceHost(boolean value)
+ {
+ processor.setProcessSourceHost(value);
+ }
+
+ public boolean isRecording()
+ {
+ return processor.isRecording();
+ }
+
+ public void setRecording(boolean value)
+ {
+ processor.setRecording(value);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessorMBean.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessorMBean.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordProcessorMBean.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.List;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * The record processor MBean interface
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 12-Dec-2007
+ */
+public interface ManagedRecordProcessorMBean
+{
+ public void processRecord(Record record);
+
+ public void setRecording(boolean value);
+
+ public boolean isRecording();
+
+ public List<RecordFilter> getFilters();
+
+ public void addFilter(RecordFilter filter);
+
+ public void setFilters(List<RecordFilter> filters);
+
+ public boolean isProcessSourceHost();
+
+ public void setProcessSourceHost(boolean value);
+
+ public boolean isProcessDestinationHost();
+
+ public void setProcessDestinationHost(boolean value);
+
+ public boolean isProcessMessageType();
+
+ public void setProcessMessageType(boolean value);
+
+ public boolean isProcessEnvelope();
+
+ public void setProcessEnvelope(boolean value);
+
+ public boolean isProcessHeaders();
+
+ public void setProcessHeaders(boolean value);
+
+ public boolean isProcessOperation();
+
+ public void setProcessOperation(boolean value);
+
+ public boolean isProcessDate();
+
+ public void setProcessDate(boolean value);
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,294 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+import org.jboss.wsf.spi.management.recording.Record.MessageType;
+
+/**
+ * Keeps the last received records in memory and allows user to
+ * search / get statistics on them.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 12-Dec-2007
+ */
+public class MemoryBufferRecorder extends AbstractRecordProcessor implements
MemoryBufferRecorderMBean, Serializable
+{
+ private static final long serialVersionUID = 5180978625780333738L;
+
+ private Map<String, List<Record>> recentRecords =
Collections.synchronizedMap(new HashMap<String, List<Record>>());
+ private ConcurrentLinkedQueue<String> recentRecordGroups = new
ConcurrentLinkedQueue<String>();
+ private int size = 0;
+ private int maxSize = 50;
+
+ public MemoryBufferRecorder()
+ {
+ this.name = "MemoryBufferRecorder";
+ }
+
+ @Override
+ public void processRecord(Record record)
+ {
+ synchronized (recentRecords)
+ {
+ List<Record> list = recentRecords.get(record.getGroupID());
+ if (list == null)
+ {
+ list = new LinkedList<Record>();
+ recentRecords.put(record.getGroupID(), list);
+ while (size > maxSize)
+ {
+ this.deleteOldestRecord();
+ }
+ recentRecordGroups.offer(record.getGroupID());
+ size++;
+ }
+ list.add(record);
+ }
+ }
+
+
+ private void deleteOldestRecord()
+ {
+ String id = recentRecordGroups.poll();
+ if (id != null)
+ {
+ recentRecords.remove(id);
+ size--;
+ }
+ }
+
+ private Map<String, List<Record>> getRecentRecords()
+ {
+ synchronized (recentRecords)
+ {
+ return new HashMap<String, List<Record>>(recentRecords);
+ }
+ }
+
+ public Set<String> getClientHosts()
+ {
+ Map<String, List<Record>> map = this.getRecentRecords();
+ Set<String> hosts = new HashSet<String>();
+ for (List<Record> list : map.values())
+ {
+ for (Record record : list)
+ {
+ if (MessageType.INBOUND.equals(record.getMessageType()) &&
record.getSourceHost() != null)
+ {
+ hosts.add(record.getSourceHost());
+ }
+ }
+ }
+ return hosts;
+ }
+
+ public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters)
+ {
+ Map<String, List<Record>> map = this.getRecentRecords();
+ Map<String, List<Record>> result = new HashMap<String,
List<Record>>();
+ for (List<Record> list : map.values())
+ {
+ for (Record record : list)
+ {
+ boolean match = true;
+ for (int i = 0; i < filters.length && match; i++)
+ {
+ match = match && filters[i].match(record);
+ }
+ if (match)
+ {
+ result.put(record.getGroupID(), list);
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public Map<String, List<Record>> getRecordsByClientHost(String
clientHost)
+ {
+ RecordFilter[] filters = new RecordFilter[1];
+ filters[0] = new HostFilter(clientHost, true);
+ return this.getMatchingRecords(filters);
+ }
+
+ public String getRecordsByClientHostAsHTMLTable(boolean groupRecords, boolean
showDetails, String clientHost)
+ {
+ return toHtml(groupRecords, showDetails, this.getRecordsByClientHost(clientHost));
+ }
+
+ public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart)
+ {
+ RecordFilter[] filters = new RecordFilter[1];
+ filters[0] = new OperationFilter(new QName(namespace, localPart));
+ return this.getMatchingRecords(filters);
+ }
+
+ public String getRecordsByOperationAsHTMLTable(boolean groupRecords, boolean
showDetails, String namespace, String localPart)
+ {
+ return toHtml(groupRecords, showDetails, this.getRecordsByOperation(namespace,
localPart));
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ synchronized (recentRecords)
+ {
+ while (maxSize < size)
+ {
+ this.deleteOldestRecord();
+ }
+ this.maxSize = maxSize;
+ }
+ }
+
+ public int getSize()
+ {
+ return size;
+ }
+
+ public String getRecordsAsHTMLTable(boolean groupRecords, boolean showDetails)
+ {
+ Map<String,List<Record>> records = this.getRecentRecords();
+ return toHtml(groupRecords, showDetails, records);
+ }
+
+ private String toHtml(boolean groupRecords, boolean showDetails, Map<String,
List<Record>> records)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("</pre></span>");
+ if (!groupRecords)
+ openTable(sb, showDetails);
+ for (String key : records.keySet())
+ {
+ if (groupRecords)
+ openTable(sb, showDetails);
+ for (Record record : records.get(key))
+ {
+ appendRecordRow(sb, record, showDetails);
+ }
+ if (groupRecords)
+ closeTable(sb);
+ }
+ if (!groupRecords)
+ closeTable(sb);
+ sb.append("<pre><span class='OpResult'>");
+ return sb.toString();
+ }
+
+ private void openTable(StringBuilder sb, boolean showDetails)
+ {
+ sb.append("<table border='1'><tr
class='AttributesHeader'><th>Group
ID</th><th>Type</th><th>Date</th><th>From</th><th>To</th><th>Operation</th>");
+ if (showDetails)
+
sb.append("<th>Headers</th><th>Envelope</th>");
+ sb.append("</tr><tr>");
+ }
+
+ private void closeTable(StringBuilder sb)
+ {
+ sb.append("</tr></table><br />");
+ }
+
+ private void appendRecordRow(StringBuilder sb, Record record, boolean showDetails) {
+ sb.append("<tr><td><pre>");
+ sb.append(record.getGroupID() != null ? record.getGroupID() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getMessageType() != null ? record.getMessageType() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getDate() != null ? record.getDate() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getSourceHost() != null ? record.getSourceHost() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getDestinationHost() != null ? record.getDestinationHost() :
"[Not available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getOperation() != null ? record.getOperation() : "[Not
available]");
+ sb.append("</pre></td>");
+ if (showDetails)
+ {
+ sb.append("<td><pre>");
+ if (record.getHeaders() != null)
+ {
+ for (String headerName : record.getHeaders().keySet())
+ {
+ sb.append(headerName);
+ sb.append(": ");
+ sb.append(record.getHeaders().get(headerName));
+ sb.append("<br />");
+ }
+ }
+ else
+ sb.append("[Not available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getEnvelope() != null ?
record.getEnvelope().replaceAll("<",
"<").replaceAll(">", ">") : "[Not
available]");
+ sb.append("</pre></td>");
+ }
+ sb.append("</tr>");
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ MemoryBufferRecorder cl = (MemoryBufferRecorder)super.clone();
+ cl.recentRecords = Collections.synchronizedMap(new HashMap<String,
List<Record>>());
+ for (String key : this.recentRecords.keySet())
+ {
+ List<Record> list = new LinkedList<Record>();
+ for (Record record : this.recentRecords.get(key))
+ {
+ list.add(record);
+ }
+ cl.recentRecords.put(key, list);
+ }
+ cl.recentRecordGroups = new ConcurrentLinkedQueue<String>();
+ for (String id : this.recentRecordGroups)
+ {
+ cl.recentRecordGroups.add(id);
+ }
+ cl.maxSize = this.maxSize;
+ cl.size = this.size;
+ return cl;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * The MemoryBufferRecorder's MBean view
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 18-Dec-2007
+ */
+public interface MemoryBufferRecorderMBean extends ManagedRecordProcessorMBean
+{
+ /**
+ * Gets the records matching the provided filters. Records having the
+ * same group ID are returned together.
+ *
+ * @param filters
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters);
+
+ /**
+ * Gets the records with the given operation. Records having the
+ * same group ID are returned together.
+ *
+ * @param namespace
+ * @param localPart
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart);
+
+ /**
+ * Gets the records with the given client host. Records having the
+ * same group ID are returned together.
+ *
+ * @param clientHost
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getRecordsByClientHost(String
clientHost);
+
+ /**
+ * Gets a set containing the client hosts of the last saved records.
+ *
+ * @return
+ */
+ public Set<String> getClientHosts();
+
+ /**
+ * Gets the current buffer max size (i.e. the number of record groups stored at the
same time)
+ *
+ * @return
+ */
+ public int getMaxSize();
+
+ public void setMaxSize(int maxSize);
+
+ /**
+ * Gets the buffer's current size
+ * @return
+ */
+ public int getSize();
+
+ /**
+ * Shows all the records as a HTML table
+ *
+ * @param groupRecords whether the records should be grouped using the group ID
+ * @param showDetails whether to show headers and envelopes
+ * @return
+ */
+ public String getRecordsAsHTMLTable(boolean groupRecords, boolean showDetails);
+
+ /**
+ * Shows the records with the given client host as a HTML table.
+ *
+ * @param groupRecords
+ * @param showDetails
+ * @param clientHost
+ * @return
+ */
+ public String getRecordsByClientHostAsHTMLTable(boolean groupRecords, boolean
showDetails, String clientHost);
+
+ /**
+ * Shows the records with the given operation as a HTML table.
+ *
+ * @param groupRecords
+ * @param showDetails
+ * @param namespace
+ * @param localPart
+ * @return
+ */
+ public String getRecordsByOperationAsHTMLTable(boolean groupRecords, boolean
showDetails, String namespace, String localPart);
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/NotFilter.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/NotFilter.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/NotFilter.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * A simple record filter acting like the negation operator
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 18-Dec-2007
+ *
+ */
+public class NotFilter implements RecordFilter
+{
+ private static final long serialVersionUID = -3254118688017137981L;
+
+ private RecordFilter filter;
+
+ public NotFilter(RecordFilter filter)
+ {
+ this.filter = filter;
+ }
+
+ public boolean match(Record record)
+ {
+ return !filter.match(record);
+ }
+
+ public RecordFilter getFilter()
+ {
+ return filter;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ NotFilter retObj = (NotFilter)super.clone();
+ retObj.filter = (RecordFilter)this.filter.clone();
+ return retObj;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OperationFilter.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OperationFilter.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OperationFilter.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * This filter matches records having a given operation QName value.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 11-Dec-2007
+ */
+public class OperationFilter implements RecordFilter
+{
+ private static final long serialVersionUID = -726794729964445956L;
+
+ private QName operation;
+
+ public OperationFilter(QName operation)
+ {
+ this.operation = operation;
+ }
+
+ public boolean match(Record record)
+ {
+ if (record != null)
+ {
+ if (record.getOperation() == null && operation == null)
+ {
+ return true;
+ }
+ else if (operation != null && operation.equals(record.getOperation()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public QName getOperation()
+ {
+ return operation;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ OperationFilter retObj = (OperationFilter)super.clone();
+ retObj.operation = this.operation;
+ return retObj;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OrFilter.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OrFilter.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/OrFilter.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * A simple record filter acting like the OR operator
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 18-Dec-2007
+ *
+ */
+public class OrFilter implements RecordFilter
+{
+ private static final long serialVersionUID = 3372989051076281559L;
+
+ private RecordFilter filter1;
+ private RecordFilter filter2;
+
+ public OrFilter(RecordFilter filter1, RecordFilter filter2)
+ {
+ this.filter1 = filter1;
+ this.filter2 = filter2;
+ }
+
+ public boolean match(Record record)
+ {
+ return filter1.match(record) || filter2.match(record);
+ }
+
+ public RecordFilter getFilter1()
+ {
+ return filter1;
+ }
+
+ public RecordFilter getFilter2()
+ {
+ return filter2;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException
+ {
+ OrFilter retObj = (OrFilter)super.clone();
+ retObj.filter1 = (RecordFilter)this.filter1.clone();
+ retObj.filter2 = (RecordFilter)this.filter2.clone();
+ return retObj;
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import org.jboss.wsf.spi.management.recording.Record;
+
+/**
+ * Simple record factory
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class RecordFactory
+{
+ private static long count = 0;
+
+ public static String newGroupID()
+ {
+ long time = System.currentTimeMillis();
+ StringBuilder sb = new StringBuilder();
+ synchronized (RecordFactory.class)
+ {
+ count++;
+ }
+ sb.append(count);
+ sb.append("-");
+ sb.append(time);
+ return sb.toString();
+ }
+
+ public static Record newRecord(String groupID)
+ {
+ Record record = new RecordImpl();
+ record.setGroupID(groupID);
+ return record;
+ }
+
+ public static Record newRecord()
+ {
+ return newRecord(newGroupID());
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordImpl.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordImpl.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordImpl.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.management.recording;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.wsf.spi.management.recording.Record;
+
+/**
+ * Default Record implementation
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class RecordImpl implements Record
+{
+ private static final long serialVersionUID = -2421022916458208468L;
+
+ private String sourceHost;
+ private String destinationHost;
+ private Map<String, List<String>> headers = new HashMap<String,
List<String>>();
+ private MessageType messageType;
+ private QName operation;
+ private String groupID;
+ private Date date;
+ private String envelope;
+
+ RecordImpl()
+ {
+
+ }
+
+ public void addHeaders(String key, List<String> value)
+ {
+ headers.put(key, value);
+ }
+
+ public Map<String, List<String>> getHeaders()
+ {
+ return headers;
+ }
+
+ public MessageType getMessageType()
+ {
+ return messageType;
+ }
+
+ public void setMessageType(MessageType messageType)
+ {
+ this.messageType = messageType;
+ }
+
+ public String getSourceHost()
+ {
+ return sourceHost;
+ }
+
+ public void setSourceHost(String sourceHost)
+ {
+ this.sourceHost = sourceHost;
+ }
+
+ public String getDestinationHost()
+ {
+ return destinationHost;
+ }
+
+ public void setDestinationHost(String destinationHost)
+ {
+ this.destinationHost = destinationHost;
+ }
+
+ public void setHeaders(Map<String, List<String>> headers)
+ {
+ if (headers != null)
+ this.headers = new HashMap<String, List<String>>(headers);
+ }
+
+ public String getGroupID()
+ {
+ return groupID;
+ }
+
+ public QName getOperation()
+ {
+ return operation;
+ }
+
+ public void setGroupID(String groupID)
+ {
+ this.groupID = groupID;
+ }
+
+ public void setOperation(QName operation)
+ {
+ this.operation = operation;
+ }
+
+ public Date getDate()
+ {
+ return date;
+ }
+
+ public void setDate(Date date)
+ {
+ this.date = date;
+ }
+
+ public void setEnvelope(String envelope)
+ {
+ this.envelope = envelope;
+ }
+
+ public String getEnvelope()
+ {
+ return envelope;
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/security/DefaultSecurityAdapterFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/security/DefaultSecurityAdapterFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/security/DefaultSecurityAdapterFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.wsf.framework.security;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+
+/**
+ * TODO: javadoc
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class DefaultSecurityAdapterFactory extends SecurityAdaptorFactory
+{
+
+ private static SecurityAdaptor SECURITY_ADAPTOR = new DefaultSecurityAdaptor();
+
+ /**
+ * Constructor.
+ */
+ public DefaultSecurityAdapterFactory()
+ {
+ super();
+ }
+
+ /**
+ * Creates new security adapter instance.
+ *
+ * @return security adapter
+ */
+ public SecurityAdaptor newSecurityAdapter()
+ {
+ return DefaultSecurityAdapterFactory.SECURITY_ADAPTOR;
+ }
+
+ private static class DefaultSecurityAdaptor implements SecurityAdaptor
+ {
+
+ private static ThreadLocal<Principal> principal = new
ThreadLocal<Principal>();
+ private static ThreadLocal<Object> credential = new
ThreadLocal<Object>();
+
+ public Object getCredential()
+ {
+ return DefaultSecurityAdaptor.credential.get();
+ }
+
+ public Principal getPrincipal()
+ {
+ return DefaultSecurityAdaptor.principal.get();
+ }
+
+ public void pushSubjectContext(Subject subject, Principal principal, Object
credential)
+ {
+ // does nothing
+ }
+
+ public void setCredential(Object credential)
+ {
+ DefaultSecurityAdaptor.credential.set(credential);
+ }
+
+ public void setPrincipal(Principal principal)
+ {
+ DefaultSecurityAdaptor.principal.set(principal);
+ }
+
+ }
+
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandler.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.serviceref;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+
+/**
+ * Binds service refs to the client's ENC.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class DefaultServiceRefHandler implements ServiceRefHandler
+{
+ @Override
+ public Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRefMD)
+ {
+ if (serviceRefMD.getVfsRoot() == null)
+ {
+ throw new IllegalStateException("VFSRoot must be provided");
+ }
+ if (serviceRefMD.getType() == null)
+ {
+ throw new IllegalStateException("Service reference type must be
provided");
+ }
+
+ return this.getBinder(serviceRefMD.getType()).createReferenceable(serviceRefMD);
+ }
+
+ private ServiceRefBinder getBinder(final Type type)
+ {
+ final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ final ServiceRefBinderFactory serviceRefBindingFactory =
spiProvider.getSPI(ServiceRefBinderFactory.class);
+
+ return serviceRefBindingFactory.newServiceRefBinder(type);
+ }
+}
Added:
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java 2011-01-11
16:08:33 UTC (rev 13555)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.wsf.framework.serviceref;
+
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+
+/**
+ * A factory for the ServiceRefHandler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 05-May-2004
+ */
+public class DefaultServiceRefHandlerFactory implements ServiceRefHandlerFactory
+{
+ public ServiceRefHandler getServiceRefHandler()
+ {
+ return new DefaultServiceRefHandler();
+ }
+}