[jboss-cvs] JBossAS SVN: r93641 - in trunk: profileservice/src/main/org/jboss/profileservice/management/client and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 17 08:25:57 EDT 2009
Author: emuckenhuber
Date: 2009-09-17 08:25:56 -0400 (Thu, 17 Sep 2009)
New Revision: 93641
Added:
trunk/profileservice/src/main/org/jboss/profileservice/management/client/
trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/package.html
trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/
trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java
trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java
trunk/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/SecurityActions.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/BasicInvocation.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/InstanceInterceptor.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/PojiMethodInvocation.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/SecurityContainer.java
trunk/profileservice/src/resources/profileservice-roles.properties
trunk/profileservice/src/resources/profileservice-users.properties
Removed:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java
trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
trunk/profileservice/src/main/org/jboss/profileservice/management/matchers/AliasMatcher.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
trunk/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
trunk/profileservice/src/resources/hdscanner-jboss-beans.xml
trunk/profileservice/src/resources/profileservice-jboss-beans.xml
trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java
trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
Log:
merge profileservice changes with branch 5_x
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -46,8 +46,8 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.annotation.ActivationPolicy;
import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
import org.jboss.managed.api.annotation.FieldsFactory;
@@ -84,7 +84,7 @@
* MBeanInfo.
*
* @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public class MBeanManagedObjectFactory
{
@@ -118,12 +118,12 @@
ClassLoader mbeanLoader, MetaData metaData)
throws Exception
{
- return getManagedObject(mbean, info, mbeanLoader, metaData, null);
+ return getManagedObject(mbean, info, mbeanLoader, metaData, null, null);
}
// FIXME - Hack until metadata mechanism is provided
public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
- ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse)
+ ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse, Map<String, String> propertyMetaMappings)
throws Exception
{
boolean trace = log.isTraceEnabled();
@@ -267,7 +267,7 @@
try
{
type = loadTypeClass(propertyType, mbeanLoader);
- metaType = this.getMetaType(propertyInfo, type, metaData, false, mapperReturn);
+ metaType = this.getMetaType(propertyInfo, type, metaData, false, propertyMetaMappings, mapperReturn);
}
catch(Exception e)
{
@@ -360,13 +360,10 @@
for (MBeanOperationInfo methodInfo : methodInfos)
{
ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
- if (managementOp == null)
- continue;
-
try
{
- ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
- operations.add(op);
+ ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
+ operations.add(op);
}
catch(Exception e)
{
@@ -428,7 +425,7 @@
* @return the MetaType for info's type
*/
protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
- boolean useTypeFactory, MetaMapper[] mapperReturn)
+ boolean useTypeFactory, Map<String, String> propertyMetaMappings, MetaMapper[] mapperReturn)
{
MetaType returnType = null;
// First look for meta mappings
@@ -465,6 +462,24 @@
log.debug("Failed to create MetaMapper: "+metaMapping, e);
}
}
+
+ if (info instanceof MBeanAttributeInfo && propertyMetaMappings != null)
+ {
+ String className = propertyMetaMappings.get(info.getName());
+ if (className != null)
+ {
+ try
+ {
+ // Use the same loader of the profile service
+ metaMapper = (MetaMapper<?>)Class.forName(className).newInstance();
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to create MetaMapper: " + className + " for property: " + info.getName());
+ }
+ }
+ }
+
if(metaMapper != null)
{
returnType = metaMapper.getMetaType();
@@ -486,7 +501,7 @@
throws Exception
{
String name = methodInfo.getName();
- String description = opAnnotation.description();
+ String description = opAnnotation != null ? opAnnotation.description() : name;
Impact impact = Impact.Unknown;
switch(methodInfo.getImpact())
{
@@ -506,7 +521,7 @@
// The op return type
MetaMapper[] returnTypeMapper = {null};
Class<?> returnTypeClass = loadTypeClass(methodInfo.getReturnType(), mbeanLoader);
- MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, returnTypeMapper);
+ MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, null, returnTypeMapper);
// Process the op parameters
ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
@@ -527,7 +542,7 @@
fields.setField(Fields.DESCRIPTION, pdescription);
MetaMapper[] paramMapper = {null};
Class<?> paramType = loadTypeClass(pinfo.getType(), mbeanLoader);
- MetaType metaType = getMetaType(pinfo, paramType, metaData, true, paramMapper);
+ MetaType metaType = getMetaType(pinfo, paramType, metaData, true, null, paramMapper);
fields.setField(Fields.META_TYPE, metaType);
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentDelegate.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedComponentDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,144 +0,0 @@
-/*
- * 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.profileservice.management;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedCommon;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedComponent;
-import org.jboss.managed.api.RunState;
-
-/**
- * A ManagedComponent used to proxy and dispatch the RunState on request.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedComponentDelegate implements MutableManagedComponent
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
- private Object componentName;
- private MutableManagedComponent delegate;
- private DelegatingComponentDispatcher dispatcher;
-
- public ManagedComponentDelegate(Object componentName, MutableManagedComponent delegate, DelegatingComponentDispatcher dispatcher)
- {
- this.componentName = componentName;
- this.delegate = delegate;
- this.dispatcher = dispatcher;
- }
-
- public Map<String, Annotation> getAnnotations()
- {
- return delegate.getAnnotations();
- }
-
- public ManagedDeployment getDeployment()
- {
- return delegate.getDeployment();
- }
-
- public RunState getRunState()
- {
- return dispatcher.updateRunState(componentName);
- }
-
- public void setRunState(RunState runState)
- {
- delegate.setRunState(runState);
- }
-
- public ComponentType getType()
- {
- return delegate.getType();
- }
-
- public boolean update()
- {
- return delegate.update();
- }
-
- public String getAttachmentName()
- {
- return delegate.getAttachmentName();
- }
-
- public Object getComponentName()
- {
- return delegate.getComponentName();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public String getNameType()
- {
- return delegate.getNameType();
- }
-
- public Set<ManagedOperation> getOperations()
- {
- return delegate.getOperations();
- }
-
- public void setOperations(Set<ManagedOperation> operations)
- {
- delegate.setOperations(operations);
- }
-
- public ManagedCommon getParent()
- {
- return delegate.getParent();
- }
-
- public ManagedProperty getProperty(String name)
- {
- return delegate.getProperty(name);
- }
-
- public Map<String, ManagedProperty> getProperties()
- {
- return delegate.getProperties();
- }
-
- public void setProperties(Map<String, ManagedProperty> properties)
- {
- delegate.setProperties(properties);
- }
-
- public Set<String> getPropertyNames()
- {
- return delegate.getPropertyNames();
- }
-
-}
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedOperationDelegate
- implements ManagedOperation
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 2031110731596810579L;
- private long opID;
- private Object componentName;
- private ManagedOperation delegate;
- private DelegatingComponentDispatcher dispatcherProxy;
-
- public ManagedOperationDelegate(long opID, ManagedOperation delegate, Object componentName,
- DelegatingComponentDispatcher dispatcherProxy)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate.");
- this.opID = opID;
- this.delegate = delegate;
- this.componentName = componentName;
- this.dispatcherProxy = dispatcherProxy;
- }
-
- public long getOpID()
- {
- return opID;
- }
-
- public MetaValue invoke(MetaValue... metaValues)
- {
- return dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);
- }
-
- public String getDescription()
- {
- return delegate.getDescription();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public Impact getImpact()
- {
- return delegate.getImpact();
- }
-
- public MetaType getReturnType()
- {
- return delegate.getReturnType();
- }
-
- public ManagedParameter[] getParameters()
- {
- return delegate.getParameters();
- }
-
- public String[] getReflectionSignature()
- {
- return delegate.getReflectionSignature();
- }
-
- public <T> T getTransientAttachment(Class<T> expectedType)
- {
- return delegate.getTransientAttachment(expectedType);
- }
-
- public Object getTransientAttachment(String name)
- {
- return delegate.getTransientAttachment(name);
- }
-
- public void setTransientAttachment(String name, Object attachment)
- {
- delegate.setTransientAttachment(name, attachment);
- }
-}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -41,6 +41,9 @@
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.MutableManagedComponent;
import org.jboss.profileservice.management.DelegatingComponentDispatcherImpl.ProxyRegistry;
+import org.jboss.profileservice.management.client.ManagedComponentDelegate;
+import org.jboss.profileservice.management.client.ManagedOperationDelegate;
+import org.jboss.profileservice.management.client.ManagedPropertyDelegate;
import org.jboss.remoting.InvokerLocator;
/**
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,229 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * A ManagedProperty delegate used as the target of the ManagedProperty
- * proxies used for runtime managed objects statistics.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedPropertyDelegate implements ManagedProperty
-{
- private final static long serialVersionUID = 1;
- private long propID;
- private Object componentName;
- private ManagedProperty delegate;
- private DelegatingComponentDispatcher dispatcher;
-
- public ManagedPropertyDelegate(long propID, ManagedProperty delegate,
- Object componentName, DelegatingComponentDispatcher dispatcher)
- {
- super();
- this.propID = propID;
- this.delegate = delegate;
- this.dispatcher = dispatcher;
- this.componentName = componentName;
- }
-
- public String checkValidValue(MetaValue value)
- {
- return delegate.checkValidValue(value);
- }
-
- public ManagedProperty copy()
- {
- return delegate.copy();
- }
-
- public Map<String, Annotation> getAnnotations()
- {
- return delegate.getAnnotations();
- }
-
- public String getDescription()
- {
- return delegate.getDescription();
- }
-
- public <T> T getField(String fieldName, Class<T> expected)
- {
- return delegate.getField(fieldName, expected);
- }
-
- public Fields getFields()
- {
- return delegate.getFields();
- }
-
- public Set<MetaValue> getLegalValues()
- {
- return delegate.getLegalValues();
- }
-
- public MetaValue getDefaultValue()
- {
- return delegate.getDefaultValue();
- }
-
- public ManagedObject getManagedObject()
- {
- return delegate.getManagedObject();
- }
-
- public String getMappedName()
- {
- return delegate.getMappedName();
- }
-
- public Comparable<? extends MetaValue> getMaximumValue()
- {
- return delegate.getMaximumValue();
- }
-
- public MetaType getMetaType()
- {
- return delegate.getMetaType();
- }
-
- public Comparable<? extends MetaValue> getMinimumValue()
- {
- return delegate.getMinimumValue();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public ManagedObject getTargetManagedObject()
- {
- return delegate.getTargetManagedObject();
- }
-
- public <T> T getTransientAttachment(Class<T> expectedType)
- {
- return delegate.getTransientAttachment(expectedType);
- }
-
- public Object getTransientAttachment(String name)
- {
- return delegate.getTransientAttachment(name);
- }
-
- public MetaValue getValue()
- {
- return dispatcher.get(propID, componentName, getMappedName());
- }
-
- public Collection<String> getAdminViewUses()
- {
- return delegate.getAdminViewUses();
- }
-
- public boolean hasAnnotation(String key)
- {
- return delegate.hasAnnotation(key);
- }
-
- public boolean hasViewUse(ViewUse use)
- {
- return delegate.hasViewUse(use);
- }
-
- public ActivationPolicy getActivationPolicy()
- {
- return delegate.getActivationPolicy();
- }
-
- public void setModified(boolean flag)
- {
- delegate.setModified(flag);
- }
-
- public boolean isMandatory()
- {
- return delegate.isMandatory();
- }
-
- public boolean isReadOnly()
- {
- return delegate.isReadOnly();
- }
-
- public boolean isModified()
- {
- return delegate.isModified();
- }
-
- public boolean isRemoved()
- {
- return delegate.isRemoved();
- }
-
- public void setField(String fieldName, Serializable value)
- {
- delegate.setField(fieldName, value);
- }
-
- public void setManagedObject(ManagedObject managedObject)
- {
- delegate.setManagedObject(managedObject);
- }
-
- public void setRemoved(boolean flag)
- {
- delegate.setRemoved(flag);
- }
-
- public void setTargetManagedObject(ManagedObject target)
- {
- delegate.setTargetManagedObject(target);
- }
-
- public void setTransientAttachment(String name, Object attachment)
- {
- delegate.setTransientAttachment(name, attachment);
- }
-
- public void setValue(MetaValue value)
- {
- delegate.setValue(value);
- }
-
-}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -114,7 +114,8 @@
properties = ManagementProperties.EXPLICIT, description = "The ProfileService ManagementView")
public class ManagementViewImpl extends AbstractTemplateCreator implements ManagementView
{
-
+ private static RuntimePermission MV_RUNTIME_PERMISSION = new RuntimePermission(ManagementView.class.getName());
+
/** The logger. */
private static Logger log = Logger.getLogger(ManagementViewImpl.class);
private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
@@ -230,6 +231,10 @@
public synchronized boolean load()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
// If the profile is not modified do nothing
if(isReload() == false)
{
@@ -269,11 +274,11 @@
log.debug("Saw MBeanComponent: "+comp);
try
{
- ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
-
+ ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse(), mdf.getPropertyMetaMappings());
+
String name = comp.getName().getCanonicalName();
ManagementObject moAnn = createMOAnnotation(name, comp.getType(), comp.getSubtype());
-
+
// Both the ManagementObject and ManagementComponent annotation need to be in the MO annotations
mo.getAnnotations().put(ManagementObject.class.getName(), moAnn);
ManagementComponent mcAnn = moAnn.componentType();
@@ -359,18 +364,18 @@
@SuppressWarnings("all")
private static final class ManagementObjectAnnotationImpl implements ManagementObject, Serializable
- {
+ {
private static final long serialVersionUID=5355799336353299850L;
-
+
private final String name;
private final String type;
private final String subtype;
-
+
@SuppressWarnings("all")
private final class ManagementComponentAnnotationImpl implements ManagementComponent, Serializable
{
private static final long serialVersionUID=5355799336353299850L;
-
+
public String subtype()
{
return subtype;
@@ -449,7 +454,7 @@
return ManagementObject.class;
}
}
-
+
private ManagementObject createMOAnnotation(final String name, final String type, final String subtype)
{
return new ManagementObjectAnnotationImpl(name, type, subtype);
@@ -457,6 +462,10 @@
public void reload()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
forceReload = true;
load();
}
@@ -917,7 +926,7 @@
}
return state;
}
-
+
protected <T extends Enum<?>> T getComponentMappedState(ManagedComponent comp, ManagedObject mo, Object name, ContextStateMapper<T> mapper)
{
T state = mapper.getErrorState();
@@ -932,7 +941,7 @@
{
dispatcher = this.dispatcher;
}
-
+
if (dispatcher != null)
{
state = dispatcher.mapControllerState(name, mapper);
@@ -1072,6 +1081,10 @@
*/
public Set<String> getDeploymentNames()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
return new TreeSet<String>(this.managedDeployments.keySet());
}
@@ -1083,7 +1096,11 @@
*/
public Set<String> getDeploymentNamesForType(String type)
{
- Set<String> matches = new TreeSet<String>();
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
+ Set<String> matches = new TreeSet<String>();
for(ManagedDeployment md : managedDeployments.values())
{
String name = md.getName();
@@ -1104,6 +1121,10 @@
public Set<String> getMatchingDeploymentName(String regex)
throws NoSuchDeploymentException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
Set<String> names = getDeploymentNames();
HashSet<String> matches = new HashSet<String>();
Pattern p = Pattern.compile(regex);
@@ -1125,6 +1146,10 @@
public Set<ManagedDeployment> getMatchingDeployments(String name, NameMatcher<ManagedDeployment> matcher)
throws NoSuchDeploymentException, Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
Set<ManagedDeployment> matches = new HashSet<ManagedDeployment>();
// TODO
return matches;
@@ -1132,6 +1157,10 @@
public Set<String> getTemplateNames()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
return new HashSet<String>(templates.keySet());
}
@@ -1169,6 +1198,10 @@
*/
public ManagedDeployment getDeployment(String name) throws NoSuchDeploymentException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
if(name == null)
throw new IllegalArgumentException("Null deployment name");
@@ -1213,6 +1246,10 @@
public Set<ManagedDeployment> getDeploymentsForType(String type)
throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
Set<String> names = getDeploymentNamesForType(type);
HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
for(String name : names)
@@ -1229,6 +1266,10 @@
*/
public Set<ComponentType> getComponentTypes()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
HashSet<ComponentType> types = new HashSet<ComponentType>(compByCompType.keySet());
return types;
}
@@ -1243,7 +1284,11 @@
public Set<ManagedComponent> getComponentsForType(ComponentType type)
throws Exception
{
- Set<ManagedComponent> comps = null;
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
+ Set<ManagedComponent> comps = null;
// Check the any component type
if(type.equals(KnownComponentTypes.ANY_TYPE))
{
@@ -1269,6 +1314,10 @@
public ManagedComponent getComponent(String name, ComponentType type)
throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
Set<ManagedComponent> components = compByCompType.get(type);
ManagedComponent comp = null;
if(components != null)
@@ -1299,6 +1348,10 @@
NameMatcher<ManagedComponent> matcher)
throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
Set<ManagedComponent> components = compByCompType.get(type);
Set<ManagedComponent> matched = new HashSet<ManagedComponent>();
if(components != null)
@@ -1320,6 +1373,10 @@
public DeploymentTemplateInfo getTemplate(String name)
throws NoSuchDeploymentException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
DeploymentTemplate template = templates.get(name);
if( template == null )
{
@@ -1340,6 +1397,10 @@
public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info)
throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
if(deploymentBaseName == null)
throw new IllegalArgumentException("Null deployment base name.");
if(info == null)
@@ -1377,6 +1438,10 @@
public void updateComponent(ManagedComponent comp)
throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
if(comp == null)
throw new IllegalArgumentException("Null managed component.");
// Find the comp deployment
@@ -1495,6 +1560,10 @@
public void removeComponent(ManagedComponent comp) throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(MV_RUNTIME_PERMISSION);
+
if(comp == null)
throw new IllegalArgumentException("null managed component.");
//
@@ -1723,14 +1792,14 @@
return proxyFactory.createOperationProxies(ops, componentName);
}
- private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse)
+ private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse, Map<String, String> propertyMetaMappings)
throws Exception
{
MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
MetaData metaData = null;
ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[]{ViewUse.valueOf(defaultViewUse)};
- ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse);
+ ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse, propertyMetaMappings);
return mo;
}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -21,7 +21,9 @@
*/
package org.jboss.profileservice.management;
+import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import javax.management.ObjectName;
@@ -31,7 +33,7 @@
/**
* Encapsulation of a collection of mbeans that should be exposed as a
* ManagedDeployment with ManagedComponents.
- *
+ *
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
@@ -48,6 +50,12 @@
/** A map of attribute name to ComponentType:ComponentSubType for child components of the root component */
private Map<String, String> componentInfo;
+ /** An attribute of the mdb used to build the subtype */
+ private String subtypeAttribute;
+
+ /** Excluded ObjectName keys */
+ private Set<String> excludedKeys = Collections.emptySet();
+
public String getCompType()
{
return compType;
@@ -64,6 +72,26 @@
{
this.compSubtype = compSubtype;
}
+
+ public String getSubtypeAttribute()
+ {
+ return this.subtypeAttribute;
+ }
+
+ public void setSubtypeAttribute(String subtypeAttribute)
+ {
+ this.subtypeAttribute = subtypeAttribute;
+ }
+
+ public Set<String> getExcludedKeys()
+ {
+ return this.excludedKeys;
+ }
+
+ public void setExcludedKeys(Set<String> excludedKeys)
+ {
+ this.excludedKeys = excludedKeys;
+ }
public ComponentType getType()
{
return new ComponentType(compType, compSubtype);
@@ -76,7 +104,7 @@
{
this.pattern = pattern;
}
-
+
public MBeanDeploymentNameBuilder getNameBuilder()
{
return nameBuilder;
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -37,7 +37,7 @@
*
* @author Scott.Stark at jboss.org
* @author Jason T. Greene
- * @version $Revision: 88974 $
+ * @version $Revision: 89854 $
*/
public class ProxyManagedDeploymentFactory implements ManagedMBeanDeploymentFactory
{
@@ -50,6 +50,9 @@
/** The default view to expose fields as */
private String defaultViewUse;
+ /** The global property to meta-mapper configuration */
+ private Map<String, String> propertyMetaMappings;
+
public String getFactoryName()
{
return factoryName;
@@ -78,7 +81,18 @@
this.defaultViewUse = defaultViewUse;
}
+ public Map<String, String> getPropertyMetaMappings()
+ {
+ return propertyMetaMappings;
+ }
+ public void setPropertyMetaMappings(Map<String, String> propertyMappings)
+ {
+ this.propertyMetaMappings = propertyMappings;
+ }
+
+
+
public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
{
Map<String, MBeanDeployment> tmp = new HashMap<String, MBeanDeployment>();
@@ -92,6 +106,9 @@
{
for(ObjectName name : names)
{
+ if (hasExcludedNameKey(info, name))
+ continue;
+
String dname = info.getNameBuilder().getName(name, mbeanServer);
MBeanDeployment deployment = tmp.get(dname);
if(deployment == null)
@@ -100,7 +117,24 @@
tmp.put(dname, deployment);
}
String compType = info.getCompType();
- String compSubtype = info.getCompSubtype();
+ String compSubtype = null;
+
+ if (info.getSubtypeAttribute() != null)
+ {
+ try
+ {
+ compSubtype = (String) mbeanServer.getAttribute(name, info.getSubtypeAttribute());
+ }
+ catch (Exception e)
+ {
+ // EAT
+ }
+ }
+
+ if (compSubtype == null)
+ compSubtype = info.getCompSubtype();
+
+
MBeanComponent rootComp = new MBeanComponent(name, compType, compSubtype);
deployment.addComponent(rootComp);
Map<String, String> componentInfo = info.getComponentInfo();
@@ -120,7 +154,7 @@
}
catch(Exception e)
{
- e.printStackTrace();
+ // EAT
}
}
}
@@ -130,6 +164,17 @@
return tmp.values();
}
+ private boolean hasExcludedNameKey(ProxyDeploymentInfo info, ObjectName name)
+ {
+ Set<String> excludedKeys = info.getExcludedKeys();
+ for (Object key : name.getKeyPropertyList().keySet())
+ {
+ if (excludedKeys.contains(key))
+ return true;
+ }
+
+ return false;
+ }
/**
* Generate MBeanComponents for each name given by the attribute value. This
* processes the attribute value as an array or collection of strings or
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,144 @@
+/*
+ * 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.profileservice.management.client;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedComponent;
+import org.jboss.managed.api.RunState;
+
+/**
+ * A ManagedComponent used to proxy and dispatch the RunState on request.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedComponentDelegate implements MutableManagedComponent
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+ private Object componentName;
+ private MutableManagedComponent delegate;
+ private DelegatingComponentDispatcher dispatcher;
+
+ public ManagedComponentDelegate(Object componentName, MutableManagedComponent delegate, DelegatingComponentDispatcher dispatcher)
+ {
+ this.componentName = componentName;
+ this.delegate = delegate;
+ this.dispatcher = dispatcher;
+ }
+
+ public Map<String, Annotation> getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public ManagedDeployment getDeployment()
+ {
+ return delegate.getDeployment();
+ }
+
+ public RunState getRunState()
+ {
+ return dispatcher.updateRunState(componentName);
+ }
+
+ public void setRunState(RunState runState)
+ {
+ delegate.setRunState(runState);
+ }
+
+ public ComponentType getType()
+ {
+ return delegate.getType();
+ }
+
+ public boolean update()
+ {
+ return delegate.update();
+ }
+
+ public String getAttachmentName()
+ {
+ return delegate.getAttachmentName();
+ }
+
+ public Object getComponentName()
+ {
+ return delegate.getComponentName();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public String getNameType()
+ {
+ return delegate.getNameType();
+ }
+
+ public Set<ManagedOperation> getOperations()
+ {
+ return delegate.getOperations();
+ }
+
+ public void setOperations(Set<ManagedOperation> operations)
+ {
+ delegate.setOperations(operations);
+ }
+
+ public ManagedCommon getParent()
+ {
+ return delegate.getParent();
+ }
+
+ public ManagedProperty getProperty(String name)
+ {
+ return delegate.getProperty(name);
+ }
+
+ public Map<String, ManagedProperty> getProperties()
+ {
+ return delegate.getProperties();
+ }
+
+ public void setProperties(Map<String, ManagedProperty> properties)
+ {
+ delegate.setProperties(properties);
+ }
+
+ public Set<String> getPropertyNames()
+ {
+ return delegate.getPropertyNames();
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 90913 $
+ */
+public class ManagedOperationDelegate
+ implements ManagedOperation
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2031110731596810579L;
+ private long opID;
+ private Object componentName;
+ private ManagedOperation delegate;
+ private DelegatingComponentDispatcher dispatcherProxy;
+
+ public ManagedOperationDelegate(long opID, ManagedOperation delegate, Object componentName,
+ DelegatingComponentDispatcher dispatcherProxy)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate.");
+ this.opID = opID;
+ this.delegate = delegate;
+ this.componentName = componentName;
+ this.dispatcherProxy = dispatcherProxy;
+ }
+
+ public long getOpID()
+ {
+ return opID;
+ }
+
+ public MetaValue invoke(MetaValue... metaValues)
+ {
+ return dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);
+ }
+
+ public String getDescription()
+ {
+ return delegate.getDescription();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public Impact getImpact()
+ {
+ return delegate.getImpact();
+ }
+
+ public MetaType getReturnType()
+ {
+ return delegate.getReturnType();
+ }
+
+ public ManagedParameter[] getParameters()
+ {
+ return delegate.getParameters();
+ }
+
+ public String[] getReflectionSignature()
+ {
+ return delegate.getReflectionSignature();
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ return delegate.getTransientAttachment(expectedType);
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ return delegate.getTransientAttachment(name);
+ }
+
+ public void setTransientAttachment(String name, Object attachment)
+ {
+ delegate.setTransientAttachment(name, attachment);
+ }
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A ManagedProperty delegate used as the target of the ManagedProperty
+ * proxies used for runtime managed objects statistics.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 90948 $
+ */
+public class ManagedPropertyDelegate implements ManagedProperty
+{
+ private final static long serialVersionUID = 1;
+ private long propID;
+ private Object componentName;
+ private ManagedProperty delegate;
+ private DelegatingComponentDispatcher dispatcher;
+
+ public ManagedPropertyDelegate(long propID, ManagedProperty delegate,
+ Object componentName, DelegatingComponentDispatcher dispatcher)
+ {
+ super();
+ this.propID = propID;
+ this.delegate = delegate;
+ this.dispatcher = dispatcher;
+ this.componentName = componentName;
+ }
+
+ public String checkValidValue(MetaValue value)
+ {
+ return delegate.checkValidValue(value);
+ }
+
+ public ManagedProperty copy()
+ {
+ return delegate.copy();
+ }
+
+ public Map<String, Annotation> getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public String getDescription()
+ {
+ return delegate.getDescription();
+ }
+
+ public <T> T getField(String fieldName, Class<T> expected)
+ {
+ return delegate.getField(fieldName, expected);
+ }
+
+ public Fields getFields()
+ {
+ return delegate.getFields();
+ }
+
+ public Set<MetaValue> getLegalValues()
+ {
+ return delegate.getLegalValues();
+ }
+
+ public MetaValue getDefaultValue()
+ {
+ return delegate.getDefaultValue();
+ }
+
+ public ManagedObject getManagedObject()
+ {
+ return delegate.getManagedObject();
+ }
+
+ public String getMappedName()
+ {
+ return delegate.getMappedName();
+ }
+
+ public Comparable<? extends MetaValue> getMaximumValue()
+ {
+ return delegate.getMaximumValue();
+ }
+
+ public MetaType getMetaType()
+ {
+ return delegate.getMetaType();
+ }
+
+ public Comparable<? extends MetaValue> getMinimumValue()
+ {
+ return delegate.getMinimumValue();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public ManagedObject getTargetManagedObject()
+ {
+ return delegate.getTargetManagedObject();
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ return delegate.getTransientAttachment(expectedType);
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ return delegate.getTransientAttachment(name);
+ }
+
+ public MetaValue getValue()
+ {
+ return dispatcher.get(propID, componentName, getMappedName());
+ }
+
+ public Collection<String> getAdminViewUses()
+ {
+ return delegate.getAdminViewUses();
+ }
+
+ public boolean hasAnnotation(String key)
+ {
+ return delegate.hasAnnotation(key);
+ }
+
+ public boolean hasViewUse(ViewUse use)
+ {
+ return delegate.hasViewUse(use);
+ }
+
+ public ActivationPolicy getActivationPolicy()
+ {
+ return delegate.getActivationPolicy();
+ }
+
+ public void setModified(boolean flag)
+ {
+ delegate.setModified(flag);
+ }
+
+ public boolean isMandatory()
+ {
+ return delegate.isMandatory();
+ }
+
+ public boolean isReadOnly()
+ {
+ return delegate.isReadOnly();
+ }
+
+ public boolean isModified()
+ {
+ return delegate.isModified();
+ }
+
+ public boolean isRemoved()
+ {
+ return delegate.isRemoved();
+ }
+
+ public void setField(String fieldName, Serializable value)
+ {
+ delegate.setField(fieldName, value);
+ }
+
+ public void setManagedObject(ManagedObject managedObject)
+ {
+ delegate.setManagedObject(managedObject);
+ }
+
+ public void setRemoved(boolean flag)
+ {
+ delegate.setRemoved(flag);
+ }
+
+ public void setTargetManagedObject(ManagedObject target)
+ {
+ delegate.setTargetManagedObject(target);
+ }
+
+ public void setTransientAttachment(String name, Object attachment)
+ {
+ delegate.setTransientAttachment(name, attachment);
+ }
+
+ public void setValue(MetaValue value)
+ {
+ delegate.setValue(value);
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/package.html
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/package.html (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/package.html 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id: package.html 71554 2008-04-01 13:25:40Z adrian at jboss.org $ -->
+ <!--
+/*
+ * 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.
+ */
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <h1>Profile Service Client Classes</h1>
+<p>This package contains the classes associated with the profile service
+implementation that need to be in client classpaths.
+</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,434 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.ProgressEvent;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
+
+/**
+ * The deployment progress.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 91130 $
+ */
+public class DeploymentProgressImpl implements DeploymentProgress, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /** The client side listeners */
+ private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
+ private transient DeploymentStatus currentStatus;
+ private transient boolean isCancelled;
+ /** The targets to distribute to */
+ private List<DeploymentTarget> targets;
+ /** The deployment being distributed */
+ private DeploymentID deployment;
+ private CommandType command;
+
+ public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
+ {
+ this.targets = targets;
+ this.deployment = deployment;
+ this.command = command;
+ }
+
+ public synchronized void addProgressListener(ProgressListener listener)
+ {
+ if(listeners == null)
+ listeners = new CopyOnWriteArrayList<ProgressListener>();
+ listeners.add(listener);
+ }
+ public void removeProgressListener(ProgressListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Begins the deployment command process
+ */
+ public void run()
+ {
+ switch(command)
+ {
+ case DISTRIBUTE:
+ distribute();
+ break;
+ case PREPARE:
+ prepare();
+ break;
+ case START:
+ start();
+ break;
+ case STOP:
+ stop();
+ break;
+ case REMOVE:
+ remove();
+ break;
+ case REDEPLOY:
+ redeploy();
+ break;
+ default:
+ throw new IllegalStateException(command+" is not currently handled");
+ }
+ }
+
+ public void cancel()
+ {
+ isCancelled = true;
+ }
+
+ public DeploymentStatus getDeploymentStatus()
+ {
+ return currentStatus;
+ }
+
+ public DeploymentID getDeploymentID()
+ {
+ return deployment;
+ }
+
+ public List<DeploymentTarget> getDeploymentTargets()
+ {
+ return targets;
+ }
+
+ /**
+ *
+ * @param event
+ */
+ protected void notify(ProgressEvent event)
+ {
+ if(listeners == null)
+ return;
+
+ for(ProgressListener listener : listeners)
+ {
+ try
+ {
+ listener.progressEvent(event);
+ }
+ catch(Throwable ignore)
+ {
+ }
+ }
+ }
+
+ protected void distribute()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setMessage("Running distribute to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Distribute has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ // TODO, percent complete info in upload and overall distribute
+ status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
+ status.setTarget(target);
+ status.setRunning(true);
+ status.setMessage("Begining distribute to target: "+target);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+
+ // TODO, cancellation of in progress distribution
+ target.distribute(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setTarget(target);
+ status.setMessage("Completed distribute to target: "+target);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+
+ if(currentStatus.isFailed() == false)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setMessage("Completed distribute to all targets");
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ }
+
+ protected void start()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running start to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Start has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.start(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed start for target: "+target);
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void stop()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running stop to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Stop has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.stop(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed stop for target: "+target);
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void remove()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running undeploy to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Undeploy has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.remove(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed undeploy for target: "+target);
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void redeploy()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running redeploy to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Redeploy has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.redeploy(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed redeploy for target: "+target);
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+
+ protected void prepare()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running prepare to: "+targets);
+ status.setRunning(true);
+ currentStatus = status;
+ ProgressEvent event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ for(DeploymentTarget target : targets)
+ {
+ if(isCancelled)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Prepare has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.prepare(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed prepare for target: "+target);
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ catch(Exception e)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ status.setTarget(target);
+ status.setFailure(e);
+ status.setFailed(true);
+ currentStatus = status;
+ ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+ notify(error);
+ break;
+ }
+ }
+ }
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A serializable DeploymentID implementation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 91130 $
+ */
+public class SerializableDeploymentID implements DeploymentID, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /** An InputStream to use to copy the contents */
+ private transient InputStream contentIS;
+ private Set<DeploymentOption> options;
+ private String[] deploymentNames;
+ private String[] repositoryNames;
+ private ProfileKey profileKey;
+ private String description;
+ private URL contentURL;
+ private boolean copyContent;
+
+ public SerializableDeploymentID(DeploymentID deployment)
+ {
+ this(deployment.getNames(), deployment.getProfile(), deployment.getDescription(), deployment.getDeploymentOptions());
+ }
+
+ public SerializableDeploymentID(String name, ProfileKey profileKey, String description)
+ {
+ this(new String[]{name}, profileKey, description);
+ }
+
+ public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description)
+ {
+ this(names, profileKey, description, new DeploymentOption[0]);
+ }
+
+ public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description, DeploymentOption... options)
+ {
+ this.deploymentNames = names;
+ this.profileKey = profileKey;
+ this.description = description;
+ this.copyContent = true; // by default we copy content
+ this.options = new HashSet<DeploymentOption>();
+ if(options != null && options.length > 0)
+ {
+ for(DeploymentOption option : options)
+ addDeploymentOption(option);
+ }
+ }
+
+ public String[] getNames()
+ {
+ return deploymentNames;
+ }
+
+ public String[] getRepositoryNames()
+ {
+ if(repositoryNames == null)
+ repositoryNames = deploymentNames;
+ return repositoryNames;
+ }
+ public void setRepositoryNames(String[] names)
+ {
+ this.repositoryNames = names;
+ }
+
+ /**
+ * The target profile for the deployment.
+ * For further use.
+ */
+ public ProfileKey getProfile()
+ {
+ return this.profileKey;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public URL getContentURL()
+ {
+ return contentURL;
+ }
+ public void setContentURL(URL contentURL)
+ {
+ this.contentURL = contentURL;
+ }
+
+ public boolean isCopyContent()
+ {
+ return copyContent;
+ }
+ public void setCopyContent(boolean copyContent)
+ {
+ this.copyContent = copyContent;
+ }
+
+ /**
+ * An optional deployment archive content stream for the top-level
+ * deployment.
+ *
+ * @return the archive input stream if it exists
+ */
+ public InputStream getContentIS()
+ {
+ return contentIS;
+ }
+ /**
+ *
+ * @param contentIS
+ */
+ public void setContentIS(InputStream contentIS)
+ {
+ this.contentIS = contentIS;
+ }
+
+ public void addDeploymentOption(DeploymentOption option)
+ {
+ if(option == null)
+ throw new IllegalArgumentException("null option");
+ this.options.add(option);
+ }
+
+ public DeploymentOption[] getDeploymentOptions()
+ {
+ return this.options.toArray(new DeploymentOption[this.options.size()]);
+ }
+
+ public boolean hasDeploymentOption(DeploymentOption option)
+ {
+ if(option == null)
+ throw new IllegalArgumentException("null option");
+ return this.options.contains(option);
+ }
+
+ public boolean removeDeploymentOption(DeploymentOption option)
+ {
+ return this.options.remove(option);
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("names=").append(Arrays.toString(getNames()));
+ // Only add the repositoryNames if it differs from deploymentNames
+ if(getRepositoryNames() != getNames())
+ buffer.append(", repositoryNames=").append(Arrays.toString(getRepositoryNames()));
+ // Only log copyContent when the contentURL is set
+ if(getContentURL() != null)
+ buffer.append(", copyContent=").append(copyContent);
+ if(description != null)
+ buffer.append(", description=").append(description);
+ if(options != null && options.isEmpty() == false)
+ buffer.append(", options=").append(options);
+ return buffer.toString();
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+
+/**
+ * Simple javabean impl of DeploymentStatus
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 91130 $
+ */
+public class SerializableDeploymentStatus implements DeploymentStatus,
+ Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ private CommandType command;
+ private Exception failure;
+ private String message;
+ private StateType state;
+ private DeploymentTarget target;
+ private boolean isCompleted;
+ private boolean isFailed;
+ private boolean isRunning;
+
+ public SerializableDeploymentStatus(CommandType command, StateType state)
+ {
+ this.command = command;
+ this.state = state;
+ }
+
+ public CommandType getCommand()
+ {
+ return command;
+ }
+ public void setCommand(CommandType command)
+ {
+ this.command = command;
+ }
+
+ public DeploymentTarget getTarget()
+ {
+ return target;
+ }
+ public void setTarget(DeploymentTarget target)
+ {
+ this.target = target;
+ }
+
+ public Exception getFailure()
+ {
+ return failure;
+ }
+ public void setFailure(Exception failure)
+ {
+ this.failure = failure;
+ }
+ public String getMessage()
+ {
+ return message;
+ }
+ public void setMessage(String message)
+ {
+ this.message = message;
+ }
+ public StateType getState()
+ {
+ return state;
+ }
+ public void setState(StateType state)
+ {
+ this.state = state;
+ }
+ public boolean isCompleted()
+ {
+ return isCompleted;
+ }
+ public void setCompleted(boolean isCompleted)
+ {
+ this.isCompleted = isCompleted;
+ }
+ public boolean isFailed()
+ {
+ return isFailed;
+ }
+ public void setFailed(boolean isFailed)
+ {
+ this.isFailed = isFailed;
+ }
+ public boolean isRunning()
+ {
+ return isRunning;
+ }
+ public void setRunning(boolean isRunning)
+ {
+ this.isRunning = isRunning;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("DeploymentStatus(");
+ tmp.append("command=");
+ tmp.append(command);
+ tmp.append(",state=");
+ tmp.append(state);
+ tmp.append(",message=");
+ tmp.append(message);
+ tmp.append(",isCompleted=");
+ tmp.append(isCompleted);
+ tmp.append(",isRunning=");
+ tmp.append(isRunning);
+ tmp.append(",isFailed=");
+ tmp.append(isFailed);
+
+ if(failure != null)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ failure.printStackTrace(pw);
+ tmp.append(",failure:\n");
+ tmp.append(sw.toString());
+ }
+ tmp.append(")");
+ return tmp.toString();
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,315 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * An implementation of DeploymentTarget that uses remoting for streaming
+ * content in distribute, and basic rpc for the other methods.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 91161 $
+ */
+public class StreamingDeploymentTarget
+ implements DeploymentTarget, Serializable
+{
+ private static final long serialVersionUID = 1;
+ private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
+
+ /** The deployment target locator */
+ private InvokerLocator locator;
+ private String name;
+ private String subsystem;
+
+ /**
+ * Create a target given a remoting locator
+ * @param locator -
+ * @param name -
+ * @param subsystem -
+ */
+ public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
+ {
+ log.debug("new StreamingTarget: " + locator);
+ this.name = name;
+ this.subsystem = subsystem;
+ this.locator = locator;
+ }
+
+ public String getDescription()
+ {
+ return name + "(" + locator + ")";
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public InvokerLocator getInvokerLocator()
+ {
+ return locator;
+ }
+
+ /**
+ * Distribute a deployment to the profile targets.
+ *
+ * @param deployment - the encapsulation of the deployment to distribute
+ * @throws Exception for any error
+ */
+ public void distribute(DeploymentID deployment) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin distribute: " + deployment);
+ String[] rnames;
+ if (deployment.isCopyContent())
+ {
+ URL contentURL = deployment.getContentURL();
+ SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
+ InputStream contentIS = contentURL.openStream();
+ sdtID.setContentIS(contentIS);
+ String repositoryName = transferDeployment(client, sdtID);
+ rnames = new String[]{repositoryName};
+ }
+ else
+ {
+ rnames = (String[])invoke(client, "distribute", createArgs(deployment));
+ }
+ // Update the repository names on the deployment
+ deployment.setRepositoryNames(rnames);
+ log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public String[] getRepositoryNames(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
+ String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
+ log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
+ return rnames;
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public void redeploy(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin redeploy: " + dtID);
+ invoke(client, "redeploy", createArgs(dtID));
+ log.debug("End redeploy: "+dtID);
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public void prepare(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin prepare: " + dtID);
+ invoke(client, "prepare", createArgs(dtID));
+ log.debug("End prepare: "+dtID);
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ /**
+ * Create the client args.
+ *
+ * @param dtID the deployment id
+ * @return args map
+ */
+ protected Map<?, ?> createArgs(DeploymentID dtID)
+ {
+ return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
+ }
+
+ /**
+ * Start a given deployment(s)
+ */
+ public void start(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Start: " + dtID);
+ invoke(client, "start", createArgs(dtID));
+ log.debug("End start: "+dtID);
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ /**
+ * Stop a given module
+ */
+ public void stop(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin stop: " + dtID);
+ invoke(client, "stop", createArgs(dtID));
+ log.debug("End stop");
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ /**
+ * Remove a given module.
+ *
+ * @param dtID the deployment id
+ * @throws Exception
+ */
+ public void remove(DeploymentID dtID) throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin remove: " + dtID);
+ invoke(client, "remove", createArgs(dtID));
+ log.debug("End remove");
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("name=");
+ tmp.append(name);
+ tmp.append(", locator=");
+ tmp.append(locator);
+ tmp.append(", subsystem=");
+ tmp.append(subsystem);
+ return tmp.toString();
+ }
+
+ /**
+ * Get the remoting client connection
+ * @return
+ * @throws Exception
+ */
+ private Client getClient() throws Exception
+ {
+ log.debug("Calling remoting server with locator of: " + locator);
+
+ Client remotingClient = new Client(locator, subsystem);
+ remotingClient.connect();
+ return remotingClient;
+ }
+
+ /**
+ * Stream a deployment to the server
+ *
+ * @param client - the remoting client
+ * @param sdtID - the deployment content encapsulation
+ * @return the profile service repository unique name
+ * @throws Exception
+ */
+ private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
+ {
+ InputStream is = sdtID.getContentIS();
+ try
+ {
+ // This return value depends on the proxy type
+ InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
+ return (String) response.getResponse();
+ }
+ catch(Error e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+
+ private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
+ {
+ try
+ {
+ return client.invoke(name, args);
+ }
+ catch(Error e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/matchers/AliasMatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/matchers/AliasMatcher.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/matchers/AliasMatcher.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -35,7 +35,7 @@
* addition to the component name.
*
* @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public class AliasMatcher implements NameMatcher<ManagedComponent>
, Serializable
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.profileservice.management.mbean;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * {@link MetaMapper} for detyped EJB invocation statistics.
+ *
+ * @author Jason T. Greene
+ */
+public class EJBInvocationStatsMapper extends MetaMapper<Map<String, Map<String, Long>>>
+{
+ public static final CompositeMetaType TYPE;
+ public static final CompositeMetaType METHOD_STATS_TYPE;
+ private static String[] rootItemNames;
+ private static MapCompositeMetaType METHOD_STATS_MAP_TYPE;
+
+ static
+ {
+ String[] methodItemNames = {
+ "count",
+ "minTime",
+ "maxTime",
+ "totalTime"
+ };
+ String[] methodItemDescriptions = {
+ "the number of invocations",
+ "the minimum invocation time",
+ "the maximum invocation time",
+ "the total invocation time",
+ };
+ MetaType[] methodItemTypes = {
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ };
+ METHOD_STATS_TYPE = new ImmutableCompositeMetaType("MethodStatistics",
+ "Method invocation statistics",
+ methodItemNames, methodItemDescriptions, methodItemTypes);
+
+ METHOD_STATS_MAP_TYPE = new MapCompositeMetaType(METHOD_STATS_TYPE);
+
+ rootItemNames = new String[] {
+ "concurrentCalls",
+ "maxConcurrentCalls",
+ "lastResetTime",
+ "methodStats"
+ };
+
+ String[] rootItemDescriptions = {
+ "the number of concurrent invocations",
+ "the maximum number of concurrent invocations",
+ "last time statistics were reset",
+ "method statistics",
+ };
+ MetaType[] rootItemTypes = {
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ METHOD_STATS_MAP_TYPE
+ };
+
+ TYPE = new ImmutableCompositeMetaType("InvocationStatistics",
+ "EJB invocation statistics",
+ rootItemNames, rootItemDescriptions, rootItemTypes);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return Map.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, Map<String, Map<String, Long>> object)
+ {
+ Map<String, MetaValue> methodMap = new HashMap<String, MetaValue>();
+ for (Map.Entry<String, Map<String, Long>> entry: object.entrySet())
+ {
+ if (entry.getKey().charAt(0) == '#')
+ continue;
+
+ MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
+ for (String name : METHOD_STATS_TYPE.itemSet())
+ cvs.put(name, SimpleValueSupport.wrap(entry.getValue().get(name)));
+
+ methodMap.put(entry.getKey(), cvs);
+ }
+
+ MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);
+ for (int i = 0; i < 3; i++)
+ root.put(rootItemNames[i], SimpleValueSupport.wrap(object.get("#Global").get(rootItemNames[i])));
+
+ root.put(rootItemNames[3], new MapCompositeValueSupport(methodMap, METHOD_STATS_MAP_TYPE));
+
+ return root;
+ }
+
+ @Override
+ public Map<String, Map<String, Long>> unwrapMetaValue(MetaValue metaValue)
+ {
+ // This is read-only, so not needed
+ return null;
+ }
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -21,6 +21,7 @@
*/
package org.jboss.profileservice.management.templates;
+import java.io.ObjectStreamException;
import java.util.Map;
import org.jboss.managed.api.Fields;
@@ -110,4 +111,15 @@
}
}
+ /**
+ * Expose only plain BasicDeploymentTemplateInfo to avoid leaking server types.
+ *
+ * @return simpler ManagedPropertyImpl
+ * @throws java.io.ObjectStreamException for any error
+ */
+ private Object writeReplace() throws ObjectStreamException
+ {
+ BasicDeploymentTemplateInfo info = new BasicDeploymentTemplateInfo(getName(), getDescription(), getProperties());
+ return info;
+ }
}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -34,7 +34,9 @@
import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
import org.jboss.logging.Logger;
-import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
+import org.jboss.profileservice.management.client.upload.DeploymentProgressImpl;
+import org.jboss.profileservice.management.client.upload.SerializableDeploymentID;
+import org.jboss.profileservice.management.client.upload.StreamingDeploymentTarget;
import org.jboss.profileservice.spi.DeploymentOption;
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileKey;
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,434 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.deployers.spi.management.deploy.ProgressEvent;
-import org.jboss.deployers.spi.management.deploy.ProgressListener;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
-
-/**
- * The deployment progress.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class DeploymentProgressImpl implements DeploymentProgress, Serializable
-{
- private static final long serialVersionUID = 1;
-
- /** The client side listeners */
- private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
- private transient DeploymentStatus currentStatus;
- private transient boolean isCancelled;
- /** The targets to distribute to */
- private List<DeploymentTarget> targets;
- /** The deployment being distributed */
- private DeploymentID deployment;
- private CommandType command;
-
- public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
- {
- this.targets = targets;
- this.deployment = deployment;
- this.command = command;
- }
-
- public synchronized void addProgressListener(ProgressListener listener)
- {
- if(listeners == null)
- listeners = new CopyOnWriteArrayList<ProgressListener>();
- listeners.add(listener);
- }
- public void removeProgressListener(ProgressListener listener)
- {
- listeners.remove(listener);
- }
-
- /**
- * Begins the deployment command process
- */
- public void run()
- {
- switch(command)
- {
- case DISTRIBUTE:
- distribute();
- break;
- case PREPARE:
- prepare();
- break;
- case START:
- start();
- break;
- case STOP:
- stop();
- break;
- case REMOVE:
- remove();
- break;
- case REDEPLOY:
- redeploy();
- break;
- default:
- throw new IllegalStateException(command+" is not currently handled");
- }
- }
-
- public void cancel()
- {
- isCancelled = true;
- }
-
- public DeploymentStatus getDeploymentStatus()
- {
- return currentStatus;
- }
-
- public DeploymentID getDeploymentID()
- {
- return deployment;
- }
-
- public List<DeploymentTarget> getDeploymentTargets()
- {
- return targets;
- }
-
- /**
- *
- * @param event
- */
- protected void notify(ProgressEvent event)
- {
- if(listeners == null)
- return;
-
- for(ProgressListener listener : listeners)
- {
- try
- {
- listener.progressEvent(event);
- }
- catch(Throwable ignore)
- {
- }
- }
- }
-
- protected void distribute()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
- status.setMessage("Running distribute to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Distribute has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- // TODO, percent complete info in upload and overall distribute
- status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
- status.setTarget(target);
- status.setRunning(true);
- status.setMessage("Begining distribute to target: "+target);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
-
- // TODO, cancellation of in progress distribution
- target.distribute(deployment);
- status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
- status.setTarget(target);
- status.setMessage("Completed distribute to target: "+target);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
-
- if(currentStatus.isFailed() == false)
- {
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setMessage("Completed distribute to all targets");
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- }
-
- protected void start()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running start to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Start has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.start(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed start for target: "+target);
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void stop()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running stop to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Stop has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.stop(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed stop for target: "+target);
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void remove()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running undeploy to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Undeploy has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.remove(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed undeploy for target: "+target);
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void redeploy()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running redeploy to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Redeploy has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.redeploy(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed redeploy for target: "+target);
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-
- protected void prepare()
- {
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
- status.setMessage("Running prepare to: "+targets);
- status.setRunning(true);
- currentStatus = status;
- ProgressEvent event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- for(DeploymentTarget target : targets)
- {
- if(isCancelled)
- {
- status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
- status.setMessage("Prepare has been cancelled");
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- break;
- }
-
- try
- {
- target.prepare(deployment);
- status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
- status.setTarget(target);
- status.setMessage("Completed prepare for target: "+target);
- status.setCompleted(true);
- currentStatus = status;
- event = new ProgressEvent(deployment, currentStatus);
- notify(event);
- }
- catch(Exception e)
- {
- status = new SerializableDeploymentStatus(command, StateType.FAILED);
- status.setTarget(target);
- status.setFailure(e);
- status.setFailed(true);
- currentStatus = status;
- ProgressEvent error = new ProgressEvent(deployment, currentStatus);
- notify(error);
- break;
- }
- }
- }
-}
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,192 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.profileservice.spi.DeploymentOption;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * A serializable DeploymentID implementation.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentID implements DeploymentID, Serializable
-{
- private static final long serialVersionUID = 1;
-
- /** An InputStream to use to copy the contents */
- private transient InputStream contentIS;
- private Set<DeploymentOption> options;
- private String[] deploymentNames;
- private String[] repositoryNames;
- private ProfileKey profileKey;
- private String description;
- private URL contentURL;
- private boolean copyContent;
-
- public SerializableDeploymentID(DeploymentID deployment)
- {
- this(deployment.getNames(), deployment.getProfile(), deployment.getDescription(), deployment.getDeploymentOptions());
- }
-
- public SerializableDeploymentID(String name, ProfileKey profileKey, String description)
- {
- this(new String[]{name}, profileKey, description);
- }
-
- public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description)
- {
- this(names, profileKey, description, new DeploymentOption[0]);
- }
-
- public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description, DeploymentOption... options)
- {
- this.deploymentNames = names;
- this.profileKey = profileKey;
- this.description = description;
- this.copyContent = true; // by default we copy content
- this.options = new HashSet<DeploymentOption>();
- if(options != null && options.length > 0)
- {
- for(DeploymentOption option : options)
- addDeploymentOption(option);
- }
- }
-
- public String[] getNames()
- {
- return deploymentNames;
- }
-
- public String[] getRepositoryNames()
- {
- if(repositoryNames == null)
- repositoryNames = deploymentNames;
- return repositoryNames;
- }
- public void setRepositoryNames(String[] names)
- {
- this.repositoryNames = names;
- }
-
- /**
- * The target profile for the deployment.
- * For further use.
- */
- public ProfileKey getProfile()
- {
- return this.profileKey;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public URL getContentURL()
- {
- return contentURL;
- }
- public void setContentURL(URL contentURL)
- {
- this.contentURL = contentURL;
- }
-
- public boolean isCopyContent()
- {
- return copyContent;
- }
- public void setCopyContent(boolean copyContent)
- {
- this.copyContent = copyContent;
- }
-
- /**
- * An optional deployment archive content stream for the top-level
- * deployment.
- *
- * @return the archive input stream if it exists
- */
- public InputStream getContentIS()
- {
- return contentIS;
- }
- /**
- *
- * @param contentIS
- */
- public void setContentIS(InputStream contentIS)
- {
- this.contentIS = contentIS;
- }
-
- public void addDeploymentOption(DeploymentOption option)
- {
- if(option == null)
- throw new IllegalArgumentException("null option");
- this.options.add(option);
- }
-
- public DeploymentOption[] getDeploymentOptions()
- {
- return this.options.toArray(new DeploymentOption[this.options.size()]);
- }
-
- public boolean hasDeploymentOption(DeploymentOption option)
- {
- if(option == null)
- throw new IllegalArgumentException("null option");
- return this.options.contains(option);
- }
-
- public boolean removeDeploymentOption(DeploymentOption option)
- {
- return this.options.remove(option);
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("names=").append(Arrays.toString(getNames()));
- // Only add the repositoryNames if it differs from deploymentNames
- if(getRepositoryNames() != getNames())
- buffer.append(", repositoryNames=").append(Arrays.toString(getRepositoryNames()));
- // Only log copyContent when the contentURL is set
- if(getContentURL() != null)
- buffer.append(", copyContent=").append(copyContent);
- if(description != null)
- buffer.append(", description=").append(description);
- if(options != null && options.isEmpty() == false)
- buffer.append(", options=").append(options);
- return buffer.toString();
- }
-
-}
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-
-/**
- * Simple javabean impl of DeploymentStatus
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentStatus implements DeploymentStatus,
- Serializable
-{
- private static final long serialVersionUID = 1;
-
- private CommandType command;
- private Exception failure;
- private String message;
- private StateType state;
- private DeploymentTarget target;
- private boolean isCompleted;
- private boolean isFailed;
- private boolean isRunning;
-
- public SerializableDeploymentStatus(CommandType command, StateType state)
- {
- this.command = command;
- this.state = state;
- }
-
- public CommandType getCommand()
- {
- return command;
- }
- public void setCommand(CommandType command)
- {
- this.command = command;
- }
-
- public DeploymentTarget getTarget()
- {
- return target;
- }
- public void setTarget(DeploymentTarget target)
- {
- this.target = target;
- }
-
- public Exception getFailure()
- {
- return failure;
- }
- public void setFailure(Exception failure)
- {
- this.failure = failure;
- }
- public String getMessage()
- {
- return message;
- }
- public void setMessage(String message)
- {
- this.message = message;
- }
- public StateType getState()
- {
- return state;
- }
- public void setState(StateType state)
- {
- this.state = state;
- }
- public boolean isCompleted()
- {
- return isCompleted;
- }
- public void setCompleted(boolean isCompleted)
- {
- this.isCompleted = isCompleted;
- }
- public boolean isFailed()
- {
- return isFailed;
- }
- public void setFailed(boolean isFailed)
- {
- this.isFailed = isFailed;
- }
- public boolean isRunning()
- {
- return isRunning;
- }
- public void setRunning(boolean isRunning)
- {
- this.isRunning = isRunning;
- }
-
- @Override
- public String toString()
- {
- StringBuffer tmp = new StringBuffer("DeploymentStatus(");
- tmp.append("command=");
- tmp.append(command);
- tmp.append(",state=");
- tmp.append(state);
- tmp.append(",message=");
- tmp.append(message);
- tmp.append(",isCompleted=");
- tmp.append(isCompleted);
- tmp.append(",isRunning=");
- tmp.append(isRunning);
- tmp.append(",isFailed=");
- tmp.append(isFailed);
-
- if(failure != null)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- failure.printStackTrace(pw);
- tmp.append(",failure:\n");
- tmp.append(sw.toString());
- }
- tmp.append(")");
- return tmp.toString();
- }
-
-}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -35,7 +35,8 @@
import org.jboss.deployers.spi.management.deploy.DeploymentID;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.logging.Logger;
-import org.jboss.profileservice.management.upload.SerializableDeploymentID;
+import org.jboss.profileservice.management.client.upload.SerializableDeploymentID;
+import org.jboss.profileservice.remoting.SecurityContainer;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileDeployment;
@@ -45,6 +46,8 @@
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.stream.StreamInvocationHandler;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.SecurityContext;
import org.jboss.system.server.profileservice.repository.DefaultProfileDeploymentFactory;
import org.jboss.system.server.profileservice.repository.MainDeployerAdapter;
import org.jboss.virtual.VirtualFile;
@@ -66,6 +69,10 @@
/** The deployer. */
private MainDeployerAdapter deployer;
+ /** The profile service security domain name */
+ private String securityDomain = "jmx-console";
+ /** The security management layer to use in the security context setup */
+ private ISecurityManagement securityManagement;
/** The deployment factory */
private static final DefaultProfileDeploymentFactory deploymentFactory = DefaultProfileDeploymentFactory.getInstance();
@@ -101,6 +108,24 @@
return deploymentRepository.getRepositoryNames(names);
}
+ public String getSecurityDomain()
+ {
+ return securityDomain;
+ }
+ public void setSecurityDomain(String securityDomain)
+ {
+ this.securityDomain = securityDomain;
+ }
+
+ public ISecurityManagement getSecurityManagement()
+ {
+ return securityManagement;
+ }
+ public void setSecurityManagement(ISecurityManagement securityManagement)
+ {
+ this.securityManagement = securityManagement;
+ }
+
public void addListener(InvokerCallbackHandler arg0)
{
}
@@ -141,11 +166,16 @@
*/
public Object invoke(InvocationRequest request) throws Throwable
{
+ // Create a security context for the invocation
+ establishSecurityContext(request);
Object parameter = request.getParameter();
+
Object returnValue = null;
if(parameter instanceof Invocation)
{
+ Invocation inv =(Invocation) parameter;
+ SecurityContainer.setInvocation(inv);
returnValue = super.invoke(request);
}
else
@@ -364,4 +394,12 @@
return deploymentFactory.createProfileDeployment(file);
}
+ private void establishSecurityContext(InvocationRequest invocation) throws Exception
+ {
+ SecurityContext newSC = SecurityActions.createAndSetSecurityContext(securityDomain);
+
+ // Set the SecurityManagement on the context
+ SecurityActions.setSecurityManagement(newSC, securityManagement);
+ log.trace("establishSecurityIdentity:SecCtx="+SecurityActions.trace(newSC));
+ }
}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/SecurityActions.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/SecurityActions.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/SecurityActions.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload.remoting;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 85526 $
+ */
+class SecurityActions
+{
+ static SecurityContext createAndSetSecurityContext(final String domain) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>()
+ {
+ public SecurityContext run() throws Exception
+ {
+ SecurityContext sc = SecurityContextFactory.createSecurityContext(domain);
+ setSecurityContext(sc);
+ return sc;
+ }}
+ );
+ }
+
+ static void setSecurityContext(final SecurityContext sc)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }}
+ );
+ }
+ static void setSecurityManagement(final SecurityContext sc, final ISecurityManagement sm)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ sc.setSecurityManagement(sm);
+ return null;
+ }}
+ );
+ }
+ static String trace(final SecurityContext sc)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" Principal = " + sc.getUtil().getUserPrincipal());
+ sb.append(" Subject:"+sc.getUtil().getSubject());
+ sb.append(" Incoming run as:"+sc.getIncomingRunAs());
+ sb.append(" Outgoing run as:"+sc.getOutgoingRunAs());
+ return sb.toString();
+ }
+ }
+ );
+ }
+}
Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -1,316 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload.remoting;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.management.upload.SerializableDeploymentID;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-
-/**
- * An implementation of DeploymentTarget that uses remoting for streaming
- * content in distribute, and basic rpc for the other methods.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class StreamingDeploymentTarget
- implements DeploymentTarget, Serializable
-{
- private static final long serialVersionUID = 1;
- private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
-
- /** The deployment target locator */
- private InvokerLocator locator;
- private String name;
- private String subsystem;
-
- /**
- * Create a target given a remoting locator
- * @param locator -
- * @param name -
- * @param subsystem -
- */
- public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
- {
- log.debug("new StreamingTarget: " + locator);
- this.name = name;
- this.subsystem = subsystem;
- this.locator = locator;
- }
-
- public String getDescription()
- {
- return name + "(" + locator + ")";
- }
-
- public String getName()
- {
- return name;
- }
-
- public InvokerLocator getInvokerLocator()
- {
- return locator;
- }
-
- /**
- * Distribute a deployment to the profile targets.
- *
- * @param deployment - the encapsulation of the deployment to distribute
- * @throws Exception for any error
- */
- public void distribute(DeploymentID deployment) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin distribute: " + deployment);
- String[] rnames;
- if (deployment.isCopyContent())
- {
- URL contentURL = deployment.getContentURL();
- SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
- InputStream contentIS = contentURL.openStream();
- sdtID.setContentIS(contentIS);
- String repositoryName = transferDeployment(client, sdtID);
- rnames = new String[]{repositoryName};
- }
- else
- {
- rnames = (String[])invoke(client, "distribute", createArgs(deployment));
- }
- // Update the repository names on the deployment
- deployment.setRepositoryNames(rnames);
- log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public String[] getRepositoryNames(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
- String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
- log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
- return rnames;
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public void redeploy(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin redeploy: " + dtID);
- invoke(client, "redeploy", createArgs(dtID));
- log.debug("End redeploy: "+dtID);
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public void prepare(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin prepare: " + dtID);
- invoke(client, "prepare", createArgs(dtID));
- log.debug("End prepare: "+dtID);
- }
- finally
- {
- client.disconnect();
- }
- }
-
- /**
- * Create the client args.
- *
- * @param dtID the deployment id
- * @return args map
- */
- protected Map<?, ?> createArgs(DeploymentID dtID)
- {
- return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
- }
-
- /**
- * Start a given deployment(s)
- */
- public void start(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Start: " + dtID);
- invoke(client, "start", createArgs(dtID));
- log.debug("End start: "+dtID);
- }
- finally
- {
- client.disconnect();
- }
- }
-
- /**
- * Stop a given module
- */
- public void stop(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin stop: " + dtID);
- invoke(client, "stop", createArgs(dtID));
- log.debug("End stop");
- }
- finally
- {
- client.disconnect();
- }
- }
-
- /**
- * Remove a given module.
- *
- * @param dtID the deployment id
- * @throws Exception
- */
- public void remove(DeploymentID dtID) throws Exception
- {
- Client client = getClient();
- try
- {
- log.debug("Begin remove: " + dtID);
- invoke(client, "remove", createArgs(dtID));
- log.debug("End remove");
- }
- finally
- {
- client.disconnect();
- }
- }
-
- public String toString()
- {
- StringBuilder tmp = new StringBuilder();
- tmp.append("name=");
- tmp.append(name);
- tmp.append(", locator=");
- tmp.append(locator);
- tmp.append(", subsystem=");
- tmp.append(subsystem);
- return tmp.toString();
- }
-
- /**
- * Get the remoting client connection
- * @return
- * @throws Exception
- */
- private Client getClient() throws Exception
- {
- log.debug("Calling remoting server with locator of: " + locator);
-
- Client remotingClient = new Client(locator, subsystem);
- remotingClient.connect();
- return remotingClient;
- }
-
- /**
- * Stream a deployment to the server
- *
- * @param client - the remoting client
- * @param sdtID - the deployment content encapsulation
- * @return the profile service repository unique name
- * @throws Exception
- */
- private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
- {
- InputStream is = sdtID.getContentIS();
- try
- {
- // This return value depends on the proxy type
- InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
- return (String) response.getResponse();
- }
- catch(Error e)
- {
- throw new RuntimeException(e);
- }
- catch(Throwable e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- try
- {
- is.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
-
- private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
- {
- try
- {
- return client.invoke(name, args);
- }
- catch(Error e)
- {
- throw new RuntimeException(e);
- }
- catch(Throwable e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Added: trunk/profileservice/src/main/org/jboss/profileservice/remoting/BasicInvocation.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/BasicInvocation.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/BasicInvocation.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.remoting;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationBase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BasicInvocation extends InvocationBase
+{
+
+ public Invocation copy()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Invocation getWrapper(Interceptor[] newchain)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/remoting/InstanceInterceptor.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/InstanceInterceptor.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/InstanceInterceptor.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.remoting;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class InstanceInterceptor implements Interceptor
+{
+ private String name;
+ private Object target;
+
+ InstanceInterceptor(String name, Object target)
+ {
+ this.name = name;
+ this.target = target;
+ }
+ public String getName()
+ {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.aop.advice.Interceptor#invoke(org.jboss.aop.joinpoint.Invocation)
+ */
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ Method m = mi.getActualMethod();
+ Object[] args = mi.getArguments();
+
+ Object value = null;
+ try
+ {
+ m.invoke(target, args);
+ }
+ catch(InvocationTargetException ite)
+ {
+ throw ite.getCause();
+ }
+ return value;
+ }
+
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/remoting/PojiMethodInvocation.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/PojiMethodInvocation.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/PojiMethodInvocation.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.remoting;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.metadata.MetaDataResolver;
+import org.jboss.aop.metadata.SimpleMetaData;
+
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PojiMethodInvocation extends MethodInvocation
+{
+ private MethodInvocation delegate;
+ private Method method;
+
+ public PojiMethodInvocation(MethodInvocation delegate, Method method)
+ {
+ super();
+ this.delegate = delegate;
+ this.method = method;
+ }
+
+ public void addResponseAttachment(Object key, Object val)
+ {
+ delegate.addResponseAttachment(key, val);
+ }
+
+ public Invocation copy()
+ {
+ return delegate.copy();
+ }
+
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ public Method getActualMethod()
+ {
+ return method;
+ }
+
+ public Advisor getAdvisor()
+ {
+ return delegate.getAdvisor();
+ }
+
+ public Object[] getArguments()
+ {
+ return delegate.getArguments();
+ }
+
+ public int getCurrentInterceptor()
+ {
+ return delegate.getCurrentInterceptor();
+ }
+
+ public MetaDataResolver getInstanceResolver()
+ {
+ return delegate.getInstanceResolver();
+ }
+
+ public Interceptor[] getInterceptors()
+ {
+ return delegate.getInterceptors();
+ }
+
+ public SimpleMetaData getMetaData()
+ {
+ return delegate.getMetaData();
+ }
+
+ public Object getMetaData(Object group, Object attr)
+ {
+ return delegate.getMetaData(group, attr);
+ }
+
+ public Method getMethod()
+ {
+ return method;
+ }
+
+ public long getMethodHash()
+ {
+ return delegate.getMethodHash();
+ }
+
+ public Object getResponseAttachment(Object key)
+ {
+ return delegate.getResponseAttachment(key);
+ }
+
+ public Map<Object, Object> getResponseContextInfo()
+ {
+ return delegate.getResponseContextInfo();
+ }
+
+ public Object getTargetObject()
+ {
+ return delegate.getTargetObject();
+ }
+
+ public Invocation getWrapper(Interceptor[] newchain)
+ {
+ return delegate.getWrapper(newchain);
+ }
+
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ public Object invokeNext() throws Throwable
+ {
+ interceptors = delegate.getInterceptors();
+ currentInterceptor = delegate.getCurrentInterceptor();
+ if (interceptors != null && currentInterceptor < interceptors.length)
+ {
+ try
+ {
+ return interceptors[currentInterceptor++].invoke(this);
+ }
+ finally
+ {
+ // so that interceptors like clustering can reinvoke down the chain
+ currentInterceptor--;
+ }
+ }
+
+ return invokeTarget();
+ }
+
+ public Object invokeNext(Interceptor[] newInterceptors) throws Throwable
+ {
+ // Save the old stack position
+ Interceptor[] oldInterceptors = interceptors;
+ int oldCurrentInterceptor = currentInterceptor;
+
+ // Start the new stack
+ interceptors = newInterceptors;
+ currentInterceptor = 0;
+
+ // Invoke the new stack
+ try
+ {
+ return invokeNext();
+ }
+ finally
+ {
+ // Restore the old stack
+ interceptors = oldInterceptors;
+ currentInterceptor = oldCurrentInterceptor;
+ }
+ }
+
+ public Object invokeTarget() throws Throwable
+ {
+ return null;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException
+ {
+ delegate.readExternal(in);
+ }
+
+ public Object resolveAnnotation(Class<? extends Annotation> annotation)
+ {
+ return delegate.resolveAnnotation(annotation);
+ }
+
+ public Object resolveAnnotation(Class<? extends Annotation>[] annotations)
+ {
+ return delegate.resolveAnnotation(annotations);
+ }
+
+ public Object resolveClassAnnotation(Class<? extends Annotation> annotation)
+ {
+ return delegate.resolveClassAnnotation(annotation);
+ }
+
+ public Object resolveClassMetaData(Object key, Object attr)
+ {
+ return delegate.resolveClassMetaData(key, attr);
+ }
+
+ public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
+ {
+ return delegate.resolveTypedAnnotation(annotation);
+ }
+
+ public <T extends Annotation> T resolveTypedAnnotation(Class<T>[] annotations)
+ {
+ return delegate.resolveTypedAnnotation(annotations);
+ }
+
+ public <T extends Annotation> T resolveTypedClassAnnotation(
+ Class<T> annotation)
+ {
+ return delegate.resolveTypedClassAnnotation(annotation);
+ }
+
+ public void setAdvisor(Advisor advisor)
+ {
+ delegate.setAdvisor(advisor);
+ }
+
+ public void setArguments(Object[] arguments)
+ {
+ delegate.setArguments(arguments);
+ }
+
+ public void setInstanceResolver(MetaDataResolver instanceResolver)
+ {
+ delegate.setInstanceResolver(instanceResolver);
+ }
+
+ public void setMetaData(SimpleMetaData data)
+ {
+ delegate.setMetaData(data);
+ }
+
+ public void setResponseContextInfo(Map<Object, Object> responseContextInfo)
+ {
+ delegate.setResponseContextInfo(responseContextInfo);
+ }
+
+ public void setTargetObject(Object targetObject)
+ {
+ delegate.setTargetObject(targetObject);
+ }
+
+ public String toString()
+ {
+ return delegate.toString();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ delegate.writeExternal(out);
+ }
+
+
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -49,7 +49,7 @@
/** The DeploymentManager proxy */
private DeploymentManager deployMgrProxy;
/** The profile service security domain name */
- private String securityDomain = "profileservice";
+ private String securityDomain = "jmx-console";
/** The security management layer to use in the security context setup */
private ISecurityManagement securityManagement;
@@ -93,6 +93,8 @@
{
// Create a security context for the invocation
establishSecurityContext(invocation);
+ org.jboss.aop.joinpoint.Invocation inv =(org.jboss.aop.joinpoint.Invocation)invocation.getParameter();
+ SecurityContainer.setInvocation(inv);
InvocationResponse value = (InvocationResponse) super.invoke(invocation);
if( value.getResponse() instanceof ManagementView )
Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -29,6 +29,7 @@
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.proxy.Proxy;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
import org.jboss.aspects.remoting.MergeMetaDataInterceptor;
import org.jboss.aspects.remoting.Remoting;
@@ -38,6 +39,8 @@
import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.id.GUID;
+import org.jboss.util.naming.NonSerializableFactory;
import org.jboss.util.naming.Util;
/**
@@ -52,16 +55,31 @@
private static final Logger log = Logger.getLogger(ProxyFactory.class);
private String dispatchName = "ProfileService";
private String jndiName = "ProfileService";
+ private String localJndiName = "java:ProfileService";
private String mgtViewJndiName = "java:ManagementView";
private String deployMgrJndiName = "java:DeploymentManager";
private InvokerLocator locator;
+ /** The ProfileService bean the ps proxies delegate to */
private ProfileService ps;
+ /** The ManagementView bean the */
private ManagementView mgtView;
+ /** The DeploymentManager bean the */
private DeploymentManager deployMgr;
+ /** The remoting ProfileService proxy */
private Proxy psProxy;
+ /** The remoting ProfileService proxy */
private Proxy mgtViewProxy;
+ /** The remoting ProfileService proxy */
private Proxy deployMgrProxy;
+ /** The server side secured ProfileService proxy */
+ private ProfileService psProxySecure;
+
+ /** The secure server interceptor stack */
+ private List<Interceptor> serverProxyInterceptors;
+ /** The remoting client interceptor stack */
private List<Interceptor> proxyInterceptors;
+ /** Flag to create links to the old ejb3 facade proxy locations */
+ private boolean createEjb3Links;
public String getDispatchName()
{
@@ -167,15 +185,48 @@
this.proxyInterceptors = proxyInterceptors;
}
+ public List<Interceptor> getServerProxyInterceptors()
+ {
+ return serverProxyInterceptors;
+ }
+ public void setServerProxyInterceptors(List<Interceptor> serverProxyInterceptors)
+ {
+ this.serverProxyInterceptors = serverProxyInterceptors;
+ }
+
+ public boolean isCreateEjb3Links()
+ {
+ return createEjb3Links;
+ }
+
+ public void setCreateEjb3Links(boolean createEjb3Links)
+ {
+ this.createEjb3Links = createEjb3Links;
+ }
+
public void start()
throws Exception
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class[] ifaces = {ProfileService.class};
+ Class<?>[] ifaces = {ProfileService.class};
- // Create the ProfileService proxy
- Dispatcher.singleton.registerTarget(dispatchName, ps);
+ // Create the server side secured proxy
+ if(this.serverProxyInterceptors == null)
+ {
+ serverProxyInterceptors = new ArrayList<Interceptor>();
+ }
+ // Add the instance interceptor which delegates to the injected ps
+ //serverProxyInterceptors.add(new InstanceInterceptor("ProfileService", ps));
+ SecurityContainer container = new SecurityContainer(serverProxyInterceptors, ps);
+ psProxySecure = (ProfileService) java.lang.reflect.Proxy.newProxyInstance(loader, ifaces, container);
+ // Bind the unsecure proxy under the local jndi name
+ InitialContext ctx = new InitialContext();
+ NonSerializableFactory.rebind(ctx, localJndiName, ps);
+
+ // Create the remote ProfileService proxy using the secured proxy as the target
+ Dispatcher.singleton.registerTarget(dispatchName, psProxySecure);
+ // Create a default client proxy interceptor stack
if(proxyInterceptors == null)
{
proxyInterceptors = new ArrayList<Interceptor>();
@@ -184,15 +235,19 @@
proxyInterceptors.add(InvokeRemoteInterceptor.singleton);
}
+ // Create the remoting proxy that invokes back to the secured proxy target
psProxy = Remoting.createRemoteProxy(dispatchName, loader, ifaces, locator, proxyInterceptors, "ProfileService");
- InitialContext ctx = new InitialContext();
Util.bind(ctx, jndiName, psProxy);
log.debug("Bound ProfileService proxy under: "+jndiName);
+ // A server side secured ManagementView proxy
+ SecurityContainer container2 = new SecurityContainer(serverProxyInterceptors, mgtView);
+ Class<?>[] ifaces2 = {ManagementView.class};
+ ManagementView mgtViewSecure = (ManagementView) java.lang.reflect.Proxy.newProxyInstance(loader, ifaces2, container2);
// Create the ManagementView proxy
Class[] mvIfaces = {ManagementView.class};
String mvDispatchName = dispatchName+".ManagementView";
- Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
+ Dispatcher.singleton.registerTarget(mvDispatchName, mgtViewSecure);
mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator, proxyInterceptors, "ProfileService");
log.debug("Created ManagementView proxy");
if(mgtViewJndiName != null && mgtViewJndiName.length() > 0)
@@ -201,10 +256,14 @@
log.debug("Bound ManagementView proxy under: "+mgtViewJndiName);
}
+ // A server side secured DeploymentManager proxy
+ SecurityContainer container3 = new SecurityContainer(serverProxyInterceptors, deployMgr);
+ Class<?>[] ifaces3 = {DeploymentManager.class};
+ DeploymentManager deployMgrSecure = (DeploymentManager) java.lang.reflect.Proxy.newProxyInstance(loader, ifaces3, container3);
// Create the DeploymentManager proxy
Class[] dmIfaces = {DeploymentManager.class};
String dmDispatchName = dispatchName+".DeploymentManager";
- Dispatcher.singleton.registerTarget(dmDispatchName, deployMgr);
+ Dispatcher.singleton.registerTarget(dmDispatchName, deployMgrSecure);
deployMgrProxy = Remoting.createRemoteProxy(dmDispatchName, loader, dmIfaces, locator, proxyInterceptors, "DeploymentManager");
log.debug("Created DeploymentManager proxy");
if(deployMgrJndiName != null && deployMgrJndiName.length() > 0)
@@ -212,6 +271,15 @@
Util.bind(ctx, deployMgrJndiName, deployMgrProxy);
log.debug("Bound DeploymentManager proxy under: "+deployMgrJndiName);
}
+
+ //
+ if(createEjb3Links)
+ {
+ Util.createLinkRef("SecureProfileService/remote", this.jndiName);
+ Util.createLinkRef("SecureManagementView/remote", mgtViewJndiName);
+ Util.createLinkRef("SecureDeploymentManager/remote", deployMgrJndiName);
+ log.debug("Bound links back to secure ejb names");
+ }
}
public void stop()
@@ -233,5 +301,13 @@
Util.unbind(ctx, deployMgrJndiName);
log.debug("Unbound DeploymentManager proxy");
}
+ //
+ if(createEjb3Links)
+ {
+ Util.unbind(ctx, "SecureProfileService/remote");
+ Util.unbind(ctx, "SecureManagementView/remote");
+ Util.unbind(ctx, "SecureDeploymentManager/remote");
+ log.debug("Unbound links back to secure ejb names");
+ }
}
}
Added: trunk/profileservice/src/main/org/jboss/profileservice/remoting/SecurityContainer.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/SecurityContainer.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/SecurityContainer.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.remoting;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * A poji proxy invocation handler that implements a simple security
+ * container using aop interceptors.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SecurityContainer implements InvocationHandler
+{
+ private static ThreadLocal<Invocation> activeInvocation
+ = new ThreadLocal<Invocation>();
+ private List<Interceptor> interceptors;
+ private Object target;
+
+ SecurityContainer(List<Interceptor> interceptors, Object target)
+ {
+ this.interceptors = interceptors;
+ this.target = target;
+ }
+
+ public static void setInvocation(Invocation inv)
+ {
+ activeInvocation.set(inv);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ // Get the invocation the handler set
+ Invocation inv = activeInvocation.get();
+ if(inv instanceof MethodInvocation)
+ {
+ // Need to set the target since this is not a true aop proxy
+ MethodInvocation mi = (MethodInvocation) inv;
+ mi.setTargetObject(target);
+ // Override the method to the poji proxy method to return the invocation method
+ inv = new PojiMethodInvocation(mi, method);
+ }
+
+ // run through the interceptors
+ for(Interceptor i : interceptors)
+ {
+ i.invoke(inv);
+ }
+
+ // Perform the invocation on the target
+ try
+ {
+ return method.invoke(target, args);
+ }
+ catch(InvocationTargetException ite)
+ {
+ throw ite.getTargetException();
+ }
+ }
+
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -23,10 +23,14 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.annotation.ViewUse;
+
/**
* @author Scott.Stark at jboss.org
* @version $Revision$
@@ -101,4 +105,5 @@
public String getFactoryName();
public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer);
public String getDefaultViewUse();
+ public Map<String, String> getPropertyMetaMappings();
}
Modified: trunk/profileservice/src/resources/hdscanner-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/hdscanner-jboss-beans.xml 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/resources/hdscanner-jboss-beans.xml 2009-09-17 12:25:56 UTC (rev 93641)
@@ -15,19 +15,19 @@
<property name="scanThreadName">HDScanner</property>
</bean>
- <bean name="ToolsDeploymentScanner" class="org.jboss.system.tools.DeploymentScanner">
- <constructor>
- <parameter><inject bean="ProfileServiceDeploymentRepositoryAdapter"/></parameter>
- </constructor>
- <property name="serverConfig"><inject bean="JBossServer" property="configuration"/></property>
- </bean>
+ <bean name="ToolsDeploymentScanner" class="org.jboss.system.tools.DeploymentScanner">
+ <constructor>
+ <parameter><inject bean="ProfileServiceDeploymentRepositoryAdapter"/></parameter>
+ </constructor>
+ <property name="serverConfig"><inject bean="JBossServer" property="configuration"/></property>
+ </bean>
- <bean name="ProfileServiceDeploymentRepositoryAdapter" class="org.jboss.system.tools.ProfileServiceDeploymentRepositoryAdapter">
- <constructor>
- <parameter><inject bean="HDScanner"/></parameter>
- <parameter><inject bean="ProfileService"/></parameter>
- <parameter><inject bean="StructureModificationChecker"/></parameter>
- </constructor>
- </bean>
+ <bean name="ProfileServiceDeploymentRepositoryAdapter" class="org.jboss.system.tools.ProfileServiceDeploymentRepositoryAdapter">
+ <constructor>
+ <parameter><inject bean="HDScanner"/></parameter>
+ <parameter><inject bean="ProfileService"/></parameter>
+ <parameter><inject bean="StructureModificationChecker"/></parameter>
+ </constructor>
+ </bean>
</deployment>
Modified: trunk/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-jboss-beans.xml 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/profileservice/src/resources/profileservice-jboss-beans.xml 2009-09-17 12:25:56 UTC (rev 93641)
@@ -44,7 +44,7 @@
</uninstall>
<property name="managementViewProxy"><inject bean="ProfileServiceProxyFactory" property="managementViewProxy"/></property>
<property name="deployMgrProxy"><inject bean="ProfileServiceProxyFactory" property="deployMgrProxy"/></property>
- <property name="securityDomain">profileservice</property>
+ <property name="securityDomain">jmx-console</property>
<property name="securityManagement"><inject bean="JNDIBasedSecurityManagement"/></property>
</bean>
@@ -63,6 +63,8 @@
<property name="deployer"><inject bean="ProfileServiceDeployer"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+ <property name="securityDomain">jmx-console</property>
+ <property name="securityManagement"><inject bean="JNDIBasedSecurityManagement"/></property>
<depends>TransientDeploymentsProfileManager</depends>
</bean>
@@ -161,10 +163,41 @@
<bean name="ProfileServiceProxyFactory" class="org.jboss.profileservice.remoting.ProxyFactory">
<property name="dispatchName">ProfileService</property>
<property name="jndiName">ProfileService</property>
+ <property name="mgtViewJndiName">ManagementView</property>
+ <property name="deployMgrJndiName">DeploymentManager</property>
<property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
<property name="profileService"><inject bean="ProfileService"/></property>
<property name="viewManager"><inject bean="ManagementView"/></property>
<property name="deploymentManager"><inject bean="DeploymentManager"/></property>
+ <!-- Create links from secured proxies back to old secured ejb3 facades -->
+ <property name="createEjb3Links">true</property>
+ <!-- Server side security interceptor stack -->
+ <property name="serverProxyInterceptors">
+ <list>
+ <!-- uncomment to enable auth checks for the profileservice
+ <bean class="org.jboss.aspects.security.AuthenticationInterceptor">
+ <constructor>
+ <parameter>
+ <value-factory bean="JNDIBasedSecurityManagement" method="getAuthenticationManager"
+ parameter="jmx-console"/>
+ </parameter>
+ </constructor>
+ </bean>
+ <bean class="org.jboss.aspects.security.RoleBasedAuthorizationInterceptor">
+ <constructor>
+ <parameter>
+ <value-factory bean="JNDIBasedSecurityManagement" method="getAuthenticationManager"
+ parameter="jmx-console"/>
+ </parameter>
+ <parameter>
+ <value-factory bean="JNDIBasedSecurityManagement" method="getAuthenticationManager"
+ parameter="jmx-console"/>
+ </parameter>
+ </constructor>
+ </bean>
+ -->
+ </list>
+ </property>
<depends>ConnectorMBean</depends>
</bean>
<bean name="PlatformMBeanKernelRegistryPlugin" class="org.jboss.profileservice.management.PlatformMBeanKernelRegistryPlugin">
@@ -197,6 +230,10 @@
class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
<property name="keyName">name</property>
</bean>
+ <bean name="JNDINameKeyMBeanDeploymentNameBuilder"
+ class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
+ <property name="keyName">jndiName</property>
+ </bean>
<bean name="HostMBeanDeploymentNameBuilder"
class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
<property name="keyName">host</property>
@@ -302,4 +339,36 @@
</set>
</property>
</bean>
+ <bean name="EJBMetricsManagedDeploymentFactory"
+ class="org.jboss.profileservice.management.ProxyManagedDeploymentFactory">
+ <property name="factoryName">EJBMetrics</property>
+ <property name="defaultViewUse">STATISTIC</property>
+ <property name="propertyMetaMappings">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>DetypedInvocationStatistics</key>
+ <value>org.jboss.profileservice.management.mbean.EJBInvocationStatsMapper</value>
+ </entry>
+ </map>
+ </property>
+ <property name="rootMOPatterns">
+ <set elementClass="org.jboss.profileservice.management.ProxyDeploymentInfo">
+ <!-- Manager -->
+ <bean class="org.jboss.profileservice.management.ProxyDeploymentInfo">
+ <property name="compType">EJB</property>
+ <property name="compSubtype">Unknown</property>
+ <property name="subtypeAttribute">BeanTypeName</property>
+ <property name="pattern">jboss.j2ee:service=EJB,*</property>
+ <property name="excludedKeys">
+ <set elementClass="java.lang.String">
+ <value>plugin</value>
+ </set>
+ </property>
+ <property name="nameBuilder">
+ <inject bean="JNDINameKeyMBeanDeploymentNameBuilder"/>
+ </property>
+ </bean>
+ </set>
+ </property>
+ </bean>
</deployment>
Added: trunk/profileservice/src/resources/profileservice-roles.properties
===================================================================
--- trunk/profileservice/src/resources/profileservice-roles.properties (rev 0)
+++ trunk/profileservice/src/resources/profileservice-roles.properties 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,2 @@
+jduke=User
+javaduke=Administrator
\ No newline at end of file
Added: trunk/profileservice/src/resources/profileservice-users.properties
===================================================================
--- trunk/profileservice/src/resources/profileservice-users.properties (rev 0)
+++ trunk/profileservice/src/resources/profileservice-users.properties 2009-09-17 12:25:56 UTC (rev 93641)
@@ -0,0 +1,2 @@
+jduke=theduke
+javaduke=anotherduke
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -49,7 +49,7 @@
namespace= "urn:jboss:profileservice:profiles:1.0",
elementFormDefault=XmlNsForm.QUALIFIED,
normalizeSpace=true)
- at XmlType(name = "profilesType"/*, propOrder = {"name", "server", "domain", "profiles"}*/)
+ at XmlType(name = "profilesType", propOrder = {"name", "server", "domain", "profiles"})
public class ProfilesMetaData implements ProfileKeyMetaData
{
/** The name. */
@@ -112,18 +112,5 @@
this.profiles = profiles;
}
- public String toString()
- {
- StringBuffer tmp = new StringBuffer("ProfilesMetaData(name=");
- tmp.append(name);
- tmp.append(", server=");
- tmp.append(server);
- tmp.append(", domain=");
- tmp.append(domain);
- tmp.append(", profiles: ");
- tmp.append(profiles);
- tmp.append(")");
- return tmp.toString();
- }
}
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -51,7 +51,17 @@
{
return Object.class.getName();
}
+
+ protected DefaultPersistenceDelegate getPersistenceDelegate()
+ {
+ return persistenceDelegate;
+ }
+ protected DefaultRecreationDelegate getRecreationDelegate()
+ {
+ return recreationDelegate;
+ }
+
public AbstractValuePersistence getValuePersistence()
{
return persistenceDelegate.getValuePersistence();
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -25,6 +25,11 @@
import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
/**
+ * The ComponentMapper maps a ManagedComponent to it's parent ManagedObject
+ * attachment. This is used to identify the ManagedComponents in their
+ * deployment descriptor, create the persistence information and
+ * restore them again.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -56,6 +56,8 @@
*/
public class AbstractProfileService implements ProfileService, ControllerContextActions
{
+ /** The RuntimePermission required for accessing PS methods */
+ private static RuntimePermission PS_RUNTIME_PERMISSION = new RuntimePermission(ProfileService.class.getName());
/** The default profile. */
private ProfileKey defaultProfile;
@@ -117,6 +119,10 @@
public DeploymentManager getDeploymentManager()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
return this.deploymentManager;
}
@@ -127,6 +133,10 @@
public ManagementView getViewManager()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
return this.managementView;
}
@@ -137,6 +147,10 @@
public String[] getDomains()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
// TODO do we need that ?
Collection<String> domains = new ArrayList<String>();
for(ProfileKey key : activeProfiles)
@@ -153,6 +167,10 @@
public Collection<ProfileKey> getProfileKeys()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
return Collections.unmodifiableCollection(this.profiles);
}
@@ -165,6 +183,10 @@
*/
public Profile getProfile(ProfileKey key) throws NoSuchProfileException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(key == null)
throw new IllegalArgumentException("Null profile key.");
@@ -185,6 +207,10 @@
public Collection<ProfileKey> getActiveProfileKeys()
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
return Collections.unmodifiableCollection(this.activeProfiles);
}
@@ -197,6 +223,10 @@
*/
public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(key == null)
throw new IllegalArgumentException("Null profile key.");
@@ -252,6 +282,10 @@
*/
public void registerProfile(Profile profile) throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(profile == null)
throw new IllegalArgumentException("Null profile.");
@@ -289,6 +323,10 @@
*/
public void activateProfile(ProfileKey key) throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(key == null)
throw new IllegalArgumentException("Null profile key.");
if(controller.isShutdown())
@@ -313,6 +351,10 @@
public void validateProfile(ProfileKey key) throws Exception
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(key == null)
throw new IllegalArgumentException("Null profile key.");
@@ -384,6 +426,10 @@
*/
public void deactivateProfile(ProfileKey key) throws NoSuchProfileException
{
+ SecurityManager sm = System.getSecurityManager();
+ if(sm != null)
+ sm.checkPermission(PS_RUNTIME_PERMISSION);
+
if(key == null)
throw new IllegalArgumentException("Null profile key.");
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-09-17 12:23:31 UTC (rev 93640)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-09-17 12:25:56 UTC (rev 93641)
@@ -278,8 +278,8 @@
if(deleteFile && root != null)
{
- // Delete the file
- if(root.delete() == false)
+ // Delete the file, fail if it can't be deleted and still exists
+ if(root.delete() == false && root.exists())
throw new IOException("Failed to delete: " + root);
cleanUpRoot(root);
More information about the jboss-cvs-commits
mailing list