From: <jbo...@li...> - 2006-05-01 01:47:33
|
Author: unibrew Date: 2006-04-30 21:47:21 -0400 (Sun, 30 Apr 2006) New Revision: 4022 Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/maven.xml labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.properties labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/persistence.xml labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/tld/ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/tld/forge.tld Log: [JBLAB-655] Adding project to JBoss Labs containing EJB3 for DownloadCounters Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/maven.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/maven.xml 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/maven.xml 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,31 @@ +<!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util"> + <!-- Default war-project goals --> + + <goal name="all"> + <attainGoal name="prj-all" /> + </goal> + + <goal name="build"> + <ant:copy todir="target/classes"> + <ant:fileset dir="src/web/WEB-INF"> + <ant:filename name="persistence.xml" /> + </ant:fileset> + </ant:copy> + <attainGoal name="jar" /> + </goal> + + <goal name="deploy"> + <ant:copy + tofile="${local.deploy.dir}/counters.ejb3" + file="target/counters-ejb3-1.0.jar" /> + </goal> + + <goal name="clean"> + <attainGoal name="prj-clean" /> + </goal> +</project> Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.properties =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.properties 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.properties 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,3 @@ +maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ +maven.junit.fork=yes +maven.war.src=${basedir}/src/web Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/project.xml 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,38 @@ +<?xml version='1.0' encoding='ISO-8859-1'?> +<!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> +<project> + <pomVersion>3</pomVersion> + <extend>../common.xml</extend> + <id>counters-ejb3</id> + <name>Download Counters EJB</name> + <currentVersion>1.0</currentVersion> + <organization> + <name>JBoss Labs</name> + <url>http://www.jboss.org</url> + </organization> + <description></description> + <dependencies> + <dependency> + <groupId>jboss-forge</groupId> + <artifactId>forge-common</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>ejb3-persistence</artifactId> + <version>3.0RC6</version> + <jar>ejb3-persistence.jar</jar> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-ejb3x</artifactId> + <version>3.0RC6</version> + <jar>jboss-ejb3x.jar</jar> + </dependency> + + </dependencies> +</project> Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersEntity.java 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,113 @@ + + /* + * JBoss, Home of Professional Open Source + * Copyright 2005, 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.forge.counters; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * + * @author Ryszard Kozmik + * + */ +@Entity +@Table(name = "jblab_counters") +public class CountersEntity +{ + + private String path; + private long counterValue; + private String order; + private String projectId; + private boolean visible; + + public CountersEntity(String path) + { + this(path,0L); + } + + public CountersEntity (String path, long initValue) + { + this.path = path; + this.counterValue=initValue; + } + + @Id + @Column(name = "path") + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + @Column(name = "counter") + public long getCounterValue() + { + return counterValue; + } + + public void setCounterValue(long cv) + { + this.counterValue = cv; + } + + public void setOrder(String order) + { + this.order = order; + } + + @Column(name = "order") + public String getOrder() + { + return order; + } + + public void setProjectId(String projectId) + { + this.projectId = projectId; + } + + @Column(name = "projectid") + public String getProjectId() + { + return projectId; + } + + public void setVisible(boolean visible) + { + this.visible = visible; + } + + @Column(name= "visible") + public boolean isVisible() + { + return visible; + } +} Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersMDB.java 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,50 @@ + + /* + * JBoss, Home of Professional Open Source + * Copyright 2005, 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.forge.counters; +/* +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.Message; + + + /** + * + * @author Ryszard Kozmik + * + */ /* +@MessageDriven(activateConfig = +{ + @ActivationConfigProperty(propertyName="destinationType", + propertyValue="javax.jms.Queue"), + @ActivationConfigProperty(propertyName="destination", + propertyValue="queue/mdb") +})*/ +public class CountersMDB +{ +/* + public void onMessage (Message msg) { + + } +*/ +} Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/java/org/jboss/forge/counters/CountersServiceBean.java 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,76 @@ + + /* + * JBoss, Home of Professional Open Source + * Copyright 2005, 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.forge.counters; + +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import org.jboss.forge.common.projects.Counter; +import org.jboss.forge.common.projects.CountersService; +import org.jboss.forge.common.projects.Sorting; + + +/** + * + * @author Ryszard Kozmik + * + */ +@Stateless +public class CountersServiceBean implements CountersService +{ + + @PersistenceContext (unitName="counters") + protected EntityManager em; + + public void createCounterWithPath(String path) + { + CountersEntity ce = new CountersEntity(path); + em.persist(ce); + } + + public Map<String,Counter> getCountersMap() + { + List<CountersEntity> countersRows = em.createQuery("from CountersEntity e").getResultList(); + Map<String,Counter> countersMap = new Hashtable<String,Counter>(countersRows.size()); + for (CountersEntity counter : countersRows) + { + countersMap.put(counter.getPath(), + new Counter(counter.getCounterValue(), + counter.getProjectId(), + counter.isVisible(), + Sorting.valueOf(counter.getOrder()))); + } + return countersMap; + } + + public void updateCounters(Map<String,Counter> downloadCounters) + { + List<CountersEntity> countersRows = em.createQuery("from CountersEntity e").getResultList(); + } +} Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/persistence.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/persistence.xml 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/persistence.xml 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,7 @@ +<entity-manager> + <name>counters</name> + <jta-data-source>java:/JBossDS</jta-data-source> + <properties> + <property name="hibernate.hbm2ddl.auto" value="update" /> + </properties> +</entity-manager> Added: labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/tld/forge.tld =================================================================== --- labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/tld/forge.tld 2006-05-01 01:43:32 UTC (rev 4021) +++ labs/jbosslabs/trunk/portal-extensions/counters-ejb3/src/web/WEB-INF/tld/forge.tld 2006-05-01 01:47:21 UTC (rev 4022) @@ -0,0 +1,139 @@ +<taglib xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd" + version="2.0"> + <!-- + JBoss, the OpenSource J2EE webOS + Distributable under LGPL license. + See terms of license at gnu.org. + --> + <tlib-version>1.1</tlib-version> + <jsp-version>2.0</jsp-version> + <shortname>forge</shortname> + <info>Forge tags</info> + + <tag> + <name>pageURL</name> + <tagclass>org.jboss.forge.common.taglib.PageURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>param</name> + <tagclass>org.jboss.forge.common.taglib.ParamTag</tagclass> + <attribute> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>value</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>wikiURL</name> + <tagclass>org.jboss.forge.common.taglib.WikiURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>freezoneURL</name> + <tagclass>org.jboss.forge.common.taglib.FreezoneURLTag</tagclass> + <attribute> + <name>page</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>projectURL</name> + <tagclass>org.jboss.forge.common.taglib.ProjectURLTag</tagclass> + <attribute> + <name>project</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>page</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>categoryURL</name> + <tagclass>org.jboss.forge.common.taglib.CategoryURLTag</tagclass> + <attribute> + <name>category</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>form</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>selectedProject</name> + <tagclass>org.jboss.forge.common.taglib.SelectedProjectTag</tagclass> + </tag> + + <tag> + <name>imagePath</name> + <tagclass>org.jboss.forge.common.taglib.ImagePathTag</tagclass> + <attribute> + <name>src</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + <attribute> + <name>project</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>attrValue</name> + <tagclass>org.jboss.forge.common.taglib.AttrValueTag</tagclass> + <attribute> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> + + <tag> + <name>attrIf</name> + <tagclass>org.jboss.forge.common.taglib.AttrIfTag</tagclass> + <attribute> + <name>name</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + </attribute> + </tag> +</taglib> |