Package org.cafesip.jiplet.jboss

Source Code of org.cafesip.jiplet.jboss.SrrDeployer

/*
* Created on September 4, 2005
*
* Copyright 2005 CafeSip.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.cafesip.jiplet.jboss;

import java.net.URL;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import org.cafesip.jiplet.JipletContainer;
import org.cafesip.jiplet.JipletLogger;
import org.jboss.deployment.DeploymentException;
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployerSupport;

/**
* @author amit
*
*/
public class SrrDeployer extends SubDeployerSupport
implements SrrDeployerMBean
{       
    private static final int RELATIVE_ORDER = 420;
    private static final String SRR_EXTENSION = ".srr";
    public static ObjectName OBJECT_NAME;
    static
    {
        try
        {
            OBJECT_NAME = new ObjectName("org.cafesip.jiplet:service=SrrDeployer");
        }
        catch (MalformedObjectNameException e)
        {
             e.printStackTrace();
        }
    }
   
    /**
     *
     */
    public SrrDeployer()
    {
        super();
       
        setSuffixes(new String[]{SRR_EXTENSION});
        setRelativeOrder(RELATIVE_ORDER); // After EJBs but before SPR
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerMBean#accepts(org.jboss.deployment.DeploymentInfo)
     */
    public boolean accepts(DeploymentInfo di)
    {
        String urlStr = di.url.toString();
        if (!urlStr.endsWith(SRR_EXTENSION)
                && !urlStr.endsWith(SRR_EXTENSION + "/"))
        {
            return false;
        }

        if (!di.url.getProtocol().equals("file"))
        {
            return false;
        }
       
//        JipletLogger.info("Received accept request for " + di.url);
        if (di.isScript || di.isXML)
        {
            return false;
        }
               
        if (JipletLogger.isDebugEnabled())
        {
            JipletLogger.debug(di.url + " is deployable");
        }
        return true;
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerMBean#start(org.jboss.deployment.DeploymentInfo)
     */
    public void start(DeploymentInfo di) throws DeploymentException
    {
        JipletLogger.info("Received a request to start deployment  " + di.url);
        try
        {           
            String err = JipletContainer.getInstance().createJ2eeRealm(di.url.getPath(), di.ucl);
            if (err.length() > 0)
            {
                throw new DeploymentException(err);
            }          
        }
        catch (Exception e)
        {
            throw new DeploymentException(e);
        }
     }
   
    /*
     * @see org.jboss.system.ServiceMBeanSupport#stop()
     */
    public void stop(DeploymentInfo di) throws DeploymentException
    {
        JipletLogger.info("Received a request to stop deployment  " + di.url);
        try
        {
            String err = JipletContainer.getInstance().deleteJ2eeRealm(di.url.getPath());
            if (err.length() > 0)
            {
                throw new DeploymentException(err);
            }

        }
        catch (Exception e)
        {
            throw new DeploymentException(e);
        }   
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerMBean#create(org.jboss.deployment.DeploymentInfo)
     */
    public void create(DeploymentInfo di) throws DeploymentException
    {
        JipletLogger.info("Received a request to create deployment  " + di.url);
        super.create(di);
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerMBean#destroy(org.jboss.deployment.DeploymentInfo)
     */
    public void destroy(DeploymentInfo di) throws DeploymentException
    {
        JipletLogger.info("Received a request to delete deployment  " + di.url);    
        super.destroy(di);
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerMBean#init(org.jboss.deployment.DeploymentInfo)
     */
    public void init(DeploymentInfo di) throws DeploymentException
    {
        JipletLogger.info("Received a request to init deployment  " + di.url);
        super.init(di);
    }
   
    /*
     * @see org.jboss.deployment.SubDeployerSupport#isDeployable(java.lang.String, java.net.URL)
     */
    protected boolean isDeployable(String name, URL url)
    {
       return name.endsWith(SRR_EXTENSION);
    }

}
TOP

Related Classes of org.cafesip.jiplet.jboss.SrrDeployer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.