Package org.apache.jetspeed.engine

Examples of org.apache.jetspeed.engine.Engine


    }

    public void shutdown()
    {
        System.out.println("Shutting down CPS Bridge");
        Engine engine =Jetspeed.getEngine();
        try
        {
            engine.shutdown();
        }
        catch (JetspeedException e)
        {
            System.out.println("ERROR: Shutting down CPS Bridge " + e);
        }
View Full Code Here


        throws InitializationException
    {
        try
        {
            // Start Jetspeed
            Engine engine = Jetspeed.createEngine(configuration, applicationRoot, servletConfig, SpringEngine.class);
            engine.initContainer(servletConfig);
           
        }
        catch (Exception e)
        {
            throw new InitializationException("Failed to initialize Fusione engine", e);
View Full Code Here

            // Handle Action Phase via Action Pipeline
            //
           
            // System.out.println("*** ACTION PARAM FOUND!!!!!!!!!!! ****");               
            ServletConfig config = data.getServletConfig();
            Engine engine = Jetspeed.getEngine();
            contextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
            context = contextComponent.create(request, response, config);

           
            //
            // Sync up navigational state for J1 Portlet Control decorators
            //           
            //if (state.)
            //String state[] = nav.parsePortalParameter(request, "_ns"); // TODO don't hard code
            //if (state != null)
            context.setAttribute(PortalReservedParameters.PIPELINE, PortalReservedParameters.ACTION_PIPELINE);                               
            engine.service(context);
           
            PortalURL url = context.getPortalURL();
            if (url != null)
            {
                NavigationalState state = url.getNavigationalState();               
View Full Code Here

        try
        {
            HttpServletRequest request = data.getRequest();
            HttpServletResponse response =  data.getResponse();
            ServletConfig config = data.getServletConfig();
            Engine engine = Jetspeed.getEngine();
            contextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
            context = (RequestContext) data.getRequest().getAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE);
            if (context == null)
            {
                context = contextComponent.create(request, response, config);
                data.getRequest().setAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE, context);               
            }
           
            context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
            context.setAttribute(PortalReservedParameters.PIPELINE, FusionResources.NAVS_PIPELINE);
            engine.service(context);         
        }
        catch (Throwable t)
        {
            t.printStackTrace();           
        }
View Full Code Here

        try
        {
            HttpServletRequest request = data.getRequest();
            HttpServletResponse response =  data.getResponse();
            ServletConfig config = data.getServletConfig();
            Engine engine = Jetspeed.getEngine();
            contextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
           
            context = (RequestContext) data.getRequest().getAttribute(FUSION_NAV_STATE);
            if (context == null)
            {
                context = contextComponent.create(request, response, config);
                data.getRequest().setAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE, context);                               
            }
            context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
            context.getRequest().removeAttribute(PortalReservedParameters.PIPELINE);
           
            engine.service(context);
           
        }
        catch (Throwable t)
        {
            t.printStackTrace();           
View Full Code Here

        }

        if (Jetspeed.getEngine() != null)
        {
            request.setAttribute(PortalReservedParameters.PIPELINE, PortalReservedParameters.LOGIN_PIPELINE);
            Engine engine = Jetspeed.getEngine();
            try
            {
                RequestContextComponent contextComponent = (RequestContextComponent) Jetspeed.getComponentManager()
                        .getComponent(RequestContextComponent.class);
                RequestContext context = contextComponent.create(request, response, getServletConfig());
                engine.service(context);
                contextComponent.release(context);
            }
            catch (JetspeedException e)
            {
                log.warn("Jetspeed engine does not work properly.", e);
View Full Code Here

        }

        if (Jetspeed.getEngine() != null)
        {
            request.setAttribute(PortalReservedParameters.PIPELINE, PortalReservedParameters.LOGIN_PIPELINE);
            Engine engine = Jetspeed.getEngine();
            try
            {
                RequestContextComponent contextComponent = (RequestContextComponent) Jetspeed.getComponentManager()
                        .getComponent(RequestContextComponent.class);
                RequestContext context = contextComponent.create(request, response, getServletConfig());
                engine.service(context);
                contextComponent.release(context);
            }
            catch (JetspeedException e)
            {
                log.warn("Jetspeed engine does not work properly.", e);
View Full Code Here

        PropertiesConfiguration config = new  PropertiesConfiguration();
        config.load(new FileInputStream("./src/webapp/WEB-INF/conf/jetspeed.properties"));
        Mock servletConfigMock = new Mock(ServletConfig.class);
        MockServletConfig msc = new MockServletConfig();
        msc.setServletContext(new MockServletContext());
        Engine engine = Jetspeed.createEngine(config, "./src/webapp", msc, SpringEngine.class);

        // mock test PortletWindow
        Mock entityMock = new Mock(MutablePortletEntity.class);       
        Mock windowListMock = new Mock(CompositeWindowList.class);
        PortletWindowListCtrl windowList = (PortletWindowListCtrl)windowListMock.proxy();
View Full Code Here

     */

    public static void main(String args[])
    {
        String arg;
        Engine engine = null;
        int i = 0;       

        // Read the command line
        String strWebAppDir = "";
        String strAction = "";
        String strWarFileName = "";
        String strPortletAppName = "";
        String strPortalName = "jetspeed";
        String applicationType = "webapp";
    String strUserName = "";
    String strPassword = "";
    String strServer = "localhost";
        String className = "org.apache.jetspeed.tools.pamanager.FileSystemPAM"; // default
        Deployment deployer = null;
        Registration registrator = null;
        Lifecycle lifecycle = null;
       
    int intServerPort = 8080;
        String jetspeedPropertiesFile = System.getProperty("pam.jetspeed.properties", "/WEB-INF/conf/jetspeed.properties");
        String appsDirectory = System.getProperty("pam.apps.directory", "/WEB-INF/apps/");
       
        while (i < args.length && args[i].startsWith("-"))
        {
            arg = args[i++];

            // use this type of check for arguments that require arguments
            if (arg.equalsIgnoreCase("-PortletAppName"))
            {
                if (i < args.length)
                    strPortletAppName = args[i++];
            }
            else if (arg.equalsIgnoreCase("-Impl"))
            {
                if (i < args.length)
                    className = args[i++];
            }           
            else if (arg.equalsIgnoreCase("-Action"))
            {
                if (i < args.length)
                    strAction = args[i++];
            }
            else if (arg.equalsIgnoreCase("-WebAppDir"))
            {
                if (i < args.length)
                    strWebAppDir = args[i++];
            }
            else if (arg.equalsIgnoreCase("-WarFileName"))
            {
                if (i < args.length)
                    strWarFileName = args[i++];
            }
            else if (arg.equalsIgnoreCase("-PortalName"))
            {
                if (i < args.length)
                    strPortalName = args[i++];
            }
            else if (arg.equalsIgnoreCase("-UserName"))
            {
                if (i < args.length)
                    strUserName = args[i++];
            }
      else if (arg.equalsIgnoreCase("-Password"))
      {
        if (i < args.length)
          strPassword = args[i++];
      }
      else if (arg.equalsIgnoreCase("-Server"))
      {
        if (i < args.length)
          strServer= args[i++];
      }
            else if (arg.equalsIgnoreCase("-ServerPort"))
            {
                if (i < args.length)
                    intServerPort = Integer.parseInt(args[i++]);
            }
            else if (arg.equalsIgnoreCase("-ApplicationType"))
            {
                if (i < args.length)
                {
                    applicationType = args[i++];
                }
            }
            else if (arg.equalsIgnoreCase("-h"))
            {
                helpScreen();
                return;
            }
            else if (arg.equalsIgnoreCase("-?"))
            {
                helpScreen();
                return;
            }
        }
       
        // Portlet Application Name and action are required by all functions.
        // Make sure that the values were defined from the command line.
        if (strPortletAppName.length() == 0 || strAction.length() == 0)
        {
            System.out.println(
                "\nPortlet Application Name and/or action are not defined."
                    + "Please use '-PortletAppName appName' and/or '-Action deploy' from the command line\n");
            helpScreen();
            log.error("PAM Error: Invalid parameter(s) passed, cannot process PAM request.");
            if (!log.isInfoEnabled())
            {
                logRequest(args, true);
            }           
            return;
        }

        String strAppRoot = strWebAppDir + strPortalName;

        try
        {
            // Start the registry service -- it's needed by many actions
            Configuration properties =
                (Configuration) new PropertiesConfiguration(strAppRoot + jetspeedPropertiesFile);

            properties.setProperty(APPLICATION_ROOT_KEY, strAppRoot);

            // Override the properties with PAM specifice settings
            overrideProperties(strAppRoot, properties);

            engine = Jetspeed.createEngine(properties, strAppRoot, null, SpringEngine.class);           
        }
        catch (Exception e)
        {
            String msg = "PAM Error: Failed to create the Jetspeed Engine. Error: ";
            System.out.println(msg + e.getMessage());
            log.error(msg, e);
            shutdownAndExit(engine);
        }

        logRequest(args, false);
       
        try
        {
            System.out.println("Ready to run PAM implementation: " + className);
            System.out.print("Supporting interfaces: Deployment");
            // Class clas = Class.forName(className);
            PortletRegistry portletRegistry = (PortletRegistry) engine.getComponentManager()
                    .getComponent(PortletRegistry.class);
            deployer = (Deployment) engine.getComponentManager().getComponent("PAM");
            if (deployer instanceof Registration)
            {               
                System.out.print(", Registration");
                registrator = (Registration)deployer;
            }
            if (deployer instanceof Lifecycle)
            {
                System.out.print(", Lifecycle");
                lifecycle = (Lifecycle)deployer;
            }           
            System.out.println();
        }
        catch (Exception e)
        {
            String msg = "PAM Error: Failed to create PAM implementation class object: " + className + " Error: ";
            System.out.println(msg  + e.getMessage());
            log.error(msg, e);
            shutdownAndExit(engine);                       
        }
       
        try
        {
            // Invoke the functions
            if (strAction.compareToIgnoreCase("deploy") == 0)
            {
                // Make sure that the WarFileName and the ApplicationServer are defined
                if (strWarFileName.length() == 0)
                {
                    System.out.println(
                        "\nDeploy action requires the war file name. Use '-WarFileName file.war' to specify the file name");
                    log.error("PAM Error: Web application (WAR) file name not specified.");
                    shutdownAndExit(engine);               
                }
                else
                {
                    if (applicationType.equals("local"))
                    {
                        String portletAppRoot = strAppRoot + appsDirectory;
                        deploy(deployer, portletAppRoot, strWarFileName, strPortletAppName); // [RUN]
                    }
                    else
                    {
                        // Requires WebAppDir
                        if (strWebAppDir.length() == 0)
                        {
                            System.out.println(
                                "\nDeploy action requires the definition of the ApplicationServer or the Web application directory.");
                            log.error("PAM Deploy Error: Web application (WAR) directory name not specified.");
                            shutdownAndExit(engine);                       
                        }
   
                        // File deploy uses Directory and warfile
                        deploy(deployer, strWebAppDir, strWarFileName, strPortletAppName); // [RUN]
                    }
                }
            }
            else if (strAction.compareToIgnoreCase("register") == 0)
            {
                // Requires WebAppDir
                if (strWebAppDir.length() == 0)
                {
                    System.out.println("\nRegister action requires the definition of the Web application directory.");
                    log.error("PAM Register Error: Web application (WAR) directory name not specified.");                       
                    shutdownAndExit(engine);
                }
                if (null == registrator)
                {
                    String msg = "PAM Register Error: Registration interface not supported by implementation: " + className;           
                    System.out.println("\n" + msg);
                    log.error(msg);
                    shutdownAndExit(engine);                               
                }
   
                register(registrator, strPortletAppName, strWarFileName); // [RUN]
            }
            else if (strAction.compareToIgnoreCase("unregister") == 0)
            {         
                if (null == registrator)
                {
                    String msg = "PAM Register Error: Registration interface not supported by implementation: " + className;           
                    System.out.println("\n" + msg);
                    log.error(msg)
                    shutdownAndExit(engine);               
                }
               
                // Application server can be null -- using Catalina as default
                unregister(registrator, strPortletAppName); // [RUN]
            }
            else if (strAction.compareToIgnoreCase("undeploy") == 0)
            {
               
                undeploy(deployer, strWebAppDir, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
            }
            else if (strAction.compareToIgnoreCase("start") == 0)
            {
                if (null == lifecycle)
                {
                    String msg = "PAM Lifecycle Error: Lifecycle interface not supported by implementation: " + className;           
                    System.out.println("\n" + msg);
                    log.error(msg);
                    shutdownAndExit(engine);                               
                }
   
                start(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
            }
            else if (strAction.compareToIgnoreCase("stop") == 0)
            {
                stop(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
            }
            else if (strAction.compareToIgnoreCase("reload") == 0)
            {
                if (null == lifecycle)
                {
                    String msg = "PAM Lifecycle Error: Lifecycle interface not supported by implementation: " + className;           
                    System.out.println("\n" + msg);
                    log.error(msg);
                    shutdownAndExit(engine);                               
                }
                // Application server can be null -- using Catalina as default
                reload(lifecycle, strPortletAppName, strServer, intServerPort, strUserName, strPassword); // [RUN]
            }
            else
            {
                System.out.println("\nAction: " + strAction + " not recognized by the PortletApplicationManager.");
                helpScreen();
            }
        }
        catch (Exception e)
        {
            String msg = "PAM Error: Failed during execution of " + strAction + ", error = " + e.getMessage();
            System.out.println(msg);
            log.error(msg);                       
            shutdownAndExit(engine);                   
        }
       
        try
        {
            if (engine != null)
            {
                engine.shutdown();
            }
        }
        catch (JetspeedException e1)
        {
            System.out.println("Failed shutting down the engine. Error: " + e1.getMessage());
View Full Code Here

        PropertiesConfiguration config = new  PropertiesConfiguration();
        config.load(new FileInputStream("./src/webapp/WEB-INF/conf/jetspeed.properties"));
        Mock servletConfigMock = new Mock(ServletConfig.class);
        MockServletConfig msc = new MockServletConfig();
        msc.setServletContext(new MockServletContext());
        Engine engine = Jetspeed.createEngine(config, "./src/webapp", msc, SpringEngine.class);

        // mock test PortletWindow
        Mock entityMock = new Mock(MutablePortletEntity.class);       
        Mock windowListMock = new Mock(CompositeWindowList.class);
        PortletWindowListCtrl windowList = (PortletWindowListCtrl)windowListMock.proxy();
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.engine.Engine

Copyright © 2018 www.massapicom. 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.