I think he may have been using @InjectObject and not @InjectState, since the exception said "....InjectObject(value=cryptoService)."  It was trying to use the object provider for the "cryptoService" prefix (which isn't defined).  Are you sure you had @InjectState and not @InjectObject in your source code?
 

 
On 10/19/06, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
The problem as described was the case: "cryptoService" vs. "CryptoService".  But James is correct, this isn't an application state object, its a service that has some internal state, and should use the "threaded" service model, or should be recoded to store the internal state (the key) somewhere else.  For example I would approach this problem as a factory of InputStreams and OutputStreams that perform the decoding and encoding.


On 10/19/06, James Carman <[EMAIL PROTECTED] > wrote:
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=""





--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Reply via email to