Revision: a35f5ff86647
Author: josemrecio <[email protected]>
Date: Sun Jul 29 18:41:35 2012
Log: Add sip application name to mgmt objects path (web subsystem uses
virtual-host/context-root/...)
Clear definition of which deployment unit will have attached the sip context
http://code.google.com/p/sipservlets/source/detail?r=a35f5ff86647
Modified:
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentDefinition.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentServletDefinition.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SIPWebContext.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipDeploymentService.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipWarDeploymentProcessor.java
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/resources/org/mobicents/as7/LocalDescriptions.properties
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentDefinition.java
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentDefinition.java
Sun Jul 29 18:41:35 2012
@@ -10,11 +10,14 @@
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
@@ -30,6 +33,8 @@
public class SipDeploymentDefinition extends SimpleResourceDefinition {
public static final SipDeploymentDefinition INSTANCE = new
SipDeploymentDefinition();
+ public static final AttributeDefinition APP_NAME = new
SimpleAttributeDefinitionBuilder("app-name",
ModelType.STRING).setStorageRuntime().build();
+
private SipDeploymentDefinition() {
super(PathElement.pathElement(SUBSYSTEM,
SipExtension.SUBSYSTEM_NAME),
SipExtension.getResourceDescriptionResolver("deployment"));
@@ -38,6 +43,7 @@
@Override
public void registerAttributes(ManagementResourceRegistration
resourceRegistration) {
+ resourceRegistration.registerReadOnlyAttribute(APP_NAME, null);
for (SessionStat stat : SessionStat.values()) {
resourceRegistration.registerMetric(stat.definition,
SessionManagerStatsHandler.getInstance());
}
@@ -57,7 +63,14 @@
@Override
protected void executeRuntimeStep(OperationContext context,
ModelNode operation) throws OperationFailedException {
- final ServiceController<?> controller =
context.getServiceRegistry(false).getService(SipSubsystemServices.deploymentServiceName());
+ final PathAddress address =
PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
+
+ final Resource sip =
context.readResourceFromRoot(address.subAddress(0, address.size()), false);
+ final ModelNode subModel = sip.getModel();
+
+ final String appName = APP_NAME.resolveModelAttribute(context,
subModel).asString();
+
+ final ServiceController<?> controller =
context.getServiceRegistry(false).getService(SipSubsystemServices.deploymentServiceName(appName));
SessionStat stat =
SessionStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString());
if (stat == null) {
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentServletDefinition.java
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentServletDefinition.java
Sun Jul 29 18:41:35 2012
@@ -13,6 +13,7 @@
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
@@ -79,10 +80,15 @@
public void execute(final OperationContext context, final
ModelNode operation) throws OperationFailedException {
final PathAddress address =
PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
+ final Resource sip =
context.readResourceFromRoot(address.subAddress(0, address.size() - 1),
false);
+ final ModelNode subModel = sip.getModel();
+
+ final String appName = subModel.require("app-name").asString();
+
context.addStep(new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final
ModelNode operation) throws OperationFailedException {
- final ServiceController<?> controller =
context.getServiceRegistry(false).getService(SipSubsystemServices.deploymentServiceName());
+ final ServiceController<?> controller =
context.getServiceRegistry(false).getService(SipSubsystemServices.deploymentServiceName(appName));
if (controller != null) {
final String name =
address.getLastElement().getValue();
final Context webContext =
Context.class.cast(controller.getValue());
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java
Sun Jul 29 18:41:35 2012
@@ -22,8 +22,8 @@
/** The base name for jboss.sip deployments. */
static final ServiceName JBOSS_SIP_DEPLOYMENT_BASE =
JBOSS_SIP.append("deployment");
- public static ServiceName deploymentServiceName() {
- return JBOSS_SIP_DEPLOYMENT_BASE.append("/");
+ public static ServiceName deploymentServiceName(final String appName) {
+ return JBOSS_SIP_DEPLOYMENT_BASE.append("".equals(appName) ? "/" :
appName);
}
private SipSubsystemServices() {
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SIPWebContext.java
Tue Mar 27 08:02:55 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SIPWebContext.java
Sun Jul 29 18:41:35 2012
@@ -68,16 +68,28 @@
super();
deploymentUnit = du;
sipJBossContextConfig = createContextConfig(this, deploymentUnit);
- // if this an ear deployment, attach this to the parent
deploymentUnit so it can be used to inject context resources (SipFactory,
etc.)
- DeploymentUnit parentDu = deploymentUnit.getParent();
- if (parentDu == null) {
- // this is a war only deployment
- return;
- }
- if (DeploymentTypeMarker.isType(DeploymentType.EAR, parentDu)) {
- if (logger.isDebugEnabled()) logger.debug("Attaching
SIPWebContext " + this + " to " + parentDu.getName());
- parentDu.putAttachment(SIPWebContext.ATTACHMENT, this);
- }
+ // attach context to top-level deploymentUnit so it can be used to
get context resources (SipFactory, etc.)
+ final DeploymentUnit anchorDu = getSipContextAnchorDu(du);
+ if (anchorDu != null) {
+ if (logger.isDebugEnabled()) logger.debug("Attaching
SIPWebContext " + this + " to " + anchorDu.getName());
+ anchorDu.putAttachment(SIPWebContext.ATTACHMENT, this);
+ }
+ else {
+ logger.error("Can't attach SIPWebContext " + this + " to " +
deploymentUnit.getName() + " - This is probably a bug");
+ }
+// DeploymentUnit parentDu = deploymentUnit.getParent();
+// if (parentDu == null) {
+// // this is a war only deployment
+// if (logger.isDebugEnabled()) logger.debug("Attaching
SIPWebContext " + this + " to " + deploymentUnit.getName());
+// deploymentUnit.putAttachment(SIPWebContext.ATTACHMENT, this);
+// }
+// else if (DeploymentTypeMarker.isType(DeploymentType.EAR,
parentDu)) {
+// if (logger.isDebugEnabled()) logger.debug("Attaching
SIPWebContext " + this + " to " + parentDu.getName());
+// parentDu.putAttachment(SIPWebContext.ATTACHMENT, this);
+// }
+// else {
+// logger.error("Cowardly refusing to attach SIPWebContext " +
this + " to " + deploymentUnit.getName() + " - This is probably a bug");
+// }
}
public void postProcessContext(DeploymentUnit deploymentUnit) {
@@ -266,5 +278,22 @@
sipContext.addLifecycleListener(config);
return config;
}
+
+ // returns the anchor deployment unit that will have attached a
SIPWebContext
+ public static DeploymentUnit getSipContextAnchorDu(final
DeploymentUnit du) {
+ // attach context to top-level deploymentUnit so it can be used to
get context resources (SipFactory, etc.)
+ DeploymentUnit parentDu = du.getParent();
+ if (parentDu == null) {
+ // this is a war only deployment
+ return du;
+ }
+ else if (DeploymentTypeMarker.isType(DeploymentType.EAR,
parentDu)) {
+ return parentDu;
+ }
+ else {
+ logger.error("Can't find proper anchor deployment unit for " +
du.getName() + " - This is probably a bug");
+ return null;
+ }
+ }
}
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipDeploymentService.java
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipDeploymentService.java
Sun Jul 29 18:41:35 2012
@@ -39,10 +39,10 @@
class SipDeploymentService implements Service<Context> {
private StandardContext sipContext;
- private final DeploymentUnit du;
+ private final DeploymentUnit anchorDu;
public SipDeploymentService(final DeploymentUnit du) {
- this.du = du;
+ this.anchorDu =SIPWebContext.getSipContextAnchorDu(du);
}
/**
@@ -50,7 +50,7 @@
*/
public synchronized void start(StartContext startContext) throws
StartException {
if (sipContext == null) {
- this.sipContext = du.getAttachment(SIPWebContext.ATTACHMENT);
+ this.sipContext =
anchorDu.getAttachment(SIPWebContext.ATTACHMENT);
}
}
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipWarDeploymentProcessor.java
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipWarDeploymentProcessor.java
Sun Jul 29 18:41:35 2012
@@ -40,6 +40,7 @@
import org.jboss.msc.service.ServiceRegistryException;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.vfs.VirtualFile;
+import org.mobicents.as7.SipDeploymentDefinition;
import org.mobicents.as7.SipSubsystemServices;
import org.mobicents.metadata.sip.spec.SipMetaData;
@@ -83,7 +84,8 @@
throw new
DeploymentUnitProcessingException(MESSAGES.failedToResolveModule(deploymentRoot));
}
final SipMetaData sipMetaData =
deploymentUnit.getAttachment(SipMetaData.ATTACHMENT_KEY);
- final ServiceName deploymentServiceName =
SipSubsystemServices.deploymentServiceName();
+ final String appNameMgmt = sipMetaData.getApplicationName();
+ final ServiceName deploymentServiceName =
SipSubsystemServices.deploymentServiceName(appNameMgmt);
try {
final SipDeploymentService sipDeploymentService = new
SipDeploymentService(deploymentUnit);
ServiceBuilder<?> builder = serviceTarget
@@ -109,6 +111,9 @@
throw new
DeploymentUnitProcessingException(MESSAGES.failedToAddSipDeployment(), e);
}
+ // Process sip related mgmt information
+ final ModelNode node =
deploymentUnit.getDeploymentSubsystemModel("sip");
+
node.get(SipDeploymentDefinition.APP_NAME.getName()).set("".equals(appNameMgmt) ? "/" :
appNameMgmt);
processManagement(deploymentUnit, sipMetaData);
}
=======================================
---
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/resources/org/mobicents/as7/LocalDescriptions.properties
Tue Jul 24 13:43:32 2012
+++
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/resources/org/mobicents/as7/LocalDescriptions.properties
Sun Jul 29 18:41:35 2012
@@ -36,6 +36,7 @@
sip.connector.requestCount=Number of the request processed by the
connector.
sip.deployment=Runtime resources exposed by sip components in the
deployment.
+sip.deployment.app-name=The root of the sip application deployment
sip.servlet=Runtime resources exposed by web components in the deployment.
sip.deployment.servlet=Runtime information about the servlets in the
deployment.
sip.deployment.servlet.load-time=Load time