[jboss-svn-commits] JBL Code SVN: r7144 - in labs/jbossesb/trunk/product: core/services/src/org/jboss/soa/esb/services/registry core/services/tests/src/org/jboss/soa/esb/services/registry etc/test/resources
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 26 10:30:53 EDT 2006
Author: kurt.stam at jboss.com
Date: 2006-10-26 10:30:50 -0400 (Thu, 26 Oct 2006)
New Revision: 7144
Added:
labs/jbossesb/trunk/product/etc/test/resources/log4j.xml
Removed:
labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/PublishOrgUnitTest.java
Modified:
labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
Log:
Adding registry integration code
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java 2006-10-26 14:30:18 UTC (rev 7143)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java 2006-10-26 14:30:50 UTC (rev 7144)
@@ -25,12 +25,32 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
import javax.xml.registry.Connection;
import javax.xml.registry.ConnectionFactory;
+import javax.xml.registry.FindQualifier;
import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.PersonName;
+import javax.xml.registry.infomodel.PostalAddress;
+import javax.xml.registry.infomodel.RegistryObject;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
@@ -47,8 +67,8 @@
{
private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
-
private static Properties props = new Properties();
+ private static Organization jbossESBOrganization;
private static void init()
{
@@ -68,7 +88,7 @@
*
* @return Connection to a Registry using JAXR.
*/
- protected static Connection getConnection()
+ protected static Connection getConnection()
{
Connection connection = null;
init();
@@ -99,20 +119,90 @@
/**
* Publish an EPR to the Registry
*/
- public void publish(String serviceName, EPR epr) {
- return;
+ protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException
+ {
+ Service service =null;
+ Organization organization = getJBossESBOrganization();
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ connection.setCredentials(JAXRRegistryImpl.creds);
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ //Adding the category as prefix for the name
+ service = blm.createService(blm.createInternationalString(category + ":" + serviceName));
+ service.setDescription(blm.createInternationalString(serviceDescription));
+// ClassificationScheme cScheme = getClassificationScheme(blm, "uddi-org:general_keywords", "");
+// Classification classification = blm.createClassification(cScheme, "JBossESB" + category, category);
+// service.addClassification(classification);
+ organization.addService(service);
+ saveRegistryObject(service);
+ } finally {
+ closeConnection(connection);
+ }
+ return service;
}
/**
* Remove an EPR from the Registry
*/
- public void unPublish(EPR epr) {
+ public void unRegisterService(String category, String serviceName) throws RegistryException{
}
/**
- * Find all ESB Services
+ * Publish an EPR to the Registry
+ */
+ public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
+ throws RegistryException
+ {
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ //Find the service
+ Service service = findService(category,serviceName);
+ if (service==null) {
+ logger.log(Priority.INFO, "Service " + serviceName + " does not yet exist, creating now..");
+ service = registerService(category, serviceName, serviceDescription);
+ }
+ connection.setCredentials(JAXRRegistryImpl.creds);
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ ServiceBinding serviceBinding = blm.createServiceBinding();
+ serviceBinding.setDescription(blm.createInternationalString("Binding Description"));
+ serviceBinding.setAccessURI("http://www.jboss.com/services/TestService");
+
+ Concept specConcept = blm.createConcept(null, "HelloConcept", "");
+ String schemeName = "uddi-org:types";
+ ClassificationScheme uddiOrgTypes =
+ bqm.findClassificationSchemeByName(null, schemeName);
+ Classification wsdlSpecClassification =
+ blm.createClassification(uddiOrgTypes,
+ "eprSpec", "eprSpec");
+ specConcept.addClassification(wsdlSpecClassification);
+ Collection<Concept> concepts = new ArrayList<Concept>();
+ concepts.add(specConcept);
+ blm.saveConcepts(concepts);
+
+ ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+ serviceBindings.add(serviceBinding);
+ service.addServiceBindings(serviceBindings);
+ saveRegistryObject(serviceBinding);
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } finally {
+ closeConnection(connection);
+ }
+ }
+ /**
+ * Remove an EPR from the Registry
+ */
+ public void unRegisterEPR(String category, String serviceName, EPR epr) throws RegistryException{
+
+ }
+
+ /**
+ * {@inheritDoc}
* @return collection services
*/
- public Collection<String> findServices()
+ public Collection<String> findAllServices()
{
Collection<String> services = new ArrayList<String>();
return services;
@@ -123,7 +213,7 @@
* @param serviceType
* @return collection services
*/
- public Collection<String> findServices(String serviceType){
+ public Collection<String> findServices(String category){
Collection<String> services = new ArrayList<String>();
return services;
}
@@ -132,8 +222,250 @@
* @param service
* @return
*/
- public Collection<EPR> findEPR(String serviceName){
+ public Collection<EPR> findEPRs(String category, String serviceName){
Collection<EPR> eprs = new ArrayList<EPR>();
return eprs;
}
+ /**
+ * Find all Organizations with a name mathing the queryString parameter.
+ *
+ * @param organizationName used to match with the name of the organization.
+ * @return the Organization.
+ */
+ protected static Organization findOrganization(String organizationName) throws JAXRException
+ {
+ if (organizationName==null) {
+ organizationName="";
+ }
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add("%" + organizationName + "%");
+ //Find based upon qualifier type and values
+ System.out.println("Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findOrganizations(findQualifiers,
+ namePatterns, null, null, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
+ {
+ Organization org = (Organization) orgIter.next();
+ logger.log(Priority.INFO, "Organization name: " + org.getName().getValue());
+ logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
+ logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
+ User primaryContact = org.getPrimaryContact();
+ logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+ if (orgIter.hasNext()) {
+ logger.log(Priority.ERROR, "Found " + response.getCollection().size()
+ + " Organization, while expecting only one of name " + organizationName);
+ }
+ return org;
+ }
+ }
+ return null;
+ } finally {
+ closeConnection(connection);
+ }
+ }
+ /**
+ *
+ * @param category
+ * @param serviceName
+ * @return Service
+ */
+ protected static Service findService(String category, String serviceName) throws JAXRException
+ {
+ if (category==null) {
+ category="";
+ }
+ if (serviceName==null) {
+ serviceName="";
+ }
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add("%" + category + "%");
+ namePatterns.add("%" + serviceName + "%");
+ //Find based upon qualifier type and values
+ logger.log(Priority.DEBUG, "Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findServices(null, findQualifiers,
+ namePatterns, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();)
+ {
+ Service service = (Service) servIter.next();
+ logger.log(Priority.INFO, "Service name: " + service.getName().getValue());
+ if (service.getDescription()!=null) {
+ logger.log(Priority.INFO, "Description: " + service.getDescription().getValue());
+ }
+ logger.log(Priority.INFO, "Key id: " + service.getKey().getId());
+ if (servIter.hasNext()) {
+ logger.log(Priority.ERROR, "Found " + response.getCollection().size()
+ + " Services, while expecting only one by the name of "
+ + serviceName + " in category " + category);
+ }
+ return service;
+ }
+ }
+ return null;
+ } finally {
+ closeConnection(connection);
+ }
+ }
+ /**
+ * Create a jbossesb organization under which we will register all our services.
+ *
+ * @param blm
+ * @return
+ * @throws JAXRException
+ */
+ protected static Organization createJBossESBOrganization()
+ throws JAXRException
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ //Logging in
+ connection.setCredentials(JAXRRegistryImpl.creds);
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Organization organization = blm.createOrganization(blm.createInternationalString("Red Hat/JBossESB"));
+ organization.setDescription(blm.createInternationalString("Red Hat/JBoss Professional Open Source, Services for the JBossESB"));
+
+ User user = blm.createUser();
+ organization.setPrimaryContact(user);
+ PersonName personName = blm.createPersonName("JBossESB");
+ TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
+ telephoneNumber.setNumber("404 467-8555");
+ telephoneNumber.setType(null);
+ PostalAddress address = blm.createPostalAddress("3340",
+ "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
+ "30326", "");
+ Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
+ postalAddresses.add(address);
+ Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
+ EmailAddress emailAddress = blm
+ .createEmailAddress("jbossesb at jboss.com");
+ emailAddresses.add(emailAddress);
+
+ Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
+ numbers.add(telephoneNumber);
+ user.setPersonName(personName);
+ user.setPostalAddresses(postalAddresses);
+ user.setEmailAddresses(emailAddresses);
+ user.setTelephoneNumbers(numbers);
+
+ // Scout does not support this (yet), so leaving it out for now.
+ // ClassificationScheme cScheme = getClassificationScheme(blm,
+ // blm.createInternationalString("uddi-org:general_keywords"), blm.createInternationalString(""));
+ // Classification classification = blm.createClassification(cScheme,
+ // blm..createInternationalString("JBoss ESB"), blm..createInternationalString("JBESB"));
+ // org.addClassification(classification);
+
+ saveRegistryObject(organization);
+ return organization;
+ } finally {
+ closeConnection(connection);
+ }
+ }
+ /**
+ * Save Registry Object
+ */
+ protected static void saveRegistryObject(RegistryObject registryObject) throws JAXRException
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ Collection<RegistryObject> registryObjects = new ArrayList<RegistryObject>();
+ BulkResponse br = null;
+ //Logging in
+ connection.setCredentials(JAXRRegistryImpl.creds);
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ registryObjects.add(registryObject);
+ Class[] interfaces = registryObject.getClass().getInterfaces();
+ String interfaceName ="";
+ for (int i=0; i<interfaces.length; i++) {
+ interfaceName = interfaces[i].getName();
+ if (interfaceName.equals("javax.xml.registry.infomodel.Organization")) {
+ br = blm.saveOrganizations(registryObjects);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
+ br = blm.saveServices(registryObjects);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
+ br = blm.saveServiceBindings(registryObjects);
+ break;
+ } else {
+ logger.log(Priority.ERROR, "Trying to save an unsupported RegistryObject");
+ throw new JAXRException("Trying to save an unsupported RegistryObject");
+ }
+ }
+ //Verify the return
+ if (br!=null && br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+ logger.log(Priority.INFO, interfaceName + " successfully saved");
+ Collection coll = br.getCollection();
+ Iterator iter = coll.iterator();
+ while (iter.hasNext()) {
+ Key key = (Key) iter.next();
+ registryObject.setKey(key);
+ logger.log(Priority.INFO, "Saved Key=" + key.getId());
+ }
+ } else {
+ logger.log(Priority.ERROR, "Errors occurred during save.");
+ if (br!=null) {
+ Collection exceptions = br.getExceptions();
+ Iterator iter = exceptions.iterator();
+ String errors = "";
+ JAXRException je = new JAXRException("JAXRExceptions occurred during save");
+ while (iter.hasNext()) {
+ Exception e = (Exception) iter.next();
+ errors += e.getLocalizedMessage() + "\n";
+ je.setStackTrace(e.getStackTrace());
+ logger.log(Priority.ERROR, e.getLocalizedMessage(), e);
+ //if it's the last error, throw it now and set the current stacktrace
+ if (!iter.hasNext()) {
+ throw new JAXRException(errors, e);
+ }
+ }
+ throw new JAXRException("Errors occurred during save. Response status=" + br.getStatus());
+ }
+ throw new JAXRException("Errors occurred during save");
+ }
+ } finally {
+ JAXRRegistryImpl.closeConnection(connection);
+ }
+ }
+ /**
+ * finds the JBossESB Organizationa and creates one if it is not there.
+ * @return JBossESB Organization
+ * @throws JAXRException
+ */
+ private Organization getJBossESBOrganization() throws JAXRException
+ {
+ if (jbossESBOrganization==null) {
+ jbossESBOrganization = findOrganization("Red Hat/JBossESB");
+ if (jbossESBOrganization==null) {
+ jbossESBOrganization = createJBossESBOrganization();
+ }
+ }
+ return jbossESBOrganization;
+ }
+
}
+
+
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java 2006-10-26 14:30:18 UTC (rev 7143)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java 2006-10-26 14:30:50 UTC (rev 7144)
@@ -23,6 +23,8 @@
import java.util.Collection;
+import javax.xml.registry.JAXRException;
+
import org.jboss.soa.esb.addressing.EPR;
/**
* Registry interface for the ESB.
@@ -31,27 +33,54 @@
*/
interface Registry
{
- public void publish(String serviceName, EPR epr);
- /**
- * Remove an EPR from the Registry
+ /**
+ * Removes a service from the Registry along with all the ServiceBindings underneath it.
+ *
+ * @param category - name of the service category, for example 'transformation'.
+ * @param serviceName - name of the service, for example 'smooks'.
+ * @throws JAXRException
*/
- public void unPublish(EPR epr);
+ public void unRegisterService(String category, String serviceName) throws RegistryException;
+ /**
+ * Registers an EPR under the specified category and service. If the specified service does
+ * not exist, it will be created at the same time.
+ *
+ * @param category - name of the category to which the service belongs.
+ * @param serviceName - name of the service to which the EPS belongs.
+ * @param serviceDescription - human readable description of the service,
+ * only used when it the service does not yet exist.
+ * @param epr - the EndPointReference (EPR) that needs to be registered.
+ * @param eprDescription - human readable description of the EPR
+ * @throws JAXRException
+ */
+ public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
+ throws RegistryException;
+ /**
+ * Removes an EPR from the Registry.
+ * @param category - name of the category to which the service belongs.
+ * @param serviceName - name of the service to which the EPS belongs.
+ * @param epr - the EndPointReference (EPR) that needs to be unregistered.
+ * @throws JAXRException
+ */
+ public void unRegisterEPR(String category, String serviceName, EPR epr) throws RegistryException;
/**
- * Find all ESB Services
- * @return collection services
+ * Find all Services assigned to the Red Hat/JBossESB organization.
+ * @return Collection of Strings containing the service names.
*/
- public Collection<String> findServices();
+ public Collection<String> findAllServices();
/**
- * Find Services based on a type ("transformation"
+ * Find all services that belong to the supplied category.
*
- * @param serviceType
- * @return collection services
+ * @param category - name of the category to which the service belongs.
+ * @return Collection of Strings containing the service names
*/
- public Collection<String> findServices(String serviceType);
+ public Collection<String> findServices(String category);
/**
+ * Finds all the EPRs that belong to a specific category and service combination.
*
- * @param service
- * @return
+ * @param category - name of the category to which the service belongs.
+ * @param serviceName - name of the service to which the EPS belongs.
+ * @return Collection of EPRs.
*/
- public Collection<EPR> findEPR(String serviceName);
+ public Collection<EPR> findEPRs(String category, String serviceName);
}
Modified: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java 2006-10-26 14:30:18 UTC (rev 7143)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java 2006-10-26 14:30:50 UTC (rev 7144)
@@ -43,25 +43,24 @@
import javax.xml.registry.RegistryService;
import javax.xml.registry.infomodel.Classification;
import javax.xml.registry.infomodel.ClassificationScheme;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.ExternalIdentifier;
-import javax.xml.registry.infomodel.Key;
import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PersonName;
-import javax.xml.registry.infomodel.PostalAddress;
import javax.xml.registry.infomodel.Service;
import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.TelephoneNumber;
import javax.xml.registry.infomodel.User;
import junit.framework.JUnit4TestAdapter;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.common.tests.HsqldbUtil;
import org.jboss.soa.esb.common.tests.TestUtil;
import org.jboss.soa.esb.services.util.FileUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+
/**
* Testing the registry.
*
@@ -70,168 +69,142 @@
*/
public class JAXRRegistryUnitTest
{
+ private static Logger logger = Logger.getLogger(JAXRRegistryUnitTest.class);
private static String mDbDriver;
private static String mDbUrl;
private static String mDbUsername;
private static String mDbPassword;
-
- @SuppressWarnings("unchecked")
+ /**
+ * Tests the successful creation of the RED HAT/JBossESB Organization.
+ */
@Test
public void publishOrganization()
{
- //Getting the connection to the Registry (reading config)
- Connection connection = JAXRRegistryImpl.getConnection();
try {
- //Logging in
- connection.setCredentials(JAXRRegistryImpl.creds);
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<Organization> orgs = new ArrayList<Organization>();
- Organization org = createOrganization(blm);
- orgs.add(org);
- //Saving the organization (this make the actual calls)
- BulkResponse br = blm.saveOrganizations(orgs);
-// Verify the return
- if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- System.out.println("Organization Saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- org.setKey(key);
- System.out.println("Saved Key=" + key.getId());
- }
- } else {
- System.out.println("JAXRExceptions " + "occurred during save:");
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- e.printStackTrace();
- }
- assertTrue(false);
- }
-
- //Add a Service
- Service service = blm.createService(blm.createInternationalString("JBossESB TEST Service"));
- service.setDescription(blm.createInternationalString("Services of the ESB UDDI Registry"));
- org.addService(service);
- Collection services = new ArrayList();
- services.add(service);
- br=blm.saveServices(services);
-// Verify the return
- if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- System.out.println("Service Saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- System.out.println("Saved Key=" + key.getId());
- service.setKey(key);
- }
- } else {
- System.out.println("JAXRExceptions " + "occurred during save:");
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- e.printStackTrace();
- }
- assertTrue(false);
- }
-
- //Add a serviceBinding
- ServiceBinding serviceBinding = blm.createServiceBinding();
- serviceBinding.setName(blm.createInternationalString("JBossESB Test ServiceBinding"));
- serviceBinding.setDescription(blm.createInternationalString("Binding Description"));
- serviceBinding.setAccessURI("http://www.jboss.com/services/TestService");
- ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
- serviceBindings.add(serviceBinding);
- service.addServiceBindings(serviceBindings);
- br=blm.saveServiceBindings(serviceBindings);
-
-// Verify the return
- if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- System.out.println("Service Binding Saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- System.out.println("Saved Key=" + key.getId());
- serviceBinding.setKey(key);
- }
- } else {
- System.out.println("JAXRExceptions " + "occurred during save:");
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- e.printStackTrace();
- }
- assertTrue(false);
- }
- } catch (Exception e) {
- e.printStackTrace();
+ Organization org = JAXRRegistryImpl.createJBossESBOrganization();
+ logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
+ assertEquals("Red Hat/JBossESB", org.getName().getValue());
+ } catch (JAXRException je) {
+ logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
assertTrue(false);
- } finally {
- JAXRRegistryImpl.closeConnection(connection);
}
}
+ @Test
+ public void findOrganization()
+ {
+ try {
+ Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
+ logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
+ assertEquals("Red Hat/JBossESB", org.getName().getValue());
+ } catch (JAXRException je) {
+ logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+ assertTrue(false);
+ }
+ try {
+ Organization org = JAXRRegistryImpl.findOrganization("Not Existing Org");
+ logger.log(Priority.INFO, "Could not find non-existing organization.");
+ assertEquals(null, org);
+ } catch (JAXRException je) {
+ logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+ assertTrue(false);
+ }
+ }
/**
+ * Tests the successful registration of a Service.
+ *
+ */
+ @Test
+ public void publishService()
+ {
+ try {
+ JAXRRegistryImpl registry = new JAXRRegistryImpl();
+ registry.registerService("registry", "Registry Test ServiceName", "Registry Test Service Description");
+ } catch (JAXRException je) {
+ logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+ assertTrue(false);
+ }
+ }
+ @Test
+ public void publishServiceBinding()
+ {
+ try {
+ EPR epr = new EPR();
+ JAXRRegistryImpl registry = new JAXRRegistryImpl();
+ registry.registerEPR("registry", "Registry Test ServiceName", "Registry Test Service Description",
+ epr, "EPR description");
+ } catch (RegistryException re) {
+ logger.log(Priority.ERROR, re.getLocalizedMessage(), re);
+ assertTrue(false);
+ }
+ }
+ /**
* Queries the newly added information
* @throws Exception
*/
@Test
- public void findOrganizations()
+ public void findServicesForAnOrganization()
{
- String queryString = "JBOSS"; //All organization with JBOSS in the name.
- Connection connection = JAXRRegistryImpl.getConnection();
try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- // Define find qualifiers and name patterns
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + queryString + "%");
-// Find based upon qualifier type and values
- System.out.println("Going to query the registry for name pattern " + namePatterns);
- BulkResponse response = bqm.findOrganizations(findQualifiers,
- namePatterns, null, null, null, null);
-
- System.out.println("Found " + response.getCollection().size() + " organization.");
- for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
- {
- Organization org = (Organization) orgIter.next();
- System.out.println("Organization name: " + org.getName().getValue());
- System.out.println("Description: " + org.getDescription().getValue());
- System.out.println("Key id: " + org.getKey().getId());
- User primaryContact = org.getPrimaryContact();
- System.out.println("Primary Contact: " + primaryContact.getPersonName().getFullName());
- Collection services = org.getServices();
- for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
- Service service = (Service) serviceIter.next();
- System.out.println("Service Name: " + service.getName().getValue());
- Collection serviceBindings = service.getServiceBindings();
- for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
- ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
- System.out.println("ServiceBinding Description: " + serviceBinding.getDescription().getValue());
- System.out.println("ServiceBinding URI: " + serviceBinding.getAccessURI());
- assertEquals("http://www.jboss.com/services/TestService",serviceBinding.getAccessURI());
- }
+ Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
+ //Listing out the services and their Bindings
+ logger.log(Priority.INFO, "-------------------------------------------------");
+ logger.log(Priority.INFO, "Organization name: " + org.getName().getValue());
+ logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
+ logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
+ User primaryContact = org.getPrimaryContact();
+ logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+ Collection services = org.getServices();
+ for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
+ Service service = (Service) serviceIter.next();
+ logger.log(Priority.INFO, "- Service Name: " + service.getName().getValue());
+ logger.log(Priority.INFO, " Service Key : " + service.getKey().getId());
+ Collection serviceBindings = service.getServiceBindings();
+ for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
+ ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
+ logger.log(Priority.INFO, " ServiceBinding Description: " + serviceBinding.getDescription().getValue());
+ logger.log(Priority.INFO, " ServiceBinding URI: " + serviceBinding.getAccessURI());
+ assertEquals("http://www.jboss.com/services/TestService",serviceBinding.getAccessURI());
}
}
-
- } catch (JAXRException e) {
- e.printStackTrace();
+ logger.log(Priority.INFO, "-------------------------------------------------");
+ } catch (JAXRException je) {
+ je.printStackTrace();
assertTrue(false);
- } finally {
- JAXRRegistryImpl.closeConnection(connection);
}
}
/**
+ * This doesn't work because scout drops the classifications on the floor.
+ * We're ignoring this test until I come up with a patch.
+ *
+ */
+ public void findServicesByClassification()
+ {
+ Connection connection = JAXRRegistryImpl.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ ClassificationScheme classificationScheme = bqm.findClassificationSchemeByName(null, "uddi-org:general_keywords");
+ Classification classification = blm.createClassification(classificationScheme,
+ "Test transformation service", "transformation");
+ Collection<Classification> classifications = new ArrayList<Classification>();
+ classifications.add(classification);
+ //Here I'd like to test filtering by this classification, but scout ignored the classification
+ String name=classificationScheme.getName().getValue();
+ System.out.println("Name=" + name);
+ Collection<String> nameParams = new ArrayList<String>();
+ //The name of the service is wild
+ nameParams.add("%");
+ BulkResponse bs = bqm.findServices(null, null,nameParams,classifications, null);
+ int status = bs.getStatus();
+ System.out.println("status=" + status);
+ } catch (JAXRException je) {
+ je.printStackTrace();
+ }
+ finally{}
+ }
+ /**
*
*/
@SuppressWarnings("unchecked")
@@ -296,74 +269,13 @@
}
/**
- * Creates a Jaxr Organization with 1 or more services
- *
- * @return
- * @throws JAXRException
- */
- @SuppressWarnings("unused")
- private Organization createOrganization(BusinessLifeCycleManager blm)
- throws JAXRException {
- Organization org = blm.createOrganization(blm.createInternationalString("USA -- JBOSS ORG"));
- org.setDescription(blm.createInternationalString("JBoss Professional Open Source"));
-
- User user = blm.createUser();
- org.setPrimaryContact(user);
- PersonName personName = blm.createPersonName("Kurt Stam");
- TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
- telephoneNumber.setNumber("404 467-8555");
- telephoneNumber.setType(null);
- PostalAddress address = blm.createPostalAddress("3340",
- "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
- "30326", "");
- Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
- postalAddresses.add(address);
- Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
- EmailAddress emailAddress = blm
- .createEmailAddress("kurt.stam at jboss.org");
- emailAddresses.add(emailAddress);
-
- Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
- numbers.add(telephoneNumber);
- user.setPersonName(personName);
- user.setPostalAddresses(postalAddresses);
- user.setEmailAddresses(emailAddresses);
- user.setTelephoneNumbers(numbers);
-
- ClassificationScheme cScheme = getClassificationScheme(blm,
- "ntis-gov:naics", "");
- Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2");
- cScheme.setKey(cKey);
- Classification classification = blm.createClassification(cScheme,
- "Professional Open Source", "5415");
- org.addClassification(classification);
- ClassificationScheme cScheme1 = getClassificationScheme(blm, "D-U-N-S",
- "");
- Key cKey1 = blm.createKey("uuid:3367C81E-FF1F-4D5A-B202-3EB13AD02423");
- cScheme1.setKey(cKey1);
- ExternalIdentifier ei = blm.createExternalIdentifier(cScheme1,
- "D-U-N-S number", "08-146-6849");
- org.addExternalIdentifier(ei);
- return org;
- }
-
- private ClassificationScheme getClassificationScheme(
- BusinessLifeCycleManager blm, String str1, String str2)
- throws JAXRException {
- ClassificationScheme cs = blm.createClassificationScheme(blm
- .createInternationalString(str1), blm
- .createInternationalString(str2));
- return cs;
- }
-
-
- /**
* Setup the database.
* @throws Exception
*/
@BeforeClass
public static void runBeforeAllTests() throws Exception {
try {
+ DOMConfigurator.configure(TestUtil.getPrefix() + "/etc/test/resources/log4j.xml");
TestUtil.setESBPropertiesFileToUse();
//Set the juddi properties file in System so juddi will pick it up later and use the test values.
String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-unittest.properties";
Deleted: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/PublishOrgUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/PublishOrgUnitTest.java 2006-10-26 14:30:18 UTC (rev 7143)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/PublishOrgUnitTest.java 2006-10-26 14:30:50 UTC (rev 7144)
@@ -1,268 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.services.registry;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.InputStream;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import javax.xml.registry.BulkResponse;
-import javax.xml.registry.BusinessLifeCycleManager;
-import javax.xml.registry.Connection;
-import javax.xml.registry.JAXRException;
-import javax.xml.registry.JAXRResponse;
-import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.Classification;
-import javax.xml.registry.infomodel.ClassificationScheme;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.ExternalIdentifier;
-import javax.xml.registry.infomodel.Key;
-import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PersonName;
-import javax.xml.registry.infomodel.PostalAddress;
-import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.TelephoneNumber;
-import javax.xml.registry.infomodel.User;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.jboss.soa.esb.common.tests.HsqldbUtil;
-import org.jboss.soa.esb.services.util.FileUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * Testing the registry.
- *
- * @author kstam
- *
- */
-public class PublishOrgUnitTest
-{
- private static Logger log = Logger.getLogger(PublishOrgUnitTest.class);
- private static String mDbDriver;
- private static String mDbUrl;
- private static String mDbUsername;
- private static String mDbPassword;
-
- @Test
- public void testPublishOrganization() {
- try { //Getting the connection to the Registry (reading config)
- Connection connection = Registry.getConnection();
- connection.setCredentials(Registry.creds);
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<Organization> orgs = new ArrayList<Organization>();
- Organization org = createOrganization(blm);
- orgs.add(org);
- //Saving the organization (this make the actual calls)
- BulkResponse br = blm.saveOrganizations(orgs);
-
- //Verify the return
- if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- log.info("Organization Saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- log.info("Saved Key=" + key.getId());
- }
- } else {
- log.error("JAXRExceptions " + "occurred during save:");
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- log.error(e.toString());
- }
- assertTrue(false);
- }
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- /**
- * Creates a Jaxr Organization with 1 or more services
- * @return
- * @throws JAXRException
- */
- @SuppressWarnings("unused")
- private Organization createOrganization(BusinessLifeCycleManager blm)
- throws JAXRException {
- Organization org = blm.createOrganization(blm
- .createInternationalString("USA -- JBOSS ORG"));
- org.setDescription(blm
- .createInternationalString("JBoss Professional Open Source"));
- Service service = blm.createService(blm
- .createInternationalString("JBossESB TEST Service"));
- service
- .setDescription(blm
- .createInternationalString("Services of the ESB UDDI Registry"));
- User user = blm.createUser();
- org.setPrimaryContact(user);
- PersonName personName = blm.createPersonName("Kurt Stam");
- TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
- telephoneNumber.setNumber("404 467-8555");
- telephoneNumber.setType(null);
- PostalAddress address = blm.createPostalAddress("3340",
- "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
- "30326", "");
- Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
- postalAddresses.add(address);
- Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
- EmailAddress emailAddress = blm
- .createEmailAddress("kurt.stam at jboss.org");
- emailAddresses.add(emailAddress);
-
- Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
- numbers.add(telephoneNumber);
- user.setPersonName(personName);
- user.setPostalAddresses(postalAddresses);
- user.setEmailAddresses(emailAddresses);
- user.setTelephoneNumbers(numbers);
-
- ClassificationScheme cScheme = getClassificationScheme(blm,
- "ntis-gov:naics", "");
- Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2");
- cScheme.setKey(cKey);
- Classification classification = blm.createClassification(cScheme,
- "Professional Open Source", "5415");
- org.addClassification(classification);
- ClassificationScheme cScheme1 = getClassificationScheme(blm, "D-U-N-S",
- "");
- Key cKey1 = blm.createKey("uuid:3367C81E-FF1F-4D5A-B202-3EB13AD02423");
- cScheme1.setKey(cKey1);
- ExternalIdentifier ei = blm.createExternalIdentifier(cScheme1,
- "D-U-N-S number", "08-146-6849");
- org.addExternalIdentifier(ei);
- org.addService(service);
- return org;
- }
-
- private ClassificationScheme getClassificationScheme(
- BusinessLifeCycleManager blm, String str1, String str2)
- throws JAXRException {
- ClassificationScheme cs = blm.createClassificationScheme(blm
- .createInternationalString(str1), blm
- .createInternationalString(str2));
- return cs;
- }
-
-
- /**
- * Setup the database.
- * @throws Exception
- */
- @BeforeClass
- public static void runBeforeAllTests() throws Exception {
- try {
- //Set the juddi properties file in System so juddi will pick it up later and use the test values.
- String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-unittest.properties";
- System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- //Read this properties file to get the db connection string
- Properties props = new Properties();
- InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
- props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- database = "hsqldb";
- //Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(getPrefix() + "build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
- database = "mysql";
- } //add and test your own database..
-
- //Get the registry-schema create scripts
- String sqlDir = getPrefix() + "install/jUDDI-registry/sql/" + database + "/";
- //Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try {
- Class.forName(mDbDriver);
- } catch (Exception e) {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
- e.printStackTrace();
- return;
- }
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
- Statement stmnt = con.createStatement();
- log.log(Priority.INFO, "Dropping the schema if exist");
- stmnt.execute(sqlDropCmd);
- log.log(Priority.INFO, "Creating the juddi-schema");
- stmnt.execute(sqlCreateCmd);
- log.log(Priority.INFO, "Adding the jbossesb publisher");
- stmnt.execute(sqlInsertPubCmd);
- } catch (Exception e) {
- log.log(Priority.ERROR, e.getMessage(), e);
- log.log(Priority.ERROR, "We should stop testing, since we don't have a db.");
- assertTrue(false);
- }
- }
- /**
- * Shutdown the database
- * @throws Exception
- */
- @AfterClass
- public static void runAfterAllTests() throws Exception {
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
- }
- /**
- * When performing file system interaction, the user.dir may differ (i.e. running the
- * tests from within eclipse).
- */
- private static String getPrefix()
- {
- String prefix="";
- String baseDir = System.getProperty("user.dir");
- log.log(Priority.INFO, baseDir);
- if (!baseDir.endsWith("product")) {
- prefix = "product/";
- }
- return prefix;
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(PublishOrgUnitTest.class);
- }
-
-}
Added: labs/jbossesb/trunk/product/etc/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/etc/test/resources/log4j.xml 2006-10-26 14:30:18 UTC (rev 7143)
+++ labs/jbossesb/trunk/product/etc/test/resources/log4j.xml 2006-10-26 14:30:50 UTC (rev 7144)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.10 2006/04/21 17:29:20 csuconic Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./trailblazer.log"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+ <category name="org.jboss.serial">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+ <category name="jacorb">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit JBoss categories -->
+ <category name="org.jboss">
+ <priority value="DEBUG"/>
+ </category>
+
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit Axis based webservice category -->
+ <category name="org.jboss.webservice">
+ <priority value="DEBUG"/>
+ </category>
+ <category name="org.jboss.axis">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.milyn">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.milyn.delivery.SmooksXML">
+ <priority value="DEBUG"/>
+ </category>
+ <category name="org.milyn.delivery.serialize.Serializer">
+ <priority value="DEBUG"/>
+ </category>
+ <category name="org.milyn.cdr.XMLConfigDigester">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBossWS webservice category
+ <category name="org.jboss.ws">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+</log4j:configuration>
More information about the jboss-svn-commits
mailing list