Guys,

Thanks for the reply. Nice to hear from the top. I will give those tips a shot this weekend... as well as try to keep my posts trim and concise.

I use to bootstrap/wire in my own singletons on app-startup to the sevlet context years back when developing struts apps. I liked struts dynabeans and beanutils but being a veteran widget person dating back to the x11 days, I was sold on the massive support for widgets in tapestry and it's de-coupled nature..

I like the idea of hivemind but still blurry on one thing. And if someone could expand on this I would appreciate it.....

Services are one thing... beit local or distributed...

But to make a service an actual part of the anatomy of a page architecture??? Or make a service the actual participant of the rendering of a page... or multiple pages. I am still trying to acquire a taste for this and wondering why and for what would I want to do something like this. I think this has been segregated historically.

Upon reading the reply to my post it now kinda dawned on me that... well hey... it might be nice to have a Crypto Service injectable to any page throughout the app so that one could encypher/decypher any text they want to on the fly on the spot. After thinking about it, it may be desirable to persist that state to a database so the algorithm/key will not be re-generated and used erroneously.

SO I am trying to think of more reasons as to why I would want to make services part of this anatomy.

If someone could list some reasons as to why one would want to integrate services as part of the architecture of tapestry pages/content that would help alot about where one could go with this.

I believe alot of the traditional/current themes have been blurred out and tapestry prompts the user to operate/develop with a new concept of thinking.

- cheers





Best regards
Ken Colassi





From: "James Carman" <[EMAIL PROTECTED]>
To: user@hivemind.apache.org, [EMAIL PROTECTED]
Subject: Re: CryptoService in hivemind
Date: Thu, 19 Oct 2006 20:13:29 -0400

Is this object supposed to be a "state" object or a "service" object?  It's
called a service, but you're trying to use it as an ASO (application state
object).  This is somewhat of a Tapestry question and should go to the
tapestry user list, but I'm familiar enough with Tapestry to help you I
think.  Since you're using tap 4.1.x, you can just create a service point
(the website docs cover this) for your CryptoService interface and Tapestry
will automatically inject (or "autowire") it into your components/pages by
just declaring this:

public abstract CryptoService getCryptoService();



On 10/19/06, Ken nashua <[EMAIL PROTECTED]> wrote:

Folks,

My CryptoService adheres to my own unique interface. So I have no need to
associate or latch onto anything HLS created.

But I did try to bootstrap it into hivemind as an ASO
    <contribution configuration-id="tapestry.state.ApplicationObjects">
        <state-object name="cryptoService" scope="application">
            <create-instance class="common.crypto.CryptoService"/>
        </state-object>
    </contribution>

but upon operating my annotation in java

        @InjectState("cryptoService")
        public abstract CryptoService getCryptoService();

The thing quits with an exception stating that the object was not
formatted

[ +/- ] Exception: Error: An error occured processing annotation
@org.apache.tapestry.annotations.InjectObject(value=cryptoService) of
public
abstract common.crypto.CryptoService proto.Login.getCryptoService():
Error:
Object provider selector 'cryptoService' is not properly formatted.


But then I found other hivemind threads that talk about HiveUtils saying
that there is no way to treat any pojo like above and we should be doing
this...

    <contribution configuration-id="hiveutils.ObjectBuilderObjects">
        <object name="CryptoService" cached="true"
class="common.crypto.CryptoService">
<inject name="entityService" object="service:EntityService" />
        </object>
    </contribution>
    <contribution configuration-id="tapestry.state.ApplicationObjects">
        <state-object name="cryptoService" scope="application">
            <invoke-factory object="object:CryptoService" />
        </state-object>
    </contribution>

But that failed due to non-existent config id of some sort...

Can anyone tell me how to get my basic pojo+unique interface into
hivemind?

Using tap-4.1.1

Thanks in advance

Best regards
Ken

---> Here is the interface
package common.crypto;

public interface ICrypto {

        public SecretKey generateKey();

        public Cipher createCipher();

        public String enCipher(String value);

        public String deCipher(String value);
}

---> Here is the implementation
package common.crypto;

public class CryptoService implements Serializable, ICrypto,
StateObjectFactory {
        private Cipher cipher;

        private SecretKey key;

        public CryptoService() {
                generateKey();
                createCipher();
        }

        public Object createStateObject() {
                return new CryptoService();
        }

        public SecretKey generateKey() {
                try {
                        KeyGenerator keygen = KeyGenerator.getInstance
("DES");
                        key = keygen.generateKey();
                } catch (NoSuchAlgorithmException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                }
                return key;
        }

        public Cipher createCipher() {
                try {
                        cipher = Cipher.getInstance
("DES/ECB/PKCS5Padding");
                } catch (NoSuchAlgorithmException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                } catch (NoSuchPaddingException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                }
                return cipher;
        }

        public String enCipher(String value) {
                String result = "";
                try {
                        cipher.init(Cipher.ENCRYPT_MODE, key);
                        byte[] text = cipher.doFinal(value.getBytes());
                        result = new String(text.toString());
                } catch (InvalidKeyException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                } catch (BadPaddingException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                } catch (IllegalBlockSizeException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                }
                return result;
        }

        public String deCipher(String value) {
                String result = "";
                try {
                        cipher.init(Cipher.DECRYPT_MODE, key);

                        // Decrypt the ciphertext
                        byte[] text = cipher.doFinal(value.getBytes());
                        result = new String(text.toString());
                } catch (InvalidKeyException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                } catch (BadPaddingException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                } catch (IllegalBlockSizeException ex) {
System.out.println(ExceptionFormatter.logException
(ex));
                }
                return result;
        }

        public Cipher getCipher() {
                return cipher;
        }

        public void setCipher(Cipher cipher) {
                this.cipher = cipher;
        }

        public SecretKey getKey() {
                return key;
        }

        public void setKey(SecretKey key) {
                this.key = key;
        }
}

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces

http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us



_________________________________________________________________
Add a Yahoo! contact to Windows Live Messenger for a chance to win a free trip! http://www.imagine-windowslive.com/minisites/yahoo/default.aspx?locale=en-us&hmtagline

Reply via email to