Examples of DeploymentAdmin


Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

        {
            Map params = (Map) req.getAttribute(AbstractWebConsolePlugin.ATTR_FILEUPLOAD);
            if (params != null)
            {
                final FileItem pck = getFileItem(params, PARAMETER_PCK_FILE, false);
                final DeploymentAdmin admin = (DeploymentAdmin) adminTracker.getService();
                if (admin != null)
                {
                    try
                    {
                        admin.installDeploymentPackage(pck.getInputStream());

                        final String uri = req.getRequestURI();
                        resp.sendRedirect(uri);
                        return;
                    }
                    catch ( /*Deployment*/Exception e)
                    {
                        throw new ServletException("Unable to deploy package.", e);
                    }
                }
            }
            throw new ServletException("Upload file or deployment admin missing.");
        }
        else if (ACTION_UNINSTALL.equals(action))
        {
            final String pckId = req.getPathInfo().substring(
                req.getPathInfo().lastIndexOf('/') + 1);
            if (pckId != null && pckId.length() > 0)
            {
                final DeploymentAdmin admin = (DeploymentAdmin) adminTracker.getService();
                if (admin != null)
                {
                    try
                    {
                        final DeploymentPackage pck = admin.getDeploymentPackage(pckId);
                        if (pck != null)
                        {
                            pck.uninstall();
                        }
                    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

     */
    protected void renderContent(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
    {

        final DeploymentAdmin admin = (DeploymentAdmin) adminTracker.getService();

        StringWriter w = new StringWriter();
        PrintWriter w2 = new PrintWriter(w);
        JSONWriter jw = new JSONWriter(w2);
        try
        {
            jw.object();
            if (null == admin)
            {
                jw.key("error"); //$NON-NLS-1$
                jw.value(true);
            }
            else
            {
                final DeploymentPackage[] packages = admin.listDeploymentPackages();
                jw.key("data"); //$NON-NLS-1$

                jw.array();
                for (int i = 0; i < packages.length; i++)
                {
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

    }

    private void getAdmin() {
        this.deploymentAdminReference = this.bundleContext.getServiceReference(DEPLOYMENT_ADMIN);
        if ( this.deploymentAdminReference != null ) {
            final DeploymentAdmin deploymentAdmin = (DeploymentAdmin) this.bundleContext.getService(this.deploymentAdminReference);
            if ( deploymentAdmin == null ) {
                this.deploymentAdminReference = null;
            } else {
                final Dictionary<String, Object> props = new Hashtable<String, Object>();
                props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Installer Support for Deployment Packages");
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

        else if (topic.equals(TOPIC_COMPLETE)) {
            String deplPackName = (String) event.getProperty("deploymentpackage.name");
            // to retrieve the version, DeploymentAdmin has to be used
            ServiceReference ref = m_context.getServiceReference(DeploymentAdmin.class.getName());
            if (ref != null) {
                DeploymentAdmin deplAdmin = (DeploymentAdmin) m_context.getService(ref);
                if (deplAdmin != null) {
                    DeploymentPackage dp = deplAdmin.getDeploymentPackage(deplPackName);
                    if (dp != null) {
                        Version version = dp.getVersion();
                        if (version != null) {
                            props.put(AuditEvent.KEY_VERSION, version.toString());
                        }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

                        String deplPackName = (String) event.getProperty("deploymentpackage.name");

                        // to retrieve the version, DeploymentAdmin has to be used
                        ServiceReference ref = m_context.getServiceReference(DeploymentAdmin.class.getName());
                        if (ref != null) {
                            DeploymentAdmin deplAdmin = (DeploymentAdmin) m_context.getService(ref);
                            if (deplAdmin != null) {
                                DeploymentPackage dp = deplAdmin.getDeploymentPackage(deplPackName);
                                if (dp != null) {
                                    Version version = dp.getVersion();
                                    if (version != null) {
                                        props.put(AuditEvent.KEY_VERSION, version.toString());
                                    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

import org.osgi.service.deploymentadmin.DeploymentPackage;

public class DeploymentPackageCommand extends BasicCommand {

  public void exec(String args, PrintStream out, PrintStream err) throws Exception {
    DeploymentAdmin admin = getDeploymentAdmin();

    if (admin == null) {
      out.println("No DeploymentAdmin service found.");
      return;
    }
    if (args != null) {
      if (args.trim().equalsIgnoreCase("list")) {
        for (DeploymentPackage dp : admin.listDeploymentPackages()) {
          out.println(dp.getName() + " " + dp.getVersion());
        }
      } else if (args.trim().startsWith("uninstall ")) {
        DeploymentPackage dp = admin.getDeploymentPackage(args.trim().substring("uninstall ".length()));
        if (dp != null) {
          dp.uninstall();
        } else {
          out.println("No such package");
        }
      } else if (args.trim().startsWith("install ")) {
        DeploymentPackage dp = admin.installDeploymentPackage(new URL(args.trim().substring("install ".length())).openStream());
        out.println(dp.getName() + " " + dp.getVersion());
      }
    } else {
      out.println("Use {list|install <url>|uninstall <name>}");
    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

import org.osgi.service.deploymentadmin.DeploymentPackage;

public class DeploymentPackageCommand extends BasicCommand {

  public void exec(String args, PrintStream out, PrintStream err) throws Exception {
    DeploymentAdmin admin = getDeploymentAdmin();

    if (admin == null) {
      out.println("No DeploymentAdmin service found.");
      return;
    }
    if (args != null) {
      if (args.trim().equalsIgnoreCase("list")) {
        for (DeploymentPackage dp : admin.listDeploymentPackages()) {
          out.println(dp.getName() + " " + dp.getVersion());
        }
      } else if (args.trim().startsWith("uninstall ")) {
        DeploymentPackage dp = admin.getDeploymentPackage(args.trim().substring("uninstall ".length()));
        if (dp != null) {
          dp.uninstall();
        } else {
          out.println("No such package");
        }
      } else if (args.trim().startsWith("install ")) {
        DeploymentPackage dp = admin.installDeploymentPackage(new URL(args.trim().substring("install ".length())).openStream());
        out.println(dp.getName() + " " + dp.getVersion());
      }
    } else {
      out.println("Use {list|install <url>|uninstall <name>}");
    }
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

        expect(discoveryHandler.getServerUrl()).andReturn(serverURL).anyTimes();

        ConfigurationHandler configurationHandler = addTestMock(ConfigurationHandler.class);
        expect(configurationHandler.get(notNull(String.class), anyObject(String.class))).andReturn(null).anyTimes();

        DeploymentAdmin deploymentAdmin = addTestMock(DeploymentAdmin.class);
        expect(deploymentAdmin.listDeploymentPackages()).andReturn(
            new DeploymentPackage[] { deploymentPackage2, deploymentPackage1 }).anyTimes();
        expect(deploymentAdmin.installDeploymentPackage(notNull(InputStream.class)
            )).andReturn(deploymentPackage3).once();

        m_agentContext = mockAgentContext();
        m_agentContext.setHandler(IdentificationHandler.class, identificationHandler);
        m_agentContext.setHandler(DiscoveryHandler.class, discoveryHandler);
View Full Code Here

Examples of org.osgi.service.deploymentadmin.DeploymentAdmin

                        String deplPackName = (String) event.getProperty("deploymentpackage.name");

                        // to retrieve the version, DeploymentAdmin has to be used
                        ServiceReference ref = m_context.getServiceReference(DeploymentAdmin.class.getName());
                        if (ref != null) {
                            DeploymentAdmin deplAdmin = (DeploymentAdmin) m_context.getService(ref);
                            if (deplAdmin != null) {
                                DeploymentPackage dp = deplAdmin.getDeploymentPackage(deplPackName);
                                if (dp != null) {
                                    Version version = dp.getVersion();
                                    if (version != null) {
                                        props.put(AuditEvent.KEY_VERSION, version.toString());
                                    }
View Full Code Here
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.