notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2134 - in development/planet/users/niclas/iso8583: . api api/src/main/net/dpml/iso8583 api/src/main/net/dpml/iso8583/authorization api/src/main/net/dpml/iso8583/data elements elements/src elements/src/main elements/src/main/net elements/src/main/net/dpml elements/src/main/net/dpml/iso8583 elements/src/main/net/dpml/iso8583/data elements/src/main/net/dpml/iso8583/data/elements elements/src/main/net/dpml/iso8583/data/manager
- From: niclas AT hedhman.org
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2134 - in development/planet/users/niclas/iso8583: . api api/src/main/net/dpml/iso8583 api/src/main/net/dpml/iso8583/authorization api/src/main/net/dpml/iso8583/data elements elements/src elements/src/main elements/src/main/net elements/src/main/net/dpml elements/src/main/net/dpml/iso8583 elements/src/main/net/dpml/iso8583/data elements/src/main/net/dpml/iso8583/data/elements elements/src/main/net/dpml/iso8583/data/manager
- Date: Fri, 25 Mar 2005 15:37:01 -0500
Author: niclas AT hedhman.org
Date: Fri Mar 25 15:37:00 2005
New Revision: 2134
Added:
development/planet/users/niclas/iso8583/api/build.xml (contents, props
changed)
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/TimeDate.java
(contents, props changed)
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElement.java
(contents, props changed)
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElementManager.java
(contents, props changed)
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/NoSuchDataElementException.java
(contents, props changed)
development/planet/users/niclas/iso8583/elements/
development/planet/users/niclas/iso8583/elements/build.xml (contents,
props changed)
development/planet/users/niclas/iso8583/elements/src/
development/planet/users/niclas/iso8583/elements/src/main/
development/planet/users/niclas/iso8583/elements/src/main/net/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/PrimaryAccountNumber.java
(contents, props changed)
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/TEMPLATE.tjava
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/manager/
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/manager/DefaultManager.java
(contents, props changed)
Modified:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationAdvice.java
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationRequest.java
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationResponse.java
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationService.java
development/planet/users/niclas/iso8583/index.xml
Log:
Starting to change to another pattern, to provide better separation of
concerns.
Added: development/planet/users/niclas/iso8583/api/build.xml
==============================================================================
--- (empty file)
+++ development/planet/users/niclas/iso8583/api/build.xml Fri Mar 25
15:37:00 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2005 Niclas Hedhman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="dpml-iso8583-api" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+>
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+</project>
Added:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/TimeDate.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/TimeDate.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.iso8583;
+
+import java.util.Date;
+
+public interface TimeDate
+{
+ Date getJavaDate();
+
+ String format();
+
+}
+
Modified:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationAdvice.java
==============================================================================
---
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationAdvice.java
(original)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationAdvice.java
Fri Mar 25 15:37:00 2005
@@ -18,6 +18,9 @@
package net.dpml.iso8583.authorization;
+import net.dpml.iso8583.Amount;
+import net.dpml.iso8583.TimeDate;
+
public interface AuthorizationAdvice
{
// Mandatory if the Primary account number conforms to International
Standard ISO 7812.
@@ -30,19 +33,19 @@
Amount getAmountTransaction();
// 30 Mandatory in real time transactions.
- Date getDateAndTimeTransmission();
+ TimeDate getDateAndTimeTransmission();
// Mandatory
String getSystemsTraceAuditNumber();
// Mandatory
- Date getDateAndTimeLocalTransaction();
+ TimeDate getDateAndTimeLocalTransaction();
// 02 Mandatory if information is available and not read electronically from
the card, e.g. manual card entry.
- Date getDateEffective();
+ TimeDate getDateEffective();
// 02 Mandatory if information is available and not read electronically from
the card, e.g. manual card entry.
- Date getDateExpiration();
+ TimeDate getDateExpiration();
// 33 Mandatory once assigned, in all subsequent messages in this
transaction (e.g. responses, acknowledgements, advices, notifications and
instructions) and all messages in related transactions (e.g. financial
presentments, chargebacks, reversals and retrievals). Shall contain the same
value as original assigned.
String getTransactionLifeCycleIdentificationData();
Modified:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationRequest.java
==============================================================================
---
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationRequest.java
(original)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationRequest.java
Fri Mar 25 15:37:00 2005
@@ -18,6 +18,10 @@
package net.dpml.iso8583.authorization;
+
+import net.dpml.iso8583.Amount;
+import net.dpml.iso8583.TimeDate;
+
public interface AuthorizationRequest
{
// For 100/101 message types
@@ -32,19 +36,19 @@
Amount getAmountTransaction();
// 30
- Date getDateAndTimeTransmission();
+ TimeDate getDateAndTimeTransmission();
// Mandatory
String getSystemsTraceAuditNumber();
// Mandatory
- Date getDateAndTimeLocalTransaction();
+ TimeDate getDateAndTimeLocalTransaction();
// 02
- Date getDateEffective();
+ TimeDate getDateEffective();
// 02
- Date getDateExpiration();
+ TimeDate getDateExpiration();
// 33
String getTransactionLifeCycleIdentificationData();
Modified:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationResponse.java
==============================================================================
---
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationResponse.java
(original)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationResponse.java
Fri Mar 25 15:37:00 2005
@@ -18,6 +18,9 @@
package net.dpml.iso8583.authorization;
+import net.dpml.iso8583.Amount;
+import net.dpml.iso8583.TimeDate;
+
public interface AuthorizationResponse
{
// For 110/130 message types
@@ -27,17 +30,17 @@
Amount getAmountTransaction();
- Date getDateAndTimeTransmission();
+ TimeDate getDateAndTimeTransmission();
String getSystemsTraceAuditNumber();
- Date getDateAndTimeLocalTransaction();
+ TimeDate getDateAndTimeLocalTransaction();
String getMessageErrorIndicator();
String getTransactionLifeCycleIdentificationData();
- Date getDateReconciliation();
+ TimeDate getDateReconciliation();
String getReconciliationIndicator();
Modified:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationService.java
==============================================================================
---
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationService.java
(original)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/authorization/AuthorizationService.java
Fri Mar 25 15:37:00 2005
@@ -18,6 +18,8 @@
package net.dpml.iso8583.authorization;
+import org.jpos.iso.ISOException;
+
/**
* @metro.service type="net.dpml.iso8583.api.AuthorizationService"
*/
Added:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElement.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElement.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.dpml.iso8583.data;
+
+import org.jpos.iso.ISOException;
+import org.jpos.iso.ISOMsg;
+
+/** Interface for a data element in ISO-8583 messages.
+ * <p>
+ * <code>DataElement</code> instances should not be looked up directly.
+ * Instead, the <code>DataElementManager</code> will provide a separate
+ * <code>lookup</code> method for client use, which will ensure wrapping
+ * in a thread-based session, to enable thread-safety.
+ * </p>
+ */
+public interface DataElement
+{
+ /** Instructs the DataElement to populate the ISOMsg object.
+ * <p>
+ * <code>DataElement</code> implementations are responsible to know
+ * which field (a.k.a. bit) that it should populate in the
+ * <code>ISOMsg</code> structure. The caller must know whether the
+ * field is required or not, and if the <code>DataElement</code> has
+ * not been properly set, either in the course of the session or as
+ * part of its initialization, it should throw an ISOException.
+ * </p>
+ * <p>
+ * If the <code>DataElement</code> is nested, it is responsible for
+ * calling the <code>populate</code> method for each of the composite
+ * <code>DataElements</code>.
+ * </p>
+ * @param message the <code>ISOMsg</code> instance to populate with the
+ * value of the <code>DataElement</code>.
+ * @param required if true, the <code>DataElement</code> must make sure
+ * that its value object has been set during the session.
+ *
+ * @exception ISOException if the ISOMsg can not be populated.
+ */
+ void populate( ISOMsg message, boolean required )
+ throws ISOException;
+
+ /** Returns the value object of the DataElement.
+ * <p>
+ * Each <code>DataElement</code> implementation defines what the value
+ * object is, and whether a default value can be
configured/parameterized
+ * or must be set during the session.
+ * </p>
+ *
+ * @return the value object of the DataElement, which is the same object
+ * that has previously been set with the <code>set()</code>
+ * method.
+ */
+ Object get();
+
+ /** Sets the value object of the DataElement.
+ * <p>
+ * Each <code>DataElement</code> implementation defines what the value
+ * object is, and whether a default value can be
configured/parameterized
+ * or must be set during the session.
+ * </p>
+ * <p>
+ * The provided argument must be of the correct type, and be within
+ * its specification defined bounds, or an <code>IllegalArgumentException
+ * </code> will be thrown.
+ * </p>
+ * @exception IllegalArgumentException if the provided <code>value</code>
+ * argument is of the wrong class, contains illegal values,
+ * or is null.
+ */
+ void set( Object value )
+ throws IllegalArgumentException;
+
+}
Added:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElementManager.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/DataElementManager.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.iso8583.data;
+
+/** DataElements needs to be coordinated between different requesting
+ * threads, and the DataElementManager is required to provide this
+ * functionality.
+ *
+ * @metro.service type="net.dpml.iso8583.data.DataElementManager"
+ */
+public interface DataElementManager
+{
+ /** Called to indicate that the current thread is starting a new
+ * session.
+ */
+ void beginSession();
+
+ /** Called to indicate that the current thread is done with the
+ * session and all data elements can be released.
+ */
+ void doneSession();
+
+ /** Requests a <code>DataElement</code> of the provided type.
+ * <p>
+ * The provided type is the class name of the <code>DataElement</code>
+ * implementation, either with or without the package name. For
+ * better typesafety, you should use the following pattern;
+ * <code><pre>
+ * private DataElementManager m_dem;
+ * :
+ * :
+ * DataElement account = m_dem.lookup(
PrimaryAccountNumber.class.getName() );
+ * </pre></code>
+ *
+ * @exception NoSuchDataElementException if the requested DataElement is
not
+ * available in the system.
+ */
+ DataElement lookup( String type )
+ throws NoSuchDataElementException;
+}
\ No newline at end of file
Added:
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/NoSuchDataElementException.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/api/src/main/net/dpml/iso8583/data/NoSuchDataElementException.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.iso8583.data;
+
+public class NoSuchDataElementException extends Exception
+{
+ public NoSuchDataElementException( String message )
+ {
+ super( message );
+ }
+}
Added: development/planet/users/niclas/iso8583/elements/build.xml
==============================================================================
--- (empty file)
+++ development/planet/users/niclas/iso8583/elements/build.xml Fri Mar 25
15:37:00 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2005 Niclas Hedhman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="dpml-iso8583-elements" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+>
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+</project>
Added:
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/PrimaryAccountNumber.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/PrimaryAccountNumber.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.dpml.iso8583.data.elements;
+
+
+import net.dpml.iso8583.data.DataElement;
+
+import net.dpml.logging.Logger;
+
+import org.jpos.iso.ISOException;
+import org.jpos.iso.ISOMsg;
+
+/** Interface for a data element in ISO-8583 messages.
+ *
+ * @metro.component name="primary-account-number" lifestyle="transient"
+ * @metro.service type="net.dpml.iso8583.data.DataElement"
+ */
+public class PrimaryAccountNumber
+ implements DataElement
+{
+ private String m_account;
+ private Logger m_logger;
+
+ public PrimaryAccountNumber( Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ public void populate( ISOMsg message, boolean required )
+ throws ISOException
+ {
+ if( m_logger.isDebugEnabled() )
+ {
+ m_logger.debug( "populate: " + message );
+ }
+
+ if( required && m_account == null )
+ {
+ throw new ISOException( "Required data element has not been set:
PrimaryAccountNumber" );
+ }
+ message.set( 2, m_account );
+ }
+
+ public void set( Object value )
+ throws IllegalArgumentException
+ {
+ if( value instanceof String == false )
+ {
+ throw new IllegalArgumentException( "Value must be a
java.lang.String: " + value );
+ }
+
+ if( value == null )
+ {
+ throw new IllegalArgumentException( "Null argument not allowed."
);
+ }
+ String number = (String) value;
+ if( number.length() > 19 )
+ {
+ throw new IllegalArgumentException( "Account numbers can not be
longer than 19 characters: " + number );
+ }
+ m_account = number;
+ }
+
+ public Object get()
+ {
+ return m_account;
+ }
+
+ public void reset()
+ {
+ m_account = null;
+ }
+}
Added:
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/TEMPLATE.tjava
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/elements/TEMPLATE.tjava
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.dpml.iso8583.data.elements;
+
+
+import net.dpml.iso8583.data.DataElement;
+
+import net.dpml.logging.Logger;
+
+import org.jpos.iso.ISOException;
+import org.jpos.iso.ISOMsg;
+
+
+/** <code>DataElement</code> implementation of XX.
+ *
+ * @author <a href="mailto:niclas AT hedhman.org";>Niclas Hedhman</a>
+ *
+ * @see net.dpml.iso8583.data.DataElement
+ * @see net.dpml.iso8583.data.DataElementManager
+ *
+ * @metro.component name="" lifestyle="transient"
+ * @metro.service type="net.dpml.iso8583.data.DataElement"
+ */
+public class XX
+ implements DataElement
+{
+ /** Maximum length of this <code>DataElement</code>. */
+ static private int MAX_LENGTH = 0;
+
+ /** Minimum length of this <code>DataElement</code>. */
+ static private int MIN_LENGTH = 0;
+
+ /** The <code>DataElement</code> name, as defined in the ISO-8583 spec,
+ * but with no spaces, no slashes and uppercase for new word.
+ */
+ static private String m_elementType;
+
+ private String m_value;
+ private Logger m_logger;
+
+ /** Sets up the element type in a generic fashion. */
+ static
+ {
+ String str = XX.class.getName();
+ int pos = str.lastIndexOf( "." );
+ m_elementType = str.substring( pos + 1 );
+ }
+
+ /** Constructor of XX.
+ *
+ * @param logger supplied <code>Logger</code> instance.
+ * @param params supplied configuration <code>Parameters</code>
+ */
+ public XX( Logger logger, Parameters params )
+ {
+ m_logger = logger;
+ }
+
+ /** Instructs the DataElement to populate the ISOMsg object.
+ * <p>
+ * <code>DataElement</code> implementations are responsible to know
+ * which field (a.k.a. bit) that it should populate in the
+ * <code>ISOMsg</code> structure. The caller must know whether the
+ * field is required or not, and if the <code>DataElement</code> has
+ * not been properly set, either in the course of the session or as
+ * part of its initialization, it should throw an ISOException.
+ * </p>
+ * <p>
+ * If the <code>DataElement</code> is nested, it is responsible for
+ * calling the <code>populate</code> method for each of the composite
+ * <code>DataElements</code>.
+ * </p>
+ * @param message the <code>ISOMsg</code> instance to populate with the
+ * value of the <code>DataElement</code>.
+ * @param required if true, the <code>DataElement</code> must make sure
+ * that its value object has been set during the session.
+ *
+ * @exception ISOException if the ISOMsg can not be populated.
+ */
+ public void populate( ISOMsg message, boolean required )
+ throws ISOException
+ {
+ if( m_logger.isDebugEnabled() )
+ {
+ m_logger.debug( "populate: " + message );
+ }
+
+ if( required && m_value == null )
+ {
+ throw new ISOException( "Required data element has not been set:
PrimaryAccountNumber" );
+ }
+ message.set( XX, m_value );
+ }
+
+ /** Sets the value object of the DataElement.
+ * <p>
+ * Each <code>DataElement</code> implementation defines what the value
+ * object is, and whether a default value can be
configured/parameterized
+ * or must be set during the session.
+ * </p>
+ * <p>
+ * The provided argument must be of the correct type, and be within
+ * its specification defined bounds, or an <code>IllegalArgumentException
+ * </code> will be thrown.
+ * </p>
+ * @exception IllegalArgumentException if the provided <code>value</code>
+ * argument is of the wrong class, contains illegal values,
+ * or is null.
+ */
+ public void set( Object obj )
+ throws IllegalArgumentException
+ {
+ validateNonNullAndType( obj );
+ String value = (String) obj;
+ validateLength( value );
+ m_value = value;
+ }
+
+ /** Returns the value object of the DataElement.
+ * <p>
+ * Each <code>DataElement</code> implementation defines what the value
+ * object is, and whether a default value can be
configured/parameterized
+ * or must be set during the session.
+ * </p>
+ *
+ * @return the value object of the DataElement, which is the same object
+ * that has previously been set with the <code>set()</code>
+ * method.
+ */
+ public Object get()
+ {
+ return m_value;
+ }
+
+ /** Validates that the value is not null and of the correct type.
+ * @param value the object to validate.
+ */
+ private void validateNonNullAndType( Object value )
+ throws IllegalArgumentException
+ {
+ if( value == null )
+ {
+ throw new IllegalArgumentException( "Null argument not allowed."
);
+ }
+
+ if( value instanceof String == false )
+ {
+ throw new IllegalArgumentException( "Value must be a
java.lang.String: " + value );
+ }
+ }
+
+ /** Validates that the string value is of the correct length.
+ * @param value the object to validate.
+ */
+ private void validateLength( String value )
+ throws IllegalArgumentException
+ {
+ if( value.length() > NN )
+ {
+ throw new IllegalArgumentException( m_ElementType + " can not be
longer than " + MAX_LENGTH + " characters: " + number );
+ }
+ }
+}
Added:
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/manager/DefaultManager.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/iso8583/elements/src/main/net/dpml/iso8583/data/manager/DefaultManager.java
Fri Mar 25 15:37:00 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004-2005 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.iso8583.data.manager;
+
+import net.dpml.iso8583.data.DataElement;
+import net.dpml.iso8583.data.DataElementManager;
+import net.dpml.iso8583.data.NoSuchDataElementException;
+import net.dpml.logging.Logger;
+import net.dpml.service.ServiceManager;
+
+import java.util.HashMap;
+
+/** DataElements needs to be coordinated between different requesting
+ * threads, and the DataElementManager is required to provide this
+ * functionality.
+ *
+ * @metro.component name="default-DE-manager" lifestyle="singleton"
+ * @metro.service type="net.dpml.iso8583.data.DataElementManager"
+ */
+public class DefaultManager
+ implements DataElementManager
+{
+ private ThreadLocal m_session;
+ private Logger m_logger;
+ private ServiceManager m_serviceManager;
+
+ /**
+ * @metro.dependency
type="net.dpml.iso8583.data.elements.PrimaryAccountNumber"
+ * @metro.dependency
type="net.dpml.iso8583.data.elements.PrimaryAccountNumber"
+ */
+ public DefaultManager( Logger logger, ServiceManager man )
+ {
+ m_logger = logger;
+ m_session = new ThreadLocal();
+ m_serviceManager = man;
+ }
+
+ /** Called to indicate that the current thread is starting a new
+ * session.
+ */
+ public void beginSession()
+ {
+ m_session.set( new HashMap() );
+ }
+
+ /** Called to indicate that the current thread is done with the
+ * session and all data elements can be released.
+ */
+ public void doneSession()
+ {
+ releaseComponents();
+ m_session.set( null );
+ }
+
+ /** Requests a <code>DataElement</code> of the provided type.
+ * <p>
+ * The provided type is the class name of the <code>DataElement</code>
+ * implementation, either with or without the package name. For
+ * better typesafety, you should use the following pattern;
+ * <code><pre>
+ * private DataElementManager m_dem;
+ * :
+ * :
+ * DataElement account = m_dem.lookup(
PrimaryAccountNumber.class.getName() );
+ * </pre></code>
+ *
+ * @exception NoSuchDataElementException if the requested DataElement is
not
+ * available in the system.
+ */
+ public DataElement lookup( String type )
+ throws NoSuchDataElementException
+ {
+ try
+ {
+ DataElement de = (DataElement) m_serviceManager.lookup( type );
+ // TODO
+ } catch( Exception e )
+ {}
+ return null;
+ }
+
+ private void releaseComponents()
+ {
+ // TODO;
+ }
+}
\ No newline at end of file
Modified: development/planet/users/niclas/iso8583/index.xml
==============================================================================
--- development/planet/users/niclas/iso8583/index.xml (original)
+++ development/planet/users/niclas/iso8583/index.xml Fri Mar 25 15:37:00
2005
@@ -28,6 +28,45 @@
</info>
</resource>
+ <project basedir="api" >
+ <info>
+ <name>dpml-iso8583-api</name>
+ <group>dpml/iso8583/api</group>
+ <version>1.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos" />
+ <include key="dpml-activity-api" />
+ <include key="dpml-logging-api" />
+ <include key="dpml-context-api" />
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-service-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="elements" >
+ <info>
+ <name>dpml-iso8583-elements</name>
+ <group>dpml/iso8583/elements</group>
+ <version>1.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos" />
+ <include key="dpml-iso8583-api" />
+ <include key="dpml-activity-api" />
+ <include key="dpml-logging-api" />
+ <include key="dpml-context-api" />
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-service-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
<project basedir="channels" >
<info>
<name>dpml-iso8583-channels</name>
- svn commit: r2134 - in development/planet/users/niclas/iso8583: . api api/src/main/net/dpml/iso8583 api/src/main/net/dpml/iso8583/authorization api/src/main/net/dpml/iso8583/data elements elements/src elements/src/main elements/src/main/net elements/src/main/net/dpml elements/src/main/net/dpml/iso8583 elements/src/main/net/dpml/iso8583/data elements/src/main/net/dpml/iso8583/data/elements elements/src/main/net/dpml/iso8583/data/manager, niclas, 03/25/2005
Archive powered by MHonArc 2.6.24.