[Ejtools-cvs] libraries/common/src/main/org/ejtools/util/service package.html,NONE,1.1 Profile.java,
Brought to you by:
letiemble
Update of /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service In directory sc8-pr-cvs1:/tmp/cvs-serv18971/common/src/main/org/ejtools/util/service Modified Files: Profile.java ProfileHolder.java ProfileMetaData.java ProfileService.java ProfileServiceProvider.java Added Files: package.html Log Message: Add more javadocs. Add package.html files. --- NEW FILE: package.html --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!-- EJTools, the Enterprise Java Tools Distributable under LGPL license. See terms of license at www.gnu.org. $Revision: 1.1 $ --> <html> <head/> <body> </body> </html> Index: Profile.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service/Profile.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Profile.java 15 Sep 2003 22:23:45 -0000 1.2 --- Profile.java 13 Dec 2003 21:27:49 -0000 1.3 *************** *** 1,58 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.util.Properties; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class Profile extends Properties ! { ! /** Description of the Field */ ! private String name = null; ! ! ! /**Constructor for the Profile object */ ! public Profile() ! { ! super(); ! } ! ! ! /** ! * Returns the name. ! * ! * @return String ! */ ! public String getName() ! { ! return this.name; ! } ! ! ! /** ! * Sets the name. ! * ! * @param name The new name value ! */ ! public void setName(String name) ! { ! this.name = name; ! } ! ! ! /** ! * @return Description of the Return Value ! */ ! public String toString() ! { ! return this.name; ! } ! } --- 1,58 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.util.Properties; ! ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class Profile extends Properties ! { ! /** Description of the Field */ ! private String name = null; ! ! ! /**Constructor for the Profile object */ ! public Profile() ! { ! super(); ! } ! ! ! /** ! * Returns the name. ! * ! * @return String ! */ ! public String getName() ! { ! return this.name; ! } ! ! ! /** ! * Sets the name. ! * ! * @param name The new name value ! */ ! public void setName(String name) ! { ! this.name = name; ! } ! ! ! /** ! * @return Description of the Return Value ! */ ! public String toString() ! { ! return this.name; ! } ! } Index: ProfileHolder.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service/ProfileHolder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProfileHolder.java 15 Sep 2003 22:23:45 -0000 1.1 --- ProfileHolder.java 13 Dec 2003 21:27:49 -0000 1.2 *************** *** 1,24 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! ! /** ! * Description of the Interface ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileHolder ! { ! /** ! * Sets the profile attribute of the ProfileHolder object ! * ! * @param profile The new profile value ! */ ! void setProfile(Profile profile); ! } --- 1,24 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! ! /** ! * Description of the Interface ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileHolder ! { ! /** ! * Sets the profile attribute of the ProfileHolder object ! * ! * @param profile The new profile value ! */ ! void setProfile(Profile profile); ! } Index: ProfileMetaData.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service/ProfileMetaData.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProfileMetaData.java 15 Sep 2003 22:23:45 -0000 1.2 --- ProfileMetaData.java 13 Dec 2003 21:27:49 -0000 1.3 *************** *** 1,48 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.io.Serializable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileMetaData extends Serializable ! { ! /** ! * Gets the fileName attribute of the ConnectionMetaData object ! * ! * @return The fileName value ! */ ! public String getFileName(); ! ! ! /** ! * Gets the key attribute of the ConnectionMetaData object ! * ! * @param index Description of the Parameter ! * @return The key value ! */ ! public String getKey(int index); ! ! ! /** ! * Gets the keys attribute of the ConnectionMetaData object ! * ! * @return The keys value ! */ ! public String[] getKeys(); ! ! ! /** ! * Gets the prefix attribute of the ConnectionMetaData object ! * ! * @return The prefix value ! */ ! public String getPrefix(); ! } --- 1,48 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.io.Serializable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileMetaData extends Serializable ! { ! /** ! * Gets the fileName attribute of the ConnectionMetaData object ! * ! * @return The fileName value ! */ ! public String getFileName(); ! ! ! /** ! * Gets the key attribute of the ConnectionMetaData object ! * ! * @param index Description of the Parameter ! * @return The key value ! */ ! public String getKey(int index); ! ! ! /** ! * Gets the keys attribute of the ConnectionMetaData object ! * ! * @return The keys value ! */ ! public String[] getKeys(); ! ! ! /** ! * Gets the prefix attribute of the ConnectionMetaData object ! * ! * @return The prefix value ! */ ! public String getPrefix(); ! } Index: ProfileService.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service/ProfileService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProfileService.java 15 Sep 2003 22:23:45 -0000 1.2 --- ProfileService.java 13 Dec 2003 21:27:49 -0000 1.3 *************** *** 1,32 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.io.Serializable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileService extends Serializable ! { ! /** ! * Gets the metaDatas attribute of the FactoryService object ! * ! * @return The metaDatas value ! */ ! public Profile[] getProfiles(); ! ! ! /** ! * Gets the metaData attribute of the FactoryService object ! * ! * @param index Description of the Parameter ! * @return The metaData value ! */ ! public Profile getProfile(int index); ! } --- 1,32 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.io.Serializable; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public interface ProfileService extends Serializable ! { ! /** ! * Gets the metaDatas attribute of the FactoryService object ! * ! * @return The metaDatas value ! */ ! public Profile[] getProfiles(); ! ! ! /** ! * Gets the metaData attribute of the FactoryService object ! * ! * @param index Description of the Parameter ! * @return The metaData value ! */ ! public Profile getProfile(int index); ! } Index: ProfileServiceProvider.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/util/service/ProfileServiceProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProfileServiceProvider.java 15 Sep 2003 22:23:45 -0000 1.3 --- ProfileServiceProvider.java 13 Dec 2003 21:27:49 -0000 1.4 *************** *** 1,169 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.beans.beancontext.BeanContextServices; ! import java.io.IOException; ! import java.io.InputStream; ! import java.util.Arrays; ! import java.util.Enumeration; ! import java.util.Iterator; ! import java.util.Properties; ! import java.util.Vector; ! ! import org.apache.log4j.Logger; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class ProfileServiceProvider extends CustomBeanContextServiceProvider implements ProfileService ! { ! /** Description of the Field */ ! protected ProfileMetaData metadata = null; ! /** Description of the Field */ ! protected Profile[] profiles = null; ! /** Description of the Field */ ! protected ProfileService service = null; ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(ProfileServiceProvider.class); ! ! ! /** ! * Constructor for the FactoryServiceProvider object ! * ! * @param metadata Description of the Parameter ! */ ! public ProfileServiceProvider(ProfileMetaData metadata) ! { ! service = this; ! this.metadata = metadata; ! this.load(); ! } ! ! ! /** ! * Getter for the currentServiceSelectors attribute ! * ! * @param bcs Description of the Parameter ! * @param serviceClass Description of the Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, java.lang.Class serviceClass) ! { ! return (new Vector()).iterator(); ! } ! ! ! /** ! * @param index Description of the Parameter ! * @return The metaData value ! */ ! public Profile getProfile(int index) ! { ! Profile profile = this.profiles[index]; ! return (Profile) profile.clone(); ! } ! ! ! /** ! * @return The metaDatas value ! */ ! public Profile[] getProfiles() ! { ! return this.profiles; ! } ! ! ! /** ! * Getter for the service attribute ! * ! * @param bcs Description of the Parameter ! * @param requestor Description of the Parameter ! * @param serviceClass Description of the Parameter ! * @param serviceSelector Description of the Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector) ! { ! return this.service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of the Parameter ! * @param requestor Description of the Parameter ! * @param service Description of the Parameter ! */ ! public void releaseService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Object service) { } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{ProfileService.class}; ! } ! ! ! /** */ ! private void load() ! { ! this.profiles = new Profile[0]; ! ! try ! { ! String prefix = this.metadata.getPrefix(); ! InputStream in = ProfileServiceProvider.class.getResourceAsStream(this.metadata.getFileName()); ! if (in != null) ! { ! Properties props = new Properties(); ! props.load(in); ! in.close(); ! ! Vector keys = new Vector(); ! Enumeration enum = props.keys(); ! while (enum.hasMoreElements()) ! { ! String key = (String) enum.nextElement(); ! if ((key.startsWith(prefix + ".")) && (key.endsWith(".name"))) ! { ! keys.add(key.substring((prefix + ".").length(), key.indexOf(".name"))); ! } ! } ! ! this.profiles = new Profile[keys.size()]; ! String[] orderedKeys = (String[]) keys.toArray(new String[0]); ! Arrays.sort(orderedKeys); ! ! for (int i = 0; i < orderedKeys.length; i++) ! { ! String key = orderedKeys[i]; ! logger.debug("Loading key " + key); ! ! Profile data = new Profile(); ! data.setName(props.getProperty(prefix + "." + key + ".name")); ! ! for (int j = 0; j < this.metadata.getKeys().length; j++) ! { ! data.setProperty(this.metadata.getKey(j), props.getProperty(prefix + "." + key + "." + this.metadata.getKey(j), "")); ! } ! ! this.profiles[i] = data; ! } ! } ! } ! catch (IOException e) ! { ! logger.error("Error while loading profiles", e); ! } ! } ! } --- 1,169 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.util.service; ! ! import java.beans.beancontext.BeanContextServices; ! import java.io.IOException; ! import java.io.InputStream; ! import java.util.Arrays; ! import java.util.Enumeration; ! import java.util.Iterator; ! import java.util.Properties; ! import java.util.Vector; ! ! import org.apache.log4j.Logger; ! import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class ProfileServiceProvider extends CustomBeanContextServiceProvider implements ProfileService ! { ! /** Description of the Field */ ! protected ProfileMetaData metadata = null; ! /** Description of the Field */ ! protected Profile[] profiles = null; ! /** Description of the Field */ ! protected ProfileService service = null; ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(ProfileServiceProvider.class); ! ! ! /** ! * Constructor for the FactoryServiceProvider object ! * ! * @param metadata Description of the Parameter ! */ ! public ProfileServiceProvider(ProfileMetaData metadata) ! { ! service = this; ! this.metadata = metadata; ! this.load(); ! } ! ! ! /** ! * Getter for the currentServiceSelectors attribute ! * ! * @param bcs Description of the Parameter ! * @param serviceClass Description of the Parameter ! * @return The currentServiceSelectors value ! */ ! public Iterator getCurrentServiceSelectors(BeanContextServices bcs, java.lang.Class serviceClass) ! { ! return (new Vector()).iterator(); ! } ! ! ! /** ! * @param index Description of the Parameter ! * @return The metaData value ! */ ! public Profile getProfile(int index) ! { ! Profile profile = this.profiles[index]; ! return (Profile) profile.clone(); ! } ! ! ! /** ! * @return The metaDatas value ! */ ! public Profile[] getProfiles() ! { ! return this.profiles; ! } ! ! ! /** ! * Getter for the service attribute ! * ! * @param bcs Description of the Parameter ! * @param requestor Description of the Parameter ! * @param serviceClass Description of the Parameter ! * @param serviceSelector Description of the Parameter ! * @return The service value ! */ ! public Object getService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector) ! { ! return this.service; ! } ! ! ! /** ! * Description of the Method ! * ! * @param bcs Description of the Parameter ! * @param requestor Description of the Parameter ! * @param service Description of the Parameter ! */ ! public void releaseService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Object service) { } ! ! ! /** ! * @return The serviceClass value ! */ ! protected Class[] getServiceClass() ! { ! return new Class[]{ProfileService.class}; ! } ! ! ! /** */ ! private void load() ! { ! this.profiles = new Profile[0]; ! ! try ! { ! String prefix = this.metadata.getPrefix(); ! InputStream in = ProfileServiceProvider.class.getResourceAsStream(this.metadata.getFileName()); ! if (in != null) ! { ! Properties props = new Properties(); ! props.load(in); ! in.close(); ! ! Vector keys = new Vector(); ! Enumeration enum = props.keys(); ! while (enum.hasMoreElements()) ! { ! String key = (String) enum.nextElement(); ! if ((key.startsWith(prefix + ".")) && (key.endsWith(".name"))) ! { ! keys.add(key.substring((prefix + ".").length(), key.indexOf(".name"))); ! } ! } ! ! this.profiles = new Profile[keys.size()]; ! String[] orderedKeys = (String[]) keys.toArray(new String[0]); ! Arrays.sort(orderedKeys); ! ! for (int i = 0; i < orderedKeys.length; i++) ! { ! String key = orderedKeys[i]; ! logger.debug("Loading key " + key); ! ! Profile data = new Profile(); ! data.setName(props.getProperty(prefix + "." + key + ".name")); ! ! for (int j = 0; j < this.metadata.getKeys().length; j++) ! { ! data.setProperty(this.metadata.getKey(j), props.getProperty(prefix + "." + key + "." + this.metadata.getKey(j), "")); ! } ! ! this.profiles[i] = data; ! } ! } ! } ! catch (IOException e) ! { ! logger.error("Error while loading profiles", e); ! } ! } ! } |