(3);
+ messages.add("Could not connect to Vasc Tech Client Swing server, please try again.");
+ messages.add("If the problem persists please contact your systems administrator.");
+ String connectionError = "Could not obtain connection to any of these urls: ";
+ Integer connectionErrorLen = connectionError.length();
+ String emsg = e.getMessage();
+ if (emsg!=null && emsg.startsWith(connectionError)) {
+ Integer urlEndIdx = emsg.substring(connectionErrorLen).indexOf(':');
+ if (urlEndIdx>=0) {
+ messages.add("Server unreachable at: "+emsg.substring(connectionErrorLen, connectionErrorLen+urlEndIdx));
+ }
+ }
+ JOptionPane.showMessageDialog(null, messages.toArray(), "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
+ System.exit(1);
+ } catch (Exception e) {
+ //logger.log(Level.WARNING,e.getMessage(),e);
+ JOptionPane.showMessageDialog(null, "Failure on login test.", "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Check if we have 'login' role on server.
+ * @return
+ * @throws Exception
+ */
+ private boolean doLoginTest() throws Exception {
+ try {
+ LoginUserController loginManager = (LoginUserController)context.lookup("loginUserControllerRemote");
+ loginManager.doClientLogin();
+ return true;
+ } catch (javax.naming.NameNotFoundException e) {
+ JOptionPane.showMessageDialog(null, "Server is not deployed.\nPlease wait a couple of minuts and try again.");
+ return false;
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage());
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * Some simple hardcoded i18n function here
+ *
+ * @param key
+ * @param params
+ * @return
+ */
+ static protected String i18n(Object obj,String key,Object...params) {
+ if(obj==null) { throw new NullPointerException("Can't get key of null obj"); }
+ if (key==null) { throw new NullPointerException("key may not be null"); }
+ if(obj instanceof Class) {
+ key=((Class>)obj).getName()+"."+key;
+ } else {
+ key=obj.getClass().getName()+"."+key;
+ }
+ return key;
+ /*
+ try {
+ String text = ResourceBundle.getBundle("resources.i18n.root").getString(key);
+ if (params != null) {
+ MessageFormat mf = new MessageFormat(text);
+ text = mf.format(params, new StringBuffer(), null).toString();
+ }
+ return text;
+ } catch(MissingResourceException e){
+ return "MISSING: '"+key+"'";
+ }
+ */
+ }
+
+ class JdniTreePrinter {
+
+ boolean printXml = true;
+
+ public JdniTreePrinter(boolean printXml) {
+ this.printXml=printXml;
+ }
+
+ public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) {
+ if (printXml) {
+ buf.append("\n");
+ buf.append("\n");
+ }
+ printTree(context,ct,buf);
+ if (printXml) {
+ buf.append("\n");
+ }
+ }
+
+ public void printTree(javax.naming.Context context,String ct,StringBuffer buf) {
+ try {
+ printNE(context,context.list(ct), ct,buf);
+ } catch (NamingException e) {
+ //ignore leaf node exception
+ }
+ }
+
+ private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration> ne, String parentctx,StringBuffer buf) throws NamingException {
+ if (ne==null) {
+ return;
+ }
+ while (ne.hasMoreElements()) {
+ NameClassPair next = (NameClassPair) ne.nextElement();
+ if (printXml) {
+ printIndent(buf);
+ buf.append("\n");
+ increaseIndent();
+ printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
+ decreaseIndent();
+
+ printIndent(buf);
+ buf.append("\n");
+ } else {
+ printEntry(next,buf);
+ increaseIndent();
+ printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
+ decreaseIndent();
+ }
+ }
+ }
+
+ private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) {
+ printIndent(buf);
+ buf.append("-->");
+ buf.append(next);
+ buf.append("\n");
+ }
+
+
+ private int indentLevel = 0;
+
+ private void increaseIndent() {
+ indentLevel += 4;
+ }
+
+ private void decreaseIndent() {
+ indentLevel -= 4;
+ }
+
+ private void printIndent(StringBuffer buf) {
+ for (int i = 0; i < indentLevel; i++) {
+ buf.append(" ");
+ }
+ }
+ }
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java
new file mode 100644
index 0000000..43bc3f3
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java
@@ -0,0 +1,408 @@
+/*
+ * @(#)DialogCallbackHandler.java 1.9 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+package net.forwardfire.vasc.demo.client.swing;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JTextField;
+
+/**
+ * Zwaar gehacke jaas login dialog
+ * added features:
+ * - name remebering
+ * - focus on name field
+ * - alway on top
+ * - logo stuff
+ * - message field
+ *
+ *
+ * Uses a Swing dialog window to query the user for answers to authentication
+ * questions. This can be used by a JAAS application to instantiate a
+ * CallbackHandler
+ *
+ * @see javax.security.auth.callback
+ */
+public class VascDemoUserLoginDialog implements CallbackHandler {
+
+ /* The parent window, or null if using the default parent */
+ private Component parentComponent;
+ private static final int JPasswordFieldLen = 8;
+ private int loginTry = 0;
+ private String userName = null;
+
+ /**
+ * Creates a callback dialog with the default parent window.
+ */
+ public VascDemoUserLoginDialog() {
+ }
+
+ /**
+ * Creates a callback dialog and specify the parent window.
+ *
+ * @param parentComponent
+ * the parent window -- specify null
for the
+ * default parent
+ */
+ public VascDemoUserLoginDialog(Component parentComponent) {
+ this.parentComponent = parentComponent;
+ }
+
+ /**
+ * An interface for recording actions to carry out if the user clicks OK for
+ * the dialog.
+ */
+ private static interface Action {
+ void perform();
+ }
+
+ /**
+ * Handles the specified set of callbacks.
+ *
+ * @param callbacks
+ * the callbacks to handle
+ * @throws UnsupportedCallbackException
+ * if the callback is not an instance of NameCallback or
+ * PasswordCallback
+ */
+ public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
+ this.loginTry++;
+ /* Collect messages to display in the dialog */
+ final JPanel loginDesign = new JPanel();
+ loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS));
+ //final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/resources/images/logos/logo.png"));
+ final JPanel logoPanel = new JPanel() {
+ private static final long serialVersionUID = 10l;
+ protected void paintComponent(Graphics g) {
+ Graphics2D g2d = (Graphics2D)g;
+
+ // for antialiasing geometric shapes
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+ // for antialiasing text
+ g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ // to go for quality over speed
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
+
+ // Paint the default look of the panel.
+ super.paintComponent(g2d);
+
+ int offsetX = 0; // for windows systems
+ boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1;
+ if (isWindows) {
+ offsetX += 25;
+ }
+
+ g2d.setColor(Color.BLACK);
+ g2d.fillRect(0,0,getWidth(),getHeight());
+ g2d.setColor(new Color(238,212,1));
+
+ //int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
+ //int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
+ //g2d.drawImage(logoImage, w, h, this);
+ }
+ };
+ logoPanel.setPreferredSize(new Dimension(200, 170));
+ logoPanel.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ loginDesign.add(logoPanel);
+ loginDesign.add(Box.createVerticalStrut(5));
+ JPanel namePanel = new JPanel();
+ JLabel nameLabel = new JLabel("Vasc Demo Client");
+ nameLabel.setFont(new Font("Lucida Sans", Font.BOLD, 24));
+ namePanel.add(nameLabel);
+ loginDesign.add(namePanel);
+ loginDesign.add(Box.createVerticalStrut(5));
+
+ final GridLayout messagesLayout = new GridLayout(2,2);
+ final JPanel messages = new JPanel();
+ messages.setLayout(messagesLayout);
+
+ /* Collection actions to perform if the user clicks OK */
+ final List okActions = new ArrayList(2);
+ ConfirmationInfo confirmation = new ConfirmationInfo();
+
+ // hackje for focus
+ final JTextField name = new JTextField();
+ confirmation.initialValue=name;
+
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof TextOutputCallback) {
+ TextOutputCallback tc = (TextOutputCallback) callbacks[i];
+
+ switch (tc.getMessageType()) {
+ case TextOutputCallback.INFORMATION:
+ confirmation.messageType = JOptionPane.INFORMATION_MESSAGE;
+ break;
+ case TextOutputCallback.WARNING:
+ confirmation.messageType = JOptionPane.WARNING_MESSAGE;
+ break;
+ case TextOutputCallback.ERROR:
+ confirmation.messageType = JOptionPane.ERROR_MESSAGE;
+ break;
+ default:
+ throw new UnsupportedCallbackException(callbacks[i], "Unrecognized message type");
+ }
+ messages.add(new JLabel(tc.getMessage()));
+
+ } else if (callbacks[i] instanceof NameCallback) {
+ final NameCallback nc = (NameCallback) callbacks[i];
+
+ JLabel prompt = new JLabel(nc.getPrompt());
+ String defaultName = nc.getDefaultName();
+
+ // if (check some property)
+ defaultName = "";
+ if (defaultName != null) {
+ name.setText(defaultName);
+ }
+ // default to last user name
+ if (userName !=null ) {
+ name.setText(userName);
+ }
+ messages.add(prompt);
+ messages.add(name);
+
+ /* Store the name back into the callback if OK */
+ okActions.add(new Action() {
+ public void perform() {
+ nc.setName(name.getText());
+ }
+ });
+
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ final PasswordCallback pc = (PasswordCallback) callbacks[i];
+
+ JLabel prompt = new JLabel(pc.getPrompt());
+
+ final JPasswordField password = new JPasswordField(JPasswordFieldLen);
+ if (!pc.isEchoOn()) {
+ password.setEchoChar('*');
+ }
+ messages.add(prompt);
+ messages.add(password);
+
+ okActions.add(new Action() {
+ public void perform() {
+ pc.setPassword(password.getPassword());
+ }
+ });
+
+ } else if (callbacks[i] instanceof ConfirmationCallback) {
+ ConfirmationCallback cc = (ConfirmationCallback) callbacks[i];
+
+ confirmation.setCallback(cc);
+ if (cc.getPrompt() != null) {
+ messages.add(new JLabel(cc.getPrompt()));
+ }
+
+ } else {
+ throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
+ }
+ }
+
+ if (this.loginTry>1) {
+ JPanel messagesPanel = new JPanel();
+ messagesPanel.setBorder(BorderFactory.createEtchedBorder());
+ JLabel iup = new JLabel("Invalid Username and Password:");
+ iup.setForeground(Color.RED);
+ messagesPanel.add(iup);
+ loginDesign.add(messagesPanel);
+ loginDesign.add(Box.createVerticalStrut(5));
+ }
+
+ JPanel messagesPanel = new JPanel();
+ messagesPanel.setBorder(BorderFactory.createEtchedBorder());
+ messagesPanel.add(messages);
+ loginDesign.add(messagesPanel);
+ /* Display the dialog */
+
+ /// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)
+ JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,confirmation.optionType,null,
+ confirmation.options,confirmation.initialValue);
+
+ JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login");
+
+ // We alway request focus after the windows gets focus
+ dialog.addWindowFocusListener(new WindowFocusListener() {
+ /**
+ * @see java.awt.event.WindowFocusListener#windowGainedFocus(java.awt.event.WindowEvent)
+ */
+ public void windowGainedFocus(WindowEvent arg0) {
+ //System.out.println("request focus window focus");
+ name.requestFocus();
+ }
+
+ /**
+ * @see java.awt.event.WindowFocusListener#windowLostFocus(java.awt.event.WindowEvent)
+ */
+ public void windowLostFocus(WindowEvent arg0) {
+ }
+ });
+
+ // HACK, EVEN the listener above doesn't work 100% so just request focus request
+ // until we have focus, then cancel task, see println output
+ final Timer lTimer = new Timer();
+ lTimer.schedule(new TimerTask() {
+ public void run() {
+ if(name.hasFocus()==false) {
+ //System.out.println("request focus timer task");
+ name.requestFocus();
+ } else {
+ cancel();
+ }
+ }
+ }, 10, 5);
+ // wait 10ms
+ // execute every 5ms
+
+ dialog.setAlwaysOnTop(true);
+ dialog.setVisible(true);
+ Integer result = (Integer)jop.getValue();
+ dialog.dispose();
+
+ if (result==null) {
+ // is null when escaping by window closing
+ result = JOptionPane.CANCEL_OPTION;
+ }
+
+ // copy user name for next try
+ userName = name.getText();
+
+ /* Perform the OK actions */
+ if (result == JOptionPane.OK_OPTION || result == JOptionPane.YES_OPTION) {
+ Iterator iterator = okActions.iterator();
+ while (iterator.hasNext()) {
+ iterator.next().perform();
+ }
+ } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.NO_OPTION) {
+ System.exit(1);
+ }
+ confirmation.handleResult(result);
+ }
+
+
+ /**
+ * Provides assistance with translating between JAAS and Swing confirmation
+ * dialogs.
+ */
+ private static class ConfirmationInfo {
+
+ private int[] translations;
+
+ int optionType = JOptionPane.OK_CANCEL_OPTION;
+ Object[] options = null;
+ Object initialValue = null;
+
+ int messageType = JOptionPane.QUESTION_MESSAGE;
+
+ private ConfirmationCallback callback;
+
+ /* Set the confirmation callback handler */
+ void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException {
+ this.callback = callback;
+
+ int confirmationOptionType = callback.getOptionType();
+ switch (confirmationOptionType) {
+ case ConfirmationCallback.YES_NO_OPTION:
+ optionType = JOptionPane.YES_NO_OPTION;
+ translations = new int[] {
+ JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO
+ };
+ break;
+ case ConfirmationCallback.YES_NO_CANCEL_OPTION:
+ optionType = JOptionPane.YES_NO_CANCEL_OPTION;
+ translations = new int[] {
+ JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION,
+ ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
+ };
+ break;
+ case ConfirmationCallback.OK_CANCEL_OPTION:
+ optionType = JOptionPane.OK_CANCEL_OPTION;
+ translations = new int[] {
+ JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION,
+ ConfirmationCallback.CANCEL
+ };
+ break;
+ case ConfirmationCallback.UNSPECIFIED_OPTION:
+ options = callback.getOptions();
+ /*
+ * There's no way to know if the default option means to
+ * cancel the login, but there isn't a better way to guess
+ * this.
+ */
+ translations = new int[] {
+ JOptionPane.CLOSED_OPTION, callback.getDefaultOption()
+ };
+ break;
+ default:
+ throw new UnsupportedCallbackException(callback, "Unrecognized option type: " + confirmationOptionType);
+ }
+
+ int confirmationMessageType = callback.getMessageType();
+ switch (confirmationMessageType) {
+ case ConfirmationCallback.WARNING:
+ messageType = JOptionPane.WARNING_MESSAGE;
+ break;
+ case ConfirmationCallback.ERROR:
+ messageType = JOptionPane.ERROR_MESSAGE;
+ break;
+ case ConfirmationCallback.INFORMATION:
+ messageType = JOptionPane.INFORMATION_MESSAGE;
+ break;
+ default:
+ throw new UnsupportedCallbackException(callback, "Unrecognized message type: " + confirmationMessageType);
+ }
+ }
+
+ /* Process the result returned by the Swing dialog */
+ void handleResult(int result) {
+ if (callback == null) {
+ return;
+ }
+
+ for (int i = 0; i < translations.length; i += 2) {
+ if (translations[i] == result) {
+ result = translations[i + 1];
+ break;
+ }
+ }
+ callback.setSelectedIndex(result);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf
new file mode 100644
index 0000000..6fd4b6e
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf
@@ -0,0 +1,6 @@
+
+vasc-auth-client {
+ org.apache.openejb.client.ClientLoginModule required
+ debug=true
+ openejb.server.uri="http://localhost:8899/demo/ejb";
+};
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java
deleted file mode 100644
index 3713ec6..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/VascControllerService.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2007-2012 forwardfire.net All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.forwardfire.vasc.demo.tech.core.service;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Logger;
-
-import net.forwardfire.vasc.backend.VascBackendControllerLocal;
-import net.forwardfire.vasc.core.VascController;
-import net.forwardfire.vasc.core.VascEntryControllerLocal;
-import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
-import net.forwardfire.vasc.impl.DefaultVascFactory;
-import net.forwardfire.vasc.impl.x4o.VascParser;
-
-/**
- * VascControllerService manages the demo vasc controller which gets init by jndi factory.
- *
- * @author Willem Cazander
- * @version 1.0 May 18, 2012
- */
-public class VascControllerService {
-
- private Logger logger = null;
- private VascController vascController = null;
- private List vascServiceListeners = null;
-
- public VascControllerService() {
- logger = Logger.getLogger(VascControllerService.class.getName());
- vascServiceListeners = new ArrayList(10);
- }
-
- public void start() {
- logger.finer("Starting vascmanager");
- if (vascController!=null) {
- throw new RuntimeException("VascManager is already started.");
- }
- try {
- // Fetch from jndi
- vascController = (VascController)VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext().lookup("vasc/DemoVascController");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void stop() {
- if (vascController==null) {
- return;
- }
- VascBackendControllerLocal backends = (VascBackendControllerLocal)vascController.getVascBackendController();
- backends.clearAndStopBackends();
-
- vascController = null;
- logger.info("Stop manager, cleared all.");
- }
-
- public void startEditor() {
- try {
- VascParser parser = new VascParser(vascController);
- parser.addGlobalELBean("vascController", vascController);
- parser.parseResource("net/forwardfire/vasc/lib/editor/vasc-edit.xml");
-
- DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- fireChangeEvent();
- }
- }
-
-
- public void openFile(File file) {
- logger.info("Vasc open file: "+file.getAbsoluteFile());
- try {
- VascParser parser = new VascParser(vascController);
- //File f = File.createTempFile("test-vasc", ".xml");
- //parser.setDebugOutputStream(new FileOutputStream(f));
- parser.parseFile(file);
-
- DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
-
-
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- fireChangeEvent();
- }
- }
-
-
- public VascController getVascController() {
- return vascController;
- }
-
-
- public void fireChangeEvent() {
- for (VascServiceListener listener:vascServiceListeners) {
- listener.changeEvent();
- }
- }
-
- public void addVascServiceListener(VascServiceListener listener) {
- vascServiceListeners.add(listener);
- }
-
- public interface VascServiceListener {
- public void changeEvent();
- }
-}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java
deleted file mode 100644
index 7139e86..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JdniTreePrinter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package net.forwardfire.vasc.demo.tech.core.service.tomcat;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingException;
-
-public class JdniTreePrinter {
- public JdniTreePrinter() {
-
- }
-
- public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) {
- try {
- printNE(context,context.list(ct), ct,buf);
- } catch (NamingException e) {
- //ignore leaf node exception
- }
- }
-
- private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration> ne, String parentctx,StringBuffer buf) throws NamingException {
- while (ne.hasMoreElements()) {
- NameClassPair next = (NameClassPair) ne.nextElement();
- printEntry(next,buf);
- increaseIndent();
- printJNDITree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
- decreaseIndent();
- }
- }
-
- private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) {
- printIndent(buf);
- buf.append("-->");
- buf.append(next);
- buf.append("\n");
- }
-
-
- private int indentLevel = 0;
-
- private void increaseIndent() {
- indentLevel += 4;
- }
-
- private void decreaseIndent() {
- indentLevel -= 4;
- }
-
- private void printIndent(StringBuffer buf) {
- for (int i = 0; i < indentLevel; i++) {
- buf.append(" ");
- }
- }
-}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java
deleted file mode 100644
index ad7d7b5..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/JndiDebugServlet.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package net.forwardfire.vasc.demo.tech.core.service.tomcat;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
-
-public class JndiDebugServlet extends HttpServlet {
- private static final long serialVersionUID = -7624183395089913214L;
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
- try {
- Context context = new InitialContext();
- if (req.getRequestURI().endsWith("global")) {
- context = VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext();
- }
- StringBuffer buf = new StringBuffer();
- JdniTreePrinter jndi = new JdniTreePrinter();
- if (req.getRequestURI().endsWith("global")) {
- jndi.printJNDITree(context,"",buf);
- } else {
- jndi.printJNDITree(context,"java:",buf);
- }
- PrintWriter out = response.getWriter();
- out.append(buf.toString());
- out.flush();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java
deleted file mode 100644
index ee2610b..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/service/tomcat/TomcatService.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2007-2012 forwardfire.net All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.forwardfire.vasc.demo.tech.core.service.tomcat;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.logging.Logger;
-
-import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Host;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.startup.Bootstrap;
-import org.apache.catalina.startup.ContextConfig;
-import org.apache.naming.resources.VirtualDirContext;
-
-/**
- * TomcatService config and starts Tomcat in semi embedded mode.
- *
- * @author Willem Cazander
- * @version 1.0 May 10, 2012
- */
-public class TomcatService {
-
- private Logger logger = null;
- private Server server = null;
- private ClassLoader commonLoader = null;
- private Context applicationContext = null;
-
- public TomcatService() {
- logger = Logger.getLogger(TomcatService.class.getName());
- }
-
- public void start() throws Exception {
-
-
- Bootstrap boot = new Bootstrap();
- boot.setCatalinaHome(System.getProperty("user.dir"));
- boot.init();
- boot.start();
-
- /// After startup get the server object from private method.
- for (Method m:boot.getClass().getDeclaredMethods()) {
- if (m.getName().equals("getServer")) {
- m.setAccessible(true);
- server = (Server)m.invoke(boot);
- }
- }
- if (server==null) {
- throw new RuntimeException("Could not get server by reflection from BootStrap.");
- }
- for (Field f:boot.getClass().getDeclaredFields()) {
- if (f.getName().equals("commonLoader")) {
- f.setAccessible(true);
- commonLoader = (ClassLoader)f.get(boot);
- }
- }
- }
-
- public void deploy(String deployContext) throws Exception {
- Service service = server.findService("Catalina");
- Host host = (Host)service.getContainer().findChild("localhost");
-
- String deployPath = null;
- if (VascTechDemo.getInstance().isMavenRun()) {
- String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
- deployPath = new File(webappPathLocation).getAbsolutePath();
- logger.info("Deploy demo app from workspace path: "+deployPath);
- } else {
-
- File techWarFile = null;
- for (File file:new File("lib").listFiles()) {
- if (file.getName().contains("vasc-demo-tech-web")) {
- techWarFile = file;
- break;
- }
- }
- if (techWarFile==null) {
- throw new NullPointerException("Could not locate war file in lib directory.");
- }
- File destDir = new File("workdir","tomcat.wars"+File.separator+techWarFile.getName());
-
- if (destDir.exists()==false) {
- destDir.mkdirs();
- JarFile jar = new JarFile(techWarFile);
- Enumeration jars = jar.entries();
- while (jars.hasMoreElements()) {
- JarEntry file = jars.nextElement();
- File f = new File(destDir+File.separator+file.getName());
- if (file.isDirectory()) {
- f.mkdir();
- continue;
- }
- InputStream is = jar.getInputStream(file);
- FileOutputStream fos = new FileOutputStream(f);
- while (is.available() > 0) {
- fos.write(is.read()); // slow copy
- }
- fos.close();
- is.close();
- }
- }
- deployPath = destDir.getAbsolutePath();
- logger.info("Deploy war path: "+deployPath);
- }
-
-
- Context ctx = new StandardContext();
- ctx.setName(deployContext);
- ctx.setPath(deployContext);
- ctx.setDocBase(deployPath);
- //ctx.setParentClassLoader(commonLoader);
- ctx.setConfigured(true);
-
- ContextConfig ctxCfg = new ContextConfig();
- ctx.addLifecycleListener(ctxCfg);
-
- VirtualDirContext vDir = new VirtualDirContext();
- vDir.setExtraResourcePaths("../vasc-demo-tech-web/target/classes");
-
- ctx.setResources(vDir);
-
- //VirtualWebappLoader loader = new VirtualWebappLoader();
- //String cl = System.getProperty("java.class.path").replace(":", ";");
- //logger.info("Virtal class path: "+cl);
- //loader.setVirtualClasspath(cl);
- //loader.setSearchVirtualFirst(true);
- //ctx.setLoader(loader);
-
- //ctx.getJarScanner().scan
- host.addChild(ctx);
-
- applicationContext = ctx;
- }
-
- public void deployDebug() throws Exception {
- if (applicationContext==null) {
- throw new NullPointerException("Can only deploy debug after deploy.");
- }
- long startTime = System.currentTimeMillis();
-
- addServlet(applicationContext,"jdbcConsole","org.h2.server.web.WebServlet");
- applicationContext.addServletMapping("/debug/jdbc/console/*", "jdbcConsole");
-
- addServlet(applicationContext,"jndiView","net.forwardfire.vasc.demo.tech.core.service.tomcat.JndiDebugServlet");
- applicationContext.addServletMapping("/debug/jndi/view", "jndiView");
- applicationContext.addServletMapping("/debug/jndi/view/global", "jndiView");
-
- addServlet(applicationContext,"logbackClassicStatus","ch.qos.logback.classic.ViewStatusMessagesServlet");
- applicationContext.addServletMapping("/debug/logback/status/classic", "logbackClassicStatus");
-
- addServlet(applicationContext,"logbackAccessStatus","ch.qos.logback.access.ViewStatusMessagesServlet");
- applicationContext.addServletMapping("/debug/logback/status/access", "logbackAccessStatus");
-
- long stopTime = System.currentTimeMillis();
- logger.info("Deployed all debug resources in: "+(stopTime-startTime)+" ms.");
- }
-
- public Wrapper addServlet(Context ctx,String servletName,String servletClass) {
- Wrapper sw = ctx.createWrapper();
- sw.setServletClass(servletClass);
- sw.setName(servletName);
- ctx.addChild(sw);
- return sw;
- }
-
- public void stop() throws Exception {
- if (server==null) {
- return;
- }
- server.stop();
- }
-
- public ClassLoader getClassLoaderCommon() {
- return commonLoader;
- }
-
- public Server getServer() {
- return server;
- }
-
- /**
- * @return the applicationContext
- */
- public Context getApplicationContext() {
- return applicationContext;
- }
-}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java
deleted file mode 100644
index 3c432f3..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/java/net/forwardfire/vasc/demo/tech/core/ui/JApplication.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package net.forwardfire.vasc.demo.tech.core.ui;
-
-import java.awt.Dimension;
-import java.util.EventObject;
-
-
-import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
-
-import org.jdesktop.application.FrameView;
-import org.jdesktop.application.SingleFrameApplication;
-
-public class JApplication extends SingleFrameApplication {
-
- protected void startup() {
- addExitListener(new ShutdownManager());
- FrameView mainView = getMainView();
- mainView.setComponent(new JMainPanel());
- mainView.setMenuBar(new JMainPanelMenuBar());
- mainView.getFrame().setMinimumSize(new Dimension(1024-64,768-128));
- show(mainView);
- }
-
- static public JApplication getInstance() {
- return getInstance(JApplication.class);
- }
-
- class ShutdownManager implements ExitListener {
- public boolean canExit(EventObject e) {
- return true;
- }
- public void willExit(EventObject event) {
- VascTechDemo.getInstance().shutdown();
- }
- }
-}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml
deleted file mode 100644
index adc9b86..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-namespaces.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- Vasc namespace for the vasc tech demo
-
- vasc-tech-demo.eld
-
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld b/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld
deleted file mode 100644
index 0871f0c..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-core/src/main/resources/META-INF/vasc/vasc-tech-demo.eld
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/.project b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/.project
new file mode 100644
index 0000000..7e8109c
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/.project
@@ -0,0 +1,23 @@
+
+
+ vasc-demo-tech-ejb3
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml
new file mode 100644
index 0000000..6e87542
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml
@@ -0,0 +1,19 @@
+
+ 4.0.0
+
+ net.forwardfire.vasc.demo
+ vasc-demo-tech
+ 0.4.1-SNAPSHOT
+
+ vasc-demo-tech-ejb3
+ vasc-demo-tech-ejb3
+ vasc-demo-tech-ejb3
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
+
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuController.java
new file mode 100644
index 0000000..78f375e
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuController.java
@@ -0,0 +1,17 @@
+package net.forwardfire.vasc.demo.tech.ejb3.menu;
+
+import java.util.List;
+
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
+
+public interface VascMenuController {
+
+ List getFilteredMenuWeb(VascMenuWebType type);
+
+ List getFilteredMenuGroup();
+
+ List getFilteredMenu(String groupId);
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java
new file mode 100644
index 0000000..757abe4
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.ejb3.menu;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuComparator;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroupComparator;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
+
+/**
+ * MenuController Shows the menu for the user.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2012
+ */
+public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuControllerRemote {
+
+ private VascMenuWebComparator vascMenuWebComparator = null;
+ private VascMenuGroupComparator vascMenuGroupComparator = null;
+ private VascMenuComparator vascMenuComparator = null;
+
+ @Resource
+ private SessionContext session;
+
+
+ public VascMenuControllerImpl() {
+ vascMenuWebComparator = new VascMenuWebComparator();
+ vascMenuGroupComparator = new VascMenuGroupComparator();
+ vascMenuComparator = new VascMenuComparator();
+ }
+
+ public List fetchVascMenuWeb() {
+ List result = new ArrayList(50);
+ Connection connection = null;
+ try {
+ DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
+ connection = ds.getConnection();
+ Statement s = connection.createStatement();
+ s.execute("SELECT * FROM VASC_MENU_WEB");
+ ResultSet rs = s.getResultSet();
+ //int cols = rs.getMetaData().getColumnCount();
+ while (rs.next()) {
+ VascMenuWeb menu = new VascMenuWeb();
+ menu.setId(rs.getInt(1));
+ menu.setHref(rs.getString(2));
+ menu.setTitle(rs.getString(3));
+ menu.setTarget(rs.getString(4));
+ menu.setActive(rs.getBoolean(5));
+ menu.setRoles(rs.getString(6));
+ menu.setMenuOrder(rs.getInt(7));
+ menu.setMenuType(VascMenuWebType.valueOf(rs.getString(8)));
+ if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
+ continue;
+ }
+ result.add(menu);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (connection!=null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ return result;
+ }
+
+ public List fetchVascMenuGroup() {
+ List result = new ArrayList(50);
+ Connection connection = null;
+ try {
+ DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
+ connection = ds.getConnection();
+ Statement s = connection.createStatement();
+ s.execute("SELECT * FROM VASC_MENU_GROUP");
+ ResultSet rs = s.getResultSet();
+ while (rs.next()) {
+ VascMenuGroup menu = new VascMenuGroup();
+ menu.setId(rs.getString(1));
+ menu.setTitle(rs.getString(2));
+ menu.setActive(rs.getBoolean(3));
+ menu.setRoles(rs.getString(4));
+ menu.setMenuOrder(rs.getInt(5));
+ if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
+ continue;
+ }
+ result.add(menu);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (connection!=null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ return result;
+ }
+
+ public List fetchVascMenu() {
+ List result = new ArrayList(50);
+ Connection connection = null;
+ try {
+ DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
+ connection = ds.getConnection();
+ Statement s = connection.createStatement();
+ s.execute("SELECT * FROM VASC_MENU");
+ ResultSet rs = s.getResultSet();
+ while (rs.next()) {
+ VascMenu menu = new VascMenu();
+ menu.setId(rs.getInt(1));
+ menu.setVascEntryId(rs.getString(2));
+ menu.setTitle(rs.getString(3));
+ menu.setActive(rs.getBoolean(4));
+ menu.setRoles(rs.getString(5));
+ menu.setMenuOrder(rs.getInt(6));
+ menu.setMenuGroup(rs.getString(7));
+ if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
+ continue;
+ }
+ result.add(menu);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (connection!=null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ return result;
+ }
+
+
+
+ private DataSource getDataSource(String name) throws SQLException {
+ try {
+ Context initialContext = new InitialContext();
+ DataSource datasource = (DataSource)initialContext.lookup(name);
+ if ( datasource == null ) {
+ throw new SQLException("Cannot lookup datasource: "+name);
+ }
+ return datasource;
+ } catch ( NamingException e ) {
+ throw new SQLException("Cannot get connection " + e,e);
+ }
+ }
+
+ private boolean filterVascMenuRoles(Boolean active,String roles) {
+ if (active!=null && active==false) {
+ return false;
+ }
+ if (roles!=null && roles.isEmpty()==false) {
+ String[] rolesArray = roles.split(",");
+ for (String role:rolesArray) {
+ if (role.isEmpty()) {
+ continue;
+ }
+
+ if (session.isCallerInRole(role)==false) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public List getFilteredMenuGroup() {
+ List result = fetchVascMenuGroup();
+ for (VascMenuGroup group:result) {
+ group.setMenus(getFilteredMenu(group.getId()));
+ }
+ Collections.sort(result,vascMenuGroupComparator);
+ return result;
+ }
+
+ public List getFilteredMenu(String groupId) {
+ if (groupId==null) {
+ throw new NullPointerException("Can't filter on null groupId.");
+ }
+ List result = new ArrayList(15);
+ for (VascMenu menu:fetchVascMenu()) {
+ if (groupId.equals(menu.getMenuGroup())) {
+ result.add(menu);
+ }
+ }
+ Collections.sort(result,vascMenuComparator);
+ return result;
+ }
+
+ public List getFilteredMenuWeb(VascMenuWebType type) {
+ if (type==null) {
+ throw new NullPointerException("Can't filter on null type.");
+ }
+ List result = new ArrayList(15);
+ for (VascMenuWeb menu:fetchVascMenuWeb()) {
+ if (type.equals(menu.getMenuType())) {
+ result.add(menu);
+ }
+ }
+ Collections.sort(result,vascMenuWebComparator);
+ return result;
+ }
+
+ private List getMenuFiltered(VascMenuWebType type) {
+ return getFilteredMenuWeb(type);
+ }
+
+ public List getMenuBarLeft() {
+ return getMenuFiltered(VascMenuWebType.BAR_LEFT);
+ }
+
+ public List getMenuBarRight() {
+ return getMenuFiltered(VascMenuWebType.BAR_RIGHT);
+ }
+
+ public List getMenuBarBottom() {
+ return getMenuFiltered(VascMenuWebType.BAR_BOTTOM);
+ }
+
+ public List getMenuPageIndex() {
+ return getMenuFiltered(VascMenuWebType.PAGE_INDEX);
+ }
+
+ public List getMenuPageUserLeft() {
+ return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT);
+ }
+
+ public List getMenuPageUserRight() {
+ return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT);
+ }
+
+ public List getMenuPageAdmin() {
+ return getMenuFiltered(VascMenuWebType.PAGE_ADMIN);
+ }
+}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerLocal.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerLocal.java
new file mode 100644
index 0000000..a676bae
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerLocal.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.demo.tech.ejb3.menu;
+
+import javax.ejb.Local;
+
+@Local
+public interface VascMenuControllerLocal extends VascMenuController {
+
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerRemote.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerRemote.java
new file mode 100644
index 0000000..cba5607
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerRemote.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.demo.tech.ejb3.menu;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface VascMenuControllerRemote extends VascMenuController {
+
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java
similarity index 78%
rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java
rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java
index 4be8125..03a1d92 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenu.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java
@@ -20,7 +20,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package net.forwardfire.vasc.demo.tech.web.menu.model;
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
+
+import java.io.Serializable;
/**
* VascMenu stores menu item information.
@@ -28,16 +30,16 @@ package net.forwardfire.vasc.demo.tech.web.menu.model;
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
-public class VascMenu {
+public class VascMenu implements Serializable {
+ private static final long serialVersionUID = 5087600835051760512L;
private Integer id = null;
- private String href = null;
+ private String vascEntryId = null;
private String title = null;
- private String target = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
- private VascMenuType menuType = null;
+ private String menuGroup = null;
/**
* @return the id
@@ -54,19 +56,19 @@ public class VascMenu {
}
/**
- * @return the href
+ * @return the vascEntryId
*/
- public String getHref() {
- return href;
+ public String getVascEntryId() {
+ return vascEntryId;
}
-
+
/**
- * @param href the href to set
+ * @param vascEntryId the vascEntryId to set
*/
- public void setHref(String href) {
- this.href = href;
+ public void setVascEntryId(String vascEntryId) {
+ this.vascEntryId = vascEntryId;
}
-
+
/**
* @return the title
*/
@@ -81,20 +83,6 @@ public class VascMenu {
this.title = title;
}
- /**
- * @return the target
- */
- public String getTarget() {
- return target;
- }
-
- /**
- * @param target the target to set
- */
- public void setTarget(String target) {
- this.target = target;
- }
-
/**
* @return the active
*/
@@ -136,18 +124,18 @@ public class VascMenu {
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
-
+
/**
- * @return the menuType
+ * @return the menuGroup
*/
- public VascMenuType getMenuType() {
- return menuType;
+ public String getMenuGroup() {
+ return menuGroup;
}
-
+
/**
- * @param menuType the menuType to set
+ * @param menuGroup the menuGroup to set
*/
- public void setMenuType(VascMenuType menuType) {
- this.menuType = menuType;
+ public void setMenuGroup(String menuGroup) {
+ this.menuGroup = menuGroup;
}
}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java
similarity index 90%
rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java
rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java
index b87f0bb..a526dcb 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/VascMenuComparator.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java
@@ -20,19 +20,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package net.forwardfire.vasc.demo.tech.web.menu;
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
-import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu;
/**
- * VascMenuComparator orders the menu items.
+ * VascMenuComparator orders the menu group.
*
* @author Willem Cazander
- * @version 1.0 May 19, 2012
+ * @version 1.0 nov 17, 2012
*/
public class VascMenuComparator implements Serializable,Comparator {
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java
new file mode 100644
index 0000000..a3815cb
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * VascMenuGroup stores menu header item information.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Nov 21, 2012
+ */
+public class VascMenuGroup implements Serializable {
+
+ private static final long serialVersionUID = -9154803561816570868L;
+ private String id = null;
+ private String title = null;
+ private Boolean active = null;
+ private String roles = null;
+ private Integer menuOrder = null;
+ private List menus = null;
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the active
+ */
+ public Boolean getActive() {
+ return active;
+ }
+
+ /**
+ * @param active the active to set
+ */
+ public void setActive(Boolean active) {
+ this.active = active;
+ }
+
+ /**
+ * @return the roles
+ */
+ public String getRoles() {
+ return roles;
+ }
+
+ /**
+ * @param roles the roles to set
+ */
+ public void setRoles(String roles) {
+ this.roles = roles;
+ }
+
+ /**
+ * @return the menuOrder
+ */
+ public Integer getMenuOrder() {
+ return menuOrder;
+ }
+
+ /**
+ * @param menuOrder the menuOrder to set
+ */
+ public void setMenuOrder(Integer menuOrder) {
+ this.menuOrder = menuOrder;
+ }
+
+ /**
+ * @return the menus
+ */
+ public List getMenus() {
+ return menus;
+ }
+
+ /**
+ * @param menus the menus to set
+ */
+ public void setMenus(List menus) {
+ this.menus = menus;
+ }
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java
new file mode 100644
index 0000000..baeeaee
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+
+
+/**
+ * VascMenuGroupComparator orders the menu group.
+ *
+ * @author Willem Cazander
+ * @version 1.0 nov 17, 2012
+ */
+public class VascMenuGroupComparator implements Serializable,Comparator {
+
+ private static final long serialVersionUID = 386631856823832371L;
+
+ public int compare(VascMenuGroup m1, VascMenuGroup m2) {
+ if (m1.getMenuOrder()==null) {
+ return 1;
+ }
+ if (m2.getMenuOrder()==null) {
+ return -1;
+ }
+ return m1.getMenuOrder().compareTo(m2.getMenuOrder());
+ }
+}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWeb.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWeb.java
new file mode 100644
index 0000000..fc94501
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWeb.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
+
+import java.io.Serializable;
+
+/**
+ * VascMenu stores menu item information.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2012
+ */
+public class VascMenuWeb implements Serializable {
+
+ private static final long serialVersionUID = -4650021226959950898L;
+ private Integer id = null;
+ private String href = null;
+ private String title = null;
+ private String target = null;
+ private Boolean active = null;
+ private String roles = null;
+ private Integer menuOrder = null;
+ private VascMenuWebType menuType = null;
+
+ /**
+ * @return the id
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the href
+ */
+ public String getHref() {
+ return href;
+ }
+
+ /**
+ * @param href the href to set
+ */
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ /**
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the target
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * @param target the target to set
+ */
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ /**
+ * @return the active
+ */
+ public Boolean getActive() {
+ return active;
+ }
+
+ /**
+ * @param active the active to set
+ */
+ public void setActive(Boolean active) {
+ this.active = active;
+ }
+
+ /**
+ * @return the roles
+ */
+ public String getRoles() {
+ return roles;
+ }
+
+ /**
+ * @param roles the roles to set
+ */
+ public void setRoles(String roles) {
+ this.roles = roles;
+ }
+
+ /**
+ * @return the menuOrder
+ */
+ public Integer getMenuOrder() {
+ return menuOrder;
+ }
+
+ /**
+ * @param menuOrder the menuOrder to set
+ */
+ public void setMenuOrder(Integer menuOrder) {
+ this.menuOrder = menuOrder;
+ }
+
+ /**
+ * @return the menuType
+ */
+ public VascMenuWebType getMenuType() {
+ return menuType;
+ }
+
+ /**
+ * @param menuType the menuType to set
+ */
+ public void setMenuType(VascMenuWebType menuType) {
+ this.menuType = menuType;
+ }
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebComparator.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebComparator.java
new file mode 100644
index 0000000..27ed974
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebComparator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+
+
+/**
+ * VascMenuComparator orders the menu items.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2012
+ */
+public class VascMenuWebComparator implements Serializable,Comparator {
+
+ private static final long serialVersionUID = 386631856823832371L;
+
+ public int compare(VascMenuWeb m1, VascMenuWeb m2) {
+ if (m1.getMenuOrder()==null) {
+ return 1;
+ }
+ if (m2.getMenuOrder()==null) {
+ return -1;
+ }
+ return m1.getMenuOrder().compareTo(m2.getMenuOrder());
+ }
+}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java
similarity index 93%
rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java
rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java
index fc66fd0..05c3190 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/model/VascMenuType.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java
@@ -20,7 +20,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package net.forwardfire.vasc.demo.tech.web.menu.model;
+package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
/**
* VascMenuType defines all menu lists on page.
@@ -28,16 +28,12 @@ package net.forwardfire.vasc.demo.tech.web.menu.model;
* @author Willem Cazander
* @version 1.0 May 26, 2012
*/
-public enum VascMenuType {
+public enum VascMenuWebType {
BAR_LEFT,
BAR_RIGHT,
BAR_BOTTOM,
- MENU0,
- MENU1,
- MENU2,
-
PAGE_INDEX,
PAGE_USER_LEFT,
PAGE_USER_RIGHT,
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java
new file mode 100644
index 0000000..cdf90a5
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java
@@ -0,0 +1,21 @@
+package net.forwardfire.vasc.demo.tech.ejb3.user;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+
+public interface LoginUserController {
+
+ public String doClientLogin();
+
+ /*
+ public void doClientLogout();
+
+ public User getUser() throws Exception;
+
+ public List getClientRoles() throws Exception;
+ */
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java
new file mode 100644
index 0000000..e7f3473
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java
@@ -0,0 +1,57 @@
+package net.forwardfire.vasc.demo.tech.ejb3.user;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+@Stateless(name="loginUserController")
+public class LoginUserControllerImpl implements LoginUserControllerLocal,LoginUserControllerRemote {
+
+ @Resource
+ private SessionContext session;
+
+ /**
+ * Tests for the login role
+ */
+ @RolesAllowed("login")
+ public String doClientLogin() {
+
+ String name = session.getCallerPrincipal().getName();
+ return name;
+
+ /*
+ User u = null;
+ try {
+ u = getUser();
+ } catch (Exception e) {
+ throw new IllegalStateException("Could not lookup showplanner user from username: "+session.getCallerPrincipal().getName());
+ }
+ UserSession us = new UserSession();
+ us.setLoginDate(new Date());
+ us.setLogoutDate(null); // set when doing doClientLogout();
+
+ try {
+ Query q2 = xtesManager.getQuery("users.xml", "getUserSessionStatusByStatusKey");
+ q2.setQueryParameter("status_key", "success");
+ q2.setProperty("limit", 1);
+ UserSessionStatus userSessionStatus = (UserSessionStatus)xtesManager.executeObject(q2);
+ us.setUserSessionStatus(userSessionStatus);
+ } catch (Exception e) {
+ throw new IllegalStateException("Could not lookup session status of success.");
+ }
+
+ // current_time_in_secs + str_to_int(username)*10E20
+ long timeSS = us.getLoginDate().getTime();
+ int userSS = hashUserName(u.getUsername());
+ int modSS = 10230;
+ long sessionId = timeSS+userSS*modSS;
+ us.setSessionId(sessionId);
+ //System.out.println("Created sessionId: timeSS: "+timeSS+" userSS: "+userSS+" modSS: "+modSS);
+
+ us.setUser(u);
+ entityManager.persist(us);
+ return u.getUsername();
+ */
+ }
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java
new file mode 100644
index 0000000..0e150d4
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.demo.tech.ejb3.user;
+
+import javax.ejb.Local;
+
+@Local
+public interface LoginUserControllerLocal extends LoginUserController {
+
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java
new file mode 100644
index 0000000..44cb392
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java
@@ -0,0 +1,8 @@
+package net.forwardfire.vasc.demo.tech.ejb3.user;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface LoginUserControllerRemote extends LoginUserController {
+
+}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/resources/META-INF/ejb-jar.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/resources/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..2214d87
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,17 @@
+
+
+
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml
index 4f3e269..406404e 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml
@@ -3,7 +3,7 @@
vasc-demo-tech
net.forwardfire.vasc.demo
- 0.3.5-SNAPSHOT
+ 0.4.1-SNAPSHOT
..
vasc-demo-tech-web
@@ -33,18 +33,32 @@
${project.version}
provided
+
+ net.forwardfire.vasc.demo
+ vasc-demo-tech-ejb3
+ ${project.version}
+ provided
+
+
javax
javaee-api
${javaee-api.version}
provided
-
- org.glassfish
- javax.faces
- ${javax.faces.version}
- provided
-
org.richfaces.ui
richfaces-components-ui
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java
index 629b1cc..26d5cf5 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/ExportController.java
@@ -18,7 +18,7 @@ public class ExportController {
public ExportController() {
try {
JndiVascControllerProvider p = new JndiVascControllerProvider();
- p.setJndiName("java:comp/env/vasc/DemoVascController");
+ p.setJndiName("java:comp/env/vasc/server-tech");
vascController = p.getVascController();
} catch (Exception e) {
e.printStackTrace();
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java
new file mode 100644
index 0000000..76f6464
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2009-2012 forwardfire.net All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.forwardfire.vasc.demo.tech.web.beans;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
+
+/**
+ * MenuController Shows the menu for the user.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2012
+ */
+public class MenuController implements Serializable {
+
+ private static final long serialVersionUID = -6820749860984575869L;
+ private List userVascMenu = null;
+ private UserController userController = null;
+ private VascMenuController vascMenuController = null;
+
+ private void init() {
+ // RM ME
+ if (vascMenuController==null) {
+ try {
+ InitialContext ctx = new InitialContext();
+ vascMenuController = (VascMenuController)ctx.lookup("java:app/demo/vascMenuController");
+ } catch (NamingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private List getMenuFiltered(VascMenuWebType type) {
+ init();
+ return vascMenuController.getFilteredMenuWeb(type);
+ }
+
+ public List getVascMenuGroup() {
+ init();
+ List result = vascMenuController.getFilteredMenuGroup();
+ return result;
+ }
+
+ public List getMenuBarLeft() {
+ return getMenuFiltered(VascMenuWebType.BAR_LEFT);
+ }
+
+ public List getMenuBarRight() {
+ return getMenuFiltered(VascMenuWebType.BAR_RIGHT);
+ }
+
+ public List getMenuBarBottom() {
+ return getMenuFiltered(VascMenuWebType.BAR_BOTTOM);
+ }
+
+ public List getMenuPageIndex() {
+ return getMenuFiltered(VascMenuWebType.PAGE_INDEX);
+ }
+
+ public List getMenuPageUserLeft() {
+ return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT);
+ }
+
+ public List getMenuPageUserRight() {
+ return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT);
+ }
+
+ public List getMenuPageAdmin() {
+ return getMenuFiltered(VascMenuWebType.PAGE_ADMIN);
+ }
+
+
+ /**
+ * @return the userController
+ */
+ public UserController getUserController() {
+ return userController;
+ }
+
+ /**
+ * @param userController the userController to set
+ */
+ public void setUserController(UserController userController) {
+ this.userController = userController;
+ }
+}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java
index 2387795..7985bf1 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java
@@ -24,11 +24,15 @@ package net.forwardfire.vasc.demo.tech.web.beans;
import java.io.IOException;
import java.io.Serializable;
+import java.util.Properties;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
+import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.servlet.http.HttpSession;
+import net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserController;
import net.forwardfire.vasc.demo.tech.web.models.WebUser;
/**
@@ -71,6 +75,27 @@ public class UserController implements Serializable {
user.setFullName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());
user.setLoginName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(WEB_USER_SESSION_KEY, user);
+
+ /*
+ try {
+ Properties properties = new Properties();
+ properties.setProperty (Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");
+ InitialContext ic = new InitialContext(properties);
+ Object object = ic.lookup("java:app/demo/vascServiceManager");
+ System.out.println("ob: "+object);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try {
+ InitialContext ic = new InitialContext();
+ LoginUserController object = (LoginUserController)ic.lookup("java:app/demo/loginUserController");
+ System.out.println("ob: "+object);
+ System.out.println("login: "+object.doClientLogin());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ */
return user;
}
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java
index 2fe406c..186788b 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/NoneLoadStyleResourceEventListener.java
@@ -18,8 +18,8 @@ import javax.faces.event.SystemEventListener;
import org.richfaces.resource.ResourceKey;
-import com.sun.faces.renderkit.html_basic.ScriptRenderer;
-import com.sun.faces.renderkit.html_basic.StylesheetRenderer;
+//import com.sun.faces.renderkit.html_basic.ScriptRenderer;
+//import com.sun.faces.renderkit.html_basic.StylesheetRenderer;
/**
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java
index 404805f..2002e0a 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/faces/UrlRewriteConfigurationProvider.java
@@ -36,7 +36,7 @@ public class UrlRewriteConfigurationProvider extends HttpConfigurationProvider {
return ConfigurationBuilder.begin()
- .addRule(Join.path("/yoyo").to("/html/index.jsf"))
+ //.addRule(Join.path("/yoyo").to("/html/index.jsf"))
.defineRule()
.when(Direction.isInbound().
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java
deleted file mode 100644
index ed05830..0000000
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/menu/MenuController.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2009-2012 forwardfire.net All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.forwardfire.vasc.demo.tech.web.menu;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-import net.forwardfire.vasc.demo.tech.web.beans.UserController;
-import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu;
-import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenuType;
-
-/**
- * MenuController Shows the menu for the user.
- *
- * @author Willem Cazander
- * @version 1.0 May 19, 2012
- */
-public class MenuController implements Serializable {
-
- private static final long serialVersionUID = -6820749860984575869L;
- private List userVascMenu = null;
- private VascMenuComparator vascMenuComparator = null;
- private UserController userController = null;
-
-
- public List fetchVascMenu() {
- //if (userVascMenu!=null) {
- // return userVascMenu;
- //}
- vascMenuComparator = new VascMenuComparator();
- userVascMenu = new ArrayList(50);
-
- /*
- MetaModelDataContextJndiDataSource dsFactory = new MetaModelDataContextJndiDataSource();
- dsFactory.setJndiName("java:comp/env/jdbc/vascDemoDS");
- DataContext ds = dsFactory.getDataContext();
- Table table = ds.getDefaultSchema().getTableByName("vasc_menu");
- DataSet data = ds.query().from(table).select(table.getColumns()).execute();
- List result = new ArrayList(50);
- Iterator i = data.iterator();
- while (i.hasNext()) {
- Row row = i.next();
- }*/
-
-
- Connection connection = null;
- try {
- DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS");
- connection = ds.getConnection();
- Statement s = connection.createStatement();
- s.execute("SELECT * FROM VASC_MENU");
- ResultSet rs = s.getResultSet();
- //int cols = rs.getMetaData().getColumnCount();
- while (rs.next()) {
- VascMenu menu = new VascMenu();
- menu.setId(rs.getInt(1));
- menu.setHref(rs.getString(2));
- menu.setTitle(rs.getString(3));
- menu.setTarget(rs.getString(4));
- menu.setActive(rs.getBoolean(5));
- menu.setRoles(rs.getString(6));
- menu.setMenuOrder(rs.getInt(7));
- menu.setMenuType(VascMenuType.valueOf(rs.getString(8)));
- if (filterVascMenuRoles(menu)==false) {
- continue;
- }
- userVascMenu.add(menu);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (connection!=null) {
- try {
- connection.close();
- } catch (Exception e) {
- }
- }
- }
-
- return userVascMenu;
- }
-
- private DataSource getDataSource(String name) throws SQLException {
- try {
- Context initialContext = new InitialContext();
- DataSource datasource = (DataSource)initialContext.lookup(name);
- if ( datasource == null ) {
- throw new SQLException("Cannot lookup datasource: "+name);
- }
- return datasource;
- } catch ( NamingException e ) {
- throw new SQLException("Cannot get connection " + e,e);
- }
- }
-
- private boolean filterVascMenuRoles(VascMenu menu) {
- if (menu.getActive()!=null && menu.getActive()==false) {
- return false;
- }
- if (menu.getRoles()!=null && menu.getRoles().isEmpty()==false) {
- String[] roles = menu.getRoles().split(",");
- for (String role:roles) {
- if (role.isEmpty()) {
- continue;
- }
- if (userController.hasUserRole(role)==false) {
- return false;
- }
- }
- }
- return true;
- }
-
- private List getMenuFiltered(VascMenuType type) {
- if (type==null) {
- throw new NullPointerException("Can't filter on null type.");
- }
- List result = new ArrayList(15);
- for (VascMenu menu:fetchVascMenu()) {
- if (type.equals(menu.getMenuType())) {
- result.add(menu);
- }
- }
- Collections.sort(result,vascMenuComparator);
- return result;
- }
-
- public List getMenuBarLeft() {
- return getMenuFiltered(VascMenuType.BAR_LEFT);
- }
-
- public List getMenuBarRight() {
- return getMenuFiltered(VascMenuType.BAR_RIGHT);
- }
-
- public List getMenuBarBottom() {
- return getMenuFiltered(VascMenuType.BAR_BOTTOM);
- }
-
- public List getMenuPageIndex() {
- return getMenuFiltered(VascMenuType.PAGE_INDEX);
- }
-
- public List getMenuPageUserLeft() {
- return getMenuFiltered(VascMenuType.PAGE_USER_LEFT);
- }
-
- public List getMenuPageUserRight() {
- return getMenuFiltered(VascMenuType.PAGE_USER_RIGHT);
- }
-
- public List getMenuPageAdmin() {
- return getMenuFiltered(VascMenuType.PAGE_ADMIN);
- }
-
- public List getMenu0() {
- return getMenuFiltered(VascMenuType.MENU0);
- }
-
- public List getMenu1() {
- return getMenuFiltered(VascMenuType.MENU1);
- }
-
- public List getMenu2() {
- return getMenuFiltered(VascMenuType.MENU2);
- }
-
- /**
- * @return the userController
- */
- public UserController getUserController() {
- return userController;
- }
-
- /**
- * @param userController the userController to set
- */
- public void setUserController(UserController userController) {
- this.userController = userController;
- }
-}
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java
index dcb0a70..0bd1d11 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java
@@ -36,8 +36,8 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
+import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
import net.forwardfire.vasc.demo.tech.web.beans.UserController;
-import net.forwardfire.vasc.demo.tech.web.menu.VascMenuComparator;
/**
* MenuController Shows the menu for the user.
diff --git a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-namespaces.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/resources/META-INF/vasc-ejb3.xml
similarity index 50%
rename from vasc-xpql/src/main/resources/META-INF/vasc/vasc-namespaces.xml
rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/resources/META-INF/vasc-ejb3.xml
index d437c97..fd18d45 100644
--- a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-namespaces.xml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/resources/META-INF/vasc-ejb3.xml
@@ -2,7 +2,7 @@
- Vasc namespace for the vasc-xpql backend
+ Files to load
- vasc-xpql.eld
+ openejb:Resource/vasc/server-tech
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties
index 2ed6100..8ff4563 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/META-INF/jawr.properties
@@ -12,8 +12,8 @@ jawr.debug.overrideKey=jawr_debug
jawr.config.reload.refreshKey=jawr_refresh
# Development mode flags
-jawr.debug.on=true
-jawr.config.reload.interval=3
+#jawr.debug.on=true
+#jawr.config.reload.interval=3
#
@@ -42,6 +42,7 @@ jawr.js.bundle.skin-switcher.mappings=skinSwitcher:switcher.js
jawr.js.bundle.vasc.mappings=/js/vasc-jsf.js
jawr.js.bundle.richfaces.mappings=\
+jar:/META-INF/resources/javax.faces/jsf.js,\
jar:/META-INF/resources/jquery.js,\
jar:/META-INF/resources/jquery.focus.js,\
jar:/META-INF/resources/jquery.position.js,\
@@ -52,7 +53,9 @@ jar:/META-INF/resources/richfaces-queue.js,\
jar:/META-INF/resources/richfaces-event.js,\
jar:/META-INF/resources/richfaces-selection.js,\
jar:/META-INF/resources/richfaces-jsf-event.js,\
-jar:/META-INF/resources/richfaces-jsf-log.js
+jar:/META-INF/resources/richfaces-jsf-log.js,\
+jar:/META-INF/resources/org.richfaces/datatable.js
+
jawr.js.bundle.richfaces-atmosphere.mappings=\
jar:/META-INF/resources/net.java.dev.atmosphere/jquery-atmosphere.js
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml
new file mode 100644
index 0000000..0bfee7e
--- /dev/null
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml
@@ -0,0 +1,31 @@
+
+
+
+ vascServiceManager
+ net.forwardfire.vasc.ejb3.VascServiceManagerLocal
+ net.forwardfire.vasc.ejb3.VascServiceManagerRemote
+ net.forwardfire.vasc.ejb3.VascServiceManagerImpl
+ Stateless
+ Container
+
+
+ loginUserController
+ net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerLocal
+ net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerRemote
+ net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerImpl
+ Stateless
+ Container
+
+
+ vascMenuController
+ net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerLocal
+ net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerRemote
+ net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerImpl
+ Stateless
+ Container
+
+
+
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml
index 0c0b3db..611e025 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml
@@ -15,9 +15,9 @@
en
- net.forwardfire.vasc.demo.tech.web.faces.NoneLoadStyleResourceEventListener
- javax.faces.event.PreRenderViewEvent
-
+ net.forwardfire.vasc.demo.tech.web.faces.NoneLoadStyleResourceEventListener
+ javax.faces.event.PreRenderViewEvent
+
@@ -37,7 +37,7 @@
Controls the display of the dynamic menus.
menuController
- net.forwardfire.vasc.demo.tech.web.menu.MenuController
+ net.forwardfire.vasc.demo.tech.web.beans.MenuController
session
userController
@@ -52,14 +52,14 @@
session
-
+
- jawr.JavascriptBundle
+ jawr.JavascriptBundle
net.jawr.web.taglib.jsf.JavascriptBundleTag
jawr.CSSBundle
net.jawr.web.taglib.jsf.CSSBundleTag
-
+
\ No newline at end of file
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml
index 224f8ed..a309f4a 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-vasc.xhtml
@@ -62,22 +62,32 @@
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
@@ -92,9 +102,8 @@
-
+
@@ -107,22 +116,25 @@
-
+
-
+
-
+
@@ -176,74 +188,76 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
+
+
-
-
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml
index a26a050..318dc70 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-decorator.xhtml
@@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
- xmlns:rich="http://richfaces.org/rich"
>
-
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml
index a22b473..452b250 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml
@@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
- xmlns:rich="http://richfaces.org/rich"
>
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml
index 6de2e35..8312851 100644
--- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml
+++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-header.xhtml
@@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
- xmlns:rich="http://richfaces.org/rich"
>