[jbpm-commits] JBoss JBPM SVN: r6119 - in projects/businesslink/src/main/java/org/jbpm/businesslink: api and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 22 06:50:01 EST 2010


Author: tom.baeyens at jboss.com
Date: 2010-01-22 06:50:00 -0500 (Fri, 22 Jan 2010)
New Revision: 6119

Added:
   projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
   projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/
   projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
   projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/
   projects/businesslink/src/main/java/org/jbpm/businesslink/test/
   projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
   projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java
   projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
Removed:
   projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java
   projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java
Modified:
   projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java
Log:
adding persistence

Deleted: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java	2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2005 JBoss Inc
- * 
- * 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 org.jbpm.businesslink.api;
-
-import java.util.List;
-
-
-/** central service access to greenlight facilities.
- * 
- * authenticated user is assumed to be accessible by the service implementation.
- * 
- * @author Tom Baeyens
- */
-public interface BusinessLinkService {
-
-  List<Artifact> getArtifacts(String directoryPath);
-
-  List<Link> getLinks(String path);
-  Link createLink(String artifactA, String artifactB);
-  void updateLink(Link link);
-  Link deleteLink(Link link);
-
-//  List<Comment> getComments(String path);
-//  void createComment(String path, String text);
-//  void updateComment(Comment comment);
-//  void deleteComment(Comment comment);
-//
-//  Watch createWatch(String path);
-//  List<Watch> getWatchers(String path);
-//  void updateWatch(Watch watch);
-//  void deleteWatch(Watch watch);
-}

Added: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java	                        (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * 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 org.jbpm.businesslink.api;
+
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface BusinessLinkSession {
+
+  List<Artifact> getArtifacts(String directoryPath);
+
+  List<Link> getLinks(String path);
+  Link createLink(String artifactA, String artifactB);
+  void updateLink(Link link);
+  Link deleteLink(Link link);
+
+//  List<Comment> getComments(String path);
+//  void createComment(String path, String text);
+//  void updateComment(Comment comment);
+//  void deleteComment(Comment comment);
+//
+//  Watch createWatch(String path);
+//  List<Watch> getWatchers(String path);
+//  void updateWatch(Watch watch);
+//  void deleteWatch(Watch watch);
+
+}


Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java	2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2005 JBoss Inc
- * 
- * 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 org.jbpm.businesslink.internal;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.businesslink.api.Artifact;
-import org.jbpm.businesslink.api.BusinessLinkService;
-import org.jbpm.businesslink.api.Link;
-import org.jbpm.businesslink.internal.spi.Repository;
-
-
-/**
- * @author Tom Baeyens
- */
-public class BusinessLinkServiceImpl implements BusinessLinkService {
-  
-  Map<String, Repository> repositories = new HashMap<String, Repository>();
-  
-  public void addRepository(Repository repository) {
-    repositories.put(repository.getName(), repository);
-  }
-
-  public List<Artifact> getArtifacts(String directoryPath) {
-    int slashIndex = directoryPath.indexOf('/');
-    if (slashIndex==-1) {
-      throw new RuntimeException("invalid directory path: no slash: "+directoryPath);
-    }
-    String repositoryName = directoryPath.substring(0, slashIndex);
-    Repository repository = repositories.get(repositoryName);
-
-    String repoPath = directoryPath.substring(slashIndex+1);
-    return repository.getArtifacts(repoPath);
-  }
-
-
-  public Link createLink(String artifactA, String artifactB) {
-    return null;
-  }
-
-  public Link deleteLink(Link link) {
-    return null;
-  }
-
-  public List<Link> getLinks(String path) {
-    return null;
-  }
-
-  public void updateLink(Link link) {
-  }
-}

Modified: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java	2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -40,7 +40,7 @@
   }
 
   public String getPath() {
-    return fileRepository.name+'/'+path;
+    return fileRepository.getName()+'/'+path;
   }
 
   public String getType() {

Added: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java	                        (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * 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 org.jbpm.businesslink.internal.log;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class LogFormatter extends Formatter {
+  
+  static final String NEWLINE = System.getProperty("line.separator");
+  static final DateFormat dateTimeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
+  static final Map<Level, String> levels = new HashMap<Level, String>();
+  private static Map<Integer, Integer> indentations = new HashMap<Integer, Integer>();
+
+  
+  static {
+    levels.put(Level.ALL,     "ALL");
+    levels.put(Level.CONFIG,  "CFG");
+    levels.put(Level.FINE,    "FIN");
+    levels.put(Level.FINER,   "FNR");
+    levels.put(Level.FINEST,  "FST");
+    levels.put(Level.INFO,    "INF");
+    levels.put(Level.OFF,     "OFF");
+    levels.put(Level.SEVERE,  "SEV");
+    levels.put(Level.WARNING, "WRN");
+  }
+
+  public String format(LogRecord logRecord) {
+    StringWriter msg = new StringWriter();
+    if (logRecord.getThrown()!=null) {
+      msg.append("### EXCEPTION ###########################################");
+      msg.append(NEWLINE);
+    }
+    msg.append(dateTimeFormat.format(new Date()));
+    msg.append(" ");
+    msg.append(levels.get(logRecord.getLevel()));
+    msg.append(" ");
+
+    int threadId = logRecord.getThreadID();
+    for (int i=0; i<getIndentation(threadId); i++) {
+      msg.append("  ");
+    }
+    
+    msg.append("| [");
+    
+    String loggerName = logRecord.getLoggerName();
+    int dotIndex = loggerName.lastIndexOf('.');
+    if (dotIndex!=-1) {
+      loggerName = loggerName.substring(dotIndex+1);
+    }
+    msg.append(loggerName);
+    
+    msg.append("] ");
+    
+    msg.append(logRecord.getMessage());
+    if (logRecord.getThrown()!=null) {
+      msg.append(NEWLINE);
+      logRecord.getThrown().printStackTrace(new PrintWriter(msg));
+      msg.append("### EXCEPTION ###########################################");
+    }
+    msg.append(NEWLINE);
+    return msg.toString();
+  }
+
+  private int getIndentation(int threadId) {
+    Integer indentation = indentations.get(threadId);
+    if (indentation==null) {
+      indentation = indentations.size();
+      indentations.put(threadId, indentation);
+    }
+    return indentation;
+  }
+
+  public static void resetIndentation() {
+    indentations = new HashMap<Integer, Integer>();
+  }
+}


Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java	                        (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * 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 org.jbpm.businesslink.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.LogManager;
+
+import org.hibernate.cfg.Configuration;
+import org.jbpm.businesslink.internal.file.FileRepository;
+import org.jbpm.businesslink.internal.spi.Repository;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessLinkConfiguration {
+  
+  static {
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    InputStream inputStream = classLoader.getResourceAsStream("logging.properties");
+    try {
+      if (inputStream != null) {
+        LogManager.getLogManager().readConfiguration(inputStream);
+
+        String redirectCommons = LogManager.getLogManager().getProperty("redirect.commons.logging");
+        if ( (redirectCommons!=null)
+             && (! redirectCommons.equalsIgnoreCase("disabled"))
+             && (! redirectCommons.equalsIgnoreCase("off"))
+             && (! redirectCommons.equalsIgnoreCase("false"))
+           ) {
+          System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger" );
+        }
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new RuntimeException("couldn't initialize logging properly", e);
+    } finally {
+      if (inputStream != null) {
+        try {
+          inputStream.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+
+  Map<String, Repository> repositories = new HashMap<String, Repository>();
+  Configuration hibernateConfiguration = new Configuration();
+  
+  public BusinessLinkConfiguration fileRepository(String name, String rootPath) {
+    addRepository(new FileRepository(name, rootPath));
+    return this;
+  }
+  
+  public BusinessLinkConfiguration hibernateCfgResource(String hibernateCfgResource) {
+    hibernateConfiguration.configure(hibernateCfgResource);
+    return this;
+  }
+
+  public BusinessLinkConfiguration hibernateMappingResource(String hibernateMappingResource) {
+    hibernateConfiguration.addResource(hibernateMappingResource);
+    return this;
+  }
+
+  public BusinessLinkSessionFactory buildBusinessLinkSessionFactory() {
+    return new BusinessLinkSessionFactory(this);
+  }
+
+  void addRepository(Repository repository) {
+    repositories.put(repository.getName(), repository);
+  }
+}


Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java (from rev 6111, projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java)
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java	                        (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * 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 org.jbpm.businesslink.test;
+
+import java.util.Map;
+
+import org.hibernate.SessionFactory;
+import org.jbpm.businesslink.internal.spi.Repository;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessLinkSessionFactory {
+  
+  Map<String, Repository> repositories;
+  SessionFactory sessionFactory;
+
+  public BusinessLinkSessionFactory(BusinessLinkConfiguration businessLinkConfiguration) {
+    repositories = businessLinkConfiguration.repositories;
+    sessionFactory = businessLinkConfiguration.hibernateConfiguration.buildSessionFactory();
+  }
+
+  public TestBusinessLinkSession openSession() {
+    return new TestBusinessLinkSession(this);
+  }
+  
+  public Map<String, Repository> getRepositories() {
+    return repositories;
+  }
+  public SessionFactory getSessionFactory() {
+    return sessionFactory;
+  }
+}


Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java	                        (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java	2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * 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 org.jbpm.businesslink.test;
+
+import org.hibernate.Transaction;
+import org.jbpm.businesslink.internal.svc.BusinessLinkSessionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestBusinessLinkSession extends BusinessLinkSessionImpl {
+  
+  Transaction transaction;
+
+  public TestBusinessLinkSession(BusinessLinkSessionFactory businessLinkSessionFactory) {
+    super(businessLinkSessionFactory);
+    this.transaction = session.beginTransaction();
+  }
+  
+  public void commit() {
+    // TODO put proper exception handling in place
+    transaction.commit();
+    session.close();
+  }
+
+  public void rollback() {
+    // TODO put proper exception handling in place
+    transaction.rollback();
+    session.close();
+  }
+}


Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbpm-commits mailing list