tubo-commits Mailing List for Tubo
Status: Alpha
Brought to you by:
maldito_orco
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(24) |
Nov
(13) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
(6) |
Mar
|
Apr
|
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mal...@us...> - 2010-03-17 12:10:29
|
Revision: 126 http://tubo.svn.sourceforge.net/tubo/?rev=126&view=rev Author: maldito_orco Date: 2010-03-17 12:10:23 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Fin version 1.0-alpha2 Added Paths: ----------- tags/1.0-alpha2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2010-03-17 12:02:34
|
Revision: 125 http://tubo.svn.sourceforge.net/tubo/?rev=125&view=rev Author: maldito_orco Date: 2010-03-17 12:02:27 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Added Paths: ----------- trunk/examples/unlog/ trunk/examples/unlog/pom.xml trunk/examples/unlog/src/ trunk/examples/unlog/src/assembly/ trunk/examples/unlog/src/assembly/simplest.xml trunk/examples/unlog/src/main/ trunk/examples/unlog/src/main/java/ trunk/examples/unlog/src/main/java/org/ trunk/examples/unlog/src/main/java/org/tubo/ trunk/examples/unlog/src/main/java/org/tubo/example/ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/LoggerComponent.java trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumer.java trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumerLoader.java trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogLoggingEvent.java trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogSimpleLayout.java trunk/examples/unlog/src/main/resources/ trunk/examples/unlog/src/main/resources/log4j.xml trunk/examples/unlog/src/main/resources/tubo.xml trunk/examples/unlog/src/shell/ trunk/examples/unlog/src/shell/starttubo.sh trunk/examples/unlog/src/site/ trunk/examples/unlog/src/site/apt/ trunk/examples/unlog/src/site/apt/index.apt trunk/examples/unlog/src/site/site.xml Added: trunk/examples/unlog/pom.xml =================================================================== --- trunk/examples/unlog/pom.xml (rev 0) +++ trunk/examples/unlog/pom.xml 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,126 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <!-- + - $Id: pom.xml 85 2006-12-15 21:50:59Z maldito_orco $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - 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. + --> + + <!-- + - Parent + --> + <parent> + <groupId>org.tubo</groupId> + <artifactId>tubo</artifactId> + <version>1.0-alpha2</version> + </parent> + <!-- + - POM Version + --> + <modelVersion>4.0.0</modelVersion> + <!-- + - Identification + --> + <groupId>org.tubo</groupId> + <artifactId>tubo-example-unlog</artifactId> + <packaging>jar</packaging> + <name>Tubo Adapter - Unlog Example</name> + <!-- + - Dependencies + --> + <dependencies> + <!-- tubo --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-core</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- logging --> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>${log4j-version}</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- commons-logging --> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>${commons-logging-version}</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- junit --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit-version}</version> + <type>jar</type> + <scope>test</scope> + </dependency> + </dependencies> + <!-- + - Build + --> + <build> + <plugins> + <!-- jar --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>org.tubo.system.main.Daemon</mainClass> + <addClasspath>true</addClasspath> + <classpathPrefix>../lib/</classpathPrefix> + </manifest> + </archive> + </configuration> + </plugin> + <!-- assembly --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/assembly/shell.xml</descriptor> + </descriptors> + <!--archive> + <manifest> + <mainClass>org.tubo.system.main.Daemon</mainClass> + <addClasspath>true</addClasspath> + <classpathPrefix>../lib/</classpathPrefix> + </manifest> + </archive--> + </configuration> + </plugin> + <!-- SITE PLUGIN --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <stagingDirectory>${basedir}/../../target/staged-site</stagingDirectory> + </configuration> + </plugin> + </plugins> + </build> + +</project> Property changes on: trunk/examples/unlog/pom.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/assembly/simplest.xml =================================================================== --- trunk/examples/unlog/src/assembly/simplest.xml (rev 0) +++ trunk/examples/unlog/src/assembly/simplest.xml 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,30 @@ +<assembly> + <id>distribution</id> + <formats> + <format>dir</format> + </formats> + <!--fileSets> + <fileSet> + <directory>src/shell</directory> + <outputDirectory>bin</outputDirectory> + <filtered>true</filtered> + <fileMode>0777</fileMode> + <directoryMode>0777</directoryMode> + </fileSet> + </fileSets--> + <files> + <file> + <source>src/shell/run.sh</source> + <outputDirectory>bin</outputDirectory> + <fileMode>0777</fileMode> + <filtered>true</filtered> + </file> + </files> + <dependencySets> + <dependencySet> + <unpack>false</unpack> + <scope>runtime</scope> + <outputDirectory>lib</outputDirectory> + </dependencySet> + </dependencySets> +</assembly> Property changes on: trunk/examples/unlog/src/assembly/simplest.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/main/java/org/tubo/example/unlog/LoggerComponent.java =================================================================== --- trunk/examples/unlog/src/main/java/org/tubo/example/unlog/LoggerComponent.java (rev 0) +++ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/LoggerComponent.java 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,70 @@ +/** + * $Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $ + * $Revision: 54 $ + * $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.unlog; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.item.Item; + +/** + * <p> + * </p> + * + * <p> + * Created: Oct 21, 2006, 2:07:35 PM<br> + * Last Modification Date: $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 54 $ + */ +public class LoggerComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $"; + private static Log log = LogFactory.getLog(LoggerComponent.class); + + public void execute(FlowContext flowContext) throws TuboException { + // + // get item + Item item = flowContext.getItem(); + // + // get consumed Log Event + LoggingEvent event = (LoggingEvent) item.getConsumedRawData(); + // + // get a logger from the hierarchy. The name of the logger is taken to be the name contained in the event. + Logger remoteLogger = LogManager.getLoggerRepository().getLogger(event.getLoggerName()); + // + // apply the logger-level filter + if(event.getLevel().isGreaterOrEqual(remoteLogger.getEffectiveLevel())) { + // + // finally log the event as if was generated locally + remoteLogger.callAppenders(event); + } + } +} \ No newline at end of file Added: trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumer.java =================================================================== --- trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumer.java (rev 0) +++ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumer.java 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,189 @@ +/** + * $Id: ServerSocketLineReaderConsumer.java 55 2006-11-08 14:06:59Z maldito_orco $ + * $Revision: 55 $ + * $Date: 2006-11-08 11:06:59 -0300 (Wed, 08 Nov 2006) $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.unlog; + +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggingEvent; +import org.tubo.exception.TuboConsumerException; +import org.tubo.resource.consumer.serversocket.ServerSocketConsumer; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.net.Socket; + +/** + * <p> + * This class is a Consumer Component based on ServerSocket. + * When the connection is established on ServerSocketConsumerWorker this class + * call process(Socket) on ServerSocketConsumer which is overwited by this + * class. + * When a process(Socket) is call, streams are opened and delegate procesing + * to process(InputStream,OutputStream). In this method tree event are throw: + * <li> + * <ul>NEW_CONNECTION_EVENT: which can be used to sey hello :)</ul> + * <ul>READ_LINE_EVENT: which is throw when a new line of text is read</ul> + * <ul>GOODBYE_EVENT: which is throw when the text read matches with 'goodbye-words' property</ul> + * </li> + * </p> + * <p> + * The method process(Socket) is override by this class, + * </p> + * + * <p> + * Created: Oct 19, 2006, 6:12:44 PM<br> + * Last Modification Date: $Date: 2006-11-08 11:06:59 -0300 (Wed, 08 Nov 2006) $ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 55 $ + */ +public class ServerSocketLog4jConsumer extends ServerSocketConsumer { + public static final String RCS_ID = "$Id: ServerSocketLineReaderConsumer.java 55 2006-11-08 14:06:59Z maldito_orco $"; + private static Log log = LogFactory.getLog(ServerSocketLog4jConsumer.class); + + public static final String LOG_EVENT = "LOG_EVENT"; + + /** Running flag*/ + private boolean running = false; + + private Socket socket = null; + + + public boolean isRunning() { + return running; + } + + + public void stop() { + // + // set false running flag + running = false; + } + + /** + * <p> + * Override normal ServerSocketConsumer behavior. On this implementation + * obtains in and out streams. Delegate the stream procesing on other + * method. + * </p> + * + * @param socket A new socket open from client + * @throws org.tubo.exception.TuboConsumerException When geting InputStream or OutputStream from socket + */ + public void process(Socket socket) throws TuboConsumerException { + // + // store socket + this.socket = socket; + // + // create OutputStream + ObjectInputStream ois = null; + try { + // + // set true running flag + running = true; + // + // get input + ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); + // + // process streams + process(ois); + } catch (IOException e) { + throw getResourceManager().getExceptionManager().getException(3520,e); + } finally { + // + // set false running flag + running = false; + // + // clear socket + socket = null; + // + // close OutputStream + if (ois != null) + try { + // + // close ois + ois.close(); + } catch (IOException e) { + log.info("Error closing InputStream",e); + } + } + } + + + /** + * <p> + * Streams Procesing. + * </p> + * + * @param ois Object Socket input + * @throws org.tubo.exception.TuboConsumerException + */ + public void process(ObjectInputStream ois) throws TuboConsumerException { + // + // process ois + try { + // + //read LoggingEvent cycle + LoggingEvent event; + while (isRunning()) { + // + // read an event from the wire + event = (LoggingEvent) ois.readObject(); + // + // wrap event + UnlogLoggingEvent unlogEvent = new UnlogLoggingEvent(event); + unlogEvent.setHost(socket.getInetAddress().getCanonicalHostName()); + // + // execute life cycle + doConsumerLifeCycle(LOG_EVENT, unlogEvent); + } + } catch(java.io.EOFException e) { + log.debug("Caught java.io.EOFException closing conneciton."); + } catch(java.net.SocketException e) { + log.error("Caught java.net.SocketException closing conneciton.",e); + } catch(IOException e) { + log.error("Caught java.io.IOException: "+e); + log.error("Closing connection."); + } catch(Exception e) { + log.error("Unexpected exception. Closing conneciton.", e); + } finally { + // + // set false the running flag + running = false; + // + // close connection + if (ois != null) { + try { + ois.close(); + } catch(Exception e) { + log.error("Could not close connection.", e); + } + } + } + } +} \ No newline at end of file Added: trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumerLoader.java =================================================================== --- trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumerLoader.java (rev 0) +++ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/ServerSocketLog4jConsumerLoader.java 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,41 @@ +/** + * $Id: ServerSocketLineReaderConsumerLoader.java 42 2006-10-26 04:57:10Z maldito_orco $ + * $Revision: 42 $ + * $Date: 2006-10-26 01:57:10 -0300 (Thu, 26 Oct 2006) $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.unlog; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.consumer.serversocket.ServerSocketConsumerLoader; + +/** + * Created: Oct 19, 2006, 6:12:44 PM + * Last Modification Date: $Date: 2006-10-26 01:57:10 -0300 (Thu, 26 Oct 2006) $ + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 42 $ + */ +public class ServerSocketLog4jConsumerLoader extends ServerSocketConsumerLoader { + public static final String RCS_ID = "$Id: ServerSocketLineReaderConsumerLoader.java 42 2006-10-26 04:57:10Z maldito_orco $"; + private static Log log = LogFactory.getLog(ServerSocketLog4jConsumerLoader.class); + +} \ No newline at end of file Added: trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogLoggingEvent.java =================================================================== --- trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogLoggingEvent.java (rev 0) +++ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogLoggingEvent.java 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,108 @@ +/** + * $Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $ + * $Revision: 54 $ + * $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.unlog; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; +import org.apache.log4j.Level; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.spi.LocationInfo; +import org.apache.log4j.spi.ThrowableInformation; + +/** + * <p> + * </p> + * + * <p> + * Created: Oct 21, 2006, 2:07:35 PM<br> + * Last Modification Date: $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 54 $ + */ +public class UnlogLoggingEvent extends LoggingEvent { + public static final String RCS_ID = "$Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $"; + private static Log log = LogFactory.getLog(UnlogLoggingEvent.class); + + private LoggingEvent le = null; + private String host; + + public UnlogLoggingEvent(LoggingEvent le) { + super("test",Logger.getLogger(le.getLoggerName()),le.getLevel(),"message",null); + this.le = le; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public LocationInfo getLocationInformation() { + return le.getLocationInformation(); //To change body of overridden methods use File | Settings | File Templates. + } + + public Level getLevel() { + return le.getLevel(); //To change body of overridden methods use File | Settings | File Templates. + } + + public String getLoggerName() { + return le.getLoggerName(); //To change body of overridden methods use File | Settings | File Templates. + } + + public Object getMessage() { + return le.getMessage(); //To change body of overridden methods use File | Settings | File Templates. + } + + public String getNDC() { + return le.getNDC(); //To change body of overridden methods use File | Settings | File Templates. + } + + public Object getMDC(String s) { + return le.getMDC(s); //To change body of overridden methods use File | Settings | File Templates. + } + + public void getMDCCopy() { + le.getMDCCopy(); //To change body of overridden methods use File | Settings | File Templates. + } + + public String getRenderedMessage() { + return le.getRenderedMessage(); //To change body of overridden methods use File | Settings | File Templates. + } + + public String getThreadName() { + return le.getThreadName(); //To change body of overridden methods use File | Settings | File Templates. + } + + public ThrowableInformation getThrowableInformation() { + return le.getThrowableInformation(); //To change body of overridden methods use File | Settings | File Templates. + } + + public String[] getThrowableStrRep() { + return le.getThrowableStrRep(); //To change body of overridden methods use File | Settings | File Templates. + } +} \ No newline at end of file Added: trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogSimpleLayout.java =================================================================== --- trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogSimpleLayout.java (rev 0) +++ trunk/examples/unlog/src/main/java/org/tubo/example/unlog/UnlogSimpleLayout.java 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,84 @@ +/** + * $Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $ + * $Revision: 54 $ + * $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.unlog; + +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Layout; +import org.apache.log4j.spi.LoggingEvent; + +/** + * <p> + * </p> + * + * <p> + * Created: Oct 21, 2006, 2:07:35 PM<br> + * Last Modification Date: $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 54 $ + */ +public class UnlogSimpleLayout extends Layout { + public static final String RCS_ID = "$Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $"; + private static Log log = LogFactory.getLog(UnlogSimpleLayout.class); + + StringBuffer sbuf = new StringBuffer(128); + + /** + Returns the log statement in a format consisting of the + <code>level</code>, followed by " - " and then the + <code>message</code>. For example, <pre> INFO - "A message" + </pre> + + <p>The <code>category</code> parameter is ignored. + <p> + @return A byte array in SimpleLayout format. + */ + public String format(LoggingEvent event) { + sbuf.setLength(0); + if (event instanceof UnlogLoggingEvent) + sbuf.append("[").append(((UnlogLoggingEvent)event).getHost()).append("] "); + sbuf.append(event.getLevel().toString()); + sbuf.append(" - "); + sbuf.append(event.getRenderedMessage()); + sbuf.append(LINE_SEP); + return sbuf.toString(); + } + + /** + The SimpleLayout does not handle the throwable contained within + {@link LoggingEvent LoggingEvents}. Thus, it returns + <code>true</code>. + + @since version 0.8.4 */ + public boolean ignoresThrowable() { + return true; + } + + + public void activateOptions() { + //To change body of implemented methods use File | Settings | File Templates. + } +} \ No newline at end of file Added: trunk/examples/unlog/src/main/resources/log4j.xml =================================================================== --- trunk/examples/unlog/src/main/resources/log4j.xml (rev 0) +++ trunk/examples/unlog/src/main/resources/log4j.xml 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <!-- BEGIN APPENDER: CONSOLE APPENDER (stdout) --> + <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> + <!--param name="threshold" value="info" /--> + <!--layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c{1}%m%n"/> + </layout--> + <layout class="org.tubo.example.unlog.UnlogSimpleLayout"/> + </appender> + + <!--logger name="org.tubo"> + <level value="trace"/> + <appender-ref ref="stdout"/> + </logger--> + + <logger name="org.apache"> + <level value="error"/> + <appender-ref ref="stdout"/> + </logger> + + <logger name="org.springframework"> + <level value="error"/> + <appender-ref ref="stdout"/> + </logger> + + <root> + <level value="debug"/> + <appender-ref ref="stdout"/> + </root> + +</log4j:configuration> Property changes on: trunk/examples/unlog/src/main/resources/log4j.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/main/resources/tubo.xml =================================================================== --- trunk/examples/unlog/src/main/resources/tubo.xml (rev 0) +++ trunk/examples/unlog/src/main/resources/tubo.xml 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,43 @@ +<tubo-configuration> + + <consumer-set> + <!-- + - Unlog serversocket consumer + --> + <consumer id="unlog-socket-consumer" + consumerClassname="org.tubo.example.unlog.ServerSocketLog4jConsumer" + type="pooled" + maxCapacity="3" + > + <property name="ports" value="10000" /> + </consumer> + </consumer-set> + + <component-set> + <!-- + - Unlog logger component + --> + <component id="unlog-logger" + componentClassname="org.tubo.example.unlog.LoggerComponent" + type="singleton" + > + </component> + </component-set> + + <flow-set> + <!-- + - Unlog Flow + --> + <flow id="unlog-flow"> + <consume> + <from refId="unlog-socket-consumer" /> + </consume> + <node-list> + <!-- log input log4j event --> + <component-node refId="unlog-logger" /> + </node-list> + </flow> + </flow-set> + + +</tubo-configuration> Property changes on: trunk/examples/unlog/src/main/resources/tubo.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/shell/starttubo.sh =================================================================== --- trunk/examples/unlog/src/shell/starttubo.sh (rev 0) +++ trunk/examples/unlog/src/shell/starttubo.sh 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,3 @@ +#!/bin/sh + +java -jar ../lib/tubo-example-simplest-${tubo.version}.jar Property changes on: trunk/examples/unlog/src/shell/starttubo.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/site/apt/index.apt =================================================================== --- trunk/examples/unlog/src/site/apt/index.apt (rev 0) +++ trunk/examples/unlog/src/site/apt/index.apt 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,311 @@ + ------ + Simplest Example + ------ + Julio Lorenzo + <mal...@us...> + ------ + February 07, 2007 + +Simplest Example + + This example is the simplest that we can create because this example don't + create any component and don't configure anything, just execute Tubo with + default configuration. + +* Default Tubo configuration, Echo Configuration + + Tubo by default create a echo service used to ping the instance. To make this + appends by default there are some components preconfigured and a echo flow + supporting service. + + This service is a socket service listen on a port, when a client connect to + this a welcome message is sended to client, and each line than is readed from + client is sended back to him. If the line "bye" is readed, a goodbye + message is sended to client and the connection is closed. + + To support this service two components are created: + + * <<ServerSocketLineReaderConsumer>> have the responsability of listen on + configured ports, create client connection and activate some event or flag + to allow the creation of a welcome message, read input line by line and + send back response, close connection. + + * <<EchoComponent>> this component have the responability of generate the + diferent message responses (hello, goodbye, echo) to client. + + [] + +** Echo Consumer + + Consume phase strategy is based on a consumer component + <<<ServerSocketLineReaderConsumer>>> which use a ServerSocket listen on a + port. When a new connection arrives the component generate a event and begin + to read the input stream line by line. Each line generate a new event and when + the line readed match with the goodbye word then the goodbye event is + generated. + + Each event is processed by the consumer life cycle activating an executing a + determinated Flow. Event consept is used to show a determinated activity or + "event" has happened on some component, in this case on Consumer. To share + data the event originator or any component can use Item properties. + + Don't forget than Tubo is based on Pipeline Arquitecture. On this Arquitecture + a set of nodes (aka Components) are conecteds one to anothers making a king + of pipeline or node flow. Each conection between nodes is made of data (aka + Item), and each node transform this data. Each Node have an Input and a Output + (in a traditional point of view). + + +*** Events and properties + + This component fire tree kinds of events and use two properties, one to send + readed input line to flow, and one to write the output message generated on + flow. + +*--------------------------+------------------------------------------------------+ +| <<NEW_CONNECTION_EVENT>> | This event is fired when a new connection is created, given the posibility of write a welcome message. +| | +| | Properties: +| | <<<SSLINEREADER_INPUT>>>: This property is setted null by Consumer before fire the event. +| | <<<SSLINEREADER_OUTPUT>>>: This property is used by components on flow to store the output message. +*--------------------------+------------------------------------------------------+ +| <<READ_LINE_EVENT>> | This event is fired when a new line is readed.| +| | +| | Properties: +| | <<<SSLINEREADER_INPUT>>>: This property is setted with the line readed. +| | <<<SSLINEREADER_OUTPUT>>>: This property is used by components on flow to store the output message. +*--------------------------+------------------------------------------------------+ +| <<GOODBYE_EVENT>> | This event is fired when a goodbye word is readed. After this event is processed the connection will be closed. +| | +| | Properties: +| | <<<SSLINEREADER_INPUT>>>: This property is setted with the line readed. +| | <<<SSLINEREADER_OUTPUT>>>: This property is used by components on flow to store the output message. +*--------------------------+------------------------------------------------------+ +~~Events and Properties used by consumer <<<ServerSocketLineReaderConsumer>>> + + +*** Consumer configuration + + This consumer create a socket with client, and consume input line by line. + Because the socket between client and consumer is a statefull condition, the + consumer assigned will be free when the conection is closed (is implemented + in this way, not is the only way!) + + Will see than this consumer is listening at port 6666 with a concurrency of 3 + (three client connections can be procesed at time), if the three consumers + are busy (because are three connections open) then the next clients they will + be able to create connections but will be blocked waiting for next free + consumer. + + The process cut condition is configured on <<<goodbye-words>>> property. In + this case, the connection will finish if client send "<<<bye>>>" or "<<<.>>>" + words. + +---- +<consumer id="tubo-echo-consumer" + consumerClassname="org.tubo.resource.consumer.serversocketlinereader.ServerSocketLineReaderConsumer" + type="pooled" + maxCapacity="3" + > + <property> + <prop-name>ports</prop-name> + <prop-value>6666</prop-value> + </property> + <property> + <prop-name>goodbye-words</prop-name> + <prop-value>bye,.</prop-value> + </property> +</consumer> +---- + + + +** Echo Component + + This component is really simple, have three executional methods than can be + mapped to listeners and two properties, one for input and one for output. + +*** Events and properties + +*----------------+------------------------------------------------------+ +| <<sayHelo>> | This method is used by the listener of the <<<NEW_CONNECTION_EVENT>>> event. +| | +| | Properties: +| | <<<ECHO_OUTPUT>>>: In this property put the Hello Message +*----------------+------------------------------------------------------+ +| <<execute>> | This is the default executional method for components, when a component don't listen a particular event this method is executed. This echo component use this method for copy input on output. +| | +| | Properties: +| | <<<ECHO_INPUT>>>: Input +| | <<<ECHO_OUTPUT>>>: Output +*----------------+------------------------------------------------------+ +| <<sayGoodbye>> | This event is fired when a goodbye word is readed. After this event is processed the connection will be closed. +| | +| | Properties: +| | <<<ECHO_INPUT>>>: Input +| | <<<ECHO_OUTPUT>>>: Goodbye message. +*----------------+------------------------------------------------------+ + +*** Echo Code + + This is the code of Echo component. + +---- +public class EchoComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $"; + private static Log log = LogFactory.getLog(EchoComponent.class); + + public static final String ECHO_INPUT_PROPERTY = "ECHO_INPUT"; + public static final String ECHO_OUTPUT_PROPERTY = "ECHO_OUTPUT"; + + + public void sayHelo(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,"helo"); + } + + public void sayGoodbye(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,"goodbye"); + } + + public void execute(FlowContext flowContext) throws TuboException { + // + // get item + Item item = flowContext.getItem(); + // + // get input + String input = (String)item.getProperty(ECHO_INPUT_PROPERTY); + // + // put input in output + item.setProperty(ECHO_OUTPUT_PROPERTY,input); + } +} +---- + +*** Echo Configuration + + This is the definition of Echo Component + +---- +<component id="tubo-echo-component" + componentClassname="org.tubo.resource.component.echo.EchoComponent" + > +</component> +---- + + + +** Transformation + + Because the Consumer output property name and Echo input property name + don't match we need a simple transformation to make input available to + Echo and output availavble to Consumer. + + +*** Transformation Code + + This is the code of Echo component. + +---- +public class SimpleTransformComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id: SimpleTransformComponent.java 78 2006-12-15 21:37:36Z maldito_orco $"; + private static Log log = LogFactory.getLog(SimpleTransformComponent.class); + + + public void execute(FlowContext flowContext) throws TuboException { + // + // get item + Item item = flowContext.getItem(); + // + // + int i=0; + String transform = null; + do { + // + // get i-esima transformation + String ti = "t"+i; + transform = (String)item.getProperty(ti); + // + // if i-esima transformation is null then is cut condition + if (transform!=null) { + // + // parse transformation + int inx = transform.indexOf("->"); + String from = transform.substring(0,inx).trim(); + String to = transform.substring(inx+"->".length(),transform.length()).trim(); + // + // transform + Object value = item.getProperties().remove(from); + item.setProperty(to,value); + // + // increment i + i++; + } + // + // check cut condition + } while (transform!=null); + } +} +---- + +*** Transformation Configuration + + This is the definition of Transformation + +---- +<component id="simple-transform" + componentClassname="org.tubo.resource.component.transform.SimpleTransformComponent" + type="singleton" + > +</component> +---- + + + +** Echo Flow + + A Flow is a pipeline of components with zero, one or more Consumers on + beginning and zero, one or more Nodes to execute. + + A Node in a flow can be a Component or a Flow. + +*** Flow Configuration + +---- +<flow id="tubo-echo-flow"> + <consume> + <from refId="tubo-echo-consumer" /> + </consume> + <node-list> + <!-- transform input ss to input echo--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>SSLINEREADER_INPUT->ECHO_INPUT</prop-value> + </property> + </component-node> + <!-- execute echo --> + <component-node refId="tubo-echo-component"> + <listen> + <event> + <action>NEW_CONNECTION_EVENT</action> + <execute>sayHelo</execute> + </event> + <event> + <action>GOODBYE_EVENT</action> + <execute>sayGoodbye</execute> + </event> + <!-- by default if not defined listens or not matched events, method 'execute' is invoked --> + </listen> + </component-node> + <!-- transform output echo to output ss--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>ECHO_OUTPUT->SSLINEREADER_OUTPUT</prop-value> + </property> + </component-node> + </node-list> +</flow> +---- + + Property changes on: trunk/examples/unlog/src/site/apt/index.apt ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/unlog/src/site/site.xml =================================================================== --- trunk/examples/unlog/src/site/site.xml (rev 0) +++ trunk/examples/unlog/src/site/site.xml 2010-03-17 12:02:27 UTC (rev 125) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<!-- + - $Id: site.xml 14 2006-10-19 14:13:41Z maldito_orco $ + - $Revision: 14 $ + - $Date: 2006-10-19 11:13:41 -0300 (Thu, 19 Oct 2006) $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - Licensed under the Apache License, Version 2.0 (the "License"); + - you may not use this file except in compliance with the License. + - You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + --> + +<project name="Tubo"> + <body> + <menu ref="parent" /> + </body> +</project> + Property changes on: trunk/examples/unlog/src/site/site.xml ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2010-03-17 11:56:46
|
Revision: 124 http://tubo.svn.sourceforge.net/tubo/?rev=124&view=rev Author: maldito_orco Date: 2010-03-17 11:56:40 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Modified Paths: -------------- trunk/pom.xml trunk/src/site/apt/roadmap.apt trunk/src/site/site.xml Added Paths: ----------- trunk/bin/ trunk/bin/clean.sh trunk/bin/eclipse-add-maven-repo.sh trunk/bin/eclipse.sh trunk/bin/install-without-test.sh trunk/bin/site-stage.sh trunk/common.properties trunk/src/site/apt/ideas.apt Added: trunk/bin/clean.sh =================================================================== --- trunk/bin/clean.sh (rev 0) +++ trunk/bin/clean.sh 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1 @@ +mvn clean Property changes on: trunk/bin/clean.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/eclipse-add-maven-repo.sh =================================================================== --- trunk/bin/eclipse-add-maven-repo.sh (rev 0) +++ trunk/bin/eclipse-add-maven-repo.sh 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1 @@ +mvn eclipse:add-maven-repo -Declipse.workspace=/home/jlorenzo/myhome/dev/eclipse-workspace Property changes on: trunk/bin/eclipse-add-maven-repo.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/eclipse.sh =================================================================== --- trunk/bin/eclipse.sh (rev 0) +++ trunk/bin/eclipse.sh 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1 @@ +mvn eclipse:eclipse -Declipse.workspace=/home/jlorenzo/myhome/dev/eclipse-workspace Property changes on: trunk/bin/eclipse.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/install-without-test.sh =================================================================== --- trunk/bin/install-without-test.sh (rev 0) +++ trunk/bin/install-without-test.sh 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1 @@ +mvn -Dmaven.test.skip=true install Property changes on: trunk/bin/install-without-test.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/bin/site-stage.sh =================================================================== --- trunk/bin/site-stage.sh (rev 0) +++ trunk/bin/site-stage.sh 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1,2 @@ +mvn -e site:stage +cp -R modules/tubo-core/target/site/xref modules/tubo-core/target/site/xref-test target/staged-site/shell.sf.net/home/groups/t/tu/tubo/htdocs/tubo-core/ Property changes on: trunk/bin/site-stage.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/common.properties =================================================================== --- trunk/common.properties (rev 0) +++ trunk/common.properties 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1 @@ +tubo.version=1.0-alpha2 \ No newline at end of file Property changes on: trunk/common.properties ___________________________________________________________________ Added: svn:executable + * Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-03-17 11:49:54 UTC (rev 123) +++ trunk/pom.xml 2010-03-17 11:56:40 UTC (rev 124) @@ -22,11 +22,11 @@ - See the License for the specific language governing permissions and - limitations under the License. --> - + <!-- - POM Version --> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> <!-- - Identification @@ -35,7 +35,7 @@ <artifactId>tubo</artifactId> <packaging>pom</packaging> <name>Tubo Adapter</name> - <version>1.0.0-SNAPSHOT</version> + <version>1.0-alpha2</version> <description>Tubo is a customisable multi adapter, with integration abilities.</description> <url>http://tubo.sourceforge.net/</url> <!--prerequisites/--> @@ -47,8 +47,33 @@ <inceptionYear>2004</inceptionYear> <!-- - - Mailing List - --> + - Properties + --> + <properties> + <tubo-version>1.0-alpha2</tubo-version> + <activemq-version>4.2-SNAPSHOT</activemq-version> + <log4j-version>1.2.14</log4j-version> + <commons-digester-version>1.8</commons-digester-version> + <commons-collections-version>3.2</commons-collections-version> + <commons-logging-version>1.1</commons-logging-version> + <commons-beanutils-version>1.7.0</commons-beanutils-version> + <commons-pool-version>1.2</commons-pool-version> + <xercesimpl-version>2.6.2</xercesimpl-version> + <xml-apis-version>2.0.2</xml-apis-version> + <spring-version>2.0.6</spring-version> + <cglib-version>2.1_3</cglib-version> + <velocity-version>1.4</velocity-version> + <backport-util-concurrent-version>2.2</backport-util-concurrent-version> + <junit-version>3.8.1</junit-version> + <restlet-version>1.1.3</restlet-version> + <javax-servlet-version>2.4</javax-servlet-version> + + </properties> + + + <!-- + - Mailing List + --> <mailingLists> <mailingList> <name>Tubo Commit List</name> @@ -144,8 +169,35 @@ <!-- - Build --> - <!--build></build--> + <build> + <!--filters> + <filter>common.properties</filter> + </filters--> + <plugins> + <!-- SITE PLUGIN --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <generateReports>true</generateReports> + <!--addModules>true</addModules--> + <stagingDirectory>${basedir}/target/staged-site</stagingDirectory> + </configuration> + </plugin> + <!-- ECLIPSE PLUGIN --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <configuration> + <downloadSources>true</downloadSources> + <downloadJavadocs>true</downloadJavadocs> + <addVersionToProjectName>true</addVersionToProjectName> + </configuration> + </plugin> + </plugins> + </build> + <!-- - Profiles --> @@ -156,57 +208,75 @@ --> <modules> <module>modules/tubo-core</module> + <module>modules/tubo-web</module> + <module>modules/tubo-restlet</module> + <!-- examples --> + <module>examples/simplest</module> + <module>examples/simple-webapp</module> + <module>examples/unlog</module> + <!--module>examples/udp</module--> + <module>examples/restlet-simplest-hello</module> + <module>examples/restlet-simple-hello</module> + <module>examples/restlet-complex-hello</module> + <module>examples/restlet-json-restful-web-service-in-java</module> + <module>examples/restlet-pls</module> + <!--module>examples/jcaconsume</module--> + <module>unlog/server</module> </modules> <!-- - - Repositories + - Repositories --> <repositories> + <repository> + <id>repo2-maven-org</id> + <url>http://repo2.maven.org/maven2/</url> + </repository> <!--repository> - <releases> - <enabled>false</enabled> - </releases> - <id>snapshots</id> - <name>Maven Central Development Repository</name> - <url>http://snapshots.maven.codehaus.org/maven2</url> - </repository--> + <id>cima-central</id> + <url>http://mvn.cimatech.com.ar/repo</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + <repository> + <id>cima-snapshots</id> + <url>http://mvn.cimatech.com.ar/repo</url> + <releases> + <enabled>false</enabled> + </releases> + </repository--> <!--repository> - <snapshots> - <enabled>false</enabled> - </snapshots> - <id>central</id> - <name>Maven Repository Switchboard</name> - <url>http://repo1.maven.org/maven2</url> + <id>java.net</id> + <url>https://maven-repository.dev.java.net/nonav/repository</url> + <layout>legacy</layout> </repository--> + <!-- Restlet repo --> <repository> - <snapshots> - <enabled>false</enabled> - </snapshots> - <id>spring-sf</id> - <name>Spring Maven Repo</name> - <url>https://svn.sourceforge.net/svnroot/springframework/repos/repo</url> + <id>maven-restlet</id> + <name>Public online Restlet repository</name> + <url>http://maven.restlet.org</url> </repository> </repositories> + <!-- - Plugin Repositories --> <pluginRepositories> <!--pluginRepository> - <snapshots> - <enabled>false</enabled> - </snapshots> - <id>central</id> - <name>Maven Plugin Repository</name> - <url>http://repo1.maven.org/maven2</url> - </pluginRepository--> - <!--pluginRepository> - <snapshots> - <enabled>false</enabled> - </snapshots> - <id>codehaus</id> - <name>Codehaus Repository</name> - <url>http://repository.codehaus.org/</url> - </pluginRepository--> + <id>cima-central</id> + <url>http://mvn.cimatech.com.ar/repo</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + <pluginRepository> + <id>cima-snapshots</id> + <url>http://mvn.cimatech.com.ar/repo</url> + <releases> + <enabled>false</enabled> + </releases> + </pluginRepository--> </pluginRepositories> <!-- @@ -225,7 +295,7 @@ <reporting> <plugins> <!-- INFO-REPORTS --> - <plugin> + <!--plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.0.1</version> @@ -242,7 +312,7 @@ </reports> </reportSet> </reportSets> - </plugin> + </plugin--> </plugins> </reporting> Added: trunk/src/site/apt/ideas.apt =================================================================== --- trunk/src/site/apt/ideas.apt (rev 0) +++ trunk/src/site/apt/ideas.apt 2010-03-17 11:56:40 UTC (rev 124) @@ -0,0 +1,56 @@ + ------ + Ideas + ------ + Julio Lorenzo + <mal...@us...> + ------ + March 2, 2007 + +Ideas + + This is a List<List<Idea>> (tecla-tecla) + +* General + +*------+------------------------------------------------------+ +| Pend | Utilizacion de Apache Mina para todo lo que es comunicaciones y utilizacion de Net. +*------+------------------------------------------------------+ +| | +*------+------------------------------------------------------+ + + +* Flow Events + +*------+------------------------------------------------------+ +| Done | Paralelo a el item se puede tener un evento. +*------+------------------------------------------------------+ +| Done | A los componentes se los podria configurar para ejecutar algun metodo determinado en vez de execute dependiendo del evento. +*------+------------------------------------------------------+ +| Pend | Estudiar la posibilidad de que los consumers eventos de salida? +*------+------------------------------------------------------+ +| | +*------+------------------------------------------------------+ + + +* Configuration + +*------+------------------------------------------------------+ +| Pend | Deprecate Digester Meta-Rules and use XML-Rules +| | Implemented parcially, Pend add custom xml-rules +*------+------------------------------------------------------+ +| Pend | Estudiar la posibilidad de pasar la parte de configuracion a Spring 2.0 xbeans +*------+------------------------------------------------------+ +| Pend | Estudiar la posibilidad de usar common-betwixt como engine de configuracion +*------+------------------------------------------------------+ +| | +*------+------------------------------------------------------+ + + +* Resource Management + +*------+------------------------------------------------------+ +| Pend | Estudiar la posibilidad de implementar jencks como container de JCA y cambiar la etapa custom de consuming a JCA enabled +*------+------------------------------------------------------+ +| | +*------+------------------------------------------------------+ + Property changes on: trunk/src/site/apt/ideas.apt ___________________________________________________________________ Added: svn:executable + * Modified: trunk/src/site/apt/roadmap.apt =================================================================== --- trunk/src/site/apt/roadmap.apt 2010-03-17 11:49:54 UTC (rev 123) +++ trunk/src/site/apt/roadmap.apt 2010-03-17 11:56:40 UTC (rev 124) @@ -6,7 +6,7 @@ ------ October 27, 2006 -Tubo's RoadMap +Tubo's Roadmap This is the version 1.0 Tubo's roadmap. Modified: trunk/src/site/site.xml =================================================================== --- trunk/src/site/site.xml 2010-03-17 11:49:54 UTC (rev 123) +++ trunk/src/site/site.xml 2010-03-17 11:56:40 UTC (rev 124) @@ -33,9 +33,12 @@ </bannerRight--> <publishDate format="dd MMM yyyy" /> <skin> + <!-- default --> + <!--groupId>org.apache.maven.skins</groupId> + <artifactId>maven-default-skin</artifactId--> + <!-- stylus --> <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-default-skin</artifactId> - <!--version>1.0</version--> + <artifactId>maven-stylus-skin</artifactId> </skin> <body> <links> @@ -66,16 +69,25 @@ <menu name="Resources"> <item name="Consumers" > - <!--item name="Server Socket Line Reader" href="consumers/serversocketlinereader.html"/--> + <item name="Server Socket" href="consumers/serversocket.html"/> + <item name="Server Socket Line Reader" href="consumers/serversocketlinereader.html"/> </item> <item name="Components"> + <item name="Echo" href="components/echo.html"/> </item> <item name="Connections"> </item> </menu> - <menu ref="modules" /> + <!--menu ref="modules" /--> + <menu name="Modules"> + <item name="Core" href="tubo-core/index.html" /> + </menu> + <menu name="Examples"> + <item name="Simplest" href="tubo-example-simplest/index.html" /> + </menu> + <menu ref="reports" /> </body> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2010-03-17 11:50:03
|
Revision: 123 http://tubo.svn.sourceforge.net/tubo/?rev=123&view=rev Author: maldito_orco Date: 2010-03-17 11:49:54 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Added Paths: ----------- trunk/examples/ trunk/examples/restlet-complex-hello/ trunk/examples/restlet-complex-hello/bin/ trunk/examples/restlet-complex-hello/bin/install-without-test.sh trunk/examples/restlet-complex-hello/bin/jetty-run.sh trunk/examples/restlet-complex-hello/pom.xml trunk/examples/restlet-complex-hello/src/ trunk/examples/restlet-complex-hello/src/main/ trunk/examples/restlet-complex-hello/src/main/java/ trunk/examples/restlet-complex-hello/src/main/java/org/ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloComponent.java trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletInboundComponent.java trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletOutboundComponent.java trunk/examples/restlet-complex-hello/src/main/resources/ trunk/examples/restlet-complex-hello/src/main/resources/log4j.xml trunk/examples/restlet-complex-hello/src/main/resources/tubo.xml trunk/examples/restlet-complex-hello/src/main/webapp/ trunk/examples/restlet-complex-hello/src/main/webapp/WEB-INF/ trunk/examples/restlet-complex-hello/src/main/webapp/WEB-INF/web.xml trunk/examples/restlet-json-restful-web-service-in-java/ trunk/examples/restlet-json-restful-web-service-in-java/bin/ trunk/examples/restlet-json-restful-web-service-in-java/bin/install-without-test.sh trunk/examples/restlet-json-restful-web-service-in-java/bin/jetty-run.sh trunk/examples/restlet-json-restful-web-service-in-java/pom.xml trunk/examples/restlet-json-restful-web-service-in-java/src/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/json/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/json/TableComponent.java trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/log4j.xml trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/tubo.xml trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/WEB-INF/ trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/WEB-INF/web.xml trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/datatablepage.html trunk/examples/restlet-pls/ trunk/examples/restlet-pls/bin/ trunk/examples/restlet-pls/bin/install-without-test.sh trunk/examples/restlet-pls/bin/jetty-run.sh trunk/examples/restlet-pls/pom.xml trunk/examples/restlet-pls/src/ trunk/examples/restlet-pls/src/main/ trunk/examples/restlet-pls/src/main/java/ trunk/examples/restlet-pls/src/main/java/org/ trunk/examples/restlet-pls/src/main/java/org/tubo/ trunk/examples/restlet-pls/src/main/java/org/tubo/example/ trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/ trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/pls/ trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/pls/TableComponent.java trunk/examples/restlet-pls/src/main/resources/ trunk/examples/restlet-pls/src/main/resources/log4j.xml trunk/examples/restlet-pls/src/main/resources/tubo.xml trunk/examples/restlet-pls/src/main/webapp/ trunk/examples/restlet-pls/src/main/webapp/WEB-INF/ trunk/examples/restlet-pls/src/main/webapp/WEB-INF/web.xml trunk/examples/restlet-pls/src/main/webapp/datatablepage.html trunk/examples/restlet-simple-hello/ trunk/examples/restlet-simple-hello/bin/ trunk/examples/restlet-simple-hello/bin/install-without-test.sh trunk/examples/restlet-simple-hello/bin/jetty-run.sh trunk/examples/restlet-simple-hello/pom.xml trunk/examples/restlet-simple-hello/src/ trunk/examples/restlet-simple-hello/src/main/ trunk/examples/restlet-simple-hello/src/main/java/ trunk/examples/restlet-simple-hello/src/main/java/org/ trunk/examples/restlet-simple-hello/src/main/java/org/tubo/ trunk/examples/restlet-simple-hello/src/main/java/org/tubo/example/ trunk/examples/restlet-simple-hello/src/main/java/org/tubo/example/restlet/ trunk/examples/restlet-simple-hello/src/main/java/org/tubo/example/restlet/simplehello/ trunk/examples/restlet-simple-hello/src/main/java/org/tubo/example/restlet/simplehello/HelloComponent.java trunk/examples/restlet-simple-hello/src/main/resources/ trunk/examples/restlet-simple-hello/src/main/resources/log4j.xml trunk/examples/restlet-simple-hello/src/main/resources/tubo.xml trunk/examples/restlet-simple-hello/src/main/webapp/ trunk/examples/restlet-simple-hello/src/main/webapp/WEB-INF/ trunk/examples/restlet-simple-hello/src/main/webapp/WEB-INF/web.xml trunk/examples/restlet-simplest-hello/ trunk/examples/restlet-simplest-hello/bin/ trunk/examples/restlet-simplest-hello/bin/install-without-test.sh trunk/examples/restlet-simplest-hello/bin/jetty-run.sh trunk/examples/restlet-simplest-hello/pom.xml trunk/examples/restlet-simplest-hello/src/ trunk/examples/restlet-simplest-hello/src/main/ trunk/examples/restlet-simplest-hello/src/main/java/ trunk/examples/restlet-simplest-hello/src/main/java/org/ trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/ trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/example/ trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/example/restlet/ trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/example/restlet/simplesthello/ trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/example/restlet/simplesthello/RestletSimplestConsumer.java trunk/examples/restlet-simplest-hello/src/main/java/org/tubo/example/restlet/simplesthello/RestletSimplestConsumerLoader.java trunk/examples/restlet-simplest-hello/src/main/resources/ trunk/examples/restlet-simplest-hello/src/main/resources/log4j.xml trunk/examples/restlet-simplest-hello/src/main/resources/tubo.xml trunk/examples/restlet-simplest-hello/src/main/webapp/ trunk/examples/restlet-simplest-hello/src/main/webapp/WEB-INF/ trunk/examples/restlet-simplest-hello/src/main/webapp/WEB-INF/web.xml trunk/examples/simple-webapp/ trunk/examples/simple-webapp/bin/ trunk/examples/simple-webapp/bin/install-without-test.sh trunk/examples/simple-webapp/bin/jetty-run.sh trunk/examples/simple-webapp/pom.xml trunk/examples/simple-webapp/src/ trunk/examples/simple-webapp/src/main/ trunk/examples/simple-webapp/src/main/java/ trunk/examples/simple-webapp/src/main/java/org/ trunk/examples/simple-webapp/src/main/java/org/tubo/ trunk/examples/simple-webapp/src/main/java/org/tubo/example/ trunk/examples/simple-webapp/src/main/java/org/tubo/example/simplewebapp/ trunk/examples/simple-webapp/src/main/java/org/tubo/example/simplewebapp/HelloComponent.java trunk/examples/simple-webapp/src/main/resources/ trunk/examples/simple-webapp/src/main/resources/log4j.xml trunk/examples/simple-webapp/src/main/resources/tubo.xml trunk/examples/simple-webapp/src/main/webapp/ trunk/examples/simple-webapp/src/main/webapp/WEB-INF/ trunk/examples/simple-webapp/src/main/webapp/WEB-INF/web.xml trunk/examples/simplest/ trunk/examples/simplest/bin/ trunk/examples/simplest/bin/pom.xml trunk/examples/simplest/bin/src/ trunk/examples/simplest/bin/src/assembly/ trunk/examples/simplest/bin/src/assembly/simplest.xml trunk/examples/simplest/bin/src/main/ trunk/examples/simplest/bin/src/main/resources/ trunk/examples/simplest/bin/src/main/resources/log4j.xml trunk/examples/simplest/bin/src/main/resources/tubo.xml trunk/examples/simplest/bin/src/shell/ trunk/examples/simplest/bin/src/shell/starttubo.sh trunk/examples/simplest/bin/src/site/ trunk/examples/simplest/bin/src/site/apt/ trunk/examples/simplest/bin/src/site/apt/index.apt trunk/examples/simplest/bin/src/site/site.xml trunk/examples/simplest/bin/target/ trunk/examples/simplest/bin/target/classes/ trunk/examples/simplest/bin/target/classes/log4j.xml trunk/examples/simplest/bin/target/classes/tubo.xml trunk/examples/simplest/bin/velocity.log trunk/examples/simplest/pom.xml trunk/examples/simplest/src/ trunk/examples/simplest/src/assembly/ trunk/examples/simplest/src/assembly/shell.xml trunk/examples/simplest/src/main/ trunk/examples/simplest/src/main/resources/ trunk/examples/simplest/src/main/resources/log4j.xml trunk/examples/simplest/src/main/resources/tubo.xml trunk/examples/simplest/src/shell/ trunk/examples/simplest/src/shell/starttubo.sh trunk/examples/simplest/src/site/ trunk/examples/simplest/src/site/apt/ trunk/examples/simplest/src/site/apt/index.apt trunk/examples/simplest/src/site/site.xml trunk/examples/udp/ trunk/examples/udp/bin/ trunk/examples/udp/pom.xml trunk/examples/udp/src/ trunk/examples/udp/src/assembly/ trunk/examples/udp/src/assembly/shell.xml trunk/examples/udp/src/main/ trunk/examples/udp/src/main/java/ trunk/examples/udp/src/main/java/com/ trunk/examples/udp/src/main/java/com/cimatech/ trunk/examples/udp/src/main/java/com/cimatech/esl/ trunk/examples/udp/src/main/java/com/cimatech/esl/server/ trunk/examples/udp/src/main/java/com/cimatech/esl/server/ESLEvent.java trunk/examples/udp/src/main/java/com/cimatech/esl/server/SyslogComponent.java trunk/examples/udp/src/main/resources/ trunk/examples/udp/src/main/resources/log4j.xml trunk/examples/udp/src/main/resources/tubo.xml trunk/examples/udp/src/shell/ trunk/examples/udp/src/shell/starttubo.sh trunk/examples/udp/src/site/ trunk/examples/udp/src/site/apt/ trunk/examples/udp/src/site/apt/index.apt trunk/examples/udp/src/site/site.xml Added: trunk/examples/restlet-complex-hello/bin/install-without-test.sh =================================================================== --- trunk/examples/restlet-complex-hello/bin/install-without-test.sh (rev 0) +++ trunk/examples/restlet-complex-hello/bin/install-without-test.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn -Dmaven.test.skip=true install Property changes on: trunk/examples/restlet-complex-hello/bin/install-without-test.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-complex-hello/bin/jetty-run.sh =================================================================== --- trunk/examples/restlet-complex-hello/bin/jetty-run.sh (rev 0) +++ trunk/examples/restlet-complex-hello/bin/jetty-run.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn jetty:run Property changes on: trunk/examples/restlet-complex-hello/bin/jetty-run.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-complex-hello/pom.xml =================================================================== --- trunk/examples/restlet-complex-hello/pom.xml (rev 0) +++ trunk/examples/restlet-complex-hello/pom.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,85 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <!-- + - $Id: pom.xml 85 2006-12-15 21:50:59Z maldito_orco $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - 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. + --> + + <!-- + - Parent + --> + <parent> + <groupId>org.tubo</groupId> + <artifactId>tubo</artifactId> + <version>1.0-alpha2</version> + </parent> + <!-- + - POM Version + --> + <modelVersion>4.0.0</modelVersion> + <!-- + - Identification + --> + <groupId>org.tubo</groupId> + <artifactId>tubo-example-restlet-complex-hello</artifactId> + <packaging>war</packaging> + <name>Tubo Examples - Restlet Complex Hello</name> + <!-- + - Dependencies + --> + <dependencies> + <!-- tubo --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-core</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- tubo-web --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-restlet</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + </dependencies> + <!-- + - Build + --> + <build> + <plugins> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <configuration> + <scanIntervalSeconds>10</scanIntervalSeconds> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8080</port> + <maxIdleTime>60000</maxIdleTime> + </connector> + </connectors> + </configuration> + </plugin> + </plugins> + </build> + +</project> Property changes on: trunk/examples/restlet-complex-hello/pom.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloComponent.java =================================================================== --- trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloComponent.java (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloComponent.java 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,65 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.restlet.complexhello; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.item.Item; + +/** + * <p></p> + * <p> + * Created: May 8, 2009, 11:11:15 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class HelloComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(HelloComponent.class); + + public static final String HELLO_NAME_PROPERTY = "HELLO_NAME"; + public static final String HELLO_OUTPUT_PROPERTY = "ECHO_OUTPUT"; + + public void sayHello(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(HELLO_OUTPUT_PROPERTY,"Hello World!!"); + } + + public void sayHelloWithName(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(HELLO_OUTPUT_PROPERTY,"Hello World!!"); + // + // get item + Item item = flowContext.getItem(); + // + // get name + String name = (String)item.getProperty(HELLO_NAME_PROPERTY); + // + // put input in output + item.setProperty(HELLO_OUTPUT_PROPERTY,"Hello World "+name+"!!"); + } + +} \ No newline at end of file Added: trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletInboundComponent.java =================================================================== --- trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletInboundComponent.java (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletInboundComponent.java 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,60 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.restlet.complexhello; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.web.restlet.RestletItem; +import org.tubo.example.restlet.complexhello.HelloComponent; +import org.restlet.data.Request; + +/** + * <p></p> + * <p> + * Created: May 8, 2009, 11:11:15 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class HelloRestletInboundComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(HelloRestletInboundComponent.class); + + + public void sayHelloWithName(FlowContext flowContext) throws TuboException { + // + // get item + RestletItem item = (RestletItem)flowContext.getItem(); + // + // get Name + Request request = item.getRestletRequest(); + String name = (String)request.getAttributes().get("name"); + // + //map in attibute to property needed by HelloComponent (this is a mapping!) + item.getProperties().put(HelloComponent.HELLO_NAME_PROPERTY,name); + } +} \ No newline at end of file Added: trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletOutboundComponent.java =================================================================== --- trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletOutboundComponent.java (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/java/org/tubo/example/restlet/complexhello/HelloRestletOutboundComponent.java 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,79 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.restlet.complexhello; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.web.restlet.RestletItem; +import org.tubo.web.restlet.RestletConsumer; +import org.tubo.example.restlet.complexhello.HelloComponent; +//restlet +import org.restlet.resource.Variant; +import org.restlet.resource.StringRepresentation; +import org.restlet.resource.Representation; +import org.restlet.data.MediaType; + +/** + * <p></p> + * <p> + * Created: May 8, 2009, 11:11:15 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class HelloRestletOutboundComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(HelloRestletOutboundComponent.class); + + public void execute(FlowContext flowContext) throws TuboException { + // + // get item + RestletItem item = (RestletItem)flowContext.getItem(); + // + // get hello text + String hello = (String) item.getProperties().get(HelloComponent.HELLO_OUTPUT_PROPERTY); + // + // get Variant + Variant variant = (Variant) item.getRestletVariant(); + // + // represent + //if (variant.getMediaType().equals(MediaType.APPLICATION_JSON)) { + // result = new JsonRepresentation(this.user.toJSON()); + //} else { + // result = new StringRepresentation(this.user.toString()); + //} + Representation result = null; + if (variant.getMediaType().equals(MediaType.TEXT_PLAIN)) + result = new StringRepresentation(hello); + else + result = new StringRepresentation("Variant no soportada"); + + // + // store result + item.getProperties().put(RestletConsumer.RESTLET_RESOURCE_OUT_REPRESENTATION,result); + } +} \ No newline at end of file Added: trunk/examples/restlet-complex-hello/src/main/resources/log4j.xml =================================================================== --- trunk/examples/restlet-complex-hello/src/main/resources/log4j.xml (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/resources/log4j.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <!-- BEGIN APPENDER: CONSOLE APPENDER (stdout) --> + <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> + <!--param name="threshold" value="info" /--> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c{3}%m%n"/> + </layout> + </appender> + + <logger name="org.apache.commons.digester"> + <level value="error"/> + <appender-ref ref="stdout"/> + </logger> + + <logger name="org.tubo"> + <level value="trace"/> + <appender-ref ref="stdout"/> + </logger> + + <!--logger name="org.jencks"> + <level value="info"/> + <appender-ref ref="stdout"/> + </logger--> + + <!--root> + <level value="error"/> + <appender-ref ref="stdout"/> + </root--> + +</log4j:configuration> Property changes on: trunk/examples/restlet-complex-hello/src/main/resources/log4j.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-complex-hello/src/main/resources/tubo.xml =================================================================== --- trunk/examples/restlet-complex-hello/src/main/resources/tubo.xml (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/resources/tubo.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,107 @@ +<tubo-configuration> + + <consumer-set> + <!-- + - Web Consumer + --> + <consumer id="hello-restlet-consumer" + consumerClassname="org.tubo.web.restlet.RestletConsumer" + type="irrestricted" + > + <property> + <prop-name>route[0]=/hello/</prop-name> + <prop-value>repesentations=TEXT_PLAIN,tubo-request-event=HELLO_EVENT</prop-value> + </property> + <property> + <prop-name>route[1]=/hello/{name}</prop-name> + <prop-value>repesentations=TEXT_PLAIN,tubo-request-event=HELLO_WITH_NAME_EVENT</prop-value> + </property> + </consumer> + </consumer-set> + + <component-set> + <!-- + - Hello component + --> + <component id="hello-component" + componentClassname="org.tubo.example.restlet.complexhello.HelloComponent" + type="singleton" + > + </component> + <!-- + - Hello Restlet Inbound component + --> + <component id="hello-restlet-inbound-component" + componentClassname="org.tubo.example.restlet.complexhello.HelloRestletInboundComponent" + type="singleton" + > + </component> + <!-- + - Hello Restlet Outbound component + --> + <component id="hello-restlet-outbound-component" + componentClassname="org.tubo.example.restlet.complexhello.HelloRestletOutboundComponent" + type="singleton" + > + </component> + </component-set> + + <flow-set> + <!-- + - Hello service + --> + <flow id="hello-restlet-flow"> + <consume> + <from refId="hello-restlet-consumer"> + <inbound-flow> + <node-list> + <component-node refId="hello-restlet-inbound-component"> + <listen> + <event> + <action>GET-HELLO_WITH_NAME_EVENT</action> + <execute>sayHelloWithName</execute> + </event> + </listen> + </component-node> + </node-list> + </inbound-flow> + <outbound-flow> + <node-list> + <component-node refId="hello-restlet-outbound-component" /> + </node-list> + </outbound-flow> + </from> + </consume> + <node-list> + <!-- transform input ss to input echo--> + <!--component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>SSLINEREADER_INPUT->ECHO_INPUT</prop-value> + </property> + </component-node--> + <!-- execute echo --> + <component-node refId="hello-component"> + <listen> + <event> + <action>GET-HELLO_EVENT</action> + <execute>sayHello</execute> + </event> + <event> + <action>GET-HELLO_WITH_NAME_EVENT</action> + <execute>sayHelloWithName</execute> + </event> + <!-- by default if not defined listens or not matched events, method 'execute' is invoked --> + </listen> + </component-node> + <!-- transform output echo to output ss--> + <!--component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>ECHO_OUTPUT->SSLINEREADER_OUTPUT</prop-value> + </property> + </component-node--> + </node-list> + </flow> + </flow-set> +</tubo-configuration> Property changes on: trunk/examples/restlet-complex-hello/src/main/resources/tubo.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-complex-hello/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/examples/restlet-complex-hello/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/examples/restlet-complex-hello/src/main/webapp/WEB-INF/web.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app> + <display-name>Simple Tubo WebApp Example</display-name> + + <listener> + <listener-class>org.tubo.system.web.TuboContextListener</listener-class> + </listener> + + <context-param> + <param-name>tubo.config.location</param-name> + <param-value>tubo.xml</param-value> + </context-param> + + <servlet> + <servlet-name>HelloRestlet</servlet-name> + <servlet-class> + org.tubo.system.web.TuboServletAdapter + </servlet-class> + <!-- consumer (mandatory) --> + <init-param> + <param-name>consumerId</param-name> + <param-value>hello-restlet-consumer</param-value> + </init-param> + </servlet> + + <!-- Catch all requests --> + <servlet-mapping> + <servlet-name>HelloRestlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> Added: trunk/examples/restlet-json-restful-web-service-in-java/bin/install-without-test.sh =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/bin/install-without-test.sh (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/bin/install-without-test.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn -Dmaven.test.skip=true install Property changes on: trunk/examples/restlet-json-restful-web-service-in-java/bin/install-without-test.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-json-restful-web-service-in-java/bin/jetty-run.sh =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/bin/jetty-run.sh (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/bin/jetty-run.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn jetty:run Property changes on: trunk/examples/restlet-json-restful-web-service-in-java/bin/jetty-run.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-json-restful-web-service-in-java/pom.xml =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/pom.xml (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/pom.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,95 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <!-- + - $Id: pom.xml 85 2006-12-15 21:50:59Z maldito_orco $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - 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. + --> + + <!-- + - Parent + --> + <parent> + <groupId>org.tubo</groupId> + <artifactId>tubo</artifactId> + <version>1.0-alpha2</version> + </parent> + <!-- + - POM Version + --> + <modelVersion>4.0.0</modelVersion> + <!-- + - Identification + --> + <groupId>org.tubo</groupId> + <artifactId>tubo-example-restlet-json-restful-web-service-in-java</artifactId> + <packaging>war</packaging> + <name>Tubo Examples - Restlet, JSON Restful Web Service in Java</name> + <!-- + - Dependencies + --> + <dependencies> + <!-- tubo --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-core</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- tubo-web --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-restlet</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.restlet</groupId> + <artifactId>org.restlet.ext.json</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>org.json</artifactId> + <version>2.0</version> + </dependency> + </dependencies> + <!--org.restlet.ext.json + - Build + --> + <build> + <plugins> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <configuration> + <scanIntervalSeconds>10</scanIntervalSeconds> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8080</port> + <maxIdleTime>60000</maxIdleTime> + </connector> + </connectors> + </configuration> + </plugin> + </plugins> + </build> + +</project> Property changes on: trunk/examples/restlet-json-restful-web-service-in-java/pom.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/json/TableComponent.java =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/json/TableComponent.java (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/src/main/java/org/tubo/example/restlet/json/TableComponent.java 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,154 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.restlet.json; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.web.restlet.RestletItem; +import org.tubo.web.restlet.RestletConsumer; +//restlet +import org.restlet.resource.Variant; +import org.restlet.data.CharacterSet; +import org.restlet.ext.json.JsonRepresentation; +//json +import org.json.JSONObject; +import org.json.JSONException; +import org.json.JSONArray; + +/** + * <p></p> + * <p> + * Created: May 15, 2009, 6:38:23 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TableComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(TableComponent.class); + + private static final String JSON_NAME_TABLE = "table"; + + private static final String JSON_NAME_COLUMNS = "cols"; + private static final String JSON_NAME_COLUMNS_ID = "id"; + private static final String JSON_NAME_COLUMNS_LABEL = "label"; + private static final String JSON_NAME_COLUMNS_TYPE = "type"; + private static final String JSON_NAME_COLUMNS_PATTERN = "pattern"; + + private static final String JSON_NAME_ROWS = "rows"; + private static final String JSON_NAME_ROWS_V = "v"; + private static final String JSON_NAME_ROWS_F = "f"; + + public void table(FlowContext flowContext) throws TuboException { + + // + // get item + RestletItem item = (RestletItem)flowContext.getItem(); + // + // get Variant + Variant variant = (Variant) item.getRestletVariant(); + + + JSONObject json = new JSONObject(); + + try { + + json.put("requestId", "0"); + json.put("status", "ok"); + json.put("signature", "6173382439516707022"); + + json.put(JSON_NAME_TABLE, this.createTable()); + + } catch (JSONException e) { + //throw new ResourceException(Status.SERVER_ERROR_INTERNAL); + } + + JsonRepresentation jr = new JsonRepresentation(json); + + jr.setCharacterSet(CharacterSet.UTF_8); + + // + // store result + item.getProperties().put(RestletConsumer.RESTLET_RESOURCE_OUT_REPRESENTATION,jr); + + + } + + private JSONObject createTable() throws JSONException{ + JSONArray columns = new JSONArray(); + JSONArray rows = new JSONArray(); + JSONObject r_c = new JSONObject(); + r_c.put(JSON_NAME_COLUMNS, columns); + r_c.put(JSON_NAME_ROWS, rows); + + this.createColumns(columns); + this.createRows(rows); + + return r_c; + } + + private void createColumns(JSONArray columns) throws JSONException{ + + columns.put(this.createColumn("A", "Date", "d", "M/d/yyyy")); + columns.put(this.createColumn("B", "Budget", "n", "#0.###############")); + columns.put(this.createColumn("C", "Revenue", "n", "#0.###############")); + columns.put(this.createColumn("D", "Movie", "t", "")); + + } + + private void createRows(JSONArray rows) throws JSONException{ + + JSONArray row = new JSONArray(); + + row.put(this.createCell("new Date(1981,10,6)", "11/6/1981")); + row.put(this.createCell("5000000.0", "5000000")); + row.put(this.createCell("4.2365581E7", "42365581")); + row.put(this.createCell("Time Bandits", null)); + + rows.put(row); + + } + + private JSONObject createCell(String v, String f) throws JSONException{ + JSONObject jo = new JSONObject(); + jo.put(JSON_NAME_ROWS_V, v); + if(f != null) + jo.put(JSON_NAME_ROWS_F, f); + return jo; + } + + private JSONObject createColumn(String id, String label, String type, String pattern) throws JSONException{ + JSONObject jo = new JSONObject(); + jo.put(JSON_NAME_COLUMNS_ID, id); + jo.put(JSON_NAME_COLUMNS_LABEL, label); + jo.put(JSON_NAME_COLUMNS_TYPE, type); + jo.put(JSON_NAME_COLUMNS_PATTERN, pattern); + return jo; + } + + +} \ No newline at end of file Added: trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/log4j.xml =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/log4j.xml (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/log4j.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <!-- BEGIN APPENDER: CONSOLE APPENDER (stdout) --> + <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> + <!--param name="threshold" value="info" /--> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c{3}%m%n"/> + </layout> + </appender> + + <logger name="org.apache.commons.digester"> + <level value="error"/> + <appender-ref ref="stdout"/> + </logger> + + <logger name="org.tubo"> + <level value="trace"/> + <appender-ref ref="stdout"/> + </logger> + + <!--logger name="org.jencks"> + <level value="info"/> + <appender-ref ref="stdout"/> + </logger--> + + <!--root> + <level value="error"/> + <appender-ref ref="stdout"/> + </root--> + +</log4j:configuration> Property changes on: trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/log4j.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/tubo.xml =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/tubo.xml (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/tubo.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,51 @@ +<tubo-configuration> + + <consumer-set> + <!-- + - Web Consumer + --> + <consumer id="json-consumer" + consumerClassname="org.tubo.web.restlet.RestletConsumer" + type="irrestricted" + > + <property> + <prop-name>route[0]=/table</prop-name> + <prop-value>repesentations=APPLICATION_JSON,tubo-request-event=TABLE_EVENT</prop-value> + </property> + </consumer> + </consumer-set> + + <component-set> + <!-- + - Hello component + --> + <component id="table-component" + componentClassname="org.tubo.example.restlet.json.TableComponent" + type="singleton" + > + </component> + </component-set> + + <flow-set> + <!-- + - Hello service + --> + <flow id="json-flow"> + <consume> + <from refId="json-consumer"/> + </consume> + <node-list> + <!-- execute table --> + <component-node refId="table-component"> + <listen> + <event> + <action>GET-TABLE_EVENT</action> + <execute>table</execute> + </event> + <!-- by default if not defined listens or not matched events, method 'execute' is invoked --> + </listen> + </component-node> + </node-list> + </flow> + </flow-set> +</tubo-configuration> Property changes on: trunk/examples/restlet-json-restful-web-service-in-java/src/main/resources/tubo.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/WEB-INF/web.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app> + <display-name>Simple Tubo WebApp Example</display-name> + + <listener> + <listener-class>org.tubo.system.web.TuboContextListener</listener-class> + </listener> + + <context-param> + <param-name>tubo.config.location</param-name> + <param-value>tubo.xml</param-value> + </context-param> + + <servlet> + <servlet-name>JSonRestlet</servlet-name> + <servlet-class> + org.tubo.system.web.TuboServletAdapter + </servlet-class> + <!-- consumer (mandatory) --> + <init-param> + <param-name>consumerId</param-name> + <param-value>json-consumer</param-value> + </init-param> + </servlet> + + <!-- Catch all requests --> + <servlet-mapping> + <servlet-name>JSonRestlet</servlet-name> + <url-pattern>/json/*</url-pattern> + </servlet-mapping> + + +</web-app> Added: trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/datatablepage.html =================================================================== --- trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/datatablepage.html (rev 0) +++ trunk/examples/restlet-json-restful-web-service-in-java/src/main/webapp/datatablepage.html 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,78 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <script type="text/javascript"> + + var xhr; + try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); } + catch (e) + { + try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } + catch (e2) + { + try { xhr = new XMLHttpRequest(); } + catch (e3) { xhr = false; } + } + } + + xhr.open("GET", "./json/table", true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send(null); + + xhr.onreadystatechange = function() + { + if(xhr.readyState == 4) + { + if(xhr.status == 200){ + the_object = eval( "(" + xhr.responseText + ")" ); + handleQueryResponse(the_object.table); + }else{ + + } + } + }; + + // Query response handler function. + function handleQueryResponse(table) { + + var html = []; + html.push('<table border="1">'); + + // Header row + html.push('<tr><th>Seq</th>'); + for (var col = 0; col < table.cols.length; col++) { + html.push('<th>' + escapeHtml(table.cols[col].label) + '</th>'); + } + html.push('</tr>'); + + for (var row = 0; row < table.rows.length; row++) { + html.push('<tr><td align="right">' + (row + 1) + '</td>'); + for (var col = 0; col < table.cols.length; col++) { + html.push(table.cols[col].type == 'number' ? '<td align="right">' : '<td>'); + html.push(escapeHtml(table.rows[row][col].f)); + html.push('</td>'); + } + html.push('</tr>'); + } + html.push('</table>'); + + document.getElementById('tablediv').innerHTML = html.join(''); + } + + function escapeHtml(text) { + if (text == null) + return ''; + + return text.replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"'); + } + + </script> +</head> + +<body> +<div id="tablediv">Loading...</div> +</body> +</html> \ No newline at end of file Added: trunk/examples/restlet-pls/bin/install-without-test.sh =================================================================== --- trunk/examples/restlet-pls/bin/install-without-test.sh (rev 0) +++ trunk/examples/restlet-pls/bin/install-without-test.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn -Dmaven.test.skip=true install Property changes on: trunk/examples/restlet-pls/bin/install-without-test.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-pls/bin/jetty-run.sh =================================================================== --- trunk/examples/restlet-pls/bin/jetty-run.sh (rev 0) +++ trunk/examples/restlet-pls/bin/jetty-run.sh 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1 @@ +mvn jetty:run Property changes on: trunk/examples/restlet-pls/bin/jetty-run.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-pls/pom.xml =================================================================== --- trunk/examples/restlet-pls/pom.xml (rev 0) +++ trunk/examples/restlet-pls/pom.xml 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,100 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <!-- + - $Id: pom.xml 85 2006-12-15 21:50:59Z maldito_orco $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - 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. + --> + + <!-- + - Parent + --> + <parent> + <groupId>org.tubo</groupId> + <artifactId>tubo</artifactId> + <version>1.0-alpha2</version> + </parent> + <!-- + - POM Version + --> + <modelVersion>4.0.0</modelVersion> + <!-- + - Identification + --> + <groupId>org.tubo</groupId> + <artifactId>tubo-example-restlet-pls</artifactId> + <packaging>war</packaging> + <name>Tubo Examples - Restlet, PLS</name> + <!-- + - Dependencies + --> + <dependencies> + <!-- tubo --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-core</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- tubo-web --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-restlet</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.restlet</groupId> + <artifactId>org.restlet.ext.json</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>org.json</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>c3p0</groupId> + <artifactId>c3p0</artifactId> + <version>0.9.1.2</version> + </dependency> + </dependencies> + <!--org.restlet.ext.json + - Build + --> + <build> + <plugins> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <configuration> + <scanIntervalSeconds>10</scanIntervalSeconds> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8081</port> + <maxIdleTime>60000</maxIdleTime> + </connector> + </connectors> + </configuration> + </plugin> + </plugins> + </build> + +</project> Property changes on: trunk/examples/restlet-pls/pom.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/pls/TableComponent.java =================================================================== --- trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/pls/TableComponent.java (rev 0) +++ trunk/examples/restlet-pls/src/main/java/org/tubo/example/restlet/pls/TableComponent.java 2010-03-17 11:49:54 UTC (rev 123) @@ -0,0 +1,199 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.example.restlet.pls; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.web.restlet.RestletItem; +import org.tubo.web.restlet.RestletConsumer; +//restlet +import org.restlet.resource.Variant; +import org.restlet.data.CharacterSet; +import org.restlet.ext.json.JsonRepresentation; +//json +import org.json.JSONObject; +import org.json.JSONException; +import org.json.JSONArray; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; + +/** + * <p></p> + * <p> + * Created: May 15, 2009, 6:38:23 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TableComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(TableComponent.class); + + private static final String JSON_NAME_TABLE = "table"; + + private static final String JSON_NAME_COLUMNS = "cols"; + private static final String JSON_NAME_COLUMNS_ID = "id"; + private static final String JSON_NAME_COLUMNS_LABEL = "label"; + private static final String JSON_NAME_COLUMNS_TYPE = "type"; + private static final String JSON_NAME_COLUMNS_PATTERN = "pattern"; + + private static final String JSON_NAME_ROWS = "rows"; + private static final String JSON_NAME_ROWS_V = "v"; + private static final String JSON_NAME_ROWS_F = "f"; + + public void pls(FlowContext flowContext) throws TuboException { + + DataSource ds = this.getResourceManager().getDataSource("TestXE"); + + Connection c = null; + try { + c = ds.getConnection(); + } catch (SQLException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + + ResultSet rs = null; + try { + DatabaseMetaData dbmd = c.getMetaData(); + rs = dbmd.getProcedures(null,"HR","%"); + + while (rs.next()) { + System.out.println( + " "+rs.getString("PROCEDURE_CAT") + + ", "+rs.getString("PROCEDURE_SCHEM") + + ", "+rs.getString("PROCEDURE_NAME")); + } + } catch (Exception e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } finally { + if (rs != null) try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } + if (c != null) try { c.close(); } catch (SQLException e) { e.printStackTrace(); } + } + + + + } + + + + + + + + public void table(FlowContext flowContext) throws TuboException { + + // + // get item + RestletItem item = (RestletItem)flowContext.getItem(); + // + // get Variant + Variant variant = (Variant) item.getRestletVariant(); + + + JSONObject json = new JSONObject(); + + try { + + json.put("requestId", "0"); + json.put("status", "ok"); + json.put("signature", "6173382439516707022"); + + json.put(JSON_NAME_TABLE, this.createTable()); + + } catch (JSONException e) { + //throw new ResourceException(Status.SERVER_ERROR_INTERNAL); + } + + JsonRepresentation jr = new JsonRepresentation(json); + + jr.setCharacterSet(CharacterSet.UTF_8); + + // + // store result + item.getProperties().put(RestletConsumer.RESTLET_RESOURCE_OUT_REPRESENTATION,jr); + + + } + + private JSONObj... [truncated message content] |
From: <mal...@us...> - 2010-03-17 11:38:39
|
Revision: 122 http://tubo.svn.sourceforge.net/tubo/?rev=122&view=rev Author: maldito_orco Date: 2010-03-17 11:38:29 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Added Paths: ----------- trunk/modules/tubo-restlet/ trunk/modules/tubo-restlet/pom.xml trunk/modules/tubo-restlet/src/ trunk/modules/tubo-restlet/src/main/ trunk/modules/tubo-restlet/src/main/java/ trunk/modules/tubo-restlet/src/main/java/org/ trunk/modules/tubo-restlet/src/main/java/org/tubo/ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumer.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumerLoader.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletData.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletItem.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletResourceData.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletResource.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletRouter.java trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletServlet.java trunk/modules/tubo-restlet/src/main/resources/ Added: trunk/modules/tubo-restlet/pom.xml =================================================================== --- trunk/modules/tubo-restlet/pom.xml (rev 0) +++ trunk/modules/tubo-restlet/pom.xml 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,101 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <!-- + - $Id: pom.xml 85 2006-12-15 21:50:59Z maldito_orco $ + - + - ========================================================================= + - + - Copyright 2005 Tubo + - + - 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. + --> + + <!-- + - Parent + --> + <parent> + <groupId>org.tubo</groupId> + <artifactId>tubo</artifactId> + <version>1.0-alpha2</version> + </parent> + <!-- + - POM Version + --> + <modelVersion>4.0.0</modelVersion> + <!-- + - Identification + --> + <groupId>org.tubo</groupId> + <artifactId>tubo-restlet</artifactId> + <packaging>jar</packaging> + <name>Tubo Adapter - Restlet Support</name> + <!-- + - Dependencies + --> + <dependencies> + <!-- tubo --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-core</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- tubo-web --> + <dependency> + <groupId>org.tubo</groupId> + <artifactId>tubo-web</artifactId> + <version>1.0-alpha2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- commons-logging --> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>${commons-logging-version}</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- jee --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>${javax-servlet-version}</version> + <type>jar</type> + <scope>provided</scope> + </dependency> + <!-- restlet - see http://www.restlet.org/downloads/maven --> + <dependency> + <groupId>org.restlet</groupId> + <artifactId>org.restlet</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet.ext.simple</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet.ext.servlet</artifactId> + <version>${restlet-version}</version> + </dependency> + </dependencies> +</project> Property changes on: trunk/modules/tubo-restlet/pom.xml ___________________________________________________________________ Added: svn:executable + * Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumer.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumer.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumer.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,247 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.web.WebConsumer; +import org.tubo.resource.flow.FlowContext; +import org.tubo.item.Item; +//servlet +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; +import javax.servlet.ServletConfig; +//io +import java.io.IOException; +//util +import java.util.*; +//restlet +import org.restlet.data.MediaType; +import com.noelios.restlet.ext.servlet.ServletConverter; + +/** + * <p></p> + * <p> + * Created: May 7, 2009, 9:45:27 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class RestletConsumer extends WebConsumer { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(RestletConsumer.class); + + public static String ROUTE_PROP_TUBO_REQUEST_EVENT = "tubo-request-event"; + public static String ROUTE_PROP_ALLOWED_REQUEST_TYPES = "allowed-request-types"; + public static String ROUTE_PROP_REPRESENTATIONS = "repesentations"; + + public static String REQUEST_TYPE_GET = "GET"; + public static String REQUEST_TYPE_POST = "POST"; + public static String REQUEST_TYPE_PUT = "PUT"; + public static String REQUEST_TYPE_DELETE = "DELETE"; + + public static String[] DEFAULT_ROUTE_PROP_ALLOWED_REQUEST_TYPES = new String[] { "GET" }; + public static MediaType[] DEFAULT_ROUTE_PROP_REPRESENTATIONS = new MediaType[] { MediaType.TEXT_PLAIN }; + + + protected static Map converters = new HashMap(); + public static String RESTLET_RESOURCE_OUT_REPRESENTATION = "RESTLET_RESOURCE_OUT_REPRESENTATION"; + + private FlowContext currentFlowContext; + + /** + * Returns a ServletConverter for the caller servlet + * @param servletConfig + * @return + */ + protected ServletConverter getServletConverter(ServletConfig servletConfig) { + // + // get converter from cache + ServletConverter converter = (ServletConverter)converters.get(servletConfig.getServletName()); + // + // check if converter exists + if (converter == null) { + // + // if not, create one + converter = new ServletConverter(servletConfig.getServletContext()); + // + // create e router + TuboRestletRouter router = new TuboRestletRouter(converter.getContext()); + // + // for each 'route' property, attach a route to router + Properties tuboProps = this.getProperties(); + for (Enumeration e = tuboProps.propertyNames(); e.hasMoreElements();) { + String aRoute = (String)e.nextElement(); + // check if this prop is a route + if ("route[".equals(aRoute.substring(0,6))) { + String[] aRouteArray = aRoute.split("="); + String route = aRouteArray[1]; + String event = tuboProps.getProperty(aRoute); + Map props = parseRouteProperties(event); + //set properties for TuboRestletResource instance + //TuboRestletHandler restlet = new TuboRestletHandler(this,event,servletConfig); + //attach handler + router.attach(route,TuboRestletResource.class, props); + //router.attach(route,restlet); + } + } + // + // set router to converter + converter.setTarget(router); + // + // store the new converter in cache + converters.put(servletConfig.getServletName(),converter); + } + // + // return the converter + return converter; + } + + /** + * Route Property Parser + * TODO: NO TIENE BUEN MANEJO DE ERRORES!! (por no decir ninguno) + * + * @param routeProp + * @return + */ + protected Map parseRouteProperties(String routeProp) { + // + // first parsing based on ',' caracter + StringTokenizer st = new StringTokenizer(routeProp,","); + // + // Map with route properties + Map mapRouteProp = new HashMap(st.countTokens()); + // + // inicialize with default data + mapRouteProp.put(ROUTE_PROP_ALLOWED_REQUEST_TYPES, DEFAULT_ROUTE_PROP_ALLOWED_REQUEST_TYPES); + mapRouteProp.put(ROUTE_PROP_REPRESENTATIONS, DEFAULT_ROUTE_PROP_REPRESENTATIONS); + // + // Iterate each token + while (st.hasMoreElements()) { + // get token + String prop = st.nextToken(); + // parse token based on '=' caracter + String arrayProp[] = prop.split("="); + /*if (arrayProp.length != 2) + if (arrayProp.length == 1) + // TODO: ERROR en propiedad arrayProp[0] + else + // TODO: ERROR en propiedad generico + */ + // get data + String key=arrayProp[0]; + String value=arrayProp[1]; + // store on map + if (ROUTE_PROP_TUBO_REQUEST_EVENT.equals(key)) + mapRouteProp.put(key,value); + else { + String values[] = value.split(";"); + mapRouteProp.put(key,values); + } + } + // + // return map + return mapRouteProp; + } + + /** + * Servlet service handler + * @throws ServletException + * @throws IOException + */ + public FlowContext processRequest() throws ServletException, IOException { + if (log.isTraceEnabled()) log.trace(".processRequest() - Begin"); + // + // get (or create) converter + ServletConverter converter = getServletConverter(getCurrentServletConfig()); + // + // execute converter + converter.service(getCurrentHttpServletRequest(), getCurrentHttpServletResponse()); + if (log.isTraceEnabled()) log.trace(".processRequest() - Done"); + // + // return the currentFlowContext because the flow execution appends on + // TuboRestletResource and is stored on this attribute on + // doConsumerLifeCycle + return currentFlowContext; + } + + /** + * Expose this method public to be public for TuboRestletHandler + * @param eventAction + * @param consumedRawData + * @return + */ + public FlowContext doConsumerLifeCycle(String eventAction, Object consumedRawData) { + // + // execute the default Consumer Life Cycle + currentFlowContext = super.doConsumerLifeCycle(eventAction, consumedRawData); + // + // return FlowContext + return currentFlowContext; + } + + protected Item createItem() { + return new RestletItem(); + } + + protected void initializeItem(Item item) { + super.initializeItem(item); + // + // cast + RestletItem restletItem = (RestletItem)item; + // + // get resource data + RestletResourceData resourceData = (RestletResourceData)restletItem.getConsumedRawData(); + // + // init restlet item + restletItem.setRestletContext(resourceData.getRestletContext()); + restletItem.setRestletRequest(resourceData.getRestletRequest()); + restletItem.setRestletResponse(resourceData.getRestletResponse()); + restletItem.setRestletVariant(resourceData.getRestletVariant()); + } + + + /** + * Helper Class to handle restlet match + */ + /*class TuboRestletHandler extends Restlet { + + protected ServletConfig servletConfig; + protected RestletConsumer restletConsumer; + protected String event; + + TuboRestletHandler(RestletConsumer restletConsumer, String event, ServletConfig servletConfig) { + this.servletConfig = servletConfig; + this.restletConsumer = restletConsumer; + this.event = event; + } + + public void handle(Request request, Response response) { + restletConsumer.doConsumerLifeCycle(event,new RestletData(servletConfig,request,response)); + } + }*/ +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumerLoader.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumerLoader.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletConsumerLoader.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,42 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.web.WebConsumerLoader; + +/** + * <p></p> + * <p> + * Created: May 7, 2009, 9:46:27 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class RestletConsumerLoader extends WebConsumerLoader { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(RestletConsumerLoader.class); + +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletData.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletData.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletData.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,78 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//restlet +import org.restlet.data.Response; +import org.restlet.data.Request; +//servlet +import javax.servlet.ServletConfig; + +/** + * <p></p> + * <p> + * Created: May 8, 2009, 2:33:43 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class RestletData { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(RestletData.class); + + protected ServletConfig servletConfig; + protected Request request; + protected Response response; + + public RestletData(ServletConfig servletConfig, Request request, Response response) { + this.servletConfig = servletConfig; + this.request = request; + this.response = response; + } + + public ServletConfig getServletConfig() { + return servletConfig; + } + + public void setServletConfig(ServletConfig servletConfig) { + this.servletConfig = servletConfig; + } + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } + + public Response getResponse() { + return response; + } + + public void setResponse(Response response) { + this.response = response; + } +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletItem.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletItem.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletItem.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,81 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.tubo.web.HttpItem; +import org.restlet.Context; +import org.restlet.resource.Variant; +import org.restlet.data.Response; +import org.restlet.data.Request; + +/** + * <p></p> + * <p> + * Created: May 14, 2009, 2:56:07 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class RestletItem extends HttpItem { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(RestletItem.class); + + private Context restletContext; + private Request restletRequest; + private Response restletResponse; + private Variant restletVariant; + + public Context getRestletContext() { + return restletContext; + } + + public void setRestletContext(Context restletContext) { + this.restletContext = restletContext; + } + + public Request getRestletRequest() { + return restletRequest; + } + + public void setRestletRequest(Request restletRequest) { + this.restletRequest = restletRequest; + } + + public Response getRestletResponse() { + return restletResponse; + } + + public void setRestletResponse(Response restletResponse) { + this.restletResponse = restletResponse; + } + + public Variant getRestletVariant() { + return restletVariant; + } + + public void setRestletVariant(Variant restletVariant) { + this.restletVariant = restletVariant; + } +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletResourceData.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletResourceData.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/RestletResourceData.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,90 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.restlet.Context; +import org.restlet.resource.Variant; +import org.restlet.data.Request; +import org.restlet.data.Response; + +/** + * <p></p> + * <p> + * Created: May 14, 2009, 4:03:12 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class RestletResourceData { + public static final String RCS_ID = "$"; + private static Log log = LogFactory.getLog(RestletResourceData.class); + + private Context restletContext; + private Request restletRequest; + private Response restletResponse; + private Variant restletVariant; + + public RestletResourceData() { + } + + public RestletResourceData(Context restletContext, Request restletRequest, Response restletResponse, Variant restletVariant) { + this.restletContext = restletContext; + this.restletRequest = restletRequest; + this.restletResponse = restletResponse; + this.restletVariant = restletVariant; + } + + public Context getRestletContext() { + return restletContext; + } + + public void setRestletContext(Context restletContext) { + this.restletContext = restletContext; + } + + public Request getRestletRequest() { + return restletRequest; + } + + public void setRestletRequest(Request restletRequest) { + this.restletRequest = restletRequest; + } + + public Response getRestletResponse() { + return restletResponse; + } + + public void setRestletResponse(Response restletResponse) { + this.restletResponse = restletResponse; + } + + public Variant getRestletVariant() { + return restletVariant; + } + + public void setRestletVariant(Variant restletVariant) { + this.restletVariant = restletVariant; + } +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletResource.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletResource.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletResource.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,185 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//restlet +import org.restlet.Context; +import org.restlet.resource.Variant; +import org.restlet.resource.Resource; +import org.restlet.resource.Representation; +import org.restlet.resource.ResourceException; +import org.restlet.data.Request; +import org.restlet.data.Response; +import org.restlet.data.MediaType; +//tubo +import org.tubo.resource.flow.FlowContext; +import org.tubo.web.WebConsumer; + +import java.util.Map; + +/** + * <p></p> + * <p> + * Created: May 9, 2009, 2:32:00 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TuboRestletResource extends Resource { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(TuboRestletResource.class); + + Map props; + + public TuboRestletResource() { + super(); + //routerProps = (Map)context.getAttributes().get("TUBO_RUTE_PROPS"); + } + + public TuboRestletResource(Context context, Request request, Response response) { + super(context, request, response); + props = (Map)context.getAttributes().get("TUBO_RUTE_PROPS"); + init(context, request, response); + } + + + public void init(Context context, Request request, Response response) { + super.init(context, request, response); + // + // Allow Requests Types + String allowedReqTypes[] = (String[]) props.get(RestletConsumer.ROUTE_PROP_ALLOWED_REQUEST_TYPES); + for (int i=0; i < allowedReqTypes.length; i++) { + if ("GET".equals(allowedReqTypes[i])) + allowGet(); + else if ("POST".equals(allowedReqTypes[i])) + this.allowPost(); + else if ("PUT".equals(allowedReqTypes[i])) + this.allowPut(); + else if ("DELETE".equals(allowedReqTypes[i])) + this.allowDelete(); + /*else + //TODO: ERRORRRRRR + */ + } + // + // define representations availables + String representations[] = (String[]) props.get(RestletConsumer.ROUTE_PROP_REPRESENTATIONS); + for (int i=0; i < representations.length; i++) + getVariants().add(new Variant(convertStringToMediaType(representations[i]))); + + } + + + /** + * GET + * @param variant + * @return + * @throws ResourceException + */ + public Representation represent(Variant variant) throws ResourceException { + // + // call process request + Representation result = processRestletRequest(RestletConsumer.REQUEST_TYPE_GET, variant); + // + // returns + return result; + } + + /** + * POST + * @param entity + * @throws ResourceException + */ + public void acceptRepresentation(Representation entity) throws ResourceException { + // + // call process request + Representation result = processRestletRequest(RestletConsumer.REQUEST_TYPE_POST, entity); + } + + + /** + * PUT + * @param entity + * @throws ResourceException + */ + public void storeRepresentation(Representation entity) throws ResourceException { + // + // call process request + Representation result = processRestletRequest(RestletConsumer.REQUEST_TYPE_PUT, entity); + } + + /** + * DELETE + * @throws ResourceException + */ + public void removeRepresentations() throws ResourceException { + // + // call process request + Representation result = processRestletRequest(RestletConsumer.REQUEST_TYPE_DELETE, null); + } + + + protected Representation processRestletRequest(String requestType, Variant variant) { + // + // fire consumer event + RestletResourceData resourceData = new RestletResourceData(getContext(), getRequest(), getResponse(), variant); + FlowContext flowContext = doConsumerLifeCycle(requestType,variant); + // + // + Representation result = (Representation)flowContext.getItem().getProperties().get(RestletConsumer.RESTLET_RESOURCE_OUT_REPRESENTATION); + // + // + return result; + } + + public FlowContext doConsumerLifeCycle(String requestType, Variant variant) { + // + // get consumer + RestletConsumer consumer = (RestletConsumer)getRequest().getAttributes().get(WebConsumer.TUBO_WEB_CONSUMER); + // + // fire consumer event + String event = requestType+"-"+props.get(RestletConsumer.ROUTE_PROP_TUBO_REQUEST_EVENT); + RestletResourceData resourceData = new RestletResourceData(getContext(), getRequest(), getResponse(), variant); + FlowContext flowContext = consumer.doConsumerLifeCycle(event,resourceData); + // + // return flow context + return flowContext; + } + + protected MediaType convertStringToMediaType(String mediaTypeName) { + MediaType mt = null; + try { + mt = (MediaType) MediaType.class.getField(mediaTypeName).get(MediaType.class); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return mt; + } + + + +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletRouter.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletRouter.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletRouter.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,92 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//restlet +import org.restlet.Router; +import org.restlet.Context; +import org.restlet.Restlet; +import org.restlet.Route; +import org.restlet.data.Request; +import org.restlet.data.Response; + +import java.util.Map; +import java.util.HashMap; + +/** + * <p></p> + * <p> + * Created: May 11, 2009, 5:36:28 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TuboRestletRouter extends Router { + public static final String RCS_ID = "$"; + private static Log log = LogFactory.getLog(TuboRestletRouter.class); + + private Map routeProps = new HashMap(); + + public TuboRestletRouter() { + super(); + } + + public TuboRestletRouter(Context context) { + super(context); + } + + public Restlet getNext(Request request, Response response) { + // + // call super and store restlet (route) + Restlet restlet = super.getNext(request, response); + // + // check if thre request route is founded + if (restlet != null) { + // + // find props for this route + Map props = (Map)routeProps.get(restlet); + // + // set context + getContext().getAttributes().put("TUBO_RUTE_PROPS",props); + // + // return + return restlet; + } + else + return null; // TODO: Dar un ERROR!!!??? o utilizar el 404 default de restlet?? + } + + public Route attach(String uriPattern, Class targetClass, Map props) { + // + // call super and store route + Route route = super.attach(uriPattern, targetClass); + // + // map route with props + routeProps.put(route,props); + // + // return route + return route; + } +} \ No newline at end of file Added: trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletServlet.java =================================================================== --- trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletServlet.java (rev 0) +++ trunk/modules/tubo-restlet/src/main/java/org/tubo/web/restlet/TuboRestletServlet.java 2010-03-17 11:38:29 UTC (rev 122) @@ -0,0 +1,94 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web.restlet; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//restlet +import org.restlet.Restlet; +import org.restlet.Router; +import org.restlet.data.Request; +import org.restlet.data.Response; +import org.restlet.data.MediaType; +import com.noelios.restlet.ext.servlet.ServletConverter; +//servlet +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; +//io +import java.io.IOException; + +/** + * <p></p> + * <p> + * Created: Mar 17, 2009, 12:14:42 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TuboRestletServlet extends HttpServlet { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(TuboRestletServlet.class); + + private ServletConverter converter; + + public void init() throws ServletException { + super.init(); + log.debug(".init() - start"); + this.converter = new ServletConverter(getServletContext()); + + Restlet restlet = new Restlet() { + public void handle(Request req, Response res) { + String name = (String) req.getAttributes().get("name"); + String msg = null; + if (name != null) + msg = "Hello World "+name+"!"; + else + msg = "Hello World!"; + + log.info(msg); + res.setEntity(msg, MediaType.TEXT_PLAIN); + } + }; + + + Router router = new Router(this.converter.getContext()); + router.attach("/hello/{name}",restlet); + router.attach("/hello/",restlet); + /*Restlet trace = new Restlet(this.converter.getContext()) { + public void handle(Request req, Response res) { + log.info("Hello World"); + res.setEntity("Hello World!", MediaType.TEXT_PLAIN); + } + };*/ + + this.converter.setTarget(router); + } + + protected void service(HttpServletRequest req, HttpServletResponse res) + throws ServletException, IOException { + this.converter.service(req, res); + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2010-03-17 11:37:18
|
Revision: 121 http://tubo.svn.sourceforge.net/tubo/?rev=121&view=rev Author: maldito_orco Date: 2010-03-17 11:37:12 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Modified Paths: -------------- trunk/modules/tubo-web/pom.xml trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java Added Paths: ----------- trunk/modules/tubo-web/src/main/java/org/tubo/web/ trunk/modules/tubo-web/src/main/java/org/tubo/web/HttpItem.java trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumer.java trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumerLoader.java Modified: trunk/modules/tubo-web/pom.xml =================================================================== --- trunk/modules/tubo-web/pom.xml 2010-03-17 11:32:16 UTC (rev 120) +++ trunk/modules/tubo-web/pom.xml 2010-03-17 11:37:12 UTC (rev 121) @@ -25,7 +25,7 @@ - Parent --> <parent> - <groupId>org.tubo</groupId> + <groupId>org.tubo</groupId> <artifactId>tubo</artifactId> <version>1.0-alpha2</version> </parent> Modified: trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java 2010-03-17 11:32:16 UTC (rev 120) +++ trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java 2010-03-17 11:37:12 UTC (rev 121) @@ -50,7 +50,7 @@ //@Override public void contextInitialized(ServletContextEvent servletContextEvent) { //To change body of implemented methods use File | Settings | File Templates. jetty:run - log.info(".contextInitialized() - Inicializando Contexto"); + log.info(".contextInitialized() - Initializing Context"); String configLocation = servletContextEvent.getServletContext().getInitParameter("tubo.config.location"); log.info(".contextInitialized() - tubo.config.location="+configLocation); @@ -77,13 +77,13 @@ // store kernel instance in servlet context servletContextEvent.getServletContext().setAttribute("TUBO_KERNEL",kernel); // - log.info(".contextInitialized() - Contexto Inicializado "); + log.info(".contextInitialized() - Context Initialized"); } //@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { //To change body of implemented methods use File | Settings | File Templates. - log.info(".contextDestroyed() - Destruyendo Contexto"); + log.info(".contextDestroyed() - Destroying Context"); kernel.shutdown(); } } \ No newline at end of file Modified: trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java 2010-03-17 11:32:16 UTC (rev 120) +++ trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java 2010-03-17 11:37:12 UTC (rev 121) @@ -23,15 +23,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //restlet -import org.restlet.Restlet; -import org.restlet.Router; -import org.restlet.data.Request; -import org.restlet.data.Response; -import org.restlet.data.MediaType; -import org.tubo.web.restlet.TuboRestletServlet; +import org.tubo.web.WebConsumer; import org.tubo.kernel.Kernel; import org.tubo.resource.consumer.ConsumerManager; -import com.noelios.restlet.ext.servlet.ServletConverter; +import org.tubo.resource.consumer.Consumer; //servlet import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -56,22 +51,34 @@ private static Log log = LogFactory.getLog(TuboServletAdapter.class); protected String consumerId; + protected ConsumerManager consumerManager; public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); //To change body of overridden methods use File | Settings | File Templates. - log.debug(".init() - start"); + if (log.isTraceEnabled()) log.trace(".init() - start"); consumerId = servletConfig.getInitParameter("consumerId"); - log.info(".init() - consumerId="+consumerId); + log.debug(".init() - consumerId="+consumerId); Kernel kernel = (Kernel) servletConfig.getServletContext().getAttribute("TUBO_KERNEL"); - ConsumerManager consumerManager = kernel.getResourceManager().getConsumerManager(consumerId); - log.info("manager="+consumerManager); - + consumerManager = kernel.getResourceManager().getConsumerManager(consumerId); + log.debug("manager="+consumerManager); + if (log.isTraceEnabled()) log.trace(".init() - end"); } protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - log.debug(".service() - start"); + if (log.isTraceEnabled()) log.trace(".service() - start"); + + Consumer consumer = consumerManager.getConsumer(); + if (consumer instanceof WebConsumer) { + WebConsumer webConsumer = (WebConsumer)consumer; + webConsumer.service(this.getServletConfig(),req, res); + } + else { + // TODO: throw Error + } + + if (log.isTraceEnabled()) log.trace(".service() - end"); } } \ No newline at end of file Added: trunk/modules/tubo-web/src/main/java/org/tubo/web/HttpItem.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/web/HttpItem.java (rev 0) +++ trunk/modules/tubo-web/src/main/java/org/tubo/web/HttpItem.java 2010-03-17 11:37:12 UTC (rev 121) @@ -0,0 +1,73 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.item.BaseItemImpl; + +import javax.servlet.ServletConfig; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletRequest; + +/** + * <p></p> + * <p> + * Created: May 13, 2009, 1:13:50 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class HttpItem extends BaseItemImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(HttpItem.class); + + private ServletConfig servletConfig; + private HttpServletRequest httpServletRequest; + private HttpServletResponse httpServletResponse; + + public ServletConfig getServletConfig() { + return servletConfig; + } + + public void setServletConfig(ServletConfig servletConfig) { + this.servletConfig = servletConfig; + } + + public HttpServletRequest getHttpServletRequest() { + return httpServletRequest; + } + + public void setHttpServletRequest(HttpServletRequest httpServletRequest) { + this.httpServletRequest = httpServletRequest; + } + + public HttpServletResponse getHttpServletResponse() { + return httpServletResponse; + } + + public void setHttpServletResponse(HttpServletResponse httpServletResponse) { + this.httpServletResponse = httpServletResponse; + } +} \ No newline at end of file Added: trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumer.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumer.java (rev 0) +++ trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumer.java 2010-03-17 11:37:12 UTC (rev 121) @@ -0,0 +1,186 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.consumer.BaseConsumerImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.item.Item; +//servlet +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; +import javax.servlet.ServletConfig; +import java.io.IOException; + +/** + * <p></p> + * <p> + * Created: May 7, 2009, 2:57:05 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class WebConsumer extends BaseConsumerImpl { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(WebConsumer.class); + + public static final String TUBO_WEB_CONSUMER = "TUBO_RESTLET_CONSUMER"; + + private static final ThreadLocal SERVLETCONFIG = new ThreadLocal(); + private static final ThreadLocal HTTPSERVLETREQUEST = new ThreadLocal(); + private static final ThreadLocal HTTPSERVLETRESPONSE = new ThreadLocal(); + + public static ServletConfig getCurrentServletConfig() { + return (ServletConfig)SERVLETCONFIG.get(); + } + + public static HttpServletRequest getCurrentHttpServletRequest() { + return (HttpServletRequest)HTTPSERVLETREQUEST.get(); + } + + public static HttpServletResponse getCurrentHttpServletResponse() { + return (HttpServletResponse)HTTPSERVLETRESPONSE.get(); + } + + public ServletConfig getServletConfig() { + return getCurrentServletConfig(); + } + + public HttpServletRequest getHttpServletRequest() { + return getCurrentHttpServletRequest(); + } + + public HttpServletResponse getHttpServletResponse() { + return getCurrentHttpServletResponse(); + } + + + + /** + * Template method + * + * @param servletConfig + * @param request + * @param response + * @throws ServletException + * @throws IOException + */ + public void service(ServletConfig servletConfig, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (log.isTraceEnabled()) log.trace(".service() - Begin"); + // + // Initialization of the HTTP request processing life cycle + initProcessRequest(servletConfig, request, response); + // + // execute a pre procesing HTTP request + preProcessRequest(); + // + // execution of the HTTP request processing + FlowContext flowContext = processRequest(); + // + // execute a post procesing HTTP request + postProcessRequest(flowContext); + + if (log.isTraceEnabled()) log.trace(".service() - Done"); + } + + /** + * Init hook for processing HTTP service method + * + * @param servletConfig + * @param request + * @param response + * @throws ServletException + * @throws IOException + */ + public void initProcessRequest(ServletConfig servletConfig, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (log.isTraceEnabled()) log.trace(".initProcessRequest() - Begin"); + // + // store original request data + SERVLETCONFIG.set(servletConfig); + HTTPSERVLETREQUEST.set(request); + HTTPSERVLETRESPONSE.set(response); + // + // Set consumer on atributes context + request.setAttribute(TUBO_WEB_CONSUMER, this); + + if (log.isTraceEnabled()) log.trace(".initProcessRequest() - Done"); + } + + /** + * Hook method to process HTTP service request + * + * @throws ServletException + * @throws IOException + */ + public FlowContext processRequest() throws ServletException, IOException { + if (log.isTraceEnabled()) log.trace(".processRequest() - Begin"); + // + // fire consumer event + FlowContext flowContext = doConsumerLifeCycle(getCurrentHttpServletRequest().getMethod(),this); + // + // log trace + if (log.isTraceEnabled()) log.trace(".processRequest() - Done"); + // + // return + return flowContext; + } + + /** + * Pre process Hook method + * @throws ServletException + * @throws IOException + */ + public void preProcessRequest() throws ServletException, IOException { + } + + /** + * Post process Hok method + * + * @param flowContext + * @throws ServletException + * @throws IOException + */ + public void postProcessRequest(FlowContext flowContext) throws ServletException, IOException { + } + + protected Item createItem() { + return new HttpItem(); + } + + protected void initializeItem(Item item) { + super.initializeItem(item); + // + // cast + HttpItem httpItem = (HttpItem)item; + // + // set original request data + httpItem.setServletConfig(getCurrentServletConfig()); + httpItem.setHttpServletRequest(getCurrentHttpServletRequest()); + httpItem.setHttpServletResponse(getCurrentHttpServletResponse()); + } +} \ No newline at end of file Added: trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumerLoader.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumerLoader.java (rev 0) +++ trunk/modules/tubo-web/src/main/java/org/tubo/web/WebConsumerLoader.java 2010-03-17 11:37:12 UTC (rev 121) @@ -0,0 +1,50 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.web; +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.consumer.ConsumerLoader; +import org.tubo.resource.consumer.ConsumerManager; +import org.tubo.exception.TuboConsumerException; + +/** + * <p></p> + * <p> + * Created: May 7, 2009, 3:31:38 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class WebConsumerLoader implements ConsumerLoader { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(WebConsumerLoader.class); + + public void load(ConsumerManager manager) throws TuboConsumerException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unload(ConsumerManager manager) throws TuboConsumerException { + //To change body of implemented methods use File | Settings | File Templates. + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2010-03-17 11:32:23
|
Revision: 120 http://tubo.svn.sourceforge.net/tubo/?rev=120&view=rev Author: maldito_orco Date: 2010-03-17 11:32:16 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Pre-Refactor Modified Paths: -------------- trunk/modules/tubo-core/pom.xml trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/ConnectionDef.java trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeFromDef.java trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseConnectionDefImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeFromDefImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowProcessorImpl.java trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml trunk/modules/tubo-core/src/main/resources/META-INF/config/digester-xml-meta-rules.xml trunk/modules/tubo-core/src/main/resources/META-INF/messages/base-errors.properties trunk/modules/tubo-core/src/test/java/org/tubo/configuration/ConfigurationManagerTest.java trunk/modules/tubo-core/src/test/java/org/tubo/configuration/reader/XMLDigesterConfigurationReaderTest.java trunk/modules/tubo-core/src/test/java/org/tubo/resource/baseimpl/BaseManagerImplTest.java trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/SpringResourceManagerImplTest.java trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/TestComponent.java trunk/modules/tubo-core/src/test/resources/log4j.xml Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeInOutFlowDef.java trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeInOutFlowDefImpl.java trunk/modules/tubo-core/src/main/resources/META-INF/flows/ trunk/modules/tubo-core/src/main/resources/META-INF/flows/admin-flow.xml trunk/modules/tubo-core/src/main/resources/META-INF/flows/echo-flow.xml trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-connection-template.vm Modified: trunk/modules/tubo-core/pom.xml =================================================================== --- trunk/modules/tubo-core/pom.xml 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/pom.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -53,7 +53,7 @@ <stagingDirectory>${basedir}/../../target/staged-site</stagingDirectory> </configuration> </plugin> - </plugins> + </plugins> </build> <!-- - Dependencies @@ -222,6 +222,7 @@ </dependencies> + <!-- - Reporting --> @@ -306,7 +307,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> - <version>2.1</version> + <version>2.4</version> <configuration> <linkXref>true</linkXref> <sourceEncoding>utf-8</sourceEncoding> Modified: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/ConnectionDef.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/ConnectionDef.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/ConnectionDef.java 2010-03-17 11:32:16 UTC (rev 120) @@ -34,6 +34,12 @@ String getType(); String getStrategy(); String getFactoryClassname(); + + String getDriverClass(); + String getUrl(); + String getUser(); + String getPassword(); + int getMinCapacity(); int getMaxCapacity(); } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeFromDef.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeFromDef.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeFromDef.java 2010-03-17 11:32:16 UTC (rev 120) @@ -32,6 +32,8 @@ public static final String RCS_ID = "$Id$"; String getRefId(); - FlowNodeList getFlowNodeList(); + FlowConsumeInOutFlowDef getInboundFlow(); + + FlowConsumeInOutFlowDef getOutboundFlow(); } \ No newline at end of file Copied: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeInOutFlowDef.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeFromDef.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeInOutFlowDef.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/FlowConsumeInOutFlowDef.java 2010-03-17 11:32:16 UTC (rev 120) @@ -0,0 +1,35 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.configuration.def; + +/** + * Created: Oct 22, 2006, 3:37:36 AM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public interface FlowConsumeInOutFlowDef { + public static final String RCS_ID = "$Id$"; + + FlowNodeList getFlowNodeList(); +} \ No newline at end of file Modified: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseConnectionDefImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseConnectionDefImpl.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseConnectionDefImpl.java 2010-03-17 11:32:16 UTC (rev 120) @@ -42,6 +42,12 @@ private String type = null; private String strategy = null; private String factoryClassname = null; + + private String driverClass = null; + private String url = null; + private String User = null; + private String Password = null; + int minCapacity = -1; int maxCapacity = -1; @@ -60,6 +66,38 @@ this.factoryClassname = factoryClassname; } + public String getDriverClass() { + return driverClass; + } + + public void setDriverClass(String driverClass) { + this.driverClass = driverClass; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUser() { + return User; + } + + public void setUser(String user) { + User = user; + } + + public String getPassword() { + return Password; + } + + public void setPassword(String password) { + Password = password; + } + public int getMinCapacity() { return minCapacity; } public void setMinCapacity(int minCapacity) { this.minCapacity = minCapacity; Modified: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeFromDefImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeFromDefImpl.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeFromDefImpl.java 2010-03-17 11:32:16 UTC (rev 120) @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; //tubo-configuration import org.tubo.configuration.def.FlowConsumeFromDef; -import org.tubo.configuration.def.FlowNodeList; +import org.tubo.configuration.def.FlowConsumeInOutFlowDef; /** * <p></p> @@ -41,15 +41,21 @@ private static Log log = LogFactory.getLog(BaseFlowConsumeFromDefImpl.class); private String refId = null; - private FlowNodeList flowNodeList = null; + private FlowConsumeInOutFlowDef inboundFlow = null; + private FlowConsumeInOutFlowDef outboundFlow = null; public String getRefId() { return refId; } public void setRefId(String refId) { this.refId = refId; } - public FlowNodeList getFlowNodeList() { return flowNodeList; } - public void setFlowNodeList(FlowNodeList flowNodeList) { - this.flowNodeList = flowNodeList; + public FlowConsumeInOutFlowDef getInboundFlow() { return inboundFlow; } + public void setInboundFlow(FlowConsumeInOutFlowDef inboundFlow) { + this.inboundFlow = inboundFlow; } + + public FlowConsumeInOutFlowDef getOutboundFlow() { return outboundFlow; } + public void setOutboundFlow(FlowConsumeInOutFlowDef outboundFlow) { + this.outboundFlow = outboundFlow; + } } Copied: trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeInOutFlowDefImpl.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeFromDefImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeInOutFlowDefImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/configuration/def/baseimpl/BaseFlowConsumeInOutFlowDefImpl.java 2010-03-17 11:32:16 UTC (rev 120) @@ -0,0 +1,49 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.configuration.def.baseimpl; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo-configuration +import org.tubo.configuration.def.FlowNodeList; +import org.tubo.configuration.def.FlowConsumeInOutFlowDef; + +/** + * <p></p> + * <p> + * Created: Oct 22, 2006, 3:41:00 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseFlowConsumeInOutFlowDefImpl implements FlowConsumeInOutFlowDef { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseFlowConsumeInOutFlowDefImpl.class); + + private FlowNodeList flowNodeList = null; + + public FlowNodeList getFlowNodeList() { return flowNodeList; } + public void setFlowNodeList(FlowNodeList flowNodeList) { + this.flowNodeList = flowNodeList; + } +} \ No newline at end of file Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java 2010-03-17 11:32:16 UTC (rev 120) @@ -33,6 +33,7 @@ import org.tubo.event.Event; import org.tubo.kernel.Kernel; //util +import javax.sql.DataSource; import java.util.List; /** @@ -113,6 +114,14 @@ ComponentManager getComponentManager(String id) throws TuboException; /** + * Get DataSource based on conection definition + * @param connectionId + * @return + * @throws TuboException + */ + DataSource getDataSource(String connectionId) throws TuboException; + + /** * <p> * Get kernel instance * </p> Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java 2010-03-17 11:32:16 UTC (rev 120) @@ -38,8 +38,6 @@ import org.springframework.core.io.ByteArrayResource; //tubo import org.tubo.configuration.def.*; -import org.tubo.resource.Manager; -import org.tubo.resource.BaseAbstractResourceManager; import org.tubo.resource.flow.FlowExecutor; import org.tubo.resource.flow.FlowContext; import org.tubo.exception.TuboResourceException; @@ -49,6 +47,7 @@ import org.tubo.event.Event; import org.tubo.kernel.Kernel; //java-util +import javax.sql.DataSource; import java.util.Map; import java.util.Iterator; import java.util.Properties; @@ -80,6 +79,9 @@ /** Template file for beans based on components */ public final static String BEAN_COMPONENT_TEMPLATE = "META-INF/templates/bean-component-template.vm"; + /** Template file for beans based on components */ + public final static String BEAN_CONNECTION_TEMPLATE = "META-INF/templates/bean-connection-template.vm"; + /** Template file for beans based on flows */ public final static String BEAN_DEFAULT_TEMPLATE = "META-INF/templates/bean-default-template.vm"; @@ -314,7 +316,28 @@ } + public DataSource getDataSource(String connectionId) throws TuboException { + // + // create Id + String id = connectionId+"DataSource"; + DataSource ds = null; + try { + // + // get DataSource via Spring + ds = (DataSource)beanFactory.getBean(id); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get DataSource identified by '"+id+"'", e); + // + // throw + throw getExceptionManager().getException(1304,id,e); + } + // + // return + return ds; + } public static SpringResourceManagerImpl newInstance(Configuration config) { // @@ -449,7 +472,23 @@ // create spring definition buffer = appendSpringDefinition(buffer,def,config); } + // + // === Connection Contexts + // + // get connection Defs + Map connectionsMap = config.getConnectionDefs(); + // + // iterate component Defs and append definitions to spring context + for (Iterator it=connectionsMap.values().iterator(); it.hasNext();) { + ConnectionDef def = (ConnectionDef)it.next(); + // + // create spring definition + buffer = appendSpringDefinition(buffer,def,config); + } + + + // // close tag beans buffer.append("</beans>"); // @@ -509,6 +548,10 @@ buffer = appendSpringDefinition(buffer,def,BEAN_COMPONENT_TEMPLATE,props); return buffer; } + if (def instanceof ConnectionDef) { + buffer = appendSpringDefinition(buffer,def,BEAN_CONNECTION_TEMPLATE,props); + return buffer; + } throw new TuboResourceException("Definition type not know."); } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java 2010-03-17 11:32:16 UTC (rev 120) @@ -45,7 +45,7 @@ /** * This class listen for new ServerSocket connections, when a new connection - * arrives, take a thead from the pool and a consumer and instance a + * arrives, take a thread from the pool and a consumer and instance a * WorkerProcessor for work with the new connection/consumer. * * Created: Sep 7, 2006, 12:51:43 AM @@ -104,6 +104,7 @@ // set wait time for client connection when timeout is expired // accept() throw a SocketTimeoutException try { + //FIXME: put this configuration on config file serverSocket.setSoTimeout(5*1000); } catch (SocketException e) { state = STATE_ERROR; Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowProcessorImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowProcessorImpl.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowProcessorImpl.java 2010-03-17 11:32:16 UTC (rev 120) @@ -30,12 +30,7 @@ import org.tubo.resource.component.ComponentManager; import org.tubo.resource.component.Component; import org.tubo.resource.ResourceManager; -import org.tubo.configuration.def.FlowDef; -import org.tubo.configuration.def.FlowNodeDef; -import org.tubo.configuration.def.FlowNodeList; -import org.tubo.configuration.def.ComponentRefFlowNodeDef; -import org.tubo.configuration.def.FlowRefFlowNodeDef; -import org.tubo.configuration.def.SwitchFlowNodeDef; +import org.tubo.configuration.def.*; import org.tubo.exception.TuboException; import org.tubo.item.Item; //util @@ -76,14 +71,40 @@ */ public void execute(FlowDef flowDef, FlowContext context) { if (log.isTraceEnabled()) log.trace(".execute(FlowDef,FlowContext) - Executing Flow ID="+flowDef.getId()); + FlowNodeList flowNodeList = null; // - // get flow node list - FlowNodeList flowNodeList = flowDef.getFlowNodeList(); + // get inbound consumer flow node list + if (((FlowConsumeFromDef)flowDef.getConsumeFromList().get(0)).getInboundFlow() != null) { + flowNodeList = ((FlowConsumeFromDef)flowDef.getConsumeFromList().get(0)).getInboundFlow().getFlowNodeList(); + // + // execute inbound consumer flow node list + if (!flowNodeList.getList().isEmpty()) + execute(flowNodeList,context); + else + if (log.isTraceEnabled()) log.trace(".execute(FlowDef,FlowContext) - Inbound FlowNode is empty"); + } // + // get Main flow node list + flowNodeList = flowDef.getFlowNodeList(); + // // execute list - execute(flowNodeList,context); + if (flowNodeList != null && !flowNodeList.getList().isEmpty()) + execute(flowNodeList,context); + else + if (log.isWarnEnabled()) log.warn(".execute(FlowDef,FlowContext) - Main FlowNode is empty"); + // - // execute node list + // get outbound consumer flow node list + if (((FlowConsumeFromDef)flowDef.getConsumeFromList().get(0)).getOutboundFlow() != null) { + flowNodeList = ((FlowConsumeFromDef)flowDef.getConsumeFromList().get(0)).getOutboundFlow().getFlowNodeList(); + // + // execute inbound consumer flow node list + if (!flowNodeList.getList().isEmpty()) + execute(flowNodeList,context); + else + if (log.isTraceEnabled()) log.trace(".execute(FlowDef,FlowContext) - Outbound FlowNode is empty"); + } + if (log.isTraceEnabled()) log.trace(".execute(FlowDef,FlowContext) - Done"); } Modified: trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -2,6 +2,18 @@ <kernel-builder-class>org.tubo.kernel.SpringKernelBuilderImpl</kernel-builder-class> <kernel-builder-properties/> + <component-set> + <!-- + - Simple transform component + --> + <component id="simple-transform" + componentClassname="org.tubo.resource.component.transform.SimpleTransformComponent" + type="singleton" + > + </component> + </component-set> + + <includes> <!--include id="include_meta_rules" resource="META-INF/config/digester-meta-rules.xml" @@ -9,11 +21,19 @@ <include id="base-errors" resource="META-INF/config/base-errors.xml" /> + <!--include id="base-ra" resource="META-INF/config/base-tubo-ra.xml" /--> - <include id="base-tubo-flows" + <!--include id="base-tubo-flows" resource="META-INF/config/base-tubo-flows.xml" - /> + /--> + + <!--include id="admin-flow" + resource="META-INF/flows/admin-flow.xml" + /--> + <!--include id="echo-flow" + resource="META-INF/flows/echo-flow.xml" + /--> </includes> </tubo-configuration> Modified: trunk/modules/tubo-core/src/main/resources/META-INF/config/digester-xml-meta-rules.xml =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/config/digester-xml-meta-rules.xml 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/resources/META-INF/config/digester-xml-meta-rules.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -84,6 +84,26 @@ <set-properties-rule /> <!-- add this object to parent --> <set-next-rule methodname="add" paramtype="org.tubo.configuration.def.FlowConsumeFromDef" /> + + <!-- inboud --> + <pattern value="inbound-flow"> + <!-- create --> + <object-create-rule classname="org.tubo.configuration.def.baseimpl.BaseFlowConsumeInOutFlowDefImpl" attrname="defclassname" /> + <!-- set tag properties --> + <set-properties-rule /> + <!-- add this object to parent --> + <set-next-rule methodname="setInboundFlow" paramtype="org.tubo.configuration.def.FlowConsumeInOutFlowDef" /> + </pattern> + + <!-- outbound --> + <pattern value="outbound-flow"> + <!-- create --> + <object-create-rule classname="org.tubo.configuration.def.baseimpl.BaseFlowConsumeInOutFlowDefImpl" attrname="defclassname" /> + <!-- set tag properties --> + <set-properties-rule /> + <!-- add this object to parent --> + <set-next-rule methodname="setOutboundFlow" paramtype="org.tubo.configuration.def.FlowConsumeInOutFlowDef" /> + </pattern> </pattern> </pattern> Added: trunk/modules/tubo-core/src/main/resources/META-INF/flows/admin-flow.xml =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/flows/admin-flow.xml (rev 0) +++ trunk/modules/tubo-core/src/main/resources/META-INF/flows/admin-flow.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -0,0 +1,75 @@ +<tubo-configuration> + + <consumer-set> + <!-- + - Tubo admin service, consumer component + --> + <consumer id="tubo-admin-consumer" + consumerClassname="org.tubo.resource.consumer.serversocketlinereader.ServerSocketLineReaderConsumer" + type="pooled" + maxCapacity="3" + > + <property> + <prop-name>ports</prop-name> + <prop-value>6667</prop-value> + </property> + <property> + <prop-name>goodbye-words</prop-name> + <prop-value>exit</prop-value> + </property> + </consumer> + </consumer-set> + + <component-set> + <!-- + - Tubo admin service, echo component + --> + <component id="tubo-admin-component" + componentClassname="org.tubo.resource.component.admin.AdminComponent" + > + </component> + </component-set> + + <flow-set> + <!-- + - Tubo admin service, flow component + --> + <flow id="tubo-admin-flow"> + <consume> + <from refId="tubo-admin-consumer"> + </from> + </consume> + <node-list> + <!-- transform input ss to input echo--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>SSLINEREADER_INPUT->ADMIN_INPUT</prop-value> + </property> + </component-node> + <!-- execute admin --> + <component-node refId="tubo-admin-component"> + <listen> + <event> + <action>NEW_CONNECTION_EVENT</action> + <execute>welcome</execute> + </event> + <event> + <action>GOODBYE_EVENT</action> + <execute>exit</execute> + </event> + <!-- by default if not defined listens or not matched events, method 'execute' is invoked --> + </listen> + </component-node> + <!-- transform output echo to output ss--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>ADMIN_OUTPUT->SSLINEREADER_OUTPUT</prop-value> + </property> + </component-node> + </node-list> + </flow> + </flow-set> + +</tubo-configuration> Added: trunk/modules/tubo-core/src/main/resources/META-INF/flows/echo-flow.xml =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/flows/echo-flow.xml (rev 0) +++ trunk/modules/tubo-core/src/main/resources/META-INF/flows/echo-flow.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -0,0 +1,79 @@ +<tubo-configuration> + + <consumer-set> + <!-- + - Tubo echo service, consumer component + --> + <consumer id="tubo-echo-consumer" + consumerClassname="org.tubo.resource.consumer.serversocketlinereader.ServerSocketLineReaderConsumer" + type="pooled" + maxCapacity="3" + > + <!--property> + <prop-name>ports</prop-name> + <prop-value>6666</prop-value> + </property--> + <property name="ports" value="6666" /> + <property> + <prop-name>goodbye-words</prop-name> + <prop-value>bye,.</prop-value> + </property> + </consumer> + </consumer-set> + + <component-set> + <!-- + - Tubo echo service, echo component + --> + <component id="tubo-echo-component" + componentClassname="org.tubo.resource.component.echo.EchoComponent" + > + </component> + </component-set> + + <flow-set> + <!-- + - Tubo echo service, flow component + --> + <flow id="tubo-echo-flow"> + <consume> + <from refId="tubo-echo-consumer"> + <!--node-list> + <component-node refId="tubo-echo-component" /> + </node-list--> + </from> + </consume> + <node-list> + <!-- transform input ss to input echo--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>SSLINEREADER_INPUT->ECHO_INPUT</prop-value> + </property> + </component-node> + <!-- execute echo --> + <component-node refId="tubo-echo-component"> + <listen> + <event> + <action>NEW_CONNECTION_EVENT</action> + <execute>sayHelo</execute> + </event> + <event> + <action>GOODBYE_EVENT</action> + <execute>sayGoodbye</execute> + </event> + <!-- by default if not defined listens or not matched events, method 'execute' is invoked --> + </listen> + </component-node> + <!-- transform output echo to output ss--> + <component-node refId="simple-transform"> + <property> + <prop-name>t0</prop-name> + <prop-value>ECHO_OUTPUT->SSLINEREADER_OUTPUT</prop-value> + </property> + </component-node> + </node-list> + </flow> + </flow-set> + +</tubo-configuration> Modified: trunk/modules/tubo-core/src/main/resources/META-INF/messages/base-errors.properties =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/messages/base-errors.properties 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/main/resources/META-INF/messages/base-errors.properties 2010-03-17 11:32:16 UTC (rev 120) @@ -9,6 +9,7 @@ ## spring resource 1302=Error trying to get FlowExecutor ''{0}'' 1303=Error trying to get Manager identified by ''{0}'' +1304=Error trying to get DatSource identified by ''{0}'' ### ## flow Copied: trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-connection-template.vm (from rev 116, trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-component-template.vm) =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-connection-template.vm (rev 0) +++ trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-connection-template.vm 2010-03-17 11:32:16 UTC (rev 120) @@ -0,0 +1,68 @@ +#** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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. + *# +## +## +#** + * Velocity Connection Template file. + * This template create a connection (DataSource) spring bean definition. + * Input + * def : connectionDef + * + * Created: Dec 13, 2005 1:13:00 AM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + *# +## +##-- Set datasource Id +#set( $beanDataSourceId = "${def.Id}DataSource") +## +##-- Write datasource def +#if ($def.Type == "c3p0") + <bean id="$beanDataSourceId" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> + <property name="driverClass"><value>$def.DriverClass</value></property> + <property name="jdbcUrl"><value>$def.Url</value></property> + <property name="properties"> + <props> + <prop key="c3p0.acquire_increment">1</prop> + <prop key="c3p0.idle_test_period">100</prop> + <prop key="c3p0.max_size">15</prop> + <prop key="c3p0.max_statements">0</prop> + <prop key="c3p0.min_size">1</prop> + <prop key="user">$def.User</prop> + <prop key="password">$def.Password</prop> + </props> + </property> + +## <property name="user"><value>$def.User</value></property> +## <property name="password"><value>$def.Password</value></property> + +## <property name="initialPoolSize"><value>3</value></property> +## <property name="minPoolSize"><value>3</value></property> +## <property name="maxPoolSize"><value>50</value></property> + </bean> +##else +#end + + + Modified: trunk/modules/tubo-core/src/test/java/org/tubo/configuration/ConfigurationManagerTest.java =================================================================== --- trunk/modules/tubo-core/src/test/java/org/tubo/configuration/ConfigurationManagerTest.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/java/org/tubo/configuration/ConfigurationManagerTest.java 2010-03-17 11:32:16 UTC (rev 120) @@ -53,7 +53,7 @@ public void setUp() throws Exception { super.setUp(); manager = new ConfigurationManager(); - manager.appendResource(KernelFactory.BASE_CONFIG_LOCATION); + manager.appendResource(KernelFactory.DEFAULT_BASE_CONFIG_LOCATION); } public void tearDown() throws Exception { Modified: trunk/modules/tubo-core/src/test/java/org/tubo/configuration/reader/XMLDigesterConfigurationReaderTest.java =================================================================== --- trunk/modules/tubo-core/src/test/java/org/tubo/configuration/reader/XMLDigesterConfigurationReaderTest.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/java/org/tubo/configuration/reader/XMLDigesterConfigurationReaderTest.java 2010-03-17 11:32:16 UTC (rev 120) @@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory; //tubo-configuration import org.tubo.configuration.def.*; -import org.tubo.configuration.ConfigurationManager; import org.tubo.exception.TuboConfigurationException; import org.tubo.kernel.KernelFactory; //junit @@ -50,7 +49,7 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(XMLDigesterConfigurationReaderTest.class); - private static final String BASE_CONFIG_LOCATION = KernelFactory.BASE_CONFIG_LOCATION; + private static final String BASE_CONFIG_LOCATION = KernelFactory.DEFAULT_BASE_CONFIG_LOCATION; private ConfigurationReader configurationReader = null; private Configuration configuration = null; @@ -85,13 +84,16 @@ configurationReader.append(resourceLocation,config); } + public void testMock() throws Exception { + } + /*public void testCreateEmptyConfigurationObject() throws Exception { Configuration _config = configurationReader.createEmptyConfigurationObject(); assertTrue("Configuration object is not an instance of DigesterConfigurationImpl",_config instanceof DigesterConfigurationImpl); }*/ - public void testParseMetaRules() throws Exception { +/* public void testParseMetaRules() throws Exception { // // load configuration Configuration config = getConfig(); @@ -115,9 +117,9 @@ assertTrue("Configuration object not contains a 'flow-object-create-rule'",config.existId("flow-object-create-rule")); assertTrue("Configuration object not contains a 'flow-set-properties-rule'",config.existId("flow-set-properties-rule")); assertTrue("Configuration object not contains a 'flow-set-next-rule'",config.existId("flow-set-next-rule")); - } + }*/ - public void testParseMetaConnection() throws Exception { + /*public void testParseMetaConnection() throws Exception { // // append test configuration (include manual) appendConfiguration("test-meta-connection.xml"); @@ -148,9 +150,9 @@ String name = (String)it.next(); assertEquals("Property "+name+" is diferent '"+name+"'!='"+def.getProperty(name)+"'",name,def.getProperty(name)); } - } + }*/ - public void testParseMetaConsumer() throws Exception { + /*public void testParseMetaConsumer() throws Exception { // // append test configuration (include manual) appendConfiguration("test-meta-consumer.xml"); @@ -181,9 +183,9 @@ String name = (String)it.next(); assertEquals("Property "+name+" is diferent '"+name+"'!='"+def.getProperty(name)+"'",name,def.getProperty(name)); } - } + }*/ - public void testParseMetaComponent() throws Exception { + /*public void testParseMetaComponent() throws Exception { // // append test configuration (include manual) appendConfiguration("test-meta-component.xml"); @@ -209,9 +211,9 @@ String name = (String)it.next(); assertEquals("Property "+name+" is diferent '"+name+"'!='"+def.getProperty(name)+"'",name,def.getProperty(name)); } - } + }*/ - public void testParseMetaFlow() throws Exception { + /*public void testParseMetaFlow() throws Exception { // // append test configuration (include manual) appendConfiguration("test-meta-flow.xml"); @@ -305,7 +307,7 @@ List flowCaseDefault = caseDefault.getFlowNodeList().getList(); assertEquals("Case Default must have 2 nodes and have "+flowCaseDefault.size(), 2, flowCaseDefault.size()); - } + }*/ public static Test suite() { return new TestSuite(XMLDigesterConfigurationReaderTest.class); Modified: trunk/modules/tubo-core/src/test/java/org/tubo/resource/baseimpl/BaseManagerImplTest.java =================================================================== --- trunk/modules/tubo-core/src/test/java/org/tubo/resource/baseimpl/BaseManagerImplTest.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/java/org/tubo/resource/baseimpl/BaseManagerImplTest.java 2010-03-17 11:32:16 UTC (rev 120) @@ -24,7 +24,10 @@ //log import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +//tubo import org.tubo.resource.Resource; +import org.tubo.resource.BaseManagerImpl; +import org.tubo.resource.ManagerStrategy; import org.tubo.exception.TuboResourceException; //junit import junit.framework.TestCase; @@ -33,7 +36,7 @@ * Created: Aug 14, 2006, 1:36:13 AM * Last Modification Date: $Date$ * - * @author jvlio (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public class BaseManagerImplTest extends TestCase { Modified: trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/SpringResourceManagerImplTest.java =================================================================== --- trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/SpringResourceManagerImplTest.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/SpringResourceManagerImplTest.java 2010-03-17 11:32:16 UTC (rev 120) @@ -28,6 +28,7 @@ import org.tubo.configuration.def.baseimpl.BaseConfigurationImpl; import org.tubo.configuration.def.baseimpl.BaseComponentDefImpl; import org.tubo.resource.Manager; +import org.tubo.resource.SpringResourceManagerImpl; //spring import org.springframework.core.io.ByteArrayResource; import org.springframework.beans.factory.xml.XmlBeanFactory; @@ -99,25 +100,25 @@ config.add(componentDef); // // create SpringResourceManagerImpl - SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); + SpringResourceManagerImpl rm = SpringResourceManagerImpl.newInstance(config); // // create spring context - String springContext = rm.createSpringContext(config); + //TODO:String springContext = rm.createSpringContext(config); // // create bean factory - ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); - BeanFactory beanFactory = new XmlBeanFactory(byteResource); + //TODO:ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); + //TODO:BeanFactory beanFactory = new XmlBeanFactory(byteResource); // // get testComponent bean - Object aBean = beanFactory.getBean("testComponent"); + //TODO:Object aBean = beanFactory.getBean("testComponent"); // // check instance - assertTrue("Bean created is not an TestComponent instance",(aBean instanceof TestComponent)); - org.tubo.resource.springimpl.TestComponent testComponent = (TestComponent)aBean; + //TODO:assertTrue("Bean created is not an TestComponent instance",(aBean instanceof TestComponent)); + //TODO:org.tubo.resource.springimpl.TestComponent testComponent = (TestComponent)aBean; // // test values - assertEquals("TestComponent.field01 is not the correct value",testComponent.getField01(),"test_string_field"); - assertEquals("TestComponent.field02 is not the correct value",testComponent.getField02(),13); + //TODO:assertEquals("TestComponent.field01 is not the correct value",testComponent.getField01(),"test_string_field"); + //TODO:assertEquals("TestComponent.field02 is not the correct value",testComponent.getField02(),13); } public void testCreateComponentDefIrrestrictedSpringContext() throws Exception { @@ -139,24 +140,24 @@ config.add(componentDef); // // create SpringResourceManagerImpl - SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); + //TODO:SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); // // create spring context - String springContext = rm.createSpringContext(config); + //TODO:String springContext = rm.createSpringContext(config); // // create bean factory - ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); - BeanFactory beanFactory = new XmlBeanFactory(byteResource); + //TODO:ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); + //TODO:BeanFactory beanFactory = new XmlBeanFactory(byteResource); // // get Resource Manager - Manager manager = (Manager)beanFactory.getBean("testComponentManager"); + //TODO:Manager manager = (Manager)beanFactory.getBean("testComponentManager"); // // get testComponent bean - Object aBean1 = manager.get(); - Object aBean2 = manager.get(); + //TODO:Object aBean1 = manager.get(); + //TODO:Object aBean2 = manager.get(); // // - assertNotSame("Beans instances are the same in irrestricted mode",aBean1,aBean2); + //TODO:assertNotSame("Beans instances are the same in irrestricted mode",aBean1,aBean2); } public void testCreateComponentDefSingletonSpringContext() throws Exception { @@ -178,24 +179,24 @@ config.add(componentDef); // // create SpringResourceManagerImpl - SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); + //TODO:SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); // // create spring context - String springContext = rm.createSpringContext(config); + //TODO:String springContext = rm.createSpringContext(config); // // create bean factory - ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); - BeanFactory beanFactory = new XmlBeanFactory(byteResource); + //TODO:ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); + //TODO:BeanFactory beanFactory = new XmlBeanFactory(byteResource); // // get Resource Manager - Manager manager = (Manager)beanFactory.getBean("testComponentManager"); + //TODO:Manager manager = (Manager)beanFactory.getBean("testComponentManager"); // // get testComponent bean - Object aBean1 = manager.get(); - Object aBean2 = manager.get(); + //TODO:Object aBean1 = manager.get(); + //TODO:Object aBean2 = manager.get(); // // - assertSame("Beans instances not are the same in singleton mode",aBean1,aBean2); + //TODO:assertSame("Beans instances not are the same in singleton mode",aBean1,aBean2); } @@ -219,24 +220,24 @@ config.add(componentDef); // // create SpringResourceManagerImpl - SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); + //TODO:SpringResourceManagerImpl rm = new SpringResourceManagerImpl(); // // create spring context - String springContext = rm.createSpringContext(config); + //TODO:String springContext = rm.createSpringContext(config); // // create bean factory - ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); - BeanFactory beanFactory = new XmlBeanFactory(byteResource); + //TODO:ByteArrayResource byteResource = new ByteArrayResource(springContext.getBytes()); + //TODO:BeanFactory beanFactory = new XmlBeanFactory(byteResource); // // get Resource Manager - Manager manager = (Manager)beanFactory.getBean("testComponentManager"); + //TODO:Manager manager = (Manager)beanFactory.getBean("testComponentManager"); // // get testComponent bean - Object aBean1 = manager.get(); - Object aBean2 = manager.get(); - Object aBean3 = manager.get(); - assertNotSame("Beans instances are the same in pooled mode",aBean1,aBean2); - assertNotSame("Beans instances are the same in pooled mode",aBean1,aBean3); - assertNotSame("Beans instances are the same in pooled mode",aBean2,aBean3); + //TODO:Object aBean1 = manager.get(); + //TODO:Object aBean2 = manager.get(); + //TODO:Object aBean3 = manager.get(); + //TODO:assertNotSame("Beans instances are the same in pooled mode",aBean1,aBean2); + //TODO:assertNotSame("Beans instances are the same in pooled mode",aBean1,aBean3); + //TODO:assertNotSame("Beans instances are the same in pooled mode",aBean2,aBean3); } } \ No newline at end of file Modified: trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/TestComponent.java =================================================================== --- trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/TestComponent.java 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/java/org/tubo/resource/springimpl/TestComponent.java 2010-03-17 11:32:16 UTC (rev 120) @@ -29,9 +29,10 @@ import org.tubo.exception.TuboException; /** - * Created: Dec 12, 2005 12:43:18 PM Last Modification Date: $Date$ + * Created: Dec 12, 2005 12:43:18 PM + * Last Modification Date: $Date$ * - * @author jvlio (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public class TestComponent implements Component { Modified: trunk/modules/tubo-core/src/test/resources/log4j.xml =================================================================== --- trunk/modules/tubo-core/src/test/resources/log4j.xml 2009-05-08 04:59:49 UTC (rev 119) +++ trunk/modules/tubo-core/src/test/resources/log4j.xml 2010-03-17 11:32:16 UTC (rev 120) @@ -16,6 +16,11 @@ <appender-ref ref="stdout"/> </logger> + <logger name="org.jencks"> + <level value="info"/> + <appender-ref ref="stdout"/> + </logger> + <root> <level value="debug"/> <appender-ref ref="stdout"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-08 04:59:56
|
Revision: 119 http://tubo.svn.sourceforge.net/tubo/?rev=119&view=rev Author: maldito_orco Date: 2009-05-08 04:59:49 +0000 (Fri, 08 May 2009) Log Message: ----------- Add consumer without flow check Modified Paths: -------------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowExecutorImpl.java Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowExecutorImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowExecutorImpl.java 2009-05-07 05:40:06 UTC (rev 118) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowExecutorImpl.java 2009-05-08 04:59:49 UTC (rev 119) @@ -83,15 +83,22 @@ // get flow id String flowId = mapConsumerIdToFlow(consumerId); // - // get flow def - FlowDef flowDef = resourceManager.getConfiguration().getFlowDef(flowId); - // - // create flow processor - // TODO: this object must be pooled (with the sum of all consumers) - FlowProcessor flowProcessor = new BaseFlowProcessorImpl(); - flowProcessor.setResourceManager(getResourceManager()); - flowProcessor.execute(flowDef, flowContext); - + // check if there is a flow asociated to this consumer + if (flowId != null) { + // + // get flow def + FlowDef flowDef = resourceManager.getConfiguration().getFlowDef(flowId); + // + // create flow processor + // TODO: this object must be pooled (with the sum of all consumers) + FlowProcessor flowProcessor = new BaseFlowProcessorImpl(); + flowProcessor.setResourceManager(getResourceManager()); + flowProcessor.execute(flowDef, flowContext); + } + else + // + // if there isn't a flow associated, then log a warning + log.warn(".execute() - There is a consume from '"+consumerId+"' consumer, but there isn''t a flow associated!"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:40:09
|
Revision: 118 http://tubo.svn.sourceforge.net/tubo/?rev=118&view=rev Author: maldito_orco Date: 2009-05-07 05:40:06 +0000 (Thu, 07 May 2009) Log Message: ----------- Estable Version non integrated Modified Paths: -------------- trunk/modules/tubo-web/pom.xml trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java Added Paths: ----------- trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java Modified: trunk/modules/tubo-web/pom.xml =================================================================== --- trunk/modules/tubo-web/pom.xml 2009-05-07 05:34:00 UTC (rev 117) +++ trunk/modules/tubo-web/pom.xml 2009-05-07 05:40:06 UTC (rev 118) @@ -64,9 +64,30 @@ <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> - <version>2.4</version> + <version>${javax-servlet-version}</version> <type>jar</type> - <scope>compile</scope> + <scope>provided</scope> </dependency> + <!-- restlet - see http://www.restlet.org/downloads/maven --> + <dependency> + <groupId>org.restlet</groupId> + <artifactId>org.restlet</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet.ext.simple</artifactId> + <version>${restlet-version}</version> + </dependency> + <dependency> + <groupId>com.noelios.restlet</groupId> + <artifactId>com.noelios.restlet.ext.servlet</artifactId> + <version>${restlet-version}</version> + </dependency> </dependencies> </project> Modified: trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java 2009-05-07 05:34:00 UTC (rev 117) +++ trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboContextListener.java 2009-05-07 05:40:06 UTC (rev 118) @@ -73,6 +73,10 @@ log.fatal("Kernel can't boot",e); throw e; } + // + // store kernel instance in servlet context + servletContextEvent.getServletContext().setAttribute("TUBO_KERNEL",kernel); + // log.info(".contextInitialized() - Contexto Inicializado "); } Added: trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java =================================================================== --- trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java (rev 0) +++ trunk/modules/tubo-web/src/main/java/org/tubo/system/web/TuboServletAdapter.java 2009-05-07 05:40:06 UTC (rev 118) @@ -0,0 +1,77 @@ +/** + * $ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.system.web; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//restlet +import org.restlet.Restlet; +import org.restlet.Router; +import org.restlet.data.Request; +import org.restlet.data.Response; +import org.restlet.data.MediaType; +import org.tubo.web.restlet.TuboRestletServlet; +import org.tubo.kernel.Kernel; +import org.tubo.resource.consumer.ConsumerManager; +import com.noelios.restlet.ext.servlet.ServletConverter; +//servlet +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; +import javax.servlet.ServletConfig; +//io +import java.io.IOException; + +/** + * <p></p> + * <p> + * Created: Mar 17, 2009, 12:14:42 AM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class TuboServletAdapter extends HttpServlet { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(TuboServletAdapter.class); + + protected String consumerId; + + public void init(ServletConfig servletConfig) throws ServletException { + super.init(servletConfig); //To change body of overridden methods use File | Settings | File Templates. + log.debug(".init() - start"); + consumerId = servletConfig.getInitParameter("consumerId"); + log.info(".init() - consumerId="+consumerId); + + Kernel kernel = (Kernel) servletConfig.getServletContext().getAttribute("TUBO_KERNEL"); + + ConsumerManager consumerManager = kernel.getResourceManager().getConsumerManager(consumerId); + log.info("manager="+consumerManager); + + } + + protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + log.debug(".service() - start"); + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:34:07
|
Revision: 117 http://tubo.svn.sourceforge.net/tubo/?rev=117&view=rev Author: maldito_orco Date: 2009-05-07 05:34:00 +0000 (Thu, 07 May 2009) Log Message: ----------- Deleting Removed Paths: ------------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/flow/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:28:47
|
Revision: 116 http://tubo.svn.sourceforge.net/tubo/?rev=116&view=rev Author: maldito_orco Date: 2009-05-07 05:28:46 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content on resource Base Modified Paths: -------------- trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-component-template.vm trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-consumer-template.vm trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-default-template.vm trunk/modules/tubo-core/src/main/resources/META-INF/templates/exception-manager-template.vm Modified: trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml 2009-05-07 05:20:22 UTC (rev 115) +++ trunk/modules/tubo-core/src/main/resources/META-INF/config/base-tubo-config.xml 2009-05-07 05:28:46 UTC (rev 116) @@ -1,5 +1,5 @@ <tubo-configuration> - <kernel-builder-class>org.tubo.kernel.springimpl.SpringKernelBuilderImpl</kernel-builder-class> + <kernel-builder-class>org.tubo.kernel.SpringKernelBuilderImpl</kernel-builder-class> <kernel-builder-properties/> <includes> Modified: trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-component-template.vm =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-component-template.vm 2009-05-07 05:20:22 UTC (rev 115) +++ trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-component-template.vm 2009-05-07 05:28:46 UTC (rev 116) @@ -62,13 +62,13 @@ ## ##-- Write manager strategy def #if ($def.Type != "pooled") - <bean id="$beanManagerStrategyId" class="org.tubo.resource.springimpl.SpringDefaultManagerStrategyImpl" singleton="true"> + <bean id="$beanManagerStrategyId" class="org.tubo.resource.SpringDefaultManagerStrategyImpl" singleton="true"> <property name="id"> <value>$beanId</value> </property> </bean> #else - <bean id="$beanManagerStrategyId" class="org.tubo.resource.springimpl.SpringPooledManagerStrategyImpl" singleton="true"> + <bean id="$beanManagerStrategyId" class="org.tubo.resource.SpringPooledManagerStrategyImpl" singleton="true"> <property name="id"> <value>$beanId</value> </property> Modified: trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-consumer-template.vm =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-consumer-template.vm 2009-05-07 05:20:22 UTC (rev 115) +++ trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-consumer-template.vm 2009-05-07 05:28:46 UTC (rev 116) @@ -73,13 +73,13 @@ ## ##-- Write manager strategy def #if ($def.Type != "pooled") - <bean id="$beanManagerStrategyId" class="org.tubo.resource.springimpl.SpringDefaultManagerStrategyImpl" singleton="true"> + <bean id="$beanManagerStrategyId" class="org.tubo.resource.SpringDefaultManagerStrategyImpl" singleton="true"> <property name="id"> <value>$beanId</value> </property> </bean> #else - <bean id="$beanManagerStrategyId" class="org.tubo.resource.springimpl.SpringPooledManagerStrategyImpl" singleton="true"> + <bean id="$beanManagerStrategyId" class="org.tubo.resource.SpringPooledManagerStrategyImpl" singleton="true"> <property name="id"> <value>$beanId</value> </property> Modified: trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-default-template.vm =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-default-template.vm 2009-05-07 05:20:22 UTC (rev 115) +++ trunk/modules/tubo-core/src/main/resources/META-INF/templates/bean-default-template.vm 2009-05-07 05:28:46 UTC (rev 116) @@ -45,7 +45,7 @@ ## ##-- Write ResourceManager defs <bean id="resourceManager" - class="org.tubo.resource.springimpl.SpringResourceManagerImpl" + class="org.tubo.resource.SpringResourceManagerImpl" singleton="true"/> ## Modified: trunk/modules/tubo-core/src/main/resources/META-INF/templates/exception-manager-template.vm =================================================================== --- trunk/modules/tubo-core/src/main/resources/META-INF/templates/exception-manager-template.vm 2009-05-07 05:20:22 UTC (rev 115) +++ trunk/modules/tubo-core/src/main/resources/META-INF/templates/exception-manager-template.vm 2009-05-07 05:28:46 UTC (rev 116) @@ -33,7 +33,7 @@ *# ## ##-- Write bean def - <bean id="exceptionManager" class="org.tubo.exception.springimpl.SpringExceptiomManagerImpl" singleton="true"> + <bean id="exceptionManager" class="org.tubo.exception.SpringExceptiomManagerImpl" singleton="true"> <property name="resourceManager"> <ref local="resourceManager"/> </property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:20:28
|
Revision: 115 http://tubo.svn.sourceforge.net/tubo/?rev=115&view=rev Author: maldito_orco Date: 2009-05-07 05:20:22 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content on resource Base Modified Paths: -------------- trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java Modified: trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -31,7 +31,7 @@ import org.tubo.kernel.Kernel; import org.tubo.exception.TuboKernelException; import org.tubo.exception.TuboException; -import org.tubo.resource.springimpl.SpringResourceManagerImpl; +import org.tubo.resource.SpringResourceManagerImpl; /** Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -26,7 +26,7 @@ import org.apache.commons.logging.LogFactory; //tubo import org.tubo.resource.flow.FlowContext; -import org.tubo.resource.baseimpl.BaseResourceImpl; +import org.tubo.resource.BaseResourceImpl; import org.tubo.exception.TuboException; /** Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentManagerImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentManagerImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -25,7 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //tubo -import org.tubo.resource.baseimpl.BaseManagerImpl; +import org.tubo.resource.BaseManagerImpl; import org.tubo.resource.Resource; import org.tubo.exception.TuboException; Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; //tubo import org.tubo.resource.Resource; -import org.tubo.resource.baseimpl.BaseManagerImpl; +import org.tubo.resource.BaseManagerImpl; /** * <p></p> Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -26,7 +26,7 @@ import org.apache.commons.logging.LogFactory; //item import org.tubo.item.Item; -import org.tubo.resource.baseimpl.BaseResourceImpl; +import org.tubo.resource.BaseResourceImpl; import org.tubo.resource.flow.FlowContext; import org.tubo.event.Event; Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java 2009-05-07 05:12:48 UTC (rev 114) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java 2009-05-07 05:20:22 UTC (rev 115) @@ -25,7 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //tubo -import org.tubo.resource.baseimpl.BaseManagerImpl; +import org.tubo.resource.BaseManagerImpl; import org.tubo.resource.Resource; import org.tubo.exception.TuboException; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:12:50
|
Revision: 114 http://tubo.svn.sourceforge.net/tubo/?rev=114&view=rev Author: maldito_orco Date: 2009-05-07 05:12:48 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Removed Paths: ------------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/ trunk/modules/tubo-core/src/main/java/org/tubo/resource/springimpl/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:10:51
|
Revision: 113 http://tubo.svn.sourceforge.net/tubo/?rev=113&view=rev Author: maldito_orco Date: 2009-05-07 05:10:50 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/ManagerStrategy.java Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/ManagerStrategy.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/ManagerStrategy.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/ManagerStrategy.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/ManagerStrategy.java 2009-05-07 05:10:50 UTC (rev 113) @@ -0,0 +1,39 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +import org.tubo.exception.TuboResourceException; +import org.tubo.resource.Resource; + +/** + * + * Created: Jan 25, 2006 5:58:17 PM + * Last Modification Date: $Date$ + * + * @author jvlio (jv...@us...) + * @version $Revision$ + */ +public interface ManagerStrategy { + + Resource get() throws TuboResourceException; + void restore(Resource resource) throws TuboResourceException; +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/ManagerStrategy.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:09:40
|
Revision: 112 http://tubo.svn.sourceforge.net/tubo/?rev=112&view=rev Author: maldito_orco Date: 2009-05-07 05:09:34 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringDefaultManagerStrategyImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringPooledManagerStrategyImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringDefaultManagerStrategyImpl.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/resource/springimpl/SpringDefaultManagerStrategyImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringDefaultManagerStrategyImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringDefaultManagerStrategyImpl.java 2009-05-07 05:09:34 UTC (rev 112) @@ -0,0 +1,71 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.ManagerStrategy; +import org.tubo.resource.BaseAbstractManagerStrategyImpl; +import org.tubo.resource.Resource; +import org.tubo.exception.TuboResourceException; +//spring +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; + +/** + * Created: Jun 28, 2006, 6:23:34 AM + * Last Modification Date: $Date$ + * + * @author jvlio (jv...@us...) + * @version $Revision$ + */ +public class SpringDefaultManagerStrategyImpl extends BaseAbstractManagerStrategyImpl implements ManagerStrategy, BeanFactoryAware { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(SpringDefaultManagerStrategyImpl.class); + + /** + * Spring bean factory + */ + private BeanFactory beanFactory = null; + + public BeanFactory getBeanFactory() { + return beanFactory; + } + + public void setBeanFactory(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + /** + * Get a Resource from Spring Bean Factory + * @return a Resource + * @throws TuboResourceException + */ + public Resource get() throws TuboResourceException { + return (Resource)beanFactory.getBean(id); + } + + public void restore(Resource resource) throws TuboResourceException { + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringDefaultManagerStrategyImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringPooledManagerStrategyImpl.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/resource/springimpl/SpringPooledManagerStrategyImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringPooledManagerStrategyImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringPooledManagerStrategyImpl.java 2009-05-07 05:09:34 UTC (rev 112) @@ -0,0 +1,139 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//commons-pool +import org.apache.commons.pool.impl.GenericObjectPool; +import org.apache.commons.pool.BasePoolableObjectFactory; +import org.apache.commons.pool.PoolableObjectFactory; +import org.apache.commons.pool.ObjectPool; +//tubo +import org.tubo.resource.BaseAbstractManagerStrategyImpl; +import org.tubo.resource.ManagerStrategy; +import org.tubo.resource.Resource; +import org.tubo.exception.TuboResourceException; +//spring +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.BeanFactory; + +/** + * Created: Jun 28, 2006, 6:23:34 AM + * Last Modification Date: $Date$ + * + * @author jvlio (jv...@us...) + * @version $Revision$ + */ +public class SpringPooledManagerStrategyImpl extends BaseAbstractManagerStrategyImpl implements ManagerStrategy, BeanFactoryAware { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(SpringPooledManagerStrategyImpl.class); + + /** + * Spring bean factory + */ + private BeanFactory beanFactory = null; + + /** + * Component Pool + */ + private ObjectPool pool = null; + private Object poolMutex = new Object(); + + /** + * Pool max capcacity + */ + private int maxCapacity = 0; + + + + public BeanFactory getBeanFactory() { + return beanFactory; + } + + public void setBeanFactory(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + private ObjectPool getPool() { + if (pool==null) + synchronized(poolMutex) { + if (pool==null) { + // + // create a PoolableObjectFactory based on a ComponentFactory + PoolableObjectFactory pooleableFactory = new BasePoolableObjectFactory() { + public Object makeObject() throws Exception { + return beanFactory.getBean(id); + } + }; + // + // create a ObjectPool with PoolableObjectFactory created before + pool = new GenericObjectPool(pooleableFactory, + maxCapacity, + GenericObjectPool.WHEN_EXHAUSTED_BLOCK, + /*block indefinitely*/-1); + } + } + return pool; + } + + public int getMaxCapacity() { + return maxCapacity; + } + + public void setMaxCapacity(int maxCapacity) { + this.maxCapacity = maxCapacity; + } + + /** + * Get a Resource from pool + * @return a Resource + * @throws org.tubo.exception.TuboResourceException + */ + public Resource get() throws TuboResourceException { + Resource resource = null; + try { + resource = (Resource)getPool().borrowObject(); + } catch (Exception e) { + log.fatal(".get() - Error getting resource.",e); + TuboResourceException ex = new TuboResourceException("Error getting resource",e); + throw ex; + } + return resource; + } + + /** + * Restore resource to pool + * @param resource + * @throws TuboResourceException + */ + public void restore(Resource resource) throws TuboResourceException { + try { + getPool().returnObject(resource); + } catch (Exception e) { + log.fatal(".restore() - Error returning resource.",e); + TuboResourceException ex = new TuboResourceException("Error returning resource",e); + throw ex; + } + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringPooledManagerStrategyImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java (from rev 104, trunk/modules/tubo-core/src/main/java/org/tubo/resource/springimpl/SpringResourceManagerImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java 2009-05-07 05:09:34 UTC (rev 112) @@ -0,0 +1,571 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//velocity +import org.apache.velocity.VelocityContext; +import org.apache.velocity.Template; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.app.Velocity; +//spring +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.xml.XmlBeanFactory; +import org.springframework.beans.BeansException; +import org.springframework.core.io.ByteArrayResource; +//tubo +import org.tubo.configuration.def.*; +import org.tubo.resource.Manager; +import org.tubo.resource.BaseAbstractResourceManager; +import org.tubo.resource.flow.FlowExecutor; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboResourceException; +import org.tubo.exception.ExceptionManager; +import org.tubo.exception.TuboException; +import org.tubo.item.Item; +import org.tubo.event.Event; +import org.tubo.kernel.Kernel; +//java-util +import java.util.Map; +import java.util.Iterator; +import java.util.Properties; +import java.util.HashMap; +//java-io +import java.io.StringWriter; + +/** + * + * Created: Dec 1, 2005 6:02:44 AM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class SpringResourceManagerImpl extends BaseAbstractResourceManager implements BeanFactoryAware { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(SpringResourceManagerImpl.class); + + /** Template file for beans based on exceptions */ + public final static String BEAN_EXCEPTION_MANAGER_TEMPLATE = "META-INF/templates/exception-manager-template.vm"; + + /** Template file for beans based on exceptions */ + public final static String BEAN_EXCEPTION_TEMPLATE = "META-INF/templates/exception-template.vm"; + + /** Template file for beans based on consumers */ + public final static String BEAN_CONSUMER_TEMPLATE = "META-INF/templates/bean-consumer-template.vm"; + + /** Template file for beans based on components */ + public final static String BEAN_COMPONENT_TEMPLATE = "META-INF/templates/bean-component-template.vm"; + + /** Template file for beans based on flows */ + public final static String BEAN_DEFAULT_TEMPLATE = "META-INF/templates/bean-default-template.vm"; + + /** Template file for beans based on flows */ + public final static String BEAN_FLOW_TEMPLATE = "META-INF/templates/bean-flow-template.vm"; + + /** Header for every spring xml context file */ + public static final String SPRING_CONTEXT_HEADFILE = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">"; + + /** Kernel bean ID */ + public static final String SPRING_KERNEL_BEAN_ID = "kernel"; + + /** ResourceManager bean ID */ + public static final String SPRING_RESOURCE_MANAGER_BEAN_ID = "resourceManager"; + + /** Item bean ID */ + public static final String SPRING_ITEM_BEAN_ID = "item"; + + /** Event bean ID */ + public static final String SPRING_EVENT_BEAN_ID = "event"; + + /** FlowContext bean ID */ + public static final String SPRING_FLOW_CONTEXT_BEAN_ID = "flowContext"; + + /** ExceptionManager bean ID */ + public static final String SPRING_EXCEPTION_MANAGER_BEAN_ID = "exceptionManager"; + + /** FlowExecutor bean ID */ + public static final String SPRING_FLOW_EXECUTOR_BEAN_ID = "flowExecutor"; + + /** Spring bean factory */ + private BeanFactory beanFactory; + + + /** + * Default constructor protected. Used by test cases. + * Don't change. USED ONLY BY TEST CASES! + * @throws TuboResourceException + */ + protected SpringResourceManagerImpl() throws TuboException { + } + + public BeanFactory getBeanFactory() { + return beanFactory; + } + + public void setBeanFactory(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + + /** + * <p> + * Get kernel instance + * </p> + * @return kernel instance + * @throws TuboException + */ + public Kernel getKernel() throws TuboException { + Kernel kernel = null; + try { + // + // get Item via Spring + kernel = (Kernel)beanFactory.getBean(SPRING_KERNEL_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get a KERNEL", e); + // + // throw + throw new TuboResourceException("Error trying to get a Kernel",e); + } + // + // return + return kernel; + } + + + /** + * <p> + * Create a new Item instance + * </p> + * @return new Item instance + * @throws TuboException + */ + public Item getNewItem() throws TuboException { + Item item = null; + try { + // + // get Item via Spring + item = (Item)beanFactory.getBean(SPRING_ITEM_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get an Item", e); + // + // throw + throw new TuboResourceException("Error trying to get an Item",e); + } + // + // return + return item; + } + + /** + * <p> + * Create a new Item instance + * </p> + * @return new Item instance + * @throws TuboException + */ + public Event getNewEvent() throws TuboException { + Event event = null; + try { + // + // get Event via Spring + event = (Event)beanFactory.getBean(SPRING_EVENT_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get an Event", e); + // + // throw + throw new TuboResourceException("Error trying to get an Event",e); + } + // + // return + return event; + } + + /** + * <p> + * Create a new FlowContext instance + * </p> + * @return new FlowContext instance + * @throws TuboException + */ + public FlowContext getNewFlowContext() throws TuboException { + FlowContext flowContext = null; + try { + // + // get FlowContext via Spring + flowContext = (FlowContext)beanFactory.getBean(SPRING_FLOW_CONTEXT_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get a FlowContext", e); + // + // throw + throw new TuboResourceException("Error trying to get a FlowContext",e); + } + // + // return + return flowContext; + } + + public ExceptionManager getExceptionManager() throws TuboException { + ExceptionManager manager = null; + try { + // + // get ExceptionManager via Spring + manager = (ExceptionManager)beanFactory.getBean(SPRING_EXCEPTION_MANAGER_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get ExceptionManager", e); + // + // throw + throw new TuboResourceException("Error trying to get ExceptionManager '"+SPRING_EXCEPTION_MANAGER_BEAN_ID+"'",e); + } + // + // check if manager==null (I need to be sure of this ... this method can'tt return null!) + if (manager == null) { + // + // log error + log.error("Error when returning ExceptionManager, return null"); + // + // throw + throw new TuboResourceException("Error when returning ExceptionManager, return null"); + } + // + // return + return manager; + } + + public FlowExecutor getFlowExecutor() throws TuboException { + FlowExecutor manager = null; + try { + // + // get FlowExecutor via Spring + manager = (FlowExecutor)beanFactory.getBean(SPRING_FLOW_EXECUTOR_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get FlowExecutor", e); + // + // throw + throw getExceptionManager().getException(1302,SPRING_FLOW_EXECUTOR_BEAN_ID,e); + } + return manager; + } + + /** + * get a bean manager from spring + * @param id + * @return + */ + public Manager getManager(String id) throws TuboException { + // + // reconfig id to adapt to all Managers + id = id+"Manager"; + // + // get manager + Manager manager = null; + try { + // + // get manager via Spring + manager = (Manager)beanFactory.getBean(id); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get Manager identified by '"+id+"'", e); + // + // throw + throw getExceptionManager().getException(1303,id,e); + } + // + // return + return manager; + } + + + + + public static SpringResourceManagerImpl newInstance(Configuration config) { + // + // trace + if (log.isTraceEnabled()) log.trace(".newInstance() - Enter"); + // + // initialize velocity + initVelocity(); + // + // create Spring resource descriptor based on configuration + String stringResource = null; + try { + stringResource = createSpringContext(config); + } catch (TuboResourceException e) { + throw new TuboResourceException("Tubo configuration can't be created",e); + } + // + // create Bean Factory + ByteArrayResource byteResource = new ByteArrayResource(stringResource.getBytes()); + BeanFactory beanFactory = new XmlBeanFactory(byteResource); + // + // get resource manager + SpringResourceManagerImpl rm = null; + try { + // + // get FlowExecutor via Spring + rm = (SpringResourceManagerImpl)beanFactory.getBean(SPRING_RESOURCE_MANAGER_BEAN_ID); + } catch (BeansException e) { + // + // log error + log.error("Error trying to get ResourceManager", e); + // + // throw + throw new TuboResourceException("Error trying to get Spring ResourceManager",e); + } + // + // set configuration + // TODO: can be inyected? + rm.setConfiguration(config); + // + // trace + if (log.isTraceEnabled()) log.trace(".newInstance() - Leave"); + // + // return resource manager + return rm; + } + + + + + /** + * + */ + private static void initVelocity() throws TuboResourceException { + // + // setup velocity + //Velocity.init("velocity.properties"); TODO: ver de poder cargar estas propiedades desde un file + Properties p = new Properties(); + p.setProperty("resource.loader", "class"); + p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + try { + Velocity.init(p); + } catch (Exception e) { + throw new TuboResourceException("Velocity can't be initialized",e); + } + } + + /** + * Create a Spring Context (Spring configuration) based on Configuration object. + * @param config Configuration + * @return A String with Spring representation of Configuration object. + */ + protected static String createSpringContext(Configuration config) throws TuboResourceException { + // + // create StringBuffer + StringBuffer buffer = new StringBuffer(); + // + // add string context head file + buffer.append(SPRING_CONTEXT_HEADFILE); + // + // open tag beans + buffer.append("<beans>"); + // + // === Default configuration + // + // create ExceptionManager spring definition + appendSpringDefaultConfiguration(buffer,config); + // + // === Exception Contexts + // + // create ExceptionManager spring definition + appendSpringExceptionManagerDefinition(buffer); + // + // === Flow Contexts + // + // create Flows spring definitions + appendSpringFlowDefinition(buffer,config); + // + // get consumer defs + Map exceptionMap = config.getExceptionDefs(); + // + // iterate exception Defs and append definitions to spring context + for (Iterator it=exceptionMap.values().iterator(); it.hasNext();) { + ExceptionDef def = (ExceptionDef)it.next(); + // + // create Exception spring definition + buffer = appendSpringDefinition(buffer,def,config); + } + // + // === Consumer Contexts + // + // get consumer defs + Map consumersMap = config.getConsumerDefs(); + // + // iterate consumer Defs and append definitions to spring context + for (Iterator it=consumersMap.values().iterator(); it.hasNext();) { + ConsumerDef def = (ConsumerDef)it.next(); + // + // create spring definition + buffer = appendSpringDefinition(buffer,def,config); + } + // + // === Component Contexts + // + // get component Defs + Map componentsMap = config.getComponentDefs(); + // + // iterate component Defs and append definitions to spring context + for (Iterator it=componentsMap.values().iterator(); it.hasNext();) { + ComponentDef def = (ComponentDef)it.next(); + // + // create spring definition + buffer = appendSpringDefinition(buffer,def,config); + } + // + // close tag beans + buffer.append("</beans>"); + // + // return Spring Resource + return buffer.toString(); + } + + protected static StringBuffer appendSpringDefaultConfiguration(StringBuffer buffer, Configuration config) throws TuboResourceException { + // + // create Velocity props + Map props = new HashMap(); + props.put("config",config); + // + // create spring definition (using Velocity) + buffer = appendSpringDefinition(buffer,null,BEAN_DEFAULT_TEMPLATE,props); + return buffer; + } + + protected static StringBuffer appendSpringFlowDefinition(StringBuffer buffer, Configuration config) throws TuboResourceException { + // + // create Velocity props + Map props = new HashMap(); + props.put("config",config); + // + // create spring definition (using Velocity) + buffer = appendSpringDefinition(buffer,null,BEAN_FLOW_TEMPLATE,props); + return buffer; + } + + protected static StringBuffer appendSpringExceptionManagerDefinition(StringBuffer buffer) throws TuboResourceException { + // + // create Velocity props + Map props = new HashMap(); + props.put("id",BEAN_EXCEPTION_MANAGER_TEMPLATE); + // + // create spring definition (using Velocity) + buffer = appendSpringDefinition(buffer,null,BEAN_EXCEPTION_MANAGER_TEMPLATE,props); + return buffer; + } + + protected static StringBuffer appendSpringDefinition(StringBuffer buffer, Definition def, Configuration config) throws TuboResourceException { + // + // create Velocity props + Map props = new HashMap(); + props.put("config",config); + + + if (def instanceof ExceptionDef) { + buffer = appendSpringDefinition(buffer,def,BEAN_EXCEPTION_TEMPLATE,props); + return buffer; + } + if (def instanceof ConsumerDef) { + buffer = appendSpringDefinition(buffer,def,BEAN_CONSUMER_TEMPLATE,props); + return buffer; + } + if (def instanceof ComponentDef) { + buffer = appendSpringDefinition(buffer,def,BEAN_COMPONENT_TEMPLATE,props); + return buffer; + } + throw new TuboResourceException("Definition type not know."); + } + + /** + * Append a Spring configuration of ComponentDef instance. + * @param buffer Spring configuration + * @param def A ComponentDef instance + * @return The same StringBuffer but with a new component (bean) definition append to end; + */ + protected static StringBuffer appendSpringDefinition(StringBuffer buffer, Definition def, String templateFile, Map props) throws TuboResourceException { + try { + // + // Make a context object and populate with the data. This + // is where the Velocity engine gets the data to resolve the + // references (ex. $list) in the template + VelocityContext context = new VelocityContext(); + context.put("def", def); + // + // add props to Velocity context + if (props!=null) + for(Iterator it=props.keySet().iterator(); it.hasNext();) { + String key = (String)it.next(); + Object value = props.get(key); + context.put(key,value); + } + // + // get the Template object. This is the parsed version of your + // template input file. Note that getTemplate() can throw + // ResourceNotFoundException : if it doesn't find the template + // ParseErrorException : if there is something wrong with the VTL + // Exception : if something else goes wrong (this is generally + // indicative of as serious problem...) + Template template = null; + try { + template = Velocity.getTemplate(templateFile); + } catch( ResourceNotFoundException rnfe ) { + throw new TuboResourceException("Velocity template "+templateFile+" can't be founded",rnfe); + } catch( ParseErrorException pee ) { + throw new TuboResourceException("Velocity parsing error procesing template "+templateFile,pee); + } + // + // Now have the template engine process your template using the + // data placed into the context. Think of it as a 'merge' + // of the template and the data to produce the output stream. + StringWriter writer = new StringWriter(); + if ( template != null) + template.merge(context, writer); + // + // flush and cleanup + writer.flush(); + writer.close(); + + buffer.append(writer.toString()); + } catch (Exception e) { + throw new TuboResourceException("Error creating spring definition",e); + } + return buffer; + } + +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/SpringResourceManagerImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 05:07:45
|
Revision: 111 http://tubo.svn.sourceforge.net/tubo/?rev=111&view=rev Author: maldito_orco Date: 2009-05-07 05:07:44 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractManagerStrategyImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractResourceManager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseResourceImpl.java Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractManagerStrategyImpl.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractManagerStrategyImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractManagerStrategyImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractManagerStrategyImpl.java 2009-05-07 05:07:44 UTC (rev 111) @@ -0,0 +1,51 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Created: Aug 14, 2006, 3:17:34 PM + * Last Modification Date: $Date$ + * + * @author jvlio (jv...@us...) + * @version $Revision$ + */ +public abstract class BaseAbstractManagerStrategyImpl implements ManagerStrategy { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseAbstractManagerStrategyImpl.class); + + /** + * Bean id + */ + protected String id = null; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractManagerStrategyImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractResourceManager.java (from rev 104, trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractResourceManager.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractResourceManager.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractResourceManager.java 2009-05-07 05:07:44 UTC (rev 111) @@ -0,0 +1,205 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.ResourceManager; +import org.tubo.resource.Manager; +import org.tubo.resource.component.ComponentManager; +import org.tubo.resource.consumer.ConsumerManager; +import org.tubo.configuration.def.Configuration; +import org.tubo.configuration.def.ConsumerDef; +import org.tubo.exception.TuboResourceException; +import org.tubo.exception.TuboException; +//util +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; +import java.util.Map; + +/** + * Created: Aug 31, 2006, 6:47:45 PM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public abstract class BaseAbstractResourceManager implements ResourceManager { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseAbstractResourceManager.class); + + /** Tubo configuration */ + private Configuration configuration = null; + + /** + * Default constructor protected. Used by test cases. + * Don't change. USED ONLY BY TEST CASES! + * @throws TuboResourceException + */ + protected BaseAbstractResourceManager() throws TuboException { + } + + /*TODO: erase + * Constructor + * @param configuration + * @throws TuboResourceException + */ + /*public BaseAbstractResourceManager(Configuration configuration) throws TuboException { + // + // call default constructor + //this(); + // + // set configuration + this.configuration = configuration; + // + // call initialize resource manager implementation + initialize(); + // + // setup + try { + setup(); + } catch (TuboException e) { + // + // log error + log.error("Error while setup ResourceManager", e); + // + // finish on error + throw e; + } + }*/ + + /*TODO: erase + * Hook method for inizialise Resource. + * @throws TuboResourceException + */ + /*protected abstract void initialize() throws TuboException;*/ + + /*TODO: erase + * Setup components + */ + /*protected void setup() throws TuboException { + // setup singleton ExceptionManager + ExceptionManager exceptionManager = getExceptionManager(); + exceptionManager.setResourceManager(this); + // + // setup FlowExecutor + FlowExecutor flowExecutor = getFlowExecutor(); + flowExecutor.setResourceManager(this); + // + // setup all ConsumerManager + List consumerManagers = getConsumerManagers(); + for(Iterator it=consumerManagers.iterator(); it.hasNext();) { + Manager manager = (Manager)it.next(); + manager.setResourceManager(this); + } + // + // TODO: miss components, connections ... + }*/ + + /** + * Get Configuration object of this resource manager + * @return Configuration + */ + public Configuration getConfiguration() throws TuboException { + return configuration; + } + + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + + /** + * Return consumer manager identified by id + * @param id ConsumerManager identificator + * @return A COnsumerManager + */ + public ConsumerManager getConsumerManager(String id) throws TuboException { + // + // get manager identified by id + Manager manager = getManager(id); + // + // define var + ConsumerManager consumerManager; + // + // check instanceof + if (manager instanceof ConsumerManager) { + // + // cast manager to Consumermanager + consumerManager = (ConsumerManager)manager; + } + else + throw getExceptionManager().getException(1300,id); + // + // return ConsumerManager + return consumerManager; + } + + public List getConsumerManagers() throws TuboException { + // + // create return value + List managers = new ArrayList(); + // + // get consumer definitions + Map defs = configuration.getConsumerDefs(); + // + // iterate over all consumer definitions, extract id and get Manager for th + for (Iterator it=defs.values().iterator(); it.hasNext();) { + ConsumerDef def = (ConsumerDef)it.next(); + ConsumerManager manager = getConsumerManager(def.getId()); + managers.add(manager); + } + // + // return managers + return managers; + } + + /** + * This method returns a ComponentManager identified by id + * @param id ConsumerManager identifier + * @return a ConsumerManager instance + */ + public ComponentManager getComponentManager(String id) throws TuboException { + // + // get Manager identified by id + Manager manager = getManager(id); + // + // define var + ComponentManager componentManager; + // + // check instanceof + if (manager instanceof ComponentManager) { + // + // cast manager to ComponentManager + componentManager = (ComponentManager)manager; + } + else + throw getExceptionManager().getException(1301,id); + // + // return ComponentManager + return componentManager; + } + +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseAbstractResourceManager.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseManagerImpl.java (from rev 104, trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseManagerImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseManagerImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseManagerImpl.java 2009-05-07 05:07:44 UTC (rev 111) @@ -0,0 +1,134 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.Manager; +import org.tubo.resource.Resource; +import org.tubo.resource.ResourceManager; +import org.tubo.exception.TuboResourceException; +import org.tubo.exception.TuboException; +//util +import java.util.Properties; + +/** + * Created: Apr 5, 2006 9:16:42 PM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseManagerImpl implements Manager { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseManagerImpl.class); + + /** Manager ID (in spring Bean id) */ + private String id = null; + + /** ResourceManager for this Manager */ + private ResourceManager resourceManager = null; + + /** Manager Strategy (singleton, irrestricted or pooled) */ + private ManagerStrategy strategy = null; + + /** Configuration properties */ + private Properties properties = new Properties(); + + /** + * Default Constructor + */ + public BaseManagerImpl() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Get for the ResourceManager linked to this Manager + * @return the ResourceManager for this Manager + */ + public ResourceManager getResourceManager() { + return resourceManager; + } + + /** + * Set for the ResourceManager for this Manager + * @param resourceManager the ResourceManager for this Manager + * @throws TuboException + */ + public void setResourceManager(ResourceManager resourceManager) throws TuboException { + this.resourceManager = resourceManager; + } + + public ManagerStrategy getStrategy() { + return strategy; + } + + public void setStrategy(ManagerStrategy strategy) { + this.strategy = strategy; + } + + /** + * <p> + * Resource Get.<br> + * This method is delegated to strategy. + * </p> + * @return a Resource + * @throws TuboResourceException + */ + public Resource get() throws TuboResourceException { + return strategy.get(); + } + + /** + * <p> + * Restore resource.<br> + * This method is delegated to strategy. + * </p> + * @param resource Resource to be restored by strategy. + * @throws TuboResourceException + */ + public void restore(Resource resource) throws TuboResourceException { + strategy.restore(resource); + } + + public Properties getProperties() { return properties; } + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String getProperty(String name) { + return properties.getProperty(name); + } + + public void setProperty(String name, String value) { + properties.setProperty(name,value); + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseManagerImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseResourceImpl.java (from rev 104, trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseResourceImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseResourceImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseResourceImpl.java 2009-05-07 05:07:44 UTC (rev 111) @@ -0,0 +1,92 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.Resource; +import org.tubo.resource.ResourceManager; +import org.tubo.exception.TuboException; +//util +import java.util.Properties; + +/** + * Created: Sep 3, 2006, 10:38:11 AM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseResourceImpl implements Resource { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseResourceImpl.class); + + /** Resource ID */ + private String id = null; + + /** ResourceManager reference */ + private ResourceManager resourceManager = null; + + /** Configuration properties */ + private Properties properties = new Properties(); + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Get for the ResourceManager linked to this Resource + * @return the ResourceManager for this Resource + */ + public ResourceManager getResourceManager() { + return resourceManager; + } + + /** + * Set for the ResourceManager for this Resource + * @param resourceManager the ResourceManager for this Resource + * @throws org.tubo.exception.TuboException + */ + public void setResourceManager(ResourceManager resourceManager) throws TuboException { + this.resourceManager = resourceManager; + } + + public Properties getProperties() { return properties; } + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String getProperty(String name) { + return properties.getProperty(name); + } + + public void setProperty(String name, String value) { + properties.setProperty(name,value); + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/BaseResourceImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 04:31:47
|
Revision: 110 http://tubo.svn.sourceforge.net/tubo/?rev=110&view=rev Author: maldito_orco Date: 2009-05-07 04:31:45 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java Removed Paths: ------------- trunk/modules/tubo-core/src/main/java/org/tubo/kernel/springimpl/ Copied: trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java (from rev 100, trunk/modules/tubo-core/src/main/java/org/tubo/kernel/springimpl/SpringKernelBuilderImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java 2009-05-07 04:31:45 UTC (rev 110) @@ -0,0 +1,77 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.kernel; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.configuration.ConfigurationManager; +import org.tubo.configuration.def.Configuration; +import org.tubo.kernel.KernelBuilder; +import org.tubo.kernel.Kernel; +import org.tubo.exception.TuboKernelException; +import org.tubo.exception.TuboException; +import org.tubo.resource.springimpl.SpringResourceManagerImpl; + + +/** + * Created: Dec 1, 2005 5:55:14 AM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class SpringKernelBuilderImpl implements KernelBuilder { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(SpringKernelBuilderImpl.class); + + /** + * This method create a Kernerl based on a configuration + * + * TODO: crear un BaseBuilder y solo dejar aka la creacion del ResourceManager + * @param manager creational ConfiguracionManager + * @return retorna un nuevo Kernel a partir de la configuracion de entrada + */ + public Kernel create(ConfigurationManager manager) throws TuboException { + // + // create spring resource manager + SpringResourceManagerImpl rm = null; + try { + // + // get configuration + Configuration config = manager.getConfiguration(); + // + // crate a new Resurce Manager based on Spring implementation + rm = SpringResourceManagerImpl.newInstance(config); + } catch (TuboException e) { + throw new TuboKernelException("ResourceManager can't be created",e); + } + // + // create kernel + Kernel kernel = rm.getKernel(); + // + // return kernel + return kernel; + } + +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/kernel/SpringKernelBuilderImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 04:15:14
|
Revision: 109 http://tubo.svn.sourceforge.net/tubo/?rev=109&view=rev Author: maldito_orco Date: 2009-05-07 04:15:07 +0000 (Thu, 07 May 2009) Log Message: ----------- Change directories Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/exception/BaseExceptionManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/exception/SpringExceptiomManagerImpl.java Copied: trunk/modules/tubo-core/src/main/java/org/tubo/exception/BaseExceptionManagerImpl.java (from rev 101, trunk/modules/tubo-core/src/main/java/org/tubo/exception/baseimpl/BaseExceptionManagerImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/exception/BaseExceptionManagerImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/exception/BaseExceptionManagerImpl.java 2009-05-07 04:15:07 UTC (rev 109) @@ -0,0 +1,251 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.exception; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.ResourceManager; +import org.tubo.exception.TuboException; +import org.tubo.exception.ExceptionManager; +import org.tubo.configuration.def.Configuration; +import org.tubo.configuration.def.ExceptionDef; +//util +import java.util.List; +import java.util.ArrayList; +import java.util.ResourceBundle; +import java.util.Map; +import java.util.Iterator; +import java.util.PropertyResourceBundle; +import java.text.MessageFormat; + +/** + * Created: Sep 28, 2006, 12:43:19 PM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseExceptionManagerImpl implements ExceptionManager { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseExceptionManagerImpl.class); + + private ResourceManager resourceManager = null; + private List ranks = new ArrayList(); + private ResourceBundle[] bundles = null; + + + public void setResourceManager(ResourceManager resourceManager) throws TuboException { + this.resourceManager = resourceManager; + // + // get configuration + Configuration configuration = resourceManager.getConfiguration(); + // + // get exception definitions + Map exceptionDefs = configuration.getExceptionDefs(); + // + // loop exception defs and create rank list + for (Iterator it=exceptionDefs.values().iterator(); it.hasNext();) { + // + // get def + ExceptionDef def = (ExceptionDef)it.next(); + // + // get exception ranks + List _ranks = def.getRankErrorCodesList(); + // + // loop ranks and add pair [rank,exception_id] to global rank list + for (Iterator rit=_ranks.iterator(); rit.hasNext(); ) { + // + // get rank + int[] arank = (int[])rit.next(); + // + // create Rank + Rank rank = new Rank(arank[1],arank[0],def.getId()); + // + // add rank to list + addRank(rank); + } + } + // + // get messages properties + List messageResources = configuration.getMessageResources(); + // + // create resource bundles array + bundles = new ResourceBundle[messageResources.size()]; + // + // loop message resource creating bundles + int i=0; + for (Iterator it=messageResources.iterator(); it.hasNext(); i++) { + String resource = (String)it.next(); + // + // create bundle + ResourceBundle bundle = null; + try { + // TODO: load this (and all this kind of) resource with spring (via ResourceManager) + bundle = PropertyResourceBundle.getBundle(resource); + } catch (Exception e) { + if(log.isErrorEnabled()) log.error("Error while load property file '"+resource+"'", e); + } + // + // put in array + bundles[i]=bundle; + } + } + + + /** + * Add rank to global rank list + * TODO: check ranks overlaping + * @param rank + * @throws TuboException + */ + protected void addRank(Rank rank) throws TuboException { + int i=0; + for(Iterator it=ranks.iterator(); it.hasNext(); i++) { + Rank irank = (Rank)it.next(); + if(irank.getUpperLimit()>rank.getUpperLimit()) + break; + } + ranks.add(i,rank); + } + + public TuboException getException(int errorCode) { + return getException(errorCode, null, null); + } + + public TuboException getException(int errorCode, Object arg1) { + return getException(errorCode, new Object[] {arg1}, null); + } + + public TuboException getException(int errorCode, Object arg1, Object arg2) { + return getException(errorCode, new Object[] {arg1,arg2}, null); + } + + public TuboException getException(int errorCode, Object[] args) { + return getException(errorCode, args, null); + } + + public TuboException getException(int errorCode, Throwable cause) { + return getException(errorCode, null, cause); + } + + public TuboException getException(int errorCode, Object arg1, Throwable cause) { + return getException(errorCode, new Object[] {arg1}, cause); + } + + public TuboException getException(int errorCode, Object arg1, Object arg2, Throwable cause) { + return getException(errorCode, new Object[] {arg1,arg2}, cause); + } + + public TuboException getException(int errorCode, Object[] args, Throwable cause) { + // + // get exception ID + boolean foundRank = false; + String exceptionId = null; + for(Iterator it=ranks.iterator(); it.hasNext() && !foundRank; ) { + Rank rank = (Rank)it.next(); + if(rank.getUpperLimit()>=errorCode && errorCode>=rank.getLowerLimit()) { + exceptionId = rank.getExceptionId(); + foundRank = true; + } + } + // + // get exception + TuboException exception = getException(exceptionId, (""+errorCode), args, cause); + // + // return + return exception; + } + + public TuboException getException(String exceptionId, String messageId, Object[] args, Throwable cause) { + // + // get messagefrom bundles + String message = null; + for (int i=0; i<bundles.length; i++) { + try { + message = bundles[i].getString(messageId); + break; + } catch (Exception e) { + log.error("TODO: write error message!", e); + } + } + // + // format message with bind args + if (args!=null) + message = MessageFormat.format(message,args); + // + // call hook to create exception from an id + TuboException exception = getException(exceptionId, message, cause); + // + // return + return exception; + } + + /** + * Hook method to create a new exception instance based on ID. + * This default implementation to create a TuboException + * @param exceptionId exception identifier + * @return by default returns TuboException for any exceptionId + */ + public TuboException getException(String exceptionId, String message, Throwable cause) { + return new TuboException(); + } + + protected class Rank { + private int upperLimit = -1; + private int lowerLimit = -1; + private String exceptionId = null; + + public Rank() { } + + public Rank(int upperLimit, int lowerLimit, String exceptionId) { + this.upperLimit = upperLimit; + this.lowerLimit = lowerLimit; + this.exceptionId = exceptionId; + } + + public int getUpperLimit() { + return upperLimit; + } + + public void setUpperLimit(int upperLimit) { + this.upperLimit = upperLimit; + } + + public int getLowerLimit() { + return lowerLimit; + } + + public void setLowerLimit(int lowerLimit) { + this.lowerLimit = lowerLimit; + } + + public String getExceptionId() { + return exceptionId; + } + + public void setExceptionId(String exceptionId) { + this.exceptionId = exceptionId; + } + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/exception/BaseExceptionManagerImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/modules/tubo-core/src/main/java/org/tubo/exception/SpringExceptiomManagerImpl.java (from rev 88, trunk/modules/tubo-core/src/main/java/org/tubo/exception/springimpl/SpringExceptiomManagerImpl.java) =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/exception/SpringExceptiomManagerImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/exception/SpringExceptiomManagerImpl.java 2009-05-07 04:15:07 UTC (rev 109) @@ -0,0 +1,107 @@ +/** + * $Id$ + * $Revision$ + * $Date$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.exception; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.exception.BaseExceptionManagerImpl; +import org.tubo.exception.TuboException; +//spring +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.BeansException; + +import java.lang.reflect.InvocationTargetException; + + +/** + * Created: Sep 28, 2006, 12:42:01 PM + * Last Modification Date: $Date$ + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class SpringExceptiomManagerImpl extends BaseExceptionManagerImpl implements BeanFactoryAware { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(SpringExceptiomManagerImpl.class); + + /** Spring bean factory */ + private BeanFactory beanFactory = null; + + public void setBeanFactory(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + /** + * I take a bad design desision, base on the supposition that message and cause on a Throwable + * can be changed late. Because that and that spring can't create a bean instance based on + * Constructor parameters, then I need to recreate the bean instance based on Constructor. + * @param exceptionId + * @param message + * @param cause + * @return an exception instance identified by exceptionId + */ + public TuboException getException(String exceptionId, String message, Throwable cause) { + // + // get bean (TuboException) instance using default constructor + TuboException exception = null; + try { + exception = (TuboException)beanFactory.getBean(exceptionId); + } catch (BeansException e) { + log.error("Error when obtains bean (exception) from beanFactory", e) ; + // + // if there is an error when create bean, then use super default + exception = super.getException(exceptionId, message,cause); + // + // return + return exception; + } + // + // then now if message or cause are not null then I need recreate exception + try { + if (message!=null && cause!=null) { + exception = (TuboException)exception.getClass().getConstructor(new Class[] {String.class,Throwable.class}).newInstance(new Object[] {message,cause}); + } + else + if (message!=null && cause==null) { + exception = (TuboException)exception.getClass().getConstructor(new Class[] {String.class}).newInstance(new Object[] {message}); + } + else + if (message==null && cause!=null) { + exception = (TuboException)exception.getClass().getConstructor(new Class[] {Throwable.class}).newInstance(new Object[] {cause}); + } + } catch (InstantiationException e) { + log.error("Error, Exception can't be instanciated", e); + } catch (IllegalAccessException e) { + log.error("Error, accesing Exception", e); + } catch (InvocationTargetException e) { + log.error("Error, invocating constructor", e); + } catch (NoSuchMethodException e) { + log.error("Error, method not found", e); + } + // + // return exception + return exception; + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/exception/SpringExceptiomManagerImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 04:13:44
|
Revision: 108 http://tubo.svn.sourceforge.net/tubo/?rev=108&view=rev Author: maldito_orco Date: 2009-05-07 04:13:34 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Removed Paths: ------------- trunk/modules/tubo-core/src/main/java/org/tubo/exception/baseimpl/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 04:10:42
|
Revision: 107 http://tubo.svn.sourceforge.net/tubo/?rev=107&view=rev Author: maldito_orco Date: 2009-05-07 04:10:28 +0000 (Thu, 07 May 2009) Log Message: ----------- Move content Removed Paths: ------------- trunk/modules/tubo-core/src/main/java/org/tubo/exception/springimpl/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 03:26:52
|
Revision: 106 http://tubo.svn.sourceforge.net/tubo/?rev=106&view=rev Author: maldito_orco Date: 2009-05-07 03:26:43 +0000 (Thu, 07 May 2009) Log Message: ----------- Estable version Modified Paths: -------------- trunk/modules/tubo-core/pom.xml Modified: trunk/modules/tubo-core/pom.xml =================================================================== --- trunk/modules/tubo-core/pom.xml 2009-05-07 03:05:19 UTC (rev 105) +++ trunk/modules/tubo-core/pom.xml 2009-05-07 03:26:43 UTC (rev 106) @@ -27,7 +27,7 @@ <parent> <groupId>org.tubo</groupId> <artifactId>tubo</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.0-alpha2</version> </parent> <!-- - POM Version @@ -41,15 +41,29 @@ <packaging>jar</packaging> <name>Tubo Adapter - CORE</name> <!-- + - Build + --> + <build> + <plugins> + <!-- SITE PLUGIN --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <stagingDirectory>${basedir}/../../target/staged-site</stagingDirectory> + </configuration> + </plugin> + </plugins> + </build> + <!-- - Dependencies --> <dependencies> - <!-- logging --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> - <version>1.2.8</version> + <version>${log4j-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -57,7 +71,7 @@ <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> - <version>1.7</version> + <version>${commons-digester-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -65,7 +79,7 @@ <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> - <version>3.2</version> + <version>${commons-collections-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -73,7 +87,7 @@ <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> - <version>1.1</version> + <version>${commons-logging-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -81,7 +95,7 @@ <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> - <version>1.7.0</version> + <version>${commons-beanutils-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -89,7 +103,7 @@ <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> - <version>1.2</version> + <version>${commons-pool-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -97,7 +111,7 @@ <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> - <version>2.6.2</version> + <version>${xercesimpl-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -105,39 +119,23 @@ <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> - <version>2.0.2</version> + <version>${xml-apis-version}</version> <type>jar</type> <scope>compile</scope> </dependency> - <!-- spring-beans --> + <!-- spring --> <dependency> <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>2.0.1</version> + <artifactId>spring</artifactId> + <version>${spring-version}</version> <type>jar</type> <scope>compile</scope> </dependency> - <!-- spring-core --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>2.0.1</version> - <type>jar</type> - <scope>compile</scope> - </dependency> - <!-- spring-aop --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aop</artifactId> - <version>2.0.1</version> - <type>jar</type> - <scope>compile</scope> - </dependency> <!-- cglib - dependency from spring aop --> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> - <version>2.1_3</version> + <version>${cglib-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -145,7 +143,7 @@ <dependency> <groupId>velocity</groupId> <artifactId>velocity</artifactId> - <version>1.4</version> + <version>${velocity-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -153,7 +151,7 @@ <dependency> <groupId>backport-util-concurrent</groupId> <artifactId>backport-util-concurrent</artifactId> - <version>2.2</version> + <version>${backport-util-concurrent-version}</version> <type>jar</type> <scope>compile</scope> </dependency> @@ -161,10 +159,67 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>${junit-version}</version> <type>jar</type> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jms_1.1_spec</artifactId> + <version>1.1</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <!-- jee --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + + <!--dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId> + <version>1.1.1</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.jencks</groupId> + <artifactId>jencks</artifactId> + <version>2.0</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + <version>4.1.1</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-ra</artifactId> + <version>4.1.1</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>com.sun.genericra</groupId> + <artifactId>genericra</artifactId> + <version>1.7</version> + <type>jar</type> + <scope>compile</scope> + </dependency--> + </dependencies> <!-- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 03:05:27
|
Revision: 105 http://tubo.svn.sourceforge.net/tubo/?rev=105&view=rev Author: maldito_orco Date: 2009-05-07 03:05:19 +0000 (Thu, 07 May 2009) Log Message: ----------- Estable version Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/event/ trunk/modules/tubo-core/src/main/java/org/tubo/event/BaseEventImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/event/Event.java Added: trunk/modules/tubo-core/src/main/java/org/tubo/event/BaseEventImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/event/BaseEventImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/event/BaseEventImpl.java 2009-05-07 03:05:19 UTC (rev 105) @@ -0,0 +1,60 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.event; + +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * <p></p> + * <p/> + * Created: Feb 12, 2007, 5:29:35 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseEventImpl implements Event { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseEventImpl.class); + + private String action = null; + private long when = 0; + + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public long getWhen() { + return when; + } + + public void setWhen(long when) { + this.when = when; + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/event/BaseEventImpl.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/modules/tubo-core/src/main/java/org/tubo/event/Event.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/event/Event.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/event/Event.java 2009-05-07 03:05:19 UTC (rev 105) @@ -0,0 +1,42 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.event; + +/** + * <p></p> + * <p/> + * Created: Feb 12, 2007, 5:29:21 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public interface Event { + public static final String RCS_ID = "$Id$"; + + String getAction(); + + void setAction(String action); + + long getWhen(); + + void setWhen(long when); +} \ No newline at end of file Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/event/Event.java ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 03:02:39
|
Revision: 104 http://tubo.svn.sourceforge.net/tubo/?rev=104&view=rev Author: maldito_orco Date: 2009-05-07 03:02:34 +0000 (Thu, 07 May 2009) Log Message: ----------- Estable version Modified Paths: -------------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/Manager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractResourceManager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseResourceImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/ComponentManager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/echo/EchoComponent.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/Consumer.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerListener.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerLoader.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerManager.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumer.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerLoader.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerWorker.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocketlinereader/ServerSocketLineReaderConsumer.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowContextImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowExecutorImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/BaseFlowProcessorImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/FlowContext.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/flow/FlowExecutor.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/springimpl/SpringResourceManagerImpl.java Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/AdminComponent.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/Connection.java trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ConnectionManager.java Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/Manager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/Manager.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/Manager.java 2009-05-07 03:02:34 UTC (rev 104) @@ -31,7 +31,7 @@ * Created: Apr 1, 2006 2:47:50 PM * Last Modification Date: $Date$ * - * @author jvlio (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public interface Manager { Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractResourceManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractResourceManager.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseAbstractResourceManager.java 2009-05-07 03:02:34 UTC (rev 104) @@ -63,12 +63,12 @@ protected BaseAbstractResourceManager() throws TuboException { } - /** + /*TODO: erase * Constructor * @param configuration * @throws TuboResourceException */ - public BaseAbstractResourceManager(Configuration configuration) throws TuboException { + /*public BaseAbstractResourceManager(Configuration configuration) throws TuboException { // // call default constructor //this(); @@ -90,18 +90,18 @@ // finish on error throw e; } - } + }*/ - /** + /*TODO: erase * Hook method for inizialise Resource. * @throws TuboResourceException */ - protected abstract void initialize() throws TuboException; + /*protected abstract void initialize() throws TuboException;*/ - /** + /*TODO: erase * Setup components */ - protected void setup() throws TuboException { + /*protected void setup() throws TuboException { // setup singleton ExceptionManager ExceptionManager exceptionManager = getExceptionManager(); exceptionManager.setResourceManager(this); @@ -118,7 +118,7 @@ } // // TODO: miss components, connections ... - } + }*/ /** * Get Configuration object of this resource manager @@ -128,6 +128,11 @@ return configuration; } + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + /** * Return consumer manager identified by id * @param id ConsumerManager identificator Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseManagerImpl.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseManagerImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -37,14 +37,14 @@ * Created: Apr 5, 2006 9:16:42 PM * Last Modification Date: $Date$ * - * @author jvlio (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public class BaseManagerImpl implements Manager { public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(BaseManagerImpl.class); - /** Bean id */ + /** Manager ID (in spring Bean id) */ private String id = null; /** ResourceManager for this Manager */ @@ -71,7 +71,7 @@ } /** - * Get for the ResourceManager link to this Manager + * Get for the ResourceManager linked to this Manager * @return the ResourceManager for this Manager */ public ResourceManager getResourceManager() { Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseResourceImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseResourceImpl.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/baseimpl/BaseResourceImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -26,6 +26,10 @@ import org.apache.commons.logging.LogFactory; //tubo import org.tubo.resource.Resource; +import org.tubo.resource.ResourceManager; +import org.tubo.exception.TuboException; +//util +import java.util.Properties; /** * Created: Sep 3, 2006, 10:38:11 AM @@ -38,10 +42,51 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(BaseResourceImpl.class); + /** Resource ID */ private String id = null; - public String getId() { return id; } + /** ResourceManager reference */ + private ResourceManager resourceManager = null; + + /** Configuration properties */ + private Properties properties = new Properties(); + + + public String getId() { + return id; + } + public void setId(String id) { this.id = id; } + + /** + * Get for the ResourceManager linked to this Resource + * @return the ResourceManager for this Resource + */ + public ResourceManager getResourceManager() { + return resourceManager; + } + + /** + * Set for the ResourceManager for this Resource + * @param resourceManager the ResourceManager for this Resource + * @throws org.tubo.exception.TuboException + */ + public void setResourceManager(ResourceManager resourceManager) throws TuboException { + this.resourceManager = resourceManager; + } + + public Properties getProperties() { return properties; } + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String getProperty(String name) { + return properties.getProperty(name); + } + + public void setProperty(String name, String value) { + properties.setProperty(name,value); + } } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/BaseComponentImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; //tubo import org.tubo.resource.flow.FlowContext; +import org.tubo.resource.baseimpl.BaseResourceImpl; import org.tubo.exception.TuboException; /** @@ -35,16 +36,16 @@ * @author jvlio (jv...@us...) * @version $Revision$ */ -public class BaseComponentImpl implements Component { +public class BaseComponentImpl extends BaseResourceImpl implements Component { public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(BaseComponentImpl.class); - private String id = null; + /*private String id = null; public String getId() { return id; } public void setId(String id) { this.id = id; - } + }*/ public void execute(FlowContext flowContext) throws TuboException { log.warn(".execute() - Execute Not Implemented."); Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/ComponentManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/ComponentManager.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/ComponentManager.java 2009-05-07 03:02:34 UTC (rev 104) @@ -35,5 +35,6 @@ public interface ComponentManager extends Manager { public static final String RCS_ID = "$Id$"; + // TODO: sacar la exception Component getComponent() throws TuboException; } Added: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/AdminComponent.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/AdminComponent.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/AdminComponent.java 2009-05-07 03:02:34 UTC (rev 104) @@ -0,0 +1,93 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource.component.admin; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.component.BaseComponentImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.exception.TuboException; +import org.tubo.item.Item; + +/** + * <p> + * </p> + * + * <p> + * Created: Oct 21, 2006, 2:07:35 PM<br> + * Last Modification Date: $Date: 2006-11-08 11:02:18 -0300 (Wed, 08 Nov 2006) $ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision: 54 $ + */ +public class AdminComponent extends BaseComponentImpl { + public static final String RCS_ID = "$Id: EchoComponent.java 54 2006-11-08 14:02:18Z maldito_orco $"; + private static Log log = LogFactory.getLog(AdminComponent.class); + + public static final String ECHO_INPUT_PROPERTY = "ADMIN_INPUT"; + public static final String ECHO_OUTPUT_PROPERTY = "ADMIN_OUTPUT"; + + public static final String HELP_CMD = "help"; + public static final String SHUTDOWN_CMD = "shutdown"; + + public static final String WELCOME_MSG = "Welcome to Tubo Admin\n"; + public static final String EXIT_MSG = "have a nice day!"; + public static final String HELP_MSG = "help This message\n"+ + "shutdown Send a Shutdown message to Tubo and exit\n"+ + "exit Exit from this Admin\n"; + public static final String CMDNOTFOUND_MSG = "Command not found\n"; + + + public void welcome(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,WELCOME_MSG); + } + + public void exit(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,EXIT_MSG); + } + + public void execute(FlowContext flowContext) throws TuboException { + // + // get item + Item item = flowContext.getItem(); + // + // get input + String input = (String)item.getProperty(ECHO_INPUT_PROPERTY); + // + // trim input + input = input.trim(); + // + // check command + if (HELP_CMD.equals(input)) + item.setProperty(ECHO_OUTPUT_PROPERTY, HELP_MSG); + else if (SHUTDOWN_CMD.equals(input)) { + getResourceManager().getKernel().shutdown(); + item.setProperty(ECHO_OUTPUT_PROPERTY, ""); + } + else + if ("".equals(input) || "\n".equals(input) || "\r".equals(input)) + item.setProperty(ECHO_OUTPUT_PROPERTY, null); + else + item.setProperty(ECHO_OUTPUT_PROPERTY, CMDNOTFOUND_MSG); + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/admin/AdminComponent.java ___________________________________________________________________ Added: svn:executable + * Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/echo/EchoComponent.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/echo/EchoComponent.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/component/echo/EchoComponent.java 2009-05-07 03:02:34 UTC (rev 104) @@ -27,13 +27,17 @@ //tubo import org.tubo.resource.component.BaseComponentImpl; import org.tubo.resource.flow.FlowContext; -import org.tubo.resource.consumer.serversocketlinereader.ServerSocketLineReaderConsumer; import org.tubo.exception.TuboException; import org.tubo.item.Item; /** - * Created: Oct 21, 2006, 2:07:35 PM + * <p> + * </p> + * + * <p> + * Created: Oct 21, 2006, 2:07:35 PM<br> * Last Modification Date: $Date$ + * </p> * * @author maldito_orco (mal...@us...) * @version $Revision$ @@ -42,38 +46,27 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(EchoComponent.class); - public static final String ECHO_SAY_HELO_PROPERTY = "ECHO_SAY_HELO"; public static final String ECHO_INPUT_PROPERTY = "ECHO_INPUT"; public static final String ECHO_OUTPUT_PROPERTY = "ECHO_OUTPUT"; - public static final String ECHO_GOODBYE_FLAG_PROPERTY = "ECHO_GOODBYE_FLAG"; + + public void sayHelo(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,"helo"); + } + + public void sayGoodbye(FlowContext flowContext) throws TuboException { + flowContext.getItem().setProperty(ECHO_OUTPUT_PROPERTY,"goodbye"); + } + public void execute(FlowContext flowContext) throws TuboException { // // get item Item item = flowContext.getItem(); // - // if sey hello ... then .. say it :) - if (item.getProperty(ECHO_SAY_HELO_PROPERTY)!= null) { - item.setProperty(ECHO_OUTPUT_PROPERTY,"helo"); - } else { - // - // get input - String input = (String)item.getProperty(ECHO_INPUT_PROPERTY); - // - // check if not goodbye - if (!"bye".equals(input)) { - // - // if not, then put input in output - item.setProperty(ECHO_OUTPUT_PROPERTY,input); - } else { - // - // else say goodbye - item.setProperty(ECHO_OUTPUT_PROPERTY,"goodbye"); - // - // activate the goodbye flag - item.setProperty(ECHO_GOODBYE_FLAG_PROPERTY,"true"); - } - } - + // get input + String input = (String)item.getProperty(ECHO_INPUT_PROPERTY); + // + // put input in output + item.setProperty(ECHO_OUTPUT_PROPERTY,input); } } Added: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -0,0 +1,52 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource.connection; + +//log +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +//tubo +import org.tubo.resource.Resource; +import org.tubo.resource.baseimpl.BaseManagerImpl; + +/** + * <p></p> + * <p/> + * Created: Dec 26, 2006, 5:20:08 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public class BaseConnectionManagerImpl extends BaseManagerImpl implements ConnectionManager { + public static final String RCS_ID = "$Id$"; + private static Log log = LogFactory.getLog(BaseConnectionManagerImpl.class); + + /** + * A get resource wrapper for a Connection + * @return a Connection managed by this manager + */ + public Connection getConnection() { + Resource resource = get(); + Connection connection = (Connection)resource; + return connection; + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/BaseConnectionManagerImpl.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/Connection.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/Connection.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/Connection.java 2009-05-07 03:02:34 UTC (rev 104) @@ -0,0 +1,34 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource.connection; + +/** + * <p></p> + * <p/> + * Created: Dec 26, 2006, 5:15:00 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public interface Connection { + public static final String RCS_ID = "$Id$"; +} \ No newline at end of file Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/Connection.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ConnectionManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ConnectionManager.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ConnectionManager.java 2009-05-07 03:02:34 UTC (rev 104) @@ -0,0 +1,36 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.resource.connection; + +/** + * <p></p> + * <p/> + * Created: Dec 26, 2006, 5:16:58 PM <br> + * Last Modification Date: $Date$ + * </p> + * + * @author maldito_orco (mal...@us...) + * @version $Revision$ + */ +public interface ConnectionManager { + public static final String RCS_ID = "$Id$"; + + Connection getConnection(); +} \ No newline at end of file Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/resource/connection/ConnectionManager.java ___________________________________________________________________ Added: svn:executable + * Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -26,8 +26,9 @@ import org.apache.commons.logging.LogFactory; //item import org.tubo.item.Item; -import org.tubo.item.BaseItemImpl; import org.tubo.resource.baseimpl.BaseResourceImpl; +import org.tubo.resource.flow.FlowContext; +import org.tubo.event.Event; /** * Created: Jun 21, 2005 6:59:48 AM @@ -48,18 +49,37 @@ */ public BaseConsumerImpl() {} + private ConsumerListener getListener() { return listener; } public void setListener(ConsumerListener listener) { this.listener = listener; } /** + * This method must stop Consumer execution + */ + public void stop() { + } + + /** * This method is a template method with the life cycle of the consumption process. + * + * @param eventAction * @param consumedRawData - * @return + * @return FlowContext used on this life cycle */ - protected Item processConsume(Object consumedRawData) { + protected FlowContext doConsumerLifeCycle(String eventAction, Object consumedRawData) { // + // create new Event + Event event = createEvent(); + // + // set default event stuff + event.setAction(eventAction); + event.setWhen(System.currentTimeMillis()); + // + // setup event (hook) + initializeEvent(event); + // // create new item Item item = createItem(); // @@ -67,35 +87,92 @@ item.setConsumedRawData(consumedRawData); // // setup item (hook) - setupItem(item); + initializeItem(item); // + // dispatch event + FlowContext flowContext = dispatchOriginFlowEvent(event,item); + // + // return + return flowContext; + } + + + /** + * Create a new Item instance using ResourceManager + * + * @return a Item instance + */ + protected Event createEvent() { + Event event = getResourceManager().getNewEvent(); + return event; + } + + /** + * LifeCycle Hook used by subclasses to do a custom Event setup + * + * @param event Event to be configured + */ + protected void initializeEvent(Event event) {} + + /** + * Create a new Item instance using ResourceManager + * @return a Item instance + */ + protected Item createItem() { + Item item = getResourceManager().getNewItem(); + return item; + } + + /** + * LifeCycle Hook used by subclasses to make a custom Event setup + * + * @param item Item to be configured + */ + protected void initializeItem(Item item) {} + + + protected FlowContext dispatchOriginFlowEvent(Event event,Item item) { + // + // create FlowContext + FlowContext flowContext = createFlowContext(); + // + // set default FlowContext stuff + flowContext.setOriginEvent(event); + flowContext.setItem(item); + flowContext.setOriginator(this); + // // actions pre call listener (hook) - preOnConsume(item); + preOriginFlowEvent(flowContext); // // call listener and delegate process - getListener().onConsume(this,item); + getListener().onOriginFlowEvent(flowContext); // // actions post call listener (hook) - postOnConsume(item); + postOriginFlowEvent(flowContext); // - // return - return item; + // return flowContext + return flowContext; } /** - * Create a new Item instance. Default is BaseItemImpl + * Create a new FlowContext instance using ResourceManager * @return a Item instance */ - protected Item createItem() { - return new BaseItemImpl(); + protected FlowContext createFlowContext() { + FlowContext flowContext = getResourceManager().getNewFlowContext(); + return flowContext; } - protected void setupItem(Item item) { - } + /** + * LifeCycle Hook used by subclasses to execute pre event actions + * @param flowContext FlowContext to be used on this event + */ + protected void preOriginFlowEvent(FlowContext flowContext) {} - protected void preOnConsume(Item item) { - } + /** + * LifeCycle Hook used by subclasses to execute post event actions + * @param flowContext FlowContext used on this event + */ + protected void postOriginFlowEvent(FlowContext flowContext) {} - protected void postOnConsume(Item item) { - } } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/BaseConsumerManagerImpl.java 2009-05-07 03:02:34 UTC (rev 104) @@ -27,20 +27,19 @@ //tubo import org.tubo.resource.baseimpl.BaseManagerImpl; import org.tubo.resource.Resource; -import org.tubo.resource.flow.FlowExecutor; -import org.tubo.exception.TuboResourceException; -import org.tubo.exception.TuboConsumerException; import org.tubo.exception.TuboException; -import org.tubo.item.Item; /** - * Created: Sep 3, 2006, 11:38:12 AM + * <p></p> + * <p/> + * Created: Sep 3, 2006, 11:38:12 AM <br> * Last Modification Date: $Date$ + * </p> * * @author maldito_orco (mal...@us...) * @version $Revision$ */ -public class BaseConsumerManagerImpl extends BaseManagerImpl implements ConsumerManager,ConsumerListener { +public class BaseConsumerManagerImpl extends BaseManagerImpl implements ConsumerManager { public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(BaseConsumerManagerImpl.class); @@ -71,34 +70,7 @@ loader.load(this); } - /** - * This method is a callback from consumers - * @param consumer - * @param item - */ - public void onConsume(Consumer consumer, Item item) { - if (log.isTraceEnabled()) log.trace(".onConsumer() Enter"); - // - // set consumer default properties - item.setProperty(Item.CONSUMER_PROPERTY,consumer); - item.setProperty(Item.CONSUMER_ID_PROPERTY,getId()); - // - // get a flow processor manager - FlowExecutor flowExecutor = null; - try { - // FIXME: do something with exception cases ... log only isn't a solution! - flowExecutor = getResourceManager().getFlowExecutor(); - } catch (TuboException e) { - log.error("Error getting flow!", e); - } - // - // execute flow - // FIXME: do something with exception cases ... log only isn't a solution! - try { - flowExecutor.execute(getId(), item); - } catch (TuboException e) { - log.error("Error executing flow", e); - } - if (log.isTraceEnabled()) log.trace(".onConsumer() Leave"); + public void unload() throws TuboException { + loader.unload(this); } } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/Consumer.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/Consumer.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/Consumer.java 2009-05-07 03:02:34 UTC (rev 104) @@ -35,4 +35,9 @@ String getId(); void setListener(ConsumerListener listener); + + /** + * This method must stop Consumer execution + */ + void stop(); } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerListener.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerListener.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerListener.java 2009-05-07 03:02:34 UTC (rev 104) @@ -21,17 +21,21 @@ */ package org.tubo.resource.consumer; -import org.tubo.item.Item; +//tubo +import org.tubo.resource.flow.FlowContext; /** - * Created: Jun 17, 2005 6:02:57 AM + * <p></p> + * <p/> + * Created: Jun 17, 2005 6:02:57 AM <br> * Last Modification Date: $Date$ + * </p> * - * @author jlorenzo (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public interface ConsumerListener { public static final String RCS_ID = "$Id$"; - void onConsume(Consumer consumer, Item item); + void onOriginFlowEvent(FlowContext flowContext); } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerLoader.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerLoader.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerLoader.java 2009-05-07 03:02:34 UTC (rev 104) @@ -35,4 +35,6 @@ public static final String RCS_ID = "$Id$"; void load(ConsumerManager manager) throws TuboConsumerException; + + void unload(ConsumerManager manager) throws TuboConsumerException; } \ No newline at end of file Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerManager.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/ConsumerManager.java 2009-05-07 03:02:34 UTC (rev 104) @@ -39,4 +39,6 @@ Consumer getConsumer() throws TuboException; void load() throws TuboException; + + void unload() throws TuboException; } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumer.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumer.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumer.java 2009-05-07 03:02:34 UTC (rev 104) @@ -43,44 +43,28 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(ServerSocketConsumer.class); + public static final String NEW_CONNECTION_EVENT = "NEW_CONNECTION_EVENT"; + + /** + * <p> + * This method is executed from ServerSocketConsumerWorker. Is used like + * entry point to consumer. + * + * The socket is closed on worker. + * </p> + * + * @param socket A new socket open from client + * @throws TuboConsumerException + */ public void process(Socket socket) throws TuboConsumerException { - InputStream is = null; - OutputStream os = null; try { - // - // get input - is = socket.getInputStream(); - // - // get output - os = socket.getOutputStream(); - // - // process streams - process(is,os); - } catch (IOException e) { - throw new TuboConsumerException("Error processing socket streams",e); - } finally { - if (os!=null) - try { - // - // close os - os.flush(); - os.close(); - } catch (IOException e) { - log.info("Error closing OutputStream",e); - } - if (is!=null) - try { - // - // close is - is.close(); - } catch (IOException e) { - log.info("Error closing InputStream",e); - } + doConsumerLifeCycle(NEW_CONNECTION_EVENT,socket); + } catch (Exception e) { + throw getResourceManager().getExceptionManager().getException(3500,e); } } - public void process(InputStream is, OutputStream os) throws TuboConsumerException { - log.warn(".process(InputStream,OutputStream) - Invoking empty ServerSocketConsumer process"); - } - + /** + * This method is used to + */ } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerLoader.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerLoader.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerLoader.java 2009-05-07 03:02:34 UTC (rev 104) @@ -30,6 +30,9 @@ import org.tubo.exception.TuboConsumerException; //util import java.util.StringTokenizer; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; //concurrent import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService; import edu.emory.mathcs.backport.java.util.concurrent.Executors; @@ -46,6 +49,12 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(ServerSocketConsumerLoader.class); + /** */ + ExecutorService executor = null; + + /** ServerSocketWorker list */ + private List workers = new ArrayList(); + public void load(ConsumerManager manager) throws TuboConsumerException { // // get ports to listen @@ -63,7 +72,7 @@ throw new TuboConsumerException("Ports not found"); // // create Workers ejecutor - ExecutorService executor = Executors.newCachedThreadPool(); + executor = Executors.newCachedThreadPool(); while (tokenizer.hasMoreElements()) { // // get port @@ -80,12 +89,29 @@ // create worker for server socket accept ServerSocketWorker worker = new ServerSocketWorker(manager,port); // - // execute worker - try { - executor.execute(worker); - } catch (Exception e) { - //FIXME: Add a exception management at this point + // if not fail worker inicialization + if (!worker.isError()) { + // + // store this worker + workers.add(worker); + // + // execute worker + try { + executor.execute(worker); + } catch (Exception e) { + //FIXME: Add a exception management at this point + } } } } + + public void unload(ConsumerManager manager) throws TuboConsumerException { + for (Iterator it=workers.iterator(); it.hasNext();) { + ServerSocketWorker worker = (ServerSocketWorker)it.next(); + worker.stop(); + } + executor.shutdown(); + + } + } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerWorker.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerWorker.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketConsumerWorker.java 2009-05-07 03:02:34 UTC (rev 104) @@ -59,11 +59,28 @@ this.manager = manager; } + public void stop() { + // + // call consumer stop + consumer.stop(); + // + // close socket + if (socket!=null) + try { + log.info(".stop() - Closing socket. A exception socket can be thowing above."); + socket.close(); + } catch (IOException e) { + log.warn(".stop() - Error closing client socket"); + } finally { + socket = null; + } + } + /** * TODO */ public void run() { - log.info(".run Begin processing socket thread="+Thread.currentThread().getName()); + if (log.isDebugEnabled()) log.debug(".run() - Begin Consumer Worker thread="+Thread.currentThread().getName()+" consumer-family="+manager.getId()+" consumer="+consumer.getId()); // // process socket try { @@ -77,17 +94,17 @@ try { socket.close(); } catch (IOException e) { - log.warn("Error closing client socket",e); + log.warn(".run() - Error closing client socket",e); } // // restore consumer to pool try { manager.restore(consumer); } catch (TuboResourceException e) { - log.error("Error tring to restore consumer to manager",e); + log.error(".run() - Error tring to restore consumer to manager",e); } } - log.info(".run End processing socket thread="+Thread.currentThread().getName()); + if (log.isDebugEnabled()) log.debug(".run() - Done Consumer Worker thread="+Thread.currentThread().getName()); } } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocket/ServerSocketWorker.java 2009-05-07 03:02:34 UTC (rev 104) @@ -31,14 +31,20 @@ //net import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketTimeoutException; +import java.net.SocketException; //io import java.io.IOException; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; +import java.nio.channels.IllegalBlockingModeException; //concurrent import edu.emory.mathcs.backport.java.util.concurrent.Executors; import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService; /** - * This class listen for new ServerSocket connections, whea a new connection + * This class listen for new ServerSocket connections, when a new connection * arrives, take a thead from the pool and a consumer and instance a * WorkerProcessor for work with the new connection/consumer. * @@ -52,11 +58,9 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(ServerSocketWorker.class); - public static final int STATE_LOADING = 0; public static final int STATE_RUNNING = 1; - public static final int STATE_UNLOADING = 2; - public static final int STATE_STOPED = 3; - public static final int STATE_ERROR = 4; + public static final int STATE_STOPED = 2; + public static final int STATE_ERROR = 3; public static final int DEFAULT_MAX_CAPACITY = 1; @@ -73,7 +77,10 @@ /** TODO */ private TuboConsumerLoaderException lastException = null; + /** ServerSocketConsumerWorker list */ + private List workers = new ArrayList(); + /** * TODO * @param manager @@ -87,12 +94,22 @@ // create ServerSocket try { serverSocket = new ServerSocket(this.port); + log.info("Server Socket Consumer "+manager.getId()+" is listening on port "+this.port); } catch (IOException e) { state = STATE_ERROR; lastException = new TuboConsumerLoaderException("Error creating ServerSocket",e); throw lastException; } // + // set wait time for client connection when timeout is expired + // accept() throw a SocketTimeoutException + try { + serverSocket.setSoTimeout(5*1000); + } catch (SocketException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("Error setting accept Timeout",e); + } + // // get maxCapacity String smaxCapacity = manager.getProperty("maxCapacity"); int maxCapacity; @@ -113,46 +130,116 @@ } /** + * Return running flag state + * @return state of running flag + */ + public boolean isRunning() { + return state==STATE_RUNNING; + } + + /** + * Return error flag state + * @return state of running flag + */ + public boolean isError() { + return state==STATE_ERROR; + } + + public void stop() { + // + // set STOPED state + state = STATE_STOPED; + // + // stop consumer workers + for (Iterator it=workers.iterator(); it.hasNext();) { + ServerSocketConsumerWorker consumerWorker = (ServerSocketConsumerWorker)it.next(); + consumerWorker.stop(); + } + + + // + // shutdown executor threads + executor.shutdown(); + } + + /** * TODO */ public void run() { // - // set running state - state = STATE_RUNNING; - // - // worker cycle - while (state<=STATE_RUNNING) { + // if inicialization is ok, then run worker + if (!isError()) { // - // wait for client - Socket socket = null; - try { - socket = serverSocket.accept(); - } catch (IOException e) { - state = STATE_ERROR; - lastException = new TuboConsumerLoaderException("Error accepting socket",e); - break; - } + // set RUNNING state + state = STATE_RUNNING; // - // get a consumer for this socket (client) - ServerSocketConsumer consumer = null; - try { - consumer = (ServerSocketConsumer)manager.getConsumer(); - } catch (TuboResourceException e) { - state = STATE_ERROR; - lastException = new TuboConsumerLoaderException("Error getting consumer",e); - break; - } + // iterate waiting for coonnections and firing workers for processing + do { + // + // wait for client connection + Socket socket = null; + try { + socket = serverSocket.accept(); + } catch(SocketTimeoutException e) { + log.trace(" TIMEOUT: ID="+manager.getId()); + // + // if timeout is throw then chek if is running and accept again + continue; + } catch(SocketException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("Error on TCP",e); + break; + } catch(IOException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("IO Error",e); + break; + } catch(SecurityException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("Security Error",e); + break; + } catch(IllegalBlockingModeException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("Blocking Mode Error",e); + break; + } + + if (isRunning()) { + // + // get a consumer for this socket (client) + ServerSocketConsumer consumer = null; + try { + consumer = (ServerSocketConsumer)manager.getConsumer(); + } catch (TuboResourceException e) { + state = STATE_ERROR; + lastException = new TuboConsumerLoaderException("Error getting consumer",e); + break; + } + // + // create a process thread for this socket + ServerSocketConsumerWorker consumerWorker = new ServerSocketConsumerWorker(socket,consumer,manager); + // + // store this worker + workers.add(consumerWorker); + // + // runs process for this socket + try { + executor.execute(consumerWorker); + } catch (Exception e) { + //FIXME: Add a exception management at this point + log.error(".run - ERROR! FIXME: Add a exception management at this point"); + } + // + // consumer resource return to manager in worker + } + } while(isRunning()); // - // create a process thread for this socket - ServerSocketConsumerWorker consumerWorker = new ServerSocketConsumerWorker(socket,consumer,manager); - // - // runs process for this socket - try { - executor.execute(consumerWorker); - } catch (Exception e) { - //FIXME: Add a exception management at this point - } + // finish log + log.trace(".run() - Finishing worker for ID="+manager.getId()); } + else { + log.error(".run() - Trying to run a instance on Error"); + throw lastException; + } } Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocketlinereader/ServerSocketLineReaderConsumer.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocketlinereader/ServerSocketLineReaderConsumer.java 2009-05-07 02:59:19 UTC (rev 103) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/consumer/serversocketlinereader/ServerSocketLineReaderConsumer.java 2009-05-07 03:02:34 UTC (rev 104) @@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; //tubo import org.tubo.resource.consumer.serversocket.ServerSocketConsumer; +import org.tubo.resource.flow.FlowContext; import org.tubo.exception.TuboConsumerException; import org.tubo.item.Item; //io @@ -35,21 +36,35 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; +//net +import java.net.Socket; +//util +import java.util.Map; +import java.util.StringTokenizer; +import java.util.HashMap; /** * <p> * This class is a Consumer Component based on ServerSocket. - * When the connection is established and the streams are opened in - * ServerSocketConsumer, then that class invoke the hook - * process(InputStream,OutputStream). This method have the resposability of - * read and write from streams and call (or not) to consume life cycle invoking - * the hook processConsume(Object).</p> + * When the connection is established on ServerSocketConsumerWorker this class + * call process(Socket) on ServerSocketConsumer which is overwited by this + * class. + * When a process(Socket) is call, streams are opened and delegate procesing + * to process(InputStream,OutputStream). In this method tree event are throw: + * <li> + * <ul>NEW_CONNECTION_EVENT: which can be used to sey hello :)</ul> + * <ul>READ_LINE_EVENT: which is throw when a new line of text is read</ul> + * <ul>GOODBYE_EVENT: which is throw when the text read matches with 'goodbye-words' property</ul> + * </li> + * </p> * <p> - * The method process(InputStream,OutputStream) is override by this class, + * The method process(Socket) is override by this class, * </p> * - * Created: Oct 19, 2006, 6:12:44 PM + * <p> + * Created: Oct 19, 2006, 6:12:44 PM<br> * Last Modification Date: $Date$ + * </p> * * @author maldito_orco (mal...@us...) * @version $Revision$ @@ -58,25 +73,103 @@ public static final String RCS_ID = "$Id$"; private static Log log = LogFactory.getLog(ServerSocketLineReaderConsumer.class); - public static final String SERVERSOCKET_LINE_READER_SAY_HELO_PROPERTY = "SSLINEREADER_SAY_HELO"; public static final String SERVERSOCKET_LINE_READER_INPUT_PROPERTY = "SSLINEREADER_INPUT"; public static final String SERVERSOCKET_LINE_READER_OUTPUT_PROPERTY = "SSLINEREADER_OUTPUT"; - public static final String SERVERSOCKET_LINE_READER_GOODBYE_FLAG_PROPERTY = "SSLINEREADER_GOODBYE_FLAG"; + public static final String READ_LINE_EVENT = "READ_LINE_EVENT"; + public static final String GOODBYE_EVENT = "GOODBYE_EVENT"; + /** Singleton item for this consumer thread */ private Item item = null; private PrintWriter out = null; private BufferedReader in = null; + private Map goodbyeWords = null; + + /** Running flag*/ + private boolean running = false; + + + public boolean isRunning() { + return running; + } + + + public void stop() { + // + // set false running flag + running = false; + } + /** - * Hook used by ServerSocketConsumer to delegate the preocesing of streams. + * <p> + * Override normal ServerSocketConsumer behavior. On this implementation + * obtains in and out streams. Delegate the stream procesing on other + * method. + * </p> * + * @param socket A new socket open from client + * @throws TuboConsumerException When geting InputStream or OutputStream from socket + */ + public void process(Socket socket) throws TuboConsumerException { + InputStream is = null; + OutputStream os = null; + try { + // + // set true running flag + running = true; + // + // get input + is = socket.getInputStream(); + // + // get output + os = socket.getOutputStream(); + // + // process streams + process(is,os); + } catch (IOException e) { + throw getResourceManager().getExceptionManager().getException(3510,e); + } finally { + // + // set false running flag + running = false; + if (os!=null) + try { + // + // close os + os.flush(); + os.close(); + } catch (IOException e) { + log.info("Error closing OutputStream",e); + } + if (is!=null) + try { + // + // close is + is.close(); + } catch (IOException e) { + log.info("Error closing InputStream",e); + } + } + } + + + /** + * <p> + * Streams Procesing. + * </p> + * * @param is Socket input * @param os Socket output * @throws TuboConsumerException */ - public void process (InputStream is, OutputStream os) throws TuboConsumerException { - + public void process(InputStream is, OutputStream os) throws TuboConsumerException { + // + // load goodbye words (cut condition) + if (goodbyeWords==null) + loadGoodbyeWords(); + // + // process is try { // // create in @@ -86,23 +179,23 @@ out = new PrintWriter(os, true); // // ey! can you say HELO!!! - // calling consume life cycle to - processConsume(null); + // calling consume life cycle with newconnection event + doConsumerLifeCycle(NEW_CONNECTION_EVENT,null); // //read/write cycle String inputLine; boolean goodbye =false; - while ((!goodbye) && ((inputLine = in.readLine()) != null)) { + while (isRunning() && (!goodbye) && ((inputLine = in.readLine()) != null)) { // - // consume life cycle - Item _item = processConsume(inputLine); - // - // if goodbye - if (_item.getProperty(SERVERSOCKET_LINE_READER_GOODBYE_FLAG_PROPERTY)!=null) - goodbye = true; + // check cut condition + if (goodbyeWords.containsKey(inputLine)) { + goodbye=true; + doConsumerLifeCycle(GOODBYE_EVENT, inputLine); + } else + doConsumerLifeCycle(READ_LINE_EVENT, inputLine); } } catch (IOException e) { - throw new TuboConsumerException("Error processing streams",e); + throw getResourceManager().getExceptionManager().getException(3511,e); } finally { if (out!=null) try { @@ -116,9 +209,10 @@ /** * Override this method to create only one item. - * To create the item the super functionality is used. + * To create the item the super method is used. * * @return The item + * TODO: move this behavior to BaseConsumerImpl... */ protected Item createItem() { if (item == null) @@ -128,38 +222,30 @@ } /** - * Hook used by consume life cycle to setup the item. - * In this consumer, this method is used to clean item because the item is - * a singleton. + * Hook from consumer life cycle called before listener execution. + * This method have the responsability of set input line like a + * item property. * - * @param item The item + * @param flowContext The flowContext */ - protected void setupItem(Item item) { - // - // clean item properties - item.getProperties().clear(); - // - // if rawData is null then you can sey helo! - if (item.getConsumedRawData()==null) { - item.setProperty(SERVERSOCKET_LINE_READER_SAY_HELO_PROPERTY,""); - } else { - // - // if not null then is the input line - String inputLine = (String)item.getConsumedRawData(); + protected void preOriginFlowEvent(FlowContext flowContext) { + if (!NEW_CONNECTION_EVENT.equals(flowContext.getOriginEvent().getAction())) { + String inputLine = (String)flowContext.getItem().getConsumedRawData(); + if (inputLine!=null) item.setProperty(SERVERSOCKET_LINE_READER_INPUT_PROPERTY,inputLine); } } /** - * Hook from consumer life cycle called when the listener finish execution. + * Hook from consumer life cycle called after listener execution. * - * @param item The item + * @param flowContext The item */ - protected void postOnConsume(Item item) { + protected void postOriginFlowEvent(FlowContext flowContext) { // // get output - String outputLine = (String)item.getProperty(SERVERSOCKET_LINE_READER_OUTPUT_PROPERTY); + String outputLine = (String)flowContext.getItem().getProperty(SERVERSOCKET_LINE_READER_OUTPUT_PROPERTY); // // print output if (outputLine != null) @@ -167,4 +253,37 @@ // // TODO: EXEPTIONS!!!! } + + /** + * Load goodbyeWords Map. This words are cut condition for read/write cycle. + * + * @throws TuboConsumerException This exception is throw if property 'goodbye-words' is not configured or with a wrong format. + */ + private void loadGoodbyeWords() throws TuboConsumerException { + goodbyeWords = new HashMap(); + // + // get goodbye words + String goodbyeWordsString = super.getProperty("goodbye-words"); + // + // check if nu... [truncated message content] |
From: <mal...@us...> - 2009-05-07 02:59:23
|
Revision: 103 http://tubo.svn.sourceforge.net/tubo/?rev=103&view=rev Author: maldito_orco Date: 2009-05-07 02:59:19 +0000 (Thu, 07 May 2009) Log Message: ----------- Add flow management Modified Paths: -------------- trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java Modified: trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java 2009-05-07 02:48:27 UTC (rev 102) +++ trunk/modules/tubo-core/src/main/java/org/tubo/resource/ResourceManager.java 2009-05-07 02:59:19 UTC (rev 103) @@ -24,10 +24,14 @@ //tubo import org.tubo.resource.consumer.ConsumerManager; import org.tubo.resource.flow.FlowExecutor; +import org.tubo.resource.flow.FlowContext; import org.tubo.resource.component.ComponentManager; import org.tubo.configuration.def.Configuration; import org.tubo.exception.ExceptionManager; import org.tubo.exception.TuboException; +import org.tubo.item.Item; +import org.tubo.event.Event; +import org.tubo.kernel.Kernel; //util import java.util.List; @@ -36,7 +40,7 @@ * Created: Jan 25, 2006 5:58:17 PM * Last Modification Date: $Date$ * - * @author jvlio (jv...@us...) + * @author maldito_orco (mal...@us...) * @version $Revision$ */ public interface ResourceManager { @@ -49,6 +53,27 @@ Configuration getConfiguration() throws TuboException; /** + * Create a new Item instance + * @return new Item instance + * @throws TuboException + */ + Item getNewItem() throws TuboException; + + /** + * Create a new Event instance + * @return new Event instance + * @throws TuboException + */ + Event getNewEvent() throws TuboException; + + /** + * Create a new FlowContext instance + * @return new FlowContext instance + * @throws TuboException + */ + FlowContext getNewFlowContext() throws TuboException; + + /** * Get exception manager * @return Exception manager */ @@ -86,4 +111,13 @@ * @return a ComponentManager identified by id */ ComponentManager getComponentManager(String id) throws TuboException; + + /** + * <p> + * Get kernel instance + * </p> + * @return kernel instance + * @throws org.tubo.exception.TuboException + */ + Kernel getKernel() throws TuboException; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mal...@us...> - 2009-05-07 02:48:29
|
Revision: 102 http://tubo.svn.sourceforge.net/tubo/?rev=102&view=rev Author: maldito_orco Date: 2009-05-07 02:48:27 +0000 (Thu, 07 May 2009) Log Message: ----------- Added Paths: ----------- trunk/modules/tubo-core/src/main/java/org/tubo/exception/TuboFlowException.java Added: trunk/modules/tubo-core/src/main/java/org/tubo/exception/TuboFlowException.java =================================================================== --- trunk/modules/tubo-core/src/main/java/org/tubo/exception/TuboFlowException.java (rev 0) +++ trunk/modules/tubo-core/src/main/java/org/tubo/exception/TuboFlowException.java 2009-05-07 02:48:27 UTC (rev 102) @@ -0,0 +1,52 @@ +/** + * $Id$ + * + * ========================================================================= + * + * Copyright 2005 Tubo + * + * 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.tubo.exception; + +//log + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Created: Jun 23, 2005 6:28:55 AM + * Last Modification Date: $Date: 2006-10-19 12:11:35 -0300 (Thu, 19 Oct 2006) $ + * + * @author jvlio (jv...@us...) + * @version $Revision: 17 $ + */ +public class TuboFlowException extends TuboException { + public static final String RCS_ID = "$Id: TuboResourceException.java 17 2006-10-19 15:11:35Z maldito_orco $"; + private static Log log = LogFactory.getLog(TuboFlowException.class); + + public TuboFlowException() { + } + + public TuboFlowException(String message) { + super(message); + } + + public TuboFlowException(Throwable cause) { + super(cause); + } + + public TuboFlowException(String message, Throwable cause) { + super(message, cause); + } +} Property changes on: trunk/modules/tubo-core/src/main/java/org/tubo/exception/TuboFlowException.java ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |