3 new revisions:

Revision: db0705253daa
Author:   josemrecio <[email protected]>
Date:     Tue Jul 24 13:43:32 2012
Log:      Backport to Telscale branch...
http://code.google.com/p/sipservlets/source/detail?r=db0705253daa

Revision: 6f24e35a34d0
Author:   josemrecio <[email protected]>
Date:     Sun Jul 29 18:41:35 2012
Log:      Update Issue 136...
http://code.google.com/p/sipservlets/source/detail?r=6f24e35a34d0

Revision: c5244ca5a048
Author:   Jean Deruelle <[email protected]>
Date:     Wed Aug  1 05:56:21 2012
Log:      Update Issue 136...
http://code.google.com/p/sipservlets/source/detail?r=c5244ca5a048

==============================================================================
Revision: db0705253daa
Author:   josemrecio <[email protected]>
Date:     Tue Jul 24 13:43:32 2012
Log:      Backport to Telscale branch

Still missed: support for servlet statistics (StandardWrapperValve methods are not being invoked) and connector stats.
(cherry picked from commit b100126cff44bd5c57c8fc206d8517de3d0ca960)

Conflicts:

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/SipMessages.java containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemAdd.java containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/resources/org/mobicents/as7/LocalDescriptions.properties

http://code.google.com/p/sipservlets/source/detail?r=db0705253daa

Added:
/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/SipMessages.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
Modified:
/containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemAdd.java /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java

=======================================
--- /dev/null
+++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipDeploymentDefinition.java Tue Jul 24 13:43:32 2012
@@ -0,0 +1,175 @@
+package org.mobicents.as7;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
+import org.jboss.as.controller.AttributeDefinition;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.jboss.msc.service.ServiceController;
+import org.mobicents.as7.deployment.SIPWebContext;
+import org.mobicents.servlet.sip.core.SipManager;
+
+/**
+ * @author Tomaz Cerar
+ * @author <a href="mailto:[email protected]";>Torben Jaeger</a>
+ * @created 23.2.12 18:32
+ * @author [email protected]
+ */
+public class SipDeploymentDefinition extends SimpleResourceDefinition {
+ public static final SipDeploymentDefinition INSTANCE = new SipDeploymentDefinition();
+
+    private SipDeploymentDefinition() {
+ super(PathElement.pathElement(SUBSYSTEM, SipExtension.SUBSYSTEM_NAME),
+              SipExtension.getResourceDescriptionResolver("deployment"));
+    }
+
+
+    @Override
+ public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
+        for (SessionStat stat : SessionStat.values()) {
+ resourceRegistration.registerMetric(stat.definition, SessionManagerStatsHandler.getInstance());
+        }
+    }
+
+ static class SessionManagerStatsHandler extends AbstractRuntimeOnlyHandler {
+
+ static SessionManagerStatsHandler INSTANCE = new SessionManagerStatsHandler();
+
+        private SessionManagerStatsHandler() {
+        }
+
+        public static SessionManagerStatsHandler getInstance() {
+            return INSTANCE;
+        }
+
+        @Override
+ protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
+
+ final ServiceController<?> controller = context.getServiceRegistry(false).getService(SipSubsystemServices.deploymentServiceName()); + SessionStat stat = SessionStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString());
+
+               if (stat == null) {
+ context.getFailureDescription().set(SipMessages.MESSAGES.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString()));
+            } else {
+ final SIPWebContext sipContext = SIPWebContext.class.cast(controller.getValue());
+                SipManager sm = (SipManager) sipContext.getManager();
+                ModelNode result = new ModelNode();
+                switch (stat) {
+                    case ACTIVE_SIP_SESSIONS:
+//                     // TODO: what about other manager implementations?
+// if (sm.getDistributable() && (sm instanceof DistributableSessionManager)) { +// result.set(((DistributableSessionManager)sm).getActiveSessionCount());
+//                     }
+                       result.set(sm.getActiveSipSessions());
+                        break;
+                    case ACTIVE_SIP_APP_SESSIONS:
+//                     // TODO: what about other manager implementations?
+// if (sm.getDistributable() && (sm instanceof DistributableSessionManager)) { +// result.set(((DistributableSessionManager)sm).getActiveSessionCount());
+//                     }
+                       result.set(sm.getActiveSipApplicationSessions());
+                        break;
+                    case EXPIRED_SIP_SESSIONS:
+                        result.set(sm.getExpiredSipSessions());
+                        break;
+                    case EXPIRED_SIP_APP_SESSIONS:
+                        result.set(sm.getExpiredSipApplicationSessions());
+                        break;
+                    case MAX_ACTIVE_SIP_SESSIONS:
+                        result.set(sm.getMaxActiveSipSessions());
+                        break;
+                    case SIP_SESSIONS_CREATED:
+                        result.set(sm.getSipSessionCounter());
+                        break;
+                    case SIP_APP_SESSIONS_CREATED:
+                        result.set(sm.getSipApplicationSessionCounter());
+                        break;
+                    case SIP_SESSIONS_CREATION_RATE:
+ result.set(sm.getNumberOfSipSessionCreationPerSecond());
+                        break;
+                    case SIP_APP_SESSIONS_CREATION_RATE:
+ result.set(sm.getNumberOfSipApplicationSessionCreationPerSecond());
+                        break;
+                    case SIP_SESSION_AVG_ALIVE_TIME:
+                        result.set(sm.getSipSessionAverageAliveTime());
+                        break;
+                    case SIP_APP_SESSION_AVG_ALIVE_TIME:
+ result.set(sm.getSipApplicationSessionAverageAliveTime());
+                        break;
+                    case SIP_SESSION_MAX_ALIVE_TIME:
+                        result.set(sm.getSipSessionMaxAliveTime());
+                        break;
+                    case SIP_APP_SESSION_MAX_ALIVE_TIME:
+ result.set(sm.getSipApplicationSessionMaxAliveTime());
+                        break;
+                    case REJECTED_SIP_SESSIONS:
+                        result.set(sm.getRejectedSipSessions());
+                        break;
+                    case REJECTED_SIP_APP_SESSIONS:
+                        result.set(sm.getRejectedSipSessions());
+                        break;
+                    default:
+ throw new IllegalStateException(SipMessages.MESSAGES.unknownMetric(stat));
+                }
+                context.getResult().set(result);
+            }
+
+            context.completeStep();
+        }
+
+    }
+
+    public enum SessionStat {
+ ACTIVE_SIP_SESSIONS(new SimpleAttributeDefinition("active-sip-sessions", ModelType.INT, false)), + ACTIVE_SIP_APP_SESSIONS(new SimpleAttributeDefinition("active-sip-application-sessions", ModelType.INT, false)), + EXPIRED_SIP_SESSIONS(new SimpleAttributeDefinition("expired-sip-sessions", ModelType.INT, false)), + EXPIRED_SIP_APP_SESSIONS(new SimpleAttributeDefinition("expired-sip-application-sessions", ModelType.INT, false)), + SIP_SESSIONS_CREATED(new SimpleAttributeDefinition("sip-sessions-created", ModelType.INT, false)), + SIP_APP_SESSIONS_CREATED(new SimpleAttributeDefinition("sip-application-sessions-created", ModelType.INT, false)), + SIP_SESSIONS_CREATION_RATE(new SimpleAttributeDefinition("sip-sessions-per-sec", ModelType.INT, false)), + SIP_APP_SESSIONS_CREATION_RATE(new SimpleAttributeDefinition("sip-application-sessions-per-sec", ModelType.INT, false)), + SIP_SESSION_AVG_ALIVE_TIME(new SimpleAttributeDefinition("sip-session-avg-alive-time", ModelType.INT, false)), + SIP_APP_SESSION_AVG_ALIVE_TIME(new SimpleAttributeDefinition("sip-application-session-avg-alive-time", ModelType.INT, false)), + SIP_SESSION_MAX_ALIVE_TIME(new SimpleAttributeDefinition("sip-session-max-alive-time", ModelType.INT, false)), + SIP_APP_SESSION_MAX_ALIVE_TIME(new SimpleAttributeDefinition("sip-application-session-max-alive-time", ModelType.INT, false)), + REJECTED_SIP_SESSIONS(new SimpleAttributeDefinition("rejected-sip-sessions", ModelType.INT, false)), + REJECTED_SIP_APP_SESSIONS(new SimpleAttributeDefinition("rejected-sip-application-sessions", ModelType.INT, false)), + MAX_ACTIVE_SIP_SESSIONS(new SimpleAttributeDefinition("max-active-sip-sessions", ModelType.INT, false));
+
+ private static final Map<String, SessionStat> MAP = new HashMap<String, SessionStat>();
+
+        static {
+            for (SessionStat stat : EnumSet.allOf(SessionStat.class)) {
+                MAP.put(stat.toString(), stat);
+            }
+        }
+
+        final AttributeDefinition definition;
+
+        private SessionStat(final AttributeDefinition definition) {
+            this.definition = definition;
+        }
+
+        @Override
+        public final String toString() {
+            return definition.getName();
+        }
+
+ public static synchronized SessionStat getStat(final String stringForm) {
+            return MAP.get(stringForm);
+        }
+    }
+
+}
=======================================
--- /dev/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
@@ -0,0 +1,101 @@
+package org.mobicents.as7;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.core.StandardWrapper;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+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.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.jboss.msc.service.ServiceController;
+
+/**
+ * @author Tomaz Cerar
+ * @created 23.2.12 18:35
+ * @author [email protected]
+ */
+public class SipDeploymentServletDefinition extends SimpleResourceDefinition { + public static final SipDeploymentServletDefinition INSTANCE = new SipDeploymentServletDefinition();
+
+ protected static final SimpleAttributeDefinition LOAD_TIME = new SimpleAttributeDefinitionBuilder(Constants.LOAD_TIME, ModelType.LONG, true).build(); + protected static final SimpleAttributeDefinition MAX_TIME = new SimpleAttributeDefinitionBuilder(Constants.MAX_TIME, ModelType.LONG, true).build(); + protected static final SimpleAttributeDefinition MIN_TIME = new SimpleAttributeDefinitionBuilder(Constants.MIN_TIME, ModelType.LONG, true).build(); + protected static final SimpleAttributeDefinition PROCESSING_TIME = new SimpleAttributeDefinitionBuilder(Constants.PROCESSING_TIME, ModelType.LONG, true).build(); + protected static final SimpleAttributeDefinition REQUEST_COUNT = new SimpleAttributeDefinitionBuilder(Constants.REQUEST_COUNT, ModelType.INT, true).build();
+
+
+    private SipDeploymentServletDefinition() {
+        super(PathElement.pathElement("servlet"),
+ SipExtension.getResourceDescriptionResolver("deployment.servlet"));
+    }
+
+    @Override
+ public void registerAttributes(ManagementResourceRegistration registration) { + registration.registerMetric(LOAD_TIME, new AbstractMetricsHandler() {
+            @Override
+ void handle(final ModelNode response, final String name, final StandardWrapper wrapper) {
+                response.set(wrapper.getLoadTime());
+            }
+        });
+ registration.registerMetric(MAX_TIME, new AbstractMetricsHandler() {
+            @Override
+ void handle(final ModelNode response, final String name, final StandardWrapper wrapper) {
+                response.set(wrapper.getMinTime());
+            }
+        });
+ registration.registerMetric(MIN_TIME, new AbstractMetricsHandler() {
+            @Override
+ void handle(final ModelNode response, final String name, final StandardWrapper wrapper) {
+                response.set(wrapper.getLoadTime());
+            }
+        });
+ registration.registerMetric(PROCESSING_TIME, new AbstractMetricsHandler() {
+            @Override
+ void handle(final ModelNode response, final String name, final StandardWrapper wrapper) {
+                response.set(wrapper.getProcessingTime());
+            }
+        });
+ registration.registerMetric(REQUEST_COUNT, new AbstractMetricsHandler() {
+            @Override
+ void handle(final ModelNode response, final String name, final StandardWrapper wrapper) {
+                response.set(wrapper.getRequestCount());
+            }
+        });
+    }
+
+ abstract static class AbstractMetricsHandler implements OperationStepHandler {
+
+ abstract void handle(ModelNode response, String name, StandardWrapper wrapper);
+
+        @Override
+ public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { + final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
+
+            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());
+                    if (controller != null) {
+ final String name = address.getLastElement().getValue(); + final Context webContext = Context.class.cast(controller.getValue()); + final Wrapper wrapper = Wrapper.class.cast(webContext.findChild(name));
+                        final ModelNode response = new ModelNode();
+                        handle(response, name, (StandardWrapper) wrapper);
+                        context.getResult().set(response);
+                    }
+                    context.completeStep();
+                }
+            }, OperationContext.Stage.RUNTIME);
+            context.completeStep();
+        }
+    }
+
+}
=======================================
--- /dev/null
+++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipMessages.java Tue Jul 24 13:43:32 2012
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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.mobicents.as7;
+
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageBundle;
+import org.jboss.logging.Messages;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Date: 05.11.2011
+ *
+ * @author <a href="mailto:[email protected]";>James R. Perkins</a>
+ */
+@MessageBundle(projectCode = "MSS")
+public interface SipMessages {
+
+    /**
+     * The messages
+     */
+    SipMessages MESSAGES = Messages.getBundle(SipMessages.class);
+
+    @Message(id = 18002, value = "Failed to get metrics %s")
+    String failedToGetMetrics(String reason);
+
+    @Message(id = 18003, value = "No metrics available")
+    String noMetricsAvailable();
+
+    @Message(id = 18007, value = "Error starting web connector")
+    String connectorStartError();
+
+    @Message(id = 18008, value = "Null service value")
+    IllegalStateException nullValue();
+
+    @Message(id = 18009, value = "Error starting sip container")
+    String errorStartingSip();
+
+ @Message(id = 18026, value = "Failed to resolve module for deployment %s")
+    String failedToResolveModule(VirtualFile deploymentRoot);
+
+ @Message(id = 18027, value = "Failed to add Mobicents SIP deployment service")
+    String failedToAddSipDeployment();
+
+    /**
+     * A message indicating the metric is unknown.
+     *
+     * @param metric the unknown metric.
+     *
+     * @return the message.
+     */
+    @Message(id = 18098, value = "Unknown metric %s")
+    String unknownMetric(Object metric);
+
+}
=======================================
--- /dev/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
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Inc., and individual contributors as indicated
+ * 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.mobicents.as7.deployment;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.core.StandardContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+
+/**
+ * A service starting a sip deployment.
+ * For sip, this is required so far only as a way to provide the context to management methods
+ *
+ * @author Emanuel Muckenhuber
+ * @author [email protected]
+ */
+class SipDeploymentService implements Service<Context> {
+
+    private StandardContext sipContext;
+    private final DeploymentUnit du;
+
+    public SipDeploymentService(final DeploymentUnit du) {
+        this.du = du;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+ public synchronized void start(StartContext startContext) throws StartException {
+        if (sipContext == null) {
+               this.sipContext = du.getAttachment(SIPWebContext.ATTACHMENT);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized void stop(StopContext stopContext) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized Context getValue() throws IllegalStateException {
+        final Context sipContext = this.sipContext;
+        if (sipContext == null) {
+            throw new IllegalStateException();
+        }
+        return sipContext;
+    }
+
+}
=======================================
--- /dev/null
+++ /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
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., 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.mobicents.as7.deployment;
+
+import static org.mobicents.as7.SipMessages.MESSAGES;
+
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.server.deployment.Attachments;
+import org.jboss.as.server.deployment.DeploymentPhaseContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
+import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.as.web.deployment.WarMetaData;
+import org.jboss.dmr.ModelNode;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.modules.Module;
+import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.ServiceController.Mode;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.ServiceRegistryException;
+import org.jboss.msc.service.ServiceTarget;
+import org.jboss.vfs.VirtualFile;
+import org.mobicents.as7.SipSubsystemServices;
+import org.mobicents.metadata.sip.spec.SipMetaData;
+
+
+/**
+ * {@code DeploymentUnitProcessor} creating the actual deployment services.
+ * For SIP this is only required to setup management points
+ *
+ * @author Emanuel Muckenhuber
+ * @author [email protected]
+ * @author [email protected]
+ */
+public class SipWarDeploymentProcessor implements DeploymentUnitProcessor {
+
+    public SipWarDeploymentProcessor() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { + final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); + final WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
+        if (metaData == null) {
+            return;
+        }
+        processDeployment(deploymentUnit, phaseContext.getServiceTarget());
+    }
+
+    @Override
+    public void undeploy(final DeploymentUnit context) {
+       // TODO
+    }
+
+    protected void processDeployment(final DeploymentUnit deploymentUnit,
+ final ServiceTarget serviceTarget) throws DeploymentUnitProcessingException { + final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); + final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
+        if (module == null) {
+ throw new DeploymentUnitProcessingException(MESSAGES.failedToResolveModule(deploymentRoot));
+        }
+ final SipMetaData sipMetaData = deploymentUnit.getAttachment(SipMetaData.ATTACHMENT_KEY); + final ServiceName deploymentServiceName = SipSubsystemServices.deploymentServiceName();
+        try {
+ final SipDeploymentService sipDeploymentService = new SipDeploymentService(deploymentUnit);
+               ServiceBuilder<?> builder = serviceTarget
+                               .addService(deploymentServiceName, 
sipDeploymentService);
+
+//             TODO: when distributable is implemented
+//             if (sipMetaData.getDistributable() != null) {
+// DistributedCacheManagerFactoryService factoryService = new DistributedCacheManagerFactoryService(); +// DistributedCacheManagerFactory factory = factoryService.getValue();
+//                     if (factory != null) {
+// ServiceName factoryServiceName = deploymentServiceName.append("session"); +// builder.addDependency(DependencyType.OPTIONAL, factoryServiceName, DistributedCacheManagerFactory.class, config.getDistributedCacheManagerFactoryInjector());
+//
+// ServiceBuilder<DistributedCacheManagerFactory> factoryBuilder = serviceTarget.addService(factoryServiceName, factoryService); +// boolean enabled = factory.addDeploymentDependencies(deploymentServiceName, deploymentUnit.getServiceRegistry(), serviceTarget, factoryBuilder, metaData); +// factoryBuilder.setInitialMode(enabled ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.NEVER).install();
+//                     }
+//             }
+            // add dependency to sip deployment service
+            builder.addDependency(deploymentServiceName);
+            builder.setInitialMode(Mode.ACTIVE).install();
+        } catch (ServiceRegistryException e) {
+ throw new DeploymentUnitProcessingException(MESSAGES.failedToAddSipDeployment(), e);
+        }
+
+        processManagement(deploymentUnit, sipMetaData);
+    }
+
+ void processManagement(final DeploymentUnit unit, final SipMetaData sipMetaData) { + for (final ServletMetaData servlet : sipMetaData.getSipServlets()) {
+            try {
+                final String name = servlet.getName().replace(' ', '_');
+ final ModelNode node = unit.createDeploymentSubModel("sip", PathElement.pathElement("servlet", name));
+                node.get("servlet-class").set(servlet.getServletClass());
+                node.get("servlet-name").set(servlet.getServletName());
+            } catch (Exception e) {
+ // Should a failure in creating the mgmt view also make to the deployment to fail?
+                continue;
+            }
+        }
+
+    }
+}
+
=======================================
--- /dev/null
+++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/resources/org/mobicents/as7/LocalDescriptions.properties Tue Jul 24 13:43:32 2012
@@ -0,0 +1,64 @@
+sip=The configuration of the jboss.sip subsystem.
+sip.add=Operation adding the sip subsystem.
+sip.remove=Operation removing the sip subsystem.
+
+sip.instance-id=Set the identifier for this server instance.
+sip.stack-properties=Sip stack configuration file.
+sip.application-router=Sip servlets application-router configuration file.
+sip.path-name=Path name for the SIP stack.
+sip.app-dispatcher-class=Sip servlets application-router configuration file.
+sip.congestion-control-interval=Congestion control interval.
+sip.concurrency-control-mode=Sip servlets container concurrency control mode. +sip.use-pretty-encoding=If true, Via, Route, and RecordRouteheader field information shall be split into multiple lines.
+
+sip.configuration=The common sip container configuration.
+
+sip.connector=A sip connector.
+sip.connector.add=Add a new sip connector.
+sip.connector.remove=Remove an existing sip connector
+sip.connector.name=A unique name for the connector.
+sip.connector.protocol=The sip connector protocol.
+sip.connector.scheme=The sip connector scheme.
+sip.connector.socket-binding=The sip connector socket-binding reference, this connector should be bound to. +sip.connector.enabled=Defines whether the connector should be started on startup. +sip.connector.use-static-address=Enables connector to use a static server address and port.
+sip.connector.static-server-address=Connector server static address.
+sip.connector.static-server-port=Connector server static port.
+sip.connector.use-stun=Enable STUN for this connector.
+sip.connector.stun-server-address=STUN server address.
+sip.connector.stun-server-port=STUN server port.
+
+sip.connector.bytesSent=Number of byte sent by the connector.
+sip.connector.bytesReceived=Number of byte received by the connector (POST data). +sip.connector.processingTime=Processing time used by the connector. Im milli-seconds. +sip.connector.errorCount=Number of error that occurs when processing requests by the connector.
+sip.connector.maxTime=Max time spent to process a requests.
+sip.connector.requestCount=Number of the request processed by the connector.
+
+sip.deployment=Runtime resources exposed by sip components in the 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
+sip.deployment.servlet.maxTime=Maximum processing time of a request
+sip.deployment.servlet.min-time=Minimum processing time of a request
+sip.deployment.servlet.processingTime=Total execution time of the servlet's service method +sip.deployment.servlet.requestCount=Number of requests processed by this servlet
+
+sip.deployment.active-sip-sessions=Number of active sip sessions
+sip.deployment.active-sip-application-sessions=Number of active sip application sessions +sip.deployment.expired-sip-sessions=Number of sip sessions that have expired +sip.deployment.expired-sip-application-sessions=Number of sip application sessions that have expired
+sip.deployment.rejected-sip-sessions=Number of rejected sip sessions
+sip.deployment.rejected-sip-application-sessions=Number of rejected sip application sessions +sip.deployment.max-active-sip-sessions=Max number of concurrent active sip sessions
+sip.deployment.sip-sessions-created=Total number of sip sessions created
+sip.deployment.sip-application-sessions-created=Total number of sip sessions created +sip.deployment.sip-sessions-per-sec=Number of sip sessions created per second +sip.deployment.sip-application-sessions-per-sec=Number of sip application sessions created per second +sip.deployment.duplicated-session-ids=Number of duplicated session IDs generated by the random source (anything \
+  bigger than 0 means problems)
+sip.deployment.sip-session-avg-alive-time=Average time (in seconds) that expired sip sessions had been alive +sip.deployment.sip-application-session-avg-alive-time=Average time (in seconds) that expired sip application sessions had been alive +sip.deployment.sip-session-max-alive-time=The longest time (in seconds) that an expired sip session had been alive +sip.deployment.sip-application-session-max-alive-time=The longest time (in seconds) that an expired sip application session had been alive
+
=======================================
--- /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemAdd.java Wed Aug 1 06:35:26 2012 +++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemAdd.java Tue Jul 24 13:43:32 2012
@@ -47,6 +47,7 @@
 import org.mobicents.as7.deployment.SipContextFactoryDeploymentProcessor;
 import org.mobicents.as7.deployment.SipJndiBindingProcessor;
 import org.mobicents.as7.deployment.SipParsingDeploymentProcessor;
+import org.mobicents.as7.deployment.SipWarDeploymentProcessor;

 /**
  * Adds the web subsystem.
@@ -109,7 +110,13 @@
                 // plugs our context factory into web subsystem deployers
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, SIP_CONTEXT_FACTORY_DEPLOYMENT_PRIORITY, SipContextFactoryDeploymentProcessor.INSTANCE); // binds sip resources to JNDI - Before POST_MODULE_INJECTION_ANNOTATION !!!
+<<<<<<< HEAD
processorTarget.addDeploymentProcessor(Phase.POST_MODULE, Phase.POST_MODULE_INJECTION_ANNOTATION - 1, new SipJndiBindingProcessor());
+=======
+ processorTarget.addDeploymentProcessor(SipExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_INJECTION_ANNOTATION - 1, new SipJndiBindingProcessor());
+                // setup management objects for servlets, etc.
+ processorTarget.addDeploymentProcessor(SipExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT, new SipWarDeploymentProcessor());
+>>>>>>> b100126... Support for AS7 cli console

 //                // Add the SIP specific deployment processor
// processorTarget.addDeploymentProcessor(Phase.PARSE, DEPLOYMENT_PROCESS_PRIORITY, SipMetaDataDeploymentProcessor.INSTANCE);
=======================================
--- /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java Wed Aug 1 06:35:26 2012 +++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/SipSubsystemServices.java Tue Jul 24 13:43:32 2012
@@ -24,8 +24,8 @@
     /** The base name for jboss.sip deployments. */
static final ServiceName JBOSS_SIP_DEPLOYMENT_BASE = JBOSS_SIP.append("deployment");

- public static ServiceName deploymentServiceName(final String virtualHost, final String contextPath) { - return JBOSS_SIP_DEPLOYMENT_BASE.append(virtualHost).append("".equals(contextPath) ? "/" : contextPath);
+    public static ServiceName deploymentServiceName() {
+       return JBOSS_SIP_DEPLOYMENT_BASE.append("/");
     }

     private SipSubsystemServices() {

==============================================================================
Revision: 6f24e35a34d0
Author:   josemrecio <[email protected]>
Date:     Sun Jul 29 18:41:35 2012
Log:      Update Issue 136

Backport to TelScale branch

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
(cherry picked from commit a35f5ff866474c33d4fbb71c6c0b8c843c91511a)

http://code.google.com/p/sipservlets/source/detail?r=6f24e35a34d0

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/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
@@ -24,8 +24,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/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

==============================================================================
Revision: c5244ca5a048
Author:   Jean Deruelle <[email protected]>
Date:     Wed Aug  1 05:56:21 2012
Log:      Update Issue 136

Backport to TelScale branch

Fixes NPE on deployment of some TCK apps and sometimes click2call
(cherry picked from commit c251c3802538be584d780cb217295386a77ff14a)

http://code.google.com/p/sipservlets/source/detail?r=c5244ca5a048

Modified:
/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/java/org/mobicents/as7/deployment/SipWarDeploymentProcessor.java Sun Jul 29 18:41:35 2012 +++ /containers/sip-servlets-as7-drop-in/jboss-as-mobicents/src/main/java/org/mobicents/as7/deployment/SipWarDeploymentProcessor.java Wed Aug 1 05:56:21 2012
@@ -84,52 +84,57 @@
throw new DeploymentUnitProcessingException(MESSAGES.failedToResolveModule(deploymentRoot));
         }
final SipMetaData sipMetaData = deploymentUnit.getAttachment(SipMetaData.ATTACHMENT_KEY);
-        final String appNameMgmt = sipMetaData.getApplicationName();
- final ServiceName deploymentServiceName = SipSubsystemServices.deploymentServiceName(appNameMgmt);
-        try {
- final SipDeploymentService sipDeploymentService = new SipDeploymentService(deploymentUnit);
-               ServiceBuilder<?> builder = serviceTarget
-                               .addService(deploymentServiceName, 
sipDeploymentService);
-
-//             TODO: when distributable is implemented
-//             if (sipMetaData.getDistributable() != null) {
-// DistributedCacheManagerFactoryService factoryService = new DistributedCacheManagerFactoryService(); -// DistributedCacheManagerFactory factory = factoryService.getValue();
-//                     if (factory != null) {
-// ServiceName factoryServiceName = deploymentServiceName.append("session"); -// builder.addDependency(DependencyType.OPTIONAL, factoryServiceName, DistributedCacheManagerFactory.class, config.getDistributedCacheManagerFactoryInjector());
-//
-// ServiceBuilder<DistributedCacheManagerFactory> factoryBuilder = serviceTarget.addService(factoryServiceName, factoryService); -// boolean enabled = factory.addDeploymentDependencies(deploymentServiceName, deploymentUnit.getServiceRegistry(), serviceTarget, factoryBuilder, metaData); -// factoryBuilder.setInitialMode(enabled ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.NEVER).install();
-//                     }
-//             }
-            // add dependency to sip deployment service
-            builder.addDependency(deploymentServiceName);
-            builder.setInitialMode(Mode.ACTIVE).install();
-        } catch (ServiceRegistryException e) {
- 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);
+        if(sipMetaData != null) {
+               final String appNameMgmt = sipMetaData.getApplicationName();
+ final ServiceName deploymentServiceName = SipSubsystemServices.deploymentServiceName(appNameMgmt);
+               try {
+ final SipDeploymentService sipDeploymentService = new SipDeploymentService(deploymentUnit);
+                       ServiceBuilder<?> builder = serviceTarget
+                                       .addService(deploymentServiceName, 
sipDeploymentService);
+
+       //              TODO: when distributable is implemented
+       //              if (sipMetaData.getDistributable() != null) {
+ // DistributedCacheManagerFactoryService factoryService = new DistributedCacheManagerFactoryService(); + // DistributedCacheManagerFactory factory = factoryService.getValue();
+       //                      if (factory != null) {
+ // ServiceName factoryServiceName = deploymentServiceName.append("session"); + // builder.addDependency(DependencyType.OPTIONAL, factoryServiceName, DistributedCacheManagerFactory.class, config.getDistributedCacheManagerFactoryInjector());
+       //
+ // ServiceBuilder<DistributedCacheManagerFactory> factoryBuilder = serviceTarget.addService(factoryServiceName, factoryService); + // boolean enabled = factory.addDeploymentDependencies(deploymentServiceName, deploymentUnit.getServiceRegistry(), serviceTarget, factoryBuilder, metaData); + // factoryBuilder.setInitialMode(enabled ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.NEVER).install();
+       //                      }
+       //              }
+                   // add dependency to sip deployment service
+                   builder.addDependency(deploymentServiceName);
+                   builder.setInitialMode(Mode.ACTIVE).install();
+               } catch (ServiceRegistryException e) {
+ 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);
+        } else {
+
+        }
     }

void processManagement(final DeploymentUnit unit, final SipMetaData sipMetaData) { - for (final ServletMetaData servlet : sipMetaData.getSipServlets()) {
-            try {
-                final String name = servlet.getName().replace(' ', '_');
- final ModelNode node = unit.createDeploymentSubModel("sip", PathElement.pathElement("servlet", name));
-                node.get("servlet-class").set(servlet.getServletClass());
-                node.get("servlet-name").set(servlet.getServletName());
-            } catch (Exception e) {
- // Should a failure in creating the mgmt view also make to the deployment to fail?
-                continue;
-            }
-        }
-
+       if(sipMetaData.getSipServlets() != null) {
+ for (final ServletMetaData servlet : sipMetaData.getSipServlets()) {
+                   try {
+                       final String name = servlet.getName().replace(' ', '_');
+ final ModelNode node = unit.createDeploymentSubModel("sip", PathElement.pathElement("servlet", name));
+                       
node.get("servlet-class").set(servlet.getServletClass());
+                       node.get("servlet-name").set(servlet.getServletName());
+                   } catch (Exception e) {
+ // Should a failure in creating the mgmt view also make to the deployment to fail?
+                       continue;
+                   }
+               }
+       }
     }
 }

Reply via email to